Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/world_entities/weapons


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

Location:
trunk/src/world_entities/weapons
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/weapons/aim.cc

    r9656 r9869  
    2929
    3030
     31ObjectListDefinition(Aim);
    3132
    3233/**
     
    5051Aim::~Aim ()
    5152{
    52 /*  if (this->text != NULL)
    53     delete this->text;*/
     53  /*  if (this->text != NULL)
     54      delete this->text;*/
    5455}
    5556
     
    5960void Aim::init()
    6061{
    61   this->setClassID(CL_CROSSHAIR, "Aim");
     62  this->registerObject(this, Aim::_objectList);
    6263  this->setName("Aim");
    6364
     
    7980
    8081
    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");*/
    8788}
    8889
     
    9293
    9394  LoadParam(root, "texture", this, Aim, setTexture)
    94       .describe("the texture-file to load onto the Aim");
     95  .describe("the texture-file to load onto the Aim");
    9596
    9697  LoadParam(root, "size", this, Aim, setSize)
    97       .describe("the size of the Aim in Pixels");
     98  .describe("the size of the Aim in Pixels");
    9899
    99100  LoadParam(root, "rotation-speed", this, Aim, setRotationSpeed)
    100       .describe("the Speed with which the Aim should rotate");
     101  .describe("the Speed with which the Aim should rotate");
    101102
    102103  LoadParam(root, "target-group", this, Aim, setTargetGroupS);
     
    107108  ObjectManager::EntityList::iterator entity;
    108109  //printf("%d\n", this->targetGroup);
    109   for (entity = State::getObjectManager()->getObjectList(this->targetGroup).begin();
    110        entity != State::getObjectManager()->getObjectList(this->targetGroup).end();
     110  for (entity = State::getObjectManager()->getEntityList(this->targetGroup).begin();
     111       entity != State::getObjectManager()->getEntityList(this->targetGroup).end();
    111112       entity ++)
    112113  {
     
    117118      //if (this->getParent() != (*entity))
    118119      {
    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());
    120121        this->anim->replay();
    121122        this->setParentSoft(*entity, 5);
     
    125126  }
    126127
    127    //if no target found:
    128    this->setParent(PNode::getNullParent());
     128  //if no target found:
     129  this->setParent(PNode::getNullParent());
    129130}
    130131
     
    165166  this->shiftDir2D(dt * rotationSpeed);
    166167
    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 )
    173174  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 range
    175    if(this->getParent() == PNode::getNullParent() ||
     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() ||
    176177      diffVec.len() > range )// ||
    177      //( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))
    178     {
    179      this->setParentSoft(PNode::getNullParent(),5);
    180      this->searchTarget();
    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,  // z
    197 //                GraphicsEngine::modMat,
    198 //                GraphicsEngine::projMat,
    199 //                GraphicsEngine::viewPort,
    200 //                &objX,
    201 //                &objY,
    202 //                &objZ );
    203 //aa
    204 //   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);
    205206}
    206207
     
    211212{
    212213
    213  if( this->getParent() != PNode::getNullParent() )
     214  if( this->getParent() != PNode::getNullParent() )
    214215  {
    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();
    231232  }
    232233
  • trunk/src/world_entities/weapons/aim.h

    r9656 r9869  
    1919template<class T> class tAnimation;
    2020
     21
    2122//! An Aim for zooming in on Targets.
    2223/**
     
    2829class Aim : public PNode, public Element2D
    2930{
     31  ObjectListDeclaration(Aim);
    3032
    3133public:
  • trunk/src/world_entities/weapons/aiming_system.cc

    r9406 r9869  
    2121
    2222#include "state.h"
     23#include "debug.h"
    2324
    2425#include "aabb.h"
    2526#include "obb_tree.h"
    2627
    27 #include <vector>
    2828
    2929
    30 
    31 
     30ObjectListDefinition(AimingSystem);
    3231
    3332/**
     
    5554void AimingSystem::init()
    5655{
    57   this->setClassID(CL_AIMING_SYSTEM, "AimingSystem");
     56  this->registerObject(this, AimingSystem::_objectList);
    5857  this->setName("AimingSystem");
    5958
     
    6362  // registering default reactions:
    6463  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());
    6665
    6766  this->range = 1000.0f;
  • trunk/src/world_entities/weapons/aiming_system.h

    r9235 r9869  
    2121class AimingSystem : public WorldEntity
    2222{
     23  ObjectListDeclaration(AimingSystem);
    2324
    2425 public:
  • trunk/src/world_entities/weapons/aiming_turret.cc

    r9656 r9869  
    2727#include "util/loading/factory.h"
    2828
    29 CREATE_FACTORY(AimingTurret, CL_AIMING_TURRET);
    30 
     29#include "class_id_DEPRECATED.h"
     30ObjectListDefinitionID(AimingTurret, CL_AIMING_TURRET);
     31CREATE_FACTORY(AimingTurret);
    3132
    3233
     
    6465void AimingTurret::init()
    6566{
    66   this->setClassID(CL_AIMING_TURRET, "AimingTurret");
     67  this->registerObject(this, AimingTurret::_objectList);
    6768
    6869  Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this);
     
    8687
    8788  this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET);
    88   this->setProjectileType(CL_GUIDED_MISSILE);
     89  this->setProjectileTypeC("GuidedMissile");
    8990
    9091
  • trunk/src/world_entities/weapons/aiming_turret.h

    r9656 r9869  
    1313class AimingTurret : public Weapon
    1414{
     15  ObjectListDeclaration(AimingTurret);
     16
    1517public:
    1618  AimingTurret ();
  • trunk/src/world_entities/weapons/ammo_container.cc

    r9406 r9869  
    2323
    2424
    25 
     25ObjectListDefinition(AmmoContainer);
    2626/**
    2727 * standard constructor
    2828 * @todo this constructor is not jet implemented - do it
    2929*/
    30 AmmoContainer::AmmoContainer (ClassID projectileType, float maxEnergy)
     30AmmoContainer::AmmoContainer (const ClassID& projectileType, float maxEnergy)
    3131{
    32    this->setClassID(CL_AMMO_CONTAINER, "AmmoContainer");
     32  this->registerObject(this, AmmoContainer::_objectList);
    3333
    34    this->projectileType = projectileType;
    35    this->maxEnergy = maxEnergy;
     34  this->projectileType = projectileType;
     35  this->maxEnergy = maxEnergy;
    3636
    37    this->energy = 0.0;
     37  this->energy = 0.0;
    3838}
    3939
  • trunk/src/world_entities/weapons/ammo_container.h

    r6671 r9869  
    1717//! A class for Storing energy of Projectiles.
    1818class AmmoContainer : public BaseObject {
     19  ObjectListDeclaration(AmmoContainer);
    1920
    2021 public:
    21   AmmoContainer(ClassID projectileType, float maxEnergy = DEFAULT_MAX_ENERGY);
     22  AmmoContainer(const ClassID& id, float maxEnergy = DEFAULT_MAX_ENERGY);
    2223  virtual ~AmmoContainer();
    2324
    24   bool operator=(ClassID projectileType) const { return (this->projectileType == projectileType); };
     25  bool operator=(int projectileType) const { return (this->projectileType == projectileType); };
    2526  ClassID getProjectileType() const { return this->projectileType; };
    2627
  • trunk/src/world_entities/weapons/boomerang_gun.cc

    r9235 r9869  
    2727#include "util/loading/factory.h"
    2828
    29 CREATE_FACTORY(BoomerangGun, CL_BOOMERANG_GUN);
     29#include "class_id_DEPRECATED.h"
     30ObjectListDefinitionID(BoomerangGun, CL_BOOMERANG_GUN);
     31CREATE_FACTORY(BoomerangGun);
    3032
    3133
     
    6163void BoomerangGun::init()
    6264{
    63   this->setClassID(CL_BOOMERANG_GUN, "BoomerangGun");
     65  this->registerObject(this, BoomerangGun::_objectList);
    6466
    6567
     
    8587
    8688  this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET);
    87   this->setProjectileType(CL_BOOMERANG_PROJECTILE);
     89  this->setProjectileTypeC("BoomerangProjectile");
    8890
    8991  this->loadModel("models/guns/turret1.obj", 5.0);
  • trunk/src/world_entities/weapons/boomerang_gun.h

    r9235 r9869  
    1111class BoomerangGun : public Weapon
    1212  {
     13    ObjectListDeclaration(BoomerangGun);
    1314  public:
    1415    BoomerangGun ();
  • trunk/src/world_entities/weapons/cannon.cc

    r9406 r9869  
    3232#include "animation3d.h"
    3333
    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"
     39ObjectListDefinitionID(Cannon, CL_CANNON);
     40CREATE_FACTORY(Cannon);
    4041
    4142/**
     
    6970void Cannon::init()
    7071{
    71   this->setClassID(CL_CANNON, "Cannon");
     72  this->registerObject(this, Cannon::_objectList);
    7273
    7374//  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN);
     
    8889
    8990  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_HEAVY);
    90   this->setProjectileType(CL_BOMB);
     91  this->setProjectileTypeC("Bomb");
    9192  this->prepareProjectiles(5);
    9293
  • trunk/src/world_entities/weapons/cannon.h

    r8777 r9869  
    1212class Cannon : public Weapon
    1313  {
     14    ObjectListDeclaration(Cannon);
    1415  public:
    1516    Cannon ();
  • trunk/src/world_entities/weapons/crosshair.cc

    r9406 r9869  
    2626
    2727
    28 
     28ObjectListDefinition(Crosshair);
    2929/**
    3030 * standart constructor
     
    5454void Crosshair::init()
    5555{
    56   this->setClassID(CL_CROSSHAIR, "Crosshair");
     56  this->registerObject(this, Crosshair::_objectList);
    5757  this->setName("Crosshair");
    5858
  • trunk/src/world_entities/weapons/crosshair.h

    r7221 r9869  
    2222//! A class that enables the
    2323class Crosshair : public PNode, public Element2D, public EventListener {
    24 
     24  ObjectListDeclaration(Crosshair);
    2525 public:
    2626  Crosshair(const TiXmlElement* root = NULL);
  • trunk/src/world_entities/weapons/fps_sniper_rifle.cc

    r9406 r9869  
    2929
    3030
    31 #include "fast_factory.h"
     31#include "loading/fast_factory.h"
    3232
    3333#include "fps_sniper_rifle.h"
     
    3939
    4040
    41 CREATE_FACTORY(FPSSniperRifle, CL_FPS_SNIPER_RIFLE);
     41#include "class_id_DEPRECATED.h"
     42ObjectListDefinitionID(FPSSniperRifle, CL_FPS_SNIPER_RIFLE);
     43CREATE_FACTORY(FPSSniperRifle);
    4244
    4345/**
     
    7678void FPSSniperRifle::init()
    7779{
    78   this->setClassID(CL_FPS_SNIPER_RIFLE, "FPSSniperRifle");
     80  this->registerObject(this, FPSSniperRifle::_objectList);
    7981
    8082  this->loadModel("models/guns/fps_sniper_rifle.obj", 0.2);
     
    98100
    99101  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    100   this->setProjectileType(CL_LASER);
     102  this->setProjectileTypeC("Laser");
    101103  this->prepareProjectiles(20);
    102104
     
    181183
    182184  this->material->select();
    183   static_cast<StaticModel*>(this->getModel())->draw();
     185  this->getModel()->draw();
     186  //static_cast<StaticModel*>(this->getModel())->draw();
    184187
    185188  glPopMatrix();
  • trunk/src/world_entities/weapons/fps_sniper_rifle.h

    r9003 r9869  
    3939class FPSSniperRifle : public Weapon
    4040  {
     41    ObjectListDeclaration(FPSSniperRifle);
     42
    4143  public:
    4244    FPSSniperRifle (int leftRight);
  • trunk/src/world_entities/weapons/hyperblaster.cc

    r9406 r9869  
    3131#include "animation3d.h"
    3232
    33 #include "fast_factory.h"
     33#include "loading/fast_factory.h"
    3434
    3535
    3636
    37 
    38 CREATE_FACTORY(Hyperblaster, CL_HYPERBLASTER);
     37#include "class_id_DEPRECATED.h"
     38ObjectListDefinitionID(Hyperblaster, CL_HYPERBLASTER);
     39CREATE_FACTORY(Hyperblaster);
    3940
    4041Hyperblaster::Hyperblaster(const TiXmlElement* root)
     
    5657void Hyperblaster::init()
    5758{
    58   this->setClassID(CL_HYPERBLASTER, "Hyperblaster");
     59  this->registerObject(this, Hyperblaster::_objectList);
    5960
    6061//  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN);
     
    7677
    7778  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_HEAVY);
    78   this->setProjectileType(CL_HYPERBLAST);
     79  this->setProjectileTypeC("Hyperblast");
    7980  this->prepareProjectiles(2);
    8081
  • trunk/src/world_entities/weapons/hyperblaster.h

    r8777 r9869  
    1212class Hyperblaster : public Weapon
    1313  {
    14   public:
     14    ObjectListDeclaration(Hyperblaster);
     15    public:
    1516    Hyperblaster (const TiXmlElement* root = NULL);
    1617    virtual ~Hyperblaster ();
  • trunk/src/world_entities/weapons/laser_cannon.cc

    r9656 r9869  
    2929#include "animation3d.h"
    3030
    31 #include "fast_factory.h"
     31#include "loading/fast_factory.h"
    3232
    33 CREATE_FACTORY(LaserCannon, CL_LASER_CANNON);
    34 
     33#include "class_id_DEPRECATED.h"
     34ObjectListDefinitionID(LaserCannon, CL_LASER_CANNON);
     35CREATE_FACTORY(LaserCannon);
    3536
    3637LaserCannon::LaserCannon(const TiXmlElement* root)
     
    5253void LaserCannon::init()
    5354{
    54   this->setClassID(CL_LASER_CANNON, "LaserCannon");
     55  this->registerObject(this, LaserCannon::_objectList);
    5556
    5657//  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/laser_cannon.obj", OBJ, RP_CAMPAIGN);
     
    7273
    7374  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    74   this->setProjectileType(CL_RAIL_PROJECTILE);
     75  this->setProjectileTypeC("RailProjectile");
    7576  this->prepareProjectiles(100);
    7677  this->setEmissionPoint(Vector(2.8,0,0) * 5.0);
  • trunk/src/world_entities/weapons/laser_cannon.h

    r9235 r9869  
    2929class LaserCannon : public Weapon
    3030  {
    31   public:
     31    ObjectListDeclaration(LaserCannon);
     32    public:
    3233    LaserCannon (const TiXmlElement* root = NULL);
    3334    virtual ~LaserCannon ();
  • trunk/src/world_entities/weapons/targeting_turret.cc

    r9656 r9869  
    2626#include "util/loading/factory.h"
    2727
    28 CREATE_FACTORY(TargetingTurret, CL_TARGETING_TURRET);
     28#include "class_id_DEPRECATED.h"
     29ObjectListDefinitionID(TargetingTurret, CL_TARGETING_TURRET);
     30CREATE_FACTORY(TargetingTurret);
    2931
    3032
    3133TargetingTurret::TargetingTurret(const TiXmlElement* root)
    32   : target(this)
    3334{
    3435  this->init();
     
    4243TargetingTurret::~TargetingTurret ()
    4344{
     45  if(Aim::objectList().exists(target))
     46    delete target;
    4447  // model will be deleted from WorldEntity-destructor
    4548//  delete this->target;
     
    4851void TargetingTurret::init()
    4952{
    50   this->setClassID(CL_TARGETING_TURRET, "TargetingTurret");
     53  this->registerObject(this, TargetingTurret::_objectList);
     54  this->target = new Aim(this);
    5155
    5256  Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this);
     
    7074
    7175  this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET);
    72   this->setProjectileType(CL_GUIDED_MISSILE);
     76  this->setProjectileTypeC("GuidedMissile");
    7377
    7478
     
    7680  //this->getProjectileFactory()->prepare(100);
    7781
    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;
    8387
    8488  this->lockedTime = 0;
     
    97101  Weapon::loadParams(root);
    98102
    99   LoadParam(root, "target-group", &target, Aim, setTargetGroupS);
     103  LoadParam(root, "target-group", target, Aim, setTargetGroupS);
    100104
    101105}
     
    109113void TargetingTurret::deactivate()
    110114{
    111   this->target.setVisibility(false);
     115  this->target->setVisibility(false);
    112116}
    113117
     
    117121    return;
    118122
    119   this->target.tick(dt);
     123  this->target->tick(dt);
    120124
    121125  if( lockedTime >= neededLockTime )
    122126   {
    123     lockedTarget = this->target.getParent();
     127    lockedTarget = this->target->getParent();
    124128    lockedTime = 0;
    125129   }
    126130
    127131
    128   if(this->target.getParent() == PNode::getNullParent())
     132  if(this->target->getParent() == PNode::getNullParent())
    129133   lockedTime = 0;
    130134  else
  • trunk/src/world_entities/weapons/targeting_turret.h

    r9656 r9869  
    1212class TargetingTurret : public Weapon
    1313{
     14  ObjectListDeclaration(TargetingTurret);
    1415public:
    1516  TargetingTurret(const TiXmlElement* root = NULL);
     
    2627  virtual void draw() const;
    2728
    28   void setTargetGroup(OM_LIST targetGroup) { this->target.setTargetGroup(targetGroup); };
     29  void setTargetGroup(OM_LIST targetGroup) { this->target->setTargetGroup(targetGroup); };
    2930  const PNode* getLockedTarget() const { return lockedTarget; };
    3031
     
    3334
    3435private:
    35   Aim            target;
     36  Aim*           target;
    3637  PNode*         lockedTarget;
    3738  float          lockedTime;
  • trunk/src/world_entities/weapons/test_gun.cc

    r9656 r9869  
    3131#include "animation3d.h"
    3232
    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"
     36ObjectListDefinitionID(TestGun, CL_TEST_GUN);
     37CREATE_FACTORY(TestGun);
    3738/**
    3839 *  standard constructor
     
    109110void TestGun::init()
    110111{
    111   this->setClassID(CL_TEST_GUN, "TestGun");
    112 
     112  this->registerObject(this, TestGun::_objectList);
    113113//  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN);
    114114
     
    129129
    130130  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    131   this->setProjectileType(CL_LASER);
     131  this->setProjectileTypeC("Laser");
    132132  this->prepareProjectiles(100);
    133133
  • trunk/src/world_entities/weapons/test_gun.h

    r8777 r9869  
    3737class TestGun : public Weapon
    3838  {
     39    ObjectListDeclaration(TestGun);
    3940  public:
    4041    TestGun (int leftRight);
  • trunk/src/world_entities/weapons/turret.cc

    r9406 r9869  
    2727#include "util/loading/factory.h"
    2828
    29 CREATE_FACTORY(Turret, CL_TURRET);
    30 
    31 
     29#include "class_id_DEPRECATED.h"
     30ObjectListDefinitionID(Turret, CL_TURRET);
     31CREATE_FACTORY(Turret);
    3232
    3333/**
     
    6262void Turret::init()
    6363{
    64   this->setClassID(CL_TURRET, "Turret");
     64  this->registerObject(this, Turret::_objectList);
    6565
    6666
     
    8686
    8787  this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET);
    88   this->setProjectileType(CL_ROCKET);
     88  this->setProjectileTypeC("Rocket");
    8989
    9090  this->loadModel("models/guns/turret1.obj");
  • trunk/src/world_entities/weapons/turret.h

    r8777 r9869  
    1111class Turret : public Weapon
    1212  {
     13    ObjectListDeclaration(Turret);
    1314  public:
    1415    Turret ();
  • trunk/src/world_entities/weapons/weapon.cc

    r9406 r9869  
    2121#include "weapon.h"
    2222
    23 #include "fast_factory.h"
     23#include "loading/fast_factory.h"
    2424#include "world_entities/projectiles/projectile.h"
    2525
    26 #include "util/loading/resource_manager.h"
    27 #include "class_list.h"
    2826#include "util/loading/factory.h"
    2927#include "util/loading/load_param.h"
     
    3331#include "sound_source.h"
    3432#include "sound_buffer.h"
     33#include "resource_sound_buffer.h"
    3534
    3635#include "elements/glgui_energywidget.h"
    3736
    38 
     37ObjectListDefinition(Weapon);
    3938
    4039////////////////////
     
    5857{
    5958  for (int i = 0; i < WS_STATE_COUNT; i++)
    60     if (this->animation[i] && ClassList::exists(animation[i], CL_ANIMATION))  //!< @todo this should check animation3D
     59    if (this->animation[i] && Animation::objectList().exists(animation[i]))  //!< @todo this should check animation3D
    6160      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))
    6763    delete this->soundSource;
    6864}
     
    7369 * @returns the newly created Weapon.
    7470 */
    75 Weapon* Weapon::createWeapon(ClassID weaponID)
     71Weapon* Weapon::createWeapon(const ClassID& weaponID)
    7672{
    7773  BaseObject* createdObject = Factory::fabricate(weaponID);
    7874  if (createdObject != NULL)
    7975  {
    80     if (createdObject->isA(CL_WEAPON))
     76    if (createdObject->isA(Weapon::staticClassID()))
    8177      return dynamic_cast<Weapon*>(createdObject);
    8278    else
     
    8985}
    9086
     87Weapon* 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
    91104/**
    92105 * initializes the Weapon with ALL default values
     
    96109void Weapon::init()
    97110{
    98   this->setClassID(CL_WEAPON, "Weapon");
     111  this->registerObject(this, Weapon::_objectList);
    99112  this->currentState     = WS_INACTIVE;            //< Normaly the Weapon is Inactive
    100113  this->requestedAction  = WA_NONE;                //< No action is requested by default
     
    105118    this->animation[i] = NULL;                   //< No animation
    106119  }
    107   for (int i = 0; i < WA_ACTION_COUNT; i++)
    108     this->soundBuffers[i] = NULL;                  //< No Sounds
    109120
    110121  this->soundSource = new OrxSound::SoundSource(this);       //< Every Weapon has exacty one SoundSource.
     
    115126  this->defaultTarget = NULL;                      //< Nothing is Targeted by default.
    116127
    117   this->projectile = CL_NULL;                      //< No Projectile Class is Connected to this weapon
     128  this->projectile = NullClass::staticClassID();         //< No Projectile Class is Connected to this weapon
    118129  this->projectileFactory = NULL;                  //< No Factory generating Projectiles is selected.
    119130
     
    163174 * What it does, is telling the Weapon what Projectiles it can Emit.
    164175 */
    165 void Weapon::setProjectileType(ClassID projectile)
    166 {
    167   if (projectile == CL_NULL)
    168     return;
     176void Weapon::setProjectileType(const ClassID& projectile)
     177{
    169178  this->projectile = projectile;
    170179  this->projectileFactory = FastFactory::searchFastFactory(projectile);
     
    259268  if (action >= WA_ACTION_COUNT)
    260269    return;
    261   if (this->soundBuffers[action] != NULL)
    262     ResourceManager::getInstance()->unload(this->soundBuffers[action]);
    263270
    264271  else if (!soundFile.empty())
    265272  {
    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())
    268275    {
    269276      PRINTF(4)("Loaded sound %s to action %s.\n", soundFile.c_str(), actionToChar(action));
     
    275282  }
    276283  else
    277     this->soundBuffers[action] = NULL;
     284    this->soundBuffers[action] = OrxSound::SoundBuffer();
    278285}
    279286
     
    409416  {
    410417    case WA_SHOOT:
    411       return this->fireW();
    412       break;
     418    return this->fireW();
     419    break;
    413420    case WA_CHARGE:
    414       return this->chargeW();
    415       break;
     421    return this->chargeW();
     422    break;
    416423    case WA_RELOAD:
    417       return this->reloadW();
    418       break;
     424    return this->reloadW();
     425    break;
    419426    case WA_DEACTIVATE:
    420       return this->deactivateW();
    421       break;
     427    return this->deactivateW();
     428    break;
    422429    case WA_ACTIVATE:
    423       return this->activateW();
    424       break;
     430    return this->activateW();
     431    break;
    425432    default:
    426       PRINTF(2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action));
    427       return false;
     433    PRINTF(2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action));
     434    return false;
    428435  }
    429436}
     
    438445  {
    439446    // play Sound
    440     if (likely(this->soundBuffers[WA_ACTIVATE] != NULL))
     447    if (likely(this->soundBuffers[WA_ACTIVATE].loaded()))
    441448      this->soundSource->play(this->soundBuffers[WA_ACTIVATE]);
    442449    this->updateWidgets();
     
    460467    PRINTF(4)("Deactivating the Weapon %s\n", this->getCName());
    461468    // play Sound
    462     if (this->soundBuffers[WA_DEACTIVATE] != NULL)
     469    if (this->soundBuffers[WA_DEACTIVATE].loaded())
    463470      this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]);
    464471    // deactivate
     
    479486  {
    480487    // playing Sound
    481     if (this->soundBuffers[WA_CHARGE] != NULL)
     488    if (this->soundBuffers[WA_CHARGE].loaded())
    482489      this->soundSource->play(this->soundBuffers[WA_CHARGE]);
    483490
     
    504511  {
    505512    // playing Sound
    506     if (this->soundBuffers[WA_SHOOT] != NULL)
     513    if (this->soundBuffers[WA_SHOOT].loaded())
    507514      this->soundSource->play(this->soundBuffers[WA_SHOOT]);
    508515    this->updateWidgets();
     
    528535{
    529536  PRINTF(4)("Reloading Weapon %s\n", this->getCName());
    530   if (this->ammoContainer.get() != NULL &&
     537  if (!this->ammoContainer.isNull() &&
    531538      unlikely(this->energy + this->ammoContainer->getStoredEnergy() < this->minCharge))
    532539  {
     
    537544
    538545
    539   if (this->soundBuffers[WA_RELOAD] != NULL)
     546  if (this->soundBuffers[WA_RELOAD].loaded())
    540547    this->soundSource->play(this->soundBuffers[WA_RELOAD]);
    541548
    542   if (this->ammoContainer.get() != NULL)
     549  if (!this->ammoContainer.isNull())
    543550    this->ammoContainer->fillWeapon(this);
    544551  else
     
    680687  {
    681688    case WA_SHOOT:
    682       return "shoot";
    683       break;
     689    return "shoot";
     690    break;
    684691    case WA_CHARGE:
    685       return "charge";
    686       break;
     692    return "charge";
     693    break;
    687694    case WA_RELOAD:
    688       return "reload";
    689       break;
     695    return "reload";
     696    break;
    690697    case WA_ACTIVATE:
    691       return "activate";
    692       break;
     698    return "activate";
     699    break;
    693700    case WA_DEACTIVATE:
    694       return "deactivate";
    695       break;
     701    return "deactivate";
     702    break;
    696703    case WA_SPECIAL1:
    697       return "special1";
    698       break;
     704    return "special1";
     705    break;
    699706    default:
    700       return "none";
    701       break;
     707    return "none";
     708    break;
    702709  }
    703710}
     
    743750  {
    744751    case WS_SHOOTING:
    745       return "shooting";
    746       break;
     752    return "shooting";
     753    break;
    747754    case WS_CHARGING:
    748       return "charging";
    749       break;
     755    return "charging";
     756    break;
    750757    case WS_RELOADING:
    751       return "reloading";
    752       break;
     758    return "reloading";
     759    break;
    753760    case WS_ACTIVATING:
    754       return "activating";
    755       break;
     761    return "activating";
     762    break;
    756763    case WS_DEACTIVATING:
    757       return "deactivating";
    758       break;
     764    return "deactivating";
     765    break;
    759766    case WS_IDLE:
    760       return "idle";
    761       break;
     767    return "idle";
     768    break;
    762769    case WS_INACTIVE:
    763       return "inactive";
    764       break;
     770    return "inactive";
     771    break;
    765772    default:
    766       return "none";
    767       break;
    768   }
    769 }
     773    return "none";
     774    break;
     775  }
     776}
  • trunk/src/world_entities/weapons/weapon.h

    r8976 r9869  
    1919#include "ammo_container.h"
    2020
     21#include "sound_buffer.h"
     22
    2123// FORWARD DECLARATION
    2224class Projectile;
     
    8385class Weapon : public WorldEntity
    8486{
     87  ObjectListDeclaration(Weapon);
     88
    8589  public:
    8690    // INITIALISATION //
    8791    Weapon ();
    8892    virtual ~Weapon ();
    89     static Weapon* createWeapon(ClassID weaponID);
     93    static Weapon* createWeapon(const ClassID& weaponID);
     94    static Weapon* createWeapon(const std::string& weaponName);
    9095
    9196    void init();
     
    110115    /** @returns the Capabilities of this Weapon */
    111116    inline long getCapability() const { return this->capability; };
    112     void setProjectileType(ClassID projectile);
     117    void setProjectileType(const ClassID& projectile);
    113118    void setProjectileTypeC(const std::string& projectile);
    114119    /** @returns The projectile's classID */
     
    216221    // PHASES //
    217222    ////////////
    218     OrxSound::SoundSource* soundSource;                      //!< A SoundSource to play sound from (this is connected to the PNode of the Weapon)
    219 
    220     WeaponState            currentState;                     //!< The State the weapon is in.
    221     WeaponAction           requestedAction;                  //!< An action to try to Engage after the currentState ends.
    222     float                  stateDuration;                    //!< how long the state has taken until now.
    223     float                  times[WS_STATE_COUNT];            //!< Times to stay in the different States @see WeaponState.
    224     Animation3D*           animation[WS_STATE_COUNT];        //!< Animations for all the States (you can say yourself on what part of the gun this animation acts).
    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.
    226231
    227232    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  
    1717*/
    1818
    19 #define DEBUG_SPECIAL_MODULE 4 //DEBUG_MODULE_WEAPON
     19#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
    2020
    2121#include "weapon_manager.h"
    2222#include "weapon.h"
    2323#include "crosshair.h"
    24 #include "class_list.h"
    2524
    2625#include "playable.h"
    2726
    28 #include "util/loading/load_param.h"
     27#include "util/loading/load_param_xml.h"
    2928#include "util/loading/factory.h"
    3029
     
    3231
    3332
     33ObjectListDefinition(WeaponManager);
    3434/**
    3535 * @brief this initializes the weaponManager for a given nnumber of weapon slots
     
    5757  // crosshair being a PNode it must not be deleted (this is because PNodes delete themselves.)
    5858  // 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;
    6161}
    6262
     
    6666void WeaponManager::init()
    6767{
    68   this->setClassID(CL_WEAPON_MANAGER, "WeaponManager");
     68  this->registerObject(this, WeaponManager::_objectList);
    6969
    7070  this->parentNode = NULL;
     
    298298  {
    299299    this->parentNode->addChild(weapon);
    300     if (this->parentEntity->isA(CL_PLAYABLE))
     300    if (this->parentEntity->isA(Playable::staticClassID()))
    301301      dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged();
    302302    weapon->setDefaultTarget(this->crosshair);
    303303  }
    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);
    305305  return true;
    306306}
     
    311311 * @param ammo the ammo to increase
    312312 */
    313 float WeaponManager::increaseAmmunition(ClassID projectileType, float ammo)
     313float WeaponManager::increaseAmmunition(const ClassID& projectileType, float ammo)
    314314{
    315315  return this->getAmmoContainer(projectileType)->increaseEnergy(ammo);
     
    324324{
    325325  assert (weapon != NULL);
    326   return this->increaseAmmunition(weapon->getLeafClassID(), ammo);
     326  return this->increaseAmmunition(weapon->getClassID(), ammo);
    327327
    328328}
     
    468468      else
    469469        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()))
    471471        dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged();
    472472    }
     
    523523}
    524524
    525 CountPointer<AmmoContainer>& WeaponManager::getAmmoContainer(ClassID projectileType)
     525CountPointer<AmmoContainer>& WeaponManager::getAmmoContainer(const ClassID& projectileType)
    526526{
    527527  for (unsigned int i = 0; i < this->ammo.size(); i++)
     
    537537{
    538538  assert (weapon != NULL);
    539   return (this->getAmmoContainer(weapon->getLeafClassID()));
     539  return (this->getAmmoContainer(weapon->getClassID()));
    540540}
    541541
  • trunk/src/world_entities/weapons/weapon_manager.h

    r8844 r9869  
    3939 */
    4040class WeaponManager : public BaseObject {
     41  ObjectListDeclaration(WeaponManager);
    4142
    4243  //! an enumerator defining a Slot, where a Weapon can be stored inside.
     
    8990    void changeWeaponConfig(int weaponConfig);
    9091
    91     float increaseAmmunition(ClassID projectileType, float ammo);
     92    float increaseAmmunition(const ClassID& projectileType, float ammo);
    9293    float inclreaseAmmunition(const Weapon* weapon, float ammo);
    9394
     
    106107 // private:
    107108    int getNextFreeSlot(int configID, long capability = WTYPE_ALL);
    108     CountPointer<AmmoContainer>& getAmmoContainer(ClassID projectileType);
     109    CountPointer<AmmoContainer>& getAmmoContainer(const ClassID& projectileType);
    109110    CountPointer<AmmoContainer>& getAmmoContainer(const Weapon* weapon);
    110111
Note: See TracChangeset for help on using the changeset viewer.