Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9610 in orxonox.OLD for branches/proxy


Ignore:
Timestamp:
Jul 30, 2006, 11:33:31 AM (18 years ago)
Author:
bensch
Message:

orxonox/proxy: var-change-handler for the groups

Location:
branches/proxy/src/world_entities
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/world_entities/npcs/network_turret.cc

    r9609 r9610  
    8080  this->weaponHolder.setRelCoor(0,25,0);
    8181  this->weaponHolder.setParent(this);
     82
     83  this->targetGroup_handle = this->registerVarId( new SynchronizeableInt ( &targetGroup, &targetGroup_write, "targetgroup" ) );
    8284}
    8385
     
    9294  // all the clases this Entity is directly derived from must be called in this way, to load all settings.
    9395  NPC::loadParams(root);
     96
     97  LoadParam(root, "target-group", this, NetworkTurret, setTargetGroupS);
    9498}
    9599
     
    122126}
    123127
     128void NetworkTurret::setTargetGroup(int targetGroup)
     129{
     130  this->weapon->setTargetGroup((OM_LIST)targetGroup);
     131}
    124132
     133
     134void NetworkTurret::setTargetGroupS(const std::string& groupName)
     135{
     136  OM_LIST id = ObjectManager::StringToOMList(groupName);
     137  if (id != OM_NULL)
     138    this->setTargetGroup(id);
     139  else
     140    PRINTF(2)("List %s not found for targetting\n", groupName.c_str());
     141}
     142
     143void NetworkTurret::varChangeHandler( std::list< int > & id )
     144{
     145  WorldEntity::varChangeHandler( id );
     146
     147  if ( std::find( id.begin(), id.end(), targetGroup_handle) != id.end() )
     148  {
     149    setTargetGroup( targetGroup_write );
     150  }
     151}
    125152
    126153/**
  • branches/proxy/src/world_entities/npcs/network_turret.h

    r9608 r9610  
    99#include "npcs/npc.h"
    1010
    11 class Weapon;
     11class TargetingTurret;
    1212
    1313//! A Class to ...
     
    2424  virtual void leftWorld ();
    2525
     26
    2627  virtual void destroy(WorldEntity* killer);
    2728
    2829  virtual void draw() const;
    2930  virtual void tick(float time);
     31
     32
     33  void setTargetGroup(int targetGroup);
     34  void setTargetGroupS(const std::string& targetGroup);
     35
     36  virtual void varChangeHandler( std::list<int> & id );
     37
    3038
    3139private:
     
    3442private:
    3543  PNode  weaponHolder;
    36   Weapon *weapon;
     44  TargetingTurret *weapon;
     45
     46  int    targetGroup;
     47  int    targetGroup_write;
     48
     49  int    targetGroup_handle;
    3750};
    3851
  • branches/proxy/src/world_entities/weapons/targeting_turret.h

    r9518 r9610  
    2626  virtual void draw() const;
    2727
     28  void setTargetGroup(OM_LIST targetGroup) { this->target.setTargetGroup(targetGroup); };
    2829  const PNode* getLockedTarget() const { return lockedTarget; };
    2930
Note: See TracChangeset for help on using the changeset viewer.