Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6054 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Dec 11, 2005, 6:23:42 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: multiple new Reparenting modes in PNode.
Testing the stuff in GuidedMissile
Projectile has a PNode as reference not as pointer
some minor weapon changes

Location:
trunk/src/world_entities
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/npcs/npc.cc

    r6004 r6054  
    5959    }
    6060    State::getWorldEntityList()->remove(this);
     61    this->removeNode();
    6162
    6263      this->collider = entity;
     
    6869    this->setVisibiliy(false);
    6970    State::getWorldEntityList()->remove(this);
     71    this->removeNode();
    7072  }
    7173}
  • trunk/src/world_entities/npcs/npc_test.cc

    r6004 r6054  
    5858
    5959
    60 void NPC2::collidesWith(WorldEntity* entity, const Vector& location)
    61 {
    62   if (entity->isA(CL_PROJECTILE))
    63   {
    64     PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
    65     this->applyForce(Vector(0,0,0)-location*1000);
    66   }
    67   else if (entity->isA(CL_PLAYER))
    68     this->applyForce(Vector(0,0,0)-location*100);
    69   else
    70   {
    71     this->setVisibiliy(false);
    72    State::getWorldEntityList()->remove(this);
    73   }
    74 }
    75 
    7660
    7761/**
  • trunk/src/world_entities/npcs/npc_test.h

    r6004 r6054  
    2020  virtual void draw() const;
    2121
    22   virtual void collidesWith (WorldEntity* entity, const Vector& location);
    23 
    24 
    2522 private:
    2623   Vector   randomRotAxis;
  • trunk/src/world_entities/npcs/npc_test1.cc

    r6004 r6054  
    4646
    4747
    48 void NPCTest1::collidesWith(WorldEntity* entity, const Vector& location)
    49 {
    50   if (entity->isA(CL_PROJECTILE) && entity != this->collider)
    51   {
    52 //    PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
    53 //    this->applyForce(Vector(0,0,0)-location*1000);
    54     if ((float)rand()/RAND_MAX < .3)
    55     {
    56       WorldEntity* powerUp = new TurretPowerUp();
    57       powerUp->setAbsCoor(this->getAbsCoor());
    58       State::getWorldEntityList()->add(powerUp);
    59     }
    60     else if ((float)rand()/RAND_MAX < .3)
    61     {
    62       WorldEntity* powerUp = new LaserPowerUp();
    63       powerUp->setAbsCoor(this->getAbsCoor());
    64       State::getWorldEntityList()->add(powerUp);
    65     }
    66     State::getWorldEntityList()->remove(this);
    67 
    68       this->collider = entity;
    69   }
    70   else if (entity->isA(CL_PLAYER))
    71     this->applyForce(Vector(0,0,0)-location*100);
    72   else if (entity->isA(CL_NPC))
    73   {
    74     this->setVisibiliy(false);
    75     State::getWorldEntityList()->remove(this);
    76   }
    77 }
    78 
    7948
    8049void NPCTest1::tick(float dt)
  • trunk/src/world_entities/npcs/npc_test1.h

    r6004 r6054  
    1818  virtual void tick(float dt);
    1919
    20   virtual void collidesWith (WorldEntity* entity, const Vector& location);
    21 
    22 
    2320 private:
    2421   Vector   randomRotAxis;
  • trunk/src/world_entities/weapons/aim.cc

    r5779 r6054  
    6565  this->setClassID(CL_CROSSHAIR, "Aim");
    6666  this->setName("Aim");
     67
     68  this->addNodeModeFlags(PNODE_REPARENT_TO_NULLPARENT);
    6769
    6870  this->setLayer(E2D_LAYER_TOP);
  • trunk/src/world_entities/weapons/guided_missile.cc

    r5994 r6054  
    152152{
    153153  //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
    154   if (target != NULL && target->getParent() != NullParent::getInstance())
     154  if (target.getParent() != NullParent::getInstance())
    155155   {
    156      velocity += ((target->getAbsCoor() - this->getAbsCoor()).getNormalized())*agility;
     156     velocity += ((target.getAbsCoor() - this->getAbsCoor()).getNormalized())*agility;
    157157     float speed = velocity.len();
    158158     if (speed > this->maxVelocity)
  • trunk/src/world_entities/weapons/guided_missile.h

    r5766 r6054  
    99#include "projectile.h"
    1010
    11 class Vector;
    1211class Weapon;
    1312class ParticleSystem;
  • trunk/src/world_entities/weapons/projectile.cc

    r5994 r6054  
    3838  this->lifeCycle = 0.0;
    3939  this->lifeSpan = 1.0f; /* sec */
    40   this->target = NULL;
     40  this->target.addNodeModeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT |
     41                                PNODE_REPARENT_TO_NULLPARENT);
    4142
    4243  this->removeNode();
     
    103104void Projectile::setTarget(PNode* target)
    104105{
    105 
    106   if (this->target == NULL)
    107      this->target = new PNode();
    108   this->target->setParent(target);
     106  this->target.setParent(target);
    109107}
    110108
  • trunk/src/world_entities/weapons/projectile.h

    r5994 r6054  
    5555    Vector                velocity;                  //!< velocity of the projectile.
    5656
    57     PNode*                target;                    //!< A target for guided Weapons.
     57    PNode                 target;                    //!< A target for guided Weapons.
    5858};
    5959
  • trunk/src/world_entities/weapons/weapon.cc

    r5930 r6054  
    528528  tick(dt);
    529529}
    530 
    531 /**
    532  *  this will draw the weapon
    533 */
    534 void Weapon::draw () const
    535 {}
    536 
    537530
    538531
  • trunk/src/world_entities/weapons/weapon.h

    r5750 r6054  
    148148
    149149    virtual void tick(float dt) {};
    150     virtual void draw() const;
    151150
    152151    bool check() const;
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r5982 r6054  
    3535
    3636/**
    37  * this initializes the weaponManager for a given nnumber of weapon slots
     37 * @brief this initializes the weaponManager for a given nnumber of weapon slots
    3838 * @param number of weapon slots of the model/ship <= 8 (limitied)
    3939 */
     
    5151
    5252/**
    53  * Destroys a WeaponManager
     53 * @brief Destroys a WeaponManager
    5454 */
    5555WeaponManager::~WeaponManager()
     
    6060
    6161/**
    62  * initializes the WeaponManager
     62 * @brief initializes the WeaponManager
    6363 */
    6464void WeaponManager::init()
Note: See TracChangeset for help on using the changeset viewer.