Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6960 was 6959, checked in by patrick, 19 years ago

trunk: merged network branche into trunk

File size: 2.4 KB
Line 
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"
10#include "extendable.h"
11#include "event.h"
12#include <list>
13
14#include "world_entities/weapons/weapon_manager.h"
15
16class Weapon;
17class DotEmitter;
18class Player;
19class SpriteParticles;
20
21//! Basic controllable WorldEntity
22/**
23 *
24 */
25class Playable : public WorldEntity, public Extendable
26{
27  public:
28    virtual ~Playable();
29
30    virtual void enter() = 0;
31    virtual void leave() = 0;
32
33    virtual bool pickup(PowerUp* powerUp);
34
35    void addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
36    void removeWeapon(Weapon* weapon);
37    void nextWeaponConfig();
38    void previousWeaponConfig();
39
40    inline WeaponManager* getWeaponManager() const { return this->weaponMan; };
41    void weaponConfigChanged();
42
43
44    bool subscribePlayer(Player* player);
45    bool unsubscribePlayer(Player* player);
46
47    void attachCamera();
48    void detachCamera();
49
50    virtual void collidesWith(WorldEntity* entity, const Vector& location);
51    virtual void process(const Event &event);
52
53    virtual void tick(float dt);
54
55    /** @return a List of Events in PEV_* sytle */
56    inline const std::list<int>& getEventList() { return this->events; };
57
58    int       writeSync(const byte* data, int length, int sender);
59    int       readSync(byte* data, int maxLength );
60    bool      needsReadSync();
61   
62    inline void setScore( int score ) { this->score = score; }
63    inline int  getScore() { return this->score; }
64
65  protected:
66    Playable();
67
68    void registerEvent(int eventType);
69    void unregisterEvent(int eventType);
70
71  private:
72    WeaponManager*        weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
73    std::list<int>        events;             //!< A list of Events, that are captured for this playable
74
75    Player*               currentPlayer;      //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL
76
77    bool                  bFire;              //!< If the Ship is firing.
78    int                   oldFlags;           //!< Used for synchronisation
79   
80    int                   score;
81    int                   oldScore;
82
83    //HACK: explosion emitter
84    DotEmitter*           emitter;
85    SpriteParticles*      explosionParticles;
86};
87
88#endif /* _PLAYABLE_H */
Note: See TracBrowser for help on using the repository browser.