Files
valheim-dashboard/Valheim Dashboard/AtomTable.cs
2025-08-01 23:28:27 +02:00

38 lines
973 B
C#

using System.Collections.Generic;
namespace Valheim_Dashboard;
public class AtomTable
{
private static readonly Dictionary<string, ushort> AtomDictionary = new();
private static ushort CurrentAtomValue = 1; // Startwert für Atoms
public static ushort AddAtom(string atomString)
{
lock (AtomDictionary)
{
if (AtomDictionary.ContainsKey(atomString))
{
return AtomDictionary[atomString];
}
ushort newAtom = CurrentAtomValue++;
AtomDictionary[atomString] = newAtom;
return newAtom;
}
}
public static ushort FindAtom(string atomString)
{
lock (AtomDictionary)
{
if (AtomDictionary.TryGetValue(atomString, out ushort atom))
{
return atom;
}
// Rückgabe 0 wie bei `GlobalFindAtom` in Windows, wenn nicht gefunden
return 0;
}
}
}