Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7341 was 7339, checked in by bensch, 19 years ago

some nice fixes

File size: 3.4 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:
29  typedef enum {
30    Vertical         = 1,
31    Horizontal       = 2,
32    FromBehind       = 4,
33    Full3D           = 8,
34  } Playmode;
[5838]35
36
[7338]37public:
38  virtual ~Playable();
[6966]39
[7338]40  virtual void loadParams(const TiXmlElement* root);
[6547]41
[7338]42  virtual void die();
43  virtual void respawn();
[6443]44
[7338]45  virtual bool pickup(PowerUp* powerUp);
[5838]46
[7338]47  void addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
48  void removeWeapon(Weapon* weapon);
49  void nextWeaponConfig();
50  void previousWeaponConfig();
[6568]51
[7338]52  inline WeaponManager& getWeaponManager() { return this->weaponMan; };
53  void weaponConfigChanged();
[5895]54
[6241]55
[7338]56  bool setPlayer(Player* player);
57  Player* getCurrentPlayer() const { return this->currentPlayer; };
[5898]58
[7338]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; };
[7339]63  bool setPlaymode(Playable::Playmode playmode);
64  Playable::Playmode getPlaymode() const { return this->playmode; };
[5898]65
[7338]66  virtual void collidesWith(WorldEntity* entity, const Vector& location);
67  virtual void process(const Event &event);
[6871]68
[7338]69  virtual void tick(float dt);
[6966]70
[7338]71  /** @return a List of Events in PEV_* sytle */
72  inline const std::vector<int>& getEventList() { return this->events; };
[7092]73
[7338]74  int       writeSync(const byte* data, int length, int sender);
75  int       readSync(byte* data, int maxLength );
76  bool      needsReadSync();
[7092]77
[5838]78
[7338]79  //
80  virtual void setStartDirection(const Quaternion& rot) = 0;
81  void setStartDirection(float angle, float dirX, float dirY, float dirZ) { this->setStartDirection(Quaternion(angle, Vector(dirX, dirY, dirZ))); }
[6804]82
[7338]83  inline void setScore( int score ) { this->score = score; }
84  inline int  getScore() { return this->score; }
[6986]85
[7339]86
87  // Transformations:
88  static Playable::Playmode stringToPlaymode(const std::string& playmode);
89  static const char* playmodeToString(Playable::Playmode playmode);
[7338]90protected:
91  Playable();
[5872]92
[7338]93  virtual void enter() = 0;
94  virtual void leave() = 0;
[5886]95
[7338]96  void setSupportedPlaymodes(short playmodes) { this->supportedPlaymodes = playmodes; };
[5888]97
[7338]98  void registerEvent(int eventType);
99  void unregisterEvent(int eventType);
[6966]100
[7338]101private:
102  WeaponManager         weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
103  std::vector<int>      events;             //!< A list of Events, that are captured for this playable
[6804]104
[7338]105  Player*               currentPlayer;      //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL
[7118]106
[7338]107  bool                  bFire;              //!< If the Ship is firing.
108  int                   oldFlags;           //!< Used for synchronisation
[7072]109
[7338]110  int                   score;
111  int                   oldScore;
[7118]112
[7338]113  bool                  bDead;
114  short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
115  Playable::Playmode    playmode;           //!< The current playmode.
116
117  WorldEntity* collider;
[5838]118};
119
120#endif /* _PLAYABLE_H */
Note: See TracBrowser for help on using the repository browser.