Add WelderComponent back
This commit is contained in:
@@ -16,12 +16,13 @@ namespace Content.Client.GameObjects.Components.Interactable
|
||||
public class ToolComponent : SharedToolComponent, IItemStatus
|
||||
{
|
||||
private Tool _behavior;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)] private bool _uiUpdateNeeded;
|
||||
|
||||
private bool _statusShowBehavior;
|
||||
[ViewVariables] public float FuelCapacity { get; private set; }
|
||||
[ViewVariables] public float Fuel { get; private set; }
|
||||
[ViewVariables] public bool Activated { get; private set; }
|
||||
|
||||
[ViewVariables] public bool StatusShowBehavior => _statusShowBehavior;
|
||||
|
||||
[ViewVariables]
|
||||
public override Tool Behavior
|
||||
{
|
||||
@@ -37,15 +38,11 @@ namespace Content.Client.GameObjects.Components.Interactable
|
||||
|
||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||
{
|
||||
if (!(curState is ToolComponentState cast))
|
||||
return;
|
||||
|
||||
FuelCapacity = cast.FuelCapacity;
|
||||
Fuel = cast.Fuel;
|
||||
Activated = cast.Activated;
|
||||
_behavior = cast.Behavior;
|
||||
if (!(curState is ToolComponentState tool)) return;
|
||||
|
||||
_behavior = tool.Behavior;
|
||||
_uiUpdateNeeded = true;
|
||||
|
||||
}
|
||||
|
||||
public Control MakeControl() => new StatusControl(this);
|
||||
@@ -75,21 +72,10 @@ namespace Content.Client.GameObjects.Components.Interactable
|
||||
|
||||
_parent._uiUpdateNeeded = false;
|
||||
|
||||
if (_parent.Behavior == Tool.Welder)
|
||||
{
|
||||
var fuelCap = _parent.FuelCapacity;
|
||||
var fuel = _parent.Fuel;
|
||||
|
||||
_label.SetMarkup(Loc.GetString("Fuel: [color={0}]{1}/{2}[/color]",
|
||||
fuel < fuelCap / 4f ? "darkorange" : "orange", Math.Round(fuel), fuelCap));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!_parent.StatusShowBehavior)
|
||||
_label.SetMarkup(string.Empty);
|
||||
else
|
||||
_label.SetMarkup(_parent.Behavior.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Content.Client.Utility;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Interactable;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Interactable
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(ToolComponent))]
|
||||
public class WelderComponent : ToolComponent, IItemStatus
|
||||
{
|
||||
public override string Name => "Welder";
|
||||
public override uint? NetID => ContentNetIDs.WELDER;
|
||||
|
||||
private Tool _behavior;
|
||||
[ViewVariables(VVAccess.ReadWrite)] private bool _uiUpdateNeeded;
|
||||
[ViewVariables] public float FuelCapacity { get; private set; }
|
||||
[ViewVariables] public float Fuel { get; private set; }
|
||||
[ViewVariables] public bool Activated { get; private set; }
|
||||
[ViewVariables]
|
||||
public override Tool Behavior
|
||||
{
|
||||
get => _behavior;
|
||||
set {}
|
||||
}
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||
{
|
||||
if (!(curState is WelderComponentState weld))
|
||||
return;
|
||||
|
||||
FuelCapacity = weld.FuelCapacity;
|
||||
Fuel = weld.Fuel;
|
||||
Activated = weld.Activated;
|
||||
_behavior = weld.Behavior;
|
||||
_uiUpdateNeeded = true;
|
||||
}
|
||||
|
||||
public Control MakeControl() => new StatusControl(this);
|
||||
|
||||
private sealed class StatusControl : Control
|
||||
{
|
||||
private readonly WelderComponent _parent;
|
||||
private readonly RichTextLabel _label;
|
||||
|
||||
public StatusControl(WelderComponent parent)
|
||||
{
|
||||
_parent = parent;
|
||||
_label = new RichTextLabel {StyleClasses = {StyleNano.StyleClassItemStatus}};
|
||||
AddChild(_label);
|
||||
|
||||
parent._uiUpdateNeeded = true;
|
||||
}
|
||||
|
||||
protected override void Update(FrameEventArgs args)
|
||||
{
|
||||
base.Update(args);
|
||||
|
||||
if (!_parent._uiUpdateNeeded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_parent._uiUpdateNeeded = false;
|
||||
|
||||
if (_parent.Behavior == Tool.Welder)
|
||||
{
|
||||
var fuelCap = _parent.FuelCapacity;
|
||||
var fuel = _parent.Fuel;
|
||||
|
||||
_label.SetMarkup(Loc.GetString("Fuel: [color={0}]{1}/{2}[/color]",
|
||||
fuel < fuelCap / 4f ? "darkorange" : "orange", Math.Round(fuel), fuelCap));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,7 @@ namespace Content.Server.GameObjects.Components.Construction
|
||||
if (!slapped.TryGetComponent<ToolComponent>(out var tool))
|
||||
return false;
|
||||
if (toolStep.Tool != tool.Behavior) return false;
|
||||
if (toolStep.Tool == Tool.Welder && !tool.TryWeld(toolStep.Amount)) return false;
|
||||
if (toolStep.Tool == Tool.Welder && !((WelderComponent)tool).TryWeld(toolStep.Amount)) return false;
|
||||
tool.PlayUseSound();
|
||||
return true;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Content.Server.GameObjects.Components.Damage;
|
||||
using Content.Server.GameObjects.Components.Interactable.Tools;
|
||||
using Content.Server.GameObjects.Components.Interactable;
|
||||
using Content.Server.GameObjects.Components.Power;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Interfaces;
|
||||
@@ -19,7 +19,7 @@ using Robust.Shared.Serialization;
|
||||
namespace Content.Server.GameObjects.Components.Gravity
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class GravityGeneratorComponent: SharedGravityGeneratorComponent, IAttackBy, IBreakAct, IAttackHand
|
||||
public class GravityGeneratorComponent: SharedGravityGeneratorComponent, IWelderAct, IBreakAct, IAttackHand
|
||||
{
|
||||
private BoundUserInterface _userInterface;
|
||||
|
||||
@@ -98,15 +98,14 @@ namespace Content.Server.GameObjects.Components.Gravity
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AttackBy(AttackByEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.AttackWith.TryGetComponent<WelderComponent>(out var welder)) return false;
|
||||
if (welder.TryUse(5.0f))
|
||||
public bool WelderAct(WelderActEventArgs eventArgs)
|
||||
{
|
||||
var welder = (WelderComponent)eventArgs.ToolComponent;
|
||||
if (!welder.TryWeld(5.0f)) return false;
|
||||
// Repair generator
|
||||
var damagable = Owner.GetComponent<DamageableComponent>();
|
||||
var damageable = Owner.GetComponent<DamageableComponent>();
|
||||
var breakable = Owner.GetComponent<BreakableComponent>();
|
||||
damagable.HealAllDamage();
|
||||
damageable.HealAllDamage();
|
||||
breakable.broken = false;
|
||||
_intact = true;
|
||||
|
||||
@@ -117,10 +116,7 @@ namespace Content.Server.GameObjects.Components.Gravity
|
||||
notifyManager.PopupMessage(Owner, eventArgs.User, Loc.GetString("You repair the gravity generator with the welder"));
|
||||
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void OnBreak(BreakageEventArgs eventArgs)
|
||||
|
||||
@@ -32,16 +32,6 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
[RegisterComponent]
|
||||
public class ToolComponent : SharedToolComponent, IExamine, IAfterAttack, IUse, IAttack
|
||||
{
|
||||
/// <summary>
|
||||
/// Default Cost of using the welder fuel for an action
|
||||
/// </summary>
|
||||
public const float DefaultFuelCost = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Rate at which we expunge fuel from ourselves when activated
|
||||
/// </summary>
|
||||
public const float FuelLossRate = 0.5f;
|
||||
|
||||
#pragma warning disable 649
|
||||
[Dependency] private IEntitySystemManager _entitySystemManager;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
|
||||
@@ -52,16 +42,12 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
|
||||
private AudioSystem _audioSystem;
|
||||
private InteractionSystem _interactionSystem;
|
||||
private ToolSystem _toolSystem;
|
||||
|
||||
private SolutionComponent _solutionComponent;
|
||||
private SpriteComponent _spriteComponent;
|
||||
|
||||
private Tool _behavior = Tool.Wrench;
|
||||
private float _speedModifier = 1;
|
||||
private bool _welderLit = false;
|
||||
protected Tool _behavior = Tool.Wrench;
|
||||
private string _useSound;
|
||||
private string _useSoundCollection;
|
||||
private float _speedModifier = 1;
|
||||
|
||||
[ViewVariables]
|
||||
public override Tool Behavior
|
||||
@@ -74,12 +60,6 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
}
|
||||
}
|
||||
|
||||
[ViewVariables]
|
||||
public float Fuel => _solutionComponent?.Solution.GetReagentQuantity("chem.WeldingFuel").Float() ?? 0f;
|
||||
|
||||
[ViewVariables]
|
||||
public float FuelCapacity => _solutionComponent?.MaxVolume.Float() ?? 0f;
|
||||
|
||||
/// <summary>
|
||||
/// For tool interactions that have a delay before action this will modify the rate, time to wait is divided by this value
|
||||
/// </summary>
|
||||
@@ -90,20 +70,6 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
set => _speedModifier = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Status of welder, whether it is ignited
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool WelderLit
|
||||
{
|
||||
get => _welderLit;
|
||||
private set
|
||||
{
|
||||
_welderLit = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public string UseSound
|
||||
{
|
||||
get => _useSound;
|
||||
@@ -122,9 +88,6 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
|
||||
_audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>();
|
||||
_interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
|
||||
_toolSystem = _entitySystemManager.GetEntitySystem<ToolSystem>();
|
||||
|
||||
Owner.TryGetComponent(out _solutionComponent);
|
||||
Owner.TryGetComponent(out _spriteComponent);
|
||||
}
|
||||
|
||||
@@ -132,8 +95,17 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
if(serializer.Reading)
|
||||
if (serializer.Reading)
|
||||
{
|
||||
try
|
||||
{
|
||||
_behavior = (Tool)serializer.ReadStringEnumKey("behavior");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
serializer.DataField(ref _speedModifier, "speed", 1);
|
||||
serializer.DataField(ref _useSound, "useSound", string.Empty);
|
||||
serializer.DataField(ref _useSoundCollection, "useSoundCollection", string.Empty);
|
||||
@@ -142,74 +114,12 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
/// <summary>
|
||||
/// Status modifier which determines whether or not we can act as a tool at this time
|
||||
/// </summary>
|
||||
public bool CanUse()
|
||||
public virtual bool CanUse()
|
||||
{
|
||||
return _behavior != Tool.Welder || CanWeld(DefaultFuelCost);
|
||||
}
|
||||
|
||||
public bool TryWeld(float value)
|
||||
{
|
||||
if (!WelderLit || !CanWeld(value) || _solutionComponent == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _solutionComponent.TryRemoveReagent("chem.WeldingFuel", ReagentUnit.New(value));
|
||||
}
|
||||
|
||||
public bool CanWeld(float value)
|
||||
{
|
||||
return Fuel > value || Behavior != Tool.Welder;
|
||||
}
|
||||
|
||||
public bool CanLitWelder()
|
||||
{
|
||||
return Fuel > 0 || Behavior != Tool.Welder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deactivates welding tool if active, activates welding tool if possible
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ToggleWelderStatus()
|
||||
{
|
||||
if (WelderLit)
|
||||
{
|
||||
WelderLit = false;
|
||||
// Layer 1 is the flame.
|
||||
_spriteComponent.LayerSetVisible(1, false);
|
||||
PlaySoundCollection("WelderOff", -5);
|
||||
_toolSystem.Unsubscribe(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!CanLitWelder()) return false;
|
||||
|
||||
WelderLit = true;
|
||||
_spriteComponent.LayerSetVisible(1, true);
|
||||
PlaySoundCollection("WelderOn", -5);
|
||||
_toolSystem.Subscribe(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnUpdate(float frameTime)
|
||||
{
|
||||
if (Behavior != Tool.Welder || !WelderLit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_solutionComponent.TryRemoveReagent("chem.WeldingFuel", ReagentUnit.New(FuelLossRate * frameTime));
|
||||
|
||||
if (Fuel == 0)
|
||||
{
|
||||
ToggleWelderStatus();
|
||||
}
|
||||
|
||||
Dirty();
|
||||
}
|
||||
|
||||
private void PlaySoundCollection(string name, float volume=-5f)
|
||||
protected void PlaySoundCollection(string name, float volume=-5f)
|
||||
{
|
||||
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(name);
|
||||
var file = _robustRandom.Pick(soundCollection.PickFiles);
|
||||
@@ -227,7 +137,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return Behavior == Tool.Welder ? new ToolComponentState(FuelCapacity, Fuel, WelderLit) : new ToolComponentState(Behavior);
|
||||
return new ToolComponentState(Behavior);
|
||||
}
|
||||
|
||||
public void AfterAttack(AfterAttackEventArgs eventArgs)
|
||||
@@ -256,42 +166,17 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
tileItem.Transform.WorldPosition += (0.2f, 0.2f);
|
||||
}
|
||||
|
||||
public bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
public virtual bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
{
|
||||
Logger.Info(Behavior.ToString());
|
||||
|
||||
switch (Behavior)
|
||||
{
|
||||
case Tool.Welder:
|
||||
return ToggleWelderStatus();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Examine(FormattedMessage message)
|
||||
public virtual void Examine(FormattedMessage message)
|
||||
{
|
||||
switch (Behavior)
|
||||
{
|
||||
case Tool.Welder:
|
||||
if (WelderLit)
|
||||
{
|
||||
message.AddMarkup(Loc.GetString("[color=orange]Lit[/color]\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
message.AddText(Loc.GetString("Not lit\n"));
|
||||
}
|
||||
|
||||
message.AddMarkup(Loc.GetString("Fuel: [color={0}]{1}/{2}[/color].",
|
||||
Fuel < FuelCapacity / 4f ? "darkorange" : "orange", Math.Round(Fuel), FuelCapacity));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Attack(AttackEventArgs eventArgs)
|
||||
public virtual void Attack(AttackEventArgs eventArgs)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using Content.Server.GameObjects.Components.Chemistry;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Interactable;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Interactable
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(ToolComponent))]
|
||||
public class WelderComponent : ToolComponent
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private IEntitySystemManager _entitySystemManager;
|
||||
[Dependency] private readonly IRobustRandom _robustRandom;
|
||||
#pragma warning restore 649
|
||||
|
||||
public override string Name => "Welder";
|
||||
public override uint? NetID => ContentNetIDs.WELDER;
|
||||
|
||||
/// <summary>
|
||||
/// Default Cost of using the welder fuel for an action
|
||||
/// </summary>
|
||||
public const float DefaultFuelCost = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Rate at which we expunge fuel from ourselves when activated
|
||||
/// </summary>
|
||||
public const float FuelLossRate = 0.5f;
|
||||
|
||||
private bool _welderLit = false;
|
||||
|
||||
private WelderSystem _welderSystem;
|
||||
private SpriteComponent _spriteComponent;
|
||||
private SolutionComponent _solutionComponent;
|
||||
|
||||
[ViewVariables]
|
||||
public float Fuel => _solutionComponent?.Solution.GetReagentQuantity("chem.WeldingFuel").Float() ?? 0f;
|
||||
|
||||
[ViewVariables]
|
||||
public float FuelCapacity => _solutionComponent?.MaxVolume.Float() ?? 0f;
|
||||
|
||||
/// <summary>
|
||||
/// Status of welder, whether it is ignited
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool WelderLit
|
||||
{
|
||||
get => _welderLit;
|
||||
private set
|
||||
{
|
||||
_welderLit = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_behavior = Tool.Welder;
|
||||
|
||||
_welderSystem = _entitySystemManager.GetEntitySystem<WelderSystem>();
|
||||
|
||||
Owner.TryGetComponent(out _solutionComponent);
|
||||
Owner.TryGetComponent(out _spriteComponent);
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new WelderComponentState(FuelCapacity, Fuel, WelderLit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Status modifier which determines whether or not we can act as a tool at this time
|
||||
/// </summary>
|
||||
public override bool CanUse()
|
||||
{
|
||||
return CanWeld(DefaultFuelCost);
|
||||
}
|
||||
|
||||
public bool TryWeld(float value)
|
||||
{
|
||||
if (!WelderLit || !CanWeld(value) || _solutionComponent == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _solutionComponent.TryRemoveReagent("chem.WeldingFuel", ReagentUnit.New(value));
|
||||
}
|
||||
|
||||
public bool CanWeld(float value)
|
||||
{
|
||||
return Fuel > value || Behavior != Tool.Welder;
|
||||
}
|
||||
|
||||
public bool CanLitWelder()
|
||||
{
|
||||
return Fuel > 0 || Behavior != Tool.Welder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deactivates welding tool if active, activates welding tool if possible
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ToggleWelderStatus()
|
||||
{
|
||||
if (WelderLit)
|
||||
{
|
||||
WelderLit = false;
|
||||
// Layer 1 is the flame.
|
||||
_spriteComponent.LayerSetVisible(1, false);
|
||||
PlaySoundCollection("WelderOff", -5);
|
||||
_welderSystem.Unsubscribe(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!CanLitWelder()) return false;
|
||||
|
||||
WelderLit = true;
|
||||
_spriteComponent.LayerSetVisible(1, true);
|
||||
PlaySoundCollection("WelderOn", -5);
|
||||
_welderSystem.Subscribe(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
{
|
||||
return ToggleWelderStatus();
|
||||
}
|
||||
|
||||
public override void Examine(FormattedMessage message)
|
||||
{
|
||||
if (WelderLit)
|
||||
{
|
||||
message.AddMarkup(Loc.GetString("[color=orange]Lit[/color]\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
message.AddText(Loc.GetString("Not lit\n"));
|
||||
}
|
||||
|
||||
message.AddMarkup(Loc.GetString("Fuel: [color={0}]{1}/{2}[/color].",
|
||||
Fuel < FuelCapacity / 4f ? "darkorange" : "orange", Math.Round(Fuel), FuelCapacity));
|
||||
}
|
||||
|
||||
public void OnUpdate(float frameTime)
|
||||
{
|
||||
if (Behavior != Tool.Welder || !WelderLit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_solutionComponent.TryRemoveReagent("chem.WeldingFuel", ReagentUnit.New(FuelLossRate * frameTime));
|
||||
|
||||
if (Fuel == 0)
|
||||
{
|
||||
ToggleWelderStatus();
|
||||
}
|
||||
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -738,10 +738,11 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
|
||||
case Tool.Welder:
|
||||
var welderList = attacked.GetAllComponents<IWelderAct>().ToList();
|
||||
var welder = (WelderComponent) tool;
|
||||
var welderAttackBy = new WelderActEventArgs()
|
||||
{
|
||||
User = user, ClickLocation = clickLocation, AttackWith = weapon,
|
||||
Fuel = tool.Fuel, FuelCapacity = tool.FuelCapacity
|
||||
Fuel = welder.Fuel, FuelCapacity = welder.FuelCapacity
|
||||
};
|
||||
|
||||
foreach (var comp in welderList)
|
||||
|
||||
@@ -8,16 +8,16 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
/// <summary>
|
||||
/// Despite the name, it's only really used for the welder logic in tools. Go figure.
|
||||
/// </summary>
|
||||
public class ToolSystem : EntitySystem
|
||||
public class WelderSystem : EntitySystem
|
||||
{
|
||||
private readonly HashSet<ToolComponent> _activeWelders = new HashSet<ToolComponent>();
|
||||
private readonly HashSet<WelderComponent> _activeWelders = new HashSet<WelderComponent>();
|
||||
|
||||
public bool Subscribe(ToolComponent welder)
|
||||
public bool Subscribe(WelderComponent welder)
|
||||
{
|
||||
return _activeWelders.Add(welder);
|
||||
}
|
||||
|
||||
public bool Unsubscribe(ToolComponent welder)
|
||||
public bool Unsubscribe(WelderComponent welder)
|
||||
{
|
||||
return _activeWelders.Remove(welder);
|
||||
}
|
||||
@@ -25,17 +25,23 @@ namespace Content.Shared.GameObjects.Components.Interactable
|
||||
[NetSerializable, Serializable]
|
||||
public class ToolComponentState : ComponentState
|
||||
{
|
||||
public float FuelCapacity { get; }
|
||||
public float Fuel { get; }
|
||||
public bool Activated { get; }
|
||||
public Tool Behavior { get; }
|
||||
|
||||
public ToolComponentState(Tool behavior) : base(ContentNetIDs.TOOL)
|
||||
{
|
||||
Behavior = behavior;
|
||||
}
|
||||
}
|
||||
|
||||
public ToolComponentState(float fuelCapacity, float fuel, bool activated) : base(ContentNetIDs.TOOL)
|
||||
[NetSerializable, Serializable]
|
||||
public class WelderComponentState : ComponentState
|
||||
{
|
||||
public float FuelCapacity { get; }
|
||||
public float Fuel { get; }
|
||||
public bool Activated { get; }
|
||||
public Tool Behavior { get; }
|
||||
|
||||
public WelderComponentState(float fuelCapacity, float fuel, bool activated) : base(ContentNetIDs.WELDER)
|
||||
{
|
||||
FuelCapacity = fuelCapacity;
|
||||
Fuel = fuel;
|
||||
|
||||
@@ -37,12 +37,13 @@
|
||||
public const uint HUMANOID_APPEARANCE = 1032;
|
||||
public const uint INSTRUMENTS = 1033;
|
||||
public const uint TOOL = 1034;
|
||||
public const uint STACK = 1035;
|
||||
public const uint HANDHELD_LIGHT = 1036;
|
||||
public const uint PAPER = 1037;
|
||||
public const uint REAGENT_INJECTOR = 1038;
|
||||
public const uint GHOST = 1039;
|
||||
public const uint MICROWAVE = 1040;
|
||||
public const uint GRAVITY_GENERATOR = 1041;
|
||||
public const uint WELDER = 1035;
|
||||
public const uint STACK = 1036;
|
||||
public const uint HANDHELD_LIGHT = 1037;
|
||||
public const uint PAPER = 1038;
|
||||
public const uint REAGENT_INJECTOR = 1039;
|
||||
public const uint GHOST = 1040;
|
||||
public const uint MICROWAVE = 1041;
|
||||
public const uint GRAVITY_GENERATOR = 1042;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +60,7 @@
|
||||
reagents:
|
||||
- ReagentId: chem.WeldingFuel
|
||||
Quantity: 100
|
||||
- type: Tool
|
||||
behavior: enum.Tool.Welder
|
||||
- type: Welder
|
||||
useSoundCollection: Welder
|
||||
|
||||
- type: entity
|
||||
|
||||
Reference in New Issue
Block a user