Finish refactoring tools. Add multitools. (as in multiple tools in one)

This commit is contained in:
zumorica
2020-04-29 13:43:07 +02:00
parent ca5638badf
commit ff5549a0d1
37 changed files with 840 additions and 467 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Shared.GameObjects.Components.Interactable;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
@@ -138,7 +139,7 @@ namespace Content.Shared.Construction
if (step.TryGetNode("tool", out node))
{
return new ConstructionStepTool(
node.AsEnum<ConstructionStepTool.ToolType>(),
node.AsEnum<Tool>(),
amount
);
}
@@ -190,21 +191,12 @@ namespace Content.Shared.Construction
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;
}
public enum ToolType
{
Wrench,
Welder,
Screwdriver,
Crowbar,
Wirecutters,
}
}
public class ConstructionStepMaterial : ConstructionStep

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -36,7 +36,7 @@
public const uint GALACTIC_MARKET = 1031;
public const uint HUMANOID_APPEARANCE = 1032;
public const uint INSTRUMENTS = 1033;
public const uint WELDER = 1034;
public const uint TOOL = 1034;
public const uint STACK = 1035;
public const uint HANDHELD_LIGHT = 1036;
public const uint PAPER = 1037;