Add pointlight to flashbangs (#15785)
This commit is contained in:
11
Content.Client/Light/Components/LightFadeComponent.cs
Normal file
11
Content.Client/Light/Components/LightFadeComponent.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Content.Client.Light.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Fades out the <see cref="SharedPointLightComponent"/> attached to this entity.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class LightFadeComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("duration")]
|
||||
public float Duration = 0.5f;
|
||||
}
|
||||
46
Content.Client/Light/EntitySystems/LightFadeSystem.cs
Normal file
46
Content.Client/Light/EntitySystems/LightFadeSystem.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Content.Client.Light.Components;
|
||||
using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Animations;
|
||||
|
||||
namespace Content.Client.Light.EntitySystems;
|
||||
|
||||
public sealed class LightFadeSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly AnimationPlayerSystem _player = default!;
|
||||
|
||||
private const string FadeTrack = "light-fade";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<LightFadeComponent, ComponentStartup>(OnFadeStartup);
|
||||
}
|
||||
|
||||
private void OnFadeStartup(EntityUid uid, LightFadeComponent component, ComponentStartup args)
|
||||
{
|
||||
if (!TryComp<PointLightComponent>(uid, out var light))
|
||||
return;
|
||||
|
||||
var animation = new Animation()
|
||||
{
|
||||
Length = TimeSpan.FromSeconds(component.Duration),
|
||||
AnimationTracks =
|
||||
{
|
||||
new AnimationTrackComponentProperty()
|
||||
{
|
||||
Property = nameof(PointLightComponent.Energy),
|
||||
ComponentType = typeof(PointLightComponent),
|
||||
InterpolationMode = AnimationInterpolationMode.Cubic,
|
||||
KeyFrames =
|
||||
{
|
||||
new AnimationTrackProperty.KeyFrame(light.Energy, 0f),
|
||||
new AnimationTrackProperty.KeyFrame(0f, component.Duration)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_player.Play(uid, animation, FadeTrack);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ namespace Content.Server.Entry
|
||||
"UIFragment",
|
||||
"PDABorderColor",
|
||||
"InventorySlots",
|
||||
"LightFade",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using Content.Server.Explosion.EntitySystems;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Explosion.Components;
|
||||
|
||||
[RegisterComponent, Access(typeof(TriggerSystem))]
|
||||
public sealed class SpawnOnTriggerComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("proto", required: true, customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string Proto = string.Empty;
|
||||
}
|
||||
@@ -70,12 +70,25 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
SubscribeLocalEvent<TriggerOnStepTriggerComponent, StepTriggeredEvent>(OnStepTriggered);
|
||||
SubscribeLocalEvent<TriggerOnSlipComponent, SlipEvent>(OnSlipTriggered);
|
||||
|
||||
SubscribeLocalEvent<SpawnOnTriggerComponent, TriggerEvent>(OnSpawnTrigger);
|
||||
SubscribeLocalEvent<DeleteOnTriggerComponent, TriggerEvent>(HandleDeleteTrigger);
|
||||
SubscribeLocalEvent<ExplodeOnTriggerComponent, TriggerEvent>(HandleExplodeTrigger);
|
||||
SubscribeLocalEvent<FlashOnTriggerComponent, TriggerEvent>(HandleFlashTrigger);
|
||||
SubscribeLocalEvent<GibOnTriggerComponent, TriggerEvent>(HandleGibTrigger);
|
||||
}
|
||||
|
||||
private void OnSpawnTrigger(EntityUid uid, SpawnOnTriggerComponent component, TriggerEvent args)
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
|
||||
var coords = xform.Coordinates;
|
||||
|
||||
if (!coords.IsValid(EntityManager))
|
||||
return;
|
||||
|
||||
Spawn(component.Proto, coords);
|
||||
}
|
||||
|
||||
private void HandleExplodeTrigger(EntityUid uid, ExplodeOnTriggerComponent component, TriggerEvent args)
|
||||
{
|
||||
_explosions.TriggerExplosive(uid, user: args.User);
|
||||
|
||||
@@ -60,12 +60,28 @@
|
||||
sound:
|
||||
path: "/Audio/Effects/flash_bang.ogg"
|
||||
- type: DeleteOnTrigger
|
||||
- type: SpawnOnTrigger
|
||||
proto: GrenadeFlashEffect
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: TimerTriggerVisualizer
|
||||
countdown_sound:
|
||||
path: /Audio/Effects/countdown.ogg
|
||||
|
||||
- type: entity
|
||||
id: GrenadeFlashEffect
|
||||
noSpawn: true
|
||||
components:
|
||||
- type: PointLight
|
||||
enabled: true
|
||||
netsync: false
|
||||
radius: 5
|
||||
energy: 8
|
||||
- type: LightFade
|
||||
duration: 0.5
|
||||
- type: TimedDespawn
|
||||
lifetime: 0.5
|
||||
|
||||
- type: entity
|
||||
name: Syndicate minibomb
|
||||
description: A precision sabotage explosive for quickly destroying a machine, dead body, or whatever else needs to go.
|
||||
|
||||
Reference in New Issue
Block a user