Files
SVSimServer/SVSim.BattleEngine/Engine/PrefabMgr.cs
gamer147 957af3d1ec feat(battle-engine): full Unity/VFX/god-object shims + expanded copy closure (2570 files)
Authored Unity primitive/object-model shim, VFX layer (control-flow-preserving, InstantVfx never invokes its action -- headless suppression), god-object stubs (GameMgr/EffectMgr/UIManager with faithfully-extracted nested enums), View/UI/Touch tree, LitJson+BetterList+Tuple copied, third-party stubs. Discovered Roslyn header-error masking: fixing class-header type errors unmasks body references, so the true copy closure is ~2570 files (was 782 under masking). Errors: masked-25720 -> 268; our shim files compile clean. Remaining: ~50 residual shim/external types, 24 NGUI UI-base overrides, static-type fixes, plus likely 1-2 more unmask waves.
2026-06-05 17:22:20 -04:00

144 lines
2.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PrefabMgr
{
private Dictionary<string, Object> m_PrefabData;
private IList<GameObject> m_AddedGameObj = new List<GameObject>();
public PrefabMgr()
{
m_PrefabData = new Dictionary<string, Object>();
}
public void Load(string str)
{
if (!m_PrefabData.ContainsKey(str) && !string.IsNullOrEmpty(str))
{
m_PrefabData.Add(str, Resources.Load(str));
}
}
public IEnumerator LoadAync(string str)
{
if (!m_PrefabData.ContainsKey(str) && !string.IsNullOrEmpty(str))
{
ResourceRequest loadRequest = Resources.LoadAsync(str);
while (!loadRequest.isDone)
{
yield return null;
}
Object asset = loadRequest.asset;
m_PrefabData.Add(str, asset);
}
}
public void UnLoad(string str)
{
if (m_PrefabData.ContainsKey(str))
{
m_PrefabData.Remove(str);
Resources.UnloadUnusedAssets();
}
}
public void AllUnLoad()
{
m_PrefabData.Clear();
Resources.UnloadUnusedAssets();
}
public GameObject CreateIns(string str)
{
if (m_PrefabData.ContainsKey(str))
{
return Object.Instantiate(m_PrefabData[str]) as GameObject;
}
return null;
}
public GameObject Get(string str)
{
if (m_PrefabData.ContainsKey(str))
{
return (GameObject)m_PrefabData[str];
}
return null;
}
public Texture GetTexture(string str)
{
if (m_PrefabData.ContainsKey(str))
{
return (Texture)m_PrefabData[str];
}
return null;
}
public Sprite GetSprite(string str)
{
if (m_PrefabData.ContainsKey(str))
{
return (Sprite)m_PrefabData[str];
}
return null;
}
public AudioClip GetAudio(string str)
{
if (m_PrefabData.ContainsKey(str))
{
return (AudioClip)m_PrefabData[str];
}
return null;
}
public Object GetObj(string str)
{
if (m_PrefabData.ContainsKey(str))
{
return m_PrefabData[str];
}
return null;
}
public void DebugDraw()
{
foreach (string key in m_PrefabData.Keys)
{
_ = key;
}
}
public Dictionary<string, Object> GetPrefabData()
{
return m_PrefabData;
}
public void DisposeAllClonedObject()
{
for (int i = 0; i < m_AddedGameObj.Count; i++)
{
Object.DestroyImmediate(m_AddedGameObj[i]);
m_AddedGameObj[i] = null;
}
m_AddedGameObj.Clear();
}
public GameObject CloneObjectToParent(string str, GameObject parentObject)
{
GameObject gameObject = NGUITools.AddChild(parentObject, GameMgr.GetIns().GetPrefabMgr().Get(str));
m_AddedGameObj.Add(gameObject);
return gameObject;
}
public GameObject CloneObjectToParent(GameObject gobj, GameObject parentObject)
{
GameObject gameObject = NGUITools.AddChild(parentObject, gobj);
m_AddedGameObj.Add(gameObject);
return gameObject;
}
}