Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 31, 2006, 10:51:08 PM (18 years ago)
Author:
bensch
Message:

orxonox/branches/new_class_id: new_class ID working, adapdet many classes, and reinvented some of the ClassID stuff

Location:
branches/new_class_id/src/world_entities/npcs
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/world_entities/npcs/attractor_mine.cc

    r9235 r9709  
    3333#include "effects/explosion.h"
    3434
    35 CREATE_FACTORY(AttractorMine, CL_ATTRACTOR_MINE);
     35#include "class_id.h"
     36NewObjectListDefinitionID(AttractorMine, CL_ATTRACTOR_MINE);
     37CREATE_FACTORY(AttractorMine);
    3638#include "script_class.h"
    37 CREATE_SCRIPTABLE_CLASS(AttractorMine, CL_ATTRACTOR_MINE,
     39CREATE_SCRIPTABLE_CLASS(AttractorMine, AttractorMine::classID(),
    3840                        addMethod("setName", ExecutorLua1<BaseObject,const std::string&>(&BaseObject::setName))
    3941                       //Coordinates
     
    5052    : NPC(NULL)
    5153{
    52   this->setClassID(CL_ATTRACTOR_MINE, "AttractorMine");
     54  this->registerObject(this, AttractorMine::_objectList);
    5355
    5456  this->toList(OM_GROUP_02);
  • branches/new_class_id/src/world_entities/npcs/attractor_mine.h

    r9235 r9709  
    99
    1010class AttractorMine : public NPC {
     11  NewObjectListDeclaration(AttractorMine);
    1112
    1213 public:
  • branches/new_class_id/src/world_entities/npcs/door.cc

    r9406 r9709  
    2525
    2626#include "door.h"
    27 #include "class_list.h"
    2827
    29 
    30 
    31 
    32 
    33 CREATE_FACTORY(Door, CL_DOOR);
     28#include "class_id.h"
     29NewObjectListDefinitionID(Door, CL_DOOR);
     30CREATE_FACTORY(Door);
    3431
    3532
     
    4744Door::Door(const TiXmlElement* root)
    4845{
    49 
    50   this->setClassID(CL_DOOR, "Door");
     46  this->registerObject(this, Door::_objectList);
    5147  this->scale = 1.0f;
    5248  this->actionRadius = 1.0;
     
    152148
    153149
    154 
     150#include "playable.h"
     151#include "generic_npc.h"
    155152/**
    156153 * checks if the door is open
     
    159156{
    160157
    161   std::list<BaseObject*>::const_iterator it;
    162   const std::list<BaseObject*>* list = ClassList::getList(CL_PLAYABLE);
    163158  WorldEntity* entity;
    164159  float distance;
    165160
    166   if( list == NULL)
    167     return false;
    168 
     161  for (NewObjectList<Playable>::const_iterator it = Playable::objectList().begin();
     162       it != Playable::objectList().end();
     163       ++it)
    169164  // for all players
    170   for( it = list->begin(); it != list->end(); it++)
    171165  {
    172     entity = dynamic_cast<WorldEntity*>(*it);
     166    entity = (*it);
    173167
    174168    distance = fabs((this->getAbsCoor() - entity->getAbsCoor()).len());
     
    178172
    179173
    180   list = ClassList::getList(CL_GENERIC_NPC);
    181   if( list == NULL)
    182     return false;
    183   for( it = list->begin(); it != list->end(); it++)
     174
     175  for (NewObjectList<GenericNPC>::const_iterator it = GenericNPC::objectList().begin();
     176       it != GenericNPC::objectList().end();
     177       ++it)
    184178  {
    185     entity = dynamic_cast<WorldEntity*>(*it);
     179    entity = (*it);
    186180
    187181    distance = fabs((this->getAbsCoor() - entity->getAbsCoor()).len());
  • branches/new_class_id/src/world_entities/npcs/door.h

    r9110 r9709  
    2121class Door : public WorldEntity
    2222{
     23  NewObjectListDeclaration(Door);
     24
    2325  public:
    2426    Door(const TiXmlElement* root = NULL);
  • branches/new_class_id/src/world_entities/npcs/gate.cc

    r9406 r9709  
    2525
    2626#include "gate.h"
    27 #include "class_list.h"
    28 
    2927#include "effects/explosion.h"
    3028
     
    3331
    3432
    35 
    36 CREATE_FACTORY(Gate, CL_GATE);
     33#include "class_id.h"
     34NewObjectListDefinitionID(Gate, CL_GATE);
     35CREATE_FACTORY(Gate);
    3736
    3837
    3938#include "script_class.h"
    40 CREATE_SCRIPTABLE_CLASS(Gate, CL_GATE,
     39CREATE_SCRIPTABLE_CLASS(Gate, Gate::classID(),
    4140                            addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide))
    4241                            ->addMethod("unhide", ExecutorLua0<WorldEntity>(&WorldEntity::unhide))
    43                             ->addMethod("destroy", ExecutorLua0<Gate>(&Gate::destroy))   
     42                            ->addMethod("destroy", ExecutorLua0<Gate>(&Gate::destroy))
    4443                            ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
    4544                            ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
     
    4948
    5049
     50
    5151//! list of all different animations a std md2model supports
    5252sAnim Gate::animationList[3] =
     
    6262Gate::Gate(const TiXmlElement* root)
    6363{
    64 
    65   this->setClassID(CL_GATE, "Gate");
     64  this->registerObject(this, Gate::_objectList);
    6665  this->scale = 1.0f;
    6766  this->actionRadius = 1.0;
     
    165164void Gate::close()
    166165{
    167  
     166
    168167  if( this->destroyed)
    169168    return;
    170  
     169
    171170  this->setAnimation(GATE_CLOSE, MD2_ANIM_ONCE);
    172171  this->bOpen = false;
     
    178177  if( this->destroyed)
    179178    return;
    180  
     179
    181180  this->setAnimation(GATE_DIE, MD2_ANIM_ONCE);
    182181
    183182  Explosion::explode(this, Vector(this->getScaling()/160,this->getScaling()/160,this->getScaling()/160));
    184  
    185  
     183
     184
    186185  this->destroyed = true;
    187186}
    188187
     188#include "playable.h"
     189#include "generic_npc.h"
    189190
    190191/**
     
    195196
    196197  std::list<BaseObject*>::const_iterator it;
    197   const std::list<BaseObject*>* list = ClassList::getList(CL_PLAYABLE);
    198198  WorldEntity* entity;
    199199  float distance;
    200200
    201   if( list == NULL)
    202     return false;
    203 
    204201  // for all players
    205   for( it = list->begin(); it != list->end(); it++)
    206   {
    207     entity = dynamic_cast<WorldEntity*>(*it);
     202  for (NewObjectList<Playable>::const_iterator it = Playable::objectList().begin();
     203       it != Playable::objectList().end();
     204       ++it)
     205  {
     206    entity = (*it);
    208207
    209208    distance = fabs((this->getAbsCoor() - entity->getAbsCoor()).len());
     
    213212
    214213
    215   list = ClassList::getList(CL_GENERIC_NPC);
    216   if( list == NULL)
    217     return false;
    218   for( it = list->begin(); it != list->end(); it++)
    219   {
    220     entity = dynamic_cast<WorldEntity*>(*it);
     214  for (NewObjectList<GenericNPC>::const_iterator it = GenericNPC::objectList().begin();
     215       it != GenericNPC::objectList().end();
     216       ++it)
     217  {
     218    entity = (*it);
    221219
    222220    distance = fabs((this->getAbsCoor() - entity->getAbsCoor()).len());
  • branches/new_class_id/src/world_entities/npcs/gate.h

    r9298 r9709  
    2222class Gate : public WorldEntity
    2323{
     24  NewObjectListDeclaration(Gate);
     25
    2426  public:
    2527    Gate(const TiXmlElement* root = NULL);
  • branches/new_class_id/src/world_entities/npcs/generic_npc.cc

    r9235 r9709  
    3030#include "loading/resource_manager.h"
    3131
    32 
    33 CREATE_FACTORY(GenericNPC, CL_GENERIC_NPC);
     32#include "bsp_entity.h"
     33
     34#include "class_id.h"
     35NewObjectListDefinitionID(GenericNPC, CL_GENERIC_NPC);
     36CREATE_FACTORY(GenericNPC);
    3437
    3538#include "script_class.h"
    36 CREATE_SCRIPTABLE_CLASS(GenericNPC, CL_GENERIC_NPC,
     39CREATE_SCRIPTABLE_CLASS(GenericNPC, GenericNPC::classID(),
    3740                        // Move
    3841                        addMethod("walkTo", ExecutorLua3<GenericNPC,float,float,float>(&GenericNPC::walkTo))
     
    8184void GenericNPC::init()
    8285{
    83   this->setClassID(CL_GENERIC_NPC, "GenericNPC");
     86  this->registerObject(this, GenericNPC::_objectList);
    8487
    8588  this->toList(OM_GROUP_00);
     
    9295
    9396  // collision reaction registration
    94    this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
     97  this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, BspEntity::classID());
    9598}
    9699
  • branches/new_class_id/src/world_entities/npcs/generic_npc.h

    r9235 r9709  
    2525class GenericNPC : public NPC
    2626{
     27  NewObjectListDeclaration(GenericNPC);
    2728
    2829
  • branches/new_class_id/src/world_entities/npcs/ground_turret.cc

    r9707 r9709  
    2929#include "effects/explosion.h"
    3030
     31#include "class_id.h"
    3132
    32 CREATE_FACTORY(GroundTurret, CL_GROUND_TURRET);
    33 
    34 
     33NewObjectListDefinitionID(GroundTurret, CL_GROUND_TURRET);
     34CREATE_FACTORY(GroundTurret);
    3535
    3636
     
    6262void GroundTurret::init()
    6363{
    64   this->setClassID(CL_GROUND_TURRET, "GroundTurret");
     64  this->registerObject(this, GroundTurret::_objectList);
    6565  this->loadModel("models/ground_turret_#.obj", 5);
    6666  this->left = NULL;
  • branches/new_class_id/src/world_entities/npcs/ground_turret.h

    r9656 r9709  
    1414class GroundTurret : public NPC
    1515{
     16  NewObjectListDeclaration(GroundTurret);
    1617
    1718public:
  • branches/new_class_id/src/world_entities/npcs/network_turret.cc

    r9656 r9709  
    3131#include "weapons/aiming_turret.h"
    3232
    33 CREATE_FACTORY(NetworkTurret, CL_NETWORK_TURRET);
    34 
    35 
     33#include "class_id.h"
     34NewObjectListDefinitionID(NetworkTurret, CL_NETWORK_TURRET);
     35CREATE_FACTORY(NetworkTurret);
    3636
    3737
     
    6262void NetworkTurret::init()
    6363{
    64   this->setClassID(CL_NETWORK_TURRET, "NetworkTurret");
     64  this->registerObject(this, NetworkTurret::_objectList);
    6565  this->loadModel("models/ground_turret_#.obj", 5);
    6666
     
    111111  ObjectManager::EntityList::iterator entity;
    112112  Vector diffVec;
    113   for (entity = State::getObjectManager()->getObjectList((OM_LIST)this->targetGroup).begin();
    114        entity != State::getObjectManager()->getObjectList((OM_LIST)this->targetGroup).end();
     113  for (entity = State::getObjectManager()->getEntityList((OM_LIST)this->targetGroup).begin();
     114       entity != State::getObjectManager()->getEntityList((OM_LIST)this->targetGroup).end();
    115115       entity ++)
    116116  {
  • branches/new_class_id/src/world_entities/npcs/network_turret.h

    r9656 r9709  
    1414class NetworkTurret : public NPC
    1515{
    16 
     16  NewObjectListDeclaration(NetworkTurret);
    1717public:
    1818  NetworkTurret(const TiXmlElement* root = NULL);
  • branches/new_class_id/src/world_entities/npcs/npc_test.cc

    r9707 r9709  
    3131
    3232#include "class_id.h"
    33 CREATE_FACTORY(NPC2, CL_NPC_TEST2);
    3433NewObjectListDefinitionID(NPC2, CL_NPC_TEST2);
     34CREATE_FACTORY(NPC2);
    3535
    3636NPC2::NPC2(const TiXmlElement* root)
  • branches/new_class_id/src/world_entities/npcs/repair_station.cc

    r9406 r9709  
    2525
    2626#include "repair_station.h"
    27 #include "class_list.h"
    2827
    29 
    30 
    31 
    32 
    33 CREATE_FACTORY(RepairStation, CL_DOOR);
     28#include "class_id.h"
     29NewObjectListDefinitionID(RepairStation, CL_DOOR +1 );
     30CREATE_FACTORY(RepairStation);
    3431
    3532
     
    6764RepairStation::RepairStation(const TiXmlElement* root)
    6865{
    69 
    70   this->setClassID(CL_DOOR, "RepairStation");
     66  this->registerObject(this, RepairStation::_objectList);
    7167  this->scale = 1.0f;
    7268
  • branches/new_class_id/src/world_entities/npcs/repair_station.h

    r9003 r9709  
    2727class RepairStation : public WorldEntity
    2828{
     29  NewObjectListDeclaration(RepairStation);
    2930  public:
    3031    RepairStation ();
  • branches/new_class_id/src/world_entities/npcs/space_turret.cc

    r9656 r9709  
    2929#include "effects/explosion.h"
    3030
    31 CREATE_FACTORY(SpaceTurret, CL_SPACE_TURRET);
     31#include "class_id.h"
     32NewObjectListDefinitionID(SpaceTurret, CL_SPACE_TURRET);
     33CREATE_FACTORY(SpaceTurret);
    3234
    3335/**
     
    5961void SpaceTurret::init()
    6062{
    61   this->setClassID(CL_SPACE_TURRET, "SpaceTurret");
     63  this->registerObject(this, SpaceTurret::_objectList);
    6264  this->loadModel("models/ground_turret_#.obj", 7.5);
    6365  this->loadModel("models/comet.obj", 1.0f, 3);
  • branches/new_class_id/src/world_entities/npcs/space_turret.h

    r9656 r9709  
    1818class SpaceTurret : public NPC
    1919{
     20  NewObjectListDeclaration(SpaceTurret);
    2021
    2122public:
Note: See TracChangeset for help on using the changeset viewer.