[2036] | 1 | |
---|
| 2 | |
---|
[4570] | 3 | /* |
---|
[2036] | 4 | orxonox - the future of 3D-vertical-scrollers |
---|
| 5 | |
---|
| 6 | Copyright (C) 2004 orx |
---|
| 7 | |
---|
| 8 | This program is free software; you can redistribute it and/or modify |
---|
| 9 | it under the terms of the GNU General Public License as published by |
---|
| 10 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 11 | any later version. |
---|
| 12 | |
---|
| 13 | ### File Specific: |
---|
| 14 | main-programmer: Patrick Boenzli |
---|
[2190] | 15 | co-programmer: Christian Meyer |
---|
[2036] | 16 | */ |
---|
[5300] | 17 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
[2036] | 18 | |
---|
| 19 | #include "world_entity.h" |
---|
[5208] | 20 | #include "shell_command.h" |
---|
[5143] | 21 | |
---|
[9869] | 22 | #include "util/loading/resource_manager.h" |
---|
| 23 | #include "resource_obj.h" |
---|
[8490] | 24 | #include "md2/md2Model.h" |
---|
| 25 | #include "md3/md3_model.h" |
---|
| 26 | |
---|
[8724] | 27 | #include "aabb_tree_node.h" |
---|
| 28 | |
---|
[7193] | 29 | #include "util/loading/load_param.h" |
---|
[10088] | 30 | #include "loading/load_param_xml.h" |
---|
| 31 | #include "util/loading/factory.h" |
---|
| 32 | |
---|
[4682] | 33 | #include "obb_tree.h" |
---|
[3608] | 34 | |
---|
[8974] | 35 | #include "elements/glgui_energywidget.h" |
---|
[10101] | 36 | #include "elements/glgui_energywidgetvertical.h" |
---|
[6430] | 37 | |
---|
[6002] | 38 | #include "state.h" |
---|
[7014] | 39 | #include "camera.h" |
---|
[6002] | 40 | |
---|
[7927] | 41 | #include "collision_handle.h" |
---|
[8190] | 42 | #include "collision_event.h" |
---|
[8777] | 43 | #include "game_rules.h" |
---|
| 44 | #include "kill.h" |
---|
[9869] | 45 | #include "debug.h" |
---|
[7927] | 46 | |
---|
[10088] | 47 | #include "track/track.h" |
---|
| 48 | |
---|
[9869] | 49 | #include "projectiles/projectile.h" |
---|
[7927] | 50 | |
---|
[5208] | 51 | SHELL_COMMAND(model, WorldEntity, loadModel) |
---|
[6430] | 52 | ->describe("sets the Model of the WorldEntity") |
---|
[7711] | 53 | ->defaultValues("models/ships/fighter.obj", 1.0f); |
---|
[5208] | 54 | |
---|
[6424] | 55 | SHELL_COMMAND(debugEntity, WorldEntity, debugWE); |
---|
[5208] | 56 | |
---|
[9869] | 57 | |
---|
| 58 | ObjectListDefinition(WorldEntity); |
---|
[2043] | 59 | /** |
---|
[4836] | 60 | * Loads the WordEntity-specific Part of any derived Class |
---|
[5498] | 61 | * |
---|
| 62 | * @param root: Normally NULL, as the Derived Entities define a loadParams Function themeselves, |
---|
| 63 | * that can calls WorldEntities loadParams for itself. |
---|
| 64 | */ |
---|
[6430] | 65 | WorldEntity::WorldEntity() |
---|
| 66 | : Synchronizeable() |
---|
[2190] | 67 | { |
---|
[9869] | 68 | this->registerObject(this, WorldEntity::_objectList); |
---|
[4597] | 69 | |
---|
[4682] | 70 | this->obbTree = NULL; |
---|
[8724] | 71 | this->aabbNode = NULL; |
---|
[6700] | 72 | this->healthWidget = NULL; |
---|
| 73 | this->healthMax = 1.0f; |
---|
| 74 | this->health = 1.0f; |
---|
[8190] | 75 | this->damage = 0.0f; // no damage dealt by a default entity |
---|
[6695] | 76 | this->scaling = 1.0f; |
---|
[4261] | 77 | |
---|
[6695] | 78 | /* OSOLETE */ |
---|
| 79 | this->bVisible = true; |
---|
| 80 | this->bCollide = true; |
---|
| 81 | |
---|
[6142] | 82 | this->objectListNumber = OM_INIT; |
---|
[9003] | 83 | this->lastObjectListNumber = OM_INIT; |
---|
[6142] | 84 | |
---|
[8190] | 85 | // reset all collision handles to NULL == unsubscribed state |
---|
| 86 | for(int i = 0; i < CREngine::CR_NUMBER; ++i) |
---|
| 87 | this->collisionHandles[i] = NULL; |
---|
| 88 | this->bReactive = false; |
---|
[9003] | 89 | this->bOnGround = false; |
---|
[8190] | 90 | |
---|
[10088] | 91 | // Track of this entity |
---|
| 92 | this->entityTrack = NULL; |
---|
| 93 | |
---|
[8190] | 94 | // registering default reactions: |
---|
[9869] | 95 | this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /* WorldEntity::staticClassID(), */ Projectile::staticClassID()); |
---|
[8190] | 96 | |
---|
[6142] | 97 | this->toList(OM_NULL); |
---|
[9235] | 98 | |
---|
[9656] | 99 | registerVar( new SynchronizeableString( &this->md2TextureFileName, &this->md2TextureFileName, "md2TextureFileName", PERMISSION_MASTER_SERVER ) ); |
---|
| 100 | modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName", PERMISSION_MASTER_SERVER ) ); |
---|
| 101 | scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling", PERMISSION_MASTER_SERVER ) ); |
---|
| 102 | list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list", PERMISSION_MASTER_SERVER ) ); |
---|
[9235] | 103 | |
---|
[9656] | 104 | health_handle = registerVarId( new SynchronizeableFloat( &this->health, &this->health_write, "health", PERMISSION_MASTER_SERVER ) ); |
---|
| 105 | healthMax_handle = registerVarId( new SynchronizeableFloat( &this->healthMax, &this->healthMax_write, "maxHealth", PERMISSION_MASTER_SERVER ) ); |
---|
[2190] | 106 | } |
---|
[2043] | 107 | |
---|
| 108 | /** |
---|
[4836] | 109 | * standard destructor |
---|
[2043] | 110 | */ |
---|
[2190] | 111 | WorldEntity::~WorldEntity () |
---|
[2036] | 112 | { |
---|
[7125] | 113 | State::getObjectManager()->toList(this, OM_INIT); |
---|
| 114 | |
---|
| 115 | // Delete the model (unregister it with the ResourceManager) |
---|
| 116 | for (unsigned int i = 0; i < this->models.size(); i++) |
---|
| 117 | this->setModel(NULL, i); |
---|
| 118 | |
---|
[5498] | 119 | // Delete the obbTree |
---|
[5302] | 120 | if( this->obbTree != NULL) |
---|
[4814] | 121 | delete this->obbTree; |
---|
[5994] | 122 | |
---|
[6700] | 123 | if (this->healthWidget != NULL) |
---|
| 124 | delete this->healthWidget; |
---|
[8190] | 125 | |
---|
| 126 | this->unsubscribeReaction(); |
---|
[3531] | 127 | } |
---|
| 128 | |
---|
[5498] | 129 | /** |
---|
| 130 | * loads the WorldEntity Specific Parameters. |
---|
| 131 | * @param root: the XML-Element to load the Data From |
---|
| 132 | */ |
---|
[4436] | 133 | void WorldEntity::loadParams(const TiXmlElement* root) |
---|
| 134 | { |
---|
[5498] | 135 | // Do the PNode loading stuff |
---|
[6512] | 136 | PNode::loadParams(root); |
---|
[5498] | 137 | |
---|
[6222] | 138 | LoadParam(root, "md2texture", this, WorldEntity, loadMD2Texture) |
---|
[6430] | 139 | .describe("the fileName of the texture, that should be loaded onto this world-entity. (must be relative to the data-dir)") |
---|
[7198] | 140 | .defaultValues(""); |
---|
[6222] | 141 | |
---|
[4436] | 142 | // Model Loading |
---|
[5671] | 143 | LoadParam(root, "model", this, WorldEntity, loadModel) |
---|
[6430] | 144 | .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)") |
---|
[7198] | 145 | .defaultValues("", 1.0f, 0); |
---|
[6430] | 146 | |
---|
[10088] | 147 | // Entity Attributes |
---|
[6700] | 148 | LoadParam(root, "maxHealth", this, WorldEntity, setHealthMax) |
---|
| 149 | .describe("The Maximum health that can be loaded onto this entity") |
---|
[7198] | 150 | .defaultValues(1.0f); |
---|
[6430] | 151 | |
---|
[6700] | 152 | LoadParam(root, "health", this, WorldEntity, setHealth) |
---|
| 153 | .describe("The Health the WorldEntity has at this moment") |
---|
[7198] | 154 | .defaultValues(1.0f); |
---|
[9656] | 155 | |
---|
| 156 | LoadParam(root, "list", this, WorldEntity, toListS); |
---|
[10088] | 157 | |
---|
| 158 | |
---|
| 159 | // Track |
---|
| 160 | LoadParamXML(root, "Track", this, WorldEntity, addTrack) |
---|
| 161 | .describe("creates and adds a track to this WorldEntity"); |
---|
[4436] | 162 | } |
---|
| 163 | |
---|
[6222] | 164 | |
---|
[3531] | 165 | /** |
---|
[10088] | 166 | * this functions adds a track to this workd entity. This can be usefull, if you like this WE to follow a some waypoints. |
---|
| 167 | * here the track is created and further initializing left for the Track itself |
---|
| 168 | */ |
---|
| 169 | void WorldEntity::addTrack(const TiXmlElement* root) |
---|
| 170 | { |
---|
[10096] | 171 | |
---|
| 172 | this->entityTrack = new Track(); |
---|
| 173 | this->setParent(this->entityTrack->getTrackNode()); |
---|
| 174 | this->entityTrack->getTrackNode()->setParentMode(PNODE_ALL); |
---|
[10088] | 175 | LOAD_PARAM_START_CYCLE(root, element); |
---|
| 176 | { |
---|
| 177 | PRINTF(4)("element is: %s\n", element->Value()); |
---|
| 178 | Factory::fabricate(element); |
---|
| 179 | } |
---|
| 180 | LOAD_PARAM_END_CYCLE(element); |
---|
[10096] | 181 | |
---|
| 182 | |
---|
[10088] | 183 | } |
---|
| 184 | |
---|
| 185 | |
---|
| 186 | /** |
---|
[4885] | 187 | * loads a Model onto a WorldEntity |
---|
[4836] | 188 | * @param fileName the name of the model to load |
---|
[5057] | 189 | * @param scaling the Scaling of the model |
---|
[7711] | 190 | * |
---|
| 191 | * FIXME |
---|
| 192 | * @todo: separate the obb tree generation from the model |
---|
[7221] | 193 | */ |
---|
[7711] | 194 | void WorldEntity::loadModel(const std::string& fileName, float scaling, unsigned int modelNumber, unsigned int obbTreeDepth) |
---|
[4261] | 195 | { |
---|
[6695] | 196 | this->modelLODName = fileName; |
---|
[6424] | 197 | this->scaling = scaling; |
---|
[7954] | 198 | |
---|
| 199 | std::string name = fileName; |
---|
| 200 | |
---|
[9869] | 201 | if ( name.find( Resources::ResourceManager::getInstance()->mainGlobalPath().name() ) == 0 ) |
---|
[7954] | 202 | { |
---|
[9869] | 203 | name.erase(Resources::ResourceManager::getInstance()->mainGlobalPath().name().size()); |
---|
[7954] | 204 | } |
---|
| 205 | |
---|
| 206 | this->modelFileName = name; |
---|
| 207 | |
---|
[7221] | 208 | if (!fileName.empty()) |
---|
[6142] | 209 | { |
---|
[6430] | 210 | // search for the special character # in the LoadParam |
---|
[7221] | 211 | if (fileName.find('#') != std::string::npos) |
---|
[6222] | 212 | { |
---|
[7221] | 213 | PRINTF(4)("Found # in %s... searching for LOD's\n", fileName.c_str()); |
---|
| 214 | std::string lodFile = fileName; |
---|
| 215 | unsigned int offset = lodFile.find('#'); |
---|
[6720] | 216 | for (unsigned int i = 0; i < 3; i++) |
---|
[6005] | 217 | { |
---|
[7221] | 218 | lodFile[offset] = 48+(int)i; |
---|
[9869] | 219 | if (Resources::ResourceManager::getInstance()->checkFileInMainPath( lodFile)) |
---|
[6222] | 220 | this->loadModel(lodFile, scaling, i); |
---|
[6005] | 221 | } |
---|
[6222] | 222 | return; |
---|
| 223 | } |
---|
[6720] | 224 | if (this->scaling <= 0.0) |
---|
[6424] | 225 | { |
---|
[7193] | 226 | PRINTF(1)("YOU GAVE ME A CRAPY SCALE resetting to 1.0\n"); |
---|
[6720] | 227 | this->scaling = 1.0; |
---|
[6424] | 228 | } |
---|
[9869] | 229 | /// LOADING AN OBJ FILE |
---|
[7221] | 230 | if(fileName.find(".obj") != std::string::npos) |
---|
[6222] | 231 | { |
---|
[7221] | 232 | PRINTF(4)("fetching OBJ file: %s\n", fileName.c_str()); |
---|
[9869] | 233 | StaticModel* model = new StaticModel(); |
---|
| 234 | *model = ResourceOBJ(fileName, this->scaling); |
---|
| 235 | if (model->getVertexCount() > 0) |
---|
| 236 | { |
---|
| 237 | this->setModel(model, modelNumber); |
---|
| 238 | if( modelNumber == 0 /* FIXME && !this->isA(CL_WEAPON) */) |
---|
| 239 | this->buildObbTree(obbTreeDepth); |
---|
| 240 | } |
---|
[7221] | 241 | else |
---|
[9869] | 242 | delete model; |
---|
[6222] | 243 | } |
---|
[9869] | 244 | /// LOADING AN MD2-model |
---|
[7221] | 245 | else if(fileName.find(".md2") != std::string::npos) |
---|
[6222] | 246 | { |
---|
[7221] | 247 | PRINTF(4)("fetching MD2 file: %s\n", fileName.c_str()); |
---|
[7055] | 248 | Model* m = new MD2Model(fileName, this->md2TextureFileName, this->scaling); |
---|
[6430] | 249 | //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0); |
---|
[6222] | 250 | this->setModel(m, 0); |
---|
[7068] | 251 | |
---|
| 252 | if( m != NULL) |
---|
[7711] | 253 | this->buildObbTree(obbTreeDepth); |
---|
[6222] | 254 | } |
---|
[9869] | 255 | /// LOADING AN MD3-MODEL. |
---|
[9235] | 256 | else if(fileName.find(".md3") != std::string::npos) |
---|
[8490] | 257 | { |
---|
| 258 | PRINTF(4)("fetching MD3 file: %s\n", fileName.c_str()); |
---|
[9869] | 259 | // Model* m = new md3::MD3Model(fileName, this->scaling); |
---|
| 260 | // this->setModel(m, 0); |
---|
[8490] | 261 | |
---|
[9869] | 262 | // if( m != NULL) |
---|
| 263 | // this->buildObbTree(obbTreeDepth); |
---|
[8490] | 264 | } |
---|
[4732] | 265 | } |
---|
| 266 | else |
---|
[6341] | 267 | { |
---|
[5995] | 268 | this->setModel(NULL); |
---|
[6341] | 269 | } |
---|
[4261] | 270 | } |
---|
| 271 | |
---|
[5061] | 272 | /** |
---|
[5994] | 273 | * sets a specific Model for the Object. |
---|
| 274 | * @param model The Model to set |
---|
| 275 | * @param modelNumber the n'th model in the List to get. |
---|
| 276 | */ |
---|
| 277 | void WorldEntity::setModel(Model* model, unsigned int modelNumber) |
---|
| 278 | { |
---|
[5995] | 279 | if (this->models.size() <= modelNumber) |
---|
| 280 | this->models.resize(modelNumber+1, NULL); |
---|
| 281 | |
---|
| 282 | if (this->models[modelNumber] != NULL) |
---|
[6004] | 283 | { |
---|
[9869] | 284 | delete this->models[modelNumber]; |
---|
[5994] | 285 | } |
---|
[6222] | 286 | |
---|
[5995] | 287 | this->models[modelNumber] = model; |
---|
[5994] | 288 | } |
---|
| 289 | |
---|
| 290 | |
---|
| 291 | /** |
---|
[5061] | 292 | * builds the obb-tree |
---|
| 293 | * @param depth the depth to calculate |
---|
| 294 | */ |
---|
[7711] | 295 | bool WorldEntity::buildObbTree(int depth) |
---|
[5061] | 296 | { |
---|
[9494] | 297 | if( this->obbTree != NULL) |
---|
| 298 | { |
---|
[5428] | 299 | delete this->obbTree; |
---|
[9494] | 300 | this->obbTree = NULL; |
---|
| 301 | } |
---|
[5428] | 302 | |
---|
[5995] | 303 | if (this->models[0] != NULL) |
---|
[7711] | 304 | this->obbTree = new OBBTree(depth, models[0]->getModelInfo(), this); |
---|
[5428] | 305 | else |
---|
| 306 | { |
---|
[7711] | 307 | PRINTF(1)("could not create obb-tree, because no model was loaded yet\n"); |
---|
[5428] | 308 | this->obbTree = NULL; |
---|
| 309 | return false; |
---|
| 310 | } |
---|
[8724] | 311 | |
---|
| 312 | |
---|
| 313 | // create the axis aligned bounding box |
---|
| 314 | if( this->aabbNode != NULL) |
---|
| 315 | { |
---|
| 316 | delete this->aabbNode; |
---|
| 317 | this->aabbNode = NULL; |
---|
| 318 | } |
---|
| 319 | |
---|
[9869] | 320 | if( this->models[0] != NULL) |
---|
| 321 | { |
---|
[8724] | 322 | this->aabbNode = new AABBTreeNode(); |
---|
| 323 | this->aabbNode->spawnBVTree(this->models[0]); |
---|
| 324 | } |
---|
[9494] | 325 | else |
---|
| 326 | { |
---|
| 327 | PRINTF(1)("could not create aabb bounding box, because no model was loaded yet\n"); |
---|
| 328 | this->aabbNode = NULL; |
---|
| 329 | return false; |
---|
| 330 | } |
---|
[8724] | 331 | return true; |
---|
[5061] | 332 | } |
---|
[5057] | 333 | |
---|
[7927] | 334 | |
---|
[6142] | 335 | /** |
---|
[7927] | 336 | * subscribes this world entity to a collision reaction |
---|
| 337 | * @param type the type of reaction to subscribe to |
---|
[8190] | 338 | * @param target1 a filter target (classID) |
---|
| 339 | */ |
---|
[9869] | 340 | void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1) |
---|
[8190] | 341 | { |
---|
| 342 | this->subscribeReaction(type); |
---|
| 343 | |
---|
| 344 | // add the target filter |
---|
| 345 | this->collisionHandles[type]->addTarget(target1); |
---|
| 346 | } |
---|
| 347 | |
---|
| 348 | |
---|
| 349 | /** |
---|
| 350 | * subscribes this world entity to a collision reaction |
---|
| 351 | * @param type the type of reaction to subscribe to |
---|
| 352 | * @param target1 a filter target (classID) |
---|
| 353 | */ |
---|
[9869] | 354 | void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2) |
---|
[8190] | 355 | { |
---|
| 356 | this->subscribeReaction(type); |
---|
| 357 | |
---|
| 358 | // add the target filter |
---|
| 359 | this->collisionHandles[type]->addTarget(target1); |
---|
| 360 | this->collisionHandles[type]->addTarget(target2); |
---|
| 361 | } |
---|
| 362 | |
---|
| 363 | |
---|
| 364 | /** |
---|
| 365 | * subscribes this world entity to a collision reaction |
---|
| 366 | * @param type the type of reaction to subscribe to |
---|
| 367 | * @param target1 a filter target (classID) |
---|
| 368 | */ |
---|
[9869] | 369 | void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3) |
---|
[8190] | 370 | { |
---|
| 371 | this->subscribeReaction(type); |
---|
| 372 | |
---|
| 373 | // add the target filter |
---|
| 374 | this->collisionHandles[type]->addTarget(target1); |
---|
| 375 | this->collisionHandles[type]->addTarget(target2); |
---|
| 376 | this->collisionHandles[type]->addTarget(target3); |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | |
---|
| 380 | /** |
---|
| 381 | * subscribes this world entity to a collision reaction |
---|
| 382 | * @param type the type of reaction to subscribe to |
---|
| 383 | * @param target1 a filter target (classID) |
---|
| 384 | */ |
---|
[9869] | 385 | void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3, const ClassID& target4) |
---|
[8190] | 386 | { |
---|
| 387 | this->subscribeReaction(type); |
---|
| 388 | |
---|
| 389 | // add the target filter |
---|
| 390 | this->collisionHandles[type]->addTarget(target1); |
---|
| 391 | this->collisionHandles[type]->addTarget(target2); |
---|
| 392 | this->collisionHandles[type]->addTarget(target3); |
---|
| 393 | this->collisionHandles[type]->addTarget(target4); |
---|
| 394 | } |
---|
| 395 | |
---|
| 396 | |
---|
| 397 | /** |
---|
| 398 | * subscribes this world entity to a collision reaction |
---|
| 399 | * @param type the type of reaction to subscribe to |
---|
[7927] | 400 | * @param nrOfTargets number of target filters |
---|
| 401 | * @param ... the targets as classIDs |
---|
| 402 | */ |
---|
[8190] | 403 | void WorldEntity::subscribeReaction(CREngine::CRType type) |
---|
| 404 | { |
---|
[9869] | 405 | if( this->collisionHandles[type] != NULL) |
---|
| 406 | { |
---|
[8190] | 407 | PRINTF(2)("Registering for a CollisionReaction already subscribed to! Skipping\n"); |
---|
| 408 | return; |
---|
| 409 | } |
---|
[7927] | 410 | |
---|
[8190] | 411 | this->collisionHandles[type] = CREngine::getInstance()->subscribeReaction(this, type); |
---|
[7927] | 412 | |
---|
[8190] | 413 | // now there is at least one collision reaction subscribed |
---|
| 414 | this->bReactive = true; |
---|
| 415 | } |
---|
| 416 | |
---|
| 417 | |
---|
[7927] | 418 | /** |
---|
[8190] | 419 | * unsubscribes a specific reaction from the worldentity |
---|
| 420 | * @param type the reaction to unsubscribe |
---|
| 421 | */ |
---|
| 422 | void WorldEntity::unsubscribeReaction(CREngine::CRType type) |
---|
| 423 | { |
---|
| 424 | if( this->collisionHandles[type] == NULL) |
---|
| 425 | return; |
---|
| 426 | |
---|
| 427 | CREngine::getInstance()->unsubscribeReaction(this->collisionHandles[type]); |
---|
| 428 | this->collisionHandles[type] = NULL; |
---|
| 429 | |
---|
| 430 | // check if there is still any handler registered |
---|
| 431 | for(int i = 0; i < CREngine::CR_NUMBER; ++i) |
---|
| 432 | { |
---|
| 433 | if( this->collisionHandles[i] != NULL) |
---|
| 434 | { |
---|
| 435 | this->bReactive = true; |
---|
| 436 | return; |
---|
| 437 | } |
---|
| 438 | } |
---|
| 439 | this->bReactive = false; |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | |
---|
| 443 | /** |
---|
| 444 | * unsubscribes all collision reactions |
---|
| 445 | */ |
---|
| 446 | void WorldEntity::unsubscribeReaction() |
---|
| 447 | { |
---|
| 448 | for( int i = 0; i < CREngine::CR_NUMBER; i++) |
---|
| 449 | this->unsubscribeReaction((CREngine::CRType)i); |
---|
| 450 | |
---|
| 451 | // there are no reactions subscribed from now on |
---|
| 452 | this->bReactive = false; |
---|
| 453 | } |
---|
| 454 | |
---|
| 455 | |
---|
| 456 | /** |
---|
| 457 | * registers a new collision event to this world entity |
---|
| 458 | * @param entityA entity of the collision |
---|
| 459 | * @param entityB entity of the collision |
---|
| 460 | * @param bvA colliding bounding volume of entityA |
---|
| 461 | * @param bvB colliding bounding volume of entityA |
---|
| 462 | */ |
---|
| 463 | bool WorldEntity::registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB) |
---|
| 464 | { |
---|
[9406] | 465 | PRINTF(5)("registering collision of type: %s vs %s\n", entityA->getClassCName(), entityB->getClassCName()); |
---|
[8190] | 466 | // is there any handler listening? |
---|
| 467 | if( !this->bReactive) |
---|
| 468 | return false; |
---|
| 469 | |
---|
| 470 | // get a collision event |
---|
| 471 | CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject(); |
---|
| 472 | assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h |
---|
[8894] | 473 | c->collide(COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB); |
---|
[8190] | 474 | |
---|
| 475 | for( int i = 0; i < CREngine::CR_NUMBER; ++i) |
---|
| 476 | if( this->collisionHandles[i] != NULL) |
---|
| 477 | this->collisionHandles[i]->registerCollisionEvent(c); |
---|
[8316] | 478 | return true; |
---|
[8190] | 479 | } |
---|
| 480 | |
---|
| 481 | |
---|
| 482 | /** |
---|
| 483 | * registers a new collision event to this woeld entity |
---|
| 484 | * @param entity the entity that collides |
---|
| 485 | * @param plane it stands on |
---|
| 486 | * @param position it collides on the plane |
---|
| 487 | */ |
---|
[8894] | 488 | bool WorldEntity::registerCollision(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall) |
---|
[8190] | 489 | { |
---|
| 490 | // is there any handler listening? |
---|
| 491 | if( !this->bReactive) |
---|
| 492 | return false; |
---|
| 493 | |
---|
| 494 | // get a collision event |
---|
| 495 | CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject(); |
---|
| 496 | assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h |
---|
[8894] | 497 | c->collide(type, entity, groundEntity, normal, position, bInWall); |
---|
[8190] | 498 | |
---|
| 499 | for( int i = 0; i < CREngine::CR_NUMBER; ++i) |
---|
| 500 | if( this->collisionHandles[i] != NULL) |
---|
| 501 | this->collisionHandles[i]->registerCollisionEvent(c); |
---|
[8316] | 502 | return true; |
---|
[8190] | 503 | } |
---|
| 504 | |
---|
| 505 | |
---|
| 506 | /** |
---|
[6142] | 507 | * @brief moves this entity to the List OM_List |
---|
| 508 | * @param list the list to set this Entity to. |
---|
| 509 | * |
---|
| 510 | * this is the same as a call to State::getObjectManager()->toList(entity , list); |
---|
| 511 | * directly, but with an easier interface. |
---|
| 512 | * |
---|
| 513 | * @todo inline this (peut etre) |
---|
| 514 | */ |
---|
| 515 | void WorldEntity::toList(OM_LIST list) |
---|
| 516 | { |
---|
| 517 | State::getObjectManager()->toList(this, list); |
---|
| 518 | } |
---|
[5061] | 519 | |
---|
[9656] | 520 | void WorldEntity::toListS(const std::string& listName) |
---|
| 521 | { |
---|
| 522 | OM_LIST id = ObjectManager::StringToOMList(listName); |
---|
| 523 | if (id != OM_NULL) |
---|
| 524 | this->toList(id); |
---|
| 525 | else |
---|
| 526 | PRINTF(2)("List %s not found\n", listName.c_str()); |
---|
| 527 | } |
---|
| 528 | |
---|
| 529 | |
---|
[8037] | 530 | void WorldEntity::toReflectionList() |
---|
| 531 | { |
---|
| 532 | State::getObjectManager()->toReflectionList( this ); |
---|
| 533 | } |
---|
[6142] | 534 | |
---|
[8037] | 535 | void removeFromReflectionList() |
---|
| 536 | { |
---|
[9869] | 537 | /// TODO |
---|
| 538 | /// State::getObject |
---|
[8037] | 539 | } |
---|
[6142] | 540 | |
---|
[4261] | 541 | /** |
---|
[4885] | 542 | * sets the character attributes of a worldentity |
---|
[4836] | 543 | * @param character attributes |
---|
[4885] | 544 | * |
---|
| 545 | * these attributes don't have to be set, only use them, if you need them |
---|
[2043] | 546 | */ |
---|
[5498] | 547 | //void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr) |
---|
| 548 | //{} |
---|
[2036] | 549 | |
---|
[3583] | 550 | |
---|
[2043] | 551 | /** |
---|
[5029] | 552 | * this function is called, when two entities collide |
---|
| 553 | * @param entity: the world entity with whom it collides |
---|
| 554 | * |
---|
| 555 | * Implement behaviour like damage application or other miscellaneous collision stuff in this function |
---|
| 556 | */ |
---|
| 557 | void WorldEntity::collidesWith(WorldEntity* entity, const Vector& location) |
---|
| 558 | { |
---|
[5498] | 559 | /** |
---|
| 560 | * THIS IS A DEFAULT COLLISION-Effect. |
---|
| 561 | * IF YOU WANT TO CREATE A SPECIFIC COLLISION ON EACH OBJECT |
---|
| 562 | * USE:: |
---|
| 563 | * if (entity->isA(CL_WHAT_YOU_ARE_LOOKING_FOR)) { printf "dothings"; }; |
---|
| 564 | * |
---|
| 565 | * You can always define a default Action.... don't be affraid just test it :) |
---|
| 566 | */ |
---|
[9406] | 567 | // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassCName(), entity->getClassCName(), location.x, location.y, location.z); |
---|
[5029] | 568 | } |
---|
| 569 | |
---|
[2043] | 570 | |
---|
| 571 | /** |
---|
[8186] | 572 | * this function is called, when two entities collide |
---|
| 573 | * @param entity: the world entity with whom it collides |
---|
| 574 | * |
---|
| 575 | * Implement behaviour like damage application or other miscellaneous collision stuff in this function |
---|
| 576 | */ |
---|
| 577 | void WorldEntity::collidesWithGround(const Vector& location) |
---|
| 578 | { |
---|
[9406] | 579 | PRINTF(0)("BSP_GROUND: %s collides \n", this->getClassCName() ); |
---|
[8186] | 580 | } |
---|
| 581 | |
---|
| 582 | void WorldEntity::collidesWithGround(const Vector& feet, const Vector& ray_1, const Vector& ray_2) |
---|
| 583 | { |
---|
[8190] | 584 | |
---|
[9406] | 585 | // PRINTF(0)("BSP_GROUND: Player collides \n", this->getClassCName() ); |
---|
[8190] | 586 | |
---|
[8186] | 587 | Vector v = this->getAbsDirX(); |
---|
[8490] | 588 | v.x *= 10.1; |
---|
| 589 | v.y *= 10.1; |
---|
| 590 | v.z *= 10.1; |
---|
| 591 | Vector u = Vector(0.0,-20.0,0.0); |
---|
[8190] | 592 | |
---|
[8490] | 593 | |
---|
| 594 | if(!(this->getAbsCoor().x == ray_2.x && this->getAbsCoor().y == ray_2.y && this->getAbsCoor().z == ray_2.z) ) |
---|
[8186] | 595 | { |
---|
[8190] | 596 | |
---|
[9869] | 597 | this->setAbsCoor(ray_2 - v); |
---|
[8490] | 598 | |
---|
[8186] | 599 | } |
---|
[9869] | 600 | else |
---|
[8186] | 601 | { |
---|
| 602 | if(ray_1.x == this->getAbsCoor().x + v.x && ray_1.y == this->getAbsCoor().y + v.y + 0.1 && ray_1.z ==this->getAbsCoor().z + v.z) |
---|
| 603 | { |
---|
[8190] | 604 | this->setAbsCoor(feet -u ); |
---|
[8186] | 605 | } |
---|
[8190] | 606 | |
---|
| 607 | this->setAbsCoor(ray_2 - v); |
---|
| 608 | |
---|
[8186] | 609 | } |
---|
[8490] | 610 | |
---|
| 611 | |
---|
[8186] | 612 | } |
---|
| 613 | |
---|
| 614 | /** |
---|
[5498] | 615 | * this is called immediately after the Entity has been constructed, initialized and then Spawned into the World |
---|
[4885] | 616 | * |
---|
[5498] | 617 | */ |
---|
[3229] | 618 | void WorldEntity::postSpawn () |
---|
[6430] | 619 | {} |
---|
[2043] | 620 | |
---|
[3583] | 621 | |
---|
[2043] | 622 | /** |
---|
[6959] | 623 | * this method is called by the world if the WorldEntity leaves the game |
---|
[5498] | 624 | */ |
---|
[6959] | 625 | void WorldEntity::leaveWorld () |
---|
[6430] | 626 | {} |
---|
[2043] | 627 | |
---|
[3583] | 628 | |
---|
[2190] | 629 | /** |
---|
[7085] | 630 | * resets the WorldEntity to its initial values. eg. used for multiplayer games: respawning |
---|
| 631 | */ |
---|
| 632 | void WorldEntity::reset() |
---|
[9235] | 633 | { |
---|
| 634 | this->setHealth( this->getHealthMax() ); |
---|
| 635 | } |
---|
[7085] | 636 | |
---|
| 637 | /** |
---|
[4836] | 638 | * this method is called every frame |
---|
| 639 | * @param time: the time in seconds that has passed since the last tick |
---|
[4885] | 640 | * |
---|
| 641 | * Handle all stuff that should update with time inside this method (movement, animation, etc.) |
---|
[2043] | 642 | */ |
---|
[4570] | 643 | void WorldEntity::tick(float time) |
---|
[10096] | 644 | { |
---|
| 645 | } |
---|
[3583] | 646 | |
---|
[5498] | 647 | |
---|
[3583] | 648 | /** |
---|
[4836] | 649 | * the entity is drawn onto the screen with this function |
---|
[4885] | 650 | * |
---|
| 651 | * This is a central function of an entity: call it to let the entity painted to the screen. |
---|
| 652 | * Just override this function with whatever you want to be drawn. |
---|
[3365] | 653 | */ |
---|
[5500] | 654 | void WorldEntity::draw() const |
---|
[3803] | 655 | { |
---|
[9406] | 656 | //PRINTF(0)("(%s::%s)\n", this->getClassCName(), this->getName()); |
---|
[6281] | 657 | // assert(!unlikely(this->models.empty())); |
---|
[6002] | 658 | { |
---|
| 659 | glMatrixMode(GL_MODELVIEW); |
---|
| 660 | glPushMatrix(); |
---|
[4570] | 661 | |
---|
[6002] | 662 | /* translate */ |
---|
| 663 | glTranslatef (this->getAbsCoor ().x, |
---|
| 664 | this->getAbsCoor ().y, |
---|
| 665 | this->getAbsCoor ().z); |
---|
[6004] | 666 | Vector tmpRot = this->getAbsDir().getSpacialAxis(); |
---|
| 667 | glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); |
---|
[2043] | 668 | |
---|
[6004] | 669 | |
---|
| 670 | // This Draws the LOD's |
---|
[7014] | 671 | float cameraDistance = State::getCamera()->distance(this); |
---|
[6004] | 672 | if (cameraDistance > 30 && this->models.size() >= 3 && this->models[2] != NULL) |
---|
[6002] | 673 | { |
---|
[6222] | 674 | this->models[2]->draw(); |
---|
[6004] | 675 | } |
---|
| 676 | else if (cameraDistance > 10 && this->models.size() >= 2 && this->models[1] != NULL) |
---|
[6002] | 677 | { |
---|
| 678 | this->models[1]->draw(); |
---|
[6004] | 679 | } |
---|
| 680 | else if (this->models.size() >= 1 && this->models[0] != NULL) |
---|
[6002] | 681 | { |
---|
| 682 | this->models[0]->draw(); |
---|
| 683 | } |
---|
[8724] | 684 | |
---|
[9869] | 685 | // if( this->aabbNode != NULL) |
---|
| 686 | // this->aabbNode->drawBV(0, DRAW_BV_POLYGON, Vector(1, 0.6, 0.2), true); |
---|
[8724] | 687 | |
---|
[6002] | 688 | glPopMatrix(); |
---|
| 689 | } |
---|
[3803] | 690 | } |
---|
[3583] | 691 | |
---|
[6430] | 692 | /** |
---|
[6700] | 693 | * @param health the Health to add. |
---|
| 694 | * @returns the health left (this->healthMax - health+this->health) |
---|
[6430] | 695 | */ |
---|
[6700] | 696 | float WorldEntity::increaseHealth(float health) |
---|
[6430] | 697 | { |
---|
[6700] | 698 | this->health += health; |
---|
| 699 | if (this->health > this->healthMax) |
---|
[6430] | 700 | { |
---|
[6700] | 701 | float retHealth = this->healthMax - this->health; |
---|
| 702 | this->health = this->healthMax; |
---|
| 703 | this->updateHealthWidget(); |
---|
| 704 | return retHealth; |
---|
[6430] | 705 | } |
---|
[6700] | 706 | this->updateHealthWidget(); |
---|
[6430] | 707 | return 0.0; |
---|
| 708 | } |
---|
[6281] | 709 | |
---|
[5498] | 710 | /** |
---|
[6700] | 711 | * @param health the Health to be removed |
---|
[6430] | 712 | * @returns 0.0 or the rest, that was not substracted (bellow 0.0) |
---|
| 713 | */ |
---|
[6700] | 714 | float WorldEntity::decreaseHealth(float health) |
---|
[6430] | 715 | { |
---|
[6700] | 716 | this->health -= health; |
---|
[6430] | 717 | |
---|
[6700] | 718 | if (this->health < 0) |
---|
[6430] | 719 | { |
---|
[6700] | 720 | float retHealth = -this->health; |
---|
| 721 | this->health = 0.0f; |
---|
| 722 | this->updateHealthWidget(); |
---|
| 723 | return retHealth; |
---|
[6430] | 724 | } |
---|
[6700] | 725 | this->updateHealthWidget(); |
---|
[6430] | 726 | return 0.0; |
---|
| 727 | |
---|
| 728 | } |
---|
| 729 | |
---|
| 730 | /** |
---|
[6700] | 731 | * @param maxHealth the maximal health that can be loaded onto the entity. |
---|
[6430] | 732 | */ |
---|
[6700] | 733 | void WorldEntity::setHealthMax(float healthMax) |
---|
[6430] | 734 | { |
---|
[6700] | 735 | this->healthMax = healthMax; |
---|
| 736 | if (this->health > this->healthMax) |
---|
[6430] | 737 | { |
---|
[9406] | 738 | PRINTF(3)("new maxHealth is bigger as the old health. Did you really intend to do this for (%s::%s)\n", this->getClassCName(), this->getCName()); |
---|
[6700] | 739 | this->health = this->healthMax; |
---|
[6430] | 740 | } |
---|
[6700] | 741 | this->updateHealthWidget(); |
---|
[6430] | 742 | } |
---|
| 743 | |
---|
[6431] | 744 | /** |
---|
[6700] | 745 | * @brief creates the HealthWidget |
---|
[6431] | 746 | * |
---|
[6700] | 747 | * since not all entities need an HealthWidget, it is only created on request. |
---|
[6431] | 748 | */ |
---|
[6700] | 749 | void WorldEntity::createHealthWidget() |
---|
[6430] | 750 | { |
---|
[6700] | 751 | if (this->healthWidget == NULL) |
---|
[6430] | 752 | { |
---|
[10101] | 753 | this->healthWidget = new OrxGui::GLGuiEnergyWidgetVertical(); |
---|
[10120] | 754 | this->healthWidget->setDisplayedName("Electronics"); |
---|
[6700] | 755 | this->healthWidget->setSize2D(30,400); |
---|
[10120] | 756 | this->healthWidget->setAbsCoor2D(100,200); |
---|
[6430] | 757 | |
---|
[6700] | 758 | this->updateHealthWidget(); |
---|
[6430] | 759 | } |
---|
| 760 | else |
---|
[9406] | 761 | PRINTF(3)("Allready created the HealthWidget for %s::%s\n", this->getClassCName(), this->getCName()); |
---|
[6430] | 762 | } |
---|
| 763 | |
---|
[6700] | 764 | void WorldEntity::increaseHealthMax(float increaseHealth) |
---|
[6440] | 765 | { |
---|
[6700] | 766 | this->healthMax += increaseHealth; |
---|
| 767 | this->updateHealthWidget(); |
---|
[6440] | 768 | } |
---|
| 769 | |
---|
[6700] | 770 | |
---|
[7779] | 771 | OrxGui::GLGuiWidget* WorldEntity::getHealthWidget() |
---|
[6700] | 772 | { |
---|
| 773 | this->createHealthWidget(); |
---|
| 774 | return this->healthWidget; |
---|
| 775 | } |
---|
| 776 | |
---|
[6431] | 777 | /** |
---|
[6700] | 778 | * @param visibility shows or hides the health-bar |
---|
[6431] | 779 | * (creates the widget if needed) |
---|
| 780 | */ |
---|
[6700] | 781 | void WorldEntity::setHealthWidgetVisibilit(bool visibility) |
---|
[6430] | 782 | { |
---|
[7198] | 783 | if (visibility) |
---|
| 784 | { |
---|
| 785 | if (this->healthWidget != NULL) |
---|
| 786 | this->healthWidget->show(); |
---|
| 787 | else |
---|
[6430] | 788 | { |
---|
[7198] | 789 | this->createHealthWidget(); |
---|
| 790 | this->updateHealthWidget(); |
---|
| 791 | this->healthWidget->show(); |
---|
[6430] | 792 | } |
---|
[7198] | 793 | } |
---|
| 794 | else if (this->healthWidget != NULL) |
---|
| 795 | this->healthWidget->hide(); |
---|
[6430] | 796 | } |
---|
| 797 | |
---|
[8724] | 798 | |
---|
[6431] | 799 | /** |
---|
[8724] | 800 | * hit the world entity with |
---|
| 801 | * @param damage damage to be dealt |
---|
| 802 | */ |
---|
[9008] | 803 | void WorldEntity::hit(float damage, WorldEntity* killer) |
---|
[8724] | 804 | { |
---|
[10113] | 805 | |
---|
[8724] | 806 | this->decreaseHealth(damage); |
---|
| 807 | |
---|
[9406] | 808 | PRINTF(5)("Hit me: %s::%s now only %f/%f health\n", this->getClassCName(), this->getCName(), this->getHealth(), this->getHealthMax()); |
---|
[8777] | 809 | |
---|
[8724] | 810 | if( this->getHealth() > 0) |
---|
| 811 | { |
---|
| 812 | // any small explosion animaitions |
---|
| 813 | } |
---|
| 814 | else |
---|
| 815 | { |
---|
[9235] | 816 | this->destroy( killer ); |
---|
[8724] | 817 | } |
---|
| 818 | } |
---|
| 819 | |
---|
| 820 | |
---|
| 821 | /** |
---|
[8777] | 822 | * destoys the world entity |
---|
| 823 | */ |
---|
[9235] | 824 | void WorldEntity::destroy(WorldEntity* killer) |
---|
[8777] | 825 | { |
---|
| 826 | this->toList(OM_DEAD); |
---|
| 827 | } |
---|
| 828 | |
---|
| 829 | |
---|
| 830 | /** |
---|
[6700] | 831 | * @brief updates the HealthWidget |
---|
[6431] | 832 | */ |
---|
[6700] | 833 | void WorldEntity::updateHealthWidget() |
---|
[6430] | 834 | { |
---|
[6700] | 835 | if (this->healthWidget != NULL) |
---|
[6430] | 836 | { |
---|
[6700] | 837 | this->healthWidget->setMaximum(this->healthMax); |
---|
| 838 | this->healthWidget->setValue(this->health); |
---|
[6430] | 839 | } |
---|
| 840 | } |
---|
| 841 | |
---|
| 842 | |
---|
| 843 | /** |
---|
[5498] | 844 | * DEBUG-DRAW OF THE BV-Tree. |
---|
| 845 | * @param depth What depth to draw |
---|
| 846 | * @param drawMode the mode to draw this entity under |
---|
| 847 | */ |
---|
[7711] | 848 | void WorldEntity::drawBVTree(int depth, int drawMode) const |
---|
[4684] | 849 | { |
---|
| 850 | glMatrixMode(GL_MODELVIEW); |
---|
| 851 | glPushMatrix(); |
---|
| 852 | /* translate */ |
---|
| 853 | glTranslatef (this->getAbsCoor ().x, |
---|
| 854 | this->getAbsCoor ().y, |
---|
| 855 | this->getAbsCoor ().z); |
---|
| 856 | /* rotate */ |
---|
[4998] | 857 | Vector tmpRot = this->getAbsDir().getSpacialAxis(); |
---|
| 858 | glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); |
---|
[4684] | 859 | |
---|
[7711] | 860 | |
---|
[4684] | 861 | if (this->obbTree) |
---|
| 862 | this->obbTree->drawBV(depth, drawMode); |
---|
[7711] | 863 | |
---|
| 864 | |
---|
[4684] | 865 | glPopMatrix(); |
---|
| 866 | } |
---|
[6341] | 867 | |
---|
[6424] | 868 | |
---|
[6341] | 869 | /** |
---|
[6424] | 870 | * Debug the WorldEntity |
---|
| 871 | */ |
---|
| 872 | void WorldEntity::debugEntity() const |
---|
| 873 | { |
---|
[9406] | 874 | PRINT(0)("WorldEntity %s::%s (DEBUG)\n", this->getClassCName(), this->getCName()); |
---|
[6424] | 875 | this->debugNode(); |
---|
[9656] | 876 | PRINT(0)("List: %s ; ModelCount %d - ", ObjectManager::OMListToString(this->objectListNumber).c_str(), this->models.size()); |
---|
[6424] | 877 | for (unsigned int i = 0; i < this->models.size(); i++) |
---|
| 878 | { |
---|
| 879 | if (models[i] != NULL) |
---|
[9406] | 880 | PRINT(0)(" : %d:%s", i, this->models[i]->getCName()); |
---|
[6424] | 881 | } |
---|
| 882 | PRINT(0)("\n"); |
---|
| 883 | |
---|
| 884 | } |
---|
| 885 | |
---|
| 886 | |
---|
| 887 | /** |
---|
[7954] | 888 | * handler for changes on registred vars |
---|
| 889 | * @param id id's which changed |
---|
[6341] | 890 | */ |
---|
[7954] | 891 | void WorldEntity::varChangeHandler( std::list< int > & id ) |
---|
[6341] | 892 | { |
---|
[7954] | 893 | if ( std::find( id.begin(), id.end(), modelFileName_handle ) != id.end() || |
---|
| 894 | std::find( id.begin(), id.end(), scaling_handle ) != id.end() |
---|
| 895 | ) |
---|
[6341] | 896 | { |
---|
[7954] | 897 | loadModel( modelFileName, scaling ); |
---|
[6341] | 898 | } |
---|
| 899 | |
---|
[9008] | 900 | if ( std::find( id.begin(), id.end(), list_handle ) != id.end() ) |
---|
| 901 | { |
---|
| 902 | this->toList( (OM_LIST)list_write ); |
---|
| 903 | } |
---|
[9235] | 904 | |
---|
[9110] | 905 | if ( std::find( id.begin(), id.end(), health_handle ) != id.end() ) |
---|
| 906 | { |
---|
| 907 | this->setHealth( health_write ); |
---|
| 908 | } |
---|
[9235] | 909 | |
---|
[9110] | 910 | if ( std::find( id.begin(), id.end(), healthMax_handle ) != id.end() ) |
---|
| 911 | { |
---|
| 912 | this->setHealthMax( healthMax_write ); |
---|
| 913 | } |
---|
[9008] | 914 | |
---|
[7954] | 915 | PNode::varChangeHandler( id ); |
---|
[6341] | 916 | } |
---|
| 917 | |
---|