Changeset 9869 in orxonox.OLD for trunk/src/world_entities/weapons
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (18 years ago)
- Location:
- trunk/src/world_entities/weapons
- Files:
-
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/weapons/aim.cc
r9656 r9869 29 29 30 30 31 ObjectListDefinition(Aim); 31 32 32 33 /** … … 50 51 Aim::~Aim () 51 52 { 52 /* if (this->text != NULL)53 delete this->text;*/53 /* if (this->text != NULL) 54 delete this->text;*/ 54 55 } 55 56 … … 59 60 void Aim::init() 60 61 { 61 this-> setClassID(CL_CROSSHAIR, "Aim");62 this->registerObject(this, Aim::_objectList); 62 63 this->setName("Aim"); 63 64 … … 79 80 80 81 81 /* this->text = new Text();82 this->text->setLayer(this->getLayer());83 this->text->setParent2D(this);84 this->text->setRelCoor2D(10, -50);85 this->text->setParentMode2D(E2D_PARENT_MOVEMENT);86 this->text->setText("Testing");*/82 /* this->text = new Text(); 83 this->text->setLayer(this->getLayer()); 84 this->text->setParent2D(this); 85 this->text->setRelCoor2D(10, -50); 86 this->text->setParentMode2D(E2D_PARENT_MOVEMENT); 87 this->text->setText("Testing");*/ 87 88 } 88 89 … … 92 93 93 94 LoadParam(root, "texture", this, Aim, setTexture) 94 95 .describe("the texture-file to load onto the Aim"); 95 96 96 97 LoadParam(root, "size", this, Aim, setSize) 97 98 .describe("the size of the Aim in Pixels"); 98 99 99 100 LoadParam(root, "rotation-speed", this, Aim, setRotationSpeed) 100 101 .describe("the Speed with which the Aim should rotate"); 101 102 102 103 LoadParam(root, "target-group", this, Aim, setTargetGroupS); … … 107 108 ObjectManager::EntityList::iterator entity; 108 109 //printf("%d\n", this->targetGroup); 109 for (entity = State::getObjectManager()->get ObjectList(this->targetGroup).begin();110 entity != State::getObjectManager()->get ObjectList(this->targetGroup).end();110 for (entity = State::getObjectManager()->getEntityList(this->targetGroup).begin(); 111 entity != State::getObjectManager()->getEntityList(this->targetGroup).end(); 111 112 entity ++) 112 113 { … … 117 118 //if (this->getParent() != (*entity)) 118 119 { 119 printf("found target::: %d %s::%s\n", (*entity)->getOMListNumber(), (*entity)->getClassCName(), (*entity)->getCName());120 // printf("found target::: %d %s::%s\n", (*entity)->getOMListNumber(), (*entity)->getClassCName(), (*entity)->getCName()); 120 121 this->anim->replay(); 121 122 this->setParentSoft(*entity, 5); … … 125 126 } 126 127 127 128 128 //if no target found: 129 this->setParent(PNode::getNullParent()); 129 130 } 130 131 … … 165 166 this->shiftDir2D(dt * rotationSpeed); 166 167 167 // char outputText[100];168 // sprintf(outputText, "%s - distance: %f\n", this->getParent()->getName(), (this->source->getAbsCoor() - this->getAbsCoor()).len());169 // this->text->setText(outputText);170 171 172 // if (this->source->getAbsCoor().x > this->getAbsCoor().x )168 // char outputText[100]; 169 // sprintf(outputText, "%s - distance: %f\n", this->getParent()->getName(), (this->source->getAbsCoor() - this->getAbsCoor()).len()); 170 // this->text->setText(outputText); 171 172 173 // if (this->source->getAbsCoor().x > this->getAbsCoor().x ) 173 174 diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() ); 174 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range175 175 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range 176 if(this->getParent() == PNode::getNullParent() || 176 177 diffVec.len() > range )// || 177 178 179 180 181 182 183 // float z = 0.0f;184 // glReadPixels ((int)this->getAbsCoor2D().x,185 // GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1,186 // 1,187 // 1,188 // GL_DEPTH_COMPONENT,189 // GL_FLOAT,190 // &z);191 //192 //193 // GLdouble objX=.0, objY=.0, objZ=.0;194 // gluUnProject(this->getAbsCoor2D().x,195 // GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1,196 // .99, // z197 // GraphicsEngine::modMat,198 // GraphicsEngine::projMat,199 // GraphicsEngine::viewPort,200 // &objX,201 // &objY,202 // &objZ );203 //aa204 // this->setAbsCoor(objX, objY, objZ);178 //( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle)) 179 { 180 this->setParentSoft(PNode::getNullParent(),5); 181 this->searchTarget(); 182 } 183 184 // float z = 0.0f; 185 // glReadPixels ((int)this->getAbsCoor2D().x, 186 // GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1, 187 // 1, 188 // 1, 189 // GL_DEPTH_COMPONENT, 190 // GL_FLOAT, 191 // &z); 192 // 193 // 194 // GLdouble objX=.0, objY=.0, objZ=.0; 195 // gluUnProject(this->getAbsCoor2D().x, 196 // GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1, 197 // .99, // z 198 // GraphicsEngine::modMat, 199 // GraphicsEngine::projMat, 200 // GraphicsEngine::viewPort, 201 // &objX, 202 // &objY, 203 // &objZ ); 204 //aa 205 // this->setAbsCoor(objX, objY, objZ); 205 206 } 206 207 … … 211 212 { 212 213 213 if( this->getParent() != PNode::getNullParent() )214 if( this->getParent() != PNode::getNullParent() ) 214 215 { 215 glPushMatrix();216 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);217 218 glRotatef(this->getAbsDir2D(), 0,0,1);219 this->material.select();220 glBegin(GL_TRIANGLE_STRIP);221 glTexCoord2f(0, 0);222 glVertex2f(-this->getSizeX2D(), -this->getSizeY2D());223 glTexCoord2f(1, 0);224 glVertex2f(this->getSizeX2D(), -this->getSizeY2D());225 glTexCoord2f(0, 1);226 glVertex2f(-this->getSizeX2D(), this->getSizeY2D());227 glTexCoord2f(1, 1);228 glVertex2f(this->getSizeX2D(), this->getSizeY2D());229 glEnd();230 glPopMatrix();216 glPushMatrix(); 217 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); 218 219 glRotatef(this->getAbsDir2D(), 0,0,1); 220 this->material.select(); 221 glBegin(GL_TRIANGLE_STRIP); 222 glTexCoord2f(0, 0); 223 glVertex2f(-this->getSizeX2D(), -this->getSizeY2D()); 224 glTexCoord2f(1, 0); 225 glVertex2f(this->getSizeX2D(), -this->getSizeY2D()); 226 glTexCoord2f(0, 1); 227 glVertex2f(-this->getSizeX2D(), this->getSizeY2D()); 228 glTexCoord2f(1, 1); 229 glVertex2f(this->getSizeX2D(), this->getSizeY2D()); 230 glEnd(); 231 glPopMatrix(); 231 232 } 232 233 -
trunk/src/world_entities/weapons/aim.h
r9656 r9869 19 19 template<class T> class tAnimation; 20 20 21 21 22 //! An Aim for zooming in on Targets. 22 23 /** … … 28 29 class Aim : public PNode, public Element2D 29 30 { 31 ObjectListDeclaration(Aim); 30 32 31 33 public: -
trunk/src/world_entities/weapons/aiming_system.cc
r9406 r9869 21 21 22 22 #include "state.h" 23 #include "debug.h" 23 24 24 25 #include "aabb.h" 25 26 #include "obb_tree.h" 26 27 27 #include <vector>28 28 29 29 30 31 30 ObjectListDefinition(AimingSystem); 32 31 33 32 /** … … 55 54 void AimingSystem::init() 56 55 { 57 this-> setClassID(CL_AIMING_SYSTEM, "AimingSystem");56 this->registerObject(this, AimingSystem::_objectList); 58 57 this->setName("AimingSystem"); 59 58 … … 63 62 // registering default reactions: 64 63 this->unsubscribeReaction(CREngine::CR_OBJECT_DAMAGE); 65 this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, CL_WORLD_ENTITY);64 this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, WorldEntity::staticClassID()); 66 65 67 66 this->range = 1000.0f; -
trunk/src/world_entities/weapons/aiming_system.h
r9235 r9869 21 21 class AimingSystem : public WorldEntity 22 22 { 23 ObjectListDeclaration(AimingSystem); 23 24 24 25 public: -
trunk/src/world_entities/weapons/aiming_turret.cc
r9656 r9869 27 27 #include "util/loading/factory.h" 28 28 29 CREATE_FACTORY(AimingTurret, CL_AIMING_TURRET); 30 29 #include "class_id_DEPRECATED.h" 30 ObjectListDefinitionID(AimingTurret, CL_AIMING_TURRET); 31 CREATE_FACTORY(AimingTurret); 31 32 32 33 … … 64 65 void AimingTurret::init() 65 66 { 66 this-> setClassID(CL_AIMING_TURRET, "AimingTurret");67 this->registerObject(this, AimingTurret::_objectList); 67 68 68 69 Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this); … … 86 87 87 88 this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET); 88 this->setProjectileType (CL_GUIDED_MISSILE);89 this->setProjectileTypeC("GuidedMissile"); 89 90 90 91 -
trunk/src/world_entities/weapons/aiming_turret.h
r9656 r9869 13 13 class AimingTurret : public Weapon 14 14 { 15 ObjectListDeclaration(AimingTurret); 16 15 17 public: 16 18 AimingTurret (); -
trunk/src/world_entities/weapons/ammo_container.cc
r9406 r9869 23 23 24 24 25 25 ObjectListDefinition(AmmoContainer); 26 26 /** 27 27 * standard constructor 28 28 * @todo this constructor is not jet implemented - do it 29 29 */ 30 AmmoContainer::AmmoContainer ( ClassIDprojectileType, float maxEnergy)30 AmmoContainer::AmmoContainer (const ClassID& projectileType, float maxEnergy) 31 31 { 32 this->setClassID(CL_AMMO_CONTAINER, "AmmoContainer");32 this->registerObject(this, AmmoContainer::_objectList); 33 33 34 35 34 this->projectileType = projectileType; 35 this->maxEnergy = maxEnergy; 36 36 37 37 this->energy = 0.0; 38 38 } 39 39 -
trunk/src/world_entities/weapons/ammo_container.h
r6671 r9869 17 17 //! A class for Storing energy of Projectiles. 18 18 class AmmoContainer : public BaseObject { 19 ObjectListDeclaration(AmmoContainer); 19 20 20 21 public: 21 AmmoContainer( ClassID projectileType, float maxEnergy = DEFAULT_MAX_ENERGY);22 AmmoContainer(const ClassID& id, float maxEnergy = DEFAULT_MAX_ENERGY); 22 23 virtual ~AmmoContainer(); 23 24 24 bool operator=( ClassIDprojectileType) const { return (this->projectileType == projectileType); };25 bool operator=(int projectileType) const { return (this->projectileType == projectileType); }; 25 26 ClassID getProjectileType() const { return this->projectileType; }; 26 27 -
trunk/src/world_entities/weapons/boomerang_gun.cc
r9235 r9869 27 27 #include "util/loading/factory.h" 28 28 29 CREATE_FACTORY(BoomerangGun, CL_BOOMERANG_GUN); 29 #include "class_id_DEPRECATED.h" 30 ObjectListDefinitionID(BoomerangGun, CL_BOOMERANG_GUN); 31 CREATE_FACTORY(BoomerangGun); 30 32 31 33 … … 61 63 void BoomerangGun::init() 62 64 { 63 this-> setClassID(CL_BOOMERANG_GUN, "BoomerangGun");65 this->registerObject(this, BoomerangGun::_objectList); 64 66 65 67 … … 85 87 86 88 this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET); 87 this->setProjectileType (CL_BOOMERANG_PROJECTILE);89 this->setProjectileTypeC("BoomerangProjectile"); 88 90 89 91 this->loadModel("models/guns/turret1.obj", 5.0); -
trunk/src/world_entities/weapons/boomerang_gun.h
r9235 r9869 11 11 class BoomerangGun : public Weapon 12 12 { 13 ObjectListDeclaration(BoomerangGun); 13 14 public: 14 15 BoomerangGun (); -
trunk/src/world_entities/weapons/cannon.cc
r9406 r9869 32 32 #include "animation3d.h" 33 33 34 #include "fast_factory.h" 35 36 37 38 39 CREATE_FACTORY(Cannon, CL_CANNON); 34 #include "loading/fast_factory.h" 35 36 37 38 #include "class_id_DEPRECATED.h" 39 ObjectListDefinitionID(Cannon, CL_CANNON); 40 CREATE_FACTORY(Cannon); 40 41 41 42 /** … … 69 70 void Cannon::init() 70 71 { 71 this-> setClassID(CL_CANNON, "Cannon");72 this->registerObject(this, Cannon::_objectList); 72 73 73 74 // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN); … … 88 89 89 90 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_HEAVY); 90 this->setProjectileType (CL_BOMB);91 this->setProjectileTypeC("Bomb"); 91 92 this->prepareProjectiles(5); 92 93 -
trunk/src/world_entities/weapons/cannon.h
r8777 r9869 12 12 class Cannon : public Weapon 13 13 { 14 ObjectListDeclaration(Cannon); 14 15 public: 15 16 Cannon (); -
trunk/src/world_entities/weapons/crosshair.cc
r9406 r9869 26 26 27 27 28 28 ObjectListDefinition(Crosshair); 29 29 /** 30 30 * standart constructor … … 54 54 void Crosshair::init() 55 55 { 56 this-> setClassID(CL_CROSSHAIR, "Crosshair");56 this->registerObject(this, Crosshair::_objectList); 57 57 this->setName("Crosshair"); 58 58 -
trunk/src/world_entities/weapons/crosshair.h
r7221 r9869 22 22 //! A class that enables the 23 23 class Crosshair : public PNode, public Element2D, public EventListener { 24 24 ObjectListDeclaration(Crosshair); 25 25 public: 26 26 Crosshair(const TiXmlElement* root = NULL); -
trunk/src/world_entities/weapons/fps_sniper_rifle.cc
r9406 r9869 29 29 30 30 31 #include " fast_factory.h"31 #include "loading/fast_factory.h" 32 32 33 33 #include "fps_sniper_rifle.h" … … 39 39 40 40 41 CREATE_FACTORY(FPSSniperRifle, CL_FPS_SNIPER_RIFLE); 41 #include "class_id_DEPRECATED.h" 42 ObjectListDefinitionID(FPSSniperRifle, CL_FPS_SNIPER_RIFLE); 43 CREATE_FACTORY(FPSSniperRifle); 42 44 43 45 /** … … 76 78 void FPSSniperRifle::init() 77 79 { 78 this-> setClassID(CL_FPS_SNIPER_RIFLE, "FPSSniperRifle");80 this->registerObject(this, FPSSniperRifle::_objectList); 79 81 80 82 this->loadModel("models/guns/fps_sniper_rifle.obj", 0.2); … … 98 100 99 101 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 100 this->setProjectileType (CL_LASER);102 this->setProjectileTypeC("Laser"); 101 103 this->prepareProjectiles(20); 102 104 … … 181 183 182 184 this->material->select(); 183 static_cast<StaticModel*>(this->getModel())->draw(); 185 this->getModel()->draw(); 186 //static_cast<StaticModel*>(this->getModel())->draw(); 184 187 185 188 glPopMatrix(); -
trunk/src/world_entities/weapons/fps_sniper_rifle.h
r9003 r9869 39 39 class FPSSniperRifle : public Weapon 40 40 { 41 ObjectListDeclaration(FPSSniperRifle); 42 41 43 public: 42 44 FPSSniperRifle (int leftRight); -
trunk/src/world_entities/weapons/hyperblaster.cc
r9406 r9869 31 31 #include "animation3d.h" 32 32 33 #include " fast_factory.h"33 #include "loading/fast_factory.h" 34 34 35 35 36 36 37 38 CREATE_FACTORY(Hyperblaster, CL_HYPERBLASTER); 37 #include "class_id_DEPRECATED.h" 38 ObjectListDefinitionID(Hyperblaster, CL_HYPERBLASTER); 39 CREATE_FACTORY(Hyperblaster); 39 40 40 41 Hyperblaster::Hyperblaster(const TiXmlElement* root) … … 56 57 void Hyperblaster::init() 57 58 { 58 this-> setClassID(CL_HYPERBLASTER, "Hyperblaster");59 this->registerObject(this, Hyperblaster::_objectList); 59 60 60 61 // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN); … … 76 77 77 78 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_HEAVY); 78 this->setProjectileType (CL_HYPERBLAST);79 this->setProjectileTypeC("Hyperblast"); 79 80 this->prepareProjectiles(2); 80 81 -
trunk/src/world_entities/weapons/hyperblaster.h
r8777 r9869 12 12 class Hyperblaster : public Weapon 13 13 { 14 public: 14 ObjectListDeclaration(Hyperblaster); 15 public: 15 16 Hyperblaster (const TiXmlElement* root = NULL); 16 17 virtual ~Hyperblaster (); -
trunk/src/world_entities/weapons/laser_cannon.cc
r9656 r9869 29 29 #include "animation3d.h" 30 30 31 #include " fast_factory.h"31 #include "loading/fast_factory.h" 32 32 33 CREATE_FACTORY(LaserCannon, CL_LASER_CANNON); 34 33 #include "class_id_DEPRECATED.h" 34 ObjectListDefinitionID(LaserCannon, CL_LASER_CANNON); 35 CREATE_FACTORY(LaserCannon); 35 36 36 37 LaserCannon::LaserCannon(const TiXmlElement* root) … … 52 53 void LaserCannon::init() 53 54 { 54 this-> setClassID(CL_LASER_CANNON, "LaserCannon");55 this->registerObject(this, LaserCannon::_objectList); 55 56 56 57 // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/laser_cannon.obj", OBJ, RP_CAMPAIGN); … … 72 73 73 74 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 74 this->setProjectileType (CL_RAIL_PROJECTILE);75 this->setProjectileTypeC("RailProjectile"); 75 76 this->prepareProjectiles(100); 76 77 this->setEmissionPoint(Vector(2.8,0,0) * 5.0); -
trunk/src/world_entities/weapons/laser_cannon.h
r9235 r9869 29 29 class LaserCannon : public Weapon 30 30 { 31 public: 31 ObjectListDeclaration(LaserCannon); 32 public: 32 33 LaserCannon (const TiXmlElement* root = NULL); 33 34 virtual ~LaserCannon (); -
trunk/src/world_entities/weapons/targeting_turret.cc
r9656 r9869 26 26 #include "util/loading/factory.h" 27 27 28 CREATE_FACTORY(TargetingTurret, CL_TARGETING_TURRET); 28 #include "class_id_DEPRECATED.h" 29 ObjectListDefinitionID(TargetingTurret, CL_TARGETING_TURRET); 30 CREATE_FACTORY(TargetingTurret); 29 31 30 32 31 33 TargetingTurret::TargetingTurret(const TiXmlElement* root) 32 : target(this)33 34 { 34 35 this->init(); … … 42 43 TargetingTurret::~TargetingTurret () 43 44 { 45 if(Aim::objectList().exists(target)) 46 delete target; 44 47 // model will be deleted from WorldEntity-destructor 45 48 // delete this->target; … … 48 51 void TargetingTurret::init() 49 52 { 50 this->setClassID(CL_TARGETING_TURRET, "TargetingTurret"); 53 this->registerObject(this, TargetingTurret::_objectList); 54 this->target = new Aim(this); 51 55 52 56 Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this); … … 70 74 71 75 this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET); 72 this->setProjectileType (CL_GUIDED_MISSILE);76 this->setProjectileTypeC("GuidedMissile"); 73 77 74 78 … … 76 80 //this->getProjectileFactory()->prepare(100); 77 81 78 this->target .setVisibility(false);79 this->target .addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT | PNODE_PROHIBIT_CHILD_DELETE);80 this->target .setRange(1000);81 this->target .setAngle(M_PI_4);82 this->lockedTarget = &this->target;82 this->target->setVisibility(false); 83 this->target->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT | PNODE_PROHIBIT_CHILD_DELETE); 84 this->target->setRange(1000); 85 this->target->setAngle(M_PI_4); 86 this->lockedTarget = this->target; 83 87 84 88 this->lockedTime = 0; … … 97 101 Weapon::loadParams(root); 98 102 99 LoadParam(root, "target-group", &target, Aim, setTargetGroupS);103 LoadParam(root, "target-group", target, Aim, setTargetGroupS); 100 104 101 105 } … … 109 113 void TargetingTurret::deactivate() 110 114 { 111 this->target .setVisibility(false);115 this->target->setVisibility(false); 112 116 } 113 117 … … 117 121 return; 118 122 119 this->target .tick(dt);123 this->target->tick(dt); 120 124 121 125 if( lockedTime >= neededLockTime ) 122 126 { 123 lockedTarget = this->target .getParent();127 lockedTarget = this->target->getParent(); 124 128 lockedTime = 0; 125 129 } 126 130 127 131 128 if(this->target .getParent() == PNode::getNullParent())132 if(this->target->getParent() == PNode::getNullParent()) 129 133 lockedTime = 0; 130 134 else -
trunk/src/world_entities/weapons/targeting_turret.h
r9656 r9869 12 12 class TargetingTurret : public Weapon 13 13 { 14 ObjectListDeclaration(TargetingTurret); 14 15 public: 15 16 TargetingTurret(const TiXmlElement* root = NULL); … … 26 27 virtual void draw() const; 27 28 28 void setTargetGroup(OM_LIST targetGroup) { this->target .setTargetGroup(targetGroup); };29 void setTargetGroup(OM_LIST targetGroup) { this->target->setTargetGroup(targetGroup); }; 29 30 const PNode* getLockedTarget() const { return lockedTarget; }; 30 31 … … 33 34 34 35 private: 35 Aim 36 Aim* target; 36 37 PNode* lockedTarget; 37 38 float lockedTime; -
trunk/src/world_entities/weapons/test_gun.cc
r9656 r9869 31 31 #include "animation3d.h" 32 32 33 #include "fast_factory.h" 34 35 CREATE_FACTORY(TestGun, CL_TEST_GUN); 36 33 #include "loading/fast_factory.h" 34 35 #include "class_id_DEPRECATED.h" 36 ObjectListDefinitionID(TestGun, CL_TEST_GUN); 37 CREATE_FACTORY(TestGun); 37 38 /** 38 39 * standard constructor … … 109 110 void TestGun::init() 110 111 { 111 this->setClassID(CL_TEST_GUN, "TestGun"); 112 112 this->registerObject(this, TestGun::_objectList); 113 113 // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN); 114 114 … … 129 129 130 130 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 131 this->setProjectileType (CL_LASER);131 this->setProjectileTypeC("Laser"); 132 132 this->prepareProjectiles(100); 133 133 -
trunk/src/world_entities/weapons/test_gun.h
r8777 r9869 37 37 class TestGun : public Weapon 38 38 { 39 ObjectListDeclaration(TestGun); 39 40 public: 40 41 TestGun (int leftRight); -
trunk/src/world_entities/weapons/turret.cc
r9406 r9869 27 27 #include "util/loading/factory.h" 28 28 29 CREATE_FACTORY(Turret, CL_TURRET); 30 31 29 #include "class_id_DEPRECATED.h" 30 ObjectListDefinitionID(Turret, CL_TURRET); 31 CREATE_FACTORY(Turret); 32 32 33 33 /** … … 62 62 void Turret::init() 63 63 { 64 this-> setClassID(CL_TURRET, "Turret");64 this->registerObject(this, Turret::_objectList); 65 65 66 66 … … 86 86 87 87 this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET); 88 this->setProjectileType (CL_ROCKET);88 this->setProjectileTypeC("Rocket"); 89 89 90 90 this->loadModel("models/guns/turret1.obj"); -
trunk/src/world_entities/weapons/turret.h
r8777 r9869 11 11 class Turret : public Weapon 12 12 { 13 ObjectListDeclaration(Turret); 13 14 public: 14 15 Turret (); -
trunk/src/world_entities/weapons/weapon.cc
r9406 r9869 21 21 #include "weapon.h" 22 22 23 #include " fast_factory.h"23 #include "loading/fast_factory.h" 24 24 #include "world_entities/projectiles/projectile.h" 25 25 26 #include "util/loading/resource_manager.h"27 #include "class_list.h"28 26 #include "util/loading/factory.h" 29 27 #include "util/loading/load_param.h" … … 33 31 #include "sound_source.h" 34 32 #include "sound_buffer.h" 33 #include "resource_sound_buffer.h" 35 34 36 35 #include "elements/glgui_energywidget.h" 37 36 38 37 ObjectListDefinition(Weapon); 39 38 40 39 //////////////////// … … 58 57 { 59 58 for (int i = 0; i < WS_STATE_COUNT; i++) 60 if (this->animation[i] && ClassList::exists(animation[i], CL_ANIMATION)) //!< @todo this should check animation3D59 if (this->animation[i] && Animation::objectList().exists(animation[i])) //!< @todo this should check animation3D 61 60 delete this->animation[i]; 62 for (int i = 0; i < WA_ACTION_COUNT; i++) 63 if (this->soundBuffers[i] != NULL && ClassList::exists(this->soundBuffers[i], CL_SOUND_BUFFER)) 64 ResourceManager::getInstance()->unload(this->soundBuffers[i]); 65 66 if (ClassList::exists(this->soundSource, CL_SOUND_SOURCE)) 61 62 if (OrxSound::SoundSource::objectList().exists(this->soundSource)) 67 63 delete this->soundSource; 68 64 } … … 73 69 * @returns the newly created Weapon. 74 70 */ 75 Weapon* Weapon::createWeapon( ClassIDweaponID)71 Weapon* Weapon::createWeapon(const ClassID& weaponID) 76 72 { 77 73 BaseObject* createdObject = Factory::fabricate(weaponID); 78 74 if (createdObject != NULL) 79 75 { 80 if (createdObject->isA( CL_WEAPON))76 if (createdObject->isA(Weapon::staticClassID())) 81 77 return dynamic_cast<Weapon*>(createdObject); 82 78 else … … 89 85 } 90 86 87 Weapon* Weapon::createWeapon(const std::string& weaponName) 88 { 89 BaseObject* createdObject = Factory::fabricate(weaponName); 90 if (createdObject != NULL) 91 { 92 if (createdObject->isA(Weapon::staticClassID())) 93 return dynamic_cast<Weapon*>(createdObject); 94 else 95 { 96 delete createdObject; 97 return NULL; 98 } 99 } 100 return NULL; 101 } 102 103 91 104 /** 92 105 * initializes the Weapon with ALL default values … … 96 109 void Weapon::init() 97 110 { 98 this-> setClassID(CL_WEAPON, "Weapon");111 this->registerObject(this, Weapon::_objectList); 99 112 this->currentState = WS_INACTIVE; //< Normaly the Weapon is Inactive 100 113 this->requestedAction = WA_NONE; //< No action is requested by default … … 105 118 this->animation[i] = NULL; //< No animation 106 119 } 107 for (int i = 0; i < WA_ACTION_COUNT; i++)108 this->soundBuffers[i] = NULL; //< No Sounds109 120 110 121 this->soundSource = new OrxSound::SoundSource(this); //< Every Weapon has exacty one SoundSource. … … 115 126 this->defaultTarget = NULL; //< Nothing is Targeted by default. 116 127 117 this->projectile = CL_NULL;//< No Projectile Class is Connected to this weapon128 this->projectile = NullClass::staticClassID(); //< No Projectile Class is Connected to this weapon 118 129 this->projectileFactory = NULL; //< No Factory generating Projectiles is selected. 119 130 … … 163 174 * What it does, is telling the Weapon what Projectiles it can Emit. 164 175 */ 165 void Weapon::setProjectileType(ClassID projectile) 166 { 167 if (projectile == CL_NULL) 168 return; 176 void Weapon::setProjectileType(const ClassID& projectile) 177 { 169 178 this->projectile = projectile; 170 179 this->projectileFactory = FastFactory::searchFastFactory(projectile); … … 259 268 if (action >= WA_ACTION_COUNT) 260 269 return; 261 if (this->soundBuffers[action] != NULL)262 ResourceManager::getInstance()->unload(this->soundBuffers[action]);263 270 264 271 else if (!soundFile.empty()) 265 272 { 266 this->soundBuffers[action] = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(soundFile, WAV);267 if (this->soundBuffers[action] != NULL)273 this->soundBuffers[action] = OrxSound::ResourceSoundBuffer(soundFile); 274 if (this->soundBuffers[action].loaded()) 268 275 { 269 276 PRINTF(4)("Loaded sound %s to action %s.\n", soundFile.c_str(), actionToChar(action)); … … 275 282 } 276 283 else 277 this->soundBuffers[action] = NULL;284 this->soundBuffers[action] = OrxSound::SoundBuffer(); 278 285 } 279 286 … … 409 416 { 410 417 case WA_SHOOT: 411 412 418 return this->fireW(); 419 break; 413 420 case WA_CHARGE: 414 415 421 return this->chargeW(); 422 break; 416 423 case WA_RELOAD: 417 418 424 return this->reloadW(); 425 break; 419 426 case WA_DEACTIVATE: 420 421 427 return this->deactivateW(); 428 break; 422 429 case WA_ACTIVATE: 423 424 430 return this->activateW(); 431 break; 425 432 default: 426 427 433 PRINTF(2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action)); 434 return false; 428 435 } 429 436 } … … 438 445 { 439 446 // play Sound 440 if (likely(this->soundBuffers[WA_ACTIVATE] != NULL))447 if (likely(this->soundBuffers[WA_ACTIVATE].loaded())) 441 448 this->soundSource->play(this->soundBuffers[WA_ACTIVATE]); 442 449 this->updateWidgets(); … … 460 467 PRINTF(4)("Deactivating the Weapon %s\n", this->getCName()); 461 468 // play Sound 462 if (this->soundBuffers[WA_DEACTIVATE] != NULL)469 if (this->soundBuffers[WA_DEACTIVATE].loaded()) 463 470 this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]); 464 471 // deactivate … … 479 486 { 480 487 // playing Sound 481 if (this->soundBuffers[WA_CHARGE] != NULL)488 if (this->soundBuffers[WA_CHARGE].loaded()) 482 489 this->soundSource->play(this->soundBuffers[WA_CHARGE]); 483 490 … … 504 511 { 505 512 // playing Sound 506 if (this->soundBuffers[WA_SHOOT] != NULL)513 if (this->soundBuffers[WA_SHOOT].loaded()) 507 514 this->soundSource->play(this->soundBuffers[WA_SHOOT]); 508 515 this->updateWidgets(); … … 528 535 { 529 536 PRINTF(4)("Reloading Weapon %s\n", this->getCName()); 530 if ( this->ammoContainer.get() != NULL&&537 if (!this->ammoContainer.isNull() && 531 538 unlikely(this->energy + this->ammoContainer->getStoredEnergy() < this->minCharge)) 532 539 { … … 537 544 538 545 539 if (this->soundBuffers[WA_RELOAD] != NULL)546 if (this->soundBuffers[WA_RELOAD].loaded()) 540 547 this->soundSource->play(this->soundBuffers[WA_RELOAD]); 541 548 542 if ( this->ammoContainer.get() != NULL)549 if (!this->ammoContainer.isNull()) 543 550 this->ammoContainer->fillWeapon(this); 544 551 else … … 680 687 { 681 688 case WA_SHOOT: 682 683 689 return "shoot"; 690 break; 684 691 case WA_CHARGE: 685 686 692 return "charge"; 693 break; 687 694 case WA_RELOAD: 688 689 695 return "reload"; 696 break; 690 697 case WA_ACTIVATE: 691 692 698 return "activate"; 699 break; 693 700 case WA_DEACTIVATE: 694 695 701 return "deactivate"; 702 break; 696 703 case WA_SPECIAL1: 697 698 704 return "special1"; 705 break; 699 706 default: 700 701 707 return "none"; 708 break; 702 709 } 703 710 } … … 743 750 { 744 751 case WS_SHOOTING: 745 746 752 return "shooting"; 753 break; 747 754 case WS_CHARGING: 748 749 755 return "charging"; 756 break; 750 757 case WS_RELOADING: 751 752 758 return "reloading"; 759 break; 753 760 case WS_ACTIVATING: 754 755 761 return "activating"; 762 break; 756 763 case WS_DEACTIVATING: 757 758 764 return "deactivating"; 765 break; 759 766 case WS_IDLE: 760 761 767 return "idle"; 768 break; 762 769 case WS_INACTIVE: 763 764 770 return "inactive"; 771 break; 765 772 default: 766 767 768 } 769 } 773 return "none"; 774 break; 775 } 776 } -
trunk/src/world_entities/weapons/weapon.h
r8976 r9869 19 19 #include "ammo_container.h" 20 20 21 #include "sound_buffer.h" 22 21 23 // FORWARD DECLARATION 22 24 class Projectile; … … 83 85 class Weapon : public WorldEntity 84 86 { 87 ObjectListDeclaration(Weapon); 88 85 89 public: 86 90 // INITIALISATION // 87 91 Weapon (); 88 92 virtual ~Weapon (); 89 static Weapon* createWeapon(ClassID weaponID); 93 static Weapon* createWeapon(const ClassID& weaponID); 94 static Weapon* createWeapon(const std::string& weaponName); 90 95 91 96 void init(); … … 110 115 /** @returns the Capabilities of this Weapon */ 111 116 inline long getCapability() const { return this->capability; }; 112 void setProjectileType( ClassIDprojectile);117 void setProjectileType(const ClassID& projectile); 113 118 void setProjectileTypeC(const std::string& projectile); 114 119 /** @returns The projectile's classID */ … … 216 221 // PHASES // 217 222 //////////// 218 OrxSound::SoundSource* soundSource; 219 220 WeaponState currentState; 221 WeaponAction requestedAction; 222 float stateDuration; 223 float times[WS_STATE_COUNT]; 224 Animation3D* animation[WS_STATE_COUNT]; 225 OrxSound::SoundBuffer * soundBuffers[WA_ACTION_COUNT];//!< SoundBuffers for all actions @see WeaponAction.223 OrxSound::SoundSource* soundSource; //!< A SoundSource to play sound from (this is connected to the PNode of the Weapon) 224 225 WeaponState currentState; //!< The State the weapon is in. 226 WeaponAction requestedAction; //!< An action to try to Engage after the currentState ends. 227 float stateDuration; //!< how long the state has taken until now. 228 float times[WS_STATE_COUNT]; //!< Times to stay in the different States @see WeaponState. 229 Animation3D* animation[WS_STATE_COUNT]; //!< Animations for all the States (you can say yourself on what part of the gun this animation acts). 230 OrxSound::SoundBuffer soundBuffers[WA_ACTION_COUNT]; //!< SoundBuffers for all actions @see WeaponAction. 226 231 227 232 PNode emissionPoint; //!< The point, where the projectiles are emitted. (this is coppled with the Weapon by default) -
trunk/src/world_entities/weapons/weapon_manager.cc
r9406 r9869 17 17 */ 18 18 19 #define DEBUG_SPECIAL_MODULE 4 //DEBUG_MODULE_WEAPON19 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON 20 20 21 21 #include "weapon_manager.h" 22 22 #include "weapon.h" 23 23 #include "crosshair.h" 24 #include "class_list.h"25 24 26 25 #include "playable.h" 27 26 28 #include "util/loading/load_param .h"27 #include "util/loading/load_param_xml.h" 29 28 #include "util/loading/factory.h" 30 29 … … 32 31 33 32 33 ObjectListDefinition(WeaponManager); 34 34 /** 35 35 * @brief this initializes the weaponManager for a given nnumber of weapon slots … … 57 57 // crosshair being a PNode it must not be deleted (this is because PNodes delete themselves.) 58 58 // rennerc: crosshair seems not to delete itselve 59 if (ClassList::exists(this->crosshair, CL_CROSSHAIR))60 delete this->crosshair;59 //if (Crosshair::objectList().exists(this->crosshair)) 60 // delete this->crosshair; 61 61 } 62 62 … … 66 66 void WeaponManager::init() 67 67 { 68 this-> setClassID(CL_WEAPON_MANAGER, "WeaponManager");68 this->registerObject(this, WeaponManager::_objectList); 69 69 70 70 this->parentNode = NULL; … … 298 298 { 299 299 this->parentNode->addChild(weapon); 300 if (this->parentEntity->isA( CL_PLAYABLE))300 if (this->parentEntity->isA(Playable::staticClassID())) 301 301 dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged(); 302 302 weapon->setDefaultTarget(this->crosshair); 303 303 } 304 PRINTF( 3)("Added a new Weapon (%s::%s) to the WeaponManager: config %i/ slot %i\n", weapon->getClassCName(), weapon->getCName(), configID, slotID);304 PRINTF(4)("Added a new Weapon (%s::%s) to the WeaponManager: config %i/ slot %i\n", weapon->getClassCName(), weapon->getCName(), configID, slotID); 305 305 return true; 306 306 } … … 311 311 * @param ammo the ammo to increase 312 312 */ 313 float WeaponManager::increaseAmmunition( ClassIDprojectileType, float ammo)313 float WeaponManager::increaseAmmunition(const ClassID& projectileType, float ammo) 314 314 { 315 315 return this->getAmmoContainer(projectileType)->increaseEnergy(ammo); … … 324 324 { 325 325 assert (weapon != NULL); 326 return this->increaseAmmunition(weapon->get LeafClassID(), ammo);326 return this->increaseAmmunition(weapon->getClassID(), ammo); 327 327 328 328 } … … 468 468 else 469 469 this->currentSlotConfig[i].position.deactivateNode(); 470 if (this->parentEntity != NULL && this->parentEntity->isA( CL_PLAYABLE))470 if (this->parentEntity != NULL && this->parentEntity->isA(Playable::staticClassID())) 471 471 dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged(); 472 472 } … … 523 523 } 524 524 525 CountPointer<AmmoContainer>& WeaponManager::getAmmoContainer( ClassIDprojectileType)525 CountPointer<AmmoContainer>& WeaponManager::getAmmoContainer(const ClassID& projectileType) 526 526 { 527 527 for (unsigned int i = 0; i < this->ammo.size(); i++) … … 537 537 { 538 538 assert (weapon != NULL); 539 return (this->getAmmoContainer(weapon->get LeafClassID()));539 return (this->getAmmoContainer(weapon->getClassID())); 540 540 } 541 541 -
trunk/src/world_entities/weapons/weapon_manager.h
r8844 r9869 39 39 */ 40 40 class WeaponManager : public BaseObject { 41 ObjectListDeclaration(WeaponManager); 41 42 42 43 //! an enumerator defining a Slot, where a Weapon can be stored inside. … … 89 90 void changeWeaponConfig(int weaponConfig); 90 91 91 float increaseAmmunition( ClassIDprojectileType, float ammo);92 float increaseAmmunition(const ClassID& projectileType, float ammo); 92 93 float inclreaseAmmunition(const Weapon* weapon, float ammo); 93 94 … … 106 107 // private: 107 108 int getNextFreeSlot(int configID, long capability = WTYPE_ALL); 108 CountPointer<AmmoContainer>& getAmmoContainer( ClassIDprojectileType);109 CountPointer<AmmoContainer>& getAmmoContainer(const ClassID& projectileType); 109 110 CountPointer<AmmoContainer>& getAmmoContainer(const Weapon* weapon); 110 111
Note: See TracChangeset
for help on using the changeset viewer.