FlashLightVisualizer refactor + low power handheld light light radius fix (#11768)

* refactor: Removes FlashLightVisualizer (based on obsolete code) in favor or merging its functionality with HandheldLightComponent
fix: Low power lighting radius animations for lanterns, floodlights and flashlights now properly restore the original light radius when going back to full power

* refactor: Use the LightBehaviour component to animate HandheldLights
refactor: Remove unneeded HandheldLight definitions in some yaml files (already inherited by parents)
fix: Properly change the server side PointLightComponent Enabled property when turning HandheldLights on/off
feat: ReverseWhenFinished property on Fade light behaviours

* Empty commit to rerun CI with the new engine PR

* fix: Restore the correct HandheldLight addPrefix property, whoops

* refactor: blinkingBehaviourID -> blinkingBehaviourId, radiatingBehaviourID -> radiatingBehaviourId
This commit is contained in:
Francesco
2022-10-19 20:34:36 +02:00
committed by GitHub
parent af33db3cc3
commit 9727cc0da0
11 changed files with 281 additions and 212 deletions

View File

@@ -1,7 +1,10 @@
using Content.Client.Items;
using Content.Client.Light.Components;
using Content.Shared.Light;
using Content.Shared.Light.Component;
using Content.Shared.Toggleable;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.Animations;
namespace Content.Client.Light;
@@ -12,10 +15,56 @@ public sealed class HandheldLightSystem : SharedHandheldLightSystem
base.Initialize();
SubscribeLocalEvent<HandheldLightComponent, ItemStatusCollectMessage>(OnGetStatusControl);
SubscribeLocalEvent<HandheldLightComponent, AppearanceChangeEvent>(OnAppearanceChange);
}
private static void OnGetStatusControl(EntityUid uid, HandheldLightComponent component, ItemStatusCollectMessage args)
{
args.Controls.Add(new HandheldLightStatus(component));
}
private void OnAppearanceChange(EntityUid uid, HandheldLightComponent? component, ref AppearanceChangeEvent args)
{
if (!Resolve(uid, ref component))
{
return;
}
if (!args.Component.TryGetData(ToggleableLightVisuals.Enabled, out bool enabled))
{
return;
}
if (!args.Component.TryGetData(HandheldLightVisuals.Power,
out HandheldLightPowerStates state))
{
return;
}
if (TryComp<LightBehaviourComponent>(uid, out var lightBehaviour))
{
// Reset any running behaviour to reset the animated properties back to the original value, to avoid conflicts between resets
if (lightBehaviour.HasRunningBehaviours())
{
lightBehaviour.StopLightBehaviour(resetToOriginalSettings: true);
}
if (!enabled)
{
return;
}
switch (state)
{
case HandheldLightPowerStates.FullPower:
break; // We just needed to reset all behaviours
case HandheldLightPowerStates.LowPower:
lightBehaviour.StartLightBehaviour(component.RadiatingBehaviourId);
break;
case HandheldLightPowerStates.Dying:
lightBehaviour.StartLightBehaviour(component.BlinkingBehaviourId);
break;
}
}
}
}