diff options
| author | troido <troido@protonmail.com> | 2020-09-26 14:58:30 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-09-26 14:58:30 +0200 |
| commit | 9e69a2d3004e83a74cb876ae6c6fbdfb6ed167fb (patch) | |
| tree | f7384d11d41495caa627a320a488996fc89e5a97 | |
| parent | 9b7e3d14b3f35163199ed704ae35544fa658931e (diff) | |
remove deduplicate
| -rw-r--r-- | src/components/mod.rs | 8 | ||||
| -rw-r--r-- | src/componentwrapper.rs | 1 | ||||
| -rw-r--r-- | src/room.rs | 6 | ||||
| -rw-r--r-- | src/systems/deduplicate.rs | 57 | ||||
| -rw-r--r-- | src/systems/mod.rs | 2 |
5 files changed, 2 insertions, 72 deletions
diff --git a/src/components/mod.rs b/src/components/mod.rs index 3f804da..91fc081 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -240,14 +240,6 @@ pub struct Whitelist{ pub allowed: HashMap<String, HashSet<PlayerId>> } - -#[derive(Component, Debug, Clone)] -pub struct Dedup { - pub id: String, - pub priority: i64 -} - - #[derive(Component, Debug, Clone)] pub struct Minable { pub progress: i64, diff --git a/src/componentwrapper.rs b/src/componentwrapper.rs index edcfee1..4add5dc 100644 --- a/src/componentwrapper.rs +++ b/src/componentwrapper.rs @@ -208,7 +208,6 @@ components!(all: Ear () {Ear::default()}; Build (obj: Template); Whitelist (allowed: HashMap<String, HashSet<PlayerId>>); - Dedup (id: String, priority: i64); Minable (trigger: String, total: i64) { Minable { trigger: Trigger::from_str(&trigger).map_err(|_|aerr!("invalid trigger name {}", trigger))?, diff --git a/src/room.rs b/src/room.rs index 23545c0..400dfa2 100644 --- a/src/room.rs +++ b/src/room.rs @@ -69,7 +69,6 @@ use crate::{ Timeout, Clear, Building, - Deduplicate, SpawnTrigger, Replace, } @@ -77,7 +76,6 @@ use crate::{ pub fn default_dispatcher<'a, 'b>() -> Dispatcher<'a, 'b> { DispatcherBuilder::new() - .with(Deduplicate, "deduplicate", &[]) .with(Replace, "replace", &[]) .with(Timeout, "timeout", &[]) .with(UpdateCooldowns, "cool_down", &[]) @@ -87,7 +85,7 @@ pub fn default_dispatcher<'a, 'b>() -> Dispatcher<'a, 'b> { .with(Take, "take", &["controlinput", "controlai"]) .with(Use, "use", &["controlinput", "controlai"]) .with(Interact, "interact", &["controlinput", "controlai"]) - .with(SpawnTrigger, "spawntrigger", &["spawn", "deduplicate", "replace"]) + .with(SpawnTrigger, "spawntrigger", &["spawn", "replace"]) .with(Move, "move", &["controlinput", "controlai"]) .with(Trapping, "trapping", &["move"]) .with(Fight, "fight", &["move"]) @@ -126,7 +124,7 @@ impl <'a, 'b>Room<'a, 'b> { world.insert(NewEntities::new(encyclopedia)); register_insert!( world, - (Position, Visible, Controller, Movable, New, Removed, Moved, Player, Inventory, Health, Serialise, RoomExit, Entered, TriggerBox, Trap, Fighter, Healing, ControlCooldown, Autofight, MonsterAI, Home, AttackInbox, Item, Spawner, Clan, Faction, Interactable, Loot, Timer, Equipment, TimeOffset, Flags, Ear, Build, Whitelist, Dedup, Minable, LootHolder, OnSpawn, Substitute), + (Position, Visible, Controller, Movable, New, Removed, Moved, Player, Inventory, Health, Serialise, RoomExit, Entered, TriggerBox, Trap, Fighter, Healing, ControlCooldown, Autofight, MonsterAI, Home, AttackInbox, Item, Spawner, Clan, Faction, Interactable, Loot, Timer, Equipment, TimeOffset, Flags, Ear, Build, Whitelist, Minable, LootHolder, OnSpawn, Substitute), (Ground, Input, Output, Size, Spawn, Players, Emigration, Time, RoomFlags) ); diff --git a/src/systems/deduplicate.rs b/src/systems/deduplicate.rs deleted file mode 100644 index e9fb88a..0000000 --- a/src/systems/deduplicate.rs +++ /dev/null @@ -1,57 +0,0 @@ - -use std::collections::HashSet; - -use specs::{ - Read, - WriteStorage, - ReadStorage, - Entities, - Entity, - System, - Join -}; - -use crate::{ - components::{Dedup, Removed, New, Position}, - resources::Ground -}; - - -pub struct Deduplicate; -impl <'a> System<'a> for Deduplicate { - type SystemData = ( - Entities<'a>, - WriteStorage<'a, Dedup>, - WriteStorage<'a, Removed>, - ReadStorage<'a, New>, - ReadStorage<'a, Position>, - Read<'a, Ground> - ); - fn run(&mut self, (entities, mut dedups, mut removeds, news, positions, ground): Self::SystemData) { - for (entity, dedup, position, _) in (&entities, &dedups, &positions, &news).join() { - let others: Vec<(Entity, &Dedup)> = ground.cells - .get(&position.pos) - .unwrap_or(&HashSet::new()) - .iter() - .filter_map(|e| Some((*e, dedups.get(*e)?))) - .collect(); - for (e, d) in others { - if dedup.id == d.id { - if dedup.priority > d.priority { - removeds.insert(e, Removed).unwrap(); - } else if dedup.priority < d.priority { - removeds.insert(entity, Removed).unwrap(); - } else if entity > e { - removeds.insert(e, Removed).unwrap(); - } else if entity < e { - removeds.insert(entity, Removed).unwrap(); - } - } - } - } - for (dedup, _) in (&mut dedups, &news).join() { - dedup.priority += 1; - } - } -} - diff --git a/src/systems/mod.rs b/src/systems/mod.rs index 7f93bb9..e0ae2e8 100644 --- a/src/systems/mod.rs +++ b/src/systems/mod.rs @@ -21,7 +21,6 @@ mod droploot; mod timeout; mod clear; mod building; -mod deduplicate; mod spawntrigger; mod replace; @@ -48,7 +47,6 @@ pub use self::{ timeout::Timeout, clear::Clear, building::Building, - deduplicate::Deduplicate, spawntrigger::SpawnTrigger, replace::Replace, }; |
