Exemple #1
0
        public AxisAlignedBoundingBox AABBPhysicsCollisionOnly(AxisAlignedBoundingBox currentAABB, Vector3 moveBy)
        {
            Island closestIsland = islandManager.getClosestIslandToLocation(currentAABB.middle());

            if (closestIsland == null)// if no islands are loaded
            {
                return(currentAABB);
            }
            AxisAlignedBoundingBox newAABB = closestIsland.AABBPhysics(currentAABB, moveBy);


            return(newAABB);
        }
Exemple #2
0
        internal void handleCharacterPlacement(Ray ray)
        {
            Island  relevant = islandManager.getClosestIslandToLocation(ray.Position);
            Vector3?toPlace  = getLastSpaceAlongRay(ray);

            if (toPlace.HasValue)
            {
                if (relevant.couldAffordResourceExpendeture(12, ResourceBlock.ResourceType.Wheat))
                {
                    relevant.debitResource(12, ResourceBlock.ResourceType.Wheat);
                    addCharacterAt(new BlockLoc((Vector3)toPlace).getMiddleInWorldSpace(), Actor.Faction.friendly);
                }
            }
        }
Exemple #3
0
        public void HandleBlockPlanPlacementMouseover(Ray ray)
        {
            Island  island     = islandManager.getClosestIslandToLocation(ray.Position);
            Vector3?maybeSpace = island.getLastSpaceAlongRayConsideringBuildSite(ray);

            if (maybeSpace.HasValue)
            {
                Vector3 space = (Vector3)maybeSpace;
                space.X = (int)space.X;
                space.Y = (int)space.Y;
                space.Z = (int)space.Z;
                WorldMarkupHandler.addCharacter(ContentDistributor.getEmptyString() + @"worldMarkup\" + "stoneMarkerOutline" + ".chr",
                                                ((Vector3)space) + new Vector3(.5f, .5f, .5f), 1.0f / 12.0f, .6f);
            }
        }
Exemple #4
0
        public void update()
        {
            gameDirector.update();
            Compositer.setSkyColors(gameDirector.getSkyHorizonColor(), gameDirector.getSkyZenithColor(), gameDirector.getAmbientBrighness());
            updateMonsterSpawning();
            handleActorActions(actorManager.update());

            foreach (Actor actor in actorManager.getActors())
            {
                Island closestIsland = islandManager.getClosestIslandToLocation(actor.getLocation());
                runPhysicsWithMoveActionAndIsland(actor, actor.getVelocity(), closestIsland);
            }


            islandManager.update();
        }
Exemple #5
0
 public Island getClosestIslandToLocation(ref Vector3 location)
 {
     if (islands.Count > 0)
     {
         int    shortestDistance = Int32.MaxValue;
         Island result           = islands[0];
         foreach (Island island in islands)
         {
             int distance = (int)Vector3.Distance(location, island.getCenterAtYZero());
             if (distance < shortestDistance)
             {
                 shortestDistance = distance;
                 result           = island;
             }
         }
         return(result);
     }
     return(null);
 }
Exemple #6
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);
        }
Exemple #7
0
        public void generationThreadTask()
        {
            while (true)
            {
                lock (generationQueue)
                {
                    if (Player.galleryMode)
                    {
                        generationQueue.Clear();
                        bool timeToRegen = IslandGeneratorLoader.updateAndReturnIfNewCodeIsReady();
                        if (timeToRegen)
                        {
                            lock (islands)
                            {
                                islands.Clear();
                            }
                            Island island = new Island(new Vector3(), Island.TerrainType.easy);
                            island.generateWithGenerator(IslandGeneratorLoader.getGenerator());
                            lock (islands)
                            {
                                addIsland(island);
                            }
                        }
                    }


                    foreach (Island toUpdate in generationQueue)
                    {
                        if (!toUpdate.hasBeenGenerated)
                        {
                            generateAndAddIslandToList(toUpdate);
                        }
                    }
                    generationQueue.Clear();
                }
                Thread.Sleep(1);
            }
        }
