glados123123123123

Untitled

Jan 6th, 2024
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Reflection;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using TombsMadnessMod.ItemScript;
  9. using TombsMadnessMod.Tags;
  10. using Unity.Netcode;
  11. using UnityEngine;
  12.  
  13. namespace TombsMadnessMod.Component
  14. {
  15.     public class AssetLoader : MonoBehaviour
  16.     {
  17.        
  18.         public StartOfRound SoR;
  19.          
  20.  
  21.         public Dictionary<string, UnityEngine.Object> assetsDictionary = new Dictionary<string, UnityEngine.Object>();
  22.  
  23.  
  24.         public void Awake()
  25.         {
  26.  
  27.             var bundle = AssetBundle.LoadFromMemory(TombsMadnessMod.Properties.Resources.tombsmadnessmodbundle);
  28.             foreach (var assetName in bundle.GetAllAssetNames())
  29.             {
  30.                 GameObject asset = bundle.LoadAsset<GameObject>(assetName);
  31.                 if (asset != null)
  32.                 {
  33.                     assetsDictionary[assetName] = asset;
  34.                     if(asset.GetComponent<ShopItem>() is ShopItem i && i != null)
  35.                     {
  36.                         LethalLib.Modules.Items.RegisterShopItem(i.itemRef, null, null, null, i.cost);
  37.                         Destroy(i);
  38.                     }
  39.                     if (asset.GetComponent<ShipItem>() is ShipItem u && u != null)
  40.                     {
  41.                         LethalLib.Modules.Unlockables.RegisterUnlockable(u.unlockableRef, u.cost);
  42.                     }
  43.                     if (asset.GetComponent<NetworkObject>() is NetworkObject obj && obj != null)
  44.                     {
  45.                         LethalLib.Modules.NetworkPrefabs.RegisterNetworkPrefab(asset);
  46.                     }
  47.                 }
  48.                
  49.             }
  50.  
  51.             foreach (KeyValuePair<string, UnityEngine.Object> kvp in assetsDictionary)
  52.             {
  53.                 TombsMadnessModBase.mls.LogFatal($"Key = {kvp.Key}, Value = {kvp.Value}");
  54.             }
  55.         }
  56.  
  57.  
  58.     }
  59.  
  60.    
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment