2020-05-27 15:09:22 +02:00
|
|
|
using System.Collections.Generic;
|
2021-03-16 15:50:20 +01:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2020-10-14 22:45:53 +02:00
|
|
|
using Content.Shared.GameTicking;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-05-27 15:09:22 +02:00
|
|
|
using Robust.Shared.ViewVariables;
|
2021-06-09 22:19:39 +02:00
|
|
|
using static Content.Shared.Wires.SharedWiresComponent;
|
2020-05-27 15:09:22 +02:00
|
|
|
|
2021-07-04 18:11:52 +02:00
|
|
|
namespace Content.Server.WireHacking
|
2020-05-27 15:09:22 +02:00
|
|
|
{
|
2021-06-29 15:56:07 +02:00
|
|
|
public class WireHackingSystem : EntitySystem
|
2020-05-27 15:09:22 +02:00
|
|
|
{
|
|
|
|
|
[ViewVariables] private readonly Dictionary<string, WireLayout> _layouts =
|
2020-11-27 11:00:49 +01:00
|
|
|
new();
|
2020-05-27 15:09:22 +02:00
|
|
|
|
2021-11-11 20:48:12 +11:00
|
|
|
public const float ScrewTime = 2.5f;
|
|
|
|
|
|
2021-06-29 15:56:07 +02:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-16 15:50:20 +01:00
|
|
|
public bool TryGetLayout(string id, [NotNullWhen(true)] out WireLayout? layout)
|
2020-05-27 15:09:22 +02:00
|
|
|
{
|
|
|
|
|
return _layouts.TryGetValue(id, out layout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddLayout(string id, WireLayout layout)
|
|
|
|
|
{
|
|
|
|
|
_layouts.Add(id, layout);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-29 15:56:07 +02:00
|
|
|
public void Reset(RoundRestartCleanupEvent ev)
|
2020-05-27 15:09:22 +02:00
|
|
|
{
|
|
|
|
|
_layouts.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public sealed class WireLayout
|
|
|
|
|
{
|
|
|
|
|
[ViewVariables] public IReadOnlyDictionary<object, WireData> Specifications { get; }
|
|
|
|
|
|
|
|
|
|
public WireLayout(IReadOnlyDictionary<object, WireData> specifications)
|
|
|
|
|
{
|
|
|
|
|
Specifications = specifications;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public sealed class WireData
|
|
|
|
|
{
|
|
|
|
|
public WireLetter Letter { get; }
|
|
|
|
|
public WireColor Color { get; }
|
|
|
|
|
public int Position { get; }
|
|
|
|
|
|
|
|
|
|
public WireData(WireLetter letter, WireColor color, int position)
|
|
|
|
|
{
|
|
|
|
|
Letter = letter;
|
|
|
|
|
Color = color;
|
|
|
|
|
Position = position;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|