Finish refactoring tools. Add multitools. (as in multiple tools in one)
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Client.GameObjects.Components.Construction;
|
using Content.Client.GameObjects.Components.Construction;
|
||||||
using Content.Shared.Construction;
|
using Content.Shared.Construction;
|
||||||
|
using Content.Shared.GameObjects.Components.Interactable;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.Interfaces.Placement;
|
using Robust.Client.Interfaces.Placement;
|
||||||
using Robust.Client.Interfaces.ResourceManagement;
|
using Robust.Client.Interfaces.ResourceManagement;
|
||||||
@@ -182,25 +183,25 @@ namespace Content.Client.Construction
|
|||||||
case ConstructionStepTool tool:
|
case ConstructionStepTool tool:
|
||||||
switch (tool.Tool)
|
switch (tool.Tool)
|
||||||
{
|
{
|
||||||
case ConstructionStepTool.ToolType.Wrench:
|
case Tool.Wrench:
|
||||||
icon = ResourceCache.GetResource<TextureResource>("/Textures/Objects/Tools/wrench.png");
|
icon = ResourceCache.GetResource<TextureResource>("/Textures/Objects/Tools/wrench.png");
|
||||||
text = "Wrench";
|
text = "Wrench";
|
||||||
break;
|
break;
|
||||||
case ConstructionStepTool.ToolType.Crowbar:
|
case Tool.Crowbar:
|
||||||
icon = ResourceCache.GetResource<TextureResource>("/Textures/Objects/Tools/crowbar.png");
|
icon = ResourceCache.GetResource<TextureResource>("/Textures/Objects/Tools/crowbar.png");
|
||||||
text = "Crowbar";
|
text = "Crowbar";
|
||||||
break;
|
break;
|
||||||
case ConstructionStepTool.ToolType.Screwdriver:
|
case Tool.Screwdriver:
|
||||||
icon = ResourceCache.GetResource<TextureResource>(
|
icon = ResourceCache.GetResource<TextureResource>(
|
||||||
"/Textures/Objects/Tools/screwdriver.png");
|
"/Textures/Objects/Tools/screwdriver.png");
|
||||||
text = "Screwdriver";
|
text = "Screwdriver";
|
||||||
break;
|
break;
|
||||||
case ConstructionStepTool.ToolType.Welder:
|
case Tool.Welder:
|
||||||
icon = ResourceCache.GetResource<RSIResource>("/Textures/Objects/tools.rsi")
|
icon = ResourceCache.GetResource<RSIResource>("/Textures/Objects/tools.rsi")
|
||||||
.RSI["welder"].Frame0;
|
.RSI["welder"].Frame0;
|
||||||
text = $"Welding tool ({tool.Amount} fuel)";
|
text = $"Welding tool ({tool.Amount} fuel)";
|
||||||
break;
|
break;
|
||||||
case ConstructionStepTool.ToolType.Wirecutters:
|
case Tool.Wirecutter:
|
||||||
icon = ResourceCache.GetResource<TextureResource>(
|
icon = ResourceCache.GetResource<TextureResource>(
|
||||||
"/Textures/Objects/Tools/wirecutter.png");
|
"/Textures/Objects/Tools/wirecutter.png");
|
||||||
text = "Wirecutters";
|
text = "Wirecutters";
|
||||||
|
|||||||
@@ -1,38 +1,49 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Client.UserInterface;
|
|
||||||
using Content.Client.UserInterface.Stylesheets;
|
using Content.Client.UserInterface.Stylesheets;
|
||||||
using Content.Client.Utility;
|
using Content.Client.Utility;
|
||||||
using Content.Shared.GameObjects;
|
using Content.Shared.GameObjects.Components.Interactable;
|
||||||
using Content.Shared.GameObjects.Components;
|
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.Components
|
namespace Content.Client.GameObjects.Components.Interactable
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class WelderComponent : Component, IItemStatus
|
public class ToolComponent : SharedToolComponent, IItemStatus
|
||||||
{
|
{
|
||||||
public override string Name => "Welder";
|
private Tool _behavior;
|
||||||
public override uint? NetID => ContentNetIDs.WELDER;
|
[ViewVariables(VVAccess.ReadWrite)] private bool _uiUpdateNeeded;
|
||||||
|
private bool _statusShowBehavior;
|
||||||
[ViewVariables] public float FuelCapacity { get; private set; }
|
[ViewVariables] public float FuelCapacity { get; private set; }
|
||||||
[ViewVariables] public float Fuel { get; private set; }
|
[ViewVariables] public float Fuel { get; private set; }
|
||||||
[ViewVariables] public bool Activated { get; private set; }
|
[ViewVariables] public bool Activated { get; private set; }
|
||||||
|
[ViewVariables] public bool StatusShowBehavior => _statusShowBehavior;
|
||||||
|
[ViewVariables]
|
||||||
|
public override Tool Behavior
|
||||||
|
{
|
||||||
|
get => _behavior;
|
||||||
|
set {}
|
||||||
|
}
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)] private bool _uiUpdateNeeded;
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
|
{
|
||||||
|
base.ExposeData(serializer);
|
||||||
|
serializer.DataField(ref _statusShowBehavior, "statusShowBehavior", false);
|
||||||
|
}
|
||||||
|
|
||||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||||
{
|
{
|
||||||
if (!(curState is WelderComponentState cast))
|
if (!(curState is ToolComponentState cast))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FuelCapacity = cast.FuelCapacity;
|
FuelCapacity = cast.FuelCapacity;
|
||||||
Fuel = cast.Fuel;
|
Fuel = cast.Fuel;
|
||||||
Activated = cast.Activated;
|
Activated = cast.Activated;
|
||||||
|
_behavior = cast.Behavior;
|
||||||
|
|
||||||
_uiUpdateNeeded = true;
|
_uiUpdateNeeded = true;
|
||||||
}
|
}
|
||||||
@@ -41,10 +52,10 @@ namespace Content.Client.GameObjects.Components
|
|||||||
|
|
||||||
private sealed class StatusControl : Control
|
private sealed class StatusControl : Control
|
||||||
{
|
{
|
||||||
private readonly WelderComponent _parent;
|
private readonly ToolComponent _parent;
|
||||||
private readonly RichTextLabel _label;
|
private readonly RichTextLabel _label;
|
||||||
|
|
||||||
public StatusControl(WelderComponent parent)
|
public StatusControl(ToolComponent parent)
|
||||||
{
|
{
|
||||||
_parent = parent;
|
_parent = parent;
|
||||||
_label = new RichTextLabel {StyleClasses = {StyleNano.StyleClassItemStatus}};
|
_label = new RichTextLabel {StyleClasses = {StyleNano.StyleClassItemStatus}};
|
||||||
@@ -64,11 +75,22 @@ namespace Content.Client.GameObjects.Components
|
|||||||
|
|
||||||
_parent._uiUpdateNeeded = false;
|
_parent._uiUpdateNeeded = false;
|
||||||
|
|
||||||
var fuelCap = _parent.FuelCapacity;
|
if (_parent.Behavior == Tool.Welder)
|
||||||
var fuel = _parent.Fuel;
|
{
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
_label.SetMarkup(Loc.GetString("Fuel: [color={0}]{1}/{2}[/color]",
|
|
||||||
fuel < fuelCap / 4f ? "darkorange" : "orange", Math.Round(fuel), fuelCap));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Server.GameObjects.Components.Interactable.Tools;
|
using Content.Server.GameObjects.Components.Interactable;
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
|
using Content.Shared.GameObjects.Components.Interactable;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.GameObjects.EntitySystems;
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -9,31 +10,25 @@ using Robust.Shared.IoC;
|
|||||||
namespace Content.Server.GameObjects.Components
|
namespace Content.Server.GameObjects.Components
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class WrenchableComponent : Component, IAttackBy
|
public class AnchorableComponent : Component, IWrenchAct
|
||||||
{
|
{
|
||||||
public override string Name => "Wrenchable";
|
public override string Name => "Anchorable";
|
||||||
private AudioSystem _audioSystem;
|
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
_audioSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>();
|
Owner.EnsureComponent<PhysicsComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AttackBy(AttackByEventArgs eventArgs)
|
public bool WrenchAct(WrenchActEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (!eventArgs.AttackWith.HasComponent<WrenchComponent>())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Owner.TryGetComponent(out PhysicsComponent physics))
|
if (!Owner.TryGetComponent(out PhysicsComponent physics))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
physics.Anchored = !physics.Anchored;
|
physics.Anchored = !physics.Anchored;
|
||||||
_audioSystem.Play("/Audio/items/ratchet.ogg", Owner);
|
eventArgs.ToolComponent.PlayUseSound();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Server.GameObjects.Components.Interactable.Tools;
|
using Content.Server.GameObjects.Components.Interactable;
|
||||||
using Content.Server.GameObjects.Components.Stack;
|
using Content.Server.GameObjects.Components.Stack;
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
using Content.Server.Interfaces;
|
using Content.Server.Interfaces;
|
||||||
using Content.Shared.Construction;
|
using Content.Shared.Construction;
|
||||||
using Content.Shared.GameObjects.Components;
|
using Content.Shared.GameObjects.Components;
|
||||||
|
using Content.Shared.GameObjects.Components.Interactable;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.GameObjects.EntitySystems;
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
using Robust.Server.Interfaces.GameObjects;
|
using Robust.Server.Interfaces.GameObjects;
|
||||||
@@ -141,46 +142,42 @@ namespace Content.Server.GameObjects.Components.Construction
|
|||||||
sound.Play("/Audio/items/deconstruct.ogg", Transform.GridPosition);
|
sound.Play("/Audio/items/deconstruct.ogg", Transform.GridPosition);
|
||||||
return true;
|
return true;
|
||||||
case ConstructionStepTool toolStep:
|
case ConstructionStepTool toolStep:
|
||||||
|
if (!slapped.TryGetComponent<ToolComponent>(out var tool))
|
||||||
|
return false;
|
||||||
switch (toolStep.Tool)
|
switch (toolStep.Tool)
|
||||||
{
|
{
|
||||||
case ToolType.Crowbar:
|
case Tool.Crowbar:
|
||||||
if (slapped.HasComponent<CrowbarComponent>())
|
if (tool.Behavior == Tool.Crowbar)
|
||||||
{
|
{
|
||||||
sound.Play("/Audio/items/crowbar.ogg", Transform.GridPosition);
|
tool.PlayUseSound();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case ToolType.Welder:
|
case Tool.Welder:
|
||||||
if (slapped.TryGetComponent(out WelderComponent welder) && welder.TryUse(toolStep.Amount))
|
if (tool.Behavior == Tool.Welder && tool.TryWeld(toolStep.Amount))
|
||||||
{
|
{
|
||||||
if (_random.NextDouble() > 0.5)
|
tool.PlayUseSound();
|
||||||
sound.Play("/Audio/items/welder.ogg", Transform.GridPosition);
|
|
||||||
else
|
|
||||||
sound.Play("/Audio/items/welder2.ogg", Transform.GridPosition);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case ToolType.Wrench:
|
case Tool.Wrench:
|
||||||
if (slapped.HasComponent<WrenchComponent>())
|
if (tool.Behavior == Tool.Wrench)
|
||||||
{
|
{
|
||||||
sound.Play("/Audio/items/ratchet.ogg", Transform.GridPosition);
|
tool.PlayUseSound();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case ToolType.Screwdriver:
|
case Tool.Screwdriver:
|
||||||
if (slapped.HasComponent<ScrewdriverComponent>())
|
if (tool.Behavior == Tool.Screwdriver)
|
||||||
{
|
{
|
||||||
if (_random.NextDouble() > 0.5)
|
tool.PlayUseSound();
|
||||||
sound.Play("/Audio/items/screwdriver.ogg", Transform.GridPosition);
|
|
||||||
else
|
|
||||||
sound.Play("/Audio/items/screwdriver2.ogg", Transform.GridPosition);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case ToolType.Wirecutters:
|
case Tool.Wirecutter:
|
||||||
if (slapped.HasComponent<WirecutterComponent>())
|
if (tool.Behavior == Tool.Wirecutter)
|
||||||
{
|
{
|
||||||
sound.Play("/Audio/items/wirecutter.ogg", Transform.GridPosition);
|
tool.PlayUseSound();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Content.Server.GameObjects.Components.Interactable.Tools;
|
using Content.Server.GameObjects.Components.Interactable;
|
||||||
using Content.Server.GameObjects.Components.Power;
|
using Content.Server.GameObjects.Components.Power;
|
||||||
using Content.Server.GameObjects.Components.VendingMachines;
|
using Content.Server.GameObjects.Components.VendingMachines;
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
using Content.Server.Interfaces;
|
using Content.Server.Interfaces;
|
||||||
using Content.Shared.GameObjects.Components.Doors;
|
using Content.Shared.GameObjects.Components.Doors;
|
||||||
|
using Content.Shared.GameObjects.Components.Interactable;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.Interfaces.GameObjects;
|
using Robust.Server.Interfaces.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -200,27 +201,28 @@ namespace Content.Server.GameObjects.Components.Doors
|
|||||||
|
|
||||||
public bool AttackBy(AttackByEventArgs eventArgs)
|
public bool AttackBy(AttackByEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (eventArgs.AttackWith.HasComponent<CrowbarComponent>())
|
if (!eventArgs.AttackWith.TryGetComponent<ToolComponent>(out var tool))
|
||||||
{
|
return false;
|
||||||
if (IsPowered())
|
|
||||||
{
|
|
||||||
var notify = IoCManager.Resolve<IServerNotifyManager>();
|
|
||||||
notify.PopupMessage(Owner, eventArgs.User, "The powered motors block your efforts!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (State == DoorState.Closed)
|
if (tool.Behavior != Tool.Crowbar) return false;
|
||||||
{
|
|
||||||
Open();
|
if (IsPowered())
|
||||||
}
|
{
|
||||||
else if(State == DoorState.Open)
|
var notify = IoCManager.Resolve<IServerNotifyManager>();
|
||||||
{
|
notify.PopupMessage(Owner, eventArgs.User, "The powered motors block your efforts!");
|
||||||
Close();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if (State == DoorState.Closed)
|
||||||
|
{
|
||||||
|
Open();
|
||||||
|
}
|
||||||
|
else if(State == DoorState.Open)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,114 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
|
using Content.Shared.GameObjects.Components.Interactable;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.Serialization;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
|
namespace Content.Server.GameObjects.Components.Interactable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Not to be confused with Multitool (power)
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent]
|
||||||
|
public class MultiToolComponent : Component, IUse
|
||||||
|
{
|
||||||
|
public class ToolEntry : IExposeData
|
||||||
|
{
|
||||||
|
private string _state;
|
||||||
|
private string _sound;
|
||||||
|
private string _soundCollection;
|
||||||
|
private string _texture;
|
||||||
|
private string _sprite;
|
||||||
|
private string _changeSound;
|
||||||
|
|
||||||
|
public Tool Behavior { get; private set; }
|
||||||
|
public string State => _state;
|
||||||
|
public string Texture => _texture;
|
||||||
|
public string Sprite => _sprite;
|
||||||
|
public string Sound => _sound;
|
||||||
|
public string SoundCollection => _soundCollection;
|
||||||
|
public string ChangeSound => _changeSound;
|
||||||
|
|
||||||
|
public void ExposeData(ObjectSerializer serializer)
|
||||||
|
{
|
||||||
|
Behavior = (Tool)serializer.ReadStringEnumKey("behavior");
|
||||||
|
serializer.DataField(ref _state, "state", string.Empty);
|
||||||
|
serializer.DataField(ref _sprite, "sprite", string.Empty);
|
||||||
|
serializer.DataField(ref _texture, "texture", string.Empty);
|
||||||
|
serializer.DataField(ref _sound, "useSound", string.Empty);
|
||||||
|
serializer.DataField(ref _soundCollection, "useSoundCollection", string.Empty);
|
||||||
|
serializer.DataField(ref _changeSound, "changeSound", string.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private IEntitySystemManager _entitySystemManager;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
|
public override string Name => "MultiTool";
|
||||||
|
private List<ToolEntry> _tools;
|
||||||
|
private int _currentTool = 0;
|
||||||
|
|
||||||
|
private AudioSystem _audioSystem;
|
||||||
|
private ToolComponent _tool;
|
||||||
|
private SpriteComponent _sprite;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
Owner.TryGetComponent(out _tool);
|
||||||
|
Owner.TryGetComponent(out _sprite);
|
||||||
|
|
||||||
|
_audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>();
|
||||||
|
|
||||||
|
SetTool();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Cycle()
|
||||||
|
{
|
||||||
|
_currentTool = (_currentTool + 1) % _tools.Count;
|
||||||
|
SetTool();
|
||||||
|
var current = _tools[_currentTool];
|
||||||
|
if(!string.IsNullOrEmpty(current.ChangeSound))
|
||||||
|
_audioSystem.Play(current.ChangeSound, Owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetTool()
|
||||||
|
{
|
||||||
|
if (_tool == null) return;
|
||||||
|
|
||||||
|
var current = _tools[_currentTool];
|
||||||
|
|
||||||
|
_tool.UseSound = current.Sound;
|
||||||
|
_tool.UseSoundCollection = current.SoundCollection;
|
||||||
|
_tool.Behavior = current.Behavior;
|
||||||
|
|
||||||
|
if (_sprite == null) return;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(current.Texture))
|
||||||
|
if (!string.IsNullOrEmpty(current.Sprite))
|
||||||
|
_sprite.LayerSetState(0, current.State, current.Sprite);
|
||||||
|
else
|
||||||
|
_sprite.LayerSetState(0, current.State);
|
||||||
|
else
|
||||||
|
_sprite.LayerSetTexture(0, current.Texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
|
{
|
||||||
|
base.ExposeData(serializer);
|
||||||
|
serializer.DataField(ref _tools, "tools", new List<ToolEntry>());
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UseEntity(UseEntityEventArgs eventArgs)
|
||||||
|
{
|
||||||
|
Cycle();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,96 +1,37 @@
|
|||||||
// Only unused on .NET Core due to KeyValuePair.Deconstruct
|
// Only unused on .NET Core due to KeyValuePair.Deconstruct
|
||||||
// ReSharper disable once RedundantUsingDirective
|
// ReSharper disable once RedundantUsingDirective
|
||||||
|
|
||||||
|
using System;
|
||||||
using Content.Server.GameObjects.Components.Chemistry;
|
using Content.Server.GameObjects.Components.Chemistry;
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
|
using Content.Shared.Audio;
|
||||||
|
using Content.Shared.Chemistry;
|
||||||
|
using Content.Shared.GameObjects;
|
||||||
|
using Content.Shared.GameObjects.Components;
|
||||||
|
using Content.Shared.GameObjects.Components.Interactable;
|
||||||
using Content.Shared.Maps;
|
using Content.Shared.Maps;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.GameObjects.EntitySystems;
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Interfaces.Map;
|
using Robust.Shared.Interfaces.Map;
|
||||||
|
using Robust.Shared.Interfaces.Random;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Interactable
|
namespace Content.Server.GameObjects.Components.Interactable
|
||||||
{
|
{
|
||||||
public enum Tool : byte
|
[RegisterComponent]
|
||||||
|
public class ToolComponent : SharedToolComponent, IExamine, IAfterAttack, IUse, IAttack
|
||||||
{
|
{
|
||||||
Wrench,
|
|
||||||
Crowbar,
|
|
||||||
Screwdriver,
|
|
||||||
Wirecutters,
|
|
||||||
Welder,
|
|
||||||
Multitool,
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract class ToolComponent : Component, IExamine, IAfterAttack
|
|
||||||
{
|
|
||||||
#pragma warning disable 649
|
|
||||||
[Dependency] private IEntitySystemManager _entitySystemManager;
|
|
||||||
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
|
|
||||||
[Dependency] private readonly IMapManager _mapManager;
|
|
||||||
#pragma warning restore 649
|
|
||||||
|
|
||||||
private AudioSystem _audioSystem;
|
|
||||||
private InteractionSystem _interactionSystem;
|
|
||||||
private SolutionComponent
|
|
||||||
|
|
||||||
private Tool _behavior;
|
|
||||||
private bool _activated = false;
|
|
||||||
|
|
||||||
public override string Name => "Tool";
|
|
||||||
|
|
||||||
public Tool Behavior
|
|
||||||
{
|
|
||||||
get => _behavior;
|
|
||||||
set => _behavior = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
|
|
||||||
_audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>();
|
|
||||||
_interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void ExposeData(ObjectSerializer serializer)
|
|
||||||
{
|
|
||||||
base.ExposeData(serializer);
|
|
||||||
|
|
||||||
serializer.DataField(ref _behavior, "behavior", Tool.Wrench);
|
|
||||||
serializer.DataField(ref _speedModifier, "Speed", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Examine(FormattedMessage message)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// For tool interactions that have a delay before action this will modify the rate, time to wait is divided by this value
|
|
||||||
/// </summary>
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
|
||||||
public float SpeedModifier
|
|
||||||
{
|
|
||||||
get => _speedModifier;
|
|
||||||
set => _speedModifier = value;
|
|
||||||
}
|
|
||||||
private float _speedModifier = 1;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Status modifier which determines whether or not we can act as a tool at this time
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public virtual bool CanUse()
|
|
||||||
{
|
|
||||||
if (_behavior != Tool.Welder)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default Cost of using the welder fuel for an action
|
/// Default Cost of using the welder fuel for an action
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -99,22 +40,197 @@ namespace Content.Server.GameObjects.Components.Interactable
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rate at which we expunge fuel from ourselves when activated
|
/// Rate at which we expunge fuel from ourselves when activated
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const float FuelLossRate = 0.2f;
|
public const float FuelLossRate = 5f; // 0.2f
|
||||||
|
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private IEntitySystemManager _entitySystemManager;
|
||||||
|
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
|
||||||
|
[Dependency] private readonly IMapManager _mapManager;
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
||||||
|
[Dependency] private readonly IRobustRandom _robustRandom;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
|
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;
|
||||||
|
private string _useSound;
|
||||||
|
private string _useSoundCollection;
|
||||||
|
|
||||||
|
[ViewVariables]
|
||||||
|
public override Tool Behavior
|
||||||
|
{
|
||||||
|
get => _behavior;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_behavior = value;
|
||||||
|
Dirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[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>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public float SpeedModifier
|
||||||
|
{
|
||||||
|
get => _speedModifier;
|
||||||
|
set => _speedModifier = value;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Status of welder, whether it is ignited
|
/// Status of welder, whether it is ignited
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public bool Activated
|
public bool WelderLit
|
||||||
{
|
{
|
||||||
get => _activated;
|
get => _welderLit;
|
||||||
private set
|
private set
|
||||||
{
|
{
|
||||||
_activated = value;
|
_welderLit = value;
|
||||||
Dirty();
|
Dirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string UseSound
|
||||||
|
{
|
||||||
|
get => _useSound;
|
||||||
|
set => _useSound = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UseSoundCollection
|
||||||
|
{
|
||||||
|
get => _useSoundCollection;
|
||||||
|
set => _useSoundCollection = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
_audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>();
|
||||||
|
_interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
|
||||||
|
_toolSystem = _entitySystemManager.GetEntitySystem<ToolSystem>();
|
||||||
|
|
||||||
|
Owner.TryGetComponent(out _solutionComponent);
|
||||||
|
Owner.TryGetComponent(out _spriteComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
|
{
|
||||||
|
base.ExposeData(serializer);
|
||||||
|
|
||||||
|
serializer.DataField(ref _speedModifier, "speed", 1);
|
||||||
|
serializer.DataField(ref _useSound, "useSound", string.Empty);
|
||||||
|
serializer.DataField(ref _useSoundCollection, "useSoundCollection", string.Empty);
|
||||||
|
_behavior = (Tool)serializer.ReadStringEnumKey("behavior");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Status modifier which determines whether or not we can act as a tool at this time
|
||||||
|
/// </summary>
|
||||||
|
public 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));
|
||||||
|
|
||||||
|
Logger.Info(_solutionComponent.Solution.GetReagentQuantity("chem.WeldingFuel").ToString());
|
||||||
|
|
||||||
|
if (Fuel == 0)
|
||||||
|
{
|
||||||
|
ToggleWelderStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
Dirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PlaySoundCollection(string name, float volume=-5f)
|
||||||
|
{
|
||||||
|
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(name);
|
||||||
|
var file = _robustRandom.Pick(soundCollection.PickFiles);
|
||||||
|
_entitySystemManager.GetEntitySystem<AudioSystem>()
|
||||||
|
.Play(file, Owner, AudioParams.Default.WithVolume(volume));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayUseSound()
|
||||||
|
{
|
||||||
|
if(string.IsNullOrEmpty(UseSoundCollection))
|
||||||
|
_audioSystem.Play(UseSound, Owner);
|
||||||
|
else
|
||||||
|
PlaySoundCollection(UseSoundCollection, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override ComponentState GetComponentState()
|
||||||
|
{
|
||||||
|
return Behavior == Tool.Welder ? new ToolComponentState(FuelCapacity, Fuel, WelderLit) : new ToolComponentState(Behavior);
|
||||||
|
}
|
||||||
|
|
||||||
public void AfterAttack(AfterAttackEventArgs eventArgs)
|
public void AfterAttack(AfterAttackEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (Behavior != Tool.Crowbar)
|
if (Behavior != Tool.Crowbar)
|
||||||
@@ -134,11 +250,49 @@ namespace Content.Server.GameObjects.Components.Interactable
|
|||||||
|
|
||||||
var underplating = _tileDefinitionManager["underplating"];
|
var underplating = _tileDefinitionManager["underplating"];
|
||||||
mapGrid.SetTile(eventArgs.ClickLocation, new Tile(underplating.TileId));
|
mapGrid.SetTile(eventArgs.ClickLocation, new Tile(underplating.TileId));
|
||||||
_audioSystem.Play("/Audio/items/crowbar.ogg", Owner);
|
PlayUseSound();
|
||||||
|
|
||||||
//Actually spawn the relevant tile item at the right position and give it some offset to the corner.
|
//Actually spawn the relevant tile item at the right position and give it some offset to the corner.
|
||||||
var tileItem = Owner.EntityManager.SpawnEntity(tileDef.ItemDropPrototypeName, coordinates);
|
var tileItem = Owner.EntityManager.SpawnEntity(tileDef.ItemDropPrototypeName, coordinates);
|
||||||
tileItem.Transform.WorldPosition += (0.2f, 0.2f);
|
tileItem.Transform.WorldPosition += (0.2f, 0.2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool UseEntity(UseEntityEventArgs eventArgs)
|
||||||
|
{
|
||||||
|
Logger.Info(Behavior.ToString());
|
||||||
|
|
||||||
|
switch (Behavior)
|
||||||
|
{
|
||||||
|
case Tool.Welder:
|
||||||
|
return ToggleWelderStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
using Content.Server.GameObjects.EntitySystems;
|
|
||||||
using Content.Shared.Maps;
|
|
||||||
using Robust.Server.GameObjects.EntitySystems;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
|
||||||
using Robust.Shared.Interfaces.Map;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Map;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Interactable.Tools
|
|
||||||
{
|
|
||||||
[RegisterComponent]
|
|
||||||
public class CrowbarComponent : ToolComponent, IAfterAttack
|
|
||||||
{
|
|
||||||
#pragma warning disable 649
|
|
||||||
|
|
||||||
#pragma warning restore 649
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Tool that can be used to crowbar things apart, such as deconstructing
|
|
||||||
/// </summary>
|
|
||||||
public override string Name => "Crowbar";
|
|
||||||
|
|
||||||
public void AfterAttack(AfterAttackEventArgs eventArgs)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,217 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
|
||||||
using Content.Shared.Audio;
|
|
||||||
using Content.Shared.GameObjects;
|
|
||||||
using Content.Shared.GameObjects.Components;
|
|
||||||
using Robust.Server.GameObjects;
|
|
||||||
using Robust.Server.GameObjects.EntitySystems;
|
|
||||||
using Robust.Shared.Audio;
|
|
||||||
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.Prototypes;
|
|
||||||
using Robust.Shared.Random;
|
|
||||||
using Robust.Shared.Serialization;
|
|
||||||
using Robust.Shared.Utility;
|
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Interactable.Tools
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Tool used to weld metal together, light things on fire, or melt into constituent parts
|
|
||||||
/// </summary>
|
|
||||||
[RegisterComponent]
|
|
||||||
class WelderComponent : ToolComponent, IUse, IExamine
|
|
||||||
{
|
|
||||||
SpriteComponent spriteComponent;
|
|
||||||
|
|
||||||
#pragma warning disable 649
|
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
|
||||||
[Dependency] private readonly IRobustRandom _robustRandom;
|
|
||||||
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
|
|
||||||
#pragma warning restore 649
|
|
||||||
|
|
||||||
public override string Name => "Welder";
|
|
||||||
public override uint? NetID => ContentNetIDs.WELDER;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Maximum fuel capacity the welder can hold
|
|
||||||
/// </summary>
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
|
||||||
public float FuelCapacity
|
|
||||||
{
|
|
||||||
get => _fuelCapacity;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_fuelCapacity = value;
|
|
||||||
Dirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float _fuelCapacity = 50;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Fuel the welder has to do tasks
|
|
||||||
/// </summary>
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
|
||||||
public float Fuel
|
|
||||||
{
|
|
||||||
get => _fuel;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_fuel = value;
|
|
||||||
Dirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float _fuel = 0;
|
|
||||||
private bool _activated = false;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Default Cost of using the welder fuel for an action
|
|
||||||
/// </summary>
|
|
||||||
public const float DefaultFuelCost = 5;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Rate at which we expunge fuel from ourselves when activated
|
|
||||||
/// </summary>
|
|
||||||
public const float FuelLossRate = 0.2f;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Status of welder, whether it is ignited
|
|
||||||
/// </summary>
|
|
||||||
[ViewVariables]
|
|
||||||
public bool Activated
|
|
||||||
{
|
|
||||||
get => _activated;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
_activated = value;
|
|
||||||
Dirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//private string OnSprite { get; set; }
|
|
||||||
//private string OffSprite { get; set; }
|
|
||||||
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
|
|
||||||
spriteComponent = Owner.GetComponent<SpriteComponent>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void ExposeData(ObjectSerializer serializer)
|
|
||||||
{
|
|
||||||
base.ExposeData(serializer);
|
|
||||||
|
|
||||||
serializer.DataField(ref _fuelCapacity, "Capacity", 50);
|
|
||||||
serializer.DataField(ref _fuel, "Fuel", FuelCapacity);
|
|
||||||
serializer.DataField(ref _activated, "Activated", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnUpdate(float frameTime)
|
|
||||||
{
|
|
||||||
if (!Activated)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Fuel = Math.Max(Fuel - (FuelLossRate * frameTime), 0);
|
|
||||||
|
|
||||||
if (Fuel == 0)
|
|
||||||
{
|
|
||||||
ToggleStatus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TryUse(float value)
|
|
||||||
{
|
|
||||||
if (!Activated || !CanUse(value))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Fuel -= value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanUse(float value)
|
|
||||||
{
|
|
||||||
return Fuel > value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanUse()
|
|
||||||
{
|
|
||||||
return CanUse(DefaultFuelCost);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanActivate()
|
|
||||||
{
|
|
||||||
return Fuel > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool UseEntity(UseEntityEventArgs eventArgs)
|
|
||||||
{
|
|
||||||
return ToggleStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deactivates welding tool if active, activates welding tool if possible
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool ToggleStatus()
|
|
||||||
{
|
|
||||||
if (Activated)
|
|
||||||
{
|
|
||||||
Activated = false;
|
|
||||||
// Layer 1 is the flame.
|
|
||||||
spriteComponent.LayerSetVisible(1, false);
|
|
||||||
PlaySoundCollection("welder_off", -5);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (CanActivate())
|
|
||||||
{
|
|
||||||
Activated = true;
|
|
||||||
spriteComponent.LayerSetVisible(1, true);
|
|
||||||
PlaySoundCollection("welder_on", -5);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IExamine.Examine(FormattedMessage message)
|
|
||||||
{
|
|
||||||
var loc = IoCManager.Resolve<ILocalizationManager>();
|
|
||||||
if (Activated)
|
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PlaySoundCollection(string name, float volume)
|
|
||||||
{
|
|
||||||
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(name);
|
|
||||||
var file = _robustRandom.Pick(soundCollection.PickFiles);
|
|
||||||
_entitySystemManager.GetEntitySystem<AudioSystem>()
|
|
||||||
.Play(file, AudioParams.Default.WithVolume(volume));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override ComponentState GetComponentState()
|
|
||||||
{
|
|
||||||
return new WelderComponentState(FuelCapacity, Fuel, Activated);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.GameObjects.Components.Interactable.Tools;
|
using Content.Server.GameObjects.Components.Interactable;
|
||||||
using Content.Server.GameObjects.Components.Stack;
|
using Content.Server.GameObjects.Components.Stack;
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
|
using Content.Shared.GameObjects.Components.Interactable;
|
||||||
using Robust.Server.Interfaces.GameObjects;
|
using Robust.Server.Interfaces.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameObjects.Components.Transform;
|
using Robust.Shared.GameObjects.Components.Transform;
|
||||||
@@ -140,17 +141,16 @@ namespace Content.Server.GameObjects.Components.Power
|
|||||||
|
|
||||||
public bool AttackBy(AttackByEventArgs eventArgs)
|
public bool AttackBy(AttackByEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (eventArgs.AttackWith.TryGetComponent(out WirecutterComponent wirecutter))
|
if (!eventArgs.AttackWith.TryGetComponent(out ToolComponent tool)) return false;
|
||||||
{
|
if (tool.Behavior != Tool.Wirecutter) return false;
|
||||||
Owner.Delete();
|
|
||||||
var droppedEnt = Owner.EntityManager.SpawnEntity("CableStack", eventArgs.ClickLocation);
|
|
||||||
|
|
||||||
if (droppedEnt.TryGetComponent<StackComponent>(out var stackComp))
|
Owner.Delete();
|
||||||
stackComp.Count = 1;
|
var droppedEnt = Owner.EntityManager.SpawnEntity("CableStack", eventArgs.ClickLocation);
|
||||||
|
|
||||||
return true;
|
if (droppedEnt.TryGetComponent<StackComponent>(out var stackComp))
|
||||||
}
|
stackComp.Count = 1;
|
||||||
return false;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.GameObjects.Components.Interactable.Tools;
|
using Content.Server.GameObjects.Components.Interactable;
|
||||||
using Content.Server.GameObjects.Components.VendingMachines;
|
using Content.Server.GameObjects.Components.VendingMachines;
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
using Content.Server.Interfaces;
|
using Content.Server.Interfaces;
|
||||||
using Content.Server.Interfaces.GameObjects;
|
using Content.Server.Interfaces.GameObjects;
|
||||||
using Content.Shared.GameObjects.Components;
|
using Content.Shared.GameObjects.Components;
|
||||||
|
using Content.Shared.GameObjects.Components.Interactable;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.GameObjects.Components.UserInterface;
|
using Robust.Server.GameObjects.Components.UserInterface;
|
||||||
@@ -235,30 +236,31 @@ namespace Content.Server.GameObjects.Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var activeHandEntity = handsComponent.GetActiveHand?.Owner;
|
var activeHandEntity = handsComponent.GetActiveHand?.Owner;
|
||||||
|
activeHandEntity.TryGetComponent<ToolComponent>(out var tool);
|
||||||
switch (msg.Action)
|
switch (msg.Action)
|
||||||
{
|
{
|
||||||
case WiresAction.Cut:
|
case WiresAction.Cut:
|
||||||
if (activeHandEntity?.HasComponent<WirecutterComponent>() != true)
|
if (tool == null || tool.Behavior != Tool.Wirecutter)
|
||||||
{
|
{
|
||||||
_notifyManager.PopupMessage(Owner.Transform.GridPosition, player, _localizationManager.GetString("You need to hold a wirecutter in your hand!"));
|
_notifyManager.PopupMessage(Owner.Transform.GridPosition, player, _localizationManager.GetString("You need to hold a wirecutter in your hand!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_audioSystem.Play("/Audio/items/wirecutter.ogg", Owner);
|
tool.PlayUseSound();
|
||||||
wire.IsCut = true;
|
wire.IsCut = true;
|
||||||
UpdateUserInterface();
|
UpdateUserInterface();
|
||||||
break;
|
break;
|
||||||
case WiresAction.Mend:
|
case WiresAction.Mend:
|
||||||
if (activeHandEntity?.HasComponent<WirecutterComponent>() != true)
|
if (tool == null || tool.Behavior != Tool.Wirecutter)
|
||||||
{
|
{
|
||||||
_notifyManager.PopupMessage(Owner.Transform.GridPosition, player, _localizationManager.GetString("You need to hold a wirecutter in your hand!"));
|
_notifyManager.PopupMessage(Owner.Transform.GridPosition, player, _localizationManager.GetString("You need to hold a wirecutter in your hand!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_audioSystem.Play("/Audio/items/wirecutter.ogg", Owner);
|
tool.PlayUseSound();
|
||||||
wire.IsCut = false;
|
wire.IsCut = false;
|
||||||
UpdateUserInterface();
|
UpdateUserInterface();
|
||||||
break;
|
break;
|
||||||
case WiresAction.Pulse:
|
case WiresAction.Pulse:
|
||||||
if (activeHandEntity?.HasComponent<MultitoolComponent>() != true)
|
if (tool == null || tool.Behavior != Tool.Multitool)
|
||||||
{
|
{
|
||||||
_notifyManager.PopupMessage(Owner.Transform.GridPosition, player, _localizationManager.GetString("You need to hold a multitool in your hand!"));
|
_notifyManager.PopupMessage(Owner.Transform.GridPosition, player, _localizationManager.GetString("You need to hold a multitool in your hand!"));
|
||||||
return;
|
return;
|
||||||
@@ -288,10 +290,10 @@ namespace Content.Server.GameObjects.Components
|
|||||||
|
|
||||||
bool IAttackBy.AttackBy(AttackByEventArgs eventArgs)
|
bool IAttackBy.AttackBy(AttackByEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (!eventArgs.AttackWith.HasComponent<ScrewdriverComponent>())
|
if (!eventArgs.AttackWith.TryGetComponent<ToolComponent>(out var tool))
|
||||||
{
|
return false;
|
||||||
|
if (tool.Behavior != Tool.Screwdriver)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
IsPanelOpen = !IsPanelOpen;
|
IsPanelOpen = !IsPanelOpen;
|
||||||
IoCManager.Resolve<IEntitySystemManager>()
|
IoCManager.Resolve<IEntitySystemManager>()
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Server.GameObjects.Components.Interactable;
|
||||||
using Content.Server.GameObjects.Components.Mobs;
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
using Content.Server.GameObjects.Components.Timing;
|
using Content.Server.GameObjects.Components.Timing;
|
||||||
using Content.Server.Interfaces.GameObjects;
|
using Content.Server.Interfaces.GameObjects;
|
||||||
|
using Content.Shared.GameObjects.Components.Interactable;
|
||||||
using Content.Shared.GameObjects.Components.Inventory;
|
using Content.Shared.GameObjects.Components.Inventory;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
@@ -43,6 +46,129 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
public IEntity AttackWith { get; set; }
|
public IEntity AttackWith { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Tools
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface gives components behavior when being clicked on or "attacked" by a user with a tool in their hand
|
||||||
|
/// </summary>
|
||||||
|
public interface IToolAct
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Called when using a wrench on an entity
|
||||||
|
/// </summary>
|
||||||
|
bool ToolAct(ToolActEventArgs eventArgs) => false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ToolActEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public IEntity User { get; set; }
|
||||||
|
public GridCoordinates ClickLocation { get; set; }
|
||||||
|
public IEntity AttackWith { get; set; }
|
||||||
|
public ToolComponent ToolComponent => AttackWith.GetComponent<ToolComponent>();
|
||||||
|
public virtual Tool Behavior { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface gives components behavior when being clicked on or "attacked" by a user with a wrench in their hand
|
||||||
|
/// </summary>
|
||||||
|
public interface IWrenchAct : IToolAct
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Called when using a wrench on an entity
|
||||||
|
/// </summary>
|
||||||
|
bool WrenchAct(WrenchActEventArgs eventArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WrenchActEventArgs : ToolActEventArgs
|
||||||
|
{
|
||||||
|
public override Tool Behavior => Tool.Wrench;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface gives components behavior when being clicked on or "attacked" by a user with a crowbar in their hand
|
||||||
|
/// </summary>
|
||||||
|
public interface ICrowbarAct : IToolAct
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Called when using a wrench on an entity
|
||||||
|
/// </summary>
|
||||||
|
bool CrowbarAct(CrowbarActEventArgs eventArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CrowbarActEventArgs : ToolActEventArgs
|
||||||
|
{
|
||||||
|
public override Tool Behavior => Tool.Crowbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface gives components behavior when being clicked on or "attacked" by a user with a screwdriver in their hand
|
||||||
|
/// </summary>
|
||||||
|
public interface IScrewdriverAct
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Called when using a wrench on an entity
|
||||||
|
/// </summary>
|
||||||
|
bool ScrewdriverAct(ScrewdriverActEventArgs eventArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ScrewdriverActEventArgs : ToolActEventArgs
|
||||||
|
{
|
||||||
|
public override Tool Behavior => Tool.Screwdriver;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface gives components behavior when being clicked on or "attacked" by a user with a wirecutter in their hand
|
||||||
|
/// </summary>
|
||||||
|
public interface IWirecutterAct
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Called when using a wrench on an entity
|
||||||
|
/// </summary>
|
||||||
|
bool WirecutterAct(WirecutterActEventArgs eventArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WirecutterActEventArgs : ToolActEventArgs
|
||||||
|
{
|
||||||
|
public override Tool Behavior => Tool.Wirecutter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface gives components behavior when being clicked on or "attacked" by a user with a welder in their hand
|
||||||
|
/// </summary>
|
||||||
|
public interface IWelderAct
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Called when using a wrench on an entity
|
||||||
|
/// </summary>
|
||||||
|
bool WelderAct(WelderActEventArgs eventArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WelderActEventArgs : ToolActEventArgs
|
||||||
|
{
|
||||||
|
public override Tool Behavior => Tool.Welder;
|
||||||
|
public bool Lit { get; set; }
|
||||||
|
public float Fuel { get; set; }
|
||||||
|
public float FuelCapacity { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface gives components behavior when being clicked on or "attacked" by a user with a multitool in their hand
|
||||||
|
/// </summary>
|
||||||
|
public interface IMultitoolAct
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Called when using a wrench on an entity
|
||||||
|
/// </summary>
|
||||||
|
bool MultitoolAct(MultitoolActEventArgs eventArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MultitoolActEventArgs : ToolActEventArgs
|
||||||
|
{
|
||||||
|
public override Tool Behavior => Tool.Multitool;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This interface gives components behavior when being clicked on or "attacked" by a user with an empty hand
|
/// This interface gives components behavior when being clicked on or "attacked" by a user with an empty hand
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -561,9 +687,97 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
foreach (var attackBy in attackBys)
|
foreach (var attackBy in attackBys)
|
||||||
{
|
{
|
||||||
if (attackBy.AttackBy(attackByEventArgs))
|
if (attackBy.AttackBy(attackByEventArgs))
|
||||||
{
|
|
||||||
// If an AttackBy returns a status completion we finish our attack
|
// If an AttackBy returns a status completion we finish our attack
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We handle specific tools AttackBy here.
|
||||||
|
if (weapon.TryGetComponent<ToolComponent>(out var tool))
|
||||||
|
{
|
||||||
|
switch (tool.Behavior)
|
||||||
|
{
|
||||||
|
case Tool.Wrench:
|
||||||
|
var wrenchList = attacked.GetAllComponents<IWrenchAct>().ToList();
|
||||||
|
var wrenchAttackBy = new WrenchActEventArgs()
|
||||||
|
{ User = user, ClickLocation = clickLocation, AttackWith = weapon };
|
||||||
|
|
||||||
|
foreach (var comp in wrenchList)
|
||||||
|
{
|
||||||
|
if (comp.WrenchAct(wrenchAttackBy))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Tool.Crowbar:
|
||||||
|
var crowbarList = attacked.GetAllComponents<ICrowbarAct>().ToList();
|
||||||
|
var crowbarAttackBy = new CrowbarActEventArgs()
|
||||||
|
{ User = user, ClickLocation = clickLocation, AttackWith = weapon };
|
||||||
|
|
||||||
|
foreach (var comp in crowbarList)
|
||||||
|
{
|
||||||
|
if (comp.CrowbarAct(crowbarAttackBy))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Tool.Screwdriver:
|
||||||
|
var screwdriverList = attacked.GetAllComponents<IScrewdriverAct>().ToList();
|
||||||
|
var screwdriverAttackBy = new ScrewdriverActEventArgs()
|
||||||
|
{ User = user, ClickLocation = clickLocation, AttackWith = weapon };
|
||||||
|
|
||||||
|
foreach (var comp in screwdriverList)
|
||||||
|
{
|
||||||
|
if (comp.ScrewdriverAct(screwdriverAttackBy))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Tool.Wirecutter:
|
||||||
|
var wirecutterList = attacked.GetAllComponents<IWirecutterAct>().ToList();
|
||||||
|
var wirecutterAttackBy = new WirecutterActEventArgs()
|
||||||
|
{ User = user, ClickLocation = clickLocation, AttackWith = weapon };
|
||||||
|
|
||||||
|
foreach (var comp in wirecutterList)
|
||||||
|
{
|
||||||
|
if (comp.WirecutterAct(wirecutterAttackBy))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Tool.Welder:
|
||||||
|
var welderList = attacked.GetAllComponents<IWelderAct>().ToList();
|
||||||
|
var welderAttackBy = new WelderActEventArgs()
|
||||||
|
{
|
||||||
|
User = user, ClickLocation = clickLocation, AttackWith = weapon,
|
||||||
|
Fuel = tool.Fuel, FuelCapacity = tool.FuelCapacity
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var comp in welderList)
|
||||||
|
{
|
||||||
|
if (comp.WelderAct(welderAttackBy))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Tool.Multitool:
|
||||||
|
var multitoolList = attacked.GetAllComponents<IMultitoolAct>().ToList();
|
||||||
|
var multitoolAttackBy = new MultitoolActEventArgs()
|
||||||
|
{ User = user, ClickLocation = clickLocation, AttackWith = weapon };
|
||||||
|
|
||||||
|
foreach (var comp in multitoolList)
|
||||||
|
{
|
||||||
|
if (comp.MultitoolAct(multitoolAttackBy))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Content.Server.GameObjects.Components.Interactable;
|
using Content.Server.GameObjects.Components.Interactable;
|
||||||
using Content.Server.GameObjects.Components.Interactable.Tools;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems
|
namespace Content.Server.GameObjects.EntitySystems
|
||||||
@@ -13,9 +12,22 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
{
|
{
|
||||||
private readonly HashSet<ToolComponent> _activeWelders = new HashSet<ToolComponent>();
|
private readonly HashSet<ToolComponent> _activeWelders = new HashSet<ToolComponent>();
|
||||||
|
|
||||||
|
public bool Subscribe(ToolComponent welder)
|
||||||
|
{
|
||||||
|
return _activeWelders.Add(welder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Unsubscribe(ToolComponent welder)
|
||||||
|
{
|
||||||
|
return _activeWelders.Remove(welder);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
foreach (var tool in _activeWelders) ;
|
foreach (var tool in _activeWelders.ToArray())
|
||||||
|
{
|
||||||
|
tool.OnUpdate(frameTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Shared.GameObjects.Components.Interactable;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
@@ -138,7 +139,7 @@ namespace Content.Shared.Construction
|
|||||||
if (step.TryGetNode("tool", out node))
|
if (step.TryGetNode("tool", out node))
|
||||||
{
|
{
|
||||||
return new ConstructionStepTool(
|
return new ConstructionStepTool(
|
||||||
node.AsEnum<ConstructionStepTool.ToolType>(),
|
node.AsEnum<Tool>(),
|
||||||
amount
|
amount
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -190,21 +191,12 @@ namespace Content.Shared.Construction
|
|||||||
|
|
||||||
public class ConstructionStepTool : ConstructionStep
|
public class ConstructionStepTool : ConstructionStep
|
||||||
{
|
{
|
||||||
public readonly ToolType Tool;
|
public readonly Tool Tool;
|
||||||
|
|
||||||
public ConstructionStepTool(ToolType tool, int amount) : base(amount)
|
public ConstructionStepTool(Tool tool, int amount) : base(amount)
|
||||||
{
|
{
|
||||||
Tool = tool;
|
Tool = tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ToolType
|
|
||||||
{
|
|
||||||
Wrench,
|
|
||||||
Welder,
|
|
||||||
Screwdriver,
|
|
||||||
Crowbar,
|
|
||||||
Wirecutters,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ConstructionStepMaterial : ConstructionStep
|
public class ConstructionStepMaterial : ConstructionStep
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
|
namespace Content.Shared.GameObjects.Components.Interactable
|
||||||
|
{
|
||||||
|
public enum Tool : byte
|
||||||
|
{
|
||||||
|
Wrench,
|
||||||
|
Crowbar,
|
||||||
|
Screwdriver,
|
||||||
|
Wirecutter,
|
||||||
|
Welder,
|
||||||
|
Multitool,
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SharedToolComponent : Component
|
||||||
|
{
|
||||||
|
public override string Name => "Tool";
|
||||||
|
public override uint? NetID => ContentNetIDs.TOOL;
|
||||||
|
|
||||||
|
public virtual Tool Behavior { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[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)
|
||||||
|
{
|
||||||
|
FuelCapacity = fuelCapacity;
|
||||||
|
Fuel = fuel;
|
||||||
|
Activated = activated;
|
||||||
|
Behavior = Tool.Welder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Serialization;
|
|
||||||
|
|
||||||
namespace Content.Shared.GameObjects.Components
|
|
||||||
{
|
|
||||||
[NetSerializable, Serializable]
|
|
||||||
public class WelderComponentState : ComponentState
|
|
||||||
{
|
|
||||||
public float FuelCapacity { get; }
|
|
||||||
public float Fuel { get; }
|
|
||||||
public bool Activated { get; }
|
|
||||||
|
|
||||||
public WelderComponentState(float fuelCapacity, float fuel, bool activated) : base(ContentNetIDs.WELDER)
|
|
||||||
{
|
|
||||||
FuelCapacity = fuelCapacity;
|
|
||||||
Fuel = fuel;
|
|
||||||
Activated = activated;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
public const uint GALACTIC_MARKET = 1031;
|
public const uint GALACTIC_MARKET = 1031;
|
||||||
public const uint HUMANOID_APPEARANCE = 1032;
|
public const uint HUMANOID_APPEARANCE = 1032;
|
||||||
public const uint INSTRUMENTS = 1033;
|
public const uint INSTRUMENTS = 1033;
|
||||||
public const uint WELDER = 1034;
|
public const uint TOOL = 1034;
|
||||||
public const uint STACK = 1035;
|
public const uint STACK = 1035;
|
||||||
public const uint HANDHELD_LIGHT = 1036;
|
public const uint HANDHELD_LIGHT = 1036;
|
||||||
public const uint PAPER = 1037;
|
public const uint PAPER = 1037;
|
||||||
|
|||||||
BIN
Resources/Audio/items/change_drill.ogg
Normal file
BIN
Resources/Audio/items/change_drill.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/items/change_jaws.ogg
Normal file
BIN
Resources/Audio/items/change_jaws.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/items/drill_hit.ogg
Normal file
BIN
Resources/Audio/items/drill_hit.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/items/drill_use.ogg
Normal file
BIN
Resources/Audio/items/drill_use.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/items/jaws_cut.ogg
Normal file
BIN
Resources/Audio/items/jaws_cut.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/items/jaws_pry.ogg
Normal file
BIN
Resources/Audio/items/jaws_pry.ogg
Normal file
Binary file not shown.
@@ -20,7 +20,7 @@
|
|||||||
- type: Computer
|
- type: Computer
|
||||||
- type: PowerDevice
|
- type: PowerDevice
|
||||||
priority: High
|
priority: High
|
||||||
- type: Wrenchable
|
- type: Anchorable
|
||||||
|
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Buildings/computer.rsi
|
sprite: Buildings/computer.rsi
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
- type: PowerDevice
|
- type: PowerDevice
|
||||||
priority: Low
|
priority: Low
|
||||||
- type: Wires
|
- type: Wires
|
||||||
- type: Wrenchable
|
- type: Anchorable
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: VendingMachine
|
parent: VendingMachine
|
||||||
|
|||||||
@@ -116,7 +116,7 @@
|
|||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
- type: PowerChargerVisualizer2D
|
- type: PowerChargerVisualizer2D
|
||||||
- type: Wrenchable
|
- type: Anchorable
|
||||||
- type: Physics
|
- type: Physics
|
||||||
mass: 5
|
mass: 5
|
||||||
- type: Clickable
|
- type: Clickable
|
||||||
@@ -148,7 +148,7 @@
|
|||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
- type: PowerChargerVisualizer2D
|
- type: PowerChargerVisualizer2D
|
||||||
- type: Wrenchable
|
- type: Anchorable
|
||||||
- type: Physics
|
- type: Physics
|
||||||
mass: 5
|
mass: 5
|
||||||
- type: Clickable
|
- type: Clickable
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
- type: ItemCooldown
|
- type: ItemCooldown
|
||||||
- type: MeleeWeapon
|
- type: MeleeWeapon
|
||||||
- type: Tool
|
- type: Tool
|
||||||
behavior: enum.Tool.Wirecutter
|
behavior: enum.Tool.Wirecutter
|
||||||
|
useSound: /Audio/items/wirecutter.ogg
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: Screwdriver
|
name: Screwdriver
|
||||||
@@ -30,7 +31,8 @@
|
|||||||
- type: ItemCooldown
|
- type: ItemCooldown
|
||||||
- type: MeleeWeapon
|
- type: MeleeWeapon
|
||||||
- type: Tool
|
- type: Tool
|
||||||
behavior: enum.Tool.Screwdriver
|
behavior: enum.Tool.Screwdriver
|
||||||
|
useSoundCollection: Screwdriver
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: Welding Tool
|
name: Welding Tool
|
||||||
@@ -51,8 +53,16 @@
|
|||||||
- type: ItemCooldown
|
- type: ItemCooldown
|
||||||
- type: MeleeWeapon
|
- type: MeleeWeapon
|
||||||
- type: ItemStatus
|
- type: ItemStatus
|
||||||
|
- type: Solution
|
||||||
|
maxVol: 50
|
||||||
|
caps: 9
|
||||||
|
contents:
|
||||||
|
reagents:
|
||||||
|
- ReagentId: chem.WeldingFuel
|
||||||
|
Quantity: 50
|
||||||
- type: Tool
|
- type: Tool
|
||||||
behavior: enum.Tool.Screwdriver
|
behavior: enum.Tool.Welder
|
||||||
|
useSoundCollection: Welder
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: Wrench
|
name: Wrench
|
||||||
@@ -67,7 +77,8 @@
|
|||||||
- type: ItemCooldown
|
- type: ItemCooldown
|
||||||
- type: MeleeWeapon
|
- type: MeleeWeapon
|
||||||
- type: Tool
|
- type: Tool
|
||||||
behavior: enum.Tool.Wrench
|
behavior: enum.Tool.Wrench
|
||||||
|
useSound: /Audio/items/ratchet.ogg
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: Crowbar
|
name: Crowbar
|
||||||
@@ -82,7 +93,8 @@
|
|||||||
- type: ItemCooldown
|
- type: ItemCooldown
|
||||||
- type: MeleeWeapon
|
- type: MeleeWeapon
|
||||||
- type: Tool
|
- type: Tool
|
||||||
behavior: enum.Tool.Crowbar
|
behavior: enum.Tool.Crowbar
|
||||||
|
useSound: /Audio/items/crowbar.ogg
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: Multitool
|
name: Multitool
|
||||||
@@ -99,4 +111,60 @@
|
|||||||
- type: Item
|
- type: Item
|
||||||
sprite: Objects/Tools/multitool.rsi
|
sprite: Objects/Tools/multitool.rsi
|
||||||
- type: Tool
|
- type: Tool
|
||||||
behavior: enum.Tool.Multitool
|
behavior: enum.Tool.Multitool
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
name: Jaws of life
|
||||||
|
parent: BaseItem
|
||||||
|
id: JawsOfLife
|
||||||
|
description: A set of jaws of life, compressed through the magic of science.
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Objects/Tools/jaws_of_life.rsi
|
||||||
|
state: jaws_pry
|
||||||
|
- type: Icon
|
||||||
|
sprite: Objects/Tools/jaws_of_life.rsi
|
||||||
|
state: jaws_pry
|
||||||
|
- type: Item
|
||||||
|
sprite: Objects/Tools/jaws_of_life.rsi
|
||||||
|
- type: Tool
|
||||||
|
behavior: enum.Tool.Crowbar
|
||||||
|
statusShowBehavior: true
|
||||||
|
- type: MultiTool
|
||||||
|
tools:
|
||||||
|
- behavior: enum.Tool.Crowbar
|
||||||
|
state: jaws_pry
|
||||||
|
useSound: /Audio/items/jaws_pry.ogg
|
||||||
|
changeSound: /Audio/items/change_jaws.ogg
|
||||||
|
- behavior: enum.Tool.Wirecutter
|
||||||
|
state: jaws_cutter
|
||||||
|
useSound: /Audio/items/jaws_cut.ogg
|
||||||
|
changeSound: /Audio/items/change_jaws.ogg
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
name: Power Drill
|
||||||
|
parent: BaseItem
|
||||||
|
id: PowerDrill
|
||||||
|
description: A simple powered hand drill.
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Objects/Tools/drill.rsi
|
||||||
|
state: drill_screw
|
||||||
|
- type: Icon
|
||||||
|
sprite: Objects/Tools/drill.rsi
|
||||||
|
state: drill_screw
|
||||||
|
- type: Item
|
||||||
|
sprite: Objects/Tools/drill.rsi
|
||||||
|
- type: Tool
|
||||||
|
behavior: enum.Tool.Screwdriver
|
||||||
|
statusShowBehavior: true
|
||||||
|
- type: MultiTool
|
||||||
|
tools:
|
||||||
|
- behavior: enum.Tool.Screwdriver
|
||||||
|
state: drill_screw
|
||||||
|
useSound: /Audio/items/drill_use.ogg
|
||||||
|
changeSound: /Audio/items/change_drill.ogg
|
||||||
|
- behavior: enum.Tool.Wrench
|
||||||
|
state: drill_bolt
|
||||||
|
useSound: /Audio/items/drill_use.ogg
|
||||||
|
changeSound: /Audio/items/change_drill.ogg
|
||||||
|
|||||||
@@ -105,3 +105,9 @@
|
|||||||
name: Unstable Mutagen
|
name: Unstable Mutagen
|
||||||
desc: Causes mutations when injected into living people or plants. High doses may be lethal, especially in humans.
|
desc: Causes mutations when injected into living people or plants. High doses may be lethal, especially in humans.
|
||||||
color: "#77b58e"
|
color: "#77b58e"
|
||||||
|
|
||||||
|
- type: reagent
|
||||||
|
id: chem.WeldingFuel
|
||||||
|
name: Welding Fuel
|
||||||
|
desc: Used by welders to weld.
|
||||||
|
color: "#a76b1c"
|
||||||
|
|||||||
@@ -8,3 +8,15 @@
|
|||||||
id: WelderOff
|
id: WelderOff
|
||||||
files:
|
files:
|
||||||
- /Audio/effects/zzzt.ogg
|
- /Audio/effects/zzzt.ogg
|
||||||
|
|
||||||
|
- type: soundCollection
|
||||||
|
id: Welder
|
||||||
|
files:
|
||||||
|
- /Audio/items/welder.ogg
|
||||||
|
- /Audio/items/welder2.ogg
|
||||||
|
|
||||||
|
- type: soundCollection
|
||||||
|
id: Screwdriver
|
||||||
|
files:
|
||||||
|
- /Audio/items/screwdriver.ogg
|
||||||
|
- /Audio/items/screwdriver2.ogg
|
||||||
|
|||||||
BIN
Resources/Textures/Objects/Tools/drill.rsi/drill_bolt.png
Normal file
BIN
Resources/Textures/Objects/Tools/drill.rsi/drill_bolt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 839 B |
BIN
Resources/Textures/Objects/Tools/drill.rsi/drill_screw.png
Normal file
BIN
Resources/Textures/Objects/Tools/drill.rsi/drill_screw.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 831 B |
1
Resources/Textures/Objects/Tools/drill.rsi/meta.json
Normal file
1
Resources/Textures/Objects/Tools/drill.rsi/meta.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC BY-SA 3.0", "copyright": "Taken from https://github.com/tgstation/tgstation at commit ea59fb4b810decbb5996b36d8876614b57c3d189", "states": [{"name": "drill_bolt", "directions": 1, "delays": [[1.0]]}, {"name": "drill_screw", "directions": 1, "delays": [[1.0]]}]}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 667 B |
BIN
Resources/Textures/Objects/Tools/jaws_of_life.rsi/jaws_pry.png
Normal file
BIN
Resources/Textures/Objects/Tools/jaws_of_life.rsi/jaws_pry.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 644 B |
@@ -0,0 +1 @@
|
|||||||
|
{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC BY-SA 3.0", "copyright": "Taken from https://github.com/tgstation/tgstation at commit ea59fb4b810decbb5996b36d8876614b57c3d189", "states": [{"name": "jaws_cutter", "directions": 1, "delays": [[1.0]]}, {"name": "jaws_pry", "directions": 1, "delays": [[1.0]]}]}
|
||||||
Submodule RobustToolbox updated: 7c4b1af967...b366070cd4
@@ -56,4 +56,5 @@
|
|||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Soundfont/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Soundfont/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=soundfonts/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=soundfonts/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=swsl/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=swsl/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=underplating/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=underplating/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Wirecutter/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||||
|
|||||||
Reference in New Issue
Block a user