Add quick interactions locally

This commit is contained in:
2025-03-31 04:02:39 +02:00
parent 5bb7a207f2
commit b7d4531ec8
134 changed files with 15494 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Barotrauma;
using HarmonyLib;
using Microsoft.Xna.Framework;
namespace QICrabUI
{
public class ModStorage
{
private static Dictionary<string, object> GetOrCreateRepo()
{
if (GUI.Canvas.GUIComponent is not GUIButton)
{
GUI.Canvas.GUIComponent = new GUIButton(new RectTransform(new Point(0, 0)));
}
if (GUI.Canvas.GUIComponent.UserData is not Dictionary<string, object>)
{
GUI.Canvas.GUIComponent.UserData = new Dictionary<string, object>();
}
return (Dictionary<string, object>)GUI.Canvas.GUIComponent.UserData;
}
public static object Get<TValue>(string key) => (TValue)Get(key);
public static object Get(string key)
{
Dictionary<string, object> repo = GetOrCreateRepo();
return repo.GetValueOrDefault(key);
}
public static void Set(string key, object value)
{
Dictionary<string, object> repo = GetOrCreateRepo();
repo[key] = value;
}
public static bool Has(string key)
{
Dictionary<string, object> repo = GetOrCreateRepo();
return repo.ContainsKey(key);
}
}
}