Esempio n. 1
0
     public static IEnumerable <ElevatorExit> EnumerateExits(ElevatorStack Stack)
     {
         foreach (var segment in Stack.Pieces)
         {
             foreach (var neighborVoxel in VoxelHelpers.EnumerateManhattanNeighbors2D_Y(segment.GetContainingVoxel().Coordinate))
             {
                 var neighborHandle = new VoxelHandle(segment.Manager.World.ChunkManager, neighborVoxel);
                 if (neighborHandle.IsValid && neighborHandle.IsEmpty)
                 {
                     var below       = neighborVoxel + new GlobalVoxelOffset(0, -1, 0);
                     var belowHandle = new VoxelHandle(segment.Manager.World.ChunkManager, below);
                     if (belowHandle.IsValid && !belowHandle.IsEmpty)
                     {
                         yield return new ElevatorExit
                                {
                                    OntoVoxel    = neighborHandle,
                                    ShaftSegment = segment
                                }
                     }
                     ;
                 }
             }
         }
     }
 }
Esempio n. 2
0
        public static ElevatorStack Create(IEnumerable <ElevatorShaft> Pieces)
        {
            var r = new ElevatorStack();

            r.Pieces.AddRange(Pieces);
            r.UpdateBoundingBox();
            r.Invalid = false;
            return(r);
        }
Esempio n. 3
0
        private void RemoveShaft(ElevatorStack Shaft)
        {
            if (Shaft.Platform != null)
            {
                Shaft.Platform.Delete();
                Shaft.Platform = null;
                Shaft.Destroy();
            }

            Shafts.Remove(Shaft);
        }
Esempio n. 4
0
        private void CreateNewShaft(IEnumerable <ElevatorShaft> segments)
        {
            var newShaft = ElevatorStack.Create(segments);

            Shafts.Add(newShaft);
            newShaft.Platform = new ElevatorPlatform(segments.First().Manager, segments.First().Position);

            foreach (var segment in segments)
            {
                RemoveShaft(segment.Shaft);
                segment.Shaft            = newShaft;
                segment.NeedsShaftUpdate = false;
            }
        }