Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5356 in orxonox.OLD for trunk/src/world_entities/weapons/weapon.cc


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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/**
Note: See TracChangeset for help on using the changeset viewer.