My Project
 
Loading...
Searching...
No Matches
actor.h
Go to the documentation of this file.
1#pragma once
2
3#include "bundlable.h"
4#include "typedefine.h"
5#include <limits>
6#include <set>
7#include <map>
8#include <vector>
9
10class Char;
11
12class Actor :public Bundlable{
13public:
14 static const int TICK = 1;
15
16 Actor();
17 virtual void storeInBundle(Bundle* bundle);
18 virtual void restoreFromBundle(Bundle* bundle);
19
20 int Id();
21
22 static void fixTime();
23 static void clear();
24 static Char* findChar(int pos);
25 static Actor* findById(int id);
26 static void init();
27 static void addDelayed(Actor* actor, float delay);
28 static void remove(Actor* actor);
29 static void add(Actor* actor);
30
31 static void occupyCell(Char* ch);
32 static void freeCell(int pos);
33 void next() { if (current == this) current = NULL; }
34 static void process();
35
37private:
38 float time;
39
40 int id;
41
42 static const std::string TIME;
43 static const std::string ID;
44 static float now;
45
46
47 static Actor* current;
48 static std::map<int, Actor*> ids;
49 static std::vector<Char*> chars;
50
51
52 static void add(Actor* actor, float time);
53protected:
54 virtual bool act() = 0;
55
56 virtual void spend(float time) { this->time += time; }
57 void postpone(float time);
58 float cooldown() { return time - now; }
59 void diactivate() { time = std::numeric_limits<float>::max(); }
60
61 virtual void onAdd(){}
62 virtual void onRemove() {}
63
64};
Actor()
Definition actor.cpp:84
static Char * findChar(int pos)
Definition actor.cpp:171
static void init()
Definition actor.cpp:183
float cooldown()
Definition actor.h:58
static Actor * findById(int id)
Definition actor.cpp:176
virtual void storeInBundle(Bundle *bundle)
Definition actor.cpp:97
static void remove(Actor *actor)
Definition actor.cpp:253
static void add(Actor *actor)
Definition actor.cpp:208
virtual void onAdd()
Definition actor.h:61
int Id()
Definition actor.cpp:109
virtual void spend(float time)
Definition actor.h:56
virtual bool act()=0
static void fixTime()
Definition actor.cpp:131
static void occupyCell(Char *ch)
Definition actor.cpp:243
virtual void restoreFromBundle(Bundle *bundle)
Definition actor.cpp:103
static void addDelayed(Actor *actor, float delay)
Definition actor.cpp:203
static void process()
Definition actor.cpp:18
static void clear()
Definition actor.cpp:157
virtual void onRemove()
Definition actor.h:62
void next()
Definition actor.h:33
static void freeCell(int pos)
Definition actor.cpp:248
static HashSet< Actor * > all
Definition actor.h:36
void postpone(float time)
Definition actor.cpp:90
static const int TICK
Definition actor.h:14
void diactivate()
Definition actor.h:59
Definition char.h:9
Definition typedefine.h:16