public static void Postfix()
 {
     foreach (var prefab in CustomPrefabHandler.customPrefabs)
     {
         PrefabDatabase.AddToCache(prefab.PrefabFileName, prefab.GetResource() as GameObject);
         PrefabDatabase.prefabFiles[prefab.ClassID] = prefab.PrefabFileName;
     }
 }
 public static void PostFix()
 {
     foreach (var v in customPrefabs)
     {
         Debug.Log("Patching Custom Resource " + v.Path + " " + v.Key);
         PrefabDatabase.AddToCache(v.Path, v.LoadResource() as GameObject);
         PrefabDatabase.prefabFiles[v.Key] = v.Path;
     }
 }
Beispiel #3
0
 public static void FixPrefabDB()
 {
     Debug.Log("[UM4SN] Fixing prefab database");
     foreach (KeyValuePair <string, GameObject> kvp in customTechGameObjects)
     {
         PrefabDatabase.AddToCache(kvp.Key, kvp.Value);
     }
     foreach (KeyValuePair <string, string> kvp in customTechUuids)
     {
         PrefabDatabase.prefabFiles[kvp.Key] = kvp.Value;
     }
 }
Beispiel #4
0
        public static void OnPrefabDatabaseInitialized()
        {
            if (prefabDatabaseInitialized)
            {
                return;
            }
            prefabDatabaseInitialized = true;

            prefabsByTechType.Clear();
            prefabsByClassID.Clear();

            Log("Initializing prefabs");
            foreach (var entry in techData)
            {
                var info   = entry.Value;
                var prefab = GetPrefab(info.techType);
                if (prefab != null)
                {
                    continue;
                }

                if (prefab == null && info.getPrefab != null)
                {
                    prefab = info.getPrefab.Invoke();
                }

                if (prefab == null)
                {
                    Log("ERROR creating prefab for " + info.techTypeKey);
                    continue;
                }

                prefab.SetActive(false);
                prefab.transform.position = new Vector3(5000, 5000, 5000);

                var constructable = prefab.GetComponent <Constructable>();
                if (constructable != null)
                {
                    constructable.techType = info.techType;
                }

                var techTag = prefab.GetComponent <TechTag>();
                if (techTag != null)
                {
                    techTag.type = info.techType;
                }

                var prefabIdentifier = prefab.GetComponent <PrefabIdentifier>();
                if (prefabIdentifier != null)
                {
                    prefabIdentifier.ClassId = info.assetPath;
                }

                var onDestroy = prefab.AddComponent <CallbackOnDestroy>();
                onDestroy.onDestroy = OnPrefabDestroyed;

                AddPrefab(info.techType, info.assetPath, prefab);
                PrefabDatabase.prefabFiles[info.assetPath] = info.assetPath;
                PrefabDatabase.AddToCache(info.assetPath, prefab);
            }
        }