Example #1
0
        /// <inheritdoc />
        public void Execute(IEntity entity, SystemEventArgs args)
        {
            if (!(entity is IPlayerEntity player))
            {
                this._logger.LogError($"Cannot execute Level System. {entity.Object.Name} is not a player.");
                return;
            }

            if (!args.GetCheckArguments())
            {
                this._logger.LogError($"Cannot execute Level System action: {args.GetType()} due to invalid arguments.");
                return;
            }

            switch (args)
            {
            case ExperienceEventArgs e:
                this.GiveExperience(player, e);
                break;

            default:
                this._logger.LogWarning("Unknown level system action type: {0} for player {1}", args.GetType(), entity.Object.Name);
                break;
            }
        }
Example #2
0
        /// <inheritdoc />
        public void Execute(IEntity entity, SystemEventArgs args)
        {
            if (!(entity is IPlayerEntity player))
            {
                this._logger.LogError($"Cannot execute {nameof(RecoverySystem)}. {entity.Object.Name} is not a player.");
                return;
            }

            if (!args.GetCheckArguments())
            {
                this._logger.LogError($"Cannot execute {nameof(RecoverySystem)} action: {args.GetType()} due to invalid arguments.");
                return;
            }

            switch (args)
            {
            case IdleRecoveryEventArgs e:
                this.IdleHeal(player, e);
                break;

            default:
                this._logger.LogWarning($"Unknown recovery system action type: {args.GetType()} for player {entity.Object.Name}");
                break;
            }
        }
Example #3
0
        /// <inheritdoc />
        public void Execute(IEntity entity, SystemEventArgs args)
        {
            if (args == null)
            {
                Logger.LogError($"Cannot execute {nameof(DropSystem)}. Arguments are null.");
                return;
            }

            if (!args.GetCheckArguments())
            {
                Logger.LogError($"Cannot execute {nameof(DropSystem)} action: {args.GetType()} due to invalid arguments.");
                return;
            }

            switch (args)
            {
            case DropItemEventArgs dropItemEventArgs:
                this.DropItem(entity, dropItemEventArgs);
                break;

            case DropGoldEventArgs dropGoldEventArgs:
                this.DropGold(entity, dropGoldEventArgs);
                break;
            }
        }
Example #4
0
        /// <inheritdoc />
        public void Execute(IEntity entity, SystemEventArgs args)
        {
            if (entity == null)
            {
                this._logger.LogError($"Cannot execute {nameof(SpecialEffectSystem)}. Entity is null.");
                return;
            }

            if (!args.GetCheckArguments())
            {
                this._logger.LogError($"Cannot execute {nameof(SpecialEffectSystem)} action: {args.GetType()} due to invalid arguments.");
                return;
            }

            switch (args)
            {
            case SpecialEffectEventArgs e:
                this.StartSpecialEffect(entity, e);
                break;

            case SpecialEffectBaseMotionEventArgs e:
                this.SetStateModeBaseMotion(entity, e);
                break;
            }
        }
Example #5
0
        /// <inheritdoc />
        public void Execute(IEntity entity, SystemEventArgs e)
        {
            if (!(entity is IPlayerEntity player) ||
                !e.GetCheckArguments())
            {
                Logger.Error("NpcShopSystem: Invalid event arguments.");
                return;
            }

            switch (e)
            {
            case NpcShopOpenEventArgs npcShopEventArgs:
                this.OpenShop(player, npcShopEventArgs);
                break;

            case NpcShopCloseEventArgs npcShopEventArgs:
                this.CloseShop(player);
                break;

            case NpcShopBuyEventArgs npcShopEventArgs:
                this.BuyItem(player, npcShopEventArgs);
                break;

            case NpcShopSellEventArgs npcShopEventArgs:
                this.SellItem(player, npcShopEventArgs);
                break;

            default:
                Logger.Warn("Unknown NpcShop action type: {0} for player {1}", e.GetType(), entity.Object.Name);
                break;
            }
        }
Example #6
0
        /// <inheritdoc />
        public void Execute(IEntity entity, SystemEventArgs e)
        {
            if (!(entity is IPlayerEntity player))
            {
                return;
            }

            if (!e.GetCheckArguments())
            {
                Logger.LogError("Cannot execute inventory action: {0} due to invalid arguments.", e.GetType());
                return;
            }

            if (player.Health.IsDead)
            {
                this.Logger.LogWarning($"Cannot execute inventory action {e.GetType()}. Player '{player.Object.Name}' is dead.");
                return;
            }

            switch (e)
            {
            case InventoryInitializeEventArgs inventoryInitializeEvent:
                this.InitializeInventory(player, inventoryInitializeEvent);
                break;

            case InventoryMoveEventArgs inventoryMoveEvent:
                this.ProcessMoveItem(player, inventoryMoveEvent);
                break;

            case InventoryEquipEventArgs inventoryEquipEvent:
                this.ProcessEquipItem(player, inventoryEquipEvent);
                break;

            case InventoryCreateItemEventArgs inventoryCreateItemEvent:
                this.ProcessCreateItem(player, inventoryCreateItemEvent);
                break;

            case InventoryDropItemEventArgs inventoryDropItemEvent:
                this.ProcessDropItem(player, inventoryDropItemEvent);
                break;

            case InventoryUseItemEventArgs inventoryUseItemEvent:
                this.ProcessUseItem(player, inventoryUseItemEvent);
                break;

            default:
                Logger.LogWarning("Unknown inventory action type: {0} for player {1}", e.GetType(), entity.Object.Name);
                break;
            }
        }
