Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3216 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Dec 18, 2004, 5:14:08 AM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: a first redesign of the CommandNode and its cmd passing system - others will follow.

Location:
orxonox/trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/command_node.cc

    r3215 r3216  
    2020#include "world_entity.h"
    2121#include "game_loader.h"
     22#include "world.h"
    2223
    2324#include <stdio.h>
     
    3839  this->bLocalInput = false;
    3940  this->bEnabled = true;
     41  this->world = NULL;
    4042}
    4143
     
    5153  this->bound = new tList<WorldEntity>();
    5254  this->bEnabled = true;
     55  this->world = NULL;
    5356  this->load_bindings (filename);
    5457}
     
    7881  //this->bound = NULL; /* \todo this produces a NULLpointer error.. FIX */
    7982  this->bEnabled = false;
     83  this->world = NULL;
    8084}
    8185
     
    8488  this->bEnabled = bEnabled;
    8589}
     90
     91
     92/**
     93  \brief adds Node to a GameWorld
     94
     95   this is usefull, if you want to catch events in a world class. usualy
     96   this is done automaticaly via GameLoader. Reset it via
     97   CommandNode::reset()
     98
     99*/
     100void CommandNode::addToWorld(World* world)
     101{
     102  this->world = world;
     103}
     104
    86105
    87106/**
     
    251270  Orxonox *orx = Orxonox::getInstance();
    252271  if( orx->system_command (cmd)) return;
     272
    253273  GameLoader* gl = GameLoader::getInstance();
    254   if(gl->worldCommand(cmd)) return;
    255  
     274  if( gl->worldCommand(cmd)) return;
     275
    256276  if( bLocalInput) send_over_network (cmd);
    257277 
     278  if( this->world->command(cmd)) return;
     279
    258280  WorldEntity* entity = bound->enumerate();
    259   while(  entity != NULL)
     281  while( entity != NULL)
    260282    {
    261283      entity->command (cmd);
  • orxonox/trunk/src/command_node.h

    r3214 r3216  
    1212
    1313class WorldEntity;
     14class World;
    1415
    1516#define N_STD_KEYS SDLK_LAST
     
    4445  tList<WorldEntity>* bound;    //!< List of WorldEntites that recieve commands from this CommandNode
    4546  Sint32 coord[2];
     47  World* world;
    4648 
    4749
     
    6264  void bind (WorldEntity* entity);
    6365  void unbind (WorldEntity* entity);
     66  void addToWorld(World* world);
    6467  void process ();
    6568 
  • orxonox/trunk/src/orxonox.cc

    r3215 r3216  
    269269bool Orxonox::system_command (Command* cmd)
    270270{
     271 
    271272  if( !strcmp( cmd->cmd, "quit"))
    272273    {
     
    275276    }
    276277  return false;
     278 
    277279}
    278280
  • orxonox/trunk/src/world.cc

    r3215 r3216  
    6464{
    6565  this->bPause = false;
    66   Orxonox::getInstance()->get_localinput()->enable(true);
     66  CommandNode* cn = Orxonox::getInstance()->get_localinput();
     67  cn->addToWorld(this);
     68  cn->enable(true);
    6769}
    6870
     
    7880  this->localPlayer->destroy();
    7981  this->localCamera->destroy();
    80 
    8182
    8283  WorldEntity* entity = entities->enumerate(); 
     
    610611{
    611612  // localinput
    612   Orxonox::getInstance()->get_localinput()->process();
     613  CommandNode* cn = Orxonox::getInstance()->get_localinput();
     614  cn->process();
    613615  // remoteinput
    614616}
     
    643645}
    644646
     647
    645648/**
    646649   \brief compute collision detection
     
    651654}
    652655
    653 /**
    654    \brief handle keyboard commands that are not meant for WorldEntities
    655    \param cmd: the command to handle
    656    \return true if the command was handled by the system or false if it may be passed to the WorldEntities
    657 */
    658 bool World::system_command (Command* cmd)
    659 {
    660   if( !strcmp( cmd->cmd, "quit"))
    661     {
    662       if( !cmd->bUp) this->bQuitOrxonox = true;
    663       {
    664         printf("World::system_command() - rescv quit command\n");
    665         return true;
    666       }
    667     }
    668   return false;
    669 }
    670656
    671657/**
     
    750736  //return entity;
    751737}
     738
     739
     740bool World::command(Command* cmd)
     741{
     742  if( !strcmp( cmd->cmd, "quit"))
     743    {
     744      if( !cmd->bUp) this->stop();
     745      return true;
     746    }
     747  return false;
     748}
  • orxonox/trunk/src/world.h

    r2822 r3216  
    4444       
    4545  void unload ();
     46  bool command(Command* cmd);
    4647 
    4748  void setTrackLen(Uint32 tracklen);
    4849  int getTrackLen();
    49   bool system_command (Command* cmd);
     50  //bool system_command (Command* cmd);
    5051  Camera* getCamera();
    5152
Note: See TracChangeset for help on using the changeset viewer.