Files
OldThink/Content.Shared/Flash/SharedFlashSystem.cs

28 lines
1001 B
C#
Raw Normal View History

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);
}
2022-02-04 12:43:58 +11:00
private static void OnGetStateAttempt(EntityUid uid, SharedFlashableComponent component, ref ComponentGetStateAttemptEvent args)
{
// Only send state to the player attached to the entity.
2021-12-05 18:09:01 +01:00
if (args.Player.AttachedEntity != uid)
2022-02-04 12:43:58 +11:00
args.Cancelled = true;
}
2022-02-04 12:43:58 +11:00
private static void OnFlashableGetState(EntityUid uid, SharedFlashableComponent component, ref ComponentGetState args)
{
args.State = new FlashableComponentState(component.Duration, component.LastFlash);
}
}
}