Upload from upload_mods.ps1

This commit is contained in:
Nathaniel Cosford
2025-06-04 16:13:35 +09:30
commit 1b47374919
26 changed files with 1948 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
using System.Collections.Generic;
using UnityEngine;
public class TrackedBehaviour<T> : TrackedBehaviourBase where T : TrackedBehaviour<T>
{
protected static Dictionary<uint, Dictionary<object, T>> hash_instances = new Dictionary<uint, Dictionary<object, T>>();
static TrackedBehaviour()
{
CustomExplosionManager.CleanUp += hash_instances.Clear;
}
protected override void Awake()
{
track = true;
base.Awake();
}
protected override void addRef()
{
if (!hash_instances.ContainsKey(explId))
hash_instances.Add(explId, new Dictionary<object, T>());
hash_instances[explId].Add(key, (T)this);
}
protected override void removeRef()
{
var dict = hash_instances[explId];
if (dict != null)
{
dict.Remove(key);
if (dict.Count <= 0)
hash_instances.Remove(explId);
}
}
public static bool TryGetValue(uint id, object key, out T controller)
{
controller = null;
if (hash_instances.TryGetValue(id, out var dict))
return dict.TryGetValue(key, out controller);
return false;
}
}