Example #1
0
 public static bool isSolid(BlockAddress testing)
 {
     if (testing == null)
         return false;
     if (MainGame.mainGame.getBlock(testing).solidity == Solidity.solid)
         return true;
     return false;
 }
Example #2
0
 public bool actionEnd(BlockAddress target)
 {
     throw new NotImplementedException();
 }
Example #3
0
 public bool actionStart(BlockAddress target)
 {
     justMined = MainGame.mainGame.getBlock(target);
     MainGame.mainGame.changeBlock(target, new SolidBlock(((MainGame.mainGame.lua.global["vanilla"] as LuaTable)["basics"] as LuaTable)["air"] as Material));
     return true;
 }
Example #4
0
 public bool onTest(BlockAddress testing)
 {
     return standardBlockTests.isSolid(testing);
 }
Example #5
0
 public bool beforeTest(BlockAddress testing)
 {
     throw new NotImplementedException();
 }
Example #6
0
 public PlayerFist()
 {
     timer = 0;
     mining = null;
     justMined = null;
 }
Example #7
0
        public BlockAddress findBlockBefore(IntVector3 chunk, Vector3 posInChunk, Vector3 directionToSeek, int lengthToStop, blockChecker isAcceptable)
        {
            Vector3 unitX, unitY, unitZ;
            Vector3 nextX, nextY, nextZ;
            float xDist, yDist, zDist, stopDist;
            float fTemp;
            Vector3 vTemp;
            BlockAddress bTemp;
            BlockAddress previous = new BlockAddress(chunk, posInChunk);

            stopDist = lengthToStop;

            #region initialization
            fTemp = Math.Abs(directionToSeek.X);
            if (fTemp != 0)
            {
                unitX = directionToSeek / fTemp;
                if (unitX.X > 0)
                {
                    fTemp = (float)Math.Ceiling(posInChunk.X) - posInChunk.X;
                }
                else
                {
                    fTemp = (float)Math.Floor(posInChunk.X) - posInChunk.X;
                }
                vTemp = unitX * fTemp;
                xDist = vTemp.Length();
                nextX = vTemp + posInChunk;
            }
            else
            {
                xDist = stopDist + 1;
                unitX = new Vector3();
                nextX = new Vector3();
            }

            fTemp = Math.Abs(directionToSeek.Y);
            if (fTemp != 0)
            {
                unitY = directionToSeek / fTemp;
                if (unitY.Y > 0)
                {
                    fTemp = (float)Math.Ceiling(posInChunk.Y) - posInChunk.Y;
                }
                else
                {
                    fTemp = (float)Math.Floor(posInChunk.Y) - posInChunk.Y;
                }
                vTemp = unitY * fTemp;
                yDist = vTemp.Length();
                nextY = vTemp + posInChunk;
            }
            else
            {
                yDist = stopDist + 1;
                unitY = new Vector3();
                nextY = new Vector3();
            }

            fTemp = Math.Abs(directionToSeek.Z);
            if (fTemp != 0)
            {
                unitZ = directionToSeek / fTemp;
                if (unitZ.Z > 0)
                {
                    fTemp = (float)Math.Ceiling(posInChunk.Z) - posInChunk.Z;
                }
                else
                {
                    fTemp = (float)Math.Floor(posInChunk.Z) - posInChunk.Z;
                }
                vTemp = unitZ * fTemp;
                zDist = vTemp.Length();
                nextZ = vTemp + posInChunk;
            }
            else
            {
                zDist = stopDist + 1;
                unitZ = new Vector3();
                nextZ = new Vector3();
            }
            #endregion
            #region seekLoop
            while (true)
            {
                fTemp = Math.Min(Math.Min(xDist, yDist), Math.Min(zDist, stopDist));
                if (fTemp == stopDist)
                    return null;
                if (fTemp == xDist)
                {
                    vTemp = new Vector3(unitX.X / 10, 0, 0);
                    bTemp = new BlockAddress(chunk, nextX + vTemp);
                    if (isAcceptable(bTemp))
                        return previous;
                    nextX += unitX;
                    xDist += unitX.Length();
                    previous = bTemp;
                    continue;
                }
                if (fTemp == yDist)
                {
                    vTemp = new Vector3(0, unitY.Y / 10, 0);
                    bTemp = new BlockAddress(chunk, nextY + vTemp);
                    if (isAcceptable(bTemp))
                        return previous;
                    nextY += unitY;
                    yDist += unitY.Length();
                    previous = bTemp;
                    continue;
                }
                if (fTemp == zDist)
                {
                    vTemp = new Vector3(0, 0, unitZ.Z / 10);
                    bTemp = new BlockAddress(chunk, nextZ + vTemp);
                    if (isAcceptable(bTemp))
                        return previous;
                    nextZ += unitZ;
                    zDist += unitZ.Length();
                    previous = bTemp;
                    continue;
                }
                return null;
            }
            #endregion
        }
Example #8
0
 public void changeBlock(BlockAddress address, Block changeTo)
 {
     IntVector3 chunk = address.chunk;
     chunk -= mapOffset;
     map.get(chunk).assignBlock(address.block, changeTo);
 }
Example #9
0
        public Block getBlock(BlockAddress address)
        {
            IntVector3 chunk = address.chunk;
            chunk -= mapOffset;
            if (chunk.X < 0 || chunk.X >= map.GetLength(0) || chunk.Y < 0 || chunk.Y >= map.GetLength(1) || chunk.Z < 0 || chunk.Z >= map.GetLength(2))
                return null;
            if(map.get(chunk) == null)
                return null;

            return map.get(chunk).getBlock(address.block);
        }
Example #10
0
 public bool actionStart(BlockAddress target)
 {
     MainGame.mainGame.changeBlock(target, block);
     return true;
 }