Example #1
0
 /// Can one pass from `origin` to adjacent `position`?
 /// <param name="origin">Position object is at now</param>
 /// <param name="position">Adjacent position object wants to move to</param>
 /// <param name="includingPlayers">Set this to false to ignore players from check</param>
 /// <param name="context">Is excluded from passable check</param>
 /// <returns></returns>
 public bool IsPassableAt(Vector3Int origin, Vector3Int position, bool isServer,
                          CollisionType collisionType    = CollisionType.Player, bool includingPlayers = true, GameObject context = null,
                          List <LayerType> excludeLayers = null, List <TileType> excludeTiles          = null, bool ignoreObjects = false)
 {
     return(MetaTileMap.IsPassableAt(origin, position, isServer, collisionType: collisionType,
                                     inclPlayers: includingPlayers, context: context, excludeLayers: excludeLayers, excludeTiles: excludeTiles, ignoreObjects: ignoreObjects));
 }
        private static void DrawGizmo(MetaTileMap scr, GizmoType gizmoType)
        {
            if (!DrawGizmos)
            {
                return;
            }

            Vector3Int start = Vector3Int.RoundToInt(Camera.current.ScreenToWorldPoint(Vector3.one * -32) - scr.transform.position);             // bottom left
            Vector3Int end   =
                Vector3Int.RoundToInt(Camera.current.ScreenToWorldPoint(new Vector3(Camera.current.pixelWidth + 32, Camera.current.pixelHeight + 32)) -
                                      scr.transform.position);

            start.z = 0;
            end.z   = 1;


            if (end.y - start.y > 100)
            {
                // avoid being zoomed out too much (creates too many objects)
                return;
            }

            Gizmos.matrix = scr.transform.localToWorldMatrix;


            Color blue = Color.blue;

            blue.a = 0.5f;

            Color red = Color.red;

            red.a = 0.5f;

            Color green = Color.green;

            red.a = 0.5f;

            if (room)
            {
                DrawRoom(scr);
            }
            else
            {
                foreach (Vector3Int position in new BoundsInt(start, end - start).allPositionsWithin)
                {
                    if (space)
                    {
                        if (scr.IsSpaceAt(position))
                        {
                            Gizmos.color = red;
                            Gizmos.DrawCube(position + new Vector3(0.5f, 0.5f, 0), Vector3.one);
                        }
                    }
                    else
                    {
                        if (corners)
                        {
                            if (scr.HasTile(position, LayerType.Walls))
                            {
                                Gizmos.color = green;

                                int corner_count = 0;
                                foreach (Vector3Int pos in new[] { Vector3Int.up, Vector3Int.left, Vector3Int.down, Vector3Int.right, Vector3Int.up })
                                {
                                    if (!scr.HasTile(position + pos, LayerType.Walls))
                                    {
                                        corner_count++;
                                    }
                                    else
                                    {
                                        corner_count = 0;
                                    }

                                    if (corner_count > 1)
                                    {
                                        Gizmos.DrawCube(position + new Vector3(0.5f, 0.5f, 0), Vector3.one);
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            Gizmos.color = blue;
                            if (passable)
                            {
                                if (north)
                                {
                                    if (!scr.IsPassableAt(position + Vector3Int.up, position))
                                    {
                                        Gizmos.DrawCube(position + new Vector3(0.5f, 0.5f, 0), Vector3.one);
                                    }
                                }
                                else if (south)
                                {
                                    if (!scr.IsPassableAt(position + Vector3Int.down, position))
                                    {
                                        Gizmos.DrawCube(position + new Vector3(0.5f, 0.5f, 0), Vector3.one);
                                    }
                                }
                                else if (!scr.IsPassableAt(position))
                                {
                                    Gizmos.DrawCube(position + new Vector3(0.5f, 0.5f, 0), Vector3.one);
                                }
                            }
                            else
                            {
                                if (!scr.IsAtmosPassableAt(position))
                                {
                                    Gizmos.DrawCube(position + new Vector3(0.5f, 0.5f, 0), Vector3.one);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #3
0
 /// Can one pass from `origin` to adjacent `position`?
 /// <param name="origin">Position object is at now</param>
 /// <param name="position">Adjacent position object wants to move to</param>
 /// <param name="includingPlayers">Set this to false to ignore players from check</param>
 /// <param name="context">Is excluded from passable check</param>
 /// <returns></returns>
 public bool IsPassableAt(Vector3Int origin, Vector3Int position, bool isServer, CollisionType collisionType = CollisionType.Player, bool includingPlayers = true, GameObject context = null)
 {
     return(MetaTileMap.IsPassableAt(origin, position, isServer, collisionType: collisionType, inclPlayers: includingPlayers, context: context));
 }
Example #4
0
 public bool IsPassableAt(Vector3Int origin, Vector3Int position)
 {
     return(metaTileMap.IsPassableAt(origin, position));
 }
Example #5
0
 public bool IsPassableAt(Vector3Int origin, Vector3Int position, bool includingPlayers = true)
 {
     return(metaTileMap.IsPassableAt(origin, position, includingPlayers));
 }
Example #6
0
 /// Can one pass from `origin` to adjacent `position`?
 /// <param name="origin">Position object is at now</param>
 /// <param name="position">Adjacent position object wants to move to</param>
 /// <param name="includingPlayers">Set this to false to ignore players from check</param>
 /// <param name="context">Is excluded from passable check</param>
 /// <returns></returns>
 public bool IsPassableAt(Vector3Int origin, Vector3Int position, bool includingPlayers = true, GameObject context = null)
 {
     return(metaTileMap.IsPassableAt(origin, position, includingPlayers, context));
 }
        static void DrawGizmo(MetaTileMap scr, GizmoType gizmoType)
        {
            if (!DrawGizmos)
            {
                return;
            }

            var start = Vector3Int.RoundToInt(Camera.current.ScreenToWorldPoint(Vector3.one * -32) - scr.transform.position); // bottom left
            var end   = Vector3Int.RoundToInt(Camera.current.ScreenToWorldPoint(new Vector3(Camera.current.pixelWidth + 32, Camera.current.pixelHeight + 32)) - scr.transform.position);

            start.z = 0;
            end.z   = 1;


            if (end.y - start.y > 100)
            {
                // avoid being zoomed out too much (creates too many objects)
                return;
            }

            Gizmos.matrix = scr.transform.localToWorldMatrix;


            var blue = Color.blue;

            blue.a = 0.5f;

            var red = Color.red;

            red.a = 0.5f;

            foreach (var position in new BoundsInt(start, end - start).allPositionsWithin)
            {
                if (!space)
                {
                    Gizmos.color = blue;
                    if (passable)
                    {
                        if (north)
                        {
                            if (!scr.IsPassableAt(position + Vector3Int.up, position))
                            {
                                Gizmos.DrawCube(position + new Vector3(0.5f, 0.5f, 0), Vector3.one);
                            }
                        }
                        else if (south)
                        {
                            if (!scr.IsPassableAt(position + Vector3Int.down, position))
                            {
                                Gizmos.DrawCube(position + new Vector3(0.5f, 0.5f, 0), Vector3.one);
                            }
                        }
                        else if (!scr.IsPassableAt(position))
                        {
                            Gizmos.DrawCube(position + new Vector3(0.5f, 0.5f, 0), Vector3.one);
                        }
                    }
                    else
                    {
                        if (!scr.IsAtmosPassableAt(position))
                        {
                            Gizmos.DrawCube(position + new Vector3(0.5f, 0.5f, 0), Vector3.one);
                        }
                    }
                }
                else
                {
                    if (scr.IsSpaceAt(position))
                    {
                        Gizmos.color = red;
                        Gizmos.DrawCube(position + new Vector3(0.5f, 0.5f, 0), Vector3.one);
                    }
                }
            }
        }