summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-09-20 23:37:28 +0200
committertroido <troido@protonmail.com>2020-09-20 23:37:28 +0200
commit1e7c665728eb638cdf921824f4c22f54b81f29de (patch)
treec4d6e0847a5d5bc3399ebde2a34a05e7b352b061 /src
parent5eda37efbd1b34851364923069c0c3effdc32ca8 (diff)
removed interactable as Parameter type
Diffstat (limited to 'src')
-rw-r--r--src/components/interactable.rs13
-rw-r--r--src/componentwrapper.rs3
-rw-r--r--src/fromtoparameter.rs2
-rw-r--r--src/parameter.rs2
-rw-r--r--src/parameterexpression.rs2
5 files changed, 2 insertions, 20 deletions
diff --git a/src/components/interactable.rs b/src/components/interactable.rs
index d5a6926..ec8c1db 100644
--- a/src/components/interactable.rs
+++ b/src/components/interactable.rs
@@ -1,7 +1,5 @@
use std::collections::HashMap;
-use serde_json;
-use serde_json::{Value};
use specs::{
Component,
HashMapStorage,
@@ -33,17 +31,6 @@ impl Interactable {
_ => None?
})
}
-
- pub fn from_json(val: &Value) -> Option<Self> {
- let typ = val.get(0)?;
- let arg = val.get(1)?;
- Some(match typ.as_str()? {
- "trigger" => Trigger(Trigger::from_str(arg.as_str()?)?),
- "visit" => Visit(RoomId::from_str(arg.as_str()?)),
- "mine" => Mine(Stat::from_str(arg.as_str()?)?),
- _ => None?
- })
- }
pub fn accepts_arg(&self, arg: &Option<String>) -> bool {
match self {
diff --git a/src/componentwrapper.rs b/src/componentwrapper.rs
index f3c2db0..62e090e 100644
--- a/src/componentwrapper.rs
+++ b/src/componentwrapper.rs
@@ -14,8 +14,7 @@ use crate::{
AttackType,
Clan,
Flag,
- Trigger,
- interactable::Interactable
+ Trigger
},
parameter::{Parameter},
fromtoparameter::FromToParameter,
diff --git a/src/fromtoparameter.rs b/src/fromtoparameter.rs
index f201a2a..75912ae 100644
--- a/src/fromtoparameter.rs
+++ b/src/fromtoparameter.rs
@@ -5,7 +5,6 @@ use crate::{
parameter::Parameter,
Template,
Pos,
- components::interactable::Interactable,
PlayerId,
Sprite,
ItemId
@@ -78,7 +77,6 @@ tofrom!(bool:Bool);
tofrom!(String: String);
tofrom!(Pos: Pos);
tofrom!(Template: Template);
-tofrom!(Interactable: Interaction);
tofrom!(PlayerId{name: String});
tofrom!(Sprite{name: String});
diff --git a/src/parameter.rs b/src/parameter.rs
index e2d48dd..e303f76 100644
--- a/src/parameter.rs
+++ b/src/parameter.rs
@@ -2,7 +2,6 @@
use serde_json::{Value, json};
use crate::{
Template,
- components::interactable::Interactable,
Pos,
PResult,
perr
@@ -70,7 +69,6 @@ parameters!(
Pos (Pos) pos, v (Pos::from_json(v).ok_or(perr!("{:?} not a pos", v))?) (json!(v));
Float (f64) float, v (v.as_f64().ok_or(perr!("{:?} not an float", v))?) (json!(v));
Template (Template) template, v (Template::from_json(v)?) (json!(["template", v.to_json()]));
- Interaction (Interactable) interaction, _v (Interactable::from_json(_v).ok_or(perr!("{:?} not an interactable", _v))?) (panic!("interactions can't be serialized"));
Bool (bool) bool, v (v.as_bool().ok_or(perr!("{:?} not a bool", v))?) (json!(v));
List (Vec<Parameter>) list, v
({
diff --git a/src/parameterexpression.rs b/src/parameterexpression.rs
index 7e2236e..65ad4c8 100644
--- a/src/parameterexpression.rs
+++ b/src/parameterexpression.rs
@@ -101,7 +101,7 @@ impl ParameterExpression {
let paramvalue = value.get(1).ok_or(perr!("index 1 not in component parameter"))?;
let typename = value.get(0).ok_or(perr!("index 0 not in component parameter"))?.as_str().ok_or(perr!("compparam type not a string"))?;
match typename {
- "string" | "int" | "float" | "bool" | "pos" | "interaction" => {
+ "string" | "int" | "float" | "bool" | "pos" => {
let paramtype = ParameterType::from_str(typename).expect(&format!("unknown parameter type {:?}", typename));
Ok(Self::Constant(Parameter::from_typed_json(paramtype, paramvalue)?))
}