Пример #1
0
        public void Begin([NotNull] IEnumerable <Target> targetEnumerable)
        {
            //IL_00c1: Unknown result type (might be due to invalid IL or missing references)
            //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
            IMapStateProvider        mapStateProvider = stateProvider;
            List <Target>            data             = m_data;
            Dictionary <int, Target> targets          = m_targets;
            bool flag = false;

            foreach (Target item in targetEnumerable)
            {
                data.Add(item);
                switch (item.type)
                {
                case Target.Type.Coord:
                {
                    Coord coord      = item.coord;
                    int   cellIndex2 = mapStateProvider.GetCellIndex(coord.x, coord.y);
                    targets.Add(cellIndex2, item);
                    break;
                }

                case Target.Type.Entity:
                {
                    IEntityWithBoardPresence entityWithBoardPresence;
                    if ((entityWithBoardPresence = (item.entity as IEntityWithBoardPresence)) != null)
                    {
                        ICharacterObject characterObject;
                        if ((characterObject = (entityWithBoardPresence.view as ICharacterObject)) != null)
                        {
                            characterObject.ShowSpellTargetFeedback(isSelected: false);
                        }
                        Vector2Int[] occupiedCoords = entityWithBoardPresence.area.occupiedCoords;
                        int          num            = occupiedCoords.Length;
                        for (int i = 0; i < num; i++)
                        {
                            Vector2Int val       = occupiedCoords[i];
                            int        cellIndex = mapStateProvider.GetCellIndex(val.get_x(), val.get_y());
                            targets.Add(cellIndex, item);
                        }
                        flag = true;
                    }
                    break;
                }

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            if (flag)
            {
                StartCharacterFocus();
            }
            isActive = (targets.Count > 0);
        }
Пример #2
0
        public void Refresh()
        {
            //IL_00b0: Unknown result type (might be due to invalid IL or missing references)
            //IL_00b5: Unknown result type (might be due to invalid IL or missing references)
            if (!isActive)
            {
                return;
            }
            IMapStateProvider        mapStateProvider = stateProvider;
            List <Target>            data             = m_data;
            Dictionary <int, Target> targets          = m_targets;

            targets.Clear();
            int count = data.Count;

            for (int i = 0; i < count; i++)
            {
                Target target = data[i];
                switch (target.type)
                {
                case Target.Type.Coord:
                {
                    Coord coord      = target.coord;
                    int   cellIndex2 = mapStateProvider.GetCellIndex(coord.x, coord.y);
                    targets.Add(cellIndex2, target);
                    break;
                }

                case Target.Type.Entity:
                {
                    IEntityWithBoardPresence entityWithBoardPresence;
                    if ((entityWithBoardPresence = (target.entity as IEntityWithBoardPresence)) != null)
                    {
                        Vector2Int[] occupiedCoords = entityWithBoardPresence.area.occupiedCoords;
                        int          num            = occupiedCoords.Length;
                        for (int j = 0; j < num; j++)
                        {
                            Vector2Int val       = occupiedCoords[j];
                            int        cellIndex = mapStateProvider.GetCellIndex(val.get_x(), val.get_y());
                            targets.Add(cellIndex, target);
                        }
                    }
                    else
                    {
                        Log.Error(string.Format("Entity target with id {0} does not implement {1}.", target.entity.id, "IEntityWithBoardPresence"), 228, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\FightMapTargetContext.cs");
                    }
                    break;
                }

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
Пример #3
0
        public IEnumerator Initialize()
        {
            CameraHandler.AddMapRotationListener(OnMapRotationChanged);
            FightStatus local       = FightStatus.local;
            int         regionCount = m_mapDefinition.regionCount;

            m_movementContexts = new FightMapMovementContext[regionCount];
            for (int i = 0; i < regionCount; i++)
            {
                FightStatus fightStatus = FightLogicExecutor.GetFightStatus(i);
                fightStatus.EntitiesChanged += OnEntitiesChanged;
                FightMapMovementContext fightMapMovementContext = new FightMapMovementContext(fightStatus.mapStatus, fightStatus);
                if (fightStatus == local)
                {
                    m_localMovementContext = fightMapMovementContext;
                }
                m_movementContexts[i] = fightMapMovementContext;
            }
            if (m_localMovementContext != null)
            {
                IMapStateProvider stateProvider = m_localMovementContext.stateProvider;
                m_targetContext = new FightMapTargetContext(stateProvider);
            }
            BoxCollider mapCollider = CreateCollider();

            InitializeHandlers(mapCollider, giveUserControl: false);
            MonsterSpawnCellDefinition monsterSpawnCellDefinition = m_bossFightMapResources.monsterSpawnCellDefinition;

            if (null != monsterSpawnCellDefinition)
            {
                yield return(monsterSpawnCellDefinition.Initialize());

                m_monsterSpawnCellDictionary = new Dictionary <int, GameObject>();
            }
            if (AudioManager.isReady)
            {
                m_audioContext.Initialize();
                m_worldMusicRequest = AudioManager.LoadWorldMusic(m_musicGroup, m_ambianceGroup, m_audioContext);
                while (m_worldMusicRequest.state == AudioWorldMusicRequest.State.Loading)
                {
                    yield return(null);
                }
            }
        }
        public FightMapMovementContext([NotNull] IMapStateProvider stateProvider, [NotNull] IMapEntityProvider entityProvider)
        {
            //IL_0020: Unknown result type (might be due to invalid IL or missing references)
            //IL_0025: Unknown result type (might be due to invalid IL or missing references)
            //IL_0027: Unknown result type (might be due to invalid IL or missing references)
            //IL_002c: Unknown result type (might be due to invalid IL or missing references)
            //IL_002d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0032: Unknown result type (might be due to invalid IL or missing references)
            //IL_00c9: Unknown result type (might be due to invalid IL or missing references)
            this.stateProvider  = stateProvider;
            this.entityProvider = entityProvider;
            Vector2Int sizeMin = stateProvider.sizeMin;
            Vector2Int val     = stateProvider.sizeMax - sizeMin;
            int        num     = val.get_y() * val.get_x();
            int        num2    = sizeMin.get_y() * val.get_x() + sizeMin.get_x();

            grid = new Cell[num];
            Vector2Int coords = default(Vector2Int);

            for (int i = 0; i < num; i++)
            {
                FightCellState cellState = stateProvider.GetCellState(i);
                int            num3      = sizeMin.get_x() + i % val.get_x();
                int            num4      = (i + num2 - num3) / val.get_x();
                coords._002Ector(num3, num4);
                CellState state;
                switch (cellState)
                {
                case FightCellState.None:
                    state = CellState.None;
                    break;

                case FightCellState.Movement:
                    state = CellState.Movement;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                grid[i] = new Cell(coords, state, null);
            }
        }
Пример #5
0
        private static bool CanStopAt(IMapStateProvider mapStateProvider, FightMapMovementContext.Cell[] grid, Vector2Int coords)
        {
            int cellIndex = mapStateProvider.GetCellIndex(coords.get_x(), coords.get_y());

            return((grid[cellIndex].state & FightMapMovementContext.CellState.Occupied) == FightMapMovementContext.CellState.None);
        }
Пример #6
0
        private void ComputeAdjacentCoords(IMapStateProvider mapStateProvider, FightMapMovementContext.Cell[] grid, Vector2Int coords, Vector2Int from)
        {
            //IL_0001: Unknown result type (might be due to invalid IL or missing references)
            //IL_0006: Unknown result type (might be due to invalid IL or missing references)
            //IL_0008: Unknown result type (might be due to invalid IL or missing references)
            //IL_000d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0088: Unknown result type (might be due to invalid IL or missing references)
            //IL_008a: Unknown result type (might be due to invalid IL or missing references)
            //IL_00fc: Unknown result type (might be due to invalid IL or missing references)
            //IL_00fe: Unknown result type (might be due to invalid IL or missing references)
            //IL_0170: Unknown result type (might be due to invalid IL or missing references)
            //IL_0172: Unknown result type (might be due to invalid IL or missing references)
            //IL_01e4: Unknown result type (might be due to invalid IL or missing references)
            //IL_01e6: Unknown result type (might be due to invalid IL or missing references)
            //IL_024e: Unknown result type (might be due to invalid IL or missing references)
            //IL_025e: Unknown result type (might be due to invalid IL or missing references)
            //IL_026e: Unknown result type (might be due to invalid IL or missing references)
            //IL_027d: Unknown result type (might be due to invalid IL or missing references)
            Vector2Int sizeMin        = mapStateProvider.sizeMin;
            Vector2Int sizeMax        = mapStateProvider.sizeMax;
            int        x              = coords.get_x();
            int        y              = coords.get_y();
            int        x2             = sizeMin.get_x();
            int        y2             = sizeMin.get_y();
            int        x3             = sizeMax.get_x();
            int        y3             = sizeMax.get_y();
            bool       canPassThrough = m_canPassThrough;
            Vector2Int val            = default(Vector2Int);

            val._002Ector(x, y + 1);
            Vector2Int val2 = default(Vector2Int);

            val2._002Ector(x - 1, y);
            Vector2Int val3 = default(Vector2Int);

            val3._002Ector(x + 1, y);
            Vector2Int val4 = default(Vector2Int);

            val4._002Ector(x, y - 1);
            int  x4 = val.get_x();
            int  y4 = val.get_y();
            bool isValid;

            if (val != from && x4 >= x2 && x4 < x3 && y4 >= y2 && y4 < y3)
            {
                int cellIndex = mapStateProvider.GetCellIndex(x4, y4);
                FightMapMovementContext.CellState state = grid[cellIndex].state;
                isValid = (((state & FightMapMovementContext.CellState.Reachable) != 0 && (((state & FightMapMovementContext.CellState.Occupied) == FightMapMovementContext.CellState.None) | canPassThrough)) || (state & FightMapMovementContext.CellState.Targeted) != FightMapMovementContext.CellState.None);
            }
            else
            {
                isValid = false;
            }
            int  x5 = val2.get_x();
            int  y5 = val2.get_y();
            bool isValid2;

            if (val2 != from && x5 >= x2 && x5 < x3 && y5 >= y2 && y5 < y3)
            {
                int cellIndex2 = mapStateProvider.GetCellIndex(x5, y5);
                FightMapMovementContext.CellState state2 = grid[cellIndex2].state;
                isValid2 = (((state2 & FightMapMovementContext.CellState.Reachable) != 0 && (((state2 & FightMapMovementContext.CellState.Occupied) == FightMapMovementContext.CellState.None) | canPassThrough)) || (state2 & FightMapMovementContext.CellState.Targeted) != FightMapMovementContext.CellState.None);
            }
            else
            {
                isValid2 = false;
            }
            int  x6 = val3.get_x();
            int  y6 = val3.get_y();
            bool isValid3;

            if (val3 != from && x6 >= x2 && x6 < x3 && y6 >= y2 && y6 < y3)
            {
                int cellIndex3 = mapStateProvider.GetCellIndex(x6, y6);
                FightMapMovementContext.CellState state3 = grid[cellIndex3].state;
                isValid3 = (((state3 & FightMapMovementContext.CellState.Reachable) != 0 && (((state3 & FightMapMovementContext.CellState.Occupied) == FightMapMovementContext.CellState.None) | canPassThrough)) || (state3 & FightMapMovementContext.CellState.Targeted) != FightMapMovementContext.CellState.None);
            }
            else
            {
                isValid3 = false;
            }
            int  x7 = val4.get_x();
            int  y7 = val4.get_y();
            bool isValid4;

            if (val4 != from && x7 >= x2 && x7 < x3 && y7 >= y2 && y7 < y3)
            {
                int cellIndex4 = mapStateProvider.GetCellIndex(x7, y7);
                FightMapMovementContext.CellState state4 = grid[cellIndex4].state;
                isValid4 = (((state4 & FightMapMovementContext.CellState.Reachable) != 0 && (((state4 & FightMapMovementContext.CellState.Occupied) == FightMapMovementContext.CellState.None) | canPassThrough)) || (state4 & FightMapMovementContext.CellState.Targeted) != FightMapMovementContext.CellState.None);
            }
            else
            {
                isValid4 = false;
            }
            AdjacentCoord[] adjacentCoordsBuffer = m_adjacentCoordsBuffer;
            adjacentCoordsBuffer[0] = new AdjacentCoord(val, isValid);
            adjacentCoordsBuffer[1] = new AdjacentCoord(val2, isValid2);
            adjacentCoordsBuffer[2] = new AdjacentCoord(val3, isValid3);
            adjacentCoordsBuffer[3] = new AdjacentCoord(val4, isValid4);
        }
Пример #7
0
        private void ComputeFullPath(IMapStateProvider mapStateProvider, FightMapMovementContext.Cell[] grid, Vector2Int start, Vector2Int end, int movementPoints, bool isTargeting)
        {
            //IL_0025: Unknown result type (might be due to invalid IL or missing references)
            //IL_002a: Unknown result type (might be due to invalid IL or missing references)
            //IL_0034: Unknown result type (might be due to invalid IL or missing references)
            //IL_0039: Unknown result type (might be due to invalid IL or missing references)
            //IL_0051: Unknown result type (might be due to invalid IL or missing references)
            //IL_0052: Unknown result type (might be due to invalid IL or missing references)
            //IL_0060: Unknown result type (might be due to invalid IL or missing references)
            //IL_0061: Unknown result type (might be due to invalid IL or missing references)
            //IL_006c: Unknown result type (might be due to invalid IL or missing references)
            //IL_006d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0089: Unknown result type (might be due to invalid IL or missing references)
            //IL_008e: Unknown result type (might be due to invalid IL or missing references)
            //IL_0092: Unknown result type (might be due to invalid IL or missing references)
            //IL_0097: Unknown result type (might be due to invalid IL or missing references)
            //IL_00ab: Unknown result type (might be due to invalid IL or missing references)
            //IL_00ad: Unknown result type (might be due to invalid IL or missing references)
            //IL_00c7: Unknown result type (might be due to invalid IL or missing references)
            //IL_00e7: Unknown result type (might be due to invalid IL or missing references)
            //IL_00e9: Unknown result type (might be due to invalid IL or missing references)
            //IL_0142: Unknown result type (might be due to invalid IL or missing references)
            //IL_0158: Unknown result type (might be due to invalid IL or missing references)
            //IL_0169: Unknown result type (might be due to invalid IL or missing references)
            //IL_016e: Unknown result type (might be due to invalid IL or missing references)
            //IL_0193: Unknown result type (might be due to invalid IL or missing references)
            //IL_01aa: Unknown result type (might be due to invalid IL or missing references)
            //IL_01b4: Unknown result type (might be due to invalid IL or missing references)
            //IL_01b6: Unknown result type (might be due to invalid IL or missing references)
            //IL_01dd: Unknown result type (might be due to invalid IL or missing references)
            //IL_01e2: Unknown result type (might be due to invalid IL or missing references)
            //IL_01ea: Unknown result type (might be due to invalid IL or missing references)
            //IL_01ec: Unknown result type (might be due to invalid IL or missing references)
            //IL_0229: Unknown result type (might be due to invalid IL or missing references)
            //IL_022b: Unknown result type (might be due to invalid IL or missing references)
            //IL_024b: Unknown result type (might be due to invalid IL or missing references)
            //IL_024d: Unknown result type (might be due to invalid IL or missing references)
            //IL_028e: Unknown result type (might be due to invalid IL or missing references)
            //IL_0297: Unknown result type (might be due to invalid IL or missing references)
            List <Vector2Int> currentPath = this.currentPath;

            AdjacentCoord[]        adjacentCoordsBuffer = m_adjacentCoordsBuffer;
            NodePriorityQueue      frontier             = m_frontier;
            Dictionary <int, Node> steps = m_steps;
            int        count             = currentPath.Count;
            Vector2Int val = mapStateProvider.sizeMax;
            int        x   = val.get_x();

            val = mapStateProvider.sizeMin;
            int num = x - val.get_x();

            frontier.Clear();
            steps.Clear();
            if (start.DistanceTo(end) <= movementPoints)
            {
                Direction directionTo = start.GetDirectionTo(end);
                Node      item        = new Node(start, start, 0, 0, directionTo);
                frontier.Enqueue(item);
                do
                {
                    Node       node       = frontier.Dequeue();
                    Vector2Int coords     = node.coords;
                    Vector2Int fromCoords = node.fromCoords;
                    int        cost       = node.cost;
                    Direction  direction  = node.direction;
                    if (coords == end)
                    {
                        if (isTargeting && m_canPassThrough && !CanStopAt(mapStateProvider, grid, fromCoords))
                        {
                            int key = coords.get_y() * num + coords.get_x();
                            steps[key] = new Node(coords, fromCoords, int.MaxValue, node.priority, direction);
                            continue;
                        }
                        int num2 = cost + 1;
                        if (currentPath.Capacity < num2)
                        {
                            currentPath.Capacity = num2;
                        }
                        if (count > num2)
                        {
                            currentPath.RemoveRange(num2, count - num2);
                        }
                        else if (count < num2)
                        {
                            for (int i = count; i < num2; i++)
                            {
                                currentPath.Add(end);
                            }
                        }
                        currentPath[cost] = end;
                        for (int num3 = cost - 1; num3 > 0; num3--)
                        {
                            Vector2Int fromCoords2 = node.fromCoords;
                            int        key2        = fromCoords2.get_y() * num + fromCoords2.get_x();
                            node = steps[key2];
                            currentPath[num3] = node.coords;
                        }
                        currentPath[0] = start;
                        return;
                    }
                    ComputeAdjacentCoords(mapStateProvider, grid, coords, fromCoords);
                    for (int j = 0; j < 4; j++)
                    {
                        AdjacentCoord adjacentCoord = adjacentCoordsBuffer[j];
                        if (!adjacentCoord.isValid)
                        {
                            continue;
                        }
                        Vector2Int coords2 = adjacentCoord.coords;
                        int        num4    = cost + 1;
                        int        num5    = coords2.DistanceTo(end);
                        if (num4 + num5 <= movementPoints)
                        {
                            int key3 = coords2.get_y() * num + coords2.get_x();
                            if (!steps.TryGetValue(key3, out Node value) || value.cost >= num4)
                            {
                                Direction directionTo2 = coords.GetDirectionTo(coords2);
                                int       num6         = (directionTo2 != direction) ? 1 : 0;
                                int       num7         = (num5 << 1) + num6;
                                value = new Node(coords2, coords, num4, num4 + num7, directionTo2);
                                frontier.Enqueue(value);
                                steps[key3] = value;
                            }
                        }
                    }
                }while (frontier.Count() > 0);
            }
            if (count == 0)
            {
                currentPath.Add(start);
                return;
            }
            currentPath[0] = start;
            currentPath.RemoveRange(1, count - 1);
        }
Пример #8
0
        private bool AppendPartialPath(IMapStateProvider mapStateProvider, FightMapMovementContext.Cell[] grid, Vector2Int end, int movementPoints, bool isTargeting)
        {
            //IL_002d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0032: Unknown result type (might be due to invalid IL or missing references)
            //IL_003c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0041: Unknown result type (might be due to invalid IL or missing references)
            //IL_0067: Unknown result type (might be due to invalid IL or missing references)
            //IL_006c: Unknown result type (might be due to invalid IL or missing references)
            //IL_006f: Unknown result type (might be due to invalid IL or missing references)
            //IL_0071: Unknown result type (might be due to invalid IL or missing references)
            //IL_0075: Unknown result type (might be due to invalid IL or missing references)
            //IL_0077: Unknown result type (might be due to invalid IL or missing references)
            //IL_008f: Unknown result type (might be due to invalid IL or missing references)
            //IL_0094: Unknown result type (might be due to invalid IL or missing references)
            //IL_0097: Unknown result type (might be due to invalid IL or missing references)
            //IL_0099: Unknown result type (might be due to invalid IL or missing references)
            //IL_009e: Unknown result type (might be due to invalid IL or missing references)
            //IL_00a0: Unknown result type (might be due to invalid IL or missing references)
            //IL_00b1: Unknown result type (might be due to invalid IL or missing references)
            //IL_00b3: Unknown result type (might be due to invalid IL or missing references)
            //IL_00d8: Unknown result type (might be due to invalid IL or missing references)
            //IL_00dd: Unknown result type (might be due to invalid IL or missing references)
            //IL_0116: Unknown result type (might be due to invalid IL or missing references)
            //IL_011b: Unknown result type (might be due to invalid IL or missing references)
            //IL_0151: Unknown result type (might be due to invalid IL or missing references)
            //IL_0156: Unknown result type (might be due to invalid IL or missing references)
            //IL_015a: Unknown result type (might be due to invalid IL or missing references)
            //IL_015f: Unknown result type (might be due to invalid IL or missing references)
            //IL_0175: Unknown result type (might be due to invalid IL or missing references)
            //IL_017a: Unknown result type (might be due to invalid IL or missing references)
            //IL_0193: Unknown result type (might be due to invalid IL or missing references)
            //IL_01b3: Unknown result type (might be due to invalid IL or missing references)
            //IL_01b5: Unknown result type (might be due to invalid IL or missing references)
            //IL_020e: Unknown result type (might be due to invalid IL or missing references)
            //IL_0223: Unknown result type (might be due to invalid IL or missing references)
            //IL_0233: Unknown result type (might be due to invalid IL or missing references)
            //IL_0238: Unknown result type (might be due to invalid IL or missing references)
            //IL_025d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0278: Unknown result type (might be due to invalid IL or missing references)
            //IL_027a: Unknown result type (might be due to invalid IL or missing references)
            //IL_02a2: Unknown result type (might be due to invalid IL or missing references)
            //IL_02a7: Unknown result type (might be due to invalid IL or missing references)
            //IL_02af: Unknown result type (might be due to invalid IL or missing references)
            //IL_02b1: Unknown result type (might be due to invalid IL or missing references)
            //IL_02ed: Unknown result type (might be due to invalid IL or missing references)
            //IL_02ef: Unknown result type (might be due to invalid IL or missing references)
            //IL_030f: Unknown result type (might be due to invalid IL or missing references)
            //IL_0311: Unknown result type (might be due to invalid IL or missing references)
            List <Vector2Int>      currentPath         = this.currentPath;
            List <Node>            previousStepsBuffer = m_previousStepsBuffer;
            NodePriorityQueue      frontier            = m_frontier;
            Dictionary <int, Node> steps = m_steps;

            AdjacentCoord[] adjacentCoordsBuffer = m_adjacentCoordsBuffer;
            int             num = currentPath.Count;
            Vector2Int      val = mapStateProvider.sizeMax;
            int             x   = val.get_x();

            val = mapStateProvider.sizeMin;
            int num2 = x - val.get_x();

            if (previousStepsBuffer.Capacity < num)
            {
                previousStepsBuffer.Capacity = num;
            }
            previousStepsBuffer.Clear();
            Vector2Int val2 = currentPath[0];

            previousStepsBuffer.Add(new Node(val2, val2, 0, 0, val2.GetDirectionTo(end)));
            for (int i = 1; i < num; i++)
            {
                Vector2Int val3 = currentPath[i];
                previousStepsBuffer.Add(new Node(val3, val2, i, 0, val2.GetDirectionTo(val3)));
                val2 = val3;
            }
            for (int num3 = num - 1; num3 > 0; num3--)
            {
                Node node = previousStepsBuffer[num3];
                int  num4 = node.coords.DistanceTo(end);
                if (num3 + num4 <= movementPoints)
                {
                    frontier.Clear();
                    frontier.Enqueue(node);
                    steps.Clear();
                    for (int j = 0; j < num3; j++)
                    {
                        Node       node2  = previousStepsBuffer[j];
                        Vector2Int coords = node2.coords;
                        int        key    = coords.get_y() * num2 + coords.get_x();
                        steps.Add(key, node2);
                    }
                    do
                    {
                        Node       node3      = frontier.Dequeue();
                        Vector2Int coords2    = node3.coords;
                        Vector2Int fromCoords = node3.fromCoords;
                        int        cost       = node3.cost;
                        Direction  direction  = node3.direction;
                        if (node3.coords == end)
                        {
                            if (isTargeting && m_canPassThrough && !CanStopAt(mapStateProvider, grid, fromCoords))
                            {
                                int key2 = coords2.get_y() * num2 + coords2.get_x();
                                steps[key2] = new Node(coords2, fromCoords, int.MaxValue, node3.priority, direction);
                                continue;
                            }
                            int num5 = cost + 1;
                            if (currentPath.Capacity < num5)
                            {
                                currentPath.Capacity = num5;
                            }
                            if (num > num5)
                            {
                                currentPath.RemoveRange(num5, num - num5);
                            }
                            else if (num < num5)
                            {
                                for (int k = num; k < num5; k++)
                                {
                                    currentPath.Add(end);
                                }
                            }
                            currentPath[cost] = end;
                            for (int num6 = cost - 1; num6 >= num; num6--)
                            {
                                Vector2Int fromCoords2 = node3.fromCoords;
                                int        key3        = fromCoords2.get_y() * num2 + fromCoords2.get_x();
                                node3             = steps[key3];
                                currentPath[num6] = node3.coords;
                            }
                            return(true);
                        }
                        ComputeAdjacentCoords(mapStateProvider, grid, coords2, fromCoords);
                        for (int l = 0; l < 4; l++)
                        {
                            AdjacentCoord adjacentCoord = adjacentCoordsBuffer[l];
                            if (!adjacentCoord.isValid)
                            {
                                continue;
                            }
                            Vector2Int coords3 = adjacentCoord.coords;
                            int        num7    = cost + 1;
                            int        num8    = coords3.DistanceTo(end);
                            if (num7 + num8 <= movementPoints)
                            {
                                int key4 = coords3.get_y() * num2 + coords3.get_x();
                                if (!steps.TryGetValue(key4, out Node value) || value.cost >= num7)
                                {
                                    Direction directionTo = coords2.GetDirectionTo(coords3);
                                    int       num9        = (directionTo != direction) ? 1 : 0;
                                    int       num10       = (num8 << 1) + num9;
                                    value = new Node(coords3, coords2, num7, num7 + num10, directionTo);
                                    frontier.Enqueue(value);
                                    steps[key4] = value;
                                }
                            }
                        }
                    }while (frontier.Count() > 0);
                }
                currentPath.RemoveAt(num3);
                num--;
            }
            return(false);
        }
Пример #9
0
        public void Move(IMapStateProvider mapStateProvider, FightMapMovementContext.Cell[] grid, Vector2Int position, bool isTargeting)
        {
            //IL_001f: Unknown result type (might be due to invalid IL or missing references)
            //IL_0024: Unknown result type (might be due to invalid IL or missing references)
            //IL_003c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0041: Unknown result type (might be due to invalid IL or missing references)
            //IL_0042: Unknown result type (might be due to invalid IL or missing references)
            //IL_0043: Unknown result type (might be due to invalid IL or missing references)
            //IL_004e: Unknown result type (might be due to invalid IL or missing references)
            //IL_005e: Unknown result type (might be due to invalid IL or missing references)
            //IL_006d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0072: Unknown result type (might be due to invalid IL or missing references)
            //IL_0094: Unknown result type (might be due to invalid IL or missing references)
            //IL_0099: Unknown result type (might be due to invalid IL or missing references)
            //IL_00b5: Unknown result type (might be due to invalid IL or missing references)
            //IL_00ba: Unknown result type (might be due to invalid IL or missing references)
            //IL_00e6: Unknown result type (might be due to invalid IL or missing references)
            //IL_00eb: Unknown result type (might be due to invalid IL or missing references)
            //IL_00f5: Unknown result type (might be due to invalid IL or missing references)
            //IL_0103: Unknown result type (might be due to invalid IL or missing references)
            //IL_0112: Unknown result type (might be due to invalid IL or missing references)
            //IL_0117: Unknown result type (might be due to invalid IL or missing references)
            List <Vector2Int> currentPath = this.currentPath;
            int count          = currentPath.Count;
            int movementPoints = m_movementPoints;

            if (isTargeting)
            {
                movementPoints++;
                if (currentPath[0].DistanceTo(position) > movementPoints)
                {
                    currentPath.RemoveRange(1, count - 1);
                    return;
                }
                Vector2Int val = currentPath[count - 1];
                if (val.DistanceTo(position) != 1 || !CanStopAt(mapStateProvider, grid, val))
                {
                    if (count == 1 || !AppendPartialPath(mapStateProvider, grid, position, movementPoints, isTargeting: true))
                    {
                        ComputeFullPath(mapStateProvider, grid, currentPath[0], position, movementPoints, isTargeting: true);
                    }
                    count = currentPath.Count;
                    if (count > 1)
                    {
                        currentPath.RemoveAt(count - 1);
                    }
                }
                return;
            }
            if (currentPath[0].DistanceTo(position) > movementPoints)
            {
                currentPath.RemoveRange(1, count - 1);
                return;
            }
            for (int i = 0; i < count; i++)
            {
                if (currentPath[i] == position)
                {
                    currentPath.RemoveRange(i + 1, count - 1 - i);
                    return;
                }
            }
            if (count <= movementPoints && currentPath[count - 1].DistanceTo(position) == 1)
            {
                currentPath.Add(position);
            }
            else if (count == 1 || !AppendPartialPath(mapStateProvider, grid, position, movementPoints, isTargeting: false))
            {
                ComputeFullPath(mapStateProvider, grid, currentPath[0], position, movementPoints, isTargeting: false);
            }
        }
Пример #10
0
        public void FloodFill(IMapStateProvider mapStateProvider, FightMapMovementContext.Cell[] grid, Vector2Int position, int movementPoints, bool canPassThrough)
        {
            //IL_0008: Unknown result type (might be due to invalid IL or missing references)
            //IL_000d: Unknown result type (might be due to invalid IL or missing references)
            //IL_000f: Unknown result type (might be due to invalid IL or missing references)
            //IL_0014: Unknown result type (might be due to invalid IL or missing references)
            //IL_001d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0032: Unknown result type (might be due to invalid IL or missing references)
            //IL_0037: Unknown result type (might be due to invalid IL or missing references)
            //IL_010c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0131: Unknown result type (might be due to invalid IL or missing references)
            //IL_0195: Unknown result type (might be due to invalid IL or missing references)
            //IL_01ba: Unknown result type (might be due to invalid IL or missing references)
            //IL_021e: Unknown result type (might be due to invalid IL or missing references)
            //IL_0243: Unknown result type (might be due to invalid IL or missing references)
            //IL_02a7: Unknown result type (might be due to invalid IL or missing references)
            //IL_02cc: Unknown result type (might be due to invalid IL or missing references)
            Queue <FloodFillNode> floodFillFrontier = m_floodFillFrontier;
            Vector2Int            sizeMin           = mapStateProvider.sizeMin;
            Vector2Int            sizeMax           = mapStateProvider.sizeMax;

            floodFillFrontier.Clear();
            FloodFillNode item = new FloodFillNode(position, 0);

            floodFillFrontier.Enqueue(item);
            Vector2Int coords2 = default(Vector2Int);
            Vector2Int coords3 = default(Vector2Int);
            Vector2Int coords4 = default(Vector2Int);
            Vector2Int coords5 = default(Vector2Int);

            do
            {
                FloodFillNode floodFillNode = floodFillFrontier.Dequeue();
                Vector2Int    coords        = floodFillNode.coords;
                int           cost          = floodFillNode.cost;
                if (cost >= movementPoints)
                {
                    continue;
                }
                int cost2 = cost + 1;
                int x     = coords.get_x();
                int y     = coords.get_y();
                int x2    = sizeMin.get_x();
                int y2    = sizeMin.get_y();
                int x3    = sizeMax.get_x();
                int y3    = sizeMax.get_y();
                coords2._002Ector(x, y + 1);
                coords3._002Ector(x - 1, y);
                coords4._002Ector(x + 1, y);
                coords5._002Ector(x, y - 1);
                int x4 = coords2.get_x();
                int y4 = coords2.get_y();
                if (x4 >= x2 && x4 < x3 && y4 >= y2 && y4 < y3)
                {
                    int cellIndex = mapStateProvider.GetCellIndex(x4, y4);
                    FightMapMovementContext.Cell      cell  = grid[cellIndex];
                    FightMapMovementContext.CellState state = cell.state;
                    if ((state & (FightMapMovementContext.CellState.Movement | FightMapMovementContext.CellState.Reachable)) == FightMapMovementContext.CellState.Movement)
                    {
                        grid[cellIndex] = new FightMapMovementContext.Cell(coords2, state | FightMapMovementContext.CellState.Reachable, cell.entity);
                        if (((state & FightMapMovementContext.CellState.Occupied) == FightMapMovementContext.CellState.None) | canPassThrough)
                        {
                            FloodFillNode item2 = new FloodFillNode(coords2, cost2);
                            floodFillFrontier.Enqueue(item2);
                        }
                    }
                }
                int x5 = coords3.get_x();
                int y5 = coords3.get_y();
                if (x5 >= x2 && x5 < x3 && y5 >= y2 && y5 < y3)
                {
                    int cellIndex2 = mapStateProvider.GetCellIndex(x5, y5);
                    FightMapMovementContext.Cell      cell2  = grid[cellIndex2];
                    FightMapMovementContext.CellState state2 = cell2.state;
                    if ((state2 & (FightMapMovementContext.CellState.Movement | FightMapMovementContext.CellState.Reachable)) == FightMapMovementContext.CellState.Movement)
                    {
                        grid[cellIndex2] = new FightMapMovementContext.Cell(coords3, state2 | FightMapMovementContext.CellState.Reachable, cell2.entity);
                        if (((state2 & FightMapMovementContext.CellState.Occupied) == FightMapMovementContext.CellState.None) | canPassThrough)
                        {
                            FloodFillNode item3 = new FloodFillNode(coords3, cost2);
                            floodFillFrontier.Enqueue(item3);
                        }
                    }
                }
                int x6 = coords4.get_x();
                int y6 = coords4.get_y();
                if (x6 >= x2 && x6 < x3 && y6 >= y2 && y6 < y3)
                {
                    int cellIndex3 = mapStateProvider.GetCellIndex(x6, y6);
                    FightMapMovementContext.Cell      cell3  = grid[cellIndex3];
                    FightMapMovementContext.CellState state3 = cell3.state;
                    if ((state3 & (FightMapMovementContext.CellState.Movement | FightMapMovementContext.CellState.Reachable)) == FightMapMovementContext.CellState.Movement)
                    {
                        grid[cellIndex3] = new FightMapMovementContext.Cell(coords4, state3 | FightMapMovementContext.CellState.Reachable, cell3.entity);
                        if (((state3 & FightMapMovementContext.CellState.Occupied) == FightMapMovementContext.CellState.None) | canPassThrough)
                        {
                            FloodFillNode item4 = new FloodFillNode(coords4, cost2);
                            floodFillFrontier.Enqueue(item4);
                        }
                    }
                }
                int x7 = coords5.get_x();
                int y7 = coords5.get_y();
                if (x7 < x2 || x7 >= x3 || y7 < y2 || y7 >= y3)
                {
                    continue;
                }
                int cellIndex4 = mapStateProvider.GetCellIndex(x7, y7);
                FightMapMovementContext.Cell      cell4  = grid[cellIndex4];
                FightMapMovementContext.CellState state4 = cell4.state;
                if ((state4 & (FightMapMovementContext.CellState.Movement | FightMapMovementContext.CellState.Reachable)) == FightMapMovementContext.CellState.Movement)
                {
                    grid[cellIndex4] = new FightMapMovementContext.Cell(coords5, state4 | FightMapMovementContext.CellState.Reachable, cell4.entity);
                    if (((state4 & FightMapMovementContext.CellState.Occupied) == FightMapMovementContext.CellState.None) | canPassThrough)
                    {
                        FloodFillNode item5 = new FloodFillNode(coords5, cost2);
                        floodFillFrontier.Enqueue(item5);
                    }
                }
            }while (floodFillFrontier.Count > 0);
        }
Пример #11
0
        public static void SetupMovementAreaHighlight([NotNull] FightMapFeedbackResources resources, [NotNull] FightMapMovementContext context, Vector2Int coords, [NotNull] CellHighlight highlight, Color color)
        {
            //IL_0001: Unknown result type (might be due to invalid IL or missing references)
            //IL_0020: Unknown result type (might be due to invalid IL or missing references)
            //IL_0025: Unknown result type (might be due to invalid IL or missing references)
            //IL_0027: Unknown result type (might be due to invalid IL or missing references)
            //IL_002c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0527: Unknown result type (might be due to invalid IL or missing references)
            //IL_0557: Unknown result type (might be due to invalid IL or missing references)
            //IL_056a: Unknown result type (might be due to invalid IL or missing references)
            if ((context.GetCell(coords).state & (FightMapMovementContext.CellState.Reachable | FightMapMovementContext.CellState.Occupied)) != FightMapMovementContext.CellState.Reachable)
            {
                highlight.ClearSprite();
                return;
            }
            IMapStateProvider stateProvider = context.stateProvider;
            Vector2Int        sizeMin       = stateProvider.sizeMin;
            Vector2Int        sizeMax       = stateProvider.sizeMax;

            FightMapMovementContext.Cell[] grid = context.grid;
            Sprite[]   areaFeedbackSprites      = resources.areaFeedbackSprites;
            Vector2Int val = default(Vector2Int);

            val._002Ector(coords.get_x(), coords.get_y() + 1);
            Vector2Int val2 = default(Vector2Int);

            val2._002Ector(coords.get_x() - 1, coords.get_y());
            Vector2Int val3 = default(Vector2Int);

            val3._002Ector(coords.get_x() + 1, coords.get_y());
            Vector2Int val4 = default(Vector2Int);

            val4._002Ector(coords.get_x(), coords.get_y() - 1);
            FightMapMovementContext.CellState cellState  = (val.get_x() >= sizeMin.get_x() && val.get_x() < sizeMax.get_x() && val.get_y() >= sizeMin.get_y() && val.get_y() < sizeMax.get_y()) ? grid[stateProvider.GetCellIndex(val.get_x(), val.get_y())].state : FightMapMovementContext.CellState.None;
            FightMapMovementContext.CellState cellState2 = (val2.get_x() >= sizeMin.get_x() && val2.get_x() < sizeMax.get_x() && val2.get_y() >= sizeMin.get_y() && val2.get_y() < sizeMax.get_y()) ? grid[stateProvider.GetCellIndex(val2.get_x(), val2.get_y())].state : FightMapMovementContext.CellState.None;
            FightMapMovementContext.CellState cellState3 = (val3.get_x() >= sizeMin.get_x() && val3.get_x() < sizeMax.get_x() && val3.get_y() >= sizeMin.get_y() && val3.get_y() < sizeMax.get_y()) ? grid[stateProvider.GetCellIndex(val3.get_x(), val3.get_y())].state : FightMapMovementContext.CellState.None;
            FightMapMovementContext.CellState num        = (val4.get_x() >= sizeMin.get_x() && val4.get_x() < sizeMax.get_x() && val4.get_y() >= sizeMin.get_y() && val4.get_y() < sizeMax.get_y()) ? grid[stateProvider.GetCellIndex(val4.get_x(), val4.get_y())].state : FightMapMovementContext.CellState.None;
            int num2 = ((cellState & (FightMapMovementContext.CellState.Reachable | FightMapMovementContext.CellState.Occupied)) == FightMapMovementContext.CellState.Reachable) ? 1 : 0;
            int num3 = ((cellState2 & (FightMapMovementContext.CellState.Reachable | FightMapMovementContext.CellState.Occupied)) == FightMapMovementContext.CellState.Reachable) ? 1 : 0;
            int num4 = ((cellState3 & (FightMapMovementContext.CellState.Reachable | FightMapMovementContext.CellState.Occupied)) == FightMapMovementContext.CellState.Reachable) ? 1 : 0;
            int num5 = ((num & (FightMapMovementContext.CellState.Reachable | FightMapMovementContext.CellState.Occupied)) == FightMapMovementContext.CellState.Reachable) ? 1 : 0;

            switch (4 - (num2 + num3 + num4 + num5))
            {
            case 0:
            case 1:
            case 2:
            {
                Vector2Int val5 = default(Vector2Int);
                val5._002Ector(coords.get_x() - 1, coords.get_y() + 1);
                Vector2Int val6 = default(Vector2Int);
                val6._002Ector(coords.get_x() + 1, coords.get_y() + 1);
                Vector2Int val7 = default(Vector2Int);
                val7._002Ector(coords.get_x() - 1, coords.get_y() - 1);
                Vector2Int val8 = default(Vector2Int);
                val8._002Ector(coords.get_x() + 1, coords.get_y() - 1);
                FightMapMovementContext.CellState cellState4 = (val5.get_x() >= sizeMin.get_x() && val5.get_x() < sizeMax.get_x() && val5.get_y() >= sizeMin.get_y() && val5.get_y() < sizeMax.get_y()) ? grid[stateProvider.GetCellIndex(val5.get_x(), val5.get_y())].state : FightMapMovementContext.CellState.None;
                FightMapMovementContext.CellState cellState5 = (val6.get_x() >= sizeMin.get_x() && val6.get_x() < sizeMax.get_x() && val6.get_y() >= sizeMin.get_y() && val6.get_y() < sizeMax.get_y()) ? grid[stateProvider.GetCellIndex(val6.get_x(), val6.get_y())].state : FightMapMovementContext.CellState.None;
                FightMapMovementContext.CellState cellState6 = (val7.get_x() >= sizeMin.get_x() && val7.get_x() < sizeMax.get_x() && val7.get_y() >= sizeMin.get_y() && val7.get_y() < sizeMax.get_y()) ? grid[stateProvider.GetCellIndex(val7.get_x(), val7.get_y())].state : FightMapMovementContext.CellState.None;
                FightMapMovementContext.CellState num6       = (val8.get_x() >= sizeMin.get_x() && val8.get_x() < sizeMax.get_x() && val8.get_y() >= sizeMin.get_y() && val8.get_y() < sizeMax.get_y()) ? grid[stateProvider.GetCellIndex(val8.get_x(), val8.get_y())].state : FightMapMovementContext.CellState.None;
                int num7  = ((cellState4 & (FightMapMovementContext.CellState.Reachable | FightMapMovementContext.CellState.Occupied)) != FightMapMovementContext.CellState.Reachable) ? 1 : 0;
                int num8  = ((cellState5 & (FightMapMovementContext.CellState.Reachable | FightMapMovementContext.CellState.Occupied)) != FightMapMovementContext.CellState.Reachable) ? 1 : 0;
                int num9  = ((cellState6 & (FightMapMovementContext.CellState.Reachable | FightMapMovementContext.CellState.Occupied)) != FightMapMovementContext.CellState.Reachable) ? 1 : 0;
                int num10 = ((num6 & (FightMapMovementContext.CellState.Reachable | FightMapMovementContext.CellState.Occupied)) != FightMapMovementContext.CellState.Reachable) ? 1 : 0;
                int num11 = 1 - num2;
                int num12 = 1 - num3;
                int num13 = 1 - num4;
                int num14 = 1 - num5;
                int num15 = num11 | num12 | (num7 * num2 * num3);
                int num16 = num11 | num13 | (num8 * num2 * num4);
                int num17 = num14 | num12 | (num9 * num5 * num3);
                int num18 = num14 | num13 | (num10 * num5 * num4);
                Compute(num15 | (num16 << 1) | (num17 << 2) | (num18 << 3) | (num11 << 4) | (num12 << 5) | (num13 << 6) | (num14 << 7), areaFeedbackSprites, highlight, color);
                break;
            }

            case 3:
            {
                Sprite sprite2 = areaFeedbackSprites[4];
                float  angle   = (float)num2 * -90f + (float)num4 * 180f + (float)num5 * 90f;
                highlight.SetSprite(sprite2, color, angle);
                break;
            }

            case 4:
            {
                Sprite sprite = areaFeedbackSprites[5];
                highlight.SetSprite(sprite, color);
                break;
            }

            default:
                throw new ArgumentException();
            }
        }
Пример #12
0
        private void UpdateFeedbacks()
        {
            //IL_0046: Unknown result type (might be due to invalid IL or missing references)
            //IL_004b: Unknown result type (might be due to invalid IL or missing references)
            //IL_004d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0052: Unknown result type (might be due to invalid IL or missing references)
            //IL_00ef: Unknown result type (might be due to invalid IL or missing references)
            //IL_00f4: Unknown result type (might be due to invalid IL or missing references)
            //IL_00f6: Unknown result type (might be due to invalid IL or missing references)
            //IL_00fb: Unknown result type (might be due to invalid IL or missing references)
            //IL_0103: Unknown result type (might be due to invalid IL or missing references)
            //IL_0108: Unknown result type (might be due to invalid IL or missing references)
            //IL_0146: Unknown result type (might be due to invalid IL or missing references)
            //IL_0152: Unknown result type (might be due to invalid IL or missing references)
            //IL_01a1: Unknown result type (might be due to invalid IL or missing references)
            //IL_01a6: Unknown result type (might be due to invalid IL or missing references)
            //IL_01a8: Unknown result type (might be due to invalid IL or missing references)
            //IL_01ad: Unknown result type (might be due to invalid IL or missing references)
            //IL_024d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0252: Unknown result type (might be due to invalid IL or missing references)
            //IL_0264: Unknown result type (might be due to invalid IL or missing references)
            //IL_0269: Unknown result type (might be due to invalid IL or missing references)
            //IL_026b: Unknown result type (might be due to invalid IL or missing references)
            //IL_0270: Unknown result type (might be due to invalid IL or missing references)
            //IL_02af: Unknown result type (might be due to invalid IL or missing references)
            //IL_02bb: Unknown result type (might be due to invalid IL or missing references)
            //IL_0311: Unknown result type (might be due to invalid IL or missing references)
            FightMapFeedbackResources feedbackResources = m_feedbackResources;

            if (null == feedbackResources)
            {
                return;
            }
            FightMapMovementContext[] movementContexts = m_movementContexts;
            int num = movementContexts.Length;

            for (int i = 0; i < num; i++)
            {
                FightMapMovementContext fightMapMovementContext = movementContexts[i];
                if (!fightMapMovementContext.hasEnded)
                {
                    continue;
                }
                IMapDefinition    mapDefinition = m_mapDefinition;
                IMapStateProvider stateProvider = fightMapMovementContext.stateProvider;
                Vector2Int        sizeMin       = stateProvider.sizeMin;
                Vector2Int        sizeMax       = stateProvider.sizeMax;
                for (int j = sizeMin.get_y(); j < sizeMax.get_y(); j++)
                {
                    for (int k = sizeMin.get_x(); k < sizeMax.get_x(); k++)
                    {
                        int        cellIndex  = mapDefinition.GetCellIndex(k, j);
                        CellObject cellObject = m_cellObjectsByIndex[cellIndex];
                        if (!(null == cellObject))
                        {
                            cellObject.highlight.ClearSprite();
                        }
                    }
                }
            }
            FightMapTargetContext targetContext = m_targetContext;

            if (targetContext != null)
            {
                if (targetContext.isActive)
                {
                    IMapDefinition    mapDefinition2      = m_mapDefinition;
                    IMapStateProvider stateProvider2      = targetContext.stateProvider;
                    Vector2Int        sizeMin2            = stateProvider2.sizeMin;
                    Vector2Int        sizeMax2            = stateProvider2.sizeMax;
                    Color             targetableAreaColor = feedbackResources.feedbackColors.targetableAreaColor;
                    for (int l = sizeMin2.get_y(); l < sizeMax2.get_y(); l++)
                    {
                        for (int m = sizeMin2.get_x(); m < sizeMax2.get_x(); m++)
                        {
                            int        cellIndex2  = mapDefinition2.GetCellIndex(m, l);
                            CellObject cellObject2 = m_cellObjectsByIndex[cellIndex2];
                            if (!(null == cellObject2))
                            {
                                FightMapFeedbackHelper.SetupSpellTargetHighlight(feedbackResources, targetContext, cellObject2.coords, cellObject2.highlight, targetableAreaColor);
                            }
                        }
                    }
                    m_pathFinderFeedbackManager.Clear();
                    return;
                }
                if (targetContext.hasEnded)
                {
                    IMapDefinition    mapDefinition3 = m_mapDefinition;
                    IMapStateProvider stateProvider3 = targetContext.stateProvider;
                    Vector2Int        sizeMin3       = stateProvider3.sizeMin;
                    Vector2Int        sizeMax3       = stateProvider3.sizeMax;
                    for (int n = sizeMin3.get_y(); n < sizeMax3.get_y(); n++)
                    {
                        for (int num2 = sizeMin3.get_x(); num2 < sizeMax3.get_x(); num2++)
                        {
                            int        cellIndex3  = mapDefinition3.GetCellIndex(num2, n);
                            CellObject cellObject3 = m_cellObjectsByIndex[cellIndex3];
                            if (!(null == cellObject3))
                            {
                                cellObject3.highlight.ClearSprite();
                            }
                        }
                    }
                }
            }
            FightMapMovementContext activeMovementContext = m_activeMovementContext;

            if (activeMovementContext == null)
            {
                m_pathFinderFeedbackManager.Clear();
                return;
            }
            ICharacterEntity trackedCharacter = activeMovementContext.trackedCharacter;

            if (trackedCharacter != null)
            {
                Color             highlightColor = GetHighlightColor(feedbackResources.feedbackColors, activeMovementContext.entityProvider, trackedCharacter);
                IMapDefinition    mapDefinition4 = m_mapDefinition;
                IMapStateProvider stateProvider4 = activeMovementContext.stateProvider;
                Vector2Int        sizeMin4       = stateProvider4.sizeMin;
                Vector2Int        sizeMax4       = stateProvider4.sizeMax;
                for (int num3 = sizeMin4.get_y(); num3 < sizeMax4.get_y(); num3++)
                {
                    for (int num4 = sizeMin4.get_x(); num4 < sizeMax4.get_x(); num4++)
                    {
                        int        cellIndex4  = mapDefinition4.GetCellIndex(num4, num3);
                        CellObject cellObject4 = m_cellObjectsByIndex[cellIndex4];
                        if (!(null == cellObject4))
                        {
                            FightMapFeedbackHelper.SetupMovementAreaHighlight(feedbackResources, activeMovementContext, cellObject4.coords, cellObject4.highlight, highlightColor);
                        }
                    }
                }
            }
            if (m_pathFinder.tracking)
            {
                Vector2Int?target = activeMovementContext.targetedEntity?.area.refCoord;
                m_pathFinderFeedbackManager.Setup(feedbackResources.movementFeedbackResources, m_pathFinder.currentPath, target);
            }
            else
            {
                m_pathFinderFeedbackManager.Clear();
            }
        }
        public bool IsInActionRange(Vector2Int coord, ICharacterEntity tracked)
        {
            //IL_0006: Unknown result type (might be due to invalid IL or missing references)
            //IL_003b: Unknown result type (might be due to invalid IL or missing references)
            //IL_0040: Unknown result type (might be due to invalid IL or missing references)
            //IL_0042: Unknown result type (might be due to invalid IL or missing references)
            //IL_0047: Unknown result type (might be due to invalid IL or missing references)
            int num = tracked.area.MinDistanceWith(coord);

            if (tracked.hasRange)
            {
                if (num >= tracked.rangeMin)
                {
                    return(num <= tracked.rangeMax);
                }
                return(false);
            }
            if (num == 1)
            {
                return(true);
            }
            IMapStateProvider mapStateProvider = stateProvider;
            Vector2Int        sizeMin          = mapStateProvider.sizeMin;
            Vector2Int        sizeMax          = mapStateProvider.sizeMax;
            int        x   = sizeMin.get_x();
            int        y   = sizeMin.get_y();
            int        x2  = sizeMax.get_x();
            int        y2  = sizeMax.get_y();
            Vector2Int val = default(Vector2Int);

            val._002Ector(coord.get_x(), coord.get_y() + 1);
            if (val.get_x() >= x && val.get_x() < x2 && val.get_y() >= y && val.get_y() < y2)
            {
                int cellIndex = mapStateProvider.GetCellIndex(val.get_x(), val.get_y());
                if ((grid[cellIndex].state & (CellState.Reachable | CellState.Occupied)) == CellState.Reachable)
                {
                    return(true);
                }
            }
            Vector2Int val2 = default(Vector2Int);

            val2._002Ector(coord.get_x() - 1, coord.get_y());
            if (val2.get_x() >= x && val2.get_x() < x2 && val2.get_y() >= y && val2.get_y() < y2)
            {
                int cellIndex2 = mapStateProvider.GetCellIndex(val2.get_x(), val2.get_y());
                if ((grid[cellIndex2].state & (CellState.Reachable | CellState.Occupied)) == CellState.Reachable)
                {
                    return(true);
                }
            }
            Vector2Int val3 = default(Vector2Int);

            val3._002Ector(coord.get_x() + 1, coord.get_y());
            if (val3.get_x() >= x && val3.get_x() < x2 && val3.get_y() >= y && val3.get_y() < y2)
            {
                int cellIndex3 = mapStateProvider.GetCellIndex(val3.get_x(), val3.get_y());
                if ((grid[cellIndex3].state & (CellState.Reachable | CellState.Occupied)) == CellState.Reachable)
                {
                    return(true);
                }
            }
            Vector2Int val4 = default(Vector2Int);

            val4._002Ector(coord.get_x(), coord.get_y() - 1);
            if (val4.get_x() >= x && val4.get_x() < x2 && val4.get_y() >= y && val4.get_y() < y2)
            {
                int cellIndex4 = mapStateProvider.GetCellIndex(val4.get_x(), val4.get_y());
                if ((grid[cellIndex4].state & (CellState.Reachable | CellState.Occupied)) == CellState.Reachable)
                {
                    return(true);
                }
            }
            return(false);
        }
        public void Begin([NotNull] ICharacterEntity tracked, FightPathFinder pathFinder)
        {
            //IL_0067: Unknown result type (might be due to invalid IL or missing references)
            //IL_006c: Unknown result type (might be due to invalid IL or missing references)
            //IL_006f: Unknown result type (might be due to invalid IL or missing references)
            //IL_0097: Unknown result type (might be due to invalid IL or missing references)
            //IL_00c3: Unknown result type (might be due to invalid IL or missing references)
            //IL_013a: Unknown result type (might be due to invalid IL or missing references)
            //IL_013f: Unknown result type (might be due to invalid IL or missing references)
            //IL_0142: Unknown result type (might be due to invalid IL or missing references)
            //IL_019d: Unknown result type (might be due to invalid IL or missing references)
            //IL_01fb: Unknown result type (might be due to invalid IL or missing references)
            //IL_0200: Unknown result type (might be due to invalid IL or missing references)
            //IL_0203: Unknown result type (might be due to invalid IL or missing references)
            //IL_025e: Unknown result type (might be due to invalid IL or missing references)
            IMapStateProvider  mapStateProvider  = stateProvider;
            IMapEntityProvider mapEntityProvider = entityProvider;
            HashSet <IObjectTargetableByAction> objectsTargetableByAction = m_objectsTargetableByAction;

            canMove             = tracked.canMove;
            canPassThrough      = tracked.HasProperty(PropertyId.CanPassThrough);
            canDoActionOnTarget = tracked.canDoActionOnTarget;
            int num = grid.Length;

            for (int i = 0; i < num; i++)
            {
                Cell cell = grid[i];
                if (cell.state != 0)
                {
                    Vector2Int coords = cell.coords;
                    IEntityWithBoardPresence entity;
                    CellState state = (!mapEntityProvider.TryGetEntityBlockingMovementAt(coords, out entity)) ? CellState.Movement : ((entity != tracked) ? (CellState.Movement | CellState.Occupied) : (CellState.Movement | CellState.Reachable | CellState.Tracked));
                    grid[i] = new Cell(cell.coords, state, entity);
                }
            }
            pathFinder.FloodFill(mapStateProvider, grid, tracked.area.refCoord, tracked.movementPoints, canPassThrough);
            ActionType      actionType         = tracked.actionType;
            IEntitySelector customActionTarget = tracked.customActionTarget;

            if (customActionTarget != null)
            {
                CharacterActionValueContext context = new CharacterActionValueContext((FightStatus)mapEntityProvider, tracked);
                foreach (IEntity item in customActionTarget.EnumerateEntities(context))
                {
                    IEntityTargetableByAction entityTargetableByAction;
                    if (item != tracked && (entityTargetableByAction = (item as IEntityTargetableByAction)) != null)
                    {
                        Vector2Int refCoord = entityTargetableByAction.area.refCoord;
                        if (IsInActionRange(refCoord, tracked))
                        {
                            IObjectTargetableByAction objectTargetableByAction;
                            if ((objectTargetableByAction = (entityTargetableByAction.view as IObjectTargetableByAction)) != null)
                            {
                                objectTargetableByAction.ShowActionTargetFeedback(actionType, isSelected: false);
                                objectsTargetableByAction.Add(objectTargetableByAction);
                            }
                            int  cellIndex = mapStateProvider.GetCellIndex(refCoord.get_x(), refCoord.get_y());
                            Cell cell2     = grid[cellIndex];
                            grid[cellIndex] = new Cell(refCoord, cell2.state | CellState.Targetable, entityTargetableByAction);
                        }
                    }
                }
            }
            else
            {
                foreach (IEntityTargetableByAction item2 in mapEntityProvider.EnumerateEntities <IEntityTargetableByAction>())
                {
                    if (item2 != tracked)
                    {
                        Vector2Int refCoord2 = item2.area.refCoord;
                        if (IsInActionRange(refCoord2, tracked))
                        {
                            IObjectTargetableByAction objectTargetableByAction2;
                            if ((objectTargetableByAction2 = (item2.view as IObjectTargetableByAction)) != null)
                            {
                                objectTargetableByAction2.ShowActionTargetFeedback(actionType, isSelected: false);
                                objectsTargetableByAction.Add(objectTargetableByAction2);
                            }
                            int  cellIndex2 = mapStateProvider.GetCellIndex(refCoord2.get_x(), refCoord2.get_y());
                            Cell cell3      = grid[cellIndex2];
                            grid[cellIndex2] = new Cell(refCoord2, cell3.state | CellState.Targetable, item2);
                        }
                    }
                }
            }
            trackedCharacter = tracked;
            targetedEntity   = null;
        }
Пример #15
0
 public FightMapTargetContext([NotNull] IMapStateProvider stateProvider)
 {
     this.stateProvider = stateProvider;
 }