Example #7
0
        /// <inheritdoc />
        public void Execute(IEntity entity, SystemEventArgs e)
        {
            if (!(entity is IMovableEntity movableEntity) || !e.GetCheckArguments())
            {
                Logger.Error("FollowSystem: Invalid arguments");
                return;
            }

            switch (e)
            {
            case FollowEventArgs followEvent:
                this.OnFollow(movableEntity, followEvent);
                break;
            }
        }
Example #8
0
        /// <inheritdoc />
        public void Execute(IEntity entity, SystemEventArgs e)
        {
            if (!e.GetCheckArguments() || !(entity is IPlayerEntity playerEntity))
            {
                return;
            }

            switch (e)
            {
            case TradeRequestEventArgs tradeRequestEventArgs:
                TradeRequest(playerEntity, tradeRequestEventArgs);
                break;

            case TradeRequestCancelEventArgs tradeRequestCancelEventArgs:
                TradeRequestCancel(playerEntity, tradeRequestCancelEventArgs);
                break;

            case TradeBeginEventArgs tradeBeginEventArgs:
                Trade(playerEntity, tradeBeginEventArgs);
                break;

            case TradePutEventArgs tradePutEventArgs:
                PutItem(playerEntity, tradePutEventArgs);
                break;

            case TradePutGoldEventArgs tradePutGoldEventArgs:
                PutGold(playerEntity, tradePutGoldEventArgs);
                break;

            case TradeCancelEventArgs tradeCancelEventArgs:
                TradeCancel(playerEntity, tradeCancelEventArgs);
                break;

            case TradeConfirmEventArgs tradeConfirmEventArgs:
                TradeConfirm(playerEntity, tradeConfirmEventArgs);
                break;

            case TradeOkEventArgs tradeOkEventArgs:
                TradeOk(playerEntity, tradeOkEventArgs);
                break;

            default:
                Logger.Warn("Unknown trade action type: {0} for player {1}", e.GetType(), entity.Object.Name);
                break;
            }
        }
Example #9
0
        /// <inheritdoc />
        public void Execute(IEntity entity, SystemEventArgs args)
        {
            if (!(entity is IPlayerEntity player))
            {
                this._logger.LogError($"Cannot execute {nameof(TeleportSystem)}. {entity.Object.Name} is not a player.");
                return;
            }

            if (!args.GetCheckArguments())
            {
                this._logger.LogError($"Cannot execute {nameof(TeleportSystem)} action: {args.GetType()} due to invalid arguments.");
                return;
            }

            switch (args)
            {
            case TeleportEventArgs e:
                this.Teleport(player, e);
                break;
            }
        }
Example #10
0
        /// <inheritdoc />
        public void Execute(IEntity entity, SystemEventArgs args)
        {
            if (!args.GetCheckArguments())
            {
                Logger.LogError("Cannot execute battle action: {0} due to invalid arguments.", args.GetType());
                return;
            }

            if (!(entity is ILivingEntity livingEntity))
            {
                Logger.LogError($"The non living entity {entity.Object.Name} tried to execute a battle action.");
                return;
            }

            switch (args)
            {
            case MeleeAttackEventArgs meleeAttackEventArgs:
                this.ProcessMeleeAttack(livingEntity, meleeAttackEventArgs);
                break;
            }
        }
Example #11
0
        /// <inheritdoc />
        public void Execute(IEntity entity, SystemEventArgs e)
        {
            if (!(entity is IPlayerEntity playerEntity))
            {
                return;
            }

            if (!e.GetCheckArguments())
            {
                Logger.LogError($"Cannot execute mailbox action: {e.GetType()} due to invalid arguments.");
                return;
            }

            switch (e)
            {
            case QueryMailboxEventArgs queryMailboxEvent:
                GetMails(playerEntity, queryMailboxEvent);
                break;

            case QueryPostMailEventArgs queryPostMailEvent:
                SendMail(playerEntity, queryPostMailEvent);
                break;

            case QueryRemoveMailEventArgs queryRemoveMailEvent:
                RemoveMail(playerEntity, queryRemoveMailEvent);
                break;

            case QueryGetMailItemEventArgs queryGetMailItemEvent:
                GetMailItem(playerEntity, queryGetMailItemEvent);
                break;

            case QueryGetMailGoldEventArgs queryGetMailGoldEvent:
                GetMailGold(playerEntity, queryGetMailGoldEvent);
                break;

            case ReadMailEventArgs readMailEvent:
                ReadMail(playerEntity, readMailEvent);
                break;
            }
        }
