Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9853 was 9656, checked in by bensch, 18 years ago

orxonox/trunk: merged the proxy bache back with no conflicts

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