Beispiel #1
0
 public bool AreConnected(Vec3 pos1, Vec3 pos2, MovementFlag flags)
 {
     using (new ReadLock(DataLock))
     {
         GridCell pos1_gc = m_GridCells.Find(g => g.Contains2D(pos1));
         GridCell pos2_gc = m_GridCells.Find(g => g.Contains2D(pos2));
         return(Algorihms.AreConnected(pos1_gc, ref pos2_gc, flags));
     }
 }
Beispiel #2
0
        private void UpdateGridDestination()
        {
            Vec3       destination          = Vec3.Empty;
            List <int> destination_grids_id = null;

            using (new ReadLock(InputLock))
                destination_grids_id = new List <int>(m_DestinationGridsId);

            if (destination_grids_id.Count > 0)
            {
                using (m_Navmesh.AcquireReadDataLock())
                {
                    GridCell current_grid = m_Navmesh.m_GridCells.FirstOrDefault(g => g.Contains2D(CurrentPos));

                    GridCell destination_grid = m_Navmesh.m_GridCells.FirstOrDefault(g => destination_grids_id.Contains(g.Id) && Algorihms.AreConnected(current_grid, ref g, MovementFlag.None));

                    if (destination_grid != null)
                    {
                        destination = m_Navmesh.GetNearestCell(destination_grid.Cells, destination_grid.Center).Center;
                    }
                }
            }

            if (!destination.IsEmpty)
            {
                SetDestination(destination, DestType.Grid, GridDestPrecision);
            }
        }
Beispiel #3
0
        private void UpdateGridDestination()
        {
            Vec3 destination = Vec3.Empty;

            if (m_DestinationGridsId.Count > 0)
            {
                using (m_Navmesh.AquireReadDataLock())
                {
                    GridCell current_grid = m_Navmesh.m_GridCells.Find(g => g.Contains2D(CurrentPos));

                    GridCell destination_grid = m_Navmesh.m_GridCells.Find(g => m_DestinationGridsId.Contains(g.Id) && Algorihms.AreConnected(current_grid, ref g, MovementFlag.None));

                    if (destination_grid != null)
                    {
                        destination = m_Navmesh.GetNearestCell(destination_grid.Cells, destination_grid.Center).Center;
                    }
                }
            }

            if (!destination.IsEmpty)
            {
                SetDestination(destination, DestType.Grid);
            }
        }
Beispiel #4
0
        private void UpdateGridDestination()
        {
            Vec3       destination          = Vec3.ZERO;
            bool       grid_dest_found      = false;
            List <int> destination_grids_id = null;

            using (new ReadLock(InputLock))
                destination_grids_id = new List <int>(m_DestinationGridsId);

            if (destination_grids_id.Count > 0)
            {
                using (m_Navmesh.AcquireReadDataLock())
                {
                    GridCell current_grid = m_Navmesh.m_GridCells.FirstOrDefault(x => x.Contains2D(CurrentPos));

                    GridCell destination_grid = m_Navmesh.m_GridCells.FirstOrDefault(x => destination_grids_id.Contains(x.Id) && Algorihms.AreConnected(current_grid, ref x, MovementFlag.None));

                    if (destination_grid != null)
                    {
                        grid_dest_found = true;
                        destination     = m_Navmesh.GetNearestCell(destination_grid.GetCells(), destination_grid.Center).Center;
                    }
                }
            }

            if (grid_dest_found)
            {
                SetDestination(destination, DestType.Grid, GridDestPrecision);
            }
        }