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 BlueprintDataBlock_UseItem(BlueprintDataBlock hook, IBlueprintItem item) { object[] args = new object[] { hook, item }; Method.Invoke("RustExtended.RustHook.BlueprintDataBlock_UseItem", args); }
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 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); }
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 BlueprintUse(IBlueprintItem item, BlueprintDataBlock bdb) { Player player = Player.FindByPlayerClient(item.controllable.playerClient); bool result; if (player != null) { BPUseEvent bPUseEvent = new BPUseEvent(bdb); if (Hooks.OnBlueprintUse != null) { Hooks.OnBlueprintUse(player, bPUseEvent); } if (!bPUseEvent.Cancel) { result = true; return(result); } } result = false; return(result); }
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); }
public BPUseEvent(BlueprintDataBlock bdb, IBlueprintItem item) { this.DataBlock = bdb; this.Cancel = false; this._item = item; }
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 virtual void UseItem(IBlueprintItem item) { }