private void _RegisterAndStowOverrideContents() { if (_myData as Equipment_Base != null) { if (_tempStowedOverrideContents != null) { if (_tempStowedOverrideContents.Count > 0) { foreach (Thing t in _tempStowedOverrideContents) { Item_Base i = t as Item_Base; Equipment_Base e = t as Equipment_Base; if (i != null) { i.state = ServiceLocator.ItemStates.Stowed; } else if (e != null) { e.state = ServiceLocator.EquipmentStates.Stowed; } ServiceLocator.Instance.EManager.Fire(new Event_NewInteractable(t, transform.position, true)); _objIntController.StowAndInstall(_myData as Equipment_Base, t); } } } } }
/// <summary> /// Function creating a new recipe setting with new recipe. /// </summary> /// <param name="pResultItem">Item resulting from the crafting.</param> /// <param name="pSubCategory">Sub category tag.</param> /// <param name="pSubCategoryOrder">Order position within the sub category.</param> /// <param name="pCosts">Crafting costs.</param> public static void CreateRecipe(Item_Base pResultItem, string pSubCategory, int pSubCategoryOrder, params CostMultiple[] pCosts) { //pResultItem.settings_recipe = new ItemInstance_Recipe(CraftingCategory.FoodWater, true, true, pSubCategory, pSubCategoryOrder) { NewCost = pCosts }; Traverse.Create(pResultItem.settings_recipe).Field("subCategory").SetValue(pSubCategory); Traverse.Create(pResultItem.settings_recipe).Field("subCategoryOrder").SetValue(pSubCategoryOrder); Traverse.Create(pResultItem.settings_recipe).Field("newCostToCraft").SetValue(pCosts); }
bool CreateRadioItem() { if (radio != null) { return(false); } radio = ItemManager.GetItemByIndex(ITEM_ID); if (radio != null) { Error($"{ITEM_DISPLAYNAME} item already created."); return(false); } var originalRadio = ItemManager.GetItemByName("Placeable_Radio"); if (originalRadio == null) { Error("Cannot find original radio item."); return(false); } radio = Object.Instantiate(originalRadio); radio.name = ITEM_NAME; var traverse = Traverse.Create(radio); traverse.Property("UniqueName").SetValue(ITEM_NAME); traverse.Property("UniqueIndex").SetValue(ITEM_ID); traverse.Field("settings_Inventory").Property("DisplayName").SetValue(ITEM_DISPLAYNAME); traverse.Field("settings_Inventory").Property("Description").SetValue(ITEM_DESCRIPTION); RAPI.RegisterItem(radio); Info($"{ITEM_DISPLAYNAME} item created."); return(true); }
public void OnTriggerStay(Collider other) { CookingStand_Purifier target = other.gameObject.GetComponent <CookingStand_Purifier>(); if (target == null) { target = other.gameObject.transform.parent.gameObject.GetComponent <CookingStand_Purifier>(); } if (target != null) { timer += Time.deltaTime; if (timer > timePerFill) { Item_Base waterCup = ItemManager.GetItemByIndex(40); CookingSlot[] possibleSlots = target.GetCookingSlotsForItem(waterCup); if (possibleSlots != null && possibleSlots.Length > 0) { Network_Player networkPlayer = ComponentManager <Network_Player> .Value; CookingStandManager cookingStandManager = networkPlayer.CookingStandManager; Message_CookingStand_Insert message = new Message_CookingStand_Insert(Messages.CookingStandManager_InsertItem, cookingStandManager, waterCup, target, possibleSlots); if (Semih_Network.IsHost) { networkPlayer.Network.RPC(message, Target.Other, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game); target.InsertItem(waterCup, possibleSlots, false); // if localPlayer was true, the local player would lose an item } } timer -= timePerFill; } } }
// Token: 0x060000DD RID: 221 public static void GiveItem(Item_Base item, int amount, Player p = null) { if (p == null) { p = UnityEngine.Object.FindObjectOfType <Player>(); } FieldInfo field = Enumerable.FirstOrDefault <FieldInfo>(typeof(Player).GetFields((BindingFlags)36), (FieldInfo x) => x.Name == "playerInventory"); if (field == null) { RConsole.Log("Couldn't find playerInventory"); return; } PlayerInventory pi = (PlayerInventory)field.GetValue(p); if (pi == null) { RConsole.Log("Couldn't get playerInventory"); return; } try { pi.AddItem(item.name, 1); } catch (Exception ex) { RConsole.Log(ex.ToString()); } }
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!"); }
private void RefreshRecipe() { baseItem.settings_recipe = new ItemInstance_Recipe((CraftingCategory)category, false, recipe == null ? false : recipe.discoveredByDefault, subcategory, 0); if (recipe != null) { if (recipe.blueprint != null) { typeof(Item_Base).GetField("BlueprintItem", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(baseItem.settings_recipe, recipe.blueprint.baseItem); } typeof(ItemInstance_Recipe).GetField("amountToCraft", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(baseItem.settings_recipe, recipe.amount); List <CostMultiple> costs = new List <CostMultiple>(); foreach (RecipeShape shape in recipe.recipe) { Item_Base[] itemBase = new Item_Base[shape.items.Length]; int j = 0; foreach (Item i in shape.items) { itemBase[j++] = i.baseItem; } costs.Add(new CostMultiple(itemBase, shape.amount)); } baseItem.settings_recipe.NewCost = costs.ToArray(); } }
public void OnPurchaseItem(Item_Base item) { bool itemDoesExist = false; //use this to save if the item exists in our array already or not foreach(ItemHandler i in allItems) //check if the newly purchased item exists in the array. { if (item.Equals(i.item)) { itemDoesExist = true; //if it does increment it i.numberOfItems++; } } if (itemDoesExist == false) //if not make a new one { ItemHandler iH = new ItemHandler(); iH.item = item; iH.numberOfItems++; allItems.Add(iH); } ModifyCoins(-item.purchaseInto.costInCoin); ModifyCash(-item.purchaseInto.costInCash); myUser.SaveData(); //PopupManager.I.CreateOneButtonPopup("Congratulations!", "You just purchased " + item.itemName + " for " + item.purchaseInto.cost + " " + item.purchaseInto.moneyType); }
public void StowAndInstall(Equipment_Base eqptThatWillPossess, Thing thingToStore) { eqptThatWillPossess.stowed.Add(thingToStore); if (thingToStore.cat == ServiceLocator.ThingCategory.Items) { Item_Base i = thingToStore as Item_Base; Debug.Assert(i != null, "Item type and category mismatch"); i.stowingEqpt = eqptThatWillPossess; i.state = ServiceLocator.ItemStates.Stowed; _Helper_AutoShiftBodyLayer(i); } else if (thingToStore.cat == ServiceLocator.ThingCategory.Equipment) { Equipment_Base e = thingToStore as Equipment_Base; Debug.Assert(e != null, "Equipment type and category mismatch"); e.stowingEqpt = eqptThatWillPossess; e.state = ServiceLocator.EquipmentStates.Stowed; _Helper_AutoShiftBodyLayer(e); } else { // *** Still requires consumable implementation *** Debug.Log("Attempting to stow invalid InteractiveCategory thing"); } }
public void AttemptToHold(ServiceLocator.ID id) { if (id == ServiceLocator.ID.p0) { if (_objIntModel.p0_InteractableInterested.cat == ServiceLocator.ThingCategory.Items) { Item_Base i = _objIntModel.p0_InteractableInterested as Item_Base; if (i != null) { i.state = ServiceLocator.ItemStates.Held; _objIntModel.SetGrabbed(id, _objIntModel.p0_InteractableInterested); _objIntModel.SetInteractableInterested(id, null); Debug.Log("Grabbed is of type " + _objIntModel.p0_InteractableGrabbed + ". It's enum type is " + _objIntModel.p0_InteractableGrabbed.type.ToString() + "."); } } else if (_objIntModel.p0_InteractableInterested.cat == ServiceLocator.ThingCategory.Equipment) { Equipment_Base e = _objIntModel.p0_InteractableInterested as Equipment_Base; if (e != null) { if (e.state == ServiceLocator.EquipmentStates.Loose) { e.state = ServiceLocator.EquipmentStates.Held; _objIntModel.SetGrabbed(id, _objIntModel.p0_InteractableInterested); _objIntModel.SetInteractableInterested(ServiceLocator.ID.p0, null); } } } } }
private static void Postfix(PlayerStats __instance, Item_Base edibleItem) { if (__instance.GetComponent(typeof(Network_Player)) == RAPI.GetLocalPlayer()) { ComponentManager <GlassHoneyUse> .Value.OnConsumeItem(edibleItem); } }
/// <summary> /// Function creating a new recipe setting with new recipe. /// </summary> /// <param name="pResultItem">Item resulting from the crafting.</param> /// <param name="pSubCategory">Sub category tag.</param> /// <param name="pSubCategoryOrder">Order position within the sub category.</param> /// <param name="pCosts">Crafting costs.</param> public static void CreateRecipe(Item_Base pResultItem, string pSubCategory, int pSubCategoryOrder, params CostMultiple[] pCosts) { pResultItem.settings_recipe = new ItemInstance_Recipe(CraftingCategory.FoodWater, true, true, pSubCategory, pSubCategoryOrder) { NewCost = pCosts }; }
private void _ItemCapacityOverride() { Item_Base tempItem = _myData as Item_Base; Debug.Assert(tempItem != null, "Not item"); tempItem.capacity = startingCapacity; }
static void Prefix(Item_Base ___item) { if (___item != null) { CostMultiple[] newCost = ___item.settings_recipe.NewCost; CraftFromStorageManager.RemoveCostMultiple(newCost); } }
public void OnConsumeItem(Item_Base item) { if (!(item.name == "Jar_Honey")) { return; } GiveGlass(); }
/** Check */ public static bool Check(Item a_from, Item a_to) { bool t_result = true; t_result &= Simple.Check_Int("pub_1", a_from.pub_1, a_to.pub_1); t_result &= Simple.Check_Int("pro_1", a_from.pub_1, a_to.pub_1); t_result &= Simple.Check_Int("pri_1", a_from.pub_1, a_to.pub_1); return(t_result & Item_Base.Check(a_from, a_to)); }
public void OnModifyTank(Network_Player player, float amount, Item_Base itemType = null) { if (!itemType || !(itemType.name == "Jar_Honey")) { return; } GiveGlass(); }
/// <summary> /// Get an item by its handle /// </summary> /// <param name="item">Handle; the legacy item</param> /// <returns>item</returns> public static Item ByHandle(Item_Base item) { if (!items.ContainsKey(item)) { return(null); } return(items[item]); }
public void Initialize(Item_Base itemInstance) { if (this.isInitialized) { return; } this.itemInstance = itemInstance; this.isInitialized = true; }
/// <summary> /// Convert an item from legacy to mod, as well as registering it /// </summary> /// <param name="item">The legacy item to convert</param> /// <returns>mod item</returns> private Item ConvertItem(Item_Base item) { Item i = new Item(item.UniqueName, item.settings_Inventory.DisplayName, item.settings_Inventory.Description, (ItemCategory)item.settings_recipe.CraftingCategory, (ItemUse)item.GetType(), item.MaxUses, item.settings_Inventory.StackSize, item.settings_recipe.SubCategory); typeof(Item).GetProperty("owner").SetValue(i, this, null); typeof(Item).GetProperty("id").SetValue(i, item.UniqueIndex, null); typeof(Item).GetProperty("baseItem").SetValue(i, item, null); AddItem(i); return(i); }
static void Prefix(SelectedRecipeBox ___selectedRecipeBox) { Item_Base itemBase = ___selectedRecipeBox.selectedRecipeItem; if (itemBase != null) { CostMultiple[] newCost = itemBase.settings_recipe.NewCost; CraftFromStorageManager.RemoveCostMultiple(newCost); } }
// The void that lowers the stats and change the need of the ai based on that. private void Live() { StatDecrease(); Needs _need = FindLowestNeed(); // Checks if the need is different, if so then change the desired item/location. if (need != _need) { need = _need; item = null; switch (need) { case Needs.Energy: item = Manager.GetItem(transform, Manager.energyItems); break; case Needs.Fullness: item = Manager.GetItem(transform, Manager.fullnessItems); break; case Needs.Hygiene: item = Manager.GetItem(transform, Manager.hygieneItems); break; case Needs.EmptyBladder: item = Manager.GetItem(transform, Manager.emptyBladderItems); break; case Needs.Fun: item = Manager.GetItem(transform, Manager.funItems); break; } // Tell the NavMeshAgent to move to it's desired location. agent.SetDestination(item.gameObject.transform.position); } // Check if the NavMeshAgent reached it's destination, and if so use the item. if (!agent.pathPending) { if (agent.remainingDistance <= agent.stoppingDistance) { if (!agent.hasPath || agent.velocity.sqrMagnitude == 0f) { // Check if the item isn't already being used, to prevent using the item multiple times. if (!item.inUse) { item.Use(this); } } } } }
public bool DoesListOfThingsContainThingOfTypeItem(List <Thing> list, ThingType type) { foreach (Thing t in list) { Item_Base itemCheck = t as Item_Base; if (itemCheck != null) { if (itemCheck.type == type) { return(true); } } } return(false); }
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); } }
public IEnumerator Start() { layerMask = ~layerMask; RConsole.Log("Fertilizer has been loaded!"); AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync("mods/ModData/Fertilizer/fertilizer.assets"); yield return(request); assets = request.assetBundle; Item_Base fertilizeItem = assets.LoadAsset <Item_Base>("fertilizer"); RAPI.RegisterItem(fertilizeItem); RAPI.SetItemObject(fertilizeItem, assets.LoadAsset <GameObject>("fertilizerGameObject")); }
private Slot FindSuitableSlot(List <Slot> inv, Item_Base stackableItem = null) { bool flag = stackableItem != null && stackableItem.settings_Inventory.Stackable; foreach (Slot slot2 in inv) { if (slot2.IsEmpty) { return(slot2); } if (flag && !slot2.StackIsFull() && !slot2.IsEmpty && slot2.itemInstance.UniqueIndex == stackableItem.UniqueIndex) { return(slot2); } } return(null); }
public static void ForceSeedDropRate(PickupItem pickupItem) { SO_RandomDropper dropper = Traverse.Create(pickupItem.dropper).Field("randomDropperAsset").GetValue() as SO_RandomDropper; Randomizer randomizer = dropper.randomizer; foreach (RandomItem item in randomizer.items) { if (item.obj != null && item.obj.GetType() == typeof(Item_Base)) { Item_Base item_Base = item.obj as Item_Base; if (item_Base.UniqueName.ToLower().Contains("seed")) { item.weight = randomizer.TotalWeight * 0.3f; item.spawnChance = item.weight / randomizer.TotalWeight * 100f + "%"; } } } }
private Slot FindSuitableSlot(List <Slot> inv, int currIndex, Item_Base stackableItem = null) { bool flag = stackableItem != null && stackableItem.settings_Inventory.Stackable; for (var i = 0; i < currIndex; i++) { Slot slot2 = inv[i]; if (slot2.IsEmpty) { return(slot2); } if (flag && !slot2.StackIsFull() && !slot2.IsEmpty && slot2.itemInstance.UniqueIndex == stackableItem.UniqueIndex) { return(slot2); } } return(null); }
public void SpawnItem() { Item_Base currentItem = null; string[] lastCommand = RConsole.lastCommands.LastOrDefault <string>().Split(' '); if (lastCommand.Length == 1) { RConsole.Log("Please include an item name after eg \"spawn Paddle\""); } else { string itemName = lastCommand[1]; int amount = 1; if (lastCommand.Length > 2) { string itemAmount = lastCommand[2]; int result; if (int.TryParse(itemAmount, out result)) { amount = result; } } for (int i = 0; i < items.Count; i++) { if (items[i].UniqueName == itemName) { PlayerInventory pi = ComponentManager <PlayerInventory> .Value; try { pi.AddItem(items[i].UniqueName, amount); RConsole.Log("Have given player " + amount + " " + items[i].UniqueName); } catch (Exception e) { RConsole.LogError(e.ToString()); } return; } } RConsole.Log("Couldn't find the item called " + itemName); } }
public void SetData(Item_Base item) { Debug.Assert(!_set, "Attempting to change item data reference for a set item."); _rb = gameObject.AddComponent <Rigidbody>(); _rb.isKinematic = true; _rb.interpolation = RigidbodyInterpolation.Interpolate; _rb.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; _rb.constraints = RigidbodyConstraints.FreezePositionZ; _rb.drag = 1; _rb.angularDrag = 12; _trig = gameObject.AddComponent <SphereCollider>(); _trig.isTrigger = true; obvservedDataGeneric = item; observedItemData = item; // done at the end to capture item type based properties assigned in "item" property assignment serializedRigidBody = new SCG_RigidBodySerialized(_rb); }
public void Unstow(Equipment_Base eqptUnstower, Thing thingUnstowee) { if (!eqptUnstower.stowed.Contains(thingUnstowee)) { Debug.Log("Attempting to unstow an item that is not stowed in this eqpt"); } eqptUnstower.stowed.Remove(thingUnstowee); if (thingUnstowee.cat == ServiceLocator.ThingCategory.Items) { Item_Base i = thingUnstowee as Item_Base; Debug.Assert(i != null, "Item type and category mismatch"); i.stowingEqpt = null; i.state = ServiceLocator.ItemStates.Loose; _Helper_AutoShiftBodyLayer(i); _objIntModel.GetBodyOfThing(i).transform.position += Vector3.right; } else if (thingUnstowee.cat == ServiceLocator.ThingCategory.Equipment) { Equipment_Base e = thingUnstowee as Equipment_Base; Debug.Assert(e != null, "Equipment type and category mismatch"); e.stowingEqpt = null; e.state = ServiceLocator.EquipmentStates.Loose; _objIntModel.GetBodyOfThing(e).transform.position += Vector3.right; _Helper_AutoShiftBodyLayer(e); } else { // *** Still requires consumable implementation *** Debug.Log("Attempting to stow invalid InteractiveCategory thing"); } Vector3 eqptPos = _objIntModel.GetWhereIsThing(eqptUnstower); _objIntModel.GetBodyOfThing(thingUnstowee).transform.position = eqptPos + Vector3.right; }
public bool IsItemPurchased(Item_Base item) { foreach(ItemHandler iH in allItems) { if (item.Equals(iH.item)) return true; } return false; }