public static void BlueprintUse(IBlueprintItem item, BlueprintDataBlock bdb) { Contract.Requires(item != null); Contract.Requires(bdb != null); if (item.controllable == null) throw new InvalidOperationException("IBlueprintItem's controllable is null."); if (item.controllable.playerClient == null) throw new InvalidOperationException("IBlueprintItem's playerClient is null."); Fougerite.Player player = Fougerite.Player.FindByPlayerClient(item.controllable.playerClient); if (player == null) return; BPUseEvent ae = new BPUseEvent(bdb); if (OnBlueprintUse != null) OnBlueprintUse(player, ae); if (ae.Cancel) return; PlayerInventory internalInventory = player.Inventory.InternalInventory as PlayerInventory; if (internalInventory.BindBlueprint(bdb)) { int count = 1; if (item.Consume(ref count)) { internalInventory.RemoveItem(item.slot); } player.Notice("", "You can now craft: " + bdb.resultItem.name, 4f); } else { player.Notice("", "You already have this blueprint", 4f); } }
public RPOSCraftItemEntry GetEntryByBP(BlueprintDataBlock bp) { RPOSCraftItemEntry rPOSCraftItemEntry; IEnumerator enumerator = base.transform.GetEnumerator(); try { while (enumerator.MoveNext()) { RPOSCraftItemEntry component = (enumerator.Current as Transform).GetComponent <RPOSCraftItemEntry>(); if (!component || !(component.blueprint == bp)) { continue; } rPOSCraftItemEntry = component; return(rPOSCraftItemEntry); } return(null); } finally { IDisposable disposable = enumerator as IDisposable; if (disposable == null) { } disposable.Dispose(); } return(rPOSCraftItemEntry); }
public static void BlueprintUse(IBlueprintItem item, BlueprintDataBlock bdb) { //Fougerite.Player player = Fougerite.Player.FindByPlayerClient(item.controllable.playerClient); Fougerite.Player player = Fougerite.Server.Cache[item.controllable.playerClient.userID]; if (player != null) { BPUseEvent ae = new BPUseEvent(bdb, item); if (OnBlueprintUse != null) { OnBlueprintUse(player, ae); } if (!ae.Cancel) { PlayerInventory internalInventory = player.Inventory.InternalInventory as PlayerInventory; if (internalInventory.BindBlueprint(bdb)) { int count = 1; if (item.Consume(ref count)) { internalInventory.RemoveItem(item.slot); } player.Notice("", "You can now craft: " + bdb.resultItem.name, 4f); } else { player.Notice("", "You already have this blueprint", 4f); } } } }
public BPUseEvent(BlueprintDataBlock bdb) { Contract.Requires(bdb != null); this.DataBlock = bdb; this.Cancel = false; }
public bool AnyOfCategoryInList(ItemDataBlock.ItemCategory category, List <BlueprintDataBlock> checkList) { bool flag; List <BlueprintDataBlock> .Enumerator enumerator = checkList.GetEnumerator(); try { while (enumerator.MoveNext()) { BlueprintDataBlock current = enumerator.Current; if (current != null) { if (current.resultItem.category != category) { continue; } flag = true; return(flag); } else { Debug.Log("WTFFFF"); flag = false; return(flag); } } return(false); } finally { ((IDisposable)(object)enumerator).Dispose(); } return(flag); }
public override InventoryItem.MergeResult TryCombine(IInventoryItem otherItem) { BlueprintDataBlock blueprintDataBlock; PlayerInventory playerInventory = base.inventory as PlayerInventory; if (!playerInventory || otherItem.inventory != playerInventory) { return(InventoryItem.MergeResult.Failed); } ItemDataBlock itemDataBlock = otherItem.datablock; if (!itemDataBlock || !itemDataBlock.isResearchable) { Notice.Popup("", "You can't research this", 4f); return(InventoryItem.MergeResult.Failed); } if (!playerInventory.AtWorkBench()) { Notice.Popup("", "You must be at a workbench to do this.", 4f); return(InventoryItem.MergeResult.Failed); } if (!BlueprintDataBlock.FindBlueprintForItem <BlueprintDataBlock>(otherItem.datablock, out blueprintDataBlock)) { Notice.Popup("", "You can't research this.. No Blueprint Available!...", 4f); return(InventoryItem.MergeResult.Failed); } if (!playerInventory.KnowsBP(blueprintDataBlock)) { return(InventoryItem.MergeResult.Combined); } Notice.Popup("", "You already know how to make this!", 4f); return(InventoryItem.MergeResult.Failed); }
public void ItemClicked(GameObject go) { if (RPOS.ObservedPlayer.GetComponent <CraftingInventory>().isCrafting) { return; } RPOSCraftItemEntry component = go.GetComponent <RPOSCraftItemEntry>(); if (component == null) { return; } BlueprintDataBlock blueprintDataBlock = component.blueprint; if (!blueprintDataBlock) { Debug.Log("no bp by that name"); return; } if (blueprintDataBlock != this.selectedItem) { this.SetSelectedItem(component.blueprint); this.UpdateIngredients(); } }
public RPOSCraftItemEntry GetEntryByBP(BlueprintDataBlock bp) { IEnumerator enumerator = base.transform.GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.Current; RPOSCraftItemEntry component = (current as Transform).GetComponent <RPOSCraftItemEntry>(); if ((component != null) && (component.blueprint == bp)) { return(component); } } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable == null) { } disposable.Dispose(); } return(null); }
public bool CanRepair(Inventory ingredientInv) { BlueprintDataBlock blueprintDataBlock; IInventoryItem repairItem = this.GetRepairItem(); if (repairItem == null || !repairItem.datablock.isRepairable) { return(false); } if (!repairItem.IsDamaged()) { return(false); } 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.CeilToInt((float)blueprintDataBlock.ingredients[i].amount * this.GetResourceScalar()); if (num > 0 && ingredientInv.CanConsume(blueprintDataBlock.ingredients[i].Ingredient, num) <= 0) { return(false); } } return(true); }
public void SetSelectedItem(BlueprintDataBlock newSel) { !this.selectedItem; this.selectedItem = newSel; this.SetRequestedAmount(1); !this.selectedItem; this.ShowCraftingOptions(this.selectedItem != null); this.UpdateWorkbenchRequirements(); }
public static void CraftingEvent(CraftingInventory inv, BlueprintDataBlock blueprint, int amount, ulong startTime) { CraftingEvent e = new CraftingEvent(inv, blueprint, amount, startTime); if (OnCrafting != null) { OnCrafting(e); } }
public bool StartCrafting(BlueprintDataBlock blueprint, int amount) { if (!blueprint.CanWork(amount, this)) { return(false); } base.networkView.RPC("CRFS", uLink.RPCMode.Server, new object[] { amount, blueprint.uniqueID }); return(true); }
public static void BlueprintDataBlock_UseItem(BlueprintDataBlock hook, IBlueprintItem item) { object[] args = new object[] { hook, item }; Method.Invoke("RustExtended.RustHook.BlueprintDataBlock_UseItem", args); }
public virtual BlueprintDataBlock GetMatchingDBForItems() { ArrayList list = new ArrayList(); foreach (ItemDataBlock block in DatablockDictionary.All) { if (!(block is BlueprintDataBlock)) { continue; } BlueprintDataBlock block2 = block as BlueprintDataBlock; bool flag = true; foreach (BlueprintDataBlock.IngredientEntry entry in block2.ingredients) { int totalNum = 0; if ((this._inventory.FindItem(entry.Ingredient, out totalNum) == null) || (totalNum < entry.amount)) { flag = false; break; } } if (flag) { list.Add(block2); } } if (list.Count <= 0) { return(null); } BlueprintDataBlock block3 = null; int length = -1; IEnumerator enumerator = list.GetEnumerator(); try { while (enumerator.MoveNext()) { BlueprintDataBlock current = (BlueprintDataBlock)enumerator.Current; if (current.ingredients.Length > length) { block3 = current; length = current.ingredients.Length; } } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable == null) { } disposable.Dispose(); } return(block3); }
public bool StartCrafting(BlueprintDataBlock blueprint, int amount) { if (blueprint.CanWork(amount, this)) { object[] args = new object[] { amount, blueprint.uniqueID }; base.networkView.RPC("CRFS", RPCMode.Server, args); return(true); } return(false); }
public bool HasBlueprint(BlueprintDataBlock dataBlock) { PlayerInventory invent = this.Inventory.InternalInventory as PlayerInventory; if (invent.KnowsBP(dataBlock)) { return(true); } return(false); }
public static bool BlueprintDataBlock_CompleteWork(BlueprintDataBlock blueprint, int amount, Inventory inventory) { object[] args = new object[] { blueprint, amount, inventory }; return(Method.Invoke("RustExtended.RustHook.BlueprintDataBlock_CompleteWork", args).AsBoolean); }
public override bool CompleteWork(IToolItem tool, Inventory workbenchInv) { BlueprintDataBlock block; if (this.CanWork(tool, workbenchInv) && BlueprintDataBlock.FindBlueprintForItem <BlueprintDataBlock>(base.GetFirstItemNotTool(tool, workbenchInv).datablock, out block)) { workbenchInv.AddItem(block, Inventory.Slot.Preference.Define(Inventory.Slot.Kind.Default, block.IsSplittable(), Inventory.Slot.Kind.Belt), 1); return(true); } return(false); }
public static void CraftingInventory_StartCrafting(CraftingInventory hook, BlueprintDataBlock blueprint, int amount, ulong startTime) { object[] args = new object[] { hook, blueprint, amount, startTime }; Method.Invoke("RustExtended.RustHook.CraftingInventory_StartCrafting", args); }
public bool ValidateCraftRequirements(BlueprintDataBlock bp) { if (!bp.RequireWorkbench) { return(true); } if (this.AtWorkBench()) { return(true); } return(false); }
protected void UpdateCrafting(BlueprintDataBlock blueprint, int amount, float start, float dur, float progress, float progresspersec) { Debug.Log(string.Format("Craft network update :{0}:", (blueprint == null) ? "NONE" : blueprint.name), this); this._lastThinkTime = NetCull.time; this.crafting.blueprint = blueprint; this.crafting.inProgress = (bool)blueprint; this.crafting.startTime = start; this.crafting.duration = dur; this.crafting.progressSeconds = progress; this.crafting.progressPerSec = progresspersec; this.crafting.amount = amount; this.Refresh(); }
private static bool smethod_3(ItemDataBlock itemDataBlock_0, out BlueprintDataBlock blueprintDataBlock_0) { foreach (ItemDataBlock block in DatablockDictionary.All) { BlueprintDataBlock block2 = block as BlueprintDataBlock; if ((block2 != null) && (block2.resultItem == itemDataBlock_0)) { blueprintDataBlock_0 = block2; return(true); } } blueprintDataBlock_0 = null; return(false); }
object OnItemCraft(CraftingInventory inv, BlueprintDataBlock bpdb, int amount, ulong starttime) { if (!blockedCrafting.Contains(bpdb.resultItem.name)) { return(null); } NetUser netuser = (inv.idMain as Character).netUser; if (netuser != null) { ConsoleNetworker.SendClientCommand(netuser.networkPlayer, "notice.popup 10 q " + Facepunch.Utility.String.QuoteSafe(blockCraftMessage)); } return(true); }
private static bool smethod_9(UnityEngine.Object object_0, out BlueprintDataBlock blueprintDataBlock_0) { ItemDataBlock[] all = DatablockDictionary.All; for (int i = 0; i < all.Length; i++) { BlueprintDataBlock block = all[i] as BlueprintDataBlock; if ((block != null) && (block.resultItem == object_0)) { blueprintDataBlock_0 = block; return(true); } } blueprintDataBlock_0 = null; return(false); }
public static void BlueprintUse(IBlueprintItem item, BlueprintDataBlock bdb) { Contract.Requires(item != null); Contract.Requires(bdb != null); if (item.controllable == null) { throw new InvalidOperationException("IBlueprintItem's controllable is null."); } if (item.controllable.playerClient == null) { throw new InvalidOperationException("IBlueprintItem's playerClient is null."); } Fougerite.Player player = Fougerite.Player.FindByPlayerClient(item.controllable.playerClient); if (player == null) { return; } BPUseEvent ae = new BPUseEvent(bdb); if (OnBlueprintUse != null) { OnBlueprintUse(player, ae); } if (ae.Cancel) { return; } PlayerInventory internalInventory = player.Inventory.InternalInventory as PlayerInventory; if (internalInventory.BindBlueprint(bdb)) { int count = 1; if (item.Consume(ref count)) { internalInventory.RemoveItem(item.slot); } player.Notice("", "You can now craft: " + bdb.resultItem.name, 4f); } else { player.Notice("", "You already have this blueprint", 4f); } }
void BlueprintUse_Test() { try { BlueprintDataBlock BDB = new BlueprintDataBlock(); Log("BlueprintUse_Test: Test 1"); Hooks.BlueprintUse(null, BDB); Log("BlueprintUse_Test: Test 2"); Hooks.BlueprintUse(null, null); } catch (Exception ex) { Logger.LogException(ex); } }
public bool Restart(Inventory inventory, int amount, BlueprintDataBlock blueprint, ulong startTimeMillis) { if (!blueprint || !blueprint.CanWork(amount, inventory)) { this = new CraftingSession(); return false; } this.blueprint = blueprint; this.startTime = (float)((double)((float)startTimeMillis) / 1000); this.duration = blueprint.craftingDuration * (float)amount; this.progressPerSec = 1f; this.progressSeconds = 0f; this.amount = amount; this.inProgress = true; return true; }
public bool Restart(Inventory inventory, int amount, BlueprintDataBlock blueprint, ulong startTimeMillis) { if (!blueprint || !blueprint.CanWork(amount, inventory)) { this = new CraftingSession(); return(false); } this.blueprint = blueprint; this.startTime = (float)((double)((float)startTimeMillis) / 1000); this.duration = blueprint.craftingDuration * (float)amount; this.progressPerSec = 1f; this.progressSeconds = 0f; this.amount = amount; this.inProgress = true; return(true); }
public override bool CanWork(IToolItem tool, Inventory workbenchInv) { if (workbenchInv.occupiedSlotCount > 2) { Debug.Log("Too many items for research"); return(false); } IInventoryItem firstItemNotTool = base.GetFirstItemNotTool(tool, workbenchInv); if (firstItemNotTool != null && firstItemNotTool.datablock.isResearchable && BlueprintDataBlock.FindBlueprintForItem(firstItemNotTool.datablock)) { return(true); } Debug.Log("Can't work!?!!?"); return(false); }
public static bool BlueprintUse(IBlueprintItem item, BlueprintDataBlock bdb) { Magma.Player player = Magma.Player.FindByPlayerClient(item.controllable.playerClient); if (player != null) { BPUseEvent ae = new BPUseEvent(bdb); if (OnBlueprintUse != null) { OnBlueprintUse(player, ae); } if (!ae.Cancel) { return(true); } } return(false); }
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); }
object OnBlueprintUse(BlueprintDataBlock bpdb, IBlueprintItem item) { if (!blockedBlueprints.Contains(bpdb.name)) { return(null); } if (!item.inventory) { return(null); } NetUser netuser = (item.inventory.idMain as Character).netUser; if (netuser != null) { ConsoleNetworker.SendClientCommand(netuser.networkPlayer, "notice.popup 10 q " + Facepunch.Utility.String.QuoteSafe(blockBlueprintMessage)); } return(true); }
public static bool CanCraft(int amount, Inventory workbenchInv, BlueprintDataBlock BDB) { if (BDB.lastCanWorkResult == null) { BDB.lastCanWorkResult = new List<int>(); } else { BDB.lastCanWorkResult.Clear(); } if (BDB.lastCanWorkIngredientCount == null) { BDB.lastCanWorkIngredientCount = new List<int>(BDB.ingredients.Length); } else { BDB.lastCanWorkIngredientCount.Clear(); } PlayerClient playerClient = Array.Find(AllPlayerClients.ToArray(), (PlayerClient pc) => pc.netPlayer == workbenchInv.networkView.owner); if (playerClient != null) { if (!craftList.Contains(playerClient.userID.ToString())) { if (BDB.RequireWorkbench && craftAtBench) { CraftingInventory component = workbenchInv.GetComponent<CraftingInventory>(); if ((component == null) || !component.AtWorkBench()) { return false; } } } } else { if (BDB.RequireWorkbench && craftAtBench) { CraftingInventory component = workbenchInv.GetComponent<CraftingInventory>(); if ((component == null) || !component.AtWorkBench()) { return false; } } } if (playerClient != null) { if (!craftList.Contains(playerClient.userID.ToString())) { foreach (BlueprintDataBlock.IngredientEntry entry in BDB.ingredients) { if (entry.amount != 0) { int item = workbenchInv.CanConsume(entry.Ingredient, entry.amount * amount, BDB.lastCanWorkResult); if (item <= 0) { BDB.lastCanWorkResult.Clear(); BDB.lastCanWorkIngredientCount.Clear(); return false; } BDB.lastCanWorkIngredientCount.Add(item); } } } } else { foreach (BlueprintDataBlock.IngredientEntry entry in BDB.ingredients) { if (entry.amount != 0) { int item = workbenchInv.CanConsume(entry.Ingredient, entry.amount * amount, BDB.lastCanWorkResult); if (item <= 0) { BDB.lastCanWorkResult.Clear(); BDB.lastCanWorkIngredientCount.Clear(); return false; } BDB.lastCanWorkIngredientCount.Add(item); } } } return true; }
private void OnBlueprintUse(BlueprintDataBlock bp, IBlueprintItem item) { HookCalled("OnBlueprintUse"); // TODO: Complete parameters var netUser = item.inventory.GetComponent<Character>()?.netUser; if (netUser == null) return; Puts(netUser.displayName + " used the blueprint " + item.datablock.name + " to learn how to craft " + bp.resultItem.name); }
private void OnItemCraft(CraftingInventory inventory, BlueprintDataBlock blueprint, int amount, ulong startTime) { HookCalled("OnItemCraft"); // Print item crafting var netUser = inventory.GetComponent<Character>().netUser; Puts(netUser.displayName + " started crafting " + blueprint.resultItem.name + " x " + amount.ToString()); }
public bool ValidateCraftRequirements(BlueprintDataBlock bp) { if (!bp.RequireWorkbench) { return true; } if (this.AtWorkBench()) { return true; } return false; }
public bool StartCrafting(BlueprintDataBlock blueprint, int amount) { if (!blueprint.CanWork(amount, this)) { return false; } base.networkView.RPC("CRFS", uLink.RPCMode.Server, new object[] { amount, blueprint.uniqueID }); return true; }
public bool HasBlueprint(BlueprintDataBlock dataBlock) { PlayerInventory invent = this.Inventory.InternalInventory as PlayerInventory; if (invent.KnowsBP(dataBlock)) return true; return false; }
protected void UpdateCrafting(BlueprintDataBlock blueprint, int amount, float start, float dur, float progress, float progresspersec) { Debug.Log(string.Format("Craft network update :{0}:", (!blueprint ? "NONE" : blueprint.name)), this); this._lastThinkTime = NetCull.time; this.crafting.blueprint = blueprint; this.crafting.inProgress = blueprint; this.crafting.startTime = start; this.crafting.duration = dur; this.crafting.progressSeconds = progress; this.crafting.progressPerSec = progresspersec; this.crafting.amount = amount; this.Refresh(); }
public static void ResearchItem(IBlueprintItem item, BlueprintDataBlock BDB) { PlayerInventory inventory = item.inventory as PlayerInventory; if (inventory != null) { bool b = false; PlayerClient playerClient = Array.Find(AllPlayerClients.ToArray(), (PlayerClient pc) => pc.netPlayer == inventory.networkView.owner); if (!restrictBlueprints.Contains(BDB.resultItem.name) || craftList.Contains(playerClient.userID.ToString())) { if (inventory.BindBlueprint(BDB)) { int count = 1; if (item.Consume(ref count)) { inventory.RemoveItem(item.slot); } Rust.Notice.Popup(inventory.networkView.owner, "", "You can now craft: " + BDB.resultItem.name, 4f); } else { Rust.Notice.Popup(inventory.networkView.owner, "", "You already researched this.", 4f); } } else Broadcast.noticeTo(inventory.networkView.owner, "", "You cannot research this item!", 4); } }
public static bool CraftItem(int amount, Inventory workbenchInv, BlueprintDataBlock BDB) { if (!BDB.CanWork(amount, workbenchInv)) { return false; } int num = 0; PlayerClient playerClient = Array.Find(AllPlayerClients.ToArray(), (PlayerClient pc) => pc.netPlayer == workbenchInv.networkView.owner); if (playerClient != null) { if (!restrictCrafting.Contains(BDB.resultItem.name) || craftList.Contains(playerClient.userID.ToString())) { for (int i = 0; i < BDB.ingredients.Length; i++) { int count = BDB.ingredients[i].amount * amount; if (count != 0) { int num4 = BDB.lastCanWorkIngredientCount[i]; for (int j = 0; j < num4; j++) { IInventoryItem item; int slot = BDB.lastCanWorkResult[num++]; if (workbenchInv.GetItem(slot, out item) && item.Consume(ref count)) { workbenchInv.RemoveItem(slot); } } } } } else { Broadcast.noticeTo(workbenchInv.networkView.owner, "♨", "You cannot craft this item!", 4); return false; } } else { if (!restrictCrafting.Contains(BDB.resultItem.name)) { for (int i = 0; i < BDB.ingredients.Length; i++) { int count = BDB.ingredients[i].amount * amount; if (count != 0) { int num4 = BDB.lastCanWorkIngredientCount[i]; for (int j = 0; j < num4; j++) { IInventoryItem item; int slot = BDB.lastCanWorkResult[num++]; if (workbenchInv.GetItem(slot, out item) && item.Consume(ref count)) { workbenchInv.RemoveItem(slot); } } } } } else { Broadcast.noticeTo(workbenchInv.networkView.owner, "♨", "You cannot craft this item!", 4); return false; } } workbenchInv.AddItemAmount(BDB.resultItem, amount * BDB.numResultItem); return true; }
private void OnItemCraft(CraftingInventory inventory, BlueprintDataBlock blueprint, int amount, ulong startTime) { HookCalled("OnItemCraft"); // TODO: Print item crafting }