Beispiel #1
0
        public byte?getBlockAt(ref BlockLoc loc)
        {
            Vector3 worldSpaceVec3 = loc.toWorldSpaceVector3();
            Island  toTest         = getClosestIslandToLocation(ref worldSpaceVec3);

            return(toTest.getBlockAt(ref loc));
        }
Beispiel #2
0
        public LinkedList <BlockLoc> GetBlocksBoundBy(BlockLoc loc1, BlockLoc loc2)
        {
            BlockLoc min = new BlockLoc((int)Math.Min(loc1.WSX(), loc2.WSX()), (int)Math.Min(loc1.WSY(), loc2.WSY()), (int)Math.Min(loc1.WSZ(), loc2.WSZ()));
            BlockLoc max = new BlockLoc((int)Math.Max(loc1.WSX(), loc2.WSX()), (int)Math.Max(loc1.WSY(), loc2.WSY()), (int)Math.Max(loc1.WSZ(), loc2.WSZ()));

            LinkedList <BlockLoc> result = new LinkedList <BlockLoc>();

            Island relevant  = getIslandManager().getClosestIslandToLocation(loc2.toWorldSpaceVector3());
            int    spaceSize = (max.WSY() - min.WSY());

            Console.WriteLine(spaceSize + " space size");
            for (int x = min.WSX(); x <= max.WSX(); x++)
            {
                for (int y = min.WSY(); y <= max.WSY(); y++)
                {
                    for (int z = min.WSZ(); z <= max.WSZ(); z++)
                    {
                        BlockLoc toTest = new BlockLoc(x, y, z);
                        byte?    block  = islandManager.getBlockAtOnGivenIsland(ref toTest, relevant);
                        if (block.HasValue)
                        {
                            if (PaintedCubeSpace.isSolidType((byte)block))
                            {
                                result.AddLast(new BlockLoc(x, y, z));
                            }
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #3
0
        public DecorativePlant(BlockLoc FootLocation)
        {
            blockRootedIn = FootLocation;
            float  height = 5;
            Random rand   = new Random();

            string[] possiblePlants = { "yellowFlower", "blueFlower", "shortLeafyPlant", "bush" };
            string   plantName      = possiblePlants[rand.Next(possiblePlants.Length)];

            setupSetPiece(new AxisAlignedBoundingBox(FootLocation.toWorldSpaceVector3() + new Vector3(0, 1, 0), FootLocation.toWorldSpaceVector3() + new Vector3(0, 1, 0) + new Vector3(1f, height, 1f)),
                          ContentDistributor.getEmptyString() + @"world_decoration\" + plantName + ".chr");

            setRootPartRotationOffset(Quaternion.CreateFromRotationMatrix(Matrix.CreateRotationY((float)new Random().NextDouble() * 10.0f)));
        }
Beispiel #4
0
        public LinkedList <BlockLoc> getSurfaceBlocksBoundBy(BlockLoc loc1, BlockLoc loc2)
        {
            BlockLoc min = new BlockLoc((int)Math.Min(loc1.WSX(), loc2.WSX()), (int)Math.Min(loc1.WSY(), loc2.WSY()), (int)Math.Min(loc1.WSZ(), loc2.WSZ()));
            BlockLoc max = new BlockLoc((int)Math.Max(loc1.WSX(), loc2.WSX()), (int)Math.Max(loc1.WSY(), loc2.WSY()), (int)Math.Max(loc1.WSZ(), loc2.WSZ()));

            LinkedList <BlockLoc> result = new LinkedList <BlockLoc>();

            Island relevant = getIslandManager().getClosestIslandToLocation(loc2.toWorldSpaceVector3());

            BlockLoc aboveBlockLoc = new BlockLoc();
            BlockLoc blockAtLoc    = new BlockLoc();

            for (int x = min.WSX(); x <= max.WSX(); x++)
            {
                for (int y = min.WSY(); y <= max.WSY(); y++)
                {
                    for (int z = min.WSZ(); z <= max.WSZ(); z++)
                    {
                        blockAtLoc.setValuesInWorldSpace(x, y, z);
                        byte?block = islandManager.getBlockAtOnGivenIsland(ref blockAtLoc, relevant);
                        if (block.HasValue)
                        {
                            if (PaintedCubeSpace.isSolidType((byte)block))
                            {
                                aboveBlockLoc.setValuesInWorldSpace(x, y + 1, z);
                                byte?aboveBlock = islandManager.getBlockAtOnGivenIsland(ref aboveBlockLoc, relevant);
                                if (aboveBlock.HasValue)
                                {
                                    if (!PaintedCubeSpace.isOpaqueType((byte)aboveBlock))
                                    {
                                        result.AddLast(new BlockLoc(x, y, z));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #5
0
        public Tree(BlockLoc nFootLocation, treeTypes type)
        {
            FootLocation = nFootLocation;
            Random rand   = new Random();
            float  height = 5;

            switch (type)
            {
            case treeTypes.maple:
                height = 5;
                string[] possibleTrees = { "tree1", "tree2" };
                string   treeName      = possibleTrees[rand.Next(possibleTrees.Length)];//"fallTree1";
                setupSetPiece(new AxisAlignedBoundingBox(FootLocation.toWorldSpaceVector3(), FootLocation.toWorldSpaceVector3() + new Vector3(1f, height, 1f)),
                              ContentDistributor.getEmptyString() + @"trees\" + treeName + ".chr", .8f + (float)new Random().NextDouble() * .4f);
                setRootPartRotationOffset(Quaternion.CreateFromRotationMatrix(Matrix.CreateRotationY((float)new Random().NextDouble() * 10.0f)));
                break;

            case treeTypes.poplar:
                height = 5;

                string[] poplarNames = { "tree", "tree2", "tree3" };
                string   poplarName  = poplarNames[rand.Next(poplarNames.Length)]; //"fallTree1";
                setupSetPiece(new AxisAlignedBoundingBox(FootLocation.toWorldSpaceVector3(), FootLocation.toWorldSpaceVector3() + new Vector3(1f, height, 1f)),
                              ContentDistributor.getEmptyString() + @"poplarTree\" + poplarName + ".chr", .2f);
                setRootPartRotationOffset(Quaternion.CreateFromRotationMatrix(Matrix.CreateRotationY((float)new Random().NextDouble() * 10.0f)));
                break;

            case treeTypes.pine:
                height = 5;

                string[] pineNames = { "tree" };
                string   pineName  = pineNames[rand.Next(pineNames.Length)]; //"fallTree1";
                String   path      = ContentDistributor.getEmptyString() + @"pineTree\" + pineName + ".chr";
                setupSetPiece(new AxisAlignedBoundingBox(FootLocation.toWorldSpaceVector3(), FootLocation.toWorldSpaceVector3() + new Vector3(1f, height, 1f)),
                              path, .4f + (float)rand.NextDouble() * .3f);
                setRootPartRotationOffset(Quaternion.CreateFromRotationMatrix(Matrix.CreateRotationY((float)new Random().NextDouble() * 10.0f)));
                break;

            case treeTypes.redwood:
                height = 5;

                string[] redwoodNames = { "tree" };
                string   redwoodName  = redwoodNames[rand.Next(redwoodNames.Length)]; //"fallTree1";
                setupSetPiece(new AxisAlignedBoundingBox(FootLocation.toWorldSpaceVector3(), FootLocation.toWorldSpaceVector3() + new Vector3(1f, height, 1f)),
                              ContentDistributor.getEmptyString() + @"redwood\" + redwoodName + ".chr", .2f);
                setRootPartRotationOffset(Quaternion.CreateFromRotationMatrix(Matrix.CreateRotationY((float)new Random().NextDouble() * 10.0f)));
                break;

            case treeTypes.snowyPine:
                height = 5;

                string[] snowPineTreeNames = { "snowyPineTree" };
                string   snowPineTreeName  = snowPineTreeNames[rand.Next(snowPineTreeNames.Length)]; //"fallTree1";
                String   snowPinePath      = ContentDistributor.getEmptyString() + @"pineTree\" + snowPineTreeName + ".chr";
                setupSetPiece(new AxisAlignedBoundingBox(FootLocation.toWorldSpaceVector3(), FootLocation.toWorldSpaceVector3() + new Vector3(1f, height, 1f)),
                              snowPinePath, .2f + (float)rand.NextDouble() * .2f);
                setRootPartRotationOffset(Quaternion.CreateFromRotationMatrix(Matrix.CreateRotationY((float)new Random().NextDouble() * 10.0f)));
                break;

            case treeTypes.snowyLargePine:
                height = 5;

                string[] snowLargePineTreeNames = { "snowyDiskBasedPineTree" };
                string   snowyLargePineTreeName = snowLargePineTreeNames[rand.Next(snowLargePineTreeNames.Length)];  //"fallTree1";
                String   snowyLargePinePath     = ContentDistributor.getEmptyString() + @"pineTree\" + snowyLargePineTreeName + ".chr";
                setupSetPiece(new AxisAlignedBoundingBox(FootLocation.toWorldSpaceVector3(), FootLocation.toWorldSpaceVector3() + new Vector3(1f, height, 1f)),
                              snowyLargePinePath, .5f + (float)rand.NextDouble() * .3f);
                setRootPartRotationOffset(Quaternion.CreateFromRotationMatrix(Matrix.CreateRotationY((float)new Random().NextDouble() * 10.0f)));
                break;

            default:
                break;
            }
        }
Beispiel #6
0
 public void removeResourceBlock(BlockLoc blockLoc, ResourceBlock.ResourceType resourceType)
 {
     getClosestIslandToLocation(blockLoc.toWorldSpaceVector3()).removeResourceBlock(blockLoc, resourceType);
 }
Beispiel #7
0
 public void addResourceBlock(BlockLoc loc, ResourceBlock.ResourceType type)
 {
     getClosestIslandToLocation(loc.toWorldSpaceVector3()).addResourceBlock(loc, type);
 }
Beispiel #8
0
 public bool vehiclePlacedHereCouldBeBoarded(BlockLoc vehicleLoc)
 {
     return(getClosestIslandToLocation(vehicleLoc.toWorldSpaceVector3()).vehiclePlacedHereCouldBeBoarded(vehicleLoc));
 }
Beispiel #9
0
        public void buildBlockAt(BlockLoc blockLoc, byte typeToBuild)
        {
            Island relevantIsland = getClosestIslandToLocation(blockLoc.toWorldSpaceVector3());

            relevantIsland.buildBlock(blockLoc, typeToBuild);
        }
Beispiel #10
0
 public override bool isProfileSolidAtWithWithinCheck(BlockLoc loc)
 {
     return(islandManager.getClosestIslandToLocation(loc.toWorldSpaceVector3()).getPathingProfile().isProfileSolidAtWithWithinCheck(loc));
 }
Beispiel #11
0
 public override float?intersects(Microsoft.Xna.Framework.Ray ray)
 {
     return(new BoundingBox(objectLoc.toWorldSpaceVector3() - new Vector3(1, 1, 1),
                            objectLoc.toWorldSpaceVector3() + new Vector3(2, 2, 2)).Intersects(ray));
 }