summaryrefslogtreecommitdiff
path: root/src/purgatory.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-03-02 22:28:03 +0100
committertroido <troido@protonmail.com>2020-03-02 22:28:03 +0100
commit22168c8eedac95fdfde9a536a1d1f6ddf622cfa1 (patch)
tree6870bff418367fc635d64b58b3921d85ee0dbbb0 /src/purgatory.rs
parent27c0795fb70739ce5609a0f424d80491d4a8c5a1 (diff)
added purgatory
Diffstat (limited to 'src/purgatory.rs')
-rw-r--r--src/purgatory.rs65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/purgatory.rs b/src/purgatory.rs
new file mode 100644
index 0000000..df7f3e9
--- /dev/null
+++ b/src/purgatory.rs
@@ -0,0 +1,65 @@
+
+use serde_json::json;
+use specs::{
+ DispatcherBuilder
+};
+
+use crate::{
+ RoomId,
+ defaultencyclopedia::default_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>() -> 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(), default_encyclopedia(), dispatcher);
+ room.load_from_template(&RoomTemplate::from_json(&json!({
+ "width": 11,
+ "height": 11,
+ "spawn": [5, 5],
+ "field": [
+ " +++ ",
+ " +++++++ ",
+ " +++++++++ ",
+ " +++++++++ ",
+ "+++++++++++",
+ "+++++++++++",
+ "+++++++++++",
+ " +++++++++ ",
+ " +++++++++ ",
+ " +++++++ ",
+ " +++ ",
+ ],
+ "mapping": {
+ " ": [],
+ "+": ["floor"]
+ }
+ })).unwrap());
+ room
+}