public void RegisterPlaceableItem(Item_Base item, RBlockQuadType[] quadtypes) { Traverse.Create(item.settings_recipe).Field("subCategory").SetValue(line.ToString()); if (currentMenuOffset == 4) { currentMenuOffset = 0; line++; } currentMenuOffset++; RAPI.RegisterItem(item); foreach (RBlockQuadType rb in quadtypes) { RAPI.AddItemToBlockQuadType(item, rb); } }
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(); }
void RegisterChest(Item_Base i) { RAPI.AddItemToBlockQuadType(i, RBlockQuadType.quad_floor); RAPI.AddItemToBlockQuadType(i, RBlockQuadType.quad_foundation); RAPI.AddItemToBlockQuadType(i, RBlockQuadType.quad_table); }