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 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 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 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); } }