summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/encyclopediae/default_encyclopedia.json37
-rw-r--r--src/assemblage.rs58
-rw-r--r--src/componentparameter.rs32
-rw-r--r--src/components/mod.rs8
-rw-r--r--src/componentwrapper.rs1
-rw-r--r--src/encyclopedia.rs12
-rw-r--r--src/resources/mod.rs2
-rw-r--r--src/room.rs16
-rw-r--r--src/systems/droploot.rs3
-rw-r--r--src/systems/growth.rs48
-rw-r--r--src/systems/heal.rs10
-rw-r--r--src/systems/mod.rs4
-rw-r--r--src/systems/spawn.rs4
-rw-r--r--src/systems/useitem.rs4
-rw-r--r--src/systems/volate.rs4
15 files changed, 171 insertions, 72 deletions
diff --git a/content/encyclopediae/default_encyclopedia.json b/content/encyclopediae/default_encyclopedia.json
index 56a0998..a94f388 100644
--- a/content/encyclopediae/default_encyclopedia.json
+++ b/content/encyclopediae/default_encyclopedia.json
@@ -78,7 +78,7 @@
["Item", {
"ent": ["template", "pebble"],
"name": ["string", "pebble"],
- "action": ["action", ["eat", 1]]
+ "action": ["action", ["none", null]]
}]
],
"sprite": "pebble",
@@ -86,7 +86,11 @@
},
"stone": {
"components": [
- ["Item", {"ent": ["template", "stone"], "name": ["string", "stone"], "action": ["action", ["build", "builtwall"]]}]
+ ["Item", {
+ "ent": ["template", "stone"],
+ "name": ["string", "stone"],
+ "action": ["action", ["build", "builtwall"]]
+ }]
],
"sprite": "stone",
"height": 0.4
@@ -192,11 +196,36 @@
"radishseed": {
"sprite": "seed",
"height": 0.2,
- "name": "radishseed"
+ "name": "radishseed",
+ "components": [
+ ["Item", {
+ "ent": ["template", "radishseed"],
+ "name": ["string", "radishseed"],
+ "action": ["action", ["build", "plantedradishseed"]]
+ }]
+ ]
+ },
+ "plantedradishseed": {
+ "sprite": "seed",
+ "height": 0.05,
+ "name": "seed",
+ "components": [
+ ["Grow", {
+ "delay": ["int", 200],
+ "into": ["template", "radishplant"]
+ }]
+ ]
},
"radishes": {
"sprite": "food",
"height": 0.3,
- "name": "radishes"
+ "name": "radishes",
+ "components": [
+ ["Item", {
+ "ent": ["template", "radishes"],
+ "name": ["string", "radishes"],
+ "action": ["action", ["eat", 1]]
+ }]
+ ]
}
}
diff --git a/src/assemblage.rs b/src/assemblage.rs
index 4c9dd82..730b34d 100644
--- a/src/assemblage.rs
+++ b/src/assemblage.rs
@@ -7,7 +7,9 @@ use crate::{
componentwrapper::{ComponentWrapper, ComponentType},
components::Serialise,
hashmap,
- Template
+ Template,
+ Result,
+ aerr
};
type ArgumentDef = (String, ParameterType, Option<Parameter>);
@@ -22,34 +24,34 @@ pub struct Assemblage {
impl Assemblage {
- fn parse_definition_arguments(args: &Value) -> Result<Vec<ArgumentDef>, &'static str> {
+ fn parse_definition_arguments(args: &Value) -> Result<Vec<ArgumentDef>> {
let mut arguments: Vec<ArgumentDef> = Vec::new();
- for arg in args.as_array().ok_or("arguments is not an array")? {
- let tup = arg.as_array().ok_or("argument is not an array")?;
- let key = tup.get(0).ok_or("argument has no name")?.as_str().ok_or("argument name is not a string")?.to_string();
- let typ = ParameterType::from_str(tup.get(1).ok_or("argument has no type")?.as_str().ok_or("argument type not a string")?).ok_or("failed to parse argument type")?;
+ for arg in args.as_array().ok_or(aerr!("arguments is not an array"))? {
+ let tup = arg.as_array().ok_or(aerr!("argument is not an array"))?;
+ let key = tup.get(0).ok_or(aerr!("argument has no name"))?.as_str().ok_or(aerr!("argument name is not a string"))?.to_string();
+ let typ = ParameterType::from_str(tup.get(1).ok_or(aerr!("argument has no type"))?.as_str().ok_or(aerr!("argument type not a string"))?).ok_or(aerr!("failed to parse argument type"))?;
let def = tup.get(2).ok_or("argument has no default")?;
if def.is_null() {
arguments.push((key.clone(), typ, None));
} else {
- arguments.push((key.clone(), typ, Some(Parameter::from_typed_json(typ, def).ok_or("invalid argument default")?)));
+ arguments.push((key.clone(), typ, Some(Parameter::from_typed_json(typ, def).ok_or(aerr!("invalid argument default"))?)));
}
}
Ok(arguments)
}
- fn parse_definition_components(comps: &Value) -> Result<Vec<(ComponentType, HashMap<String, ComponentParameter>)>, &'static str> {
+ fn parse_definition_components(comps: &Value) -> Result<Vec<(ComponentType, HashMap<String, ComponentParameter>)>> {
let mut components = Vec::new();
- for tup in comps.as_array().ok_or("components is not a json array")? {
+ for tup in comps.as_array().ok_or(aerr!("components is not a json array"))? {
if let Some(name) = tup.as_str() {
- components.push((ComponentType::from_str(name).ok_or("not a valid componenttype")?, HashMap::new()));
+ components.push((ComponentType::from_str(name).ok_or(aerr!("not a valid componenttype"))?, HashMap::new()));
} else {
let comptype = ComponentType::from_str(tup
- .get(0).ok_or("index 0 not in component")?
- .as_str().ok_or("component name not a string")?
+ .get(0).ok_or(aerr!("index 0 not in component"))?
+ .as_str().ok_or(aerr!("component name not a string"))?
).ok_or("not a valid componenttype")?;
let mut parameters: HashMap<String, ComponentParameter> = HashMap::new();
- for (key, value) in tup.get(1).ok_or("index 1 not in component")?.as_object().ok_or("component parameters not a json object")? {
+ for (key, value) in tup.get(1).ok_or(aerr!("index 1 not in component"))?.as_object().ok_or(aerr!("component parameters not a json object"))? {
let param = ComponentParameter::from_json(value)?;
parameters.insert(key.clone(), param);
}
@@ -59,40 +61,40 @@ impl Assemblage {
Ok(components)
}
- fn validate(&self) -> Result<(), &'static str> {
+ fn validate(&self) -> Result<()> {
for (comptype, parameters) in &self.components {
for (paramname, paramtype) in comptype.parameters() {
- let param = parameters.get(paramname).ok_or("missing parameter")?;
+ let param = parameters.get(paramname).ok_or(aerr!("missing parameter"))?;
let actualtype = param.get_type(&self.arguments)?;
if actualtype != paramtype {
- return Err("parameter type incorrect");
+ return Err(aerr!("parameter type incorrect"));
}
}
}
Ok(())
}
- pub fn from_json(val: &Value) -> Result<Self, &'static str>{
+ pub fn from_json(val: &Value) -> Result<Self>{
let mut assemblage = Self {
arguments: Self::parse_definition_arguments(val.get("arguments").unwrap_or(&json!([])))?,
components: Self::parse_definition_components(val.get("components").unwrap_or(&json!([])))?,
- save: val.get("save").unwrap_or(&json!(true)).as_bool().ok_or("assemblage save not a bool")?
+ save: val.get("save").unwrap_or(&json!(true)).as_bool().ok_or(aerr!("assemblage save not a bool"))?
};
// visible component is so common that shortcuts are very helpful
if let Some(spritename) = val.get("sprite") {
- let height = val.get("height").ok_or("defining a sprite requires also defining a height")?;
+ let height = val.get("height").ok_or(aerr!("defining a sprite requires also defining a height"))?;
let name = val.get("name").unwrap_or(spritename);
assemblage.components.push((
ComponentType::Visible,
hashmap!(
"sprite".to_string() => ComponentParameter::Constant(
- Parameter::String(spritename.as_str().ok_or("sprite not a string")?.to_string())
+ Parameter::String(spritename.as_str().ok_or(aerr!("sprite not a string"))?.to_string())
),
"height".to_string() => ComponentParameter::Constant(
- Parameter::Float(height.as_f64().ok_or("height not a float")?)
+ Parameter::Float(height.as_f64().ok_or(aerr!("height not a float"))?)
),
"name".to_string() => ComponentParameter::Constant(
- Parameter::String(name.as_str().ok_or("name not a string")?.to_string())
+ Parameter::String(name.as_str().ok_or(aerr!("name not a string"))?.to_string())
)
)
));
@@ -101,7 +103,7 @@ impl Assemblage {
Ok(assemblage)
}
- fn prepare_arguments(&self, args: &[Parameter], kwargs: &HashMap<String, Parameter>) -> Result<HashMap<&str, Parameter>, &'static str> {
+ fn prepare_arguments(&self, args: &[Parameter], kwargs: &HashMap<String, Parameter>) -> Result<HashMap<&str, Parameter>> {
let mut arguments: HashMap<&str, Parameter> = HashMap::new();
for (idx, (name, typ, def)) in self.arguments.iter().enumerate() {
let value: Option<Parameter> = {
@@ -115,16 +117,16 @@ impl Assemblage {
None
}
};
- let param = value.ok_or("argument has no value")?;
+ let param = value.ok_or(aerr!("argument has no value"))?;
if param.paramtype() != *typ {
- return Err("argument has incorrect type");
+ return Err(aerr!("argument has incorrect type"));
}
arguments.insert(name, param);
}
Ok(arguments)
}
- pub fn instantiate(&self, template: &Template) -> Result<Vec<ComponentWrapper>, &'static str>{
+ pub fn instantiate(&self, template: &Template) -> Result<Vec<ComponentWrapper>>{
let args = &template.args;
let kwargs = &template.kwargs;
let mut components: Vec<ComponentWrapper> = Vec::new();
@@ -132,9 +134,9 @@ impl Assemblage {
for (comptype, compparams) in &self.components {
let mut compargs: HashMap<&str, Parameter> = HashMap::new();
for (name, param) in compparams {
- compargs.insert(name.as_str(), param.evaluate(&arguments).ok_or("argument not found")?);
+ compargs.insert(name.as_str(), param.evaluate(&arguments).ok_or(aerr!("argument not found"))?);
}
- components.push(ComponentWrapper::load_component(*comptype, compargs).ok_or("failed to load component")?);
+ components.push(ComponentWrapper::load_component(*comptype, compargs).ok_or(aerr!("failed to load component"))?);
}
if template.save && self.save {
components.push(ComponentWrapper::Serialise(Serialise{template: template.clone()}));
diff --git a/src/componentparameter.rs b/src/componentparameter.rs
index 2b76849..fdbfc71 100644
--- a/src/componentparameter.rs
+++ b/src/componentparameter.rs
@@ -2,7 +2,11 @@
use std::collections::HashMap;
use rand::Rng;
use serde_json::Value;
-use crate::parameter::{Parameter, ParameterType};
+use crate::{
+ parameter::{Parameter, ParameterType},
+ Result,
+ aerr
+};
const MAX_NESTING: usize = 5;
@@ -50,19 +54,21 @@ impl ComponentParameter {
}
}
- pub fn from_json(value: &Value) -> Result<Self, &'static str> {
- let paramvalue = value.get(1).ok_or("index 1 not in component parameter")?;
- let typename = value.get(0).ok_or("index 0 not in component parameter")?.as_str().ok_or("compparam type not a string")?;
+ pub fn from_json(value: &Value) -> Result<Self> {
+ let paramvalue = value.get(1).ok_or(aerr!("index 1 not in component parameter"))?;
+ let typename = value.get(0).ok_or(aerr!("index 0 not in component parameter"))?.as_str().ok_or(aerr!("compparam type not a string"))?;
if let Some(paramtype) = ParameterType::from_str(typename) {
- Ok(Self::Constant(Parameter::from_typed_json(paramtype, paramvalue).ok_or("failed to parse parameter constant")?))
+ Ok(Self::Constant(Parameter::from_typed_json(paramtype, paramvalue).ok_or_else(||
+ aerr!(& format!("failed to parse parameter constant: {:?} {:?}", paramtype, paramvalue))
+ )?))
} else {
match typename {
"A" | "arg" => {
- let argname = paramvalue.as_str().ok_or("argument parameter not a string")?.to_string();
+ let argname = paramvalue.as_str().ok_or(aerr!("argument parameter not a string"))?.to_string();
Ok(Self::Argument(argname))
},
"random" => {
- let optionvalues = paramvalue.as_array().ok_or("random argument not an array")?;
+ let optionvalues = paramvalue.as_array().ok_or(aerr!("random argument not an array"))?;
let mut options = Vec::new();
for option in optionvalues {
options.push(Self::from_json(option)?)
@@ -70,27 +76,27 @@ impl ComponentParameter {
Ok(Self::Random(options))
},
"concat" => {
- let values = paramvalue.as_array().ok_or("concat argument not an array")?;
+ let values = paramvalue.as_array().ok_or(aerr!("concat argument not an array"))?;
let mut options = Vec::new();
for option in values {
options.push(Self::from_json(option)?)
}
Ok(Self::Concat(options))
},
- _ => Err("unknown compparam type")
+ _ => Err(aerr!("unknown compparam type"))
}
}
}
- pub fn get_type(&self, arguments: &[(String, ParameterType, Option<Parameter>)]) -> Result<ParameterType, &'static str>{
+ pub fn get_type(&self, arguments: &[(String, ParameterType, Option<Parameter>)]) -> Result<ParameterType>{
Ok(match self {
Self::Constant(param) => param.paramtype(),
- Self::Argument(argname) => arguments.iter().find(|(n, _t, _d)| n == argname).ok_or("unknown argument name")?.1,
+ Self::Argument(argname) => arguments.iter().find(|(n, _t, _d)| n == argname).ok_or(aerr!("unknown argument name"))?.1,
Self::Random(options) => {
- let typ: ParameterType = options.get(0).ok_or("random has no options")?.get_type(arguments)?;
+ let typ: ParameterType = options.get(0).ok_or(aerr!("random has no options"))?.get_type(arguments)?;
for param in options {
if param.get_type(arguments)? != typ {
- return Err("inconsistent parameter types");
+ return Err(aerr!("inconsistent parameter types"));
}
}
typ
diff --git a/src/components/mod.rs b/src/components/mod.rs
index efaeb68..ac6c9e6 100644
--- a/src/components/mod.rs
+++ b/src/components/mod.rs
@@ -238,6 +238,14 @@ pub struct Loot {
}
+#[derive(Component, Debug, Clone)]
+#[storage(HashMapStorage)]
+pub struct Grow {
+ pub delay: i64,
+ pub target_time: Option<Timestamp>,
+ pub into: Template
+}
+
diff --git a/src/componentwrapper.rs b/src/componentwrapper.rs
index e1389c4..7a3d946 100644
--- a/src/componentwrapper.rs
+++ b/src/componentwrapper.rs
@@ -137,6 +137,7 @@ components!(
Faction (faction: String) {Faction::from_str(faction.as_str())?};
Interactable (action: String) {Interactable::from_str(action.as_str())?};
Loot (loot: LootList) {Loot{loot}};
+ Grow (delay: Int, into: Template) {Grow{delay, into, target_time: None}};
);
diff --git a/src/encyclopedia.rs b/src/encyclopedia.rs
index 7b40373..8de5424 100644
--- a/src/encyclopedia.rs
+++ b/src/encyclopedia.rs
@@ -5,7 +5,9 @@ use crate::{
assemblage::Assemblage,
componentwrapper::PreEntity,
Template,
- template::EntityType
+ template::EntityType,
+ Result,
+ aerr
};
#[derive(Default, Clone)]
@@ -15,16 +17,16 @@ pub struct Encyclopedia {
impl Encyclopedia {
- pub fn from_json(val: Value) -> Result<Encyclopedia, &'static str> {
+ pub fn from_json(val: Value) -> Result<Encyclopedia> {
let mut items = HashMap::new();
- for (k, v) in val.as_object().ok_or("encyclopedia not a json object")?.into_iter() {
+ for (k, v) in val.as_object().ok_or(aerr!("encyclopedia not a json object"))?.into_iter() {
items.insert(EntityType(k.clone()), Assemblage::from_json(v)?);
}
Ok(Encyclopedia{items})
}
- pub fn construct(&self, template: &Template) -> Result<PreEntity, &'static str> {
- let assemblage = self.items.get(&template.name).ok_or("unknown assemblage name")?;
+ pub fn construct(&self, template: &Template) -> Result<PreEntity> {
+ let assemblage = self.items.get(&template.name).ok_or(aerr!("unknown assemblage name"))?;
assemblage.instantiate(template)
}
diff --git a/src/resources/mod.rs b/src/resources/mod.rs
index 4ce0e59..ae3f4e2 100644
--- a/src/resources/mod.rs
+++ b/src/resources/mod.rs
@@ -52,6 +52,6 @@ pub struct Emigration {
}
#[derive(Default)]
-pub struct TimeStamp {
+pub struct Time {
pub time: Timestamp
}
diff --git a/src/room.rs b/src/room.rs
index e7153b7..f41350a 100644
--- a/src/room.rs
+++ b/src/room.rs
@@ -22,7 +22,7 @@ use crate::{
Spawn as SpawnPosition,
Players,
Emigration,
- TimeStamp
+ Time
},
components::{
Position,
@@ -64,7 +64,8 @@ use crate::{
Die,
Spawn,
Interact,
- DropLoot
+ DropLoot,
+ Growth
}
};
@@ -72,6 +73,7 @@ pub fn default_dispatcher<'a, 'b>() -> Dispatcher<'a, 'b> {
DispatcherBuilder::new()
.with(Volate, "volate", &[])
.with(RegisterNew::default(), "registernew", &[])
+ .with(Growth, "growth", &["registernew"])
.with(UpdateCooldowns, "cool_down", &["registernew"])
.with(Spawn, "spawn", &["registernew"])
.with(ControlInput, "controlinput", &["cool_down"])
@@ -88,7 +90,7 @@ pub fn default_dispatcher<'a, 'b>() -> Dispatcher<'a, 'b> {
.with(DropLoot, "droploot", &["attacking"])
.with(View::default(), "view", &["move", "attacking", "volate", "die"])
.with(Migrate, "migrate", &["view"])
- .with(Create, "create", &["view", "spawn", "droploot"])
+ .with(Create, "create", &["view", "spawn", "droploot", "growth"])
.with(Remove, "remove", &["view", "move", "droploot"])
.build()
}
@@ -119,8 +121,8 @@ impl <'a, 'b>Room<'a, 'b> {
world.insert(NewEntities::new(encyclopedia));
register_insert!(
world,
- (Position, Visible, Controller, Movable, Blocking, Floor, New, Removed, Moved, Player, Inventory, Health, Serialise, RoomExit, Entered, Dead, Trap, Fighter, Healing, Volatile, ControlCooldown, Autofight, MonsterAI, Home, Mortal, AttackInbox, Item, Spawner, Clan, Faction, Interactable, Loot),
- (Ground, Input, Output, Size, Spawn, Players, Emigration, TimeStamp)
+ (Position, Visible, Controller, Movable, Blocking, Floor, New, Removed, Moved, Player, Inventory, Health, Serialise, RoomExit, Entered, Dead, Trap, Fighter, Healing, Volatile, ControlCooldown, Autofight, MonsterAI, Home, Mortal, AttackInbox, Item, Spawner, Clan, Faction, Interactable, Loot, Grow),
+ (Ground, Input, Output, Size, Spawn, Players, Emigration, Time)
);
Room {
@@ -164,7 +166,7 @@ impl <'a, 'b>Room<'a, 'b> {
}
pub fn update(&mut self, timestamp: Timestamp) {
- self.world.fetch_mut::<TimeStamp>().time = timestamp;
+ self.world.fetch_mut::<Time>().time = timestamp;
self.dispatcher.dispatch(&self.world);
self.world.maintain();
}
@@ -263,7 +265,7 @@ impl <'a, 'b>Room<'a, 'b> {
}
pub fn get_time(&self) -> Timestamp {
- self.world.fetch::<TimeStamp>().time
+ self.world.fetch::<Time>().time
}
}
diff --git a/src/systems/droploot.rs b/src/systems/droploot.rs
index 616d38d..1b8f824 100644
--- a/src/systems/droploot.rs
+++ b/src/systems/droploot.rs
@@ -3,7 +3,6 @@ use rand::Rng;
use specs::{
ReadStorage,
- WriteStorage,
System,
Join,
Write
@@ -22,7 +21,7 @@ use crate::{
pub struct DropLoot;
impl <'a> System<'a> for DropLoot{
type SystemData = (
- WriteStorage<'a, Position>,
+ ReadStorage<'a, Position>,
Write<'a, NewEntities>,
ReadStorage<'a, Dead>,
ReadStorage<'a, Loot>
diff --git a/src/systems/growth.rs b/src/systems/growth.rs
new file mode 100644
index 0000000..7472115
--- /dev/null
+++ b/src/systems/growth.rs
@@ -0,0 +1,48 @@
+
+use rand;
+
+use specs::{
+ ReadStorage,
+ WriteStorage,
+ Entities,
+ System,
+ Join,
+ Write,
+ Read
+};
+
+use crate::{
+ components::{
+ Position,
+ Grow,
+ Removed
+ },
+ resources::{NewEntities, Time}
+};
+
+
+pub struct Growth;
+impl <'a> System<'a> for Growth{
+ type SystemData = (
+ Entities<'a>,
+ ReadStorage<'a, Position>,
+ Write<'a, NewEntities>,
+ WriteStorage<'a, Grow>,
+ WriteStorage<'a, Removed>,
+ Read<'a, Time>
+ );
+
+ fn run(&mut self, (entities, positions, mut new, mut grows, mut removeds, time): Self::SystemData) {
+ for (entity, position, grow) in (&entities, &positions, &mut grows).join(){
+ if grow.target_time == None {
+ let duration = grow.delay as f64 * (1.0 + rand::random::<f64>()) / (if rand::random() {1.0} else {2.0});
+ grow.target_time = Some(time.time + duration as i64);
+ }
+ if grow.target_time.unwrap() <= time.time {
+ removeds.insert(entity, Removed).unwrap();
+ // todo: error handling
+ new.create(position.pos, grow.into.clone()).unwrap();
+ }
+ }
+ }
+}
diff --git a/src/systems/heal.rs b/src/systems/heal.rs
index 458bc17..34e67f4 100644
--- a/src/systems/heal.rs
+++ b/src/systems/heal.rs
@@ -8,7 +8,7 @@ use specs::{
use crate::{
components::{Health, Healing},
- resources::TimeStamp
+ resources::Time
};
@@ -17,19 +17,19 @@ impl <'a> System<'a> for Heal {
type SystemData = (
WriteStorage<'a, Health>,
WriteStorage<'a, Healing>,
- Read<'a, TimeStamp>
+ Read<'a, Time>
);
- fn run(&mut self, (mut healths, mut healing, timestamp): Self::SystemData) {
+ fn run(&mut self, (mut healths, mut healing, time): Self::SystemData) {
for (health, mut heal) in (&mut healths, &mut healing).join() {
if let Some(next_heal) = heal.next_heal {
- if next_heal <= timestamp.time {
+ if next_heal <= time.time {
health.heal(heal.health);
heal.next_heal = None
}
}
if health.health < health.maxhealth && heal.next_heal == None {
- heal.next_heal = Some(timestamp.time + heal.delay)
+ heal.next_heal = Some(time.time + heal.delay)
}
}
}
diff --git a/src/systems/mod.rs b/src/systems/mod.rs
index 1735df9..318d5ee 100644
--- a/src/systems/mod.rs
+++ b/src/systems/mod.rs
@@ -19,6 +19,7 @@ mod die;
mod spawn;
mod interact;
mod droploot;
+mod growth;
pub use self::{
controlinput::ControlInput,
@@ -40,5 +41,6 @@ pub use self::{
die::Die,
spawn::Spawn,
interact::Interact,
- droploot::DropLoot
+ droploot::DropLoot,
+ growth::Growth
};
diff --git a/src/systems/spawn.rs b/src/systems/spawn.rs
index 27dcb1f..33dbc95 100644
--- a/src/systems/spawn.rs
+++ b/src/systems/spawn.rs
@@ -17,7 +17,7 @@ use crate::{
Clan,
Home
},
- resources::{NewEntities, TimeStamp},
+ resources::{NewEntities, Time},
componentwrapper::ComponentWrapper
};
@@ -30,7 +30,7 @@ impl <'a> System<'a> for Spawn {
Write<'a, NewEntities>,
WriteStorage<'a, Spawner>,
ReadStorage<'a, Clan>,
- Read<'a, TimeStamp>
+ Read<'a, Time>
);
fn run(&mut self, (positions, mut new, mut spawners, clans, time): Self::SystemData) {
diff --git a/src/systems/useitem.rs b/src/systems/useitem.rs
index ab147b7..89a301c 100644
--- a/src/systems/useitem.rs
+++ b/src/systems/useitem.rs
@@ -29,7 +29,7 @@ impl <'a> System<'a> for Use {
type SystemData = (
Entities<'a>,
ReadStorage<'a, Controller>,
- WriteStorage<'a, Position>,
+ ReadStorage<'a, Position>,
WriteStorage<'a, Inventory>,
Write<'a, NewEntities>,
WriteStorage<'a, AttackInbox>
@@ -42,7 +42,7 @@ impl <'a> System<'a> for Use {
if let Some(item) = inventory.items.get(*rank) {
match &item.action {
Build(template) => {
- let _ = new.create(position.pos, template.clone());
+ new.create(position.pos, template.clone()).unwrap();
inventory.items.remove(*rank);
}
Eat(health_diff) => {
diff --git a/src/systems/volate.rs b/src/systems/volate.rs
index 8cfa826..cd50995 100644
--- a/src/systems/volate.rs
+++ b/src/systems/volate.rs
@@ -9,7 +9,7 @@ use specs::{
use crate::{
components::{Volatile, Removed},
- resources::TimeStamp
+ resources::Time
};
pub struct Volate;
@@ -18,7 +18,7 @@ impl <'a> System<'a> for Volate {
Entities<'a>,
WriteStorage<'a, Volatile>,
WriteStorage<'a, Removed>,
- Read<'a, TimeStamp>
+ Read<'a, Time>
);
fn run(&mut self, (entities, mut volatiles, mut removals, timestamp): Self::SystemData) {
for (ent, volatile) in (&entities, &mut volatiles).join() {