Files
SVSimServer/SVSim.BattleEngine/Engine/Wizard/AIVariableResultContainer.cs
gamer147 0d9d8acae0 feat(battle-engine): M1 auto-copy closure (782 battle-logic files)
Compile-driven bulk-copy loop (tools/engine-port/m1_copy_loop.py) pulled the precise reference closure of the battle-core roots, stopping at the classify god-object/View-VFX-UI boundary. 782 files; no re-explosion (M0 had estimated ~order 1000). Residual frontier = 52 shim-classified + 80 external (Unity/BCL) types to author next.
2026-06-05 16:57:20 -04:00

65 lines
1.6 KiB
C#

using System.Collections.Generic;
namespace Wizard;
public class AIVariableResultContainer
{
private Dictionary<AIScriptTokenVariableType, Dictionary<ulong, float>> _variableResultDic;
public AIVariableResultContainer()
{
_variableResultDic = new Dictionary<AIScriptTokenVariableType, Dictionary<ulong, float>>();
}
public void Clear()
{
foreach (AIScriptTokenVariableType key in _variableResultDic.Keys)
{
_variableResultDic[key].Clear();
}
_variableResultDic.Clear();
}
private void AddRecord(AIScriptTokenVariableType valType, ulong hash, float result)
{
if (!_variableResultDic.TryGetValue(valType, out var value))
{
value = new Dictionary<ulong, float>();
_variableResultDic.Add(valType, value);
}
if (value.ContainsKey(hash))
{
AIConsoleUtility.LogError($"AIFunctionResultContainer.AddRecord() error!! conflict key = {hash}");
}
else
{
value.Add(hash, result);
}
}
public bool GetContainsResultValue(AIScriptTokenVariableType valType, ulong hash, out float getResult)
{
if (_variableResultDic.TryGetValue(valType, out var value))
{
return value.TryGetValue(hash, out getResult);
}
getResult = 0f;
return false;
}
public void CheckDuplicateAndAddRecord(AIScriptTokenVariableType type, ulong hash, float result, string errorMessage)
{
if (GetContainsResultValue(type, hash, out var getResult))
{
if (errorMessage != null && errorMessage != "" && getResult != result)
{
AIConsoleUtility.LogError(errorMessage);
}
}
else
{
AddRecord(type, hash, result);
}
}
}