diff options
| author | troido <troido@protonmail.com> | 2020-09-26 14:05:14 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-09-26 14:05:14 +0200 |
| commit | 9b7e3d14b3f35163199ed704ae35544fa658931e (patch) | |
| tree | 9ad3623420f34b48f538ff2ceca6e3a277f16758 /src/componentwrapper.rs | |
| parent | 450cf9331803532cb0e3a002fec17d12be18abd6 (diff) | |
spawned entities are now saved but not spawned again until removed
Diffstat (limited to 'src/componentwrapper.rs')
| -rw-r--r-- | src/componentwrapper.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/componentwrapper.rs b/src/componentwrapper.rs index 340d0c0..edcfee1 100644 --- a/src/componentwrapper.rs +++ b/src/componentwrapper.rs @@ -3,7 +3,6 @@ use std::collections::{HashMap, HashSet}; use serde::{Serialize, Deserialize}; use strum_macros::{EnumString, Display}; use specs::Builder; -use rand::Rng; use std::str::FromStr; use crate::{ @@ -24,7 +23,8 @@ use crate::{ Template, Pos, Result, - aerr + aerr, + errors }; @@ -163,14 +163,8 @@ components!(all: Spawner (amount: i64, clan: String, template: Template, radius: i64) { Spawner{ amount: amount as usize, - clan: Clan{name: - if clan == "" { - format!("$random({})", rand::thread_rng().gen::<u32>()) - } else { - clan - } - }, - template: template.unsaved(), + clan: Clan{name: clan}, + template: template, saturated: false, radius } @@ -230,6 +224,13 @@ components!(all: } }; Substitute (into: Template); + TriggerBox (triggers: Vec<String>) { + TriggerBox { + messages: triggers.iter().map(|s| + Trigger::from_str(s).map_err(|_|aerr!("invalid trigger name {}", s)) + ).collect::<std::result::Result<Vec<Trigger>, std::boxed::Box<errors::AError>>>()? + } + }; ); |
