From 3a196a1d098fa999e68edfec374041ad68413b07 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sat, 30 Sep 2023 14:35:32 +1000 Subject: [PATCH] Move TimedDespawn to engine (#20515) --- .../Animations/ReusableAnimations.cs | 3 +- .../Visualizers/FoamVisualizerSystem.cs | 2 +- Content.Client/Content.Client.csproj | 3 ++ .../Projectiles/ProjectileSystem.cs | 3 +- Content.Client/Salvage/FultonSystem.cs | 3 +- Content.Client/Spawners/TimedDespawnSystem.cs | 11 ----- .../Weapons/Ranged/Systems/GunSystem.cs | 3 +- .../Chemistry/EntitySystems/VaporSystem.cs | 3 +- .../ExplosionSystem.Processing.cs | 3 +- .../Fluids/EntitySystems/SmokeSystem.cs | 5 +- Content.Server/Magic/MagicSystem.cs | 2 +- .../Shuttles/Systems/ArrivalsSystem.cs | 3 +- .../Spawners/EntitySystems/SpawnerSystem.cs | 6 +++ .../EntitySystems/TimedDespawnSystem.cs | 23 ---------- .../StationEvents/Events/ImmovableRodRule.cs | 3 +- .../StationEvents/Events/MeteorSwarmRule.cs | 3 +- .../Components/RadiationPulseComponent.cs | 3 +- .../Radiation/Systems/RadiationPulseSystem.cs | 4 +- .../Components/TimedDespawnComponent.cs | 16 ------- .../EntitySystems/SharedTimedDespawnSystem.cs | 46 ------------------- Content.Shared/Spawners/TimedDespawnEvent.cs | 7 --- 21 files changed, 35 insertions(+), 120 deletions(-) delete mode 100644 Content.Client/Spawners/TimedDespawnSystem.cs delete mode 100644 Content.Server/Spawners/EntitySystems/TimedDespawnSystem.cs delete mode 100644 Content.Shared/Spawners/Components/TimedDespawnComponent.cs delete mode 100644 Content.Shared/Spawners/EntitySystems/SharedTimedDespawnSystem.cs delete mode 100644 Content.Shared/Spawners/TimedDespawnEvent.cs diff --git a/Content.Client/Animations/ReusableAnimations.cs b/Content.Client/Animations/ReusableAnimations.cs index 3803af1de9..33e3eb25b4 100644 --- a/Content.Client/Animations/ReusableAnimations.cs +++ b/Content.Client/Animations/ReusableAnimations.cs @@ -1,9 +1,10 @@ using System.Numerics; -using Content.Shared.Spawners.Components; +using Robust.Shared.Spawners; using Robust.Client.Animations; using Robust.Client.GameObjects; using Robust.Shared.Animations; using Robust.Shared.Map; +using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent; namespace Content.Client.Animations { diff --git a/Content.Client/Chemistry/Visualizers/FoamVisualizerSystem.cs b/Content.Client/Chemistry/Visualizers/FoamVisualizerSystem.cs index 5cef1db805..ec582ee094 100644 --- a/Content.Client/Chemistry/Visualizers/FoamVisualizerSystem.cs +++ b/Content.Client/Chemistry/Visualizers/FoamVisualizerSystem.cs @@ -1,5 +1,5 @@ using Content.Shared.Smoking; -using Content.Shared.Spawners.Components; +using Robust.Shared.Spawners; using Robust.Client.Animations; using Robust.Client.GameObjects; using Robust.Shared.Network; diff --git a/Content.Client/Content.Client.csproj b/Content.Client/Content.Client.csproj index 257999b8c1..33ee0e0a34 100644 --- a/Content.Client/Content.Client.csproj +++ b/Content.Client/Content.Client.csproj @@ -23,6 +23,9 @@ + + + diff --git a/Content.Client/Projectiles/ProjectileSystem.cs b/Content.Client/Projectiles/ProjectileSystem.cs index 07da813045..2132256b1b 100644 --- a/Content.Client/Projectiles/ProjectileSystem.cs +++ b/Content.Client/Projectiles/ProjectileSystem.cs @@ -1,9 +1,10 @@ using Content.Shared.Projectiles; -using Content.Shared.Spawners.Components; +using Robust.Shared.Spawners; using Content.Shared.Weapons.Ranged.Systems; using Robust.Client.Animations; using Robust.Client.GameObjects; using Robust.Shared.GameStates; +using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent; namespace Content.Client.Projectiles; diff --git a/Content.Client/Salvage/FultonSystem.cs b/Content.Client/Salvage/FultonSystem.cs index 05e7dd12d9..7e31fbb180 100644 --- a/Content.Client/Salvage/FultonSystem.cs +++ b/Content.Client/Salvage/FultonSystem.cs @@ -1,6 +1,6 @@ using System.Numerics; using Content.Shared.Salvage.Fulton; -using Content.Shared.Spawners.Components; +using Robust.Shared.Spawners; using JetBrains.Annotations; using Robust.Client.Animations; using Robust.Client.GameObjects; @@ -8,6 +8,7 @@ using Robust.Client.Graphics; using Robust.Shared.Animations; using Robust.Shared.Serialization.Manager; using Robust.Shared.Utility; +using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent; namespace Content.Client.Salvage; diff --git a/Content.Client/Spawners/TimedDespawnSystem.cs b/Content.Client/Spawners/TimedDespawnSystem.cs deleted file mode 100644 index 14e34dce44..0000000000 --- a/Content.Client/Spawners/TimedDespawnSystem.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Content.Shared.Spawners.EntitySystems; - -namespace Content.Client.Spawners; - -public sealed class TimedDespawnSystem : SharedTimedDespawnSystem -{ - protected override bool CanDelete(EntityUid uid) - { - return IsClientSide(uid); - } -} diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs index 84284c9a50..72f0c2130b 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs @@ -3,7 +3,7 @@ using Content.Client.Items; using Content.Client.Weapons.Ranged.Components; using Content.Shared.Camera; using Content.Shared.CombatMode; -using Content.Shared.Spawners.Components; +using Robust.Shared.Spawners; using Content.Shared.Weapons.Ranged; using Content.Shared.Weapons.Ranged.Components; using Content.Shared.Weapons.Ranged.Events; @@ -19,6 +19,7 @@ using Robust.Shared.Map; using Robust.Shared.Prototypes; using Robust.Shared.Utility; using SharedGunSystem = Content.Shared.Weapons.Ranged.Systems.SharedGunSystem; +using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent; namespace Content.Client.Weapons.Ranged.Systems; diff --git a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs index 8cff8a19cb..d95490e9a0 100644 --- a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs @@ -6,7 +6,7 @@ using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Reagent; using Content.Shared.FixedPoint; using Content.Shared.Physics; -using Content.Shared.Spawners.Components; +using Robust.Shared.Spawners; using Content.Shared.Throwing; using JetBrains.Annotations; using Robust.Shared.Map; @@ -15,6 +15,7 @@ using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Events; using Robust.Shared.Physics.Systems; using Robust.Shared.Prototypes; +using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent; namespace Content.Server.Chemistry.EntitySystems { diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs index 1938831f7e..cce7050e3f 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs @@ -9,7 +9,7 @@ using Content.Shared.Maps; using Content.Shared.Mind.Components; using Content.Shared.Physics; using Content.Shared.Projectiles; -using Content.Shared.Spawners.Components; +using Robust.Shared.Spawners; using Content.Shared.Tag; using Robust.Shared.Map; using Robust.Shared.Map.Components; @@ -18,6 +18,7 @@ using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Dynamics; using Robust.Shared.Random; using Robust.Shared.Timing; +using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent; namespace Content.Server.Explosion.EntitySystems; diff --git a/Content.Server/Fluids/EntitySystems/SmokeSystem.cs b/Content.Server/Fluids/EntitySystems/SmokeSystem.cs index ee0d16a7a2..a192b39e56 100644 --- a/Content.Server/Fluids/EntitySystems/SmokeSystem.cs +++ b/Content.Server/Fluids/EntitySystems/SmokeSystem.cs @@ -14,12 +14,13 @@ using Content.Shared.Coordinates.Helpers; using Content.Shared.Database; using Content.Shared.FixedPoint; using Content.Shared.Smoking; -using Content.Shared.Spawners; -using Content.Shared.Spawners.Components; +using Robust.Shared.Spawners; using Robust.Server.GameObjects; using Robust.Shared.Map; using Robust.Shared.Prototypes; +using Robust.Shared.Spawners; using Robust.Shared.Timing; +using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent; namespace Content.Server.Fluids.EntitySystems; diff --git a/Content.Server/Magic/MagicSystem.cs b/Content.Server/Magic/MagicSystem.cs index 5b990412d8..9cca5fa32c 100644 --- a/Content.Server/Magic/MagicSystem.cs +++ b/Content.Server/Magic/MagicSystem.cs @@ -16,7 +16,7 @@ using Content.Shared.Magic; using Content.Shared.Magic.Events; using Content.Shared.Maps; using Content.Shared.Physics; -using Content.Shared.Spawners.Components; +using Robust.Shared.Spawners; using Content.Shared.Storage; using Robust.Server.GameObjects; using Robust.Shared.Audio; diff --git a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs index 7bbe6ed108..19779c5cfe 100644 --- a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs +++ b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs @@ -13,7 +13,7 @@ using Content.Shared.CCVar; using Content.Shared.Mobs.Components; using Content.Shared.Movement.Components; using Content.Shared.Shuttles.Components; -using Content.Shared.Spawners.Components; +using Robust.Shared.Spawners; using Content.Shared.Tiles; using Robust.Server.GameObjects; using Robust.Shared.Collections; @@ -22,6 +22,7 @@ using Robust.Shared.Console; using Robust.Shared.Map; using Robust.Shared.Random; using Robust.Shared.Timing; +using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent; namespace Content.Server.Shuttles.Systems; diff --git a/Content.Server/Spawners/EntitySystems/SpawnerSystem.cs b/Content.Server/Spawners/EntitySystems/SpawnerSystem.cs index 1d0e4c397c..c6e34c1848 100644 --- a/Content.Server/Spawners/EntitySystems/SpawnerSystem.cs +++ b/Content.Server/Spawners/EntitySystems/SpawnerSystem.cs @@ -12,6 +12,7 @@ public sealed class SpawnerSystem : EntitySystem { base.Initialize(); SubscribeLocalEvent(OnSpawnerInit); + SubscribeLocalEvent(OnTimedSpawnerShutdown); } private void OnSpawnerInit(EntityUid uid, TimedSpawnerComponent component, ComponentInit args) @@ -35,4 +36,9 @@ public sealed class SpawnerSystem : EntitySystem Spawn(entity, coordinates); } } + + private void OnTimedSpawnerShutdown(EntityUid uid, TimedSpawnerComponent component, ComponentShutdown args) + { + component.TokenSource?.Cancel(); + } } diff --git a/Content.Server/Spawners/EntitySystems/TimedDespawnSystem.cs b/Content.Server/Spawners/EntitySystems/TimedDespawnSystem.cs deleted file mode 100644 index cadad4633e..0000000000 --- a/Content.Server/Spawners/EntitySystems/TimedDespawnSystem.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Content.Server.Spawners.Components; -using Content.Shared.Spawners.EntitySystems; - -namespace Content.Server.Spawners.EntitySystems; - -public sealed class TimedDespawnSystem : SharedTimedDespawnSystem -{ - public override void Initialize() - { - base.Initialize(); - SubscribeLocalEvent(OnTimedSpawnerShutdown); - } - - private void OnTimedSpawnerShutdown(EntityUid uid, TimedSpawnerComponent component, ComponentShutdown args) - { - component.TokenSource?.Cancel(); - } - - protected override bool CanDelete(EntityUid uid) - { - return true; - } -} diff --git a/Content.Server/StationEvents/Events/ImmovableRodRule.cs b/Content.Server/StationEvents/Events/ImmovableRodRule.cs index b92ac917bc..a61c6b69e1 100644 --- a/Content.Server/StationEvents/Events/ImmovableRodRule.cs +++ b/Content.Server/StationEvents/Events/ImmovableRodRule.cs @@ -3,8 +3,9 @@ using Content.Server.GameTicking.Rules.Components; using Content.Server.ImmovableRod; using Content.Server.StationEvents.Components; using Content.Server.Weapons.Ranged.Systems; -using Content.Shared.Spawners.Components; +using Robust.Shared.Spawners; using Robust.Shared.Prototypes; +using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent; namespace Content.Server.StationEvents.Events; diff --git a/Content.Server/StationEvents/Events/MeteorSwarmRule.cs b/Content.Server/StationEvents/Events/MeteorSwarmRule.cs index b5408ac982..5192eef69b 100644 --- a/Content.Server/StationEvents/Events/MeteorSwarmRule.cs +++ b/Content.Server/StationEvents/Events/MeteorSwarmRule.cs @@ -1,10 +1,11 @@ using System.Numerics; using Content.Server.GameTicking.Rules.Components; using Content.Server.StationEvents.Components; -using Content.Shared.Spawners.Components; +using Robust.Shared.Spawners; using Robust.Shared.Map; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Systems; +using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent; namespace Content.Server.StationEvents.Events { diff --git a/Content.Shared/Radiation/Components/RadiationPulseComponent.cs b/Content.Shared/Radiation/Components/RadiationPulseComponent.cs index a1cfa566bc..a11e8e3ee0 100644 --- a/Content.Shared/Radiation/Components/RadiationPulseComponent.cs +++ b/Content.Shared/Radiation/Components/RadiationPulseComponent.cs @@ -1,5 +1,4 @@ using Content.Shared.Radiation.Systems; -using Content.Shared.Spawners.Components; namespace Content.Shared.Radiation.Components; @@ -18,7 +17,7 @@ public sealed partial class RadiationPulseComponent : Component /// /// How long will animation play in seconds. - /// Can be overridden by . + /// Can be overridden by . /// public float VisualDuration = 2f; diff --git a/Content.Shared/Radiation/Systems/RadiationPulseSystem.cs b/Content.Shared/Radiation/Systems/RadiationPulseSystem.cs index 7991f331ee..9f28033025 100644 --- a/Content.Shared/Radiation/Systems/RadiationPulseSystem.cs +++ b/Content.Shared/Radiation/Systems/RadiationPulseSystem.cs @@ -1,5 +1,5 @@ using Content.Shared.Radiation.Components; -using Content.Shared.Spawners.Components; +using Robust.Shared.Spawners; using Robust.Shared.Timing; namespace Content.Shared.Radiation.Systems; @@ -25,7 +25,7 @@ public sealed class RadiationPulseSystem : EntitySystem } // try to get radiation range or keep default visual range if (TryComp(uid, out var radSource)) - { + { component.VisualRange = radSource.Intensity / radSource.Slope; } } diff --git a/Content.Shared/Spawners/Components/TimedDespawnComponent.cs b/Content.Shared/Spawners/Components/TimedDespawnComponent.cs deleted file mode 100644 index c66d4810ad..0000000000 --- a/Content.Shared/Spawners/Components/TimedDespawnComponent.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Robust.Shared.GameStates; - -namespace Content.Shared.Spawners.Components; - -/// -/// Put this component on something you would like to despawn after a certain amount of time -/// -[RegisterComponent] -public sealed partial class TimedDespawnComponent : Component -{ - /// - /// How long the entity will exist before despawning - /// - [DataField("lifetime")] - public float Lifetime = 5f; -} diff --git a/Content.Shared/Spawners/EntitySystems/SharedTimedDespawnSystem.cs b/Content.Shared/Spawners/EntitySystems/SharedTimedDespawnSystem.cs deleted file mode 100644 index b867737cb6..0000000000 --- a/Content.Shared/Spawners/EntitySystems/SharedTimedDespawnSystem.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Content.Shared.Spawners.Components; -using Robust.Shared.GameStates; -using Robust.Shared.Serialization; -using Robust.Shared.Timing; - -namespace Content.Shared.Spawners.EntitySystems; - -public abstract class SharedTimedDespawnSystem : EntitySystem -{ - [Dependency] private readonly IGameTiming _timing = default!; - - public override void Initialize() - { - base.Initialize(); - UpdatesOutsidePrediction = true; - } - - public override void Update(float frameTime) - { - base.Update(frameTime); - - // AAAAAAAAAAAAAAAAAAAAAAAAAAA - // Client both needs to predict this, but also can't properly handle prediction resetting. - if (!_timing.IsFirstTimePredicted) - return; - - var query = EntityQueryEnumerator(); - - while (query.MoveNext(out var uid, out var comp)) - { - comp.Lifetime -= frameTime; - - if (!CanDelete(uid)) - continue; - - if (comp.Lifetime <= 0) - { - var ev = new TimedDespawnEvent(); - RaiseLocalEvent(uid, ref ev); - QueueDel(uid); - } - } - } - - protected abstract bool CanDelete(EntityUid uid); -} diff --git a/Content.Shared/Spawners/TimedDespawnEvent.cs b/Content.Shared/Spawners/TimedDespawnEvent.cs deleted file mode 100644 index 26551d86bf..0000000000 --- a/Content.Shared/Spawners/TimedDespawnEvent.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Content.Shared.Spawners; - -/// -/// Raised directed on an entity when its timed despawn is over. -/// -[ByRefEvent] -public readonly record struct TimedDespawnEvent; -- 2.51.2