IEnumerator Start() { RNotification notification = FindObjectOfType <RNotify>().AddNotification(RNotify.NotificationType.spinning, "Loading MoreStorages..."); var bundleLoadRequest = AssetBundle.LoadFromFileAsync("mods\\ModData\\MoreStorages\\morestorages.assets"); yield return(bundleLoadRequest); assetbundle = bundleLoadRequest.assetBundle; if (assetbundle == null) { RConsole.LogError("Failed to load AssetBundle for MoreStorages!"); notification.Close(); yield return(null); } List <Item_Base> list = Traverse.Create(typeof(ItemManager)).Field("allAvailableItems").GetValue <List <Item_Base> >(); Item_Base Placeable_MoreStorages_MinecraftChest = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("Placeable_MoreStorages_MinecraftChest"); Placeable_MoreStorages_MinecraftChest.Initialize(9845, "Placeable_MoreStorages_MinecraftChest", 1); list.Add(Placeable_MoreStorages_MinecraftChest); RegisterChest(Placeable_MoreStorages_MinecraftChest); Item_Base Placeable_MoreStorages_Barrel = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("Placeable_MoreStorages_Barrel"); Placeable_MoreStorages_Barrel.Initialize(9846, "Placeable_MoreStorages_Barrel", 1); list.Add(Placeable_MoreStorages_Barrel); RegisterChest(Placeable_MoreStorages_Barrel); Item_Base Placeable_MoreStorages_Crate = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("Placeable_MoreStorages_Crate"); Placeable_MoreStorages_Crate.Initialize(9847, "Placeable_MoreStorages_Crate", 1); list.Add(Placeable_MoreStorages_Crate); RegisterChest(Placeable_MoreStorages_Crate); Item_Base Placeable_MoreStorages_Luggage = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("Placeable_MoreStorages_Luggage"); Placeable_MoreStorages_Luggage.Initialize(9848, "Placeable_MoreStorages_Luggage", 1); list.Add(Placeable_MoreStorages_Luggage); RegisterChest(Placeable_MoreStorages_Luggage); Item_Base Placeable_MoreStorages_MedievalChest = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("Placeable_MoreStorages_MedievalChest"); Placeable_MoreStorages_MedievalChest.Initialize(9849, "Placeable_MoreStorages_MedievalChest", 1); list.Add(Placeable_MoreStorages_MedievalChest); RegisterChest(Placeable_MoreStorages_MedievalChest); Item_Base Placeable_MoreStorages_Package = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("Placeable_MoreStorages_Package"); Placeable_MoreStorages_Package.Initialize(9850, "Placeable_MoreStorages_Package", 1); list.Add(Placeable_MoreStorages_Package); RegisterChest(Placeable_MoreStorages_Package); Traverse.Create(typeof(ItemManager)).Field("allAvailableItems").SetValue(list); notification.Close(); RConsole.Log("MoreStorages has been successfully loaded!"); }
public IEnumerator Start() { RNotification notification = FindObjectOfType <RNotify>().AddNotification(RNotify.NotificationType.spinning, "Loading WaterWheel..."); var bundleLoadRequest = AssetBundle.LoadFromFileAsync("mods\\ModData\\WaterWheel\\waterwheel.assets"); yield return(bundleLoadRequest); AssetBundle assetBundle = bundleLoadRequest.assetBundle; if (assetBundle == null) { Error("Failed to load Asset Bundle. This mod will not work."); notification.Close(); yield return(null); } Item_Base placeable_testblock = assetBundle.LoadAsset <Item_Base>("Placeable_WaterWheel_Item"); Material colorMat = ItemManager.GetItemByName("Block_Wall_Fence_Plank").settings_buildable.GetBlockPrefab(0).GetComponentInChildren <Renderer>().material; placeable_testblock.settings_buildable.GetBlockPrefab(0).GetComponentInChildren <Renderer>().material = colorMat; placeable_testblock.settings_buildable.GetBlockPrefab(0).paintable = true; List <Item_Base> list = Traverse.Create(typeof(ItemManager)).Field("allAvailableItems").GetValue <List <Item_Base> >(); list.Add(placeable_testblock); GameObject prefab = placeable_testblock.settings_buildable.GetBlockPrefab(0).gameObject; prefab.transform.Find("_waterTargetCollider").gameObject.AddComponent <WaterWheelTarget>(); prefab.transform.Find("_model").Find("wheel").gameObject.AddComponent <WaterWheelRotator>(); Traverse.Create(typeof(ItemManager)).Field("allAvailableItems").SetValue(list); List <Item_Base> sobject = Traverse.Create(Resources.Load <ScriptableObject>("blockquadtype/quad_foundation_empty")).Field("acceptableBlockTypes").GetValue <List <Item_Base> >(); sobject.Add(placeable_testblock); Traverse.Create(Resources.Load <ScriptableObject>("blockquadtype/quad_foundation_empty")).Field("acceptableBlockTypes").SetValue(sobject); notification.Close(); Info("Mod was loaded successfully!"); FollowUpLog("This mod is still in development, please make a backup before you use it!"); }
IEnumerator Start() { RNotification notification = FindObjectOfType <RNotify>().AddNotification(RNotify.NotificationType.spinning, "Loading SolarPanelMod..."); var bundleLoadRequest = AssetBundle.LoadFromFileAsync("mods\\ModData\\SolarPanel\\solarpanel.assets"); yield return(bundleLoadRequest); assetbundle = bundleLoadRequest.assetBundle; if (assetbundle == null) { RConsole.LogError("Failed to load AssetBundle for solarpanel!"); notification.Close(); yield return(null); } List <Item_Base> list = Traverse.Create(typeof(ItemManager)).Field("allAvailableItems").GetValue <List <Item_Base> >(); Item_Base placeable_solarpanel = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("placeable_solarpanel"); placeable_solarpanel.settings_buildable.GetBlockPrefab(0).gameObject.AddComponent <SolarPanelObject>(); SolarPanelObject obj = placeable_solarpanel.settings_buildable.GetBlockPrefab(0).gameObject.AddComponent <SolarPanelObject>(); Traverse.Create(placeable_solarpanel.settings_buildable.GetBlockPrefab(0).GetComponentInChildren <Battery>()).Field("networkBehaviourID").SetValue(obj); placeable_solarpanel.Initialize(999, "placeable_solarpanel", 1); list.Add(placeable_solarpanel); Traverse.Create(typeof(ItemManager)).Field("allAvailableItems").SetValue(list); RAPI.AddItemToBlockQuadType(placeable_solarpanel, RBlockQuadType.quad_floor); RAPI.AddItemToBlockQuadType(placeable_solarpanel, RBlockQuadType.quad_foundation); RAPI.AddItemToBlockQuadType(placeable_solarpanel, RBlockQuadType.quad_table); notification.Close(); }