예제 #1
0
 public PieceCrossing(StructureMineshaft shaft, BlockPos hallwayPoint, Direction hallwayDir, int piecesFromCenter)
     : base(shaft, hallwayPoint + (hallwayDir.blockPos * 4))
 {
     piecesFromCenter += 1;
     if (this.addToShaftIfValid(piecesFromCenter))
     {
         this.generateHallwaysAroundPoint(hallwayDir.getOpposite(), this.orgin, 6, piecesFromCenter);
     }
 }
예제 #2
0
 public PieceMobSpawner(StructureMineshaft shaft, BlockPos hallwayPoint, Direction hallwayDir, int piecesFromCenter)
     : base(shaft, hallwayPoint + (hallwayDir.blockPos * 4))
 {
     piecesFromCenter += 1;
     if (this.addToShaftIfValid(piecesFromCenter))
     {
         int i = this.generateHallwaysAroundPoint(hallwayDir.getOpposite(), this.orgin, 6, piecesFromCenter);
         this.northGate = this.func02(i, hallwayDir, Direction.NORTH);
         this.eastGate  = this.func02(i, hallwayDir, Direction.EAST);
         this.southGate = this.func02(i, hallwayDir, Direction.SOUTH);
         this.westGate  = this.func02(i, hallwayDir, Direction.WEST);
     }
 }
예제 #3
0
        public PieceHallway(StructureMineshaft shaft, BlockPos start, Direction hallwayDirection, int piecesFromCenter) : base(shaft, start)
        {
            this.end      = this.orgin + (hallwayDirection.blockPos * this.shaft.rnd.Next(PieceHallway.minLength, PieceHallway.minLength + 1) * 8);
            this.pointing = hallwayDirection;
            this.is3High  = this.shaft.rnd.Next(0, 2) == 0;

            this.calculateBounds();

            piecesFromCenter++;
            if (this.addToShaftIfValid(piecesFromCenter))
            {
                this.successfullyGenerated = true;

                if (piecesFromCenter <= 1)
                {
                    // If we are still close to the start, always go straight, so we arent wrapping back around the middle.
                    new PieceHallway(this.shaft, this.end + this.pointing.blockPos, this.pointing, piecesFromCenter);
                }
                else
                {
                    int i = this.shaft.rnd.Next(7);
                    if (i <= 1)  // 0, 1
                    {
                        this.addHallway(this.pointing.getClockwise(), piecesFromCenter);
                    }
                    else if (i <= 3)   // 2, 3
                    {
                        this.addHallway(this.pointing.getCounterClockwise(), piecesFromCenter);
                    }
                    else if (i <= 5)   // 4, 5
                    {
                        this.addRoom(piecesFromCenter);
                    }
                    else if (i == 6)   // 6
                    {
                        new PieceHallway(this.shaft, this.end + this.pointing.blockPos, this.pointing, piecesFromCenter);
                    }
                }
            }
        }
