Welder flame fix (#7021)
This commit is contained in:
parent
e2dc47bff9
commit
db4322e5b3
|
|
@ -0,0 +1,21 @@
|
|||
using Content.Client.Tools.Components;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Tools.Visualizers;
|
||||
|
||||
public sealed class WelderVisualizerSystem : VisualizerSystem<WelderComponent>
|
||||
{
|
||||
protected override void OnAppearanceChange(EntityUid uid, WelderComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
base.OnAppearanceChange(uid, component, ref args);
|
||||
|
||||
if (!TryComp(uid, out SpriteComponent? sprite))
|
||||
return;
|
||||
|
||||
if (args.Component.TryGetData(WelderVisuals.Lit, out bool isLit))
|
||||
{
|
||||
sprite.LayerSetVisible(WelderLayers.Flame, isLit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
|
|
@ -15,9 +14,7 @@ using Content.Shared.Temperature;
|
|||
using Content.Shared.Tools.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.Tools
|
||||
|
|
@ -64,7 +61,7 @@ namespace Content.Server.Tools
|
|||
SolutionContainerManagerComponent? solutionContainer = null,
|
||||
SharedItemComponent? item = null,
|
||||
PointLightComponent? light = null,
|
||||
SpriteComponent? sprite = null)
|
||||
AppearanceComponent? appearance = null)
|
||||
{
|
||||
// Right now, we only need the welder.
|
||||
// So let's not unnecessarily resolve components
|
||||
|
|
@ -72,8 +69,8 @@ namespace Content.Server.Tools
|
|||
return false;
|
||||
|
||||
return !welder.Lit
|
||||
? TryTurnWelderOn(uid, user, welder, solutionContainer, item, light, sprite)
|
||||
: TryTurnWelderOff(uid, user, welder, item, light, sprite);
|
||||
? TryTurnWelderOn(uid, user, welder, solutionContainer, item, light, appearance)
|
||||
: TryTurnWelderOff(uid, user, welder, item, light, appearance);
|
||||
}
|
||||
|
||||
public bool TryTurnWelderOn(EntityUid uid, EntityUid? user,
|
||||
|
|
@ -81,13 +78,13 @@ namespace Content.Server.Tools
|
|||
SolutionContainerManagerComponent? solutionContainer = null,
|
||||
SharedItemComponent? item = null,
|
||||
PointLightComponent? light = null,
|
||||
SpriteComponent? sprite = null)
|
||||
AppearanceComponent? appearance = null)
|
||||
{
|
||||
if (!Resolve(uid, ref welder, ref solutionContainer))
|
||||
return false;
|
||||
|
||||
// Optional components.
|
||||
Resolve(uid, ref item, ref light, ref sprite);
|
||||
Resolve(uid, ref item, ref light, ref appearance, false);
|
||||
|
||||
if (!_solutionContainerSystem.TryGetSolution(uid, welder.FuelSolution, out var solution, solutionContainer))
|
||||
return false;
|
||||
|
|
@ -109,7 +106,7 @@ namespace Content.Server.Tools
|
|||
if(item != null)
|
||||
item.EquippedPrefix = "on";
|
||||
|
||||
sprite?.LayerSetVisible(1, true);
|
||||
appearance?.SetData(WelderVisuals.Lit, true);
|
||||
|
||||
if (light != null)
|
||||
light.Enabled = true;
|
||||
|
|
@ -129,13 +126,13 @@ namespace Content.Server.Tools
|
|||
WelderComponent? welder = null,
|
||||
SharedItemComponent? item = null,
|
||||
PointLightComponent? light = null,
|
||||
SpriteComponent? sprite = null)
|
||||
AppearanceComponent? appearance = null)
|
||||
{
|
||||
if (!Resolve(uid, ref welder))
|
||||
return false;
|
||||
|
||||
// Optional components.
|
||||
Resolve(uid, ref item, ref light, ref sprite);
|
||||
Resolve(uid, ref item, ref light, ref appearance, false);
|
||||
|
||||
welder.Lit = false;
|
||||
|
||||
|
|
@ -144,7 +141,7 @@ namespace Content.Server.Tools
|
|||
item.EquippedPrefix = "off";
|
||||
|
||||
// Layer 1 is the flame.
|
||||
sprite?.LayerSetVisible(1, false);
|
||||
appearance?.SetData(WelderVisuals.Lit, false);
|
||||
|
||||
if (light != null)
|
||||
light.Enabled = false;
|
||||
|
|
|
|||
|
|
@ -25,4 +25,17 @@ namespace Content.Shared.Tools.Components
|
|||
Lit = lit;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum WelderVisuals : byte
|
||||
{
|
||||
Lit
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum WelderLayers : byte
|
||||
{
|
||||
Base,
|
||||
Flame
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,11 +117,6 @@
|
|||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Tools/Cowtools/cowelder.rsi
|
||||
layers:
|
||||
- state: icon
|
||||
- state: welder_flame
|
||||
shader: unshaded
|
||||
visible: false
|
||||
- type: Item
|
||||
size: 10
|
||||
sprite: Objects/Tools/Cowtools/cowelder.rsi
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@
|
|||
netsync: false
|
||||
layers:
|
||||
- state: icon
|
||||
map: ["enum.WelderLayers.Base"]
|
||||
- state: welder_flame
|
||||
map: ["enum.WelderLayers.Flame"]
|
||||
shader: unshaded
|
||||
visible: false
|
||||
- type: Item
|
||||
|
|
@ -47,6 +49,7 @@
|
|||
enabled: false
|
||||
radius: 1.5
|
||||
color: orange
|
||||
- type: Appearance
|
||||
|
||||
- type: entity
|
||||
name: experimental welding tool
|
||||
|
|
|
|||
Loading…
Reference in New Issue