Refactors flashes to ECS, sunglasses protect you from being flashed. (#4579)
* Refactors flashes to ECS, sunglasses protect you from being flashed. * VV ReadWrite for FlashImmunity Enabled. * Use cached IEntityLookup. * Consistent formatting. * Fix flashbang duration. Flash duration is a mess. * Small area flash code cleanup. * Flashable state is only sent to attached player.
This commit is contained in:
committed by
GitHub
parent
e8f769d189
commit
77fe21eb0d
24
Content.Shared/Flash/SharedFlashSystem.cs
Normal file
24
Content.Shared/Flash/SharedFlashSystem.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
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);
|
||||
}
|
||||
|
||||
private void OnFlashableGetState(EntityUid uid, SharedFlashableComponent component, ref ComponentGetState args)
|
||||
{
|
||||
// Only send state to the player attached to the entity.
|
||||
if (args.Player.AttachedEntityUid != uid)
|
||||
return;
|
||||
|
||||
args.State = new FlashableComponentState(component.Duration, component.LastFlash);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,27 @@
|
||||
using System;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Flash
|
||||
{
|
||||
[NetworkedComponent()]
|
||||
public class SharedFlashableComponent : Component
|
||||
[NetworkedComponent, Friend(typeof(SharedFlashSystem))]
|
||||
public abstract class SharedFlashableComponent : Component
|
||||
{
|
||||
public override string Name => "Flashable";
|
||||
|
||||
public float Duration { get; set; }
|
||||
public TimeSpan LastFlash { get; set; }
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class FlashComponentState : ComponentState
|
||||
public class FlashableComponentState : ComponentState
|
||||
{
|
||||
public double Duration { get; }
|
||||
public float Duration { get; }
|
||||
public TimeSpan Time { get; }
|
||||
|
||||
public FlashComponentState(double duration, TimeSpan time)
|
||||
public FlashableComponentState(float duration, TimeSpan time)
|
||||
{
|
||||
Duration = duration;
|
||||
Time = time;
|
||||
|
||||
Reference in New Issue
Block a user