Beispiel #1
0
        private void UpdateWallCaps()
        {
            if (wallCapPrefab == null)
            {
                return;
            }

            // Go through each direction and ensure the wallcap is present.
            for (Direction direction = Direction.North; direction < Direction.NorthWest; direction += 2)
            {
                int i = (int)direction / 2;

                // Get the direction this applies to for the external world
                Direction outsideDirection = DirectionHelper.Apply(RotationHelper.ToPerpendicularDirection(TileState.rotation), direction);
                bool      isPresent        = adjacents.Adjacent(outsideDirection) == 1;

                if (isPresent && wallCaps[i] == null)
                {
                    wallCaps[i]      = SpawnWallCap(direction);
                    wallCaps[i].name = $"WallCap{i}";
                }
                else if (!isPresent && wallCaps[i] != null)
                {
                    EditorAndRuntime.Destroy(wallCaps[i]);
                    wallCaps[i] = null;
                }
            }
        }