2021-09-09 16:20:41 +02:00
|
|
|
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);
|
2021-11-30 15:20:38 +01:00
|
|
|
SubscribeLocalEvent<SharedFlashableComponent, ComponentGetStateAttemptEvent>(OnGetStateAttempt);
|
2021-09-09 16:20:41 +02:00
|
|
|
}
|
|
|
|
|
|
2021-11-30 15:20:38 +01:00
|
|
|
private void OnGetStateAttempt(EntityUid uid, SharedFlashableComponent component, ComponentGetStateAttemptEvent args)
|
2021-09-09 16:20:41 +02:00
|
|
|
{
|
|
|
|
|
// Only send state to the player attached to the entity.
|
|
|
|
|
if (args.Player.AttachedEntityUid != uid)
|
2021-11-30 15:20:38 +01:00
|
|
|
args.Cancel();
|
|
|
|
|
}
|
2021-09-09 16:20:41 +02:00
|
|
|
|
2021-11-30 15:20:38 +01:00
|
|
|
private void OnFlashableGetState(EntityUid uid, SharedFlashableComponent component, ref ComponentGetState args)
|
|
|
|
|
{
|
2021-09-09 16:20:41 +02:00
|
|
|
args.State = new FlashableComponentState(component.Duration, component.LastFlash);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|