Resolves LightBulbVisualizer is Obsolete (#13889)
This commit is contained in:
36
Content.Client/Light/EntitySystems/LightBulbSystem.cs
Normal file
36
Content.Client/Light/EntitySystems/LightBulbSystem.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using Content.Shared.Light.Component;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Client.Light.Visualizers;
|
||||||
|
|
||||||
|
public sealed class LightBulbSystem : VisualizerSystem<LightBulbComponent>
|
||||||
|
{
|
||||||
|
protected override void OnAppearanceChange(EntityUid uid, LightBulbComponent comp, ref AppearanceChangeEvent args)
|
||||||
|
{
|
||||||
|
if (args.Sprite == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// update sprite state
|
||||||
|
if (AppearanceSystem.TryGetData<LightBulbState>(uid, LightBulbVisuals.State, out var state, args.Component))
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case LightBulbState.Normal:
|
||||||
|
args.Sprite.LayerSetState(LightBulbVisualLayers.Base, comp.NormalSpriteState);
|
||||||
|
break;
|
||||||
|
case LightBulbState.Broken:
|
||||||
|
args.Sprite.LayerSetState(LightBulbVisualLayers.Base, comp.BrokenSpriteState);
|
||||||
|
break;
|
||||||
|
case LightBulbState.Burned:
|
||||||
|
args.Sprite.LayerSetState(LightBulbVisualLayers.Base, comp.BurnedSpriteState);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// also update sprites color
|
||||||
|
if (AppearanceSystem.TryGetData<Color>(uid, LightBulbVisuals.Color, out var color, args.Component))
|
||||||
|
{
|
||||||
|
args.Sprite.Color = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
using Content.Shared.Light;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Robust.Client.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
|
|
||||||
namespace Content.Client.Light.Visualizers
|
|
||||||
{
|
|
||||||
[UsedImplicitly]
|
|
||||||
public sealed class LightBulbVisualizer : AppearanceVisualizer
|
|
||||||
{
|
|
||||||
[Obsolete("Subscribe to AppearanceChangeEvent instead.")]
|
|
||||||
public override void OnChangeData(AppearanceComponent component)
|
|
||||||
{
|
|
||||||
base.OnChangeData(component);
|
|
||||||
|
|
||||||
var entities = IoCManager.Resolve<IEntityManager>();
|
|
||||||
if (!entities.TryGetComponent(component.Owner, out SpriteComponent? sprite))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// update sprite state
|
|
||||||
if (component.TryGetData(LightBulbVisuals.State, out LightBulbState state))
|
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case LightBulbState.Normal:
|
|
||||||
sprite.LayerSetState(0, "normal");
|
|
||||||
break;
|
|
||||||
case LightBulbState.Broken:
|
|
||||||
sprite.LayerSetState(0, "broken");
|
|
||||||
break;
|
|
||||||
case LightBulbState.Burned:
|
|
||||||
sprite.LayerSetState(0, "burned");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// also update sprites color
|
|
||||||
if (component.TryGetData(LightBulbVisuals.Color, out Color color))
|
|
||||||
{
|
|
||||||
sprite.Color = color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
using Content.Server.Light.EntitySystems;
|
|
||||||
using Content.Shared.Light;
|
|
||||||
using Robust.Shared.Audio;
|
|
||||||
|
|
||||||
namespace Content.Server.Light.Components
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Component that represents a light bulb. Can be broken, or burned, which turns them mostly useless.
|
|
||||||
/// </summary>
|
|
||||||
[RegisterComponent, Access(typeof(LightBulbSystem))]
|
|
||||||
public sealed class LightBulbComponent : Component
|
|
||||||
{
|
|
||||||
[DataField("color")]
|
|
||||||
public Color Color = Color.White;
|
|
||||||
|
|
||||||
[DataField("bulb")]
|
|
||||||
public LightBulbType Type = LightBulbType.Tube;
|
|
||||||
|
|
||||||
[DataField("startingState")]
|
|
||||||
public LightBulbState State = LightBulbState.Normal;
|
|
||||||
|
|
||||||
[DataField("BurningTemperature")]
|
|
||||||
public int BurningTemperature = 1400;
|
|
||||||
|
|
||||||
[DataField("lightEnergy")]
|
|
||||||
public float LightEnergy = 0.8f;
|
|
||||||
|
|
||||||
[DataField("lightRadius")]
|
|
||||||
public float LightRadius = 10;
|
|
||||||
|
|
||||||
[DataField("lightSoftness")]
|
|
||||||
public float LightSoftness = 1;
|
|
||||||
|
|
||||||
[DataField("PowerUse")]
|
|
||||||
public int PowerUse = 60;
|
|
||||||
|
|
||||||
[DataField("breakSound")]
|
|
||||||
public SoundSpecifier BreakSound = new SoundCollectionSpecifier("GlassBreak");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using Content.Shared.Light;
|
using Content.Shared.Light.Component;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Content.Server.Light.EntitySystems;
|
using Content.Server.Light.EntitySystems;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.Light;
|
using Content.Shared.Light.Component;
|
||||||
using Content.Shared.MachineLinking;
|
using Content.Shared.MachineLinking;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Content.Server.Light.Components;
|
using Content.Server.Light.Components;
|
||||||
using Content.Shared.Destructible;
|
using Content.Shared.Destructible;
|
||||||
using Content.Shared.Light;
|
using Content.Shared.Light.Component;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using System.Linq;
|
|||||||
using Content.Server.Light.Components;
|
using Content.Server.Light.Components;
|
||||||
using Content.Server.Storage.Components;
|
using Content.Server.Storage.Components;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Light;
|
using Content.Shared.Light.Component;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using Content.Shared.Database;
|
|||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Light;
|
using Content.Shared.Light;
|
||||||
|
using Content.Shared.Light.Component;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
|
|||||||
129
Content.Shared/Light/Component/LightBulbComponent.cs
Normal file
129
Content.Shared/Light/Component/LightBulbComponent.cs
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
using Robust.Shared.Audio;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
|
namespace Content.Shared.Light.Component;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Component that represents a light bulb. Can be broken, or burned, which turns them mostly useless.
|
||||||
|
/// TODO: Breaking and burning should probably be moved to another component eventually.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent]
|
||||||
|
[NetworkedComponent]
|
||||||
|
public sealed class LightBulbComponent : Robust.Shared.GameObjects.Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The color of the lightbulb and the light it produces.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("color")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public Color Color = Color.White;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type of lightbulb. Tube/bulb/etc...
|
||||||
|
/// </summary>
|
||||||
|
[DataField("bulb")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public LightBulbType Type = LightBulbType.Tube;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The initial state of the lightbulb.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("startingState")]
|
||||||
|
public LightBulbState State = LightBulbState.Normal;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The temperature the air around the lightbulb is exposed to when the lightbulb burns out.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("BurningTemperature")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public int BurningTemperature = 1400;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Relates to how bright the light produced by the lightbulb is.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("lightEnergy")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public float LightEnergy = 0.8f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum radius of the point light source this light produces.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("lightRadius")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public float LightRadius = 10;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Relates to the falloff constant of the light produced by the lightbulb.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("lightSoftness")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public float LightSoftness = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The amount of power used by the lightbulb when it's active.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("PowerUse")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public int PowerUse = 60;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sound produced when the lightbulb breaks.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("breakSound")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public SoundSpecifier BreakSound = new SoundCollectionSpecifier("GlassBreak");
|
||||||
|
|
||||||
|
#region Appearance
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sprite state used when the lightbulb is intact.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("normalSpriteState")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public string NormalSpriteState = "normal";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sprite state used when the lightbulb is broken.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("brokenSpriteState")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public string BrokenSpriteState = "broken";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sprite state used when the lightbulb is burned.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("burnedSpriteState")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public string BurnedSpriteState = "burned";
|
||||||
|
|
||||||
|
#endregion Appearance
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum LightBulbState : byte
|
||||||
|
{
|
||||||
|
Normal,
|
||||||
|
Broken,
|
||||||
|
Burned,
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum LightBulbVisuals : byte
|
||||||
|
{
|
||||||
|
State,
|
||||||
|
Color
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum LightBulbType : byte
|
||||||
|
{
|
||||||
|
Bulb,
|
||||||
|
Tube,
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum LightBulbVisualLayers : byte
|
||||||
|
{
|
||||||
|
Base,
|
||||||
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
using Robust.Shared.Serialization;
|
|
||||||
|
|
||||||
namespace Content.Shared.Light
|
|
||||||
{
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public enum LightBulbState : byte
|
|
||||||
{
|
|
||||||
Normal,
|
|
||||||
Broken,
|
|
||||||
Burned,
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public enum LightBulbVisuals : byte
|
|
||||||
{
|
|
||||||
State,
|
|
||||||
Color
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public enum LightBulbType : byte
|
|
||||||
{
|
|
||||||
Bulb,
|
|
||||||
Tube,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,6 +11,8 @@
|
|||||||
- type: Sprite
|
- type: Sprite
|
||||||
netsync: false
|
netsync: false
|
||||||
sprite: Objects/Power/light_bulb.rsi
|
sprite: Objects/Power/light_bulb.rsi
|
||||||
|
layers:
|
||||||
|
- map: [ enum.LightBulbVisualLayers.Base ]
|
||||||
state: normal
|
state: normal
|
||||||
- type: LightBulb
|
- type: LightBulb
|
||||||
- type: Damageable
|
- type: Damageable
|
||||||
@@ -55,14 +57,22 @@
|
|||||||
- !type:DoActsBehavior
|
- !type:DoActsBehavior
|
||||||
acts: [ "Destruction" ]
|
acts: [ "Destruction" ]
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
|
||||||
- type: LightBulbVisualizer
|
|
||||||
- type: Tag
|
- type: Tag
|
||||||
tags:
|
tags:
|
||||||
- Trash
|
- Trash
|
||||||
- type: Recyclable
|
- type: Recyclable
|
||||||
- type: SpaceGarbage
|
- type: SpaceGarbage
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: BaseLightbulb
|
||||||
|
id: BaseLightTube
|
||||||
|
abstract: true
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Objects/Power/light_tube.rsi
|
||||||
|
- type: LightBulb
|
||||||
|
bulb: Tube
|
||||||
|
|
||||||
# Lighting color values gathered from
|
# Lighting color values gathered from
|
||||||
# https://andi-siess.de/rgb-to-color-temperature/
|
# https://andi-siess.de/rgb-to-color-temperature/
|
||||||
# https://academo.org/demos/colour-temperature-relationship/
|
# https://academo.org/demos/colour-temperature-relationship/
|
||||||
@@ -78,77 +88,58 @@
|
|||||||
lightEnergy: 1.0
|
lightEnergy: 1.0
|
||||||
lightRadius: 6
|
lightRadius: 6
|
||||||
lightSoftness: 1.1
|
lightSoftness: 1.1
|
||||||
- type: Sprite
|
|
||||||
sprite: Objects/Power/light_bulb.rsi
|
|
||||||
state: normal
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: BaseLightbulb
|
parent: BaseLightTube
|
||||||
name: fluorescent light tube
|
name: fluorescent light tube
|
||||||
id: LightTube
|
id: LightTube
|
||||||
description: A light fixture.
|
description: A light fixture.
|
||||||
components:
|
components:
|
||||||
- type: LightBulb
|
- type: LightBulb
|
||||||
bulb: Tube
|
|
||||||
color: "#FFE4CE" # 5000K color temp
|
color: "#FFE4CE" # 5000K color temp
|
||||||
lightEnergy: 0.8
|
lightEnergy: 0.8
|
||||||
lightRadius: 10
|
lightRadius: 10
|
||||||
lightSoftness: 1
|
lightSoftness: 1
|
||||||
PowerUse: 25
|
PowerUse: 25
|
||||||
- type: Sprite
|
|
||||||
sprite: Objects/Power/light_tube.rsi
|
|
||||||
state: normal
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: BaseLightbulb
|
parent: BaseLightTube
|
||||||
name: led light tube
|
name: led light tube
|
||||||
description: A high power high energy bulb.
|
description: A high power high energy bulb.
|
||||||
id: LedLightTube
|
id: LedLightTube
|
||||||
components:
|
components:
|
||||||
- type: LightBulb
|
- type: LightBulb
|
||||||
bulb: Tube
|
|
||||||
color: "#EEEEFF"
|
color: "#EEEEFF"
|
||||||
lightEnergy: 1
|
lightEnergy: 1
|
||||||
lightRadius: 15
|
lightRadius: 15
|
||||||
lightSoftness: 0.9
|
lightSoftness: 0.9
|
||||||
BurningTemperature: 350
|
BurningTemperature: 350
|
||||||
PowerUse: 12
|
PowerUse: 12
|
||||||
- type: Sprite
|
|
||||||
sprite: Objects/Power/light_tube.rsi
|
|
||||||
state: normal
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: BaseLightbulb
|
parent: BaseLightTube
|
||||||
name: exterior light tube
|
name: exterior light tube
|
||||||
description: A high power high energy bulb for the depths of space. May contain mercury.
|
description: A high power high energy bulb for the depths of space. May contain mercury.
|
||||||
id: ExteriorLightTube
|
id: ExteriorLightTube
|
||||||
components:
|
components:
|
||||||
- type: LightBulb
|
- type: LightBulb
|
||||||
bulb: Tube
|
|
||||||
color: "#B4FCF0"
|
color: "#B4FCF0"
|
||||||
lightEnergy: 4.5
|
lightEnergy: 4.5
|
||||||
lightRadius: 12
|
lightRadius: 12
|
||||||
lightSoftness: 0.5
|
lightSoftness: 0.5
|
||||||
BurningTemperature: 350
|
BurningTemperature: 350
|
||||||
PowerUse: 100
|
PowerUse: 100
|
||||||
- type: Sprite
|
|
||||||
sprite: Objects/Power/light_tube.rsi
|
|
||||||
state: normal
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: BaseLightbulb
|
parent: BaseLightTube
|
||||||
name: sodium light tube
|
name: sodium light tube
|
||||||
description: A high power high energy bulb for the depths of space. Salty.
|
description: A high power high energy bulb for the depths of space. Salty.
|
||||||
id: SodiumLightTube
|
id: SodiumLightTube
|
||||||
components:
|
components:
|
||||||
- type: LightBulb
|
- type: LightBulb
|
||||||
bulb: Tube
|
|
||||||
color: "#FFAF38"
|
color: "#FFAF38"
|
||||||
lightEnergy: 4
|
lightEnergy: 4
|
||||||
lightRadius: 10
|
lightRadius: 10
|
||||||
lightSoftness: 0.5
|
lightSoftness: 0.5
|
||||||
BurningTemperature: 350
|
BurningTemperature: 350
|
||||||
PowerUse: 100
|
PowerUse: 100
|
||||||
- type: Sprite
|
|
||||||
sprite: Objects/Power/light_tube.rsi
|
|
||||||
state: normal
|
|
||||||
|
|||||||
Reference in New Issue
Block a user