Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

more renamings

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 "class_id_DEPRECATED.h"
21ObjectListDefinitionID(BspEntity, CL_BSP_ENTITY);
22CREATE_FACTORY(BspEntity);
23
24
25/**
26 * constructs and loads a BspEntity from a XML-element
27 * @param root the XML-element to load from
28 */
29BspEntity::BspEntity(const TiXmlElement* root)
30{
31  this->init();
32
33  if (root != NULL)
34    this->loadParams(root);
35}
36
37
38/**
39 * standard deconstructor
40 */
41BspEntity::~BspEntity ()
42{
43  if( this->bspManager != NULL)
44    delete this->bspManager;
45}
46
47
48
49/**
50 * initializes the BspEntity
51 * @todo change this to what you wish
52 */
53void BspEntity::init()
54{
55  this->registerObject(this, BspEntity::_objectList);
56
57  this->bspManager = NULL;
58
59  this->name_handle = registerVarId( new SynchronizeableString( &this->name, &this->name_write, "name", PERMISSION_MASTER_SERVER ) );
60
61  this->setSynchronized( true );
62}
63
64
65void BspEntity::setName(const std::string& name)
66{
67  PRINTF(0)("+++++++++++ LOADING NAME %s\n", name.c_str());
68
69  this->name = name;
70
71  // Check wether file exists....
72  if ( File(ResourceManager::getFullName(name)).exists()  ) {
73
74    this->bspManager = new BspManager(this);
75
76    if(this->bspManager->load(name.c_str(), 0.1f) == -1 ) {
77      this->bspManager = NULL;
78
79    } else {
80      this->toList(OM_ENVIRON); // Success!!!
81    }
82  } else {
83    this->bspManager = NULL;
84    this->toList(OM_DEAD);
85  }
86}
87
88
89/**
90 * loads a BspEntity from a XML-element
91 * @param root the XML-element to load from
92 * @todo make the class Loadable
93 */
94void BspEntity::loadParams(const TiXmlElement* root)
95{
96  // all the clases this Entity is directly derived from must be called in this way, to load all settings.
97  // WorldEntity::loadParam(root);
98
99  LoadParam(root, "Name", this, BspEntity, setName)
100  .describe("Sets the of the BSP file.");
101
102  /*  LoadParam(root, "Scale", this, BSpEntity, setScale)
103        .describe("Sets the scale factore of the bsp level.");
104  */
105
106  /**
107   * @todo: make the class Loadable
108   */
109}
110
111
112/**
113 * advances the BspEntity about time seconds
114 * @param time the Time to step
115 */
116void BspEntity::tick(float time)
117{
118  this->bspManager->tick(time);
119}
120
121
122/**
123 * draws this worldEntity
124 */
125void BspEntity::draw () const
126{
127  this->bspManager->draw();
128}
129
130
131/**
132 *
133 *
134 */
135void BspEntity::collidesWith (WorldEntity* entity, const Vector& location)
136{}
137
138void BspEntity::varChangeHandler( std::list< int > & id )
139{
140  if ( std::find( id.begin(), id.end(), this->name_handle ) != id.end() )
141  {
142    this->setName( this->name_write );
143  }
144}
Note: See TracBrowser for help on using the repository browser.