コード例 #1
0
ファイル: InsideCheck.cs プロジェクト: DevZhav/The-Forest
        private static void AddRoof(InsideCheck.GridPosition position, IRoof roof)
        {
            List <IRoof> list = InsideCheck.AffirmRoofList(position);

            list.Add(roof);
            InsideCheck.ForceRefresh(position);
        }
コード例 #2
0
ファイル: InsideCheck.cs プロジェクト: DevZhav/The-Forest
        private static void AddWallChunk(InsideCheck.GridPosition position, InsideCheck.WallChunk chunk)
        {
            List <InsideCheck.WallChunk> list = InsideCheck.AffirmWallList(position);

            list.Add(chunk);
            InsideCheck.ForceRefresh(position);
        }
コード例 #3
0
        private IEnumerator UpdateInsideRoutine()
        {
            for (;;)
            {
                Transform listener = this.GetListener();
                if (listener == null)
                {
                    yield return(YieldPresets.WaitForFixedUpdate);

                    yield return(0);
                }
                else
                {
                    InsideCheck.GridPosition position = InsideCheck.ToGridPosition(listener.position);
                    if (this._forceRefresh || position != this._currentGridPosition)
                    {
                        this._forceRefresh        = false;
                        this._currentGridPosition = position;
                        this._currentGridCells.Clear();
                        for (int i = -1; i <= 1; i++)
                        {
                            for (int j = -1; j <= 1; j++)
                            {
                                InsideCheck.GridCell gridCell = InsideCheck.GetGridCell(position + new InsideCheck.GridPosition(i, j));
                                if (gridCell != null)
                                {
                                    this._currentGridCells.Add(gridCell);
                                }
                            }
                        }
                    }
                    for (int k = 0; k < this._occlusion.Count; k++)
                    {
                        this._occlusion[k] = false;
                    }
                    this._roofDetected = InsideCheck.IsAnyRoofAbove(listener.position);
                    if (this._roofDetected)
                    {
                        for (int l = 0; l < this._currentGridCells.Count; l++)
                        {
                            InsideCheck.RenderWallsToOcclusion(this._currentGridCells[l], listener.position, this._occlusion);
                        }
                    }
                    float occlusionPercent = 0f;
                    for (int m = 0; m < this._occlusion.Count; m++)
                    {
                        if (this._occlusion[m])
                        {
                            occlusionPercent += 1f;
                        }
                    }
                    occlusionPercent *= 100f / (float)this._occlusion.Count;
                    this.SetInside(occlusionPercent >= this.OCCLUSION_THRESHOLD);
                    yield return(YieldPresets.WaitPointOneSeconds);
                }
            }
            yield break;
        }
コード例 #4
0
ファイル: InsideCheck.cs プロジェクト: DevZhav/The-Forest
 private static InsideCheck.GridCell GetGridCell(InsideCheck.GridPosition position)
 {
     InsideCheck.GridCell result = null;
     if (InsideCheck._grid != null)
     {
         InsideCheck._grid.TryGetValue(position, out result);
     }
     return(result);
 }
コード例 #5
0
ファイル: InsideCheck.cs プロジェクト: DevZhav/The-Forest
 private static List <IRoof> AffirmRoofList(InsideCheck.GridPosition position)
 {
     InsideCheck.GridCell gridCell = InsideCheck.AffirmGridCell(position);
     if (gridCell.roofs == null)
     {
         gridCell.roofs = new List <IRoof>();
     }
     return(gridCell.roofs);
 }
コード例 #6
0
ファイル: InsideCheck.cs プロジェクト: DevZhav/The-Forest
 private static List <InsideCheck.WallChunk> AffirmWallList(InsideCheck.GridPosition position)
 {
     InsideCheck.GridCell gridCell = InsideCheck.AffirmGridCell(position);
     if (gridCell.walls == null)
     {
         gridCell.walls = new List <InsideCheck.WallChunk>();
     }
     return(gridCell.walls);
 }
コード例 #7
0
ファイル: InsideCheck.cs プロジェクト: DevZhav/The-Forest
 private static void ForceRefresh(InsideCheck.GridPosition position)
 {
     if (InsideCheck._instance != null)
     {
         InsideCheck.GridPosition currentGridPosition = InsideCheck._instance._currentGridPosition;
         if (Mathf.Abs(position.x - InsideCheck._instance._currentGridPosition.x) <= 1 && Mathf.Abs(position.y - InsideCheck._instance._currentGridPosition.y) <= 1)
         {
             InsideCheck._instance._forceRefresh = true;
         }
     }
 }
コード例 #8
0
ファイル: InsideCheck.cs プロジェクト: DevZhav/The-Forest
 private static InsideCheck.GridCell AffirmGridCell(InsideCheck.GridPosition position)
 {
     InsideCheck.AffirmGrid();
     InsideCheck.GridCell gridCell = null;
     if (!InsideCheck._grid.TryGetValue(position, out gridCell))
     {
         gridCell = new InsideCheck.GridCell();
         InsideCheck._grid[position] = gridCell;
     }
     return(gridCell);
 }
コード例 #9
0
ファイル: InsideCheck.cs プロジェクト: DevZhav/The-Forest
 public static int AddWallChunk(Vector3 start, Vector3 end, float height)
 {
     if (end.y < start.y)
     {
         float y = start.y;
         start.y = end.y;
         end.y   = y;
     }
     end.y += height;
     InsideCheck.WallChunk wallChunk = new InsideCheck.WallChunk(start, end, InsideCheck._nextGridToken);
     InsideCheck._nextGridToken++;
     InsideCheck.GridPosition gridPosition = InsideCheck.ToGridPosition(start);
     InsideCheck.AddWallChunk(gridPosition, wallChunk);
     InsideCheck.GridPosition gridPosition2 = InsideCheck.ToGridPosition(end);
     if (gridPosition2 != gridPosition)
     {
         InsideCheck.AddWallChunk(gridPosition2, wallChunk);
     }
     return(wallChunk.token);
 }
コード例 #10
0
ファイル: InsideCheck.cs プロジェクト: DevZhav/The-Forest
        public static void AddRoof(IRoof roof)
        {
            List <Vector3> polygon = roof.GetPolygon();

            if (polygon.Count <= 0)
            {
                return;
            }
            Bounds bounds = new Bounds(polygon[0], Vector3.zero);

            for (int i = 1; i < polygon.Count; i++)
            {
                bounds.Encapsulate(polygon[i]);
            }
            InsideCheck.GridPosition gridPosition  = InsideCheck.ToGridPosition(bounds.min);
            InsideCheck.GridPosition gridPosition2 = InsideCheck.ToGridPosition(bounds.max);
            for (int j = gridPosition.x; j <= gridPosition2.x; j++)
            {
                for (int k = gridPosition.y; k <= gridPosition2.y; k++)
                {
                    InsideCheck.AddRoof(new InsideCheck.GridPosition(j, k), roof);
                }
            }
        }