Exemple #8
0
        Island getIslandIntersectedByRay(Ray ray)
        {
            Island nearest = null;
            float  minDist = float.MaxValue;

            foreach (Island test in islands)
            {
                float?distToStrike = test.boundingBoxIntersectsRay(ray);
                if (distToStrike.HasValue)
                {
                    if (test.boundingBoxContaintPoint(ray.Position))
                    {
                        nearest = test;
                        break;
                    }

                    if ((float)distToStrike < minDist)
                    {
                        nearest = test;
                    }
                }
            }
            return(nearest);
        }
Exemple #9
0
 private void addIsland(Island toUpdate)
 {
     islands.Add(toUpdate);
 }
Exemple #10
0
 public IslandLocationProfile(Island nIsland)
 {
     island = nIsland;
 }
Exemple #11
0
        public void acceptWorkStrike(ActorStrikeAction actorStrikeAction)
        {
            Island relevantIsland = getClosestIslandToLocation(actorStrikeAction.getStriker().getLocation());

            relevantIsland.acceptWorkStrike(actorStrikeAction);
        }
Exemple #12
0
 public byte?getBlockAtOnGivenIsland(ref BlockLoc loc, Island toTest)
 {
     return(toTest.getBlockAt(ref loc));
 }
Exemple #13
0
        public void placeWoodBlockPlanAlongRay(Ray placeWoodBlockClickRay, byte typeToAdd)
        {
            Island island = islandManager.getClosestIslandToLocation(placeWoodBlockClickRay.Position);

            island.placeWoodBlockPlan(placeWoodBlockClickRay, typeToAdd);
        }
Exemple #14
0
        internal void placeExcavationBlockAlongRay(Ray ray)
        {
            Island island = islandManager.getClosestIslandToLocation(ray.Position);

            island.placeExcavationMark(ray);
        }
Exemple #15
0
 public void mipIslandToLevel(Island island, int level)
 {
     island.setMipLevel(level);
 }
Exemple #16
0
        public void removeWoodBlockPlanAlongRay(Ray removeWoodBlockClickRay)
        {
            Island island = islandManager.getClosestIslandToLocation(removeWoodBlockClickRay.Position);

            island.removeBlueprintBlockAlongRay(removeWoodBlockClickRay);
        }
Exemple #17
0
        public void placeBlockAlongRay(Ray placementRay, byte typeToPlace)
        {
            Island island = islandManager.getClosestIslandToLocation(placementRay.Position);

            island.placeBlockAlongRay(placementRay, typeToPlace);
        }
Exemple #18
0
        public void buildBlockAt(BlockLoc blockLoc, byte typeToBuild)
        {
            Island relevantIsland = getClosestIslandToLocation(blockLoc.toWorldSpaceVector3());

            relevantIsland.buildBlock(blockLoc, typeToBuild);
        }
Exemple #19
0
        public void destroyBlockAlongRay(Ray destructionRay)
        {
            Island island = islandManager.getClosestIslandToLocation(destructionRay.Position);

            island.destroyBlockAlongRayReturnTrueIfSomethingDestroyed(destructionRay);
        }
 public IslandPathingProfile(Island nIsland)
 {
     island = nIsland;
 }
Exemple #21
0
        private static void runPhysicsWithMoveActionAndIsland(Actor toMove, Vector3 movement, Island closestIsland)
        {
            Vector3 originalDesiredCharacterAABBMiddle = toMove.getAABB().addVector(movement).middle();


            AxisAlignedBoundingBox newAABBforCharacter = closestIsland.AABBPhysics(toMove.getAABB(), movement);
            Vector3 newVelocity = toMove.getVelocity();

            if (newAABBforCharacter.middle().X != originalDesiredCharacterAABBMiddle.X)
            {
                newVelocity.X = 0;
            }
            if (newAABBforCharacter.middle().Y != originalDesiredCharacterAABBMiddle.Y)
            {
                newVelocity.Y = 0;
            }
            if (newAABBforCharacter.middle().Z != originalDesiredCharacterAABBMiddle.Z)
            {
                newVelocity.Z = 0;
            }
            toMove.setVelocity(newVelocity);
            toMove.setAABB(newAABBforCharacter);
        }