public virtual bool Execute() { if (this.HasExecuted || !this.CanExecute()) { this.SendInventories(); return(false); } InventoryTransactionEventArgs inventoryTransactionEvent = new InventoryTransactionEventArgs(this); InventoryEvents.OnInventoryTransaction(inventoryTransactionEvent); if (inventoryTransactionEvent.IsCancel) { this.SendInventories(); return(false); } for (int i = 0; i < this.Actions.Count; ++i) { if (!this.Actions[i].OnPreExecute(this.Player)) { this.SendInventories(); return(false); } } for (int i = 0; i < this.Actions.Count; ++i) { if (this.Actions[i].Execute(this.Player)) { this.Actions[i].OnExecuteSuccess(this.Player); } else { this.Actions[i].OnExecuteFail(this.Player); } } this.HasExecuted = true; return(true); }
public static void OnInventoryTransaction(InventoryTransactionEventArgs args) { InventoryTransaction?.Invoke(args); }