[4838] | 1 | /* |
---|
[1853] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
[9003] | 3 | |
---|
[1853] | 4 | Copyright (C) 2004 orx |
---|
[9003] | 5 | |
---|
[1853] | 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. |
---|
[9003] | 10 | |
---|
[1855] | 11 | ### File Specific: |
---|
[8490] | 12 | main-programmer: Claudio Botta |
---|
[1855] | 13 | co-programmer: ... |
---|
[1853] | 14 | */ |
---|
| 15 | |
---|
[8081] | 16 | #include "bsp_entity.h" |
---|
| 17 | #include "util/loading/resource_manager.h" |
---|
[9003] | 18 | #include "util/loading/resource_manager.h" |
---|
[1853] | 19 | |
---|
[8490] | 20 | CREATE_FACTORY(BspEntity, CL_BSP_ENTITY); |
---|
[8087] | 21 | |
---|
| 22 | |
---|
[3564] | 23 | /** |
---|
[8490] | 24 | * constructs and loads a BspEntity from a XML-element |
---|
[4838] | 25 | * @param root the XML-element to load from |
---|
| 26 | */ |
---|
[8490] | 27 | BspEntity::BspEntity(const TiXmlElement* root) |
---|
[4483] | 28 | { |
---|
| 29 | this->init(); |
---|
[8490] | 30 | |
---|
[4838] | 31 | if (root != NULL) |
---|
| 32 | this->loadParams(root); |
---|
[4483] | 33 | } |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | /** |
---|
[4838] | 37 | * standard deconstructor |
---|
| 38 | */ |
---|
[8490] | 39 | BspEntity::~BspEntity () |
---|
[3566] | 40 | { |
---|
[9003] | 41 | if( this->bspManager != NULL) |
---|
[8490] | 42 | delete this->bspManager; |
---|
[3566] | 43 | } |
---|
| 44 | |
---|
[8087] | 45 | |
---|
[9003] | 46 | |
---|
[3762] | 47 | /** |
---|
[8490] | 48 | * initializes the BspEntity |
---|
[4838] | 49 | * @todo change this to what you wish |
---|
| 50 | */ |
---|
[8490] | 51 | void BspEntity::init() |
---|
[4483] | 52 | { |
---|
[5509] | 53 | |
---|
[9003] | 54 | this->bspManager = NULL; |
---|
[5509] | 55 | /** |
---|
[8081] | 56 | * @todo: Write CL_BSP_ENTITY INTO THE src/defs/class_id.h (your own definition) |
---|
[5509] | 57 | */ |
---|
[8490] | 58 | } |
---|
[5509] | 59 | |
---|
[8490] | 60 | |
---|
| 61 | void BspEntity::setName(const std::string& name) |
---|
| 62 | { |
---|
| 63 | PRINTF(0)("+++++++++++ LOADING NAME %s\n", name.c_str()); |
---|
| 64 | |
---|
[9003] | 65 | // Check wether file exists.... |
---|
| 66 | if ( File(ResourceManager::getFullName(name)).exists() ) { |
---|
| 67 | |
---|
| 68 | this->setClassID(CL_BSP_ENTITY, "BspEntity"); |
---|
| 69 | this->bspManager = new BspManager(this); |
---|
| 70 | |
---|
| 71 | if(this->bspManager->load(name.c_str(), 0.1f) == -1 ) { |
---|
| 72 | this->bspManager = NULL; |
---|
| 73 | |
---|
| 74 | } else { |
---|
| 75 | this->toList(OM_ENVIRON); // Success!!! |
---|
| 76 | } |
---|
| 77 | } else { |
---|
| 78 | this->bspManager = NULL; |
---|
| 79 | this->toList(OM_DEAD); |
---|
| 80 | } |
---|
[4483] | 81 | } |
---|
| 82 | |
---|
[5509] | 83 | |
---|
[4483] | 84 | /** |
---|
[8490] | 85 | * loads a BspEntity from a XML-element |
---|
[4838] | 86 | * @param root the XML-element to load from |
---|
| 87 | * @todo make the class Loadable |
---|
| 88 | */ |
---|
[8490] | 89 | void BspEntity::loadParams(const TiXmlElement* root) |
---|
[4483] | 90 | { |
---|
[4838] | 91 | // all the clases this Entity is directly derived from must be called in this way, to load all settings. |
---|
[9003] | 92 | // WorldEntity::loadParam(root); |
---|
[8087] | 93 | |
---|
[8490] | 94 | LoadParam(root, "Name", this, BspEntity, setName) |
---|
[9003] | 95 | .describe("Sets the of the BSP file."); |
---|
[4483] | 96 | |
---|
[9003] | 97 | /* LoadParam(root, "Scale", this, BSpEntity, setScale) |
---|
| 98 | .describe("Sets the scale factore of the bsp level."); |
---|
| 99 | */ |
---|
[5509] | 100 | |
---|
| 101 | /** |
---|
| 102 | * @todo: make the class Loadable |
---|
| 103 | */ |
---|
[4483] | 104 | } |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | /** |
---|
[8490] | 108 | * advances the BspEntity about time seconds |
---|
[4838] | 109 | * @param time the Time to step |
---|
| 110 | */ |
---|
[8490] | 111 | void BspEntity::tick(float time) |
---|
[3762] | 112 | { |
---|
[8490] | 113 | this->bspManager->tick(time); |
---|
[3762] | 114 | } |
---|
| 115 | |
---|
[8081] | 116 | |
---|
[3245] | 117 | /** |
---|
[4838] | 118 | * draws this worldEntity |
---|
| 119 | */ |
---|
[8490] | 120 | void BspEntity::draw () const |
---|
[4838] | 121 | { |
---|
[8081] | 122 | this->bspManager->draw(); |
---|
[3559] | 123 | } |
---|
[5509] | 124 | |
---|
| 125 | |
---|
| 126 | /** |
---|
| 127 | * |
---|
| 128 | * |
---|
| 129 | */ |
---|
[8490] | 130 | void BspEntity::collidesWith (WorldEntity* entity, const Vector& location) |
---|
[9003] | 131 | {} |
---|