Exemplo n.º 1
0
        private bool IsPassableAtOrthogonal(Vector3Int origin, Vector3Int to, bool isServer,
                                            CollisionType collisionType    = CollisionType.Player, bool inclPlayers = true, GameObject context = null,
                                            List <LayerType> excludeLayers = null, List <TileType> excludeTiles     = null, bool ignoreObjects = false, bool isReach = false)
        {
            if (ignoreObjects == false &&
                ObjectLayer.IsPassableAtOnThisLayer(origin, to, isServer, collisionType, inclPlayers, context, excludeTiles, isReach: isReach) == false)
            {
                return(false);
            }

            TileLocation TileLcation = null;

            for (var i = 0; i < SolidLayersValues.Length; i++)
            {
                // Skip floor & base collisions if this is not a shuttle
                if (collisionType != CollisionType.Shuttle &&
                    (SolidLayersValues[i].LayerType == LayerType.Floors ||
                     SolidLayersValues[i].LayerType == LayerType.Base))
                {
                    continue;
                }

                // Skip if the current tested layer is being excluded.
                if (excludeLayers != null && excludeLayers.Contains(SolidLayersValues[i].LayerType))
                {
                    continue;
                }

                lock (PresentTiles)
                {
                    PresentTiles[SolidLayersValues[i]].TryGetValue(to, out TileLcation);
                }

                if (TileLcation?.Tile == null)
                {
                    continue;
                }
                var tile = TileLcation.Tile as BasicTile;

                // Return passable if the tile type is being excluded from checks.
                if (excludeTiles != null && excludeTiles.Contains(tile.TileType))
                {
                    continue;
                }

                if (tile.IsPassable(collisionType, origin, this) == false)
                {
                    return(false);
                }

                // if ((TileLcation.Tile as BasicTile).IsAtmosPassable() == false)
                // {
                // return false;
                // }

                // if (!SolidLayersValues[i].IsPassableAt(origin, to, isServer, collisionType: collisionType,
                // inclPlayers: inclPlayers, context: context, excludeTiles))
                // {
                // return false;
                // }
            }

            return(true);
        }