Move TimedDespawn to engine (#20515)
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
<ProjectReference Include="..\RobustToolbox\Robust.Client\Robust.Client.csproj" />
|
||||
<ProjectReference Include="..\Content.Shared\Content.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Spawners\" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
|
||||
<Import Project="..\RobustToolbox\MSBuild\XamlIL.targets" />
|
||||
</Project>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ public sealed class SpawnerSystem : EntitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<TimedSpawnerComponent, ComponentInit>(OnSpawnerInit);
|
||||
SubscribeLocalEvent<TimedSpawnerComponent, ComponentShutdown>(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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<TimedSpawnerComponent, ComponentShutdown>(OnTimedSpawnerShutdown);
|
||||
}
|
||||
|
||||
private void OnTimedSpawnerShutdown(EntityUid uid, TimedSpawnerComponent component, ComponentShutdown args)
|
||||
{
|
||||
component.TokenSource?.Cancel();
|
||||
}
|
||||
|
||||
protected override bool CanDelete(EntityUid uid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
/// <summary>
|
||||
/// How long will animation play in seconds.
|
||||
/// Can be overridden by <see cref="TimedDespawnComponent"/>.
|
||||
/// Can be overridden by <see cref="Robust.Shared.Spawners.TimedDespawnComponent"/>.
|
||||
/// </summary>
|
||||
public float VisualDuration = 2f;
|
||||
|
||||
|
||||
@@ -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<RadiationSourceComponent>(uid, out var radSource))
|
||||
{
|
||||
{
|
||||
component.VisualRange = radSource.Intensity / radSource.Slope;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Spawners.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Put this component on something you would like to despawn after a certain amount of time
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class TimedDespawnComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// How long the entity will exist before despawning
|
||||
/// </summary>
|
||||
[DataField("lifetime")]
|
||||
public float Lifetime = 5f;
|
||||
}
|
||||
@@ -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<TimedDespawnComponent>();
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Content.Shared.Spawners;
|
||||
|
||||
/// <summary>
|
||||
/// Raised directed on an entity when its timed despawn is over.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly record struct TimedDespawnEvent;
|
||||
Reference in New Issue
Block a user