Key distribution system (#625)

* data restruct

* yay

* Update arenas.yml

* fixes

* auto labeling

* shuffle
This commit is contained in:
Ed
2024-12-03 12:34:07 +03:00
committed by GitHub
parent 7e6e4709c4
commit f6630e1ec9
40 changed files with 1262 additions and 724 deletions

View File

@@ -1,4 +1,5 @@
using System.Linq;
using Content.Server.Labels;
using Content.Shared._CP14.LockKey;
using Content.Shared._CP14.LockKey.Components;
using Content.Shared.Examine;
@@ -12,8 +13,9 @@ public sealed partial class CP14KeyholeGenerationSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly LabelSystem _label = default!;
private Dictionary<ProtoId<CP14LockCategoryPrototype>, List<int>> _roundKeyData = new();
private Dictionary<ProtoId<CP14LockTypePrototype>, List<int>> _roundKeyData = new();
public override void Initialize()
{
@@ -37,7 +39,7 @@ public sealed partial class CP14KeyholeGenerationSystem : EntitySystem
{
if (keyEnt.Comp.AutoGenerateShape != null)
{
keyEnt.Comp.LockShape = GetKeyLockData(keyEnt.Comp.AutoGenerateShape.Value);
SetShape(keyEnt, keyEnt.Comp.AutoGenerateShape.Value);
}
}
@@ -45,7 +47,7 @@ public sealed partial class CP14KeyholeGenerationSystem : EntitySystem
{
if (lockEnt.Comp.AutoGenerateShape != null)
{
lockEnt.Comp.LockShape = GetKeyLockData(lockEnt.Comp.AutoGenerateShape.Value);
SetShape(lockEnt, lockEnt.Comp.AutoGenerateShape.Value);
}
}
#endregion
@@ -69,7 +71,7 @@ public sealed partial class CP14KeyholeGenerationSystem : EntitySystem
args.PushMarkup(markup);
}
private List<int> GetKeyLockData(ProtoId<CP14LockCategoryPrototype> category)
private List<int> GetKeyLockData(ProtoId<CP14LockTypePrototype> category)
{
if (_roundKeyData.ContainsKey(category))
return _roundKeyData[category];
@@ -79,7 +81,25 @@ public sealed partial class CP14KeyholeGenerationSystem : EntitySystem
return newData;
}
private List<int> GenerateNewUniqueLockData(ProtoId<CP14LockCategoryPrototype> category)
public void SetShape(Entity<CP14KeyComponent> keyEnt, ProtoId<CP14LockTypePrototype> type)
{
keyEnt.Comp.LockShape = GetKeyLockData(type);
var indexedType = _proto.Index(type);
if (indexedType.Name is not null)
_label.Label(keyEnt, Loc.GetString(indexedType.Name.Value));
}
public void SetShape(Entity<CP14LockComponent> lockEnt, ProtoId<CP14LockTypePrototype> type)
{
lockEnt.Comp.LockShape = GetKeyLockData(type);
var indexedType = _proto.Index(type);
if (indexedType.Name is not null)
_label.Label(lockEnt, Loc.GetString(indexedType.Name.Value));
}
private List<int> GenerateNewUniqueLockData(ProtoId<CP14LockTypePrototype> category)
{
List<int> newKeyData = new();
var categoryData = _proto.Index(category);