Files
tbd-station-14/Content.Shared/Tool/SharedToolComponent.cs
Acruid 59e5cc5e3c Remove Static Component NetIds (#4247)
* Remove the unnecessary NetID property from ComponentState.

* Remove Component.NetworkSynchronizeExistence.

* Removed Component.NetID.

* Adds component netID automatic generation.

* Removed NetIdAttribute from serverside components with no corresponding clientside registration.

* Completely remove static NetIds.

* Renamed NetIDAttribute to NetworkedComponentAttribute.

* Add GenerateNetIds calls to client and server entry points.
Add test to make sure auto generated NetIds are identical.

* Component changes when rebasing that I am too lazy to rewrite into the branch.

Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
2021-07-12 10:32:10 +02:00

72 lines
1.9 KiB
C#

#nullable enable
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.Tool
{
[Flags]
public enum ToolQuality : byte
{
None = 0,
Anchoring = 1,
Prying = 1 << 1,
Screwing = 1 << 2,
Cutting = 1 << 3,
Welding = 1 << 4,
Multitool = 1 << 5,
}
public static class ToolQualityHelpers
{
public static string GetToolName(this ToolQuality quality)
{
return quality switch
{
ToolQuality.Anchoring => "Wrench",
ToolQuality.Prying => "Crowbar",
ToolQuality.Screwing => "Screwdriver",
ToolQuality.Cutting => "Wirecutters",
ToolQuality.Welding => "Welding tool",
ToolQuality.Multitool => "Multitool",
_ => throw new ArgumentOutOfRangeException()
};
}
}
public class SharedToolComponent : Component
{
public override string Name => "Tool";
public virtual ToolQuality Qualities { get; set; }
}
[NetSerializable, Serializable]
public class MultiToolComponentState : ComponentState
{
public ToolQuality Quality { get; }
public MultiToolComponentState(ToolQuality quality)
{
Quality = quality;
}
}
[NetSerializable, Serializable]
public class WelderComponentState : ComponentState
{
public float FuelCapacity { get; }
public float Fuel { get; }
public bool Activated { get; }
public ToolQuality Quality { get; }
public WelderComponentState(float fuelCapacity, float fuel, bool activated)
{
FuelCapacity = fuelCapacity;
Fuel = fuel;
Activated = activated;
Quality = ToolQuality.Welding;
}
}
}