Light bulb brightness (and other settings) change clientside PointLights (#5869)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -29,6 +29,15 @@ namespace Content.Server.Light.Components
|
|||||||
[DataField("BurningTemperature")]
|
[DataField("BurningTemperature")]
|
||||||
public int BurningTemperature = 1400;
|
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")]
|
[DataField("PowerUse")]
|
||||||
public int PowerUse = 40;
|
public int PowerUse = 40;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ using Robust.Shared.Analyzers;
|
|||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Server.Light.Components
|
namespace Content.Server.Light.Components
|
||||||
@@ -25,8 +27,8 @@ namespace Content.Server.Light.Components
|
|||||||
[DataField("turnOnSound")]
|
[DataField("turnOnSound")]
|
||||||
public SoundSpecifier TurnOnSound = new SoundPathSpecifier("/Audio/Machines/light_tube_on.ogg");
|
public SoundSpecifier TurnOnSound = new SoundPathSpecifier("/Audio/Machines/light_tube_on.ogg");
|
||||||
|
|
||||||
[DataField("hasLampOnSpawn")]
|
[DataField("hasLampOnSpawn", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||||
public bool HasLampOnSpawn = true;
|
public string? HasLampOnSpawn = null;
|
||||||
|
|
||||||
[DataField("bulb")]
|
[DataField("bulb")]
|
||||||
public LightBulbType BulbType;
|
public LightBulbType BulbType;
|
||||||
|
|||||||
@@ -64,19 +64,11 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
|
|
||||||
private void OnMapInit(EntityUid uid, PoweredLightComponent light, MapInitEvent args)
|
private void OnMapInit(EntityUid uid, PoweredLightComponent light, MapInitEvent args)
|
||||||
{
|
{
|
||||||
if (light.HasLampOnSpawn)
|
if (light.HasLampOnSpawn != null)
|
||||||
{
|
{
|
||||||
var prototype = light.BulbType switch
|
var entity = EntityManager.SpawnEntity(light.HasLampOnSpawn, EntityManager.GetComponent<TransformComponent>(light.Owner).Coordinates);
|
||||||
{
|
|
||||||
LightBulbType.Bulb => "LightBulb",
|
|
||||||
LightBulbType.Tube => "LightTube",
|
|
||||||
_ => throw new ArgumentOutOfRangeException()
|
|
||||||
};
|
|
||||||
|
|
||||||
var entity = EntityManager.SpawnEntity(prototype, EntityManager.GetComponent<TransformComponent>(light.Owner).Coordinates);
|
|
||||||
light.LightBulbContainer.Insert(entity);
|
light.LightBulbContainer.Insert(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// need this to update visualizers
|
// need this to update visualizers
|
||||||
UpdateLight(uid, light);
|
UpdateLight(uid, light);
|
||||||
}
|
}
|
||||||
@@ -158,7 +150,6 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
UpdateLight(uid, light);
|
UpdateLight(uid, light);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +251,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
case LightBulbState.Normal:
|
case LightBulbState.Normal:
|
||||||
if (powerReceiver.Powered && light.On)
|
if (powerReceiver.Powered && light.On)
|
||||||
{
|
{
|
||||||
SetLight(uid, true, lightBulb.Color, light);
|
SetLight(uid, true, lightBulb.Color, light, lightBulb.lightRadius, lightBulb.lightEnergy, lightBulb.lightSoftness);
|
||||||
appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.On);
|
appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.On);
|
||||||
var time = _gameTiming.CurTime;
|
var time = _gameTiming.CurTime;
|
||||||
if (time > light.LastThunk + ThunkDelay)
|
if (time > light.LastThunk + ThunkDelay)
|
||||||
@@ -363,7 +354,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
SetState(uid, enabled, component);
|
SetState(uid, enabled, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetLight(EntityUid uid, bool value, Color? color = null, PoweredLightComponent? light = null)
|
private void SetLight(EntityUid uid, bool value, Color? color = null, PoweredLightComponent? light = null, float? radius = null, float? energy = null, float? softness=null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref light))
|
if (!Resolve(uid, ref light))
|
||||||
return;
|
return;
|
||||||
@@ -377,6 +368,12 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
|
|
||||||
if (color != null)
|
if (color != null)
|
||||||
pointLight.Color = color.Value;
|
pointLight.Color = color.Value;
|
||||||
|
if (radius != null)
|
||||||
|
pointLight.Radius = (float) radius;
|
||||||
|
if (energy != null)
|
||||||
|
pointLight.Energy = (float) energy;
|
||||||
|
if (softness != null)
|
||||||
|
pointLight.Softness = (float) softness;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,9 @@
|
|||||||
- type: LightBulb
|
- type: LightBulb
|
||||||
bulb: Bulb
|
bulb: Bulb
|
||||||
color: "#FFD1A3" # 4000K color temp
|
color: "#FFD1A3" # 4000K color temp
|
||||||
|
lightEnergy: 1.0
|
||||||
|
lightRadius: 6
|
||||||
|
lightSoftness: 1.1
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Power/light_bulb.rsi
|
sprite: Objects/Power/light_bulb.rsi
|
||||||
state: normal
|
state: normal
|
||||||
@@ -73,6 +76,9 @@
|
|||||||
- type: LightBulb
|
- type: LightBulb
|
||||||
bulb: Tube
|
bulb: Tube
|
||||||
color: "#FFE4CE" # 5000K color temp
|
color: "#FFE4CE" # 5000K color temp
|
||||||
|
lightEnergy: 0.8
|
||||||
|
lightRadius: 10
|
||||||
|
lightSoftness: 1
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Power/light_tube.rsi
|
sprite: Objects/Power/light_tube.rsi
|
||||||
state: normal
|
state: normal
|
||||||
@@ -85,6 +91,9 @@
|
|||||||
- type: LightBulb
|
- type: LightBulb
|
||||||
bulb: Tube
|
bulb: Tube
|
||||||
color: "#EEEEFF"
|
color: "#EEEEFF"
|
||||||
|
lightEnergy: 4
|
||||||
|
lightRadius: 10
|
||||||
|
lightSoftness: 0.9
|
||||||
BurningTemperature: 350
|
BurningTemperature: 350
|
||||||
PowerUse: 9
|
PowerUse: 9
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
|
|||||||
@@ -61,14 +61,14 @@
|
|||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: light
|
name: light
|
||||||
description: "A powered wall light emitting... light."
|
description: "A light fixture. Draws power and produces light when equipped with a light tube."
|
||||||
id: Poweredlight
|
id: PoweredlightEmpty
|
||||||
suffix: Powered
|
suffix: Empty, Powered
|
||||||
parent: WallLight
|
parent: WallLight
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Structures/Wallmounts/Lighting/light_tube.rsi
|
sprite: Structures/Wallmounts/Lighting/light_tube.rsi
|
||||||
state: off
|
state: empty
|
||||||
- type: PointLight
|
- type: PointLight
|
||||||
enabled: false
|
enabled: false
|
||||||
- type: PoweredLight
|
- type: PoweredLight
|
||||||
@@ -88,15 +88,27 @@
|
|||||||
path: "/Audio/Machines/light_tube_on.ogg"
|
path: "/Audio/Machines/light_tube_on.ogg"
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: PoweredlightEmpty
|
id: Poweredlight
|
||||||
description: "A wall light. It's empty."
|
description: "A light fixture. Draws power and produces light when equipped with a light tube."
|
||||||
suffix: Empty, Powered
|
suffix: Powered
|
||||||
parent: Poweredlight
|
parent: PoweredlightEmpty
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
state: empty
|
state: off
|
||||||
- type: PoweredLight
|
- type: PoweredLight
|
||||||
hasLampOnSpawn: False
|
hasLampOnSpawn: LightTube
|
||||||
|
damage:
|
||||||
|
types:
|
||||||
|
Heat: 20
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
id: PoweredlightLED
|
||||||
|
description: "A light fixture. Draws power and produces light when equipped with a light tube."
|
||||||
|
suffix: LED tube, Powered
|
||||||
|
parent: Poweredlight
|
||||||
|
components:
|
||||||
|
- type: PoweredLight
|
||||||
|
hasLampOnSpawn: LedLightTube
|
||||||
damage:
|
damage:
|
||||||
types:
|
types:
|
||||||
Heat: 20
|
Heat: 20
|
||||||
@@ -143,14 +155,14 @@
|
|||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: small light
|
name: small light
|
||||||
description: "A powered wall light emitting... light."
|
description: "A light fixture. Draws power and produces light when equipped with a light bulb."
|
||||||
id: PoweredSmallLight
|
id: PoweredSmallLightEmpty
|
||||||
suffix: Powered
|
suffix: Empty, Powered
|
||||||
parent: SmallLight
|
parent: SmallLight
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Structures/Wallmounts/Lighting/light_small.rsi
|
sprite: Structures/Wallmounts/Lighting/light_small.rsi
|
||||||
state: off
|
state: empty
|
||||||
- type: PointLight
|
- type: PointLight
|
||||||
enabled: false
|
enabled: false
|
||||||
offset: "0, -0.5"
|
offset: "0, -0.5"
|
||||||
@@ -176,14 +188,14 @@
|
|||||||
- type: PoweredLightVisualizer
|
- type: PoweredLightVisualizer
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: PoweredSmallLightEmpty
|
id: PoweredSmallLight
|
||||||
suffix: Empty, Powered
|
suffix: Powered
|
||||||
parent: PoweredSmallLight
|
parent: PoweredSmallLightEmpty
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
state: empty
|
state: off
|
||||||
- type: PoweredLight
|
- type: PoweredLight
|
||||||
hasLampOnSpawn: False
|
hasLampOnSpawn: LightBulb
|
||||||
damage:
|
damage:
|
||||||
types:
|
types:
|
||||||
Heat: 20
|
Heat: 20
|
||||||
|
|||||||
Reference in New Issue
Block a user