Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7338 in orxonox.OLD for trunk/src/world_entities/playable.h


Ignore:
Timestamp:
Apr 19, 2006, 1:25:07 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: some Playable-stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/playable.h

    r7337 r7338  
    1010#include "extendable.h"
    1111#include "event.h"
    12 #include <list>
     12#include <vector>
    1313
    1414#include "world_entities/weapons/weapon_manager.h"
     
    2626class Playable : public WorldEntity, public Extendable
    2727{
    28   public:
    29     virtual ~Playable();
    30 
    31     virtual void loadParams(const TiXmlElement* root);
    32 
    33     virtual void die();
    34     virtual void respawn();
    35 
    36     virtual bool pickup(PowerUp* powerUp);
    37 
    38     void addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
    39     void removeWeapon(Weapon* weapon);
    40     void nextWeaponConfig();
    41     void previousWeaponConfig();
    42 
    43     inline WeaponManager& getWeaponManager() { return this->weaponMan; };
    44     void weaponConfigChanged();
     28public:
     29  typedef enum {
     30    Vertical         = 1,
     31    Horizontal       = 2,
     32    FromBehind       = 4,
     33    Full3D           = 8,
     34  } Playmode;
    4535
    4636
    47     bool setPlayer(Player* player);
    48     Player* getCurrentPlayer() const { return this->currentPlayer; };
     37public:
     38  virtual ~Playable();
    4939
    50     void attachCamera();
    51     void detachCamera();
    52     virtual void setCameraMode(unsigned int cameraMode = 0);
     40  virtual void loadParams(const TiXmlElement* root);
    5341
    54     virtual void collidesWith(WorldEntity* entity, const Vector& location);
    55     virtual void process(const Event &event);
     42  virtual void die();
     43  virtual void respawn();
    5644
    57     virtual void tick(float dt);
     45  virtual bool pickup(PowerUp* powerUp);
    5846
    59     /** @return a List of Events in PEV_* sytle */
    60     inline const std::list<int>& getEventList() { return this->events; };
     47  void addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
     48  void removeWeapon(Weapon* weapon);
     49  void nextWeaponConfig();
     50  void previousWeaponConfig();
    6151
    62     int       writeSync(const byte* data, int length, int sender);
    63     int       readSync(byte* data, int maxLength );
    64     bool      needsReadSync();
     52  inline WeaponManager& getWeaponManager() { return this->weaponMan; };
     53  void weaponConfigChanged();
    6554
    6655
    67     //
    68     virtual void setStartDirection(const Quaternion& rot) = 0;
    69     void setStartDirection(float angle, float dirX, float dirY, float dirZ) { this->setStartDirection(Quaternion(angle, Vector(dirX, dirY, dirZ))); }
     56  bool setPlayer(Player* player);
     57  Player* getCurrentPlayer() const { return this->currentPlayer; };
    7058
    71     inline void setScore( int score ) { this->score = score; }
    72     inline int  getScore() { return this->score; }
     59  void attachCamera();
     60  void detachCamera();
     61  virtual void setCameraMode(unsigned int cameraMode = 0);
     62  bool playmodeSupported(Playable::Playmode playmode) const { return this->supportedPlaymodes & playmode; };
     63  bool setPlayMode(Playable::Playmode playmode);
    7364
    74   protected:
    75     Playable();
     65  virtual void collidesWith(WorldEntity* entity, const Vector& location);
     66  virtual void process(const Event &event);
    7667
    77     virtual void enter() = 0;
    78     virtual void leave() = 0;
     68  virtual void tick(float dt);
    7969
    80     void registerEvent(int eventType);
    81     void unregisterEvent(int eventType);
     70  /** @return a List of Events in PEV_* sytle */
     71  inline const std::vector<int>& getEventList() { return this->events; };
    8272
    83   private:
    84     WeaponManager         weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
    85     std::list<int>        events;             //!< A list of Events, that are captured for this playable
    86 
    87     Player*               currentPlayer;      //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL
    88 
    89     bool                  bFire;              //!< If the Ship is firing.
    90     int                   oldFlags;           //!< Used for synchronisation
    91 
    92     int                   score;
    93     int                   oldScore;
    94 
    95     bool                  bDead;
    96 
    97     //TODO HACK: explosion emitter
     73  int       writeSync(const byte* data, int length, int sender);
     74  int       readSync(byte* data, int maxLength );
     75  bool      needsReadSync();
    9876
    9977
    100     WorldEntity* collider;
     78  //
     79  virtual void setStartDirection(const Quaternion& rot) = 0;
     80  void setStartDirection(float angle, float dirX, float dirY, float dirZ) { this->setStartDirection(Quaternion(angle, Vector(dirX, dirY, dirZ))); }
     81
     82  inline void setScore( int score ) { this->score = score; }
     83  inline int  getScore() { return this->score; }
     84
     85protected:
     86  Playable();
     87
     88  virtual void enter() = 0;
     89  virtual void leave() = 0;
     90
     91  void setSupportedPlaymodes(short playmodes) { this->supportedPlaymodes = playmodes; };
     92
     93  void registerEvent(int eventType);
     94  void unregisterEvent(int eventType);
     95
     96private:
     97  WeaponManager         weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
     98  std::vector<int>      events;             //!< A list of Events, that are captured for this playable
     99
     100  Player*               currentPlayer;      //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL
     101
     102  bool                  bFire;              //!< If the Ship is firing.
     103  int                   oldFlags;           //!< Used for synchronisation
     104
     105  int                   score;
     106  int                   oldScore;
     107
     108  bool                  bDead;
     109  short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
     110  Playable::Playmode    playmode;           //!< The current playmode.
     111
     112  WorldEntity* collider;
    101113};
    102114
Note: See TracChangeset for help on using the changeset viewer.