diff options
| -rw-r--r-- | content/encyclopediae/default_encyclopedia.json | 11 | ||||
| -rw-r--r-- | src/components/interactable.rs | 4 | ||||
| -rw-r--r-- | src/systems/interact.rs | 12 |
3 files changed, 11 insertions, 16 deletions
diff --git a/content/encyclopediae/default_encyclopedia.json b/content/encyclopediae/default_encyclopedia.json index 0d54304..80d84cb 100644 --- a/content/encyclopediae/default_encyclopedia.json +++ b/content/encyclopediae/default_encyclopedia.json @@ -90,7 +90,8 @@ "arguments": [["health", "int", 100]], "components": [ ["Health", {"health": ["arg", "health"], "maxhealth": 100}], - "Mortal" + "Mortal", + ["Loot", {"loot": ["list", [{"type": "stone"}]]}] ], "sprite": "wall", "height": 2, @@ -286,7 +287,9 @@ "height": 2, "flags": ["Blocking"], "components": [ - ["Interactable", {"action": ["interaction", ["change", {"type": "opendoor", "save": false}]]}] + ["Interactable", {"action": ["interaction", "harvest"]}], + ["Loot", {"loot": ["list", [{"type": "opendoor", "save": false}]]}], + "Mortal" ] }, "opendoor": { @@ -294,7 +297,9 @@ "height": 0.8, "flags": ["Occupied"], "components": [ - ["Interactable", {"action": ["interaction", ["change", {"type": "closeddoor", "save": false}]]}] + ["Interactable", {"action": ["interaction", "harvest"]}], + ["Loot", {"loot": ["list", [{"type": "closeddoor", "save": false}]]}], + "Mortal" ] }, "sign": { diff --git a/src/components/interactable.rs b/src/components/interactable.rs index 33e3a12..eafe977 100644 --- a/src/components/interactable.rs +++ b/src/components/interactable.rs @@ -6,7 +6,6 @@ use specs::{ HashMapStorage }; use crate::{ - Template, exchange::Exchange, ItemId }; @@ -15,7 +14,6 @@ use crate::{ #[storage(HashMapStorage)] pub enum Interactable { Harvest, - Change(Template), Say(String), Reply(String), Exchange(String, HashMap<String, Exchange>) @@ -29,7 +27,6 @@ impl Interactable { let arg = if val.is_string() {&Value::Null} else {val.get(1)?}; Some(match typ.as_str()? { "harvest" => Harvest, - "change" => Change(Template::from_json(arg).ok()?), "say" => Say(arg.as_str()?.to_string()), "reply" => Reply(arg.as_str()?.to_string()), "exchange" => Exchange( @@ -53,7 +50,6 @@ impl Interactable { pub fn accepts_arg(&self, arg: &Option<String>) -> bool { match self { Harvest => arg.is_none(), - Change(_) => arg.is_none(), Say(_) => arg.is_none(), Reply(_) => arg.is_some(), Exchange(prefix, _exchanges) => { diff --git a/src/systems/interact.rs b/src/systems/interact.rs index 43c355d..fb11488 100644 --- a/src/systems/interact.rs +++ b/src/systems/interact.rs @@ -17,7 +17,6 @@ use crate::{ ControlCooldown, Interactable, Dead, - Removed, Sound, Ear, Inventory @@ -36,13 +35,12 @@ impl <'a> System<'a> for Interact { WriteStorage<'a, ControlCooldown>, ReadStorage<'a, Interactable>, WriteStorage<'a, Dead>, - WriteStorage<'a, Removed>, Write<'a, NewEntities>, WriteStorage<'a, Ear>, WriteStorage<'a, Inventory> ); - fn run(&mut self, (entities, controllers, positions, ground, mut cooldowns, interactables, mut deads, mut removeds, mut new, mut ears, mut inventories): Self::SystemData) { + fn run(&mut self, (entities, controllers, positions, ground, mut cooldowns, interactables, mut deads, new, mut ears, mut inventories): Self::SystemData) { for (entity, controller, position) in (&entities, &controllers, &positions).join(){ let mut target = None; let ear = ears.get_mut(entity); @@ -53,7 +51,7 @@ impl <'a> System<'a> for Interact { for ent in ground.cells.get(&pos).unwrap_or(&HashSet::new()) { if let Some(interactable) = interactables.get(*ent) { if interactable.accepts_arg(arg){ - target = Some((*ent, interactable, pos, arg.clone())); + target = Some((*ent, interactable, arg.clone())); break 'targets; } } @@ -62,15 +60,11 @@ impl <'a> System<'a> for Interact { } _ => {} } - if let Some((ent, interactable, pos, arg)) = target { + if let Some((ent, interactable, arg)) = target { match interactable { Interactable::Harvest => { deads.insert(ent, Dead).unwrap(); } - Interactable::Change(into) => { - new.create(pos, into).unwrap(); - removeds.insert(ent, Removed).unwrap(); - } Interactable::Say(text) => { say(ear, text.clone()); } |
