Locks update (#501)

* massive code refactor

* fix

* ftl fix

* rider pet pet

* hacking doAfter

* Update SharedCP14LockKeySystem.cs

* optimization

* Update migration.yml

* Update migration.yml
This commit is contained in:
Ed
2024-10-21 14:20:05 +03:00
committed by GitHub
parent 8c06677ff4
commit 41d3ccab8b
14 changed files with 217 additions and 406 deletions

View File

@@ -15,8 +15,6 @@ public sealed partial class CP14KeyholeGenerationSystem : EntitySystem
private Dictionary<ProtoId<CP14LockCategoryPrototype>, List<int>> _roundKeyData = new();
private const int DepthCompexity = 2;
public override void Initialize()
{
base.Initialize();
@@ -75,32 +73,29 @@ public sealed partial class CP14KeyholeGenerationSystem : EntitySystem
{
if (_roundKeyData.ContainsKey(category))
return _roundKeyData[category];
else
{
var newData = GenerateNewUniqueLockData(category);
_roundKeyData[category] = newData;
return newData;
}
var newData = GenerateNewUniqueLockData(category);
_roundKeyData[category] = newData;
return newData;
}
private List<int> GenerateNewUniqueLockData(ProtoId<CP14LockCategoryPrototype> category)
{
List<int> newKeyData = new List<int>();
List<int> newKeyData = new();
var categoryData = _proto.Index(category);
var ready = false;
var iteration = 0;
while (!ready)
while (true)
{
//Generate try
newKeyData = new List<int>();
for (int i = 0; i < categoryData.Complexity; i++)
for (var i = 0; i < categoryData.Complexity; i++)
{
newKeyData.Add(_random.Next(-DepthCompexity, DepthCompexity));
newKeyData.Add(_random.Next(-SharedCP14LockKeySystem.DepthComplexity, SharedCP14LockKeySystem.DepthComplexity));
}
//Identity Check shitcode
// На текущий момент он пытается сгенерировать уникальный код. Если он 100 раз не смог сгенерировать уникальный код, он выдаст последний сгенерированный неуникальный.
// Identity Check shit code
// It is currently trying to generate a unique code. If it fails to generate a unique code 100 times, it will output the last generated non-unique code.
var unique = true;
foreach (var pair in _roundKeyData)
{