Урны-логисты не входят в лимит урн
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
38a8b3b417
commit
bf334c5c44
@@ -114,7 +114,7 @@ namespace NecromancerTome
|
||||
}
|
||||
if (ConnectionManager.Instance.IsServer)
|
||||
{
|
||||
CinerariumRegistry.Add(_blockPos, Parent?.Owner);
|
||||
CinerariumRegistry.Add(_blockPos, Parent?.Owner, _logist);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -758,6 +758,10 @@ namespace NecromancerTome
|
||||
{
|
||||
return "necroCinerariumOverlap";
|
||||
}
|
||||
if (IsLogistBlock(_placing))
|
||||
{
|
||||
return null; // логисты в лимит не входят (16.10, пользователь)
|
||||
}
|
||||
World world = GameManager.Instance?.World;
|
||||
EntityPlayerLocal player = world?.GetPrimaryPlayer();
|
||||
// Реестр живёт на сервере; клиент в сети лимит не проверяет (мультиплеер поддержан не полностью).
|
||||
@@ -778,6 +782,8 @@ namespace NecromancerTome
|
||||
{
|
||||
const string FileName = "NecroCinerariums.txt";
|
||||
static Dictionary<Vector3i, string> _urns;
|
||||
/// <summary>Логисты (третье поле строки «L»): в лимит не входят.</summary>
|
||||
static HashSet<Vector3i> _logists = new HashSet<Vector3i>();
|
||||
static string _dir;
|
||||
|
||||
static string FilePath => Path.Combine(GameIO.GetSaveGameDir(), FileName);
|
||||
@@ -791,6 +797,7 @@ namespace NecromancerTome
|
||||
}
|
||||
_dir = dir;
|
||||
_urns = new Dictionary<Vector3i, string>();
|
||||
_logists = new HashSet<Vector3i>();
|
||||
try
|
||||
{
|
||||
if (File.Exists(FilePath))
|
||||
@@ -802,6 +809,10 @@ namespace NecromancerTome
|
||||
if (xyz.Length == 3 && int.TryParse(xyz[0], out int x) && int.TryParse(xyz[1], out int y) && int.TryParse(xyz[2], out int z))
|
||||
{
|
||||
_urns[new Vector3i(x, y, z)] = parts.Length > 1 ? parts[1] : "";
|
||||
if (parts.Length > 2 && parts[2] == "L")
|
||||
{
|
||||
_logists.Add(new Vector3i(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -820,7 +831,12 @@ namespace NecromancerTome
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (KeyValuePair<Vector3i, string> kv in Urns())
|
||||
{
|
||||
sb.Append(kv.Key.x).Append(',').Append(kv.Key.y).Append(',').Append(kv.Key.z).Append('|').Append(kv.Value).Append('\n');
|
||||
sb.Append(kv.Key.x).Append(',').Append(kv.Key.y).Append(',').Append(kv.Key.z).Append('|').Append(kv.Value);
|
||||
if (_logists.Contains(kv.Key))
|
||||
{
|
||||
sb.Append("|L");
|
||||
}
|
||||
sb.Append('\n');
|
||||
}
|
||||
File.WriteAllText(FilePath, sb.ToString());
|
||||
}
|
||||
@@ -830,9 +846,17 @@ namespace NecromancerTome
|
||||
}
|
||||
}
|
||||
|
||||
public static void Add(Vector3i _pos, PlatformUserIdentifierAbs _owner)
|
||||
public static void Add(Vector3i _pos, PlatformUserIdentifierAbs _owner, bool _logist)
|
||||
{
|
||||
Urns()[_pos] = _owner != null ? _owner.CombinedString : "";
|
||||
if (_logist)
|
||||
{
|
||||
_logists.Add(_pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logists.Remove(_pos);
|
||||
}
|
||||
Save();
|
||||
Debug.Log("[NecromancerTome] Cinerarium: урна поставлена " + _pos + ", всего в сейве " + _urns.Count);
|
||||
}
|
||||
@@ -841,6 +865,7 @@ namespace NecromancerTome
|
||||
{
|
||||
if (Urns().Remove(_pos))
|
||||
{
|
||||
_logists.Remove(_pos);
|
||||
Save();
|
||||
Debug.Log("[NecromancerTome] Cinerarium: урна убрана " + _pos + ", всего в сейве " + _urns.Count);
|
||||
}
|
||||
@@ -850,9 +875,12 @@ namespace NecromancerTome
|
||||
{
|
||||
string id = _owner != null ? _owner.CombinedString : "";
|
||||
int n = 0;
|
||||
foreach (string v in Urns().Values)
|
||||
World world = GameManager.Instance?.World;
|
||||
foreach (KeyValuePair<Vector3i, string> kv in Urns())
|
||||
{
|
||||
if (v == id)
|
||||
// Логисты не считаются; записанные до метки «L» узнаются по блоку в мире (чанк рядом загружен).
|
||||
if (kv.Value == id && !_logists.Contains(kv.Key) &&
|
||||
!(world != null && TEFeatureCinerarium.IsLogistBlock(world.GetBlock(kv.Key).Block)))
|
||||
{
|
||||
n++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user