Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7707 was 7412, checked in by bensch, 18 years ago

orxonox/trunk: Another CompletionMode is working

File size: 3.9 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>
[5838]13
[6444]14#include "world_entities/weapons/weapon_manager.h"
[6442]15
[5847]16class Weapon;
[6959]17class DotEmitter;
[5872]18class Player;
[6959]19class SpriteParticles;
[7118]20class Explosion;
[5838]21
22//! Basic controllable WorldEntity
23/**
[5864]24 *
[5838]25 */
[6547]26class Playable : public WorldEntity, public Extendable
[5838]27{
[7338]28public:
[7346]29  //! Defines the Playmode of an Entity.
[7338]30  typedef enum {
[7346]31    Vertical         = 1,       //!< Vertical (seen from left or right/move in x-z)
32    Horizontal       = 2,       //!< Horizontal (seet from the top/move in x-y)
33    FromBehind       = 4,       //!< Seen from behind (move in z-y)
34    Full3D           = 8,       //!< Full featured 3D-mode. (move in all directions x-y-z)
[7412]35
36    PlaymodeCount    = 4,
[7338]37  } Playmode;
[5838]38
39
[7338]40public:
41  virtual ~Playable();
[6966]42
[7338]43  virtual void loadParams(const TiXmlElement* root);
[6547]44
[7346]45  // Weapon and Pickups
[7338]46  virtual bool pickup(PowerUp* powerUp);
[7350]47  bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
[7338]48  void removeWeapon(Weapon* weapon);
49  void nextWeaponConfig();
50  void previousWeaponConfig();
51  inline WeaponManager& getWeaponManager() { return this->weaponMan; };
52  void weaponConfigChanged();
[7351]53  static void addSomeWeapons_CHEAT();
[5895]54
[6241]55
[7346]56  // Player Settup
[7338]57  bool setPlayer(Player* player);
58  Player* getCurrentPlayer() const { return this->currentPlayer; };
[7346]59  /** @return a List of Events in PEV_* sytle */
60  inline const std::vector<int>& getEventList() { return this->events; };
[5898]61
[7346]62  // Camera and Playmode
[7338]63  void attachCamera();
64  void detachCamera();
[7347]65  void setCameraMode(unsigned int cameraMode = 0);
[7338]66  bool playmodeSupported(Playable::Playmode playmode) const { return this->supportedPlaymodes & playmode; };
[7339]67  bool setPlaymode(Playable::Playmode playmode);
68  Playable::Playmode getPlaymode() const { return this->playmode; };
[7346]69  virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f) = 0;
70  void setPlayDirection(float angle, float dirX, float dirY, float dirZ, float speed = 0.0f);
[5898]71
[7346]72  inline void setScore( int score ) { this->score = score; }
73  inline int  getScore() { return this->score; }
74
75
76  // WorldEntity Extensions
77  virtual void die();
78  virtual void respawn();
[7338]79  virtual void collidesWith(WorldEntity* entity, const Vector& location);
80  virtual void process(const Event &event);
81  virtual void tick(float dt);
[6966]82
[7346]83  // NETWORK
[7338]84  int       writeSync(const byte* data, int length, int sender);
85  int       readSync(byte* data, int maxLength );
86  bool      needsReadSync();
[7092]87
[5838]88
[7339]89  // Transformations:
90  static Playable::Playmode stringToPlaymode(const std::string& playmode);
[7412]91  static const std::string& playmodeToString(Playable::Playmode playmode);
92  static const std::string playmodeNames[];
93
[7338]94protected:
95  Playable();
[5872]96
[7346]97  // Player Setup
[7338]98  virtual void enter() = 0;
99  virtual void leave() = 0;
[7346]100  // Playmode
[7338]101  void setSupportedPlaymodes(short playmodes) { this->supportedPlaymodes = playmodes; };
[7346]102  virtual void enterPlaymode(Playable::Playmode playmode);
[5888]103
[7346]104  // Events.
[7338]105  void registerEvent(int eventType);
106  void unregisterEvent(int eventType);
[6966]107
[7338]108private:
109  WeaponManager         weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
110  std::vector<int>      events;             //!< A list of Events, that are captured for this playable
[6804]111
[7338]112  Player*               currentPlayer;      //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL
[7118]113
[7338]114  bool                  bFire;              //!< If the Ship is firing.
115  int                   oldFlags;           //!< Used for synchronisation
[7072]116
[7338]117  int                   score;
118  int                   oldScore;
[7118]119
[7338]120  bool                  bDead;
121  short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
122  Playable::Playmode    playmode;           //!< The current playmode.
123
124  WorldEntity* collider;
[5838]125};
126
127#endif /* _PLAYABLE_H */
Note: See TracBrowser for help on using the repository browser.