Files
tbd-station-14/Content.Shared/Flash/SharedFlashSystem.cs
Paul Ritter fbcb53dcc0 pvs content (#5484)
Co-authored-by: Paul <ritter.paul1+git@googlemail.com>
2021-11-30 15:20:38 +01:00

29 lines
1011 B
C#

using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
namespace Content.Shared.Flash
{
public abstract class SharedFlashSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SharedFlashableComponent, ComponentGetState>(OnFlashableGetState);
SubscribeLocalEvent<SharedFlashableComponent, ComponentGetStateAttemptEvent>(OnGetStateAttempt);
}
private void OnGetStateAttempt(EntityUid uid, SharedFlashableComponent component, ComponentGetStateAttemptEvent args)
{
// Only send state to the player attached to the entity.
if (args.Player.AttachedEntityUid != uid)
args.Cancel();
}
private void OnFlashableGetState(EntityUid uid, SharedFlashableComponent component, ref ComponentGetState args)
{
args.State = new FlashableComponentState(component.Duration, component.LastFlash);
}
}
}