Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jul 23, 2005, 11:17:27 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: ProjectileFactory now handled in Weapon-class

Location:
orxonox/trunk/src/world_entities/weapons
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/weapons/test_bullet.cc

    r4942 r4947  
    2222#include "vector.h"
    2323#include "garbage_collector.h"
     24#include "fast_factory.h"
    2425
    2526using namespace std;
    2627
     28CREATE_FAST_FACTORY(TestBullet, CL_TEST_BULLET);
    2729
    2830/**
  • orxonox/trunk/src/world_entities/weapons/test_gun.cc

    r4940 r4947  
    112112  this->setActionSound(WA_SHOOT, "sound/shot1.wav");
    113113
    114   this->bulletFactory = tFastFactory<TestBullet>::getFastFactory(CL_TEST_BULLET, "TestBullet");
    115   this->bulletFactory->prepare(100);
     114  this->setProjectile(CL_TEST_BULLET);
     115  this->getProjectileFactory()->prepare(100);
    116116}
    117117
     
    158158void TestGun::fire()
    159159{
    160   Projectile* pj =  dynamic_cast<Projectile*>(this->bulletFactory->resurrect());
     160  Projectile* pj =  dynamic_cast<Projectile*>(this->getProjectileFactory()->resurrect());
    161161
    162162  pj->setAbsCoor(this->getEmissionPoint());
  • orxonox/trunk/src/world_entities/weapons/test_gun.h

    r4934 r4947  
    5454
    5555    int leftRight;   // this will become an enum
    56 
    57     tFastFactory<TestBullet>*       bulletFactory;  //!< The factory for fast interaction with the TestBullet Class.
    58 
    59 
    60 
    6156  };
    6257#endif /* _TEST_GUN_H */
  • orxonox/trunk/src/world_entities/weapons/weapon.cc

    r4934 r4947  
    8080  this->emissionPoint.setParent(this);
    8181
    82   this->projectile = NULL;
     82  this->projectile = CL_NULL;
     83  this->projectileFactory = NULL;
    8384
    8485  this->hideInactive = true;
     
    9394}
    9495
     96/**
     97 * sets the Projectile to use for this weapon.
     98 * @param projectile The ID of the Projectile to use
     99 *
     100 * be aware, that this function does not create Factories, as this is job of Bullet-classes.
     101 */
     102bool Weapon::setProjectile(ClassID projectile)
     103{
     104  if (projectile == CL_NULL)
     105    return false;
     106  this->projectile = projectile;
     107  this->projectileFactory = FastFactory::searchFastFactory(projectile);
     108  if (this->projectileFactory == NULL)
     109    return false;
     110};
    95111
    96112/**
     
    446462  bool retVal = true;
    447463
    448   if (this->projectile == NULL)
     464//  if (this->projectile == NULL)
    449465  {
    450466    PRINTF(2)("There was no projectile assigned to the Weapon.\n");
  • orxonox/trunk/src/world_entities/weapons/weapon.h

    r4934 r4947  
    2020
    2121#include "world_entity.h"
     22#include "fast_factory.h"
    2223
    2324// FORWARD DECLARATION
     
    7980    ////////////////////
    8081
     82    // INTERACTIVITY //
    8183    void requestAction(WeaponAction action);
    8284    float increaseEnergy(float energyToAdd);
     85    ///////////////////
     86
    8387
    8488    /** @returns true if the Weapon is Active  (this is used to check if the weapon must be drawn)*/
     
    8892
    8993    // FUNCTIONS TO SET THE WEAPONS PROPERTIES.
    90     /** @param projectile a projectile for this weapon */
    91     void setProjectile(Projectile* projectile) { this->projectile = projectile; };
    92     /** @returns The projectile if availiable */
    93     Projectile* getProjectile() { return this->projectile; };
     94    bool setProjectile(ClassID projectile);
     95    /** @returns The projectile's classID */
     96    inline ClassID getProjectile() { return this->projectile; };
     97    /** @returns the FastFactory, that creates Projectiles of type getProjectile */
     98    inline FastFactory* getProjectileFactory() { return this->projectileFactory; };
     99
    94100
    95101    void setEmissionPoint(const Vector& point);
     
    188194    bool                 chargeable;                      //!< if the Weapon is charcheable (if true, the weapon will charge before it fires.)
    189195
    190     Projectile*          projectile;                      //!< the projectile used for this weapon
     196    ClassID              projectile;                      //!< the projectile used for this weapon (since they should be generated via macro and the FastFactory, only the ClassID must be known.)
     197    FastFactory*         projectileFactory;               //!< A factory, that produces and handles the projectiles.
    191198  };
    192199
Note: See TracChangeset for help on using the changeset viewer.