38 lines
973 B
C#
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;
|
|
}
|
|
}
|
|
} |