Fix light animations (#20263)

This commit is contained in:
Leon Friedrich
2023-09-18 05:57:49 +12:00
committed by GitHub
parent 91231cb3fc
commit 53b4da68fa
13 changed files with 12 additions and 55 deletions

View File

@@ -30,7 +30,7 @@ public sealed partial class TriggerSystem
{
ComponentType = typeof(PointLightComponent),
InterpolationMode = AnimationInterpolationMode.Nearest,
Property = nameof(PointLightComponent.Radius),
Property = nameof(PointLightComponent.AnimatedRadius),
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(0.1f, 0),

View File

@@ -24,7 +24,7 @@ namespace Content.Client.Light.Components
[DataField("id")] public string ID { get; set; } = string.Empty;
[DataField("property")]
public virtual string Property { get; protected set; } = "Radius";
public virtual string Property { get; protected set; } = nameof(PointLightComponent.AnimatedRadius);
[DataField("isLooped")] public bool IsLooped { get; set; }
@@ -119,7 +119,7 @@ namespace Content.Client.Light.Components
var playingTime = prevPlayingTime + frameTime;
var interpolateValue = playingTime / MaxTime;
if (Property == "Enabled") // special case for boolean
if (Property == nameof(PointLightComponent.AnimatedEnable)) // special case for boolean
{
ApplyProperty(interpolateValue < 0.5f);
return (-1, playingTime);
@@ -181,7 +181,7 @@ namespace Content.Client.Light.Components
var playingTime = prevPlayingTime + frameTime;
var interpolateValue = playingTime / MaxTime;
if (Property == "Enabled") // special case for boolean
if (Property == nameof(PointLightComponent.AnimatedEnable)) // special case for boolean
{
ApplyProperty(interpolateValue < EndValue);
return (-1, playingTime);
@@ -245,7 +245,7 @@ namespace Content.Client.Light.Components
public override void OnStart()
{
if (Property == "Enabled") // special case for boolean, we randomize it
if (Property == nameof(PointLightComponent.AnimatedEnable)) // special case for boolean, we randomize it
{
ApplyProperty(_random.NextDouble() < 0.5);
return;
@@ -267,7 +267,7 @@ namespace Content.Client.Light.Components
var playingTime = prevPlayingTime + frameTime;
var interpolateValue = playingTime / MaxTime;
if (Property == "Enabled")
if (Property == nameof(PointLightComponent.AnimatedEnable))
{
return (-1, playingTime);
}
@@ -298,7 +298,7 @@ namespace Content.Client.Light.Components
public sealed partial class ColorCycleBehaviour : LightBehaviourAnimationTrack, ISerializationHooks
{
[DataField("property")]
public override string Property { get; protected set; } = "Color";
public override string Property { get; protected set; } = nameof(PointLightComponent.Color);
[DataField("colors")] public List<Color> ColorsToCycle { get; set; } = new();

View File

@@ -89,7 +89,7 @@ public sealed class PoweredLightVisualizerSystem : VisualizerSystem<PoweredLight
{
ComponentType = typeof(PointLightComponent),
InterpolationMode = AnimationInterpolationMode.Nearest,
Property = nameof(PointLightComponent.Enabled),
Property = nameof(PointLightComponent.AnimatedEnable),
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(false, 0),

View File

@@ -334,7 +334,7 @@ public sealed partial class GunSystem : SharedGunSystem
new AnimationTrackComponentProperty
{
ComponentType = typeof(PointLightComponent),
Property = nameof(PointLightComponent.Enabled),
Property = nameof(PointLightComponent.AnimatedEnable),
InterpolationMode = AnimationInterpolationMode.Linear,
KeyFrames =
{

View File

@@ -90,8 +90,6 @@
startValue: 3.0
endValue: 2.0
isLooped: true
property: Radius
enabled: false
reverseWhenFinished: true
- !type:PulseBehaviour
id: blinking
@@ -100,8 +98,6 @@
minValue: 0.1
maxValue: 2.0
isLooped: true
property: Radius
enabled: false
- type: PowerCellSlot
cellSlotId: cell_slot
- type: ItemSlots
@@ -209,8 +205,6 @@
startValue: 3.0
endValue: 2.0
isLooped: true
property: Radius
enabled: false
reverseWhenFinished: true
- !type:PulseBehaviour
id: blinking
@@ -219,15 +213,13 @@
minValue: 0.1
maxValue: 2.0
isLooped: true
property: Radius
enabled: false
- type: Battery
maxCharge: 600 #lights drain 3/s but recharge of 2 makes this 1/s. Therefore 600 is 10 minutes of light.
startingCharge: 600
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 2 #recharge of 2 makes total drain 1w / s so max charge is 1:1 with time. Time to fully charge should be 5 minutes. Having recharge gives light an extended flicker period which gives you some warning to return to light area.
- type: entity
abstract: true
id: ClothingHeadHatHoodWinterBase
@@ -236,7 +228,7 @@
noSpawn: true
components:
- type: Sprite
state: icon
state: icon
- type: Clickable
- type: Clothing
equipSound: /Audio/Effects/rustle1.ogg

View File

@@ -32,8 +32,6 @@
startValue: 3.0
endValue: 2.0
isLooped: true
property: Radius
enabled: false
reverseWhenFinished: true
- !type:PulseBehaviour
id: blinking
@@ -42,8 +40,6 @@
minValue: 0.1
maxValue: 2.0
isLooped: true
property: Radius
enabled: false
- type: ToggleableLightVisuals
spriteLayer: light
inhandVisuals:

View File

@@ -166,13 +166,10 @@
behaviours:
- !type:FadeBehaviour
id: radiating
interpolate: Linear
maxDuration: 2.0
startValue: 3.0
endValue: 2.0
isLooped: true
property: Radius
enabled: false
reverseWhenFinished: true
- !type:PulseBehaviour
id: blinking
@@ -181,8 +178,6 @@
minValue: 0.1
maxValue: 2.0
isLooped: true
property: Radius
enabled: false
- type: ToggleableLightVisuals
- type: PointLight
enabled: false

View File

@@ -12,13 +12,10 @@
behaviours:
- !type:FadeBehaviour
id: radiating
interpolate: Linear
maxDuration: 2.0
startValue: 3.0
endValue: 2.0
isLooped: true
property: Radius
enabled: false
reverseWhenFinished: true
- !type:PulseBehaviour
id: blinking
@@ -27,8 +24,6 @@
minValue: 0.1
maxValue: 2.0
isLooped: true
property: Radius
enabled: false
- type: PowerCellSlot
cellSlotId: cell_slot
- type: ItemSlots

View File

@@ -57,11 +57,9 @@
isLooped: true
- !type:FadeBehaviour # have the radius start small and get larger as it starts to burn
id: turn_on
interpolate: Linear
maxDuration: 8.0
startValue: 1.0
endValue: 6.0
property: Radius
- !type:RandomizeBehaviour # weaker flicker as it fades out
id: fade_out
interpolate: Nearest
@@ -73,8 +71,6 @@
isLooped: true
- !type:FadeBehaviour # fade out radius as it burns out
id: fade_out
interpolate: Linear
maxDuration: 4.0
startValue: 6.0
endValue: 1.0
property: Radius

View File

@@ -53,11 +53,9 @@
behaviours:
- !type:FadeBehaviour # have the radius start small and get larger as it starts to burn
id: turn_on
interpolate: Linear
maxDuration: 45.0
startValue: 2.5
endValue: 10.0
property: Radius
- !type:RandomizeBehaviour # weaker flicker as it fades out
id: fade_out
interpolate: Nearest
@@ -69,8 +67,6 @@
isLooped: true
- !type:FadeBehaviour # fade out radius as it burns out
id: fade_out
interpolate: Linear
maxDuration: 15.0
startValue: 10.0
endValue: 1.0
property: Radius

View File

@@ -16,13 +16,10 @@
behaviours:
- !type:FadeBehaviour
id: radiating
interpolate: Linear
maxDuration: 2.0
startValue: 3.0
endValue: 2.0
isLooped: true
property: Radius
enabled: false
reverseWhenFinished: true
- !type:PulseBehaviour
id: blinking
@@ -31,8 +28,6 @@
minValue: 0.1
maxValue: 2.0
isLooped: true
property: Radius
enabled: false
- type: ToggleableLightVisuals
spriteLayer: light
inhandVisuals:

View File

@@ -60,7 +60,6 @@
maxDuration: 10 # 300.0
startValue: 5.0
endValue: 1.5
property: Radius
- type: entity
name: red glowstick
@@ -199,7 +198,7 @@
minDuration: 0.2
maxDuration: 1.0
maxValue: 0.2
property: Enabled
property: AnimatedEnable
isLooped: true
enabled: true
- !type:ColorCycleBehaviour
@@ -272,7 +271,6 @@
minValue: 2.0
maxValue: 10.0
isLooped: true
property: Radius
enabled: true
- type: entity
@@ -304,5 +302,4 @@
minValue: 10.0
maxValue: 25.0
isLooped: true
property: Radius
enabled: true

View File

@@ -12,13 +12,10 @@
behaviours:
- !type:FadeBehaviour
id: radiating
interpolate: Linear
maxDuration: 2.0
startValue: 3.0
endValue: 2.0
isLooped: true
property: Radius
enabled: false
reverseWhenFinished: true
- !type:PulseBehaviour
id: blinking
@@ -27,8 +24,6 @@
minValue: 0.1
maxValue: 2.0
isLooped: true
property: Radius
enabled: false
- type: Sprite
sprite: Objects/Tools/lantern.rsi
layers: