Changeset 10664 in orxonox.OLD for branches/adm/src
- Timestamp:
- May 31, 2007, 3:45:05 PM (18 years ago)
- Location:
- branches/adm/src/world_entities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/adm/src/world_entities/WorldEntities.am
r10638 r10664 13 13 world_entities/npcs/attractor_mine.cc \ 14 14 world_entities/npcs/mover.cc \ 15 world_entities/npcs/adm_turret.cc \ 15 16 \ 16 17 \ … … 147 148 npcs/attractor_mine.h \ 148 149 npcs/mover.h \ 150 npcs/adm_turret.h \ 149 151 \ 150 152 environments/environment.h \ -
branches/adm/src/world_entities/npcs/adm_turret.cc
r10663 r10664 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY 17 17 #include "adm_turret.h" 18 #include "weapon_manager.h" 18 #include "weapons/weapon_manager.h" 19 #include "weapons/weapon.h" 19 20 #include "lib/util/loading/factory.h" 20 21 #include "world_entities/projectiles/projectile.h" 21 22 #include "loading/load_param.h" 23 #include "debug.h" 22 24 23 25 ObjectListDefinition(AdmTurret); 24 26 CREATE_FACTORY(AdmTurret); 25 27 26 public: 27 28 28 29 /** 29 30 * Standard constructor … … 31 32 AdmTurret::AdmTurret () 32 33 { 33 34 this->init(); 34 35 } 35 36 36 37 37 /** 38 38 * destructs the turret, deletes allocated memory … … 43 43 } 44 44 45 AdmTurret::AdmTurret (const TiXmlEleme t* root)45 AdmTurret::AdmTurret (const TiXmlElement* root) 46 46 { 47 this->init(); 48 if (root != NULL) 49 this->loadParams(root); 47 this->init(); 48 if (root != NULL) 49 { 50 this->loadParams(root); 51 } 50 52 } 51 53 52 54 void AdmTurret::init() 53 55 { 54 this->registerObject(this, GroundTurret::_objectList); 55 56 // load the 3 parts of the turret 57 // this-> loadModel ("...", , ) 58 // this-> loadModel ("...", , ) 59 // this-> loadModel ("...", , ) 60 61 62 //Cannon Node: 2 Cannons fixed left and right of the main turret 63 this->cannonNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT) 64 this->cannonNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE) 65 this->cannonNode.setParent(this) 66 // this->cannonNode.setRelCoor( , , ) 67 68 69 70 //Sensor Node: Sensor rotating independently from main turret (like Radar) 71 this->sensorNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT) 72 this->sensorNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE) 73 this->sensorNode.setParent(this) 74 // this->sensorNode.setRelCoor( , , ) 75 56 this->registerObject(this, AdmTurret::_objectList); 76 57 77 this->setStateDuration(WS_SHOOTING, .1); 78 this->setStateDuration(WS_RELOADING, .1); 79 this->setStateDuration(WS_ACTIVATING, .4); 80 this->setStateDuration(WS_DEACTIVATING, .4); 58 // load the 3 parts of the turret 59 // this-> loadModel ("...", , ) 60 // this-> loadModel ("...", , ) 61 // this-> loadModel ("...", , ) 81 62 82 this->setEnergyMax(10000); 83 this->increaseEnergy(10000); 84 //this->minCharge = ; 85 86 //this->setActionSound(WA_SHOOT, "sounds/guns/xyz.wav"); 87 //this->setActionSound(WA_ACTIVATE, "sounds/voices/xxyz.wav"); 63 //Cannon Node: 2 Cannons fixed left and right of the main turret 64 this->cannonNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 65 this->cannonNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); 66 this->cannonNode.setParent(this); 67 // this->cannonNode.setRelCoor( , , ) 88 68 89 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 90 this->setProjectileTypeC("Projectile"); 91 // this->prepareProjectiles(10000); 92 93 94 // PROBLEM!! 2 emission Points! 95 // this->setEmissionPoint(Vector( , , ) ); 96 97 // initialise here 69 //Sensor Node: Sensor rotating independently from main turret (like Radar) 70 this->sensorNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 71 this->sensorNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); 72 this->sensorNode.setParent(this); 73 // this->sensorNode.setRelCoor( , , ) 74 75 // initialise Weapons here 98 76 } 99 77 100 78 void AdmTurret::loadParams(const TiXmlElement* root) 101 79 { 102 Weapon::loadParams(root); 103 104 LoadParam(root, "target", this, GroundTurret, setTarget) 80 WorldEntity::loadParams(root); 81 82 LoadParam(root, "target", this, AdmTurret, setTarget) 83 .describe("the filename of the World Entity, that is to be shot at") 84 .defaultValues(""); 105 85 } 106 86 107 virtual void AdmTurret::tick(float dt); 108 109 virtual void GroundTurret::draw() const; 110 111 virtual void AdmTurret::collidesWith(WorldEntity* entity, const Vector& location); 112 113 virtual void AdmTurret::activate() 87 void AdmTurret::tick(float dt) 114 88 { 115 89 } 116 117 v irtual void AdmTurret::deactivate()118 { 90 91 void AdmTurret::draw() const 92 { 119 93 } 120 94 121 v irtual void AdmTurret::setTarget(const std::string& target)95 void AdmTurret::collidesWith(WorldEntity* entity, const Vector& location) 122 96 { 123 WorldEntity* targetEntity = WorldEntity::objectList().getObject(target);124 if (targetEntity != NULL)125 {126 this->myTarget = targetEntity;127 }128 else129 {130 PRINTF(2)("ERROR ADMTURRET : Target %s does not exist\n", target.c_str());131 }132 }133 134 private:135 136 bool AdmTurret::isVisible(const WorldEntity myTarget)137 {138 97 } 139 98 140 float AdmTurret::aim(const WorldEntity Target); 99 void AdmTurret::activate() 100 { 101 } 102 103 void AdmTurret::deactivate() 104 { 105 } 106 107 void AdmTurret::setTarget(const std::string& target) 108 { 109 WorldEntity* targetEntity = WorldEntity::objectList().getObject(target); 110 if (targetEntity != NULL) 111 { 112 this->myTarget = targetEntity; 113 } 114 else 115 { 116 PRINTF(2)("ERROR ADMTURRET : Target %s does not exist\n", target.c_str()); 117 } 118 } 119 120 bool AdmTurret::isVisible(const WorldEntity myTarget) 121 { 122 return true; 123 } 124 125 float AdmTurret::aim(const WorldEntity Target) 126 { 127 return 0; 128 } 141 129 142 130 void AdmTurret::fire() 143 131 { 144 Projectile* pj = this->getProjectile(); 145 if (pj == NULL) return; 146 147 //pj->setOwner(this->getOwner()); 148 149 //pj->setParent(PNode::getNullParent()); 132 // Projectile* pj = this->getProjectile(); 133 // if (pj == NULL) return; 150 134 151 //pj->setVelocity(this->getAbsDir().apply(Vector( , , )) ); 152 153 //pj->setAbsCoor(this->getEmissionPoint()); 154 //pj->setAbsDir(this->getAbsDir()); 155 //pj->activate(); 156 } 135 //pj->setOwner(this->getOwner()); 136 //pj->setParent(PNode::getNullParent()); 137 //pj->setVelocity(this->getAbsDir().apply(Vector( , , )) ); 138 //pj->setAbsCoor(this->getEmissionPoint()); 139 //pj->setAbsDir(this->getAbsDir()); 140 //pj->activate(); 141 } -
branches/adm/src/world_entities/npcs/adm_turret.h
r10663 r10664 10 10 //#include "sound_source.h" 11 11 12 #include "w eapon.h"12 #include "world_entity.h" 13 13 14 class GroundTurret : public WorldEntity14 class AdmTurret : public WorldEntity 15 15 { 16 16 ObjectListDeclaration(AdmTurret); … … 40 40 void fire(); 41 41 42 } 42 }; 43 44 #endif
Note: See TracChangeset
for help on using the changeset viewer.