public static void GenerateShrine(User user, int numberOfShrines = 1, int shrineSize = 12) { if (shrineSize < 1 || shrineSize > 20) { ChatManager.DebugAddToChatLog("#Shrine location", "Shrine size must be between 1 and 20", user.Name, 1); return; } for (int i = 0; i < numberOfShrines; ++i) { var location = World.GetRandomLandPos() + (Vector3i.Down * (shrineSize * 2)); location.SpiralOutXZIter(shrineSize).ForEach(x => { var height = Math.Min((shrineSize * 0.5f), (shrineSize * 0.6f) - WorldPosition3i.Distance(x, location)); for (int j = 0; j < height; ++j) { if (!World.GetBlock((Vector3i)x + (Vector3i.Up * j)).Is <Impenetrable>()) { World.DeleteBlock((Vector3i)x + (Vector3i.Up * j)); } if ((int)WorldPosition3i.Distance(x, location) != 0 && !World.GetBlock((Vector3i)x + (Vector3i.Down * j)).Is <Impenetrable>()) { World.SetBlock <WaterBlock>((Vector3i)x + (Vector3i.Down * j)); } } }); WorldObjectUtil.Spawn("EckoStatueObject", null, (Vector3i)location); ChatManager.DebugAddToChatLog("#Shrine location", location.ToString(), user.Name, 1); } }
public static BTStatus RouteToWater(Animal agent, float speed, AnimalAnimationState state) { var start = agent.Position.WorldPosition3i; // only works for surface start points if (World.World.IsUnderwater(start) || start.y != World.World.MaxYCache[start] || RouteManager.RouteToSeaMap == null) return BTStatus.Failure; if (start.IsValid) { agent.AnimationState = state; // get a destination a decent var current = start; for (int i = 0; i < 10; i++) { var next = RouteManager.RouteToSeaMap[current]; if (next == current) break; current = next; if (WorldPosition3i.Distance(current, start) > 10) break; } var target = ((Vector2)(WorldPosition3i.GetDelta(current, start)).XZ).Rotate(RandomUtil.Range(-20, 20)); return AmphibiousMovement(agent, target, speed, state, 10, 20); } return BTStatus.Failure; }
public static BTResult RouteToWater(Animal agent, bool wandering, AnimalState state) { var start = agent.Position.WorldPosition3i; // only works for surface start points if (World.World.IsUnderwater(start)) { return(BTResult.Failure("Already underwater.")); } if (start.y != World.World.MaxYCache[start]) { return(BTResult.Failure("Not on world surface.")); } if (RouteManager.RouteToSeaMap == null) { return(BTResult.Failure("Missing sea route map.")); } if (start.IsValid) { agent.ChangeState(state, 0, false); // get a destination a decent var current = start; for (int i = 0; i < 10; i++) { var next = RouteManager.RouteToSeaMap[current]; if (next == current) { break; } current = next; if (WorldPosition3i.Distance(current, start) > 10) { break; } } var target = ((Vector2)WorldPosition3i.GetDelta(current, start).XZ).Rotate(RandomUtil.Range(-20, 20)); return(AmphibiousMovement(agent, target, wandering, state, 10, 20)); } return(BTResult.Failure("Invalid start pos")); }
public void Generate(Random seed, Vector3 voxelSize, WorldSettings settings) { for (int i = 0; i < numberOfShrines; ++i) { var location = World.GetRandomLandPos() + (Vector3i.Down * (shrineSize * 2)); location.SpiralOutXZIter(shrineSize).ForEach(x => { var height = Math.Min((shrineSize * 0.5f), (shrineSize * 0.6f) - WorldPosition3i.Distance(x, location)); for (int j = 0; j < height; ++j) { if (!World.GetBlock((Vector3i)x + (Vector3i.Up * j)).Is <Impenetrable>()) { World.DeleteBlock((Vector3i)x + (Vector3i.Up * j)); } if ((int)WorldPosition3i.Distance(x, location) != 0 && !World.GetBlock((Vector3i)x + (Vector3i.Down * j)).Is <Impenetrable>()) { World.SetBlock <WaterBlock>((Vector3i)x + (Vector3i.Down * j)); } } }); WorldObjectUtil.Spawn("EckoStatueObject", null, (Vector3i)location); } }