Un-network TimedDespawnComponent (#20280)

This commit is contained in:
Leon Friedrich
2023-09-17 19:18:52 +12:00
committed by GitHub
parent 93ccd1b77d
commit 3be88f4680
2 changed files with 3 additions and 25 deletions

View File

@@ -5,7 +5,7 @@ namespace Content.Shared.Spawners.Components;
/// <summary> /// <summary>
/// Put this component on something you would like to despawn after a certain amount of time /// Put this component on something you would like to despawn after a certain amount of time
/// </summary> /// </summary>
[RegisterComponent, NetworkedComponent] [RegisterComponent]
public sealed partial class TimedDespawnComponent : Component public sealed partial class TimedDespawnComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -13,30 +13,14 @@ public abstract class SharedTimedDespawnSystem : EntitySystem
{ {
base.Initialize(); base.Initialize();
UpdatesOutsidePrediction = true; UpdatesOutsidePrediction = true;
SubscribeLocalEvent<TimedDespawnComponent, ComponentGetState>(OnDespawnGetState);
SubscribeLocalEvent<TimedDespawnComponent, ComponentHandleState>(OnDespawnHandleState);
}
private void OnDespawnGetState(EntityUid uid, TimedDespawnComponent component, ref ComponentGetState args)
{
args.State = new TimedDespawnComponentState()
{
Lifetime = component.Lifetime,
};
}
private void OnDespawnHandleState(EntityUid uid, TimedDespawnComponent component, ref ComponentHandleState args)
{
if (args.Current is not TimedDespawnComponentState state)
return;
component.Lifetime = state.Lifetime;
} }
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
base.Update(frameTime); base.Update(frameTime);
// AAAAAAAAAAAAAAAAAAAAAAAAAAA
// Client both needs to predict this, but also can't properly handle prediction resetting.
if (!_timing.IsFirstTimePredicted) if (!_timing.IsFirstTimePredicted)
return; return;
@@ -59,10 +43,4 @@ public abstract class SharedTimedDespawnSystem : EntitySystem
} }
protected abstract bool CanDelete(EntityUid uid); protected abstract bool CanDelete(EntityUid uid);
[Serializable, NetSerializable]
private sealed class TimedDespawnComponentState : ComponentState
{
public float Lifetime;
}
} }