/
movement_script.hpp
50 lines (39 loc) · 1.19 KB
/
movement_script.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef MOVEMENT_SCRIPT_HPP_INCLUDED
#define MOVEMENT_SCRIPT_HPP_INCLUDED
#include "entity.hpp"
#include "formula.hpp"
#include "variant.hpp"
#include <map>
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
class active_movement_script {
public:
~active_movement_script();
void modify(entity_ptr entity, const std::map<std::string, game_logic::const_formula_ptr>& handlers);
private:
struct entity_mod {
entity_ptr entity;
std::map<std::string, game_logic::const_formula_ptr> handlers_backup;
};
std::vector<entity_mod> mods_;
};
typedef boost::shared_ptr<active_movement_script> active_movement_script_ptr;
typedef boost::shared_ptr<const active_movement_script> const_active_movement_script_ptr;
class movement_script
{
public:
movement_script() {}
explicit movement_script(variant node);
active_movement_script_ptr begin_execution(const game_logic::formula_callable& callable) const;
const std::string& id() const { return id_; }
variant write() const;
private:
struct modification {
game_logic::const_formula_ptr target_formula;
std::map<std::string, game_logic::const_formula_ptr> handlers;
};
std::string id_;
std::vector<modification> modifications_;
};
#endif