Update trivial components to use auto comp states (#20539)

This commit is contained in:
DrSmugleaf
2023-09-28 16:20:29 -07:00
committed by GitHub
parent 14cfe44ece
commit a44fa86b68
158 changed files with 806 additions and 2866 deletions

View File

@@ -1,6 +1,3 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Speech
{
public sealed class SpeechSystem : EntitySystem
@@ -10,8 +7,6 @@ namespace Content.Shared.Speech
base.Initialize();
SubscribeLocalEvent<SpeakAttemptEvent>(OnSpeakAttempt);
SubscribeLocalEvent<SpeechComponent, ComponentGetState>(OnSpeechGetState);
SubscribeLocalEvent<SpeechComponent, ComponentHandleState>(OnSpeechHandleState);
}
public void SetSpeech(EntityUid uid, bool value, SpeechComponent? component = null)
@@ -27,34 +22,10 @@ namespace Content.Shared.Speech
Dirty(component);
}
private void OnSpeechHandleState(EntityUid uid, SpeechComponent component, ref ComponentHandleState args)
{
if (args.Current is not SpeechComponentState state)
return;
component.Enabled = state.Enabled;
}
private void OnSpeechGetState(EntityUid uid, SpeechComponent component, ref ComponentGetState args)
{
args.State = new SpeechComponentState(component.Enabled);
}
private void OnSpeakAttempt(SpeakAttemptEvent args)
{
if (!TryComp(args.Uid, out SpeechComponent? speech) || !speech.Enabled)
args.Cancel();
}
[Serializable, NetSerializable]
private sealed class SpeechComponentState : ComponentState
{
public readonly bool Enabled;
public SpeechComponentState(bool enabled)
{
Enabled = enabled;
}
}
}
}