Initial commit
This commit is contained in:
38
Valheim Dashboard/AtomTable.cs
Normal file
38
Valheim Dashboard/AtomTable.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user