Esempio n. 1
0
        private bool ProcessAction(Action action)
        {
            var methodName = "ProcessAction";

            LogTrace(methodName, "Action: {0}", action.Name);

            var target = GetTargetEntityForAction(action);

            //If we're breaking on spawn and npcs have spawned, we're done.
            var npcCount = GetCurrentNpcCount();
            var returnForBreakOnSpawn = false;

            if (npcCount > _lastNpcCount)
            {
                if (action.BreakOnSpawn)
                {
                    LogMessage(methodName, LogSeverityTypes.Standard, "Breaking on spawn and npc count increased by {0}.",
                               npcCount - _lastNpcCount);
                    BreakAction(target);
                    returnForBreakOnSpawn = true;
                }
            }
            _lastNpcCount = npcCount;

            if (returnForBreakOnSpawn)
            {
                return(true);
            }

            //If we're breaking on targeted, and are being targeted by NPCs, we're done.
            if (action.BreakOnTargeted)
            {
                var npcsTargetingMe = _entityProvider.EntityWrappers.Count(x => x.IsNPC && x.IsTargetingMe);
                if (npcsTargetingMe > 0)
                {
                    LogMessage(methodName, LogSeverityTypes.Standard, "Breaking on targeted and targeted by {0} npcs.",
                               npcsTargetingMe);
                    BreakAction(target);
                    return(true);
                }
            }

            switch (action.Name)
            {
            case "NextRoom":
                return(ProcessNextRoom(action));

            case "ClearRoom":
                return(ProcessClearRoom(action));

            case "Approach":
                return(ProcessApproach(action, target));

            case "Loot":
            {
                var lootComplete = ProcessLoot(action);

                if (!lootComplete)
                {
                    if (_movement.IsNearbyCollidableAvoidanceEnabled)
                    {
                        _movement.DisableNearbyCollidableAvoidance();
                    }
                }
                else
                {
                    if (!_movement.IsNearbyCollidableAvoidanceEnabled)
                    {
                        _movement.EnableNearbyCollidableAvoidance();
                    }
                }

                return(lootComplete);
            }

            case "Kill":
                return(ProcessKill(action, target));

            default:
                return(false);
            }
        }