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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
use serde_json::json;
use specs::{
DispatcherBuilder
};
use crate::{
RoomId,
Encyclopedia,
room::Room,
roomtemplate::RoomTemplate,
systems::{
Move,
RegisterNew,
ControlInput,
View,
Remove,
Create,
Volate,
UpdateCooldowns,
ControlAI,
}
};
pub fn purgatory_id() -> RoomId {
RoomId{name: String::from("+")}
}
pub fn create_purgatory<'a, 'b>(encyclopedia: Encyclopedia) -> Room<'a, 'b> {
let dispatcher = DispatcherBuilder::new()
.with(Volate, "volate", &[])
.with(RegisterNew::default(), "registernew", &[])
.with(UpdateCooldowns, "cool_down", &["registernew"])
.with(ControlInput, "controlinput", &["cool_down"])
.with(ControlAI, "controlai", &["cool_down"])
.with(Move, "move", &["controlinput", "controlai"])
.with(View::default(), "view", &["move", "volate"])
.with(Create, "create", &["view"])
.with(Remove, "remove", &["view", "move"])
.build();
let mut room = Room::new(purgatory_id(), encyclopedia, dispatcher);
room.load_from_template(&RoomTemplate::from_json(&json!({
"width": 11,
"height": 11,
"spawn": [5, 5],
"field": [
" +++ ",
" +++++++ ",
" +++++++++ ",
" +++++++++ ",
"+++++++++++",
"+++++++++++",
"+++++++++++",
" +++++++++ ",
" +++++++++ ",
" +++++++ ",
" +++ ",
],
"mapping": {
" ": [],
"+": ["floor"]
}
})).unwrap());
room
}
|