Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/playable.h @ 10772

Last change on this file since 10772 was 10698, checked in by snellen, 17 years ago

merged adm, hud, vs-enhancements : beni's responsible for this commit. blame him!

File size: 4.7 KB
RevLine 
[5838]1
2/*!
3 * @file playable.h
4 * Interface for a basic controllable WorldEntity
5 */
6#ifndef _PLAYABLE_H
7#define _PLAYABLE_H
8
9#include "world_entity.h"
[6547]10#include "extendable.h"
[5838]11#include "event.h"
[7338]12#include <vector>
[9656]13#include <list>
[5838]14
[6444]15#include "world_entities/weapons/weapon_manager.h"
[6442]16
[5847]17class Weapon;
[6959]18class DotEmitter;
[5872]19class Player;
[6959]20class SpriteParticles;
[7118]21class Explosion;
[5838]22
23//! Basic controllable WorldEntity
24/**
[5864]25 *
[5838]26 */
[6547]27class Playable : public WorldEntity, public Extendable
[5838]28{
[9869]29  ObjectListDeclaration(Playable);
[7338]30public:
[7346]31  //! Defines the Playmode of an Entity.
[7338]32  typedef enum {
[8055]33    Vertical         =  1,       //!< Vertical (seen from left or right/move in x-z)
[10698]34    Horizontal       =  2,       //!< Horizontal (seen from the top/move in x-y)
[8055]35    FromBehind       =  4,       //!< Seen from behind (move in z-y)
36    Full3D           =  8,       //!< Full featured 3D-mode. (move in all directions x-y-z)
37    FirstPerson      = 16,
[7412]38
[8055]39    PlaymodeCount    =  5,
[7338]40  } Playmode;
[5838]41
42
[7338]43public:
44  virtual ~Playable();
[6966]45
[7338]46  virtual void loadParams(const TiXmlElement* root);
[9656]47  void varChangeHandler( std::list< int > & id );
[6547]48
[7346]49  // Weapon and Pickups
[7338]50  virtual bool pickup(PowerUp* powerUp);
[7350]51  bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
[7338]52  void removeWeapon(Weapon* weapon);
53  void nextWeaponConfig();
54  void previousWeaponConfig();
55  inline WeaponManager& getWeaponManager() { return this->weaponMan; };
56  void weaponConfigChanged();
[7351]57  static void addSomeWeapons_CHEAT();
[5895]58
[6241]59
[7346]60  // Player Settup
[9061]61  bool hasPlayer(){return !(this->currentPlayer == NULL);}
[7338]62  bool setPlayer(Player* player);
63  Player* getCurrentPlayer() const { return this->currentPlayer; };
[7346]64  /** @return a List of Events in PEV_* sytle */
65  inline const std::vector<int>& getEventList() { return this->events; };
[5898]66
[9656]67
[7346]68  // Camera and Playmode
[7338]69  void attachCamera();
70  void detachCamera();
[7347]71  void setCameraMode(unsigned int cameraMode = 0);
[7338]72  bool playmodeSupported(Playable::Playmode playmode) const { return this->supportedPlaymodes & playmode; };
[10368]73  virtual bool setPlaymode(Playable::Playmode playmode);
[7339]74  Playable::Playmode getPlaymode() const { return this->playmode; };
[7346]75  virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f) = 0;
76  void setPlayDirection(float angle, float dirX, float dirY, float dirZ, float speed = 0.0f);
[5898]77
[9656]78  // Networking interface
[7346]79  inline void setScore( int score ) { this->score = score; }
80  inline int  getScore() { return this->score; }
[9656]81  inline void setTeamId( int teamId) { this->teamId = teamId;}
82  inline int getTeamId() const { return this->teamId; }
83  virtual void setTeam(int teamID);
[7346]84
[9656]85
[9061]86  void setEnterRadius(float radius) { this->enterRadius = radius; };
87  /** @returns the EnterRadius (how far away a Player must be to enter this entity) */
88  inline float getEnterRadius() const { return this->enterRadius; };
[7346]89
90  // WorldEntity Extensions
[9235]91  virtual void destroy(WorldEntity* killer);
[7346]92  virtual void respawn();
[7338]93  virtual void process(const Event &event);
94  virtual void tick(float dt);
[6966]95
[9656]96
97  inline bool beFire() const { return this->bFire; }
98  inline void fire(bool bF) { this->bFire = bF;}
99
[7339]100  // Transformations:
101  static Playable::Playmode stringToPlaymode(const std::string& playmode);
[7412]102  static const std::string& playmodeToString(Playable::Playmode playmode);
103  static const std::string playmodeNames[];
[9406]104
[7338]105protected:
106  Playable();
[5872]107
[7346]108  // Player Setup
[7338]109  virtual void enter() = 0;
110  virtual void leave() = 0;
[7346]111  // Playmode
[7338]112  void setSupportedPlaymodes(short playmodes) { this->supportedPlaymodes = playmodes; };
[7346]113  virtual void enterPlaymode(Playable::Playmode playmode);
[5888]114
[7346]115  // Events.
[7338]116  void registerEvent(int eventType);
117  void unregisterEvent(int eventType);
[6966]118
[10368]119protected:
120  WeaponManager         weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
121  bool                  bFire;              //!< If the Ship is firing.
122  short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
123  Playable::Playmode    playmode;           //!< The current playmode.
124
[7338]125private:
126  std::vector<int>      events;             //!< A list of Events, that are captured for this playable
[6804]127
[7338]128  Player*               currentPlayer;      //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL
[7118]129
[7338]130  int                   oldFlags;           //!< Used for synchronisation
[7072]131
[7954]132  int                   score;              //!< players score
[9656]133  int                   teamChangeHandler;  //!< handler id for team changes network sync
134  int                   teamId;             //!< id of the current team
[7118]135
[7338]136  bool                  bDead;
137
[9061]138  float                 enterRadius;        //!< How far one can be away from the Playable to enter it.
139
[9656]140  WorldEntity*          collider;
[5838]141};
142
143#endif /* _PLAYABLE_H */
Note: See TracBrowser for help on using the repository browser.