Example #12
0
        public void Execute(IEntity entity, SystemEventArgs args)
        {
            if (!(entity is IPlayerEntity playerEntity) || !args.GetCheckArguments())
            {
                Logger.LogError("CustomizationSystem: Invalid arguments.");
                return;
            }

            switch (args)
            {
            case ChangeFaceEventArgs e:
                OnChangeFace(playerEntity, e);
                break;

            case SetHairEventArgs e:
                OnSetHair(playerEntity, e);
                break;

            default:
                Logger.LogWarning("Unknown Customization action type: {0} for player {1}", args.GetType(), entity.Object.Name);
                break;
            }
        }
Example #13
0
        public void Execute(IEntity entity, SystemEventArgs args)
        {
            if (!(entity is IPlayerEntity player))
            {
                return;
            }

            if (!args.GetCheckArguments())
            {
                Logger.LogWarning("Invalid arguments received.");
                return;
            }

            switch (args)
            {
            case AddTaskbarAppletEventArgs e:
                HandleAddAppletTaskbarShortcut(player, e);
                break;

            case RemoveTaskbarAppletEventArgs e:
                HandleRemoveAppletTaskbarShortcut(player, e);
                break;

            case AddTaskbarItemEventArgs e:
                HandleAddItemTaskbarShortcut(player, e);
                break;

            case RemoveTaskbarItemEventArgs e:
                HandleRemoveItemTaskbarShortcut(player, e);
                break;

            case TaskbarSkillEventArgs e:
                HandleActionSlot(player, e);
                break;
            }
        }
Example #14
0
        /// <summary>
        /// Executes the <see cref="InteractionSystem"/> logic.
        /// </summary>
        /// <param name="entity">Current entity</param>
        public void Execute(IEntity entity, SystemEventArgs e)
        {
            if (!(entity is IPlayerEntity playerEntity))
            {
                return;
            }

            if (!e.GetCheckArguments())
            {
                Logger.LogError("Cannot execute interaction action: {0} due to invalid arguments.", e.GetType());
                return;
            }

            switch (e)
            {
            case SetTargetEventArgs setTargetEventArgs:
                this.SetTarget(playerEntity, setTargetEventArgs);
                break;

            default:
                Logger.LogWarning("Unknown interaction action type: {0} for player {1}", e.GetType(), entity.Object.Name);
                break;
            }
        }
Example #15
0
        public void Execute(IEntity entity, SystemEventArgs e)
        {
            if (!(entity is IPlayerEntity playerEntity))
            {
                return;
            }

            if (!e.GetCheckArguments())
            {
                Logger.LogError($"Cannot execute player data action {e.GetType()} due to invalid arguments.");
                return;
            }

            switch (e)
            {
            case QueryPlayerDataEventArgs queryPlayerDataEvent:
                GetPlayerData(playerEntity, queryPlayerDataEvent);
                break;

            case QueryPlayerData2EventArgs queryPlayerData2Event:
                GetPlayerData(playerEntity, queryPlayerData2Event);
                break;
            }
        }
Example #16
0
        public void Execute(IEntity entity, SystemEventArgs args)
        {
            if (!(entity is IPlayerEntity player))
            {
                return;
            }

            if (!args.GetCheckArguments())
            {
                Logger.LogError("PartySystem: Invalid event action arguments.");
                return;
            }

            switch (args)
            {
            case PartyMemberRequestEventArgs e:
                OnPartyMemberRequest(player, e);
                break;

            case PartyMemberRequestCancelEventArgs e:
                OnPartyMemberRequestCancel(player, e);
                break;

            case PartyAddMemberEventArgs e:
                OnAddPartyMember(player, e);
                break;

            case PartyRemoveMemberEventArgs e:
                OnRemovePartyMember(player, e);
                break;

            default:
                Logger.LogWarning("Unknown statistics action type: {0} for player {1}", args.GetType(), entity.Object.Name);
                break;
            }
        }
Example #17
0
        /// <inheritdoc />
        public void Execute(IEntity entity, SystemEventArgs e)
        {
            if (!(entity is IPlayerEntity playerEntity) ||
                !e.GetCheckArguments())
            {
                Logger.Error("StatisticsSystem: Invalid event action arguments.");
                return;
            }

            Logger.Debug("Execute statistics action: {0}", e.GetType());

            switch (e)
            {
            case StatisticsModifyEventArgs statisticsModifyEvent:
                this.ModifyStatus(playerEntity, statisticsModifyEvent);
                break;

            default:
                Logger.Warn("Unknown statistics action type: {0} for player {1}", e.GetType(), entity.Object.Name);
                break;
            }

            WorldPacketFactory.SendUpdateState(playerEntity);
        }