[Fix] Fixed laser's regulator lamp's visualizer (#530)

* Reapply "[Fix] Regulator Lamp Visuals" (#523)

This reverts commit 5337022158.

* Reapply "[Fix] Regular Lamp Layers" (#522)"

This reverts commit 2ebf5e18

* fix: fixed lamp layers

* style: styled overheat systems

* fix: fixed advanced regulator lamp layers
This commit is contained in:
Remuchi
2025-05-28 19:38:18 +07:00
committed by GitHub
parent 7d72b86d19
commit 2bbaaafd67
5 changed files with 207 additions and 202 deletions

View File

@@ -102,7 +102,7 @@ public sealed partial class GunSystem
MinHeight = 15;
HorizontalExpand = true;
VerticalAlignment = VAlignment.Center;
AddChild(_bulletRender = new BulletRender
AddChild(_bulletRender = new()
{
HorizontalAlignment = HAlignment.Right,
VerticalAlignment = VAlignment.Bottom
@@ -135,12 +135,12 @@ public sealed partial class GunSystem
Orientation = BoxContainer.LayoutOrientation.Horizontal,
Children =
{
(_bullets = new BatteryBulletRenderer
(_bullets = new()
{
Margin = new Thickness(0, 0, 5, 0),
Margin = new(0, 0, 5, 0),
HorizontalExpand = true
}),
(_ammoCount = new Label
(_ammoCount = new()
{
StyleClasses = { StyleNano.StyleClassItemStatus },
HorizontalAlignment = HAlignment.Right,
@@ -183,15 +183,15 @@ public sealed partial class GunSystem
new Control
{
HorizontalExpand = true,
Margin = new Thickness(0, 0, 5, 0),
Margin = new(0, 0, 5, 0),
Children =
{
(_bulletRender = new BulletRender
(_bulletRender = new()
{
HorizontalAlignment = HAlignment.Right,
VerticalAlignment = VAlignment.Bottom
}),
(_noMagazineLabel = new Label
(_noMagazineLabel = new()
{
Text = "No Magazine!",
StyleClasses = {StyleNano.StyleClassItemStatus}
@@ -202,15 +202,15 @@ public sealed partial class GunSystem
{
Orientation = BoxContainer.LayoutOrientation.Vertical,
VerticalAlignment = VAlignment.Bottom,
Margin = new Thickness(0, 0, 0, 2),
Margin = new(0, 0, 0, 2),
Children =
{
(_ammoCount = new Label
(_ammoCount = new()
{
StyleClasses = {StyleNano.StyleClassItemStatus},
HorizontalAlignment = HAlignment.Right,
}),
(_chamberedBullet = new TextureRect
(_chamberedBullet = new()
{
Texture = StaticIoC.ResC.GetTexture("/Textures/Interface/ItemStatus/Bullets/chambered.png"),
HorizontalAlignment = HAlignment.Left,
@@ -261,13 +261,13 @@ public sealed partial class GunSystem
MinHeight = 15;
HorizontalExpand = true;
VerticalAlignment = Control.VAlignment.Center;
AddChild((_bulletsList = new BoxContainer
AddChild(_bulletsList = new()
{
Orientation = BoxContainer.LayoutOrientation.Horizontal,
HorizontalExpand = true,
VerticalAlignment = VAlignment.Center,
SeparationOverride = 0
}));
});
}
public void Update(int currentIndex, bool?[] bullets)
@@ -321,7 +321,7 @@ public sealed partial class GunSystem
box.AddChild(new TextureRect
{
Texture = texture,
TextureScale = new Vector2(scale, scale),
TextureScale = new(scale, scale),
ModulateSelfOverride = Color.LimeGreen,
});
}
@@ -369,23 +369,22 @@ public sealed partial class GunSystem
private readonly BatteryAmmoProviderComponent _ammoProvider;
private readonly GunOverheatComponent? _regulator;
private readonly GunOverheatSystem _regSys;
private readonly IEntityManager _entMan;
private int _ammoCount = 0;
private int _ammoCount;
private bool _heatLimitEnabled = true;
private float _heatLimit = 0;
private float _heat = 0; // caching temperature and ammo counts so that the labels don't end up having their measures invalidated every frame
private float _heatLimit;
private float _heat; // caching temperature and ammo counts so that the labels don't end up having their measures invalidated every frame
// not sure if this makes any difference performance-wise, but it just seems like a good idea
public EnergyGunBatteryStatusControl(BatteryAmmoProviderComponent comp)
public EnergyGunBatteryStatusControl(EntityUid uid, BatteryAmmoProviderComponent comp)
{
_entMan = IoCManager.Resolve<IEntityManager>();
_regSys = _entMan.System<GunOverheatSystem>();
_gun = comp.Owner;
var entMan = IoCManager.Resolve<IEntityManager>();
_regSys = entMan.System<GunOverheatSystem>();
_gun = uid;
_ammoProvider = comp;
_ammoCount = comp.Shots;
MinHeight = 15;
HorizontalExpand = true;
VerticalAlignment = Control.VAlignment.Center;
VerticalAlignment = VAlignment.Center;
AddChild(new BoxContainer // outer box
{
Orientation = BoxContainer.LayoutOrientation.Vertical,
@@ -396,14 +395,14 @@ public sealed partial class GunSystem
Orientation = BoxContainer.LayoutOrientation.Horizontal,
Children =
{
(_lampLabel = new Label
(_lampLabel = new()
{
StyleClasses = { StyleNano.StyleClassItemStatus },
HorizontalAlignment = HAlignment.Left,
VerticalAlignment = VAlignment.Bottom,
Text = $" "
Text = " \u25cf"
}),
(_heatLabel = new Label
(_heatLabel = new()
{
StyleClasses = { StyleNano.StyleClassItemStatus },
HorizontalAlignment = HAlignment.Right,
@@ -418,12 +417,12 @@ public sealed partial class GunSystem
Orientation = BoxContainer.LayoutOrientation.Horizontal,
Children =
{
(_ammoBar = new BarControl
(_ammoBar = new()
{
Rows = 4,
MaxWidth = 75
}),
(_ammoLabel = new Label
(_ammoLabel = new()
{
StyleClasses = { StyleNano.StyleClassItemStatus },
HorizontalExpand = true,
@@ -438,7 +437,7 @@ public sealed partial class GunSystem
// if temp regulator component is missing on the gun, hide the temperature gauge and lamp display
// since they won't matter anyways
if (!_entMan.TryGetComponent(_gun, out _regulator))
if (!entMan.TryGetComponent(_gun, out _regulator))
{
_heatLabel.Visible = false;
_lampLabel.Visible = false;
@@ -450,22 +449,21 @@ public sealed partial class GunSystem
// still using kelvin because having temperature go from 0 to +inf is much nicer than from -273.15 to +inf
private void UpdateTemp(float K)
{
float celcius = K - 273.15f;
var celcius = K - 273.15f;
// we assume _regulator is not null since we'll check for it before calling this method
float maxTemp = _regulator!.MaxDisplayTemperatureCelcius;
string currentTemp = celcius > maxTemp ? $"{maxTemp:0}+°C" : $"{celcius:0} °C";
if (_regulator.SafetyEnabled)
_heatLabel.Text = $"{currentTemp}/{_regulator.TemperatureLimit - 273.15f:0} °C "; // MathF.Min to conserve a single digit for space in an otherwise overly cramped piece of UI.
else
_heatLabel.Text = currentTemp;
var maxTemp = _regulator!.MaxDisplayTemperatureCelcius;
var currentTemp = celcius > maxTemp ? $"{maxTemp:0}+°C" : $"{celcius:0} °C";
_heatLabel.Text = _regulator.SafetyEnabled
? $"{currentTemp}/{_regulator.TemperatureLimit - 273.15f:0} °C "
: currentTemp;
float hue = 0; // full red
const float hueoffset = 0.07f; // raises the 0K color from dark blue to a brighter tone
if (K < _regulator.TemperatureLimit)
hue = 0.66f - ((K) / (_regulator.TemperatureLimit) * 0.55f * (1f - hueoffset) + hueoffset);
hue = 0.66f - (K / _regulator.TemperatureLimit * 0.55f * (1f - hueoffset) + hueoffset);
var tempColor = Color.FromHsv(new Robust.Shared.Maths.Vector4(hue, 1, 1, 1));
var tempColor = Color.FromHsv(new(hue, 1, 1, 1));
_heatLabel.FontColorOverride = tempColor;
_lampLabel.FontColorOverride = tempColor;
}
@@ -486,10 +484,8 @@ public sealed partial class GunSystem
if (_regulator is null)
return;
if (_regSys.GetLamp(_gun, out var lampComp, _regulator))
{
_lampLabel.Text = lampComp is null || !lampComp.Intact ? " ◌" : " ●";
}
if (_regSys.GetLamp((_gun,_regulator), out var lamp))
_lampLabel.Text = !lamp.Value.Comp.Intact ? " ◌" : " ●";
if (_heat != _regulator.CurrentTemperature || _heatLimit != _regulator.TemperatureLimit || _heatLimitEnabled != _regulator.SafetyEnabled)
{

View File

@@ -27,6 +27,6 @@ public sealed partial class GunSystem
private void OnControl(EntityUid uid, BatteryAmmoProviderComponent component, AmmoCounterControlEvent args)
{
args.Control = new EnergyGunBatteryStatusControl(component); // WWDP EDIT
args.Control = new EnergyGunBatteryStatusControl(uid, component); // WWDP EDIT
}
}

View File

@@ -25,37 +25,36 @@ public sealed class GunOverheatSystem : SharedGunOverheatSystem
private void OnLampInit(EntityUid uid, RegulatorLampComponent comp, ComponentInit args)
{
if (comp.SafeTemperature > comp.UnsafeTemperature)
{
Log.Warning($"Entity {ToPrettyString(uid)} has SafeTemperature bigger than UnsafeTemperature. (s={comp.SafeTemperature}, u={comp.UnsafeTemperature}) Resolving by swapping them around.");
Log.Warning(
$"Entity {ToPrettyString(uid)} has SafeTemperature bigger than UnsafeTemperature. (s={comp.SafeTemperature}, u={comp.UnsafeTemperature}) Resolving by swapping them around.");
(comp.SafeTemperature, comp.UnsafeTemperature) = (comp.UnsafeTemperature, comp.SafeTemperature);
Dirty(uid, comp);
}
if (comp.SafeTemperature == comp.UnsafeTemperature)
{
Log.Error($"Entity {ToPrettyString(uid)} has equal SafeTemperature and UnsafeTemperature. (s={comp.SafeTemperature}, u={comp.UnsafeTemperature}) Resolving by increasing UnsafeTemperature by 0.01f.");
comp.UnsafeTemperature += 0.01f;
Dirty(uid, comp);
}
}
protected override void OnGunShot(EntityUid uid, GunOverheatComponent comp, ref GunShotEvent args)
{
CheckForBurnout(uid, comp, args.User);
_temp.ForceChangeTemperature(uid, comp.CurrentTemperature + comp.HeatCost);
}
private void CheckForBurnout(EntityUid uid, GunOverheatComponent comp, EntityUid shooter)
{
if (!GetLamp(uid, out var lampComp, comp) || lampComp is null)
if (comp.SafeTemperature != comp.UnsafeTemperature)
return;
float breakChance = GetLampBreakChance(comp.CurrentTemperature, lampComp, comp.LampBreakChanceMultiplier);
if (_rng.Prob(breakChance))
{
BurnoutLamp(lampComp, shooter);
}
Log.Error(
$"Entity {ToPrettyString(uid)} has equal SafeTemperature and UnsafeTemperature. (s={comp.SafeTemperature}, u={comp.UnsafeTemperature}) Resolving by increasing UnsafeTemperature by 0.01f.");
comp.UnsafeTemperature += 0.01f;
Dirty(uid, comp);
}
protected override void OnGunShot(Entity<GunOverheatComponent> gun, ref GunShotEvent args)
{
CheckForBurnout(gun, args.User);
_temp.ForceChangeTemperature(gun, gun.Comp.CurrentTemperature + gun.Comp.HeatCost);
}
private void CheckForBurnout(Entity<GunOverheatComponent> gun, EntityUid shooter)
{
if (!GetLamp(gun, out var lamp))
return;
var breakChance = GetLampBreakChance(gun.Comp.CurrentTemperature, lamp, gun.Comp.LampBreakChanceMultiplier);
if (Rng.Prob(breakChance))
BurnoutLamp(lamp.Value, shooter);
}
}

View File

@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Destructible;
using Content.Shared.Examine;
@@ -17,177 +18,186 @@ namespace Content.Shared._White.Guns;
/// </summary>
public abstract class SharedGunOverheatSystem : EntitySystem
{
[Dependency] protected readonly ItemSlotsSystem _slots = default!;
[Dependency] protected readonly IRobustRandom _rng = default!;
[Dependency] protected readonly SharedAudioSystem _audio = default!;
[Dependency] protected readonly SharedAppearanceSystem _appearance = default!;
[Dependency] protected readonly IGameTiming _timing = default!;
[Dependency] protected readonly ItemSlotsSystem Slots = default!;
[Dependency] protected readonly IRobustRandom Rng = default!;
[Dependency] protected readonly SharedAudioSystem Audio = default!;
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
[Dependency] protected readonly IGameTiming Timing = default!;
public override void Initialize()
{
SubscribeLocalEvent<GunOverheatComponent, AttemptShootEvent>(OnAttemptShoot);
SubscribeLocalEvent<GunOverheatComponent, GunShotEvent>(OnGunShot);
SubscribeLocalEvent<RegulatorLampComponent, BreakageEventArgs>(OnBreak);
SubscribeLocalEvent<RegulatorLampComponent, ExaminedEvent>(OnLampExamined);
SubscribeLocalEvent<GunOverheatComponent, ExaminedEvent>(OnGunExamined);
SubscribeLocalEvent<GunOverheatComponent, GetVerbsEvent<AlternativeVerb>>(OnAltVerbs);
SubscribeLocalEvent<RegulatorLampComponent, BreakageEventArgs>(OnBreak);
SubscribeLocalEvent<RegulatorLampComponent, ExaminedEvent>(OnLampExamined);
}
private void OnLampExamined(EntityUid uid, RegulatorLampComponent comp, ExaminedEvent args)
{
args.PushMarkup(Loc.GetString("gun-regulator-lamp-examine-intact", ("intact", comp.Intact)));
if (!args.IsInDetailsRange)
return;
args.PushMarkup(Loc.GetString("gun-regulator-lamp-examine-temperature-range", ("safetemp", MathF.Round(comp.SafeTemperature - 273.15f)), ("unsafetemp", MathF.Round(comp.UnsafeTemperature - 273.15f))));
}
private void OnGunExamined(EntityUid uid, GunOverheatComponent comp, ExaminedEvent args)
{
if (!args.IsInDetailsRange)
return;
args.PushMarkup(Loc.GetString($"gun-regulator-examine-safety{(comp.CanChangeSafety ? "-toggleable" : "")}", ("enabled", comp.SafetyEnabled), ("limit", MathF.Round(comp.TemperatureLimit - 273.15f))));
if (comp.RequiresLamp)
{
int lampStatus = 0; // missing
if (GetLamp(uid, out var lamp, comp) && lamp is not null)
lampStatus = lamp.Intact ? 2 : 1; // present : broken
args.PushMarkup(Loc.GetString($"gun-regulator-examine-lamp", ("lampstatus", lampStatus)));
}
}
private void OnBreak(EntityUid uid, RegulatorLampComponent comp, BreakageEventArgs args)
{
/*_appearance.SetData(uid, RegulatorLampVisuals.Glass, RegulatorLampState.Broken);*/
comp.Intact = false;
Dirty(uid, comp);
}
private void OnAttemptShoot(EntityUid uid, GunOverheatComponent comp, ref AttemptShootEvent args)
private void OnAttemptShoot(Entity<GunOverheatComponent> gun, ref AttemptShootEvent args)
{
if (args.Cancelled)
return;
if (comp.CurrentTemperature >= comp.TemperatureLimit && comp.SafetyEnabled)
if (gun.Comp.CurrentTemperature >= gun.Comp.TemperatureLimit && gun.Comp.SafetyEnabled)
{
args.Cancelled = true;
args.Message = Loc.GetString("gun-regulator-temperature-limit-exceeded-popup");
return;
}
if (!comp.RequiresLamp)
if (!gun.Comp.RequiresLamp)
return;
if (GetLamp(uid, out var lampComp, comp) && lampComp is not null)
if (!GetLamp(gun, out var lamp))
{
if (lampComp.Intact)
return;
args.Cancelled = true;
args.Message = Loc.GetString($"gun-regulator-lamp-broken-popup");
args.Message = Loc.GetString("gun-regulator-lamp-missing-popup");
return;
}
args.Cancelled = true;
args.Message = Loc.GetString($"gun-regulator-lamp-missing-popup");
return;
if (!lamp.Value.Comp.Intact)
{
args.Cancelled = true;
args.Message = Loc.GetString("gun-regulator-lamp-broken-popup");
}
}
protected virtual void OnGunShot(EntityUid uid, GunOverheatComponent comp, ref GunShotEvent args)
protected virtual void OnGunShot(Entity<GunOverheatComponent> gun, ref GunShotEvent args)
{
if (_timing.IsFirstTimePredicted)
comp.CurrentTemperature += comp.HeatCost;
if (Timing.IsFirstTimePredicted)
gun.Comp.CurrentTemperature += gun.Comp.HeatCost;
}
private void OnGunExamined(Entity<GunOverheatComponent> gun, ref ExaminedEvent args)
{
if (!args.IsInDetailsRange)
return;
args.PushMarkup(
Loc.GetString(
$"gun-regulator-examine-safety{(gun.Comp.CanChangeSafety ? "-toggleable" : "")}",
("enabled", gun.Comp.SafetyEnabled), ("limit", MathF.Round(gun.Comp.TemperatureLimit - 273.15f))));
if (!gun.Comp.RequiresLamp)
return;
var lampStatus = 0; // missing
if (GetLamp(gun, out var lamp))
lampStatus = lamp.Value.Comp.Intact ? 2 : 1; // present : broken
args.PushMarkup(Loc.GetString("gun-regulator-examine-lamp", ("lampstatus", lampStatus)));
}
private void OnAltVerbs(Entity<GunOverheatComponent> gun, ref GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanInteract || !args.CanComplexInteract || !args.CanAccess || !gun.Comp.CanChangeSafety)
return;
var player = args.User;
AddVerb(-1, "fireselector-100up-verb", ref args, () => AdjustSafety(gun.Comp, 100, player));
AddVerb(-2, "fireselector-10up-verb", ref args, () => AdjustSafety(gun.Comp, 10, player));
AddVerb(-3, "fireselector-toggle-verb", ref args, () => ToggleSafety(gun.Comp, player));
AddVerb(-4, "fireselector-10down-verb", ref args, () => AdjustSafety(gun.Comp, -10, player));
AddVerb(-5, "fireselector-100down-verb", ref args, () => AdjustSafety(gun.Comp, -100, player));
return;
void AddVerb(int priority, string text, ref GetVerbsEvent<AlternativeVerb> args, Action act) =>
args.Verbs.Add(
new()
{
Category = VerbCategory.Safety,
Priority = priority,
CloseMenu = false,
DoContactInteraction = true,
Text = Loc.GetString(text),
Act = act
});
void AdjustSafety(GunOverheatComponent heat, float T, EntityUid user)
{
if (!Timing.IsFirstTimePredicted)
return;
Audio.PlayPredicted(T >= 0 ? heat.clickUpSound : heat.clickDownSound, gun, user);
AdjustTemperatureLimit(heat, T);
}
void ToggleSafety(GunOverheatComponent heat, EntityUid user)
{
if (!Timing.IsFirstTimePredicted)
return;
Audio.PlayPredicted(heat.clickSound, gun, user);
heat.SafetyEnabled = !heat.SafetyEnabled;
}
}
private void OnBreak(Entity<RegulatorLampComponent> lamp, ref BreakageEventArgs args)
{
Appearance.SetData(lamp, RegulatorLampGlass.Intact, false);
lamp.Comp.Intact = false;
Dirty(lamp);
}
private void OnLampExamined(Entity<RegulatorLampComponent> lamp, ref ExaminedEvent args)
{
if (!args.IsInDetailsRange)
return;
args.PushMarkup(Loc.GetString("gun-regulator-lamp-examine-intact", ("intact", lamp.Comp.Intact)));
args.PushMarkup(
Loc.GetString(
"gun-regulator-lamp-examine-temperature-range",
("safetemp", MathF.Round(lamp.Comp.SafeTemperature - 273.15f)),
("unsafetemp", MathF.Round(lamp.Comp.UnsafeTemperature - 273.15f))));
}
public void AdjustTemperatureLimit(GunOverheatComponent comp, float tempChange)
{
comp.TemperatureLimit = MathHelper.Clamp(comp.TemperatureLimit + tempChange, -250f + 273.15f, comp.MaxSafetyTemperature); // from -250C to MaxSafetyTemperature
}
private void OnAltVerbs(EntityUid uid, GunOverheatComponent comp, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanInteract || !args.CanComplexInteract || !args.CanAccess || !comp.CanChangeSafety)
return;
AddVerb(-1, "fireselector-100up-verb", () => _adjustSafety(comp, 100));
AddVerb(-2, "fireselector-10up-verb", () => _adjustSafety(comp, 10));
AddVerb(-3, "fireselector-toggle-verb", () => _toggleSafety(comp));
AddVerb(-4, "fireselector-10down-verb", () => _adjustSafety(comp, -10));
AddVerb(-5, "fireselector-100down-verb", () => _adjustSafety(comp, -100));
void AddVerb(int priority, string text, Action act)
{
args.Verbs.Add(new AlternativeVerb
{
Category = VerbCategory.Safety,
Priority = priority,
CloseMenu = false,
DoContactInteraction = true,
Text = Loc.GetString(text),
Act = act,
});
}
void _adjustSafety(GunOverheatComponent comp, float T)
{
if (!_timing.IsFirstTimePredicted)
return;
_audio.PlayPredicted(T >= 0 ? comp.clickUpSound : comp.clickDownSound, uid, args.User);
AdjustTemperatureLimit(comp, T);
}
void _toggleSafety(GunOverheatComponent comp)
{
if (!_timing.IsFirstTimePredicted)
return;
_audio.PlayPredicted(comp.clickSound, uid, args.User);
comp.SafetyEnabled = !comp.SafetyEnabled;
}
comp.TemperatureLimit = MathHelper.Clamp(
comp.TemperatureLimit + tempChange, -250f + 273.15f,
comp.MaxSafetyTemperature); // from -250C to MaxSafetyTemperature
}
/// <summary>
/// Returns false if called on something without GunTemperatureRegulatorComponent.
/// Otherwise returns true.
/// </summary>
public bool GetLamp(EntityUid gunUid, out RegulatorLampComponent? lampComp, GunOverheatComponent? comp = null)
public bool GetLamp(Entity<GunOverheatComponent> gun, [NotNullWhen(true)] out Entity<RegulatorLampComponent>? lamp)
{
lampComp = null;
if (!Resolve(gunUid, ref comp))
lamp = null;
if (!TryComp<ItemSlotsComponent>(gun, out var slotComp) ||
!Slots.TryGetSlot(gun, gun.Comp.LampSlot, out var slot, slotComp) ||
!TryComp(slot.Item, out RegulatorLampComponent? comp))
return false;
if (TryComp<ItemSlotsComponent>(gunUid, out var slotComp) && _slots.TryGetSlot(gunUid, comp.LampSlot, out var slot, slotComp))
TryComp(slot.Item, out lampComp);
lamp = (slot.Item.Value, comp);
return true;
}
protected void BurnoutLamp(RegulatorLampComponent comp, EntityUid? shooter = null)
protected void BurnoutLamp(Entity<RegulatorLampComponent> lamp, EntityUid? shooter = null)
{
var lampUid = comp.Owner;
_audio.PlayEntity(comp.BreakSound, Filter.Pvs(lampUid), lampUid, true);
/*_appearance.SetData(lampUid, RegulatorLampVisuals.Filament, RegulatorLampState.Broken);*/
comp.Intact = false;
Dirty(lampUid, comp);
Audio.PlayEntity(lamp.Comp.BreakSound, Filter.Pvs(lamp), lamp, true);
Appearance.SetData(lamp, RegulatorLampFilament.Intact, false);
lamp.Comp.Intact = false;
Dirty(lamp);
}
public float GetLampBreakChance(float temp, RegulatorLampComponent comp, float multiplier = 1) => MathHelper.Clamp01((temp - comp.SafeTemperature) / (comp.UnsafeTemperature - comp.SafeTemperature) * multiplier);
}
// I do not know why, but it refuses to work on the server. TODO: return it
/*
[Serializable, NetSerializable]
public enum RegulatorLampVisuals
{
Glass,
Filament
public float GetLampBreakChance(float temp, RegulatorLampComponent comp, float multiplier = 1)
{
return MathHelper.Clamp01(
(temp - comp.SafeTemperature) / (comp.UnsafeTemperature - comp.SafeTemperature) * multiplier);
}
}
[Serializable, NetSerializable]
public enum RegulatorLampState
public enum RegulatorLampGlass : byte
{
Intact,
Broken
Layer,
Intact
}
[Serializable, NetSerializable]
public enum RegulatorLampFilament : byte
{
Layer,
Intact
}
*/

View File

@@ -10,9 +10,9 @@
layers:
- state: base
- state: filament
map: [ "Filament" ]
map: [ "enum.RegulatorLampFilament.Layer" ]
- state: glass
map: [ "Glass" ]
map: [ "enum.RegulatorLampGlass.Layer" ]
- type: RegulatorLamp
safeTemp: 240
unsafeTemp: 650
@@ -61,17 +61,17 @@
max: 1
- !type:DoActsBehavior
acts: [ "Destruction" ]
# - type: Appearance
# - type: GenericVisualizer
# visuals:
# enum.RegulatorLampVisuals.Glass:
# Glass:
# Intact: { state: glass }
# Broken: { state: glassbroken }
# enum.RegulatorLampVisuals.Filament:
# Filament:
# Intact: { state: filament }
# Broken: { state: filamentburned }
- type: Appearance
- type: GenericVisualizer
visuals:
enum.RegulatorLampGlass.Intact:
enum.RegulatorLampGlass.Layer:
True: { state: glass }
False: { state: glassbroken }
enum.RegulatorLampFilament.Intact:
enum.RegulatorLampFilament.Layer:
True: { state: filament }
False: { state: filamentburned }
- type: entity
parent: BaseRegulatorLamp
@@ -90,9 +90,9 @@
layers:
- state: adv
- state: filament
map: [ "Filament" ]
map: [ "enum.RegulatorLampFilament.Layer" ]
- state: glass
map: [ "Glass" ]
map: [ "enum.RegulatorLampGlass.Layer" ]
- type: RegulatorLamp
safeTemp: 480
unsafeTemp: 840