Remove server-side sprites from ExpendableLightComponent (#13516)
This commit is contained in:
@@ -8,12 +8,25 @@ namespace Content.Client.Light.Visualizers
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class ExpendableLightVisualizer : AppearanceVisualizer
|
public sealed class ExpendableLightVisualizer : AppearanceVisualizer
|
||||||
{
|
{
|
||||||
|
[DataField("iconStateSpent")]
|
||||||
|
public string? IconStateSpent { get; set; }
|
||||||
|
|
||||||
|
[DataField("iconStateOn")]
|
||||||
|
public string? IconStateLit { get; set; }
|
||||||
|
|
||||||
[Obsolete("Subscribe to AppearanceChangeEvent instead.")]
|
[Obsolete("Subscribe to AppearanceChangeEvent instead.")]
|
||||||
public override void OnChangeData(AppearanceComponent component)
|
public override void OnChangeData(AppearanceComponent component)
|
||||||
{
|
{
|
||||||
base.OnChangeData(component);
|
base.OnChangeData(component);
|
||||||
|
|
||||||
var entities = IoCManager.Resolve<IEntityManager>();
|
var entities = IoCManager.Resolve<IEntityManager>();
|
||||||
|
|
||||||
|
if (!entities.TryGetComponent(component.Owner, out ExpendableLightComponent? expendableLight))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!entities.TryGetComponent(component.Owner, out SpriteComponent? sprite))
|
||||||
|
return;
|
||||||
|
|
||||||
if (component.TryGetData(ExpendableLightVisuals.Behavior, out string lightBehaviourID))
|
if (component.TryGetData(ExpendableLightVisuals.Behavior, out string lightBehaviourID))
|
||||||
{
|
{
|
||||||
if (entities.TryGetComponent(component.Owner, out LightBehaviourComponent? lightBehaviour))
|
if (entities.TryGetComponent(component.Owner, out LightBehaviourComponent? lightBehaviour))
|
||||||
@@ -31,9 +44,9 @@ namespace Content.Client.Light.Visualizers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component.TryGetData(ExpendableLightVisuals.State, out ExpendableLightState state)
|
if (!component.TryGetData(ExpendableLightVisuals.State, out ExpendableLightState state))
|
||||||
&& entities.TryGetComponent(component.Owner, out ExpendableLightComponent? expendableLight))
|
return;
|
||||||
{
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case ExpendableLightState.Lit:
|
case ExpendableLightState.Lit:
|
||||||
@@ -42,12 +55,26 @@ namespace Content.Client.Light.Visualizers
|
|||||||
expendableLight.LoopedSound,
|
expendableLight.LoopedSound,
|
||||||
expendableLight.Owner,
|
expendableLight.Owner,
|
||||||
SharedExpendableLightComponent.LoopedSoundParams);
|
SharedExpendableLightComponent.LoopedSoundParams);
|
||||||
|
if (!string.IsNullOrWhiteSpace(IconStateLit))
|
||||||
|
{
|
||||||
|
sprite.LayerSetState(2, IconStateLit);
|
||||||
|
sprite.LayerSetShader(2, "shaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
sprite.LayerSetVisible(1, true);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ExpendableLightState.Dead:
|
case ExpendableLightState.Dead:
|
||||||
expendableLight.PlayingStream?.Stop();
|
expendableLight.PlayingStream?.Stop();
|
||||||
|
if (!string.IsNullOrWhiteSpace(IconStateSpent))
|
||||||
|
{
|
||||||
|
sprite.LayerSetState(0, IconStateSpent);
|
||||||
|
sprite.LayerSetShader(0, "shaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
sprite.LayerSetVisible(1, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
|
|
||||||
_tagSystem.AddTag(component.Owner, "Trash");
|
_tagSystem.AddTag(component.Owner, "Trash");
|
||||||
|
|
||||||
UpdateSpriteAndSounds(component);
|
UpdateSounds(component);
|
||||||
UpdateVisualizer(component);
|
UpdateVisualizer(component);
|
||||||
|
|
||||||
if (TryComp<ItemComponent>(component.Owner, out var item))
|
if (TryComp<ItemComponent>(component.Owner, out var item))
|
||||||
@@ -93,7 +93,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
component.CurrentState = ExpendableLightState.Lit;
|
component.CurrentState = ExpendableLightState.Lit;
|
||||||
component.StateExpiryTime = component.GlowDuration;
|
component.StateExpiryTime = component.GlowDuration;
|
||||||
|
|
||||||
UpdateSpriteAndSounds(component);
|
UpdateSounds(component);
|
||||||
UpdateVisualizer(component);
|
UpdateVisualizer(component);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -124,43 +124,25 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateSpriteAndSounds(ExpendableLightComponent component)
|
private void UpdateSounds(ExpendableLightComponent component)
|
||||||
{
|
|
||||||
if (TryComp<SpriteComponent>(component.Owner, out var sprite))
|
|
||||||
{
|
{
|
||||||
|
var uid = component.Owner;
|
||||||
|
|
||||||
switch (component.CurrentState)
|
switch (component.CurrentState)
|
||||||
{
|
{
|
||||||
case ExpendableLightState.Lit:
|
case ExpendableLightState.Lit:
|
||||||
_audio.PlayPvs(component.LitSound, component.Owner);
|
_audio.PlayPvs(component.LitSound, uid);
|
||||||
if (component.IconStateLit != string.Empty)
|
|
||||||
{
|
|
||||||
sprite.LayerSetState(2, component.IconStateLit);
|
|
||||||
sprite.LayerSetShader(2, "shaded");
|
|
||||||
}
|
|
||||||
|
|
||||||
sprite.LayerSetVisible(1, true);
|
|
||||||
break;
|
break;
|
||||||
case ExpendableLightState.Fading:
|
case ExpendableLightState.Fading:
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
case ExpendableLightState.Dead:
|
_audio.PlayPvs(component.DieSound, uid);
|
||||||
_audio.PlayPvs(component.DieSound, component.Owner);
|
|
||||||
if (!string.IsNullOrEmpty(component.IconStateSpent))
|
|
||||||
{
|
|
||||||
sprite.LayerSetState(0, component.IconStateSpent);
|
|
||||||
sprite.LayerSetShader(0, "shaded");
|
|
||||||
}
|
|
||||||
|
|
||||||
sprite.LayerSetVisible(1, false);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (TryComp<ClothingComponent>(component.Owner, out var clothing))
|
if (TryComp<ClothingComponent>(uid, out var clothing))
|
||||||
{
|
{
|
||||||
_clothing.SetEquippedPrefix(component.Owner, component.Activated ? "Activated" : string.Empty, clothing);
|
_clothing.SetEquippedPrefix(uid, component.Activated ? "Activated" : string.Empty, clothing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,12 +46,6 @@ namespace Content.Shared.Light.Component
|
|||||||
[DataField("spentName")]
|
[DataField("spentName")]
|
||||||
public string SpentName { get; set; } = string.Empty;
|
public string SpentName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DataField("iconStateSpent")]
|
|
||||||
public string IconStateSpent { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[DataField("iconStateOn")]
|
|
||||||
public string IconStateLit { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[DataField("litSound")]
|
[DataField("litSound")]
|
||||||
public SoundSpecifier? LitSound { get; set; }
|
public SoundSpecifier? LitSound { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@
|
|||||||
spentDesc: expendable-light-spent-glowstick-desc
|
spentDesc: expendable-light-spent-glowstick-desc
|
||||||
glowDuration: 900 # time in seconds
|
glowDuration: 900 # time in seconds
|
||||||
fadeOutDuration: 300
|
fadeOutDuration: 300
|
||||||
iconStateOn: glowstick_lit
|
|
||||||
iconStateSpent: glowstick_unlit
|
|
||||||
turnOnBehaviourID: turn_on
|
turnOnBehaviourID: turn_on
|
||||||
fadeOutBehaviourID: fade_out
|
fadeOutBehaviourID: fade_out
|
||||||
litSound:
|
litSound:
|
||||||
@@ -33,6 +31,8 @@
|
|||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
- type: ExpendableLightVisualizer
|
- type: ExpendableLightVisualizer
|
||||||
|
iconStateOn: glowstick_lit
|
||||||
|
iconStateSpent: glowstick_unlit
|
||||||
- type: PointLight
|
- type: PointLight
|
||||||
enabled: false
|
enabled: false
|
||||||
color: "#00FF00"
|
color: "#00FF00"
|
||||||
@@ -70,17 +70,9 @@
|
|||||||
components:
|
components:
|
||||||
- type: ExpendableLight
|
- type: ExpendableLight
|
||||||
spentName: expendable-light-spent-red-glowstick-name
|
spentName: expendable-light-spent-red-glowstick-name
|
||||||
spentDesc: expendable-light-spent-glowstick-desc
|
glowDuration: 10 # time in seconds
|
||||||
glowDuration: 900
|
fadeOutDuration: 5
|
||||||
fadeOutDuration: 300
|
|
||||||
iconStateOn: glowstick_lit
|
|
||||||
iconStateSpent: glowstick_unlit
|
|
||||||
turnOnBehaviourID: turn_on
|
|
||||||
fadeOutBehaviourID: fade_out
|
|
||||||
litSound:
|
|
||||||
path: /Audio/Items/Handcuffs/rope_breakout.ogg
|
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
|
||||||
layers:
|
layers:
|
||||||
- state: glowstick_base
|
- state: glowstick_base
|
||||||
- state: glowstick_glow
|
- state: glowstick_glow
|
||||||
@@ -89,9 +81,6 @@
|
|||||||
shader: unshaded
|
shader: unshaded
|
||||||
- state: glowstick_unlit
|
- state: glowstick_unlit
|
||||||
color: "#FF0000"
|
color: "#FF0000"
|
||||||
- type: Item
|
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
|
||||||
heldPrefix: unlit
|
|
||||||
- type: PointLight
|
- type: PointLight
|
||||||
enabled: false
|
enabled: false
|
||||||
color: "#FF0000"
|
color: "#FF0000"
|
||||||
@@ -105,17 +94,7 @@
|
|||||||
components:
|
components:
|
||||||
- type: ExpendableLight
|
- type: ExpendableLight
|
||||||
spentName: expendable-light-spent-purple-glowstick-name
|
spentName: expendable-light-spent-purple-glowstick-name
|
||||||
spentDesc: expendable-light-spent-glowstick-desc
|
|
||||||
glowDuration: 900
|
|
||||||
fadeOutDuration: 300
|
|
||||||
iconStateOn: glowstick_lit
|
|
||||||
iconStateSpent: glowstick_unlit
|
|
||||||
turnOnBehaviourID: turn_on
|
|
||||||
fadeOutBehaviourID: fade_out
|
|
||||||
litSound:
|
|
||||||
path: /Audio/Items/Handcuffs/rope_breakout.ogg
|
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
|
||||||
layers:
|
layers:
|
||||||
- state: glowstick_base
|
- state: glowstick_base
|
||||||
- state: glowstick_glow
|
- state: glowstick_glow
|
||||||
@@ -124,9 +103,6 @@
|
|||||||
shader: unshaded
|
shader: unshaded
|
||||||
- state: glowstick_unlit
|
- state: glowstick_unlit
|
||||||
color: "#FF00FF"
|
color: "#FF00FF"
|
||||||
- type: Item
|
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
|
||||||
heldPrefix: unlit
|
|
||||||
- type: PointLight
|
- type: PointLight
|
||||||
enabled: false
|
enabled: false
|
||||||
color: "#FF00FF"
|
color: "#FF00FF"
|
||||||
@@ -140,15 +116,6 @@
|
|||||||
components:
|
components:
|
||||||
- type: ExpendableLight
|
- type: ExpendableLight
|
||||||
spentName: expendable-light-spent-yellow-glowstick-name
|
spentName: expendable-light-spent-yellow-glowstick-name
|
||||||
spentDesc: expendable-light-spent-glowstick-desc
|
|
||||||
glowDuration: 900
|
|
||||||
fadeOutDuration: 300
|
|
||||||
iconStateOn: glowstick_lit
|
|
||||||
iconStateSpent: glowstick_unlit
|
|
||||||
turnOnBehaviourID: turn_on
|
|
||||||
fadeOutBehaviourID: fade_out
|
|
||||||
litSound:
|
|
||||||
path: /Audio/Items/Handcuffs/rope_breakout.ogg
|
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
sprite: Objects/Misc/glowstick.rsi
|
||||||
layers:
|
layers:
|
||||||
@@ -159,9 +126,6 @@
|
|||||||
shader: unshaded
|
shader: unshaded
|
||||||
- state: glowstick_unlit
|
- state: glowstick_unlit
|
||||||
color: "#FFFF00"
|
color: "#FFFF00"
|
||||||
- type: Item
|
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
|
||||||
heldPrefix: unlit
|
|
||||||
- type: PointLight
|
- type: PointLight
|
||||||
enabled: false
|
enabled: false
|
||||||
color: "#FFFF00"
|
color: "#FFFF00"
|
||||||
@@ -175,15 +139,6 @@
|
|||||||
components:
|
components:
|
||||||
- type: ExpendableLight
|
- type: ExpendableLight
|
||||||
spentName: expendable-light-spent-blue-glowstick-name
|
spentName: expendable-light-spent-blue-glowstick-name
|
||||||
spentDesc: expendable-light-spent-glowstick-desc
|
|
||||||
glowDuration: 900
|
|
||||||
fadeOutDuration: 300
|
|
||||||
iconStateOn: glowstick_lit
|
|
||||||
iconStateSpent: glowstick_unlit
|
|
||||||
turnOnBehaviourID: turn_on
|
|
||||||
fadeOutBehaviourID: fade_out
|
|
||||||
litSound:
|
|
||||||
path: /Audio/Items/Handcuffs/rope_breakout.ogg
|
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
sprite: Objects/Misc/glowstick.rsi
|
||||||
layers:
|
layers:
|
||||||
@@ -194,8 +149,6 @@
|
|||||||
shader: unshaded
|
shader: unshaded
|
||||||
- state: glowstick_unlit
|
- state: glowstick_unlit
|
||||||
color: "#0000FF"
|
color: "#0000FF"
|
||||||
- type: Item
|
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
|
||||||
heldPrefix: unlit
|
heldPrefix: unlit
|
||||||
- type: PointLight
|
- type: PointLight
|
||||||
enabled: false
|
enabled: false
|
||||||
@@ -210,6 +163,7 @@
|
|||||||
name: light pulse test
|
name: light pulse test
|
||||||
parent: BaseItem
|
parent: BaseItem
|
||||||
id: LightBehaviourTest1
|
id: LightBehaviourTest1
|
||||||
|
noSpawn: true
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
sprite: Objects/Misc/glowstick.rsi
|
||||||
@@ -240,6 +194,7 @@
|
|||||||
name: color cycle test
|
name: color cycle test
|
||||||
parent: BaseItem
|
parent: BaseItem
|
||||||
id: LightBehaviourTest2
|
id: LightBehaviourTest2
|
||||||
|
noSpawn: true
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
sprite: Objects/Misc/glowstick.rsi
|
||||||
@@ -271,6 +226,7 @@
|
|||||||
name: multi-behaviour light test
|
name: multi-behaviour light test
|
||||||
parent: BaseItem
|
parent: BaseItem
|
||||||
id: LightBehaviourTest3
|
id: LightBehaviourTest3
|
||||||
|
noSpawn: true
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
sprite: Objects/Misc/glowstick.rsi
|
||||||
@@ -310,6 +266,7 @@
|
|||||||
name: light fade in test
|
name: light fade in test
|
||||||
parent: BaseItem
|
parent: BaseItem
|
||||||
id: LightBehaviourTest4
|
id: LightBehaviourTest4
|
||||||
|
noSpawn: true
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
sprite: Objects/Misc/glowstick.rsi
|
||||||
@@ -340,6 +297,7 @@
|
|||||||
name: light pulse radius test
|
name: light pulse radius test
|
||||||
parent: BaseItem
|
parent: BaseItem
|
||||||
id: LightBehaviourTest5
|
id: LightBehaviourTest5
|
||||||
|
noSpawn: true
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
sprite: Objects/Misc/glowstick.rsi
|
||||||
@@ -371,6 +329,7 @@
|
|||||||
name: light randomize radius test
|
name: light randomize radius test
|
||||||
parent: BaseItem
|
parent: BaseItem
|
||||||
id: LightBehaviourTest6
|
id: LightBehaviourTest6
|
||||||
|
noSpawn: true
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Misc/glowstick.rsi
|
sprite: Objects/Misc/glowstick.rsi
|
||||||
|
|||||||
Reference in New Issue
Block a user