diff --git a/common/net/src/synced_components.rs b/common/net/src/synced_components.rs index 63b5fc1e5e..f83f9c6e15 100644 --- a/common/net/src/synced_components.rs +++ b/common/net/src/synced_components.rs @@ -64,6 +64,7 @@ macro_rules! synced_components { combo: Combo, active_abilities: ActiveAbilities, can_build: CanBuild, + object: Object, } }; } @@ -253,3 +254,7 @@ impl NetSync for ActiveAbilities { impl NetSync for CanBuild { const SYNC_FROM: SyncFrom = SyncFrom::ClientEntity; } + +impl NetSync for Object { + const SYNC_FROM: SyncFrom = SyncFrom::AnyEntity; +} diff --git a/common/src/comp/misc.rs b/common/src/comp/misc.rs index 968c894ff7..c803ec64e9 100644 --- a/common/src/comp/misc.rs +++ b/common/src/comp/misc.rs @@ -1,9 +1,10 @@ use super::item::Reagent; -use crate::uid::Uid; +use crate::{resources::Time, uid::Uid}; use serde::{Deserialize, Serialize}; -use specs::Component; +use specs::{Component, DerefFlaggedStorage}; +use std::time::Duration; -#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum Object { Bomb { owner: Option, @@ -12,8 +13,12 @@ pub enum Object { owner: Option, reagent: Reagent, }, + DeleteAfter { + spawned_at: Time, + timeout: Duration, + }, } impl Component for Object { - type Storage = specs::VecStorage; + type Storage = DerefFlaggedStorage>; } diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index a15f4fdbac..db45966106 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -19,7 +19,7 @@ use common::{ self, item::{ItemKind, MaterialStatManifest}, skills::{GeneralSkill, Skill}, - ChatType, Group, Inventory, Item, LootOwner, Player, Poise, Presence, PresenceKind, + ChatType, Group, Inventory, Item, LootOwner, Object, Player, Poise, Presence, PresenceKind, }, effect::Effect, link::{Link, LinkHandle}, @@ -40,7 +40,7 @@ use specs::{ saveload::MarkerAllocator, Builder, Entity as EcsEntity, EntityBuilder as EcsEntityBuilder, Join, WorldExt, }; -use std::time::Instant; +use std::time::{Duration, Instant}; use tracing::{trace, warn}; use vek::*; @@ -366,6 +366,8 @@ impl StateExt for State { // Only if merging items fails do we give up and create a new item } + let spawned_at = *self.ecs().read_resource::