Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5356 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Oct 10, 2005, 8:17:44 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: saver Weapon-Projectile-generation and Stuff

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/coord/p_node.h

    r5209 r5356  
    2424#include "base_object.h"
    2525#include "vector.h"
    26 
    27 
    2826
    2927// FORWARD DEFINITION \\
  • trunk/src/lib/graphics/spatial_separation/spatial_separation.h

    r5039 r5356  
    77
    88#include "base_object.h"
    9 #include "vector.h"
    109
    1110
  • trunk/src/util/loading/factory.h

    r5355 r5356  
    8484tFactory<T>::tFactory(const char* factoryName) : Factory(factoryName)
    8585{
    86   PRINTF(1)("Class: %s loadable\n", this->getName());
     86 printf("Class: %s loadable\n", this->getName());
    8787}
    8888
  • trunk/src/world_entities/skybox.cc

    r5355 r5356  
    2020#include "skybox.h"
    2121
     22#include "load_param.h"
    2223#include "factory.h"
    23 
    24 #include "load_param.h"
    25 #include "material.h"
    26 #include "vector.h"
    27 #include "resource_manager.h"
    28 #include "model.h"
    29 //#include "world_entity.h"
    30 
     24#include "list.h"
     25
     26using namespace std;
    3127CREATE_FACTORY(SkyBox);
    32 
    33 using namespace std;
    3428
    3529/**
  • trunk/src/world_entities/terrain.cc

    r5308 r5356  
    1717#include "terrain.h"
    1818
    19 #include "model.h"
    20 #include "vector.h"
    21 #include "glincl.h"
    22 
     19#include "load_param.h"
    2320#include "factory.h"
    24 #include "load_param.h"
    25 #include "resource_manager.h"
    2621#include "spatial_separation.h"
    2722
  • trunk/src/world_entities/weapons/test_gun.cc

    r5355 r5356  
    134134  this->setActionSound(WA_SHOOT, "sound/shot1.wav");
    135135
    136   this->setProjectile(CL_TEST_BULLET);
    137   this->getProjectileFactory()->prepare(20);
     136  this->setProjectileType(CL_TEST_BULLET);
     137  this->prepareProjectiles(20);
    138138}
    139139
     
    178178void TestGun::fire()
    179179{
    180   Projectile* pj =  dynamic_cast<Projectile*>(this->getProjectileFactory()->resurrect());
     180  Projectile* pj =  this->getProjectile();
     181  if (pj == NULL)
     182    return;
    181183
    182184  pj->setParent(NullParent::getInstance());
  • trunk/src/world_entities/weapons/turret.cc

    r5355 r5356  
    2828
    2929#include "factory.h"
    30 #include "fast_factory.h"
    3130
    3231CREATE_FACTORY(Turret);
     
    9392
    9493
    95   this->setProjectile(CL_TEST_BULLET);
     94  this->setProjectileType(CL_TEST_BULLET);
    9695
    9796
     
    133132void Turret::fire()
    134133{
    135   Projectile* pj =  dynamic_cast<Projectile*>(this->getProjectileFactory()->resurrect());
     134  Projectile* pj = this->getProjectile();
     135  if (pj == NULL)
     136    return;
    136137
    137138  PNode* target = this->getWeaponManager()->getFixedTarget();
  • trunk/src/world_entities/weapons/weapon.cc

    r5355 r5356  
    102102  static_cast<WorldEntity*>(this)->loadParams(root);
    103103
    104   LoadParam<Weapon>(root, "projectile", this, &Weapon::setProjectile)
     104  LoadParam<Weapon>(root, "projectile", this, &Weapon::setProjectileType)
    105105      .describe("Sets the name of the Projectile to load onto the Entity");
    106106
     
    122122 * be aware, that this function does not create Factories, as this is job of Bullet-classes.
    123123 */
    124 void Weapon::setProjectile(ClassID projectile)
     124void Weapon::setProjectileType(ClassID projectile)
    125125{
    126126  if (projectile == CL_NULL)
     
    148148 * @param projectile the Name of the Projectile.
    149149 */
    150 void Weapon::setProjectile(const char* projectile)
     150void Weapon::setProjectileType(const char* projectile)
    151151{
    152152  if (projectile == NULL)
     
    155155  if (tmpFac != NULL)
    156156  {
    157     this->setProjectile(tmpFac->getStoredID());
    158   }
    159   else
    160   {
    161     PRINTF(2)("Projectile %s does not exist for weapon %s\n", projectile, this->getName());
    162   }
    163 }
     157    this->setProjectileType(tmpFac->getStoredID());
     158  }
     159  else
     160  {
     161    PRINTF(1)("Projectile %s does not exist for weapon %s\n", projectile, this->getName());
     162  }
     163}
     164
     165/**
     166 * prepares Projectiles of the Weapon
     167 * @param count how many Projectiles to create
     168 */
     169void Weapon::prepareProjectiles(unsigned int count)
     170{
     171  if (this->projectileFactory != NULL)
     172    projectileFactory->prepare(count);
     173  else
     174    PRINTF(2)("unable to create %d projectile for Weapon %s\n", count, this->getName());
     175}
     176
     177/**
     178 * resurects and returns a Projectile
     179 * @returns a Projectile on success, NULL on error (ProjectileFastFactory not Found)
     180 */
     181Projectile* Weapon::getProjectile()
     182{
     183  if (this->projectileFactory)
     184    return dynamic_cast<Projectile*>(this->projectileFactory->resurrect());
     185  else
     186  {
     187    PRINTF(2)("No projectile defined for Weapon %s cant return any\n", this->getName());
     188    return NULL;
     189  }
     190}
     191
    164192
    165193/**
  • trunk/src/world_entities/weapons/weapon.h

    r5355 r5356  
    106106
    107107    // FUNCTIONS TO SET THE WEAPONS PROPERTIES.
    108     void setProjectile(ClassID projectile);
    109     void setProjectile(const char* projectile);
     108    void setProjectileType(ClassID projectile);
     109    void setProjectileType(const char* projectile);
    110110    /** @returns The projectile's classID */
    111     inline ClassID getProjectile() { return this->projectile; };
     111    inline ClassID getProjectileType() { return this->projectile; };
    112112    /** @returns the FastFactory, that creates Projectiles of type getProjectile */
    113113    inline FastFactory* getProjectileFactory() { return this->projectileFactory; };
     114    void prepareProjectiles(unsigned int count);
     115    Projectile* getProjectile();
    114116
    115117
  • trunk/src/world_entities/world_entity.h

    r5355 r5356  
    88
    99#include "p_node.h"
    10 
    1110#include "model.h"
    12 
    1311
    1412// FORWARD DECLARATION
Note: See TracChangeset for help on using the changeset viewer.