예제 #4
0
        public PieceCenter(StructureMineshaft shaft, BlockPos center) : base(shaft, center)
        {
            // Get random floors
            if (this.shaft.rnd.Next(2) == 1)
            {
                this.topFloor    = 0;
                this.bottomFloor = 1;
            }
            else
            {
                this.topFloor    = 1;
                this.bottomFloor = 0;
            }

            // Pick entrance to use.
            this.useFartherEntrance = this.shaft.rnd.Next(2) == 0;
            this.isTall             = false; // this.shaft.rnd.Next(2) == 0;

            this.calculateBounds();
            this.shaft.pieces.Add(this);

            BlockPos shaftOrgin = new BlockPos(this.orgin.x - 8, this.orgin.y, this.orgin.z);

            // Add starting rooms above and below.
            this.shaft.pieces.Add(new PieceSmallShaft(this.shaft, shaftOrgin, 9, false));
            this.shaft.pieces.Add(new PieceSmallShaft(this.shaft, shaftOrgin + new BlockPos(0, 9, 0), 6, false));
            this.shaft.pieces.Add(new PieceSmallShaft(this.shaft, shaftOrgin + new BlockPos(0, -6, 0), 6, true));

            this.pickRndRoom(shaftOrgin + new BlockPos(0, 9, 0));
            this.pickRndRoom(shaftOrgin + new BlockPos(0, -6, 0));

            // Add hallways.
            new PieceHallway(this.shaft, this.orgin + new BlockPos(-5, 1, -8), Direction.WEST, 0);
            new PieceHallway(this.shaft, this.orgin + new BlockPos(5, 1, this.useFartherEntrance ? 0 : -8), Direction.EAST, 0);
            new PieceHallway(this.shaft, this.orgin + new BlockPos(0, 1, 5), Direction.NORTH, 0);
            new PieceHallway(this.shaft, this.orgin + new BlockPos(0, 1, -15), Direction.SOUTH, 0);
        }
예제 #5
0
        public PieceShaft(StructureMineshaft shaft, BlockPos hallwayPoint, Direction hallwayDir, int piecesFromCenter, int flag)
            : base(shaft, hallwayPoint + (hallwayDir.blockPos * 4))
        {
            this.calculateBounds();

            if (this.isIntersecting())
            {
                return;
            }
            this.shaft.pieces.Add(this);
            this.addedToList = true;

            piecesFromCenter++;
            if (piecesFromCenter > StructureMineshaft.SIZE_CAP)
            {
                return;
            }

            this.specialFlag  = flag;
            this.floor1Ladder = (byte)this.shaft.rnd.Next(4);
            this.floor2Ladder = (byte)this.shaft.rnd.Next(4);

            // Only pick a random floor block and column mode if this is the root piece (middle).
            if (this.specialFlag != 0)
            {
                this.closeColumns = this.shaft.rnd.Next(4) == 0;
                this.floorType    = (byte)this.shaft.rnd.Next(2);
            }

            if (this.specialFlag == 0)
            {
                //This is the middle/first piece
                PieceShaft up   = new PieceShaft(this.shaft, new BlockPos(hallwayPoint.x, hallwayPoint.y + 14, hallwayPoint.z), hallwayDir, piecesFromCenter, this.specialFlag + 1);
                PieceShaft down = new PieceShaft(this.shaft, new BlockPos(hallwayPoint.x, hallwayPoint.y - 14, hallwayPoint.z), hallwayDir, piecesFromCenter, this.specialFlag - 1);
                if (!up.addedToList && !down.addedToList)
                {
                    //Both pieces failed, remove this piece. The whole stack failed, so nothing should be here.
                    this.shaft.pieces.RemoveAt(this.shaft.pieces.Count - 1);
                }
                else
                {
                    // We added at least one piece, up or down or both
                    if (up.addedToList)
                    {
                        up.floorBelowLadderFlag = this.floor2Ladder;
                    }
                    else
                    {
                        this.specialFlag = 1;
                    }
                    if (down.addedToList)
                    {
                        this.floorBelowLadderFlag = down.floor2Ladder;
                    }
                    else
                    {
                        this.specialFlag = -1;
                    }
                }
                up.floorType      = this.floorType;
                down.floorType    = this.floorType;
                up.closeColumns   = this.closeColumns;
                down.closeColumns = this.closeColumns;
            }
            else if (this.specialFlag == -1)
            {
                //TODO chance for water filled bottom piece
            }

            this.generateHallwaysAroundPoint(hallwayDir.getOpposite(), this.orgin, 5, piecesFromCenter);
        }
예제 #6
0
 /// <summary>
 /// Constructor when the piece is added from the generation classes.
 /// </summary>
 public PieceBase(StructureMineshaft shaft, BlockPos orgin)
 {
     this.shaft = shaft;
     this.orgin = orgin;
 }