Make welder flames like proper unshaded lights. (#12320)

* Make welders use ToggleableLightVisualsComponent.

* Remove old code from ToolSystem.Welder.

* Update welder sprites.
This commit is contained in:
Vordenburg
2022-11-01 21:16:33 -04:00
committed by GitHub
parent 8fcb87d0a3
commit 784e0ab51f
43 changed files with 94 additions and 61 deletions

View File

@@ -4,12 +4,12 @@ using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Tools.Components;
using Content.Server.Weapons.Melee.Events;
using Content.Shared.Audio;
using Content.Shared.Examine;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
using Content.Shared.Item;
using Content.Shared.Temperature;
using Content.Shared.Toggleable;
using Content.Shared.Tools.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -20,6 +20,11 @@ namespace Content.Server.Tools
{
public sealed partial class ToolSystem
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly AppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
private readonly HashSet<EntityUid> _activeWelders = new();
private const float WelderUpdateTimer = 1f;
@@ -106,15 +111,13 @@ namespace Content.Server.Tools
var ev = new WelderToggledEvent(true);
RaiseLocalEvent(welder.Owner, ev, false);
if(item != null)
_itemSystem.SetHeldPrefix(uid, "on", item);
appearance?.SetData(WelderVisuals.Lit, true);
_appearanceSystem.SetData(uid, WelderVisuals.Lit, true);
_appearanceSystem.SetData(uid, ToggleableLightVisuals.Enabled, true);
if (light != null)
light.Enabled = true;
SoundSystem.Play(welder.WelderOnSounds.GetSound(), Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.125f).WithVolume(-5f));
_audioSystem.PlayPvs(welder.WelderOnSounds, uid, AudioParams.Default.WithVariation(0.125f).WithVolume(-5f));
if (transform.GridUid is {} gridUid)
{
@@ -122,7 +125,7 @@ namespace Content.Server.Tools
_atmosphereSystem.HotspotExpose(gridUid, position, 700, 50, true);
}
welder.Dirty();
_entityManager.Dirty(welder);
_activeWelders.Add(uid);
return true;
@@ -145,27 +148,24 @@ namespace Content.Server.Tools
var ev = new WelderToggledEvent(false);
RaiseLocalEvent(welder.Owner, ev, false);
// TODO: Make all this use visualizers.
if (item != null)
_itemSystem.SetHeldPrefix(uid, "off", item);
// Layer 1 is the flame.
appearance?.SetData(WelderVisuals.Lit, false);
_appearanceSystem.SetData(uid, WelderVisuals.Lit, false);
_appearanceSystem.SetData(uid, ToggleableLightVisuals.Enabled, false);
if (light != null)
light.Enabled = false;
SoundSystem.Play(welder.WelderOffSounds.GetSound(), Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.125f).WithVolume(-5f));
_audioSystem.PlayPvs(welder.WelderOffSounds, uid, AudioParams.Default.WithVariation(0.125f).WithVolume(-5f));
welder.Dirty();
_entityManager.Dirty(welder);
_activeWelders.Remove(uid);
return true;
}
private void OnWelderStartup(EntityUid uid, WelderComponent component, ComponentStartup args)
private void OnWelderStartup(EntityUid uid, WelderComponent welder, ComponentStartup args)
{
component.Dirty();
_entityManager.Dirty(welder);
}
private void OnWelderIsHotEvent(EntityUid uid, WelderComponent welder, IsHotEvent args)
@@ -198,7 +198,7 @@ namespace Content.Server.Tools
private void OnWelderSolutionChange(EntityUid uid, WelderComponent welder, SolutionChangedEvent args)
{
welder.Dirty();
_entityManager.Dirty(welder);
}
private void OnWelderActivate(EntityUid uid, WelderComponent welder, ActivateInWorldEvent args)
@@ -226,7 +226,7 @@ namespace Content.Server.Tools
{
var drained = _solutionContainerSystem.Drain(target, targetSolution, trans);
_solutionContainerSystem.TryAddSolution(uid, welderSolution, drained);
SoundSystem.Play(welder.WelderRefill.GetSound(), Filter.Pvs(uid), uid);
_audioSystem.PlayPvs(welder.WelderRefill, uid);
_popupSystem.PopupEntity(Loc.GetString("welder-component-after-interact-refueled-message"), uid, Filter.Entities(args.User));
}
else if (welderSolution.AvailableVolume <= 0)
@@ -292,7 +292,7 @@ namespace Content.Server.Tools
}
solution.RemoveReagent(welder.FuelReagent, neededFuel);
welder.Dirty();
_entityManager.Dirty(welder);
}
private void OnWelderShutdown(EntityUid uid, WelderComponent welder, ComponentShutdown args)
@@ -335,7 +335,7 @@ namespace Content.Server.Tools
if (solution.GetReagentQuantity(welder.FuelReagent) <= FixedPoint2.Zero)
TryTurnWelderOff(tool, null, welder);
welder.Dirty();
_entityManager.Dirty(welder);
}
_welderTimer -= WelderUpdateTimer;