public virtual void UseItem(IInventoryItem inventoryItem) { var player = new Fougerite.Player(inventoryItem.controller.playerClient); if (player.Inventory.FreeSlots >= 8) { player.Inventory.AddItem("Metal Ceiling", 20); player.Inventory.AddItem("Metal Doorway", 20); player.Inventory.AddItem("Metal Foundation", 20); player.Inventory.AddItem("Metal Pillar", 40); player.Inventory.AddItem("Metal Ramp", 10); player.Inventory.AddItem("Metal Stairs", 10); player.Inventory.AddItem("Metal Wall", 40); player.Inventory.AddItem("Metal Window", 10); int num = 1; if (inventoryItem.Consume(ref num)) { inventoryItem.inventory.RemoveItem(inventoryItem.slot); } else { inventoryItem.inventory.MarkSlotDirty(inventoryItem.slot); } } else { player.Notice("You don't have enough space in your inventory!"); } }
public virtual void UseItem(IInventoryItem inventoryItem) { var player = new Fougerite.Player(inventoryItem.controller.playerClient); if (player.Inventory.FreeSlots >= 7) { player.Inventory.AddItem("M4", 1); player.Inventory.AddItem("556 Ammo", 100); player.Inventory.AddItem("Leather Vest", 1); player.Inventory.AddItem("Leather Pants", 1); player.Inventory.AddItem("Leather Helmet", 1); player.Inventory.AddItem("Leather Boots", 1); player.Inventory.AddItem("Small Medkit", 2); int num = 1; if (inventoryItem.Consume(ref num)) { inventoryItem.inventory.RemoveItem(inventoryItem.slot); } else { inventoryItem.inventory.MarkSlotDirty(inventoryItem.slot); } } else { player.Notice("You don't have enough space in your inventory!"); } }
public override InventoryItem.MergeResult TryCombine(IInventoryItem other) { ItemDataBlock datablock = other.datablock; ItemDataBlock.CombineRecipe matchingRecipe = this.datablock.GetMatchingRecipe(datablock); if (matchingRecipe != null) { int uses = other.uses; if (uses < matchingRecipe.amountToLoseOther) { return(InventoryItem.MergeResult.Failed); } if (base.uses < matchingRecipe.amountToLose) { return(InventoryItem.MergeResult.Failed); } Inventory inventory = other.inventory; int amount = 0; int a = base.uses / matchingRecipe.amountToLose; int b = uses / matchingRecipe.amountToLoseOther; amount = Mathf.Min(a, b); int num5 = 0; if (matchingRecipe.resultItem.IsSplittable()) { num5 = Mathf.CeilToInt(((float)amount) / ((float)num5)); } else { num5 = amount; } int vacantSlotCount = inventory.vacantSlotCount; if (num5 <= vacantSlotCount) { int count = amount * matchingRecipe.amountToLoseOther; if (other.Consume(ref count)) { inventory.RemoveItem(other.slot); } inventory.AddItemAmount(matchingRecipe.resultItem, amount, Inventory.AmountMode.Default); int numWant = amount * matchingRecipe.amountToLose; if (base.Consume(ref numWant)) { base.inventory.RemoveItem(base.slot); } } } return(InventoryItem.MergeResult.Failed); }
public virtual void UseItem(IInventoryItem inventoryItem) { var player = new Fougerite.Player(inventoryItem.controller.playerClient); player.TeleportTo(new Vector3(6636.035f, 348.0485f, -4385.647f)); int num = 1; if (inventoryItem.Consume(ref num)) { inventoryItem.inventory.RemoveItem(inventoryItem.slot); } else { inventoryItem.inventory.MarkSlotDirty(inventoryItem.slot); } }
public virtual void UseItem(IInventoryItem inventoryItem) { var player = new Fougerite.Player(inventoryItem.controller.playerClient); player.TeleportTo(new Vector3(6660.546f, 353.1123f, -3852.007f)); int num = 1; if (inventoryItem.Consume(ref num)) { inventoryItem.inventory.RemoveItem(inventoryItem.slot); } else { inventoryItem.inventory.MarkSlotDirty(inventoryItem.slot); } }
public override InventoryItem.MergeResult TryCombine(IInventoryItem other) { ItemDataBlock itemDataBlock = other.datablock; ItemDataBlock.CombineRecipe matchingRecipe = this.datablock.GetMatchingRecipe(itemDataBlock); if (matchingRecipe == null) { return(InventoryItem.MergeResult.Failed); } int num = other.uses; if (num < matchingRecipe.amountToLoseOther) { return(InventoryItem.MergeResult.Failed); } if (base.uses < matchingRecipe.amountToLose) { return(InventoryItem.MergeResult.Failed); } Inventory inventory = other.inventory; int num1 = 0; int num2 = base.uses / matchingRecipe.amountToLose; num1 = Mathf.Min(num2, num / matchingRecipe.amountToLoseOther); int num3 = 0; num3 = (!matchingRecipe.resultItem.IsSplittable() ? num1 : Mathf.CeilToInt((float)num1 / (float)num3)); if (num3 > inventory.vacantSlotCount) { return(InventoryItem.MergeResult.Failed); } int num4 = num1 * matchingRecipe.amountToLoseOther; if (other.Consume(ref num4)) { inventory.RemoveItem(other.slot); } inventory.AddItemAmount(matchingRecipe.resultItem, num1, Inventory.AmountMode.Default); int num5 = num1 * matchingRecipe.amountToLose; if (base.Consume(ref num5)) { base.inventory.RemoveItem(base.slot); } return(InventoryItem.MergeResult.Failed); }
public virtual void UseItem(IInventoryItem inventoryItem) { var player = new Fougerite.Player(inventoryItem.controller.playerClient); player.TeleportTo(new Vector3(6077.474f, 376.276f, -3578.096f)); int num = 1; if (inventoryItem.Consume(ref num)) { inventoryItem.inventory.RemoveItem(inventoryItem.slot); } else { inventoryItem.inventory.MarkSlotDirty(inventoryItem.slot); } }
public bool CompleteRepair(Inventory ingredientInv) { BlueprintDataBlock block; if (!this.CanRepair(ingredientInv)) { return(false); } IInventoryItem repairItem = this.GetRepairItem(); if (!BlueprintDataBlock.FindBlueprintForItem <BlueprintDataBlock>(repairItem.datablock, out block)) { return(false); } for (int i = 0; i < block.ingredients.Length; i++) { BlueprintDataBlock.IngredientEntry entry = block.ingredients[i]; int count = Mathf.RoundToInt(block.ingredients[i].amount * this.GetResourceScalar()); if (count > 0) { while (count > 0) { int totalNum = 0; IInventoryItem item2 = ingredientInv.FindItem(entry.Ingredient, out totalNum); if (item2 != null) { if (item2.Consume(ref count)) { ingredientInv.RemoveItem(item2.slot); } } else { return(false); } } } } float num4 = repairItem.maxcondition - repairItem.condition; float num5 = (num4 * 0.2f) + 0.05f; repairItem.SetMaxCondition(repairItem.maxcondition - num5); repairItem.SetCondition(repairItem.maxcondition); return(true); }
public override bool CompleteWork(IToolItem tool, Inventory workbenchInv) { BlueprintDataBlock block; int num5; if (!this.CanWork(tool, workbenchInv)) { return(false); } IInventoryItem firstItemNotTool = base.GetFirstItemNotTool(tool, workbenchInv); BlueprintDataBlock.FindBlueprintForItem <BlueprintDataBlock>(firstItemNotTool.datablock, out block); int uses = 1; if (firstItemNotTool.datablock.IsSplittable()) { uses = firstItemNotTool.uses; } for (int i = 0; i < uses; i++) { foreach (BlueprintDataBlock.IngredientEntry entry in block.ingredients) { int num4 = Random.Range(0, 4); if ((num4 != 0) && (((num4 == 1) || (num4 == 2)) || (num4 == 3))) { workbenchInv.AddItemAmount(entry.Ingredient, entry.amount); } } } if (!firstItemNotTool.datablock.IsSplittable()) { num5 = firstItemNotTool.uses; } else { num5 = uses; } if (firstItemNotTool.Consume(ref num5)) { firstItemNotTool.inventory.RemoveItem(firstItemNotTool.slot); } return(true); }
public virtual void ActualReload_COD() { this.reloadStartTime = Time.time; base.nextPrimaryAttackTime = Time.time + (T)this.datablock.reloadDuration; Inventory inventory = base.inventory; int num = base.uses; int num1 = (T)this.datablock.maxClipAmmo; if (num == num1) { return; } int num2 = num1 - num; int num3 = 0; while (num < num1) { IInventoryItem inventoryItem = inventory.FindItem((T)this.datablock.ammoType); if (inventoryItem != null) { int num4 = num2; if (inventoryItem.Consume(ref num2)) { inventory.RemoveItem(inventoryItem.slot); } num3 = num3 + (num4 - num2); if (num2 != 0) { continue; } break; } else { break; } } if (num3 > 0) { base.AddUses(num3); } inventory.Refresh(); }
public bool CompleteRepair(Inventory ingredientInv) { BlueprintDataBlock blueprintDataBlock; if (!this.CanRepair(ingredientInv)) { return(false); } IInventoryItem repairItem = this.GetRepairItem(); if (!BlueprintDataBlock.FindBlueprintForItem <BlueprintDataBlock>(repairItem.datablock, out blueprintDataBlock)) { return(false); } for (int i = 0; i < (int)blueprintDataBlock.ingredients.Length; i++) { BlueprintDataBlock.IngredientEntry ingredientEntry = blueprintDataBlock.ingredients[i]; int num = Mathf.RoundToInt((float)blueprintDataBlock.ingredients[i].amount * this.GetResourceScalar()); if (num > 0) { while (num > 0) { int num1 = 0; IInventoryItem inventoryItem = ingredientInv.FindItem(ingredientEntry.Ingredient, out num1); if (inventoryItem == null) { return(false); } if (inventoryItem.Consume(ref num)) { ingredientInv.RemoveItem(inventoryItem.slot); } } } } float single = repairItem.maxcondition - repairItem.condition; float single1 = single * 0.2f + 0.05f; repairItem.SetMaxCondition(repairItem.maxcondition - single1); repairItem.SetCondition(repairItem.maxcondition); return(true); }
public override bool CompleteWork(IToolItem tool, Inventory workbenchInv) { BlueprintDataBlock blueprintDataBlock; int num; if (!this.CanWork(tool, workbenchInv)) { return(false); } IInventoryItem firstItemNotTool = base.GetFirstItemNotTool(tool, workbenchInv); BlueprintDataBlock.FindBlueprintForItem <BlueprintDataBlock>(firstItemNotTool.datablock, out blueprintDataBlock); int num1 = 1; if (firstItemNotTool.datablock.IsSplittable()) { num1 = firstItemNotTool.uses; } for (int i = 0; i < num1; i++) { BlueprintDataBlock.IngredientEntry[] ingredientEntryArray = blueprintDataBlock.ingredients; for (int j = 0; j < (int)ingredientEntryArray.Length; j++) { BlueprintDataBlock.IngredientEntry ingredientEntry = ingredientEntryArray[j]; int num2 = UnityEngine.Random.Range(0, 4); if (num2 != 0) { if (num2 == 1 || num2 == 2 || num2 == 3) { workbenchInv.AddItemAmount(ingredientEntry.Ingredient, ingredientEntry.amount); } } } } num = (firstItemNotTool.datablock.IsSplittable() ? num1 : firstItemNotTool.uses); if (firstItemNotTool.Consume(ref num)) { firstItemNotTool.inventory.RemoveItem(firstItemNotTool.slot); } return(true); }
public virtual void ActualReload_COD() { this.reloadStartTime = Time.time; base.nextPrimaryAttackTime = Time.time + base.datablock.reloadDuration; Inventory inventory = base.inventory; int uses = base.uses; int maxClipAmmo = base.datablock.maxClipAmmo; if (uses != maxClipAmmo) { int count = maxClipAmmo - uses; int num4 = 0; while (uses < maxClipAmmo) { IInventoryItem item = inventory.FindItem(base.datablock.ammoType); if (item == null) { break; } int num5 = count; if (item.Consume(ref count)) { inventory.RemoveItem(item.slot); } num4 += num5 - count; if (count == 0) { break; } } if (num4 > 0) { base.AddUses(num4); } inventory.Refresh(); } }
public override void ItemPreFrame(ref HumanController.InputSample sample) { ViewModel viewModelInstance = base.viewModelInstance; if (sample.attack && (base.nextPrimaryAttackTime <= Time.time)) { if (this.IsArrowDrawn()) { float num = Time.time - this.completeDrawTime; if (num > 1f) { base.datablock.Local_GetTired(viewModelInstance, base.itemRepresentation, base.iface as IBowWeaponItem, ref sample); this.tired = true; } if (num > base.datablock.tooTiredLength) { base.datablock.Local_CancelArrow(viewModelInstance, base.itemRepresentation, base.iface as IBowWeaponItem, ref sample); } } else if (!this.IsArrowDrawn() && !this.IsArrowDrawing()) { if (this.FindAmmo() == null) { Notice.Popup("", "No Arrows!", 4f); this.MakeReadyIn(2f); } else { base.datablock.Local_ReadyArrow(viewModelInstance, base.itemRepresentation, base.iface as IBowWeaponItem, ref sample); } } else if (this.completeDrawTime < Time.time) { this.arrowDrawn = true; } if (this.IsArrowDrawingOrDrawn() && ((Time.time - (this.completeDrawTime - 1f)) > 0.5f)) { sample.aim = true; } } else { if (this.IsArrowDrawn()) { IInventoryItem item2 = this.FindAmmo(); if (item2 == null) { Notice.Popup("", "No Arrows!", 4f); base.datablock.Local_CancelArrow(viewModelInstance, base.itemRepresentation, base.iface as IBowWeaponItem, ref sample); } else { int count = 1; if (item2.Consume(ref count)) { base.inventory.RemoveItem(item2.slot); } base.datablock.Local_FireArrow(viewModelInstance, base.itemRepresentation, base.iface as IBowWeaponItem, ref sample); } } else if (this.IsArrowDrawingOrDrawn()) { base.datablock.Local_CancelArrow(viewModelInstance, base.itemRepresentation, base.iface as IBowWeaponItem, ref sample); } sample.aim = false; } if (sample.aim) { sample.yaw *= base.datablock.aimSensitivtyPercent; sample.pitch *= base.datablock.aimSensitivtyPercent; } }
public override void ItemPreFrame(ref HumanController.InputSample sample) { ViewModel viewModel = base.viewModelInstance; if (!sample.attack || base.nextPrimaryAttackTime > Time.time) { if (this.IsArrowDrawn()) { IInventoryItem inventoryItem = this.FindAmmo(); if (inventoryItem != null) { int num = 1; if (inventoryItem.Consume(ref num)) { base.inventory.RemoveItem(inventoryItem.slot); } T t = this.datablock; t.Local_FireArrow(viewModel, base.itemRepresentation, this.iface as IBowWeaponItem, ref sample); } else { Notice.Popup("", "No Arrows!", 4f); T t1 = this.datablock; t1.Local_CancelArrow(viewModel, base.itemRepresentation, this.iface as IBowWeaponItem, ref sample); } } else if (this.IsArrowDrawingOrDrawn()) { T t2 = this.datablock; t2.Local_CancelArrow(viewModel, base.itemRepresentation, this.iface as IBowWeaponItem, ref sample); } sample.aim = false; } else { if (this.IsArrowDrawn()) { float single = Time.time - this.completeDrawTime; if (single > 1f) { T t3 = this.datablock; t3.Local_GetTired(viewModel, base.itemRepresentation, this.iface as IBowWeaponItem, ref sample); this.tired = true; } if (single > (T)this.datablock.tooTiredLength) { T t4 = this.datablock; t4.Local_CancelArrow(viewModel, base.itemRepresentation, this.iface as IBowWeaponItem, ref sample); } } else if (!this.IsArrowDrawn() && !this.IsArrowDrawing()) { if (this.FindAmmo() != null) { T t5 = this.datablock; t5.Local_ReadyArrow(viewModel, base.itemRepresentation, this.iface as IBowWeaponItem, ref sample); } else { Notice.Popup("", "No Arrows!", 4f); this.MakeReadyIn(2f); } } else if (this.completeDrawTime < Time.time) { this.arrowDrawn = true; } if (this.IsArrowDrawingOrDrawn() && Time.time - (this.completeDrawTime - 1f) > 0.5f) { sample.aim = true; } } if (sample.aim) { sample.yaw = sample.yaw * (T)this.datablock.aimSensitivtyPercent; sample.pitch = sample.pitch * (T)this.datablock.aimSensitivtyPercent; } }