2021-09-09 16:20:41 +02:00
|
|
|
using Robust.Shared.GameStates;
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared.Flash
|
|
|
|
|
{
|
|
|
|
|
public abstract class SharedFlashSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<SharedFlashableComponent, ComponentGetState>(OnFlashableGetState);
|
2021-11-30 15:20:38 +01:00
|
|
|
SubscribeLocalEvent<SharedFlashableComponent, ComponentGetStateAttemptEvent>(OnGetStateAttempt);
|
2021-09-09 16:20:41 +02:00
|
|
|
}
|
|
|
|
|
|
2022-02-04 12:43:58 +11:00
|
|
|
private static void OnGetStateAttempt(EntityUid uid, SharedFlashableComponent component, ref ComponentGetStateAttemptEvent args)
|
2021-09-09 16:20:41 +02:00
|
|
|
{
|
|
|
|
|
// 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;
|
2021-11-30 15:20:38 +01:00
|
|
|
}
|
2021-09-09 16:20:41 +02:00
|
|
|
|
2022-02-04 12:43:58 +11:00
|
|
|
private static void OnFlashableGetState(EntityUid uid, SharedFlashableComponent component, ref ComponentGetState args)
|
2021-11-30 15:20:38 +01:00
|
|
|
{
|
2021-09-09 16:20:41 +02:00
|
|
|
args.State = new FlashableComponentState(component.Duration, component.LastFlash);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|