Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10440 in orxonox.OLD for trunk


Ignore:
Timestamp:
Jan 28, 2007, 2:09:09 PM (18 years ago)
Author:
patrick
Message:

making weapons loadable

Location:
trunk/src/world_entities
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/mount_point.cc

    r10437 r10440  
    2121#include "util/loading/load_param_xml.h"
    2222
    23 
     23#include "weapons/weapon_slot.h"
    2424
    2525#include "mount_point.h"
     
    178178      this->_mount->toList( (OM_LIST)(this->getOMListNumber()+1));
    179179    }
     180    else if( obj->isA( WeaponSlot::staticClassID()))
     181    {
     182      PRINTF(0)("=========+>we got a weapon slot\n");
     183    }
    180184  }
    181185  else
  • trunk/src/world_entities/npcs/npc.cc

    r10439 r10440  
    3434#include "debug.h"
    3535#include "loading/load_param.h"
     36#include "util/loading/load_param_xml.h"
    3637#include "track/track.h"
    3738
     
    5859
    5960  this->toList(OM_GROUP_01);
     61  this->bAIEnabled = false;
    6062
    6163  if( root != NULL)
    62           this->loadParams(root);
    63 
    64   std::cout << "Team Number: " << teamNumber << "\n";
    65   std::cout << "Swarm Number:" << swarmNumber << "\n";
    66 
    67 //add to track
    68   if(this->entityTrack)
    69     this->setParent(this->entityTrack->getTrackNode());
    70   else
    71   AIEngine::getInstance()->addAI(teamNumber,swarmNumber,(WorldEntity*)this,maxSpeed,attackDistance);
     64    this->loadParams(root);
     65
     66  if( this->bAIEnabled)
     67  {
     68    std::cout << "Team Number: " << teamNumber << "\n";
     69    std::cout << "Swarm Number:" << swarmNumber << "\n";
     70
     71    if( this->entityTrack)
     72      this->setParent(this->entityTrack->getTrackNode());
     73    else
     74      AIEngine::getInstance()->addAI(teamNumber,swarmNumber,(WorldEntity*)this,maxSpeed,attackDistance);
     75  }
    7276
    7377  this->bFire = false;
     
    123127
    124128
    125  
     129
    126130
    127131}
     
    144148   WorldEntity::loadParams(root);
    145149
     150  LoadParam(root, "enableAI", this, NPC, enableAI)
     151      .describe("enables the AI algorithms");
     152
    146153  LoadParam(root, "team", this, NPC, setTeamNumber)
    147154  .describe("this sets the team number")
     
    159166  .describe("this sets the NPC distance to target")
    160167  .defaultValues(0);
     168
     169
     170    // Track
     171  LoadParamXML(root, "Weapons", this, NPC, addWeapons)
     172  .describe("creates and adds weapons");
     173}
     174
     175
     176void NPC::addWeapons(const TiXmlElement* root)
     177{
     178  if( root == NULL)
     179    return;
     180
     181  LOAD_PARAM_START_CYCLE(root, element);
     182  {
     183    PRINTF(0)("got weapon: %s\n", element->Value());
     184    BaseObject* obj = Factory::fabricate(element);
     185    if( obj != NULL && obj->isA( Weapon::staticClassID()))
     186    {
     187      PRINTF(0)("created a weapon\n");
     188    }
     189  }
     190  LOAD_PARAM_END_CYCLE(element);
    161191}
    162192
  • trunk/src/world_entities/npcs/npc.h

    r10376 r10440  
    2020
    2121
     22  void addWeapons(const TiXmlElement* root);
    2223  bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
    2324  void removeWeapon(Weapon* weapon);
     
    3132  inline void fire(){ this->bFire=true;}
    3233
    33 
     34  inline void enableAI() { this->bAIEnabled = true; }
    3435
    3536private:
     
    5152
    5253  AIModule*             aiModule;
     54
     55  bool                  bAIEnabled;   //!< true is AI enabled
    5356};
    5457
  • trunk/src/world_entities/weapons/weapon_slot.cc

    r10437 r10440  
    1919#include "weapon_slot.h"
    2020#include "util/loading/factory.h"
     21#include "util/loading/load_param.h"
    2122
    2223
     
    2728{
    2829  this->registerObject(this, WeaponSlot::_objectList);
    29 
    3030}
    3131
     
    3434   this->registerObject(this, WeaponSlot::_objectList);
    3535
     36   if( root != NULL)
     37     this->loadParams( root);
    3638}
    3739
     
    3941WeaponSlot::~WeaponSlot()
    4042{}
     43
     44
     45
     46void WeaponSlot::loadParams(const TiXmlElement* root)
     47{
     48  PNode::loadParams( root);
     49
     50    // now check for the orx class to create
     51  LoadParam(root, "WeaponClass", this, WeaponSlot, setWeaponClass)
     52  .describe("Sets the class this mount points should host");
     53}
     54
     55
     56
     57
     58void WeaponSlot::setWeaponClass()
     59{
     60
     61}
     62
  • trunk/src/world_entities/weapons/weapon_slot.h

    r10438 r10440  
    2323  virtual ~WeaponSlot();
    2424
     25  virtual void loadParams(const TiXmlElement* root);
     26
     27  void setWeaponClass();
    2528
    2629  long getCapability() { return this->capability; }
Note: See TracChangeset for help on using the changeset viewer.