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.Containers;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Threading;
|
||||
using Content.Server.Light.EntitySystems;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Light;
|
||||
using Content.Shared.Light.Component;
|
||||
using Content.Shared.MachineLinking;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Content.Server.Light.Components;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.Light;
|
||||
using Content.Shared.Light.Component;
|
||||
using Content.Shared.Throwing;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
@@ -2,7 +2,7 @@ using System.Linq;
|
||||
using Content.Server.Light.Components;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Light;
|
||||
using Content.Shared.Light.Component;
|
||||
using Content.Shared.Popups;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
@@ -14,6 +14,7 @@ using Content.Shared.Database;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Light;
|
||||
using Content.Shared.Light.Component;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Server.GameObjects;
|
||||
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
|
||||
netsync: false
|
||||
sprite: Objects/Power/light_bulb.rsi
|
||||
layers:
|
||||
- map: [ enum.LightBulbVisualLayers.Base ]
|
||||
state: normal
|
||||
- type: LightBulb
|
||||
- type: Damageable
|
||||
@@ -55,14 +57,22 @@
|
||||
- !type:DoActsBehavior
|
||||
acts: [ "Destruction" ]
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: LightBulbVisualizer
|
||||
- type: Tag
|
||||
tags:
|
||||
- Trash
|
||||
- type: Recyclable
|
||||
- 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
|
||||
# https://andi-siess.de/rgb-to-color-temperature/
|
||||
# https://academo.org/demos/colour-temperature-relationship/
|
||||
@@ -78,77 +88,58 @@
|
||||
lightEnergy: 1.0
|
||||
lightRadius: 6
|
||||
lightSoftness: 1.1
|
||||
- type: Sprite
|
||||
sprite: Objects/Power/light_bulb.rsi
|
||||
state: normal
|
||||
|
||||
- type: entity
|
||||
parent: BaseLightbulb
|
||||
parent: BaseLightTube
|
||||
name: fluorescent light tube
|
||||
id: LightTube
|
||||
description: A light fixture.
|
||||
components:
|
||||
- type: LightBulb
|
||||
bulb: Tube
|
||||
color: "#FFE4CE" # 5000K color temp
|
||||
lightEnergy: 0.8
|
||||
lightRadius: 10
|
||||
lightSoftness: 1
|
||||
PowerUse: 25
|
||||
- type: Sprite
|
||||
sprite: Objects/Power/light_tube.rsi
|
||||
state: normal
|
||||
|
||||
- type: entity
|
||||
parent: BaseLightbulb
|
||||
parent: BaseLightTube
|
||||
name: led light tube
|
||||
description: A high power high energy bulb.
|
||||
id: LedLightTube
|
||||
components:
|
||||
- type: LightBulb
|
||||
bulb: Tube
|
||||
color: "#EEEEFF"
|
||||
lightEnergy: 1
|
||||
lightRadius: 15
|
||||
lightSoftness: 0.9
|
||||
BurningTemperature: 350
|
||||
PowerUse: 12
|
||||
- type: Sprite
|
||||
sprite: Objects/Power/light_tube.rsi
|
||||
state: normal
|
||||
|
||||
- type: entity
|
||||
parent: BaseLightbulb
|
||||
parent: BaseLightTube
|
||||
name: exterior light tube
|
||||
description: A high power high energy bulb for the depths of space. May contain mercury.
|
||||
id: ExteriorLightTube
|
||||
components:
|
||||
- type: LightBulb
|
||||
bulb: Tube
|
||||
color: "#B4FCF0"
|
||||
lightEnergy: 4.5
|
||||
lightRadius: 12
|
||||
lightSoftness: 0.5
|
||||
BurningTemperature: 350
|
||||
PowerUse: 100
|
||||
- type: Sprite
|
||||
sprite: Objects/Power/light_tube.rsi
|
||||
state: normal
|
||||
|
||||
- type: entity
|
||||
parent: BaseLightbulb
|
||||
parent: BaseLightTube
|
||||
name: sodium light tube
|
||||
description: A high power high energy bulb for the depths of space. Salty.
|
||||
id: SodiumLightTube
|
||||
components:
|
||||
- type: LightBulb
|
||||
bulb: Tube
|
||||
color: "#FFAF38"
|
||||
lightEnergy: 4
|
||||
lightRadius: 10
|
||||
lightSoftness: 0.5
|
||||
BurningTemperature: 350
|
||||
PowerUse: 100
|
||||
- type: Sprite
|
||||
sprite: Objects/Power/light_tube.rsi
|
||||
state: normal
|
||||
|
||||
Reference in New Issue
Block a user