Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/world_entities/bsp_entity.cc @ 9727

Last change on this file since 9727 was 9727, checked in by bensch, 18 years ago

orxonox/new_class_id: new Executor construct, that is much more typesafe, faster, and easier to extend…

Also changed the LoadParam process, and adapted ScriptEngine calls

Then at the end, some missing headers appeared, and appended them to all the cc-files again.

File size: 2.9 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Claudio Botta
13   co-programmer: ...
14*/
15
16#include "bsp_entity.h"
17#include "util/loading/resource_manager.h"
18#include "util/loading/resource_manager.h"
19
20#include "debug.h"
21
22#include "class_id_DEPRECATED.h"
23ObjectListDefinitionID(BspEntity, CL_BSP_ENTITY);
24CREATE_FACTORY(BspEntity);
25
26
27/**
28 * constructs and loads a BspEntity from a XML-element
29 * @param root the XML-element to load from
30 */
31BspEntity::BspEntity(const TiXmlElement* root)
32{
33  this->init();
34
35  if (root != NULL)
36    this->loadParams(root);
37}
38
39
40/**
41 * standard deconstructor
42 */
43BspEntity::~BspEntity ()
44{
45  if( this->bspManager != NULL)
46    delete this->bspManager;
47}
48
49
50
51/**
52 * initializes the BspEntity
53 * @todo change this to what you wish
54 */
55void BspEntity::init()
56{
57  this->registerObject(this, BspEntity::_objectList);
58
59  this->bspManager = NULL;
60
61  this->name_handle = registerVarId( new SynchronizeableString( &this->name, &this->name_write, "name", PERMISSION_MASTER_SERVER ) );
62
63  this->setSynchronized( true );
64}
65
66
67void BspEntity::setName(const std::string& name)
68{
69  PRINTF(0)("+++++++++++ LOADING NAME %s\n", name.c_str());
70
71  this->name = name;
72
73  // Check wether file exists....
74  if ( File(ResourceManager::getFullName(name)).exists()  ) {
75
76    this->bspManager = new BspManager(this);
77
78    if(this->bspManager->load(name.c_str(), 0.1f) == -1 ) {
79      this->bspManager = NULL;
80
81    } else {
82      this->toList(OM_ENVIRON); // Success!!!
83    }
84  } else {
85    this->bspManager = NULL;
86    this->toList(OM_DEAD);
87  }
88}
89
90
91/**
92 * loads a BspEntity from a XML-element
93 * @param root the XML-element to load from
94 * @todo make the class Loadable
95 */
96void BspEntity::loadParams(const TiXmlElement* root)
97{
98  // all the clases this Entity is directly derived from must be called in this way, to load all settings.
99  // WorldEntity::loadParam(root);
100
101  LoadParam(root, "Name", this, BspEntity, setName)
102  .describe("Sets the of the BSP file.");
103
104  /*  LoadParam(root, "Scale", this, BSpEntity, setScale)
105        .describe("Sets the scale factore of the bsp level.");
106  */
107
108  /**
109   * @todo: make the class Loadable
110   */
111}
112
113
114/**
115 * advances the BspEntity about time seconds
116 * @param time the Time to step
117 */
118void BspEntity::tick(float time)
119{
120  this->bspManager->tick(time);
121}
122
123
124/**
125 * draws this worldEntity
126 */
127void BspEntity::draw () const
128{
129  this->bspManager->draw();
130}
131
132
133/**
134 *
135 *
136 */
137void BspEntity::collidesWith (WorldEntity* entity, const Vector& location)
138{}
139
140void BspEntity::varChangeHandler( std::list< int > & id )
141{
142  if ( std::find( id.begin(), id.end(), this->name_handle ) != id.end() )
143  {
144    this->setName( this->name_write );
145  }
146}
Note: See TracBrowser for help on using the repository browser.