diff --git a/TrueCraft.Core/AI/AStarPathFinder.cs b/TrueCraft.Core/AI/AStarPathFinder.cs index 4af7cb8..c1817be 100644 --- a/TrueCraft.Core/AI/AStarPathFinder.cs +++ b/TrueCraft.Core/AI/AStarPathFinder.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using TrueCraft.API; using TrueCraft.API.World; +using System.Diagnostics; namespace TrueCraft.Core.AI { @@ -66,7 +67,6 @@ namespace TrueCraft.Core.AI public PathResult FindPath(IWorld world, BoundingBox subject, Coordinates3D start, Coordinates3D goal) { // Thanks to www.redblobgames.com/pathfinding/a-star/implementation.html - var parents = new Dictionary(); var costs = new Dictionary(); var openset = new PriorityQueue(); diff --git a/TrueCraft.Core/AI/WanderState.cs b/TrueCraft.Core/AI/WanderState.cs index a002bf0..f792a8b 100644 --- a/TrueCraft.Core/AI/WanderState.cs +++ b/TrueCraft.Core/AI/WanderState.cs @@ -24,8 +24,8 @@ namespace TrueCraft.Core.AI public WanderState() { - IdleChance = 5; - Distance = 16; + IdleChance = 20; + Distance = 25; PathFinder = new AStarPathFinder(); } diff --git a/TrueCraft/MultiplayerServer.cs b/TrueCraft/MultiplayerServer.cs index 6c201bd..905c283 100644 --- a/TrueCraft/MultiplayerServer.cs +++ b/TrueCraft/MultiplayerServer.cs @@ -17,6 +17,8 @@ using TrueCraft.Exceptions; using TrueCraft.Core.Logic; using TrueCraft.Core.Lighting; using TrueCraft.Core.World; +using System.Threading.Tasks; +using System.Diagnostics; namespace TrueCraft { @@ -172,23 +174,36 @@ namespace TrueCraft } PendingBlockUpdates.Enqueue(new BlockUpdate { Coordinates = e.Position, World = sender as IWorld }); ProcessBlockUpdates(); - var lighter = WorldLighters.SingleOrDefault(l => l.World == sender); - if (lighter != null) + if (Program.ServerConfiguration.EnableLighting) { - lighter.EnqueueOperation(new BoundingBox(e.Position, e.Position + Vector3.One), true); - lighter.EnqueueOperation(new BoundingBox(e.Position, e.Position + Vector3.One), false); + var lighter = WorldLighters.SingleOrDefault(l => l.World == sender); + if (lighter != null) + { + lighter.EnqueueOperation(new BoundingBox(e.Position, e.Position + Vector3.One), true); + lighter.EnqueueOperation(new BoundingBox(e.Position, e.Position + Vector3.One), false); + } } } } void HandleChunkGenerated(object sender, ChunkLoadedEventArgs e) { - var lighter = new WorldLighting(sender as IWorld, BlockRepository); - var coords = e.Coordinates * new Coordinates2D(Chunk.Width, Chunk.Depth); - lighter.EnqueueOperation(new BoundingBox(new Vector3(coords.X, 0, coords.Z), - new Vector3(coords.X + Chunk.Width, Chunk.Height, coords.Z + Chunk.Depth)), true, true); - while (lighter.TryLightNext()) // Initial lighting + if (Program.ServerConfiguration.EnableLighting) { + var lighter = new WorldLighting(sender as IWorld, BlockRepository); + var coords = e.Coordinates * new Coordinates2D(Chunk.Width, Chunk.Depth); + lighter.EnqueueOperation(new BoundingBox(new Vector3(coords.X, 0, coords.Z), + new Vector3(coords.X + Chunk.Width, Chunk.Height, coords.Z + Chunk.Depth)), true, true); + while (lighter.TryLightNext()) // Initial lighting + { + } + } + else + { + for (int i = 0; i < e.Chunk.SkyLight.Data.Length; i++) + { + e.Chunk.SkyLight.Data[i] = 0xFF; + } } } diff --git a/TrueCraft/ServerConfiguration.cs b/TrueCraft/ServerConfiguration.cs index 4bba2c5..6f7f516 100644 --- a/TrueCraft/ServerConfiguration.cs +++ b/TrueCraft/ServerConfiguration.cs @@ -30,6 +30,7 @@ namespace TrueCraft Singleplayer = false; Query = true; QueryPort = 25566; + EnableLighting = false; } [YamlMember(Alias = "motd")] @@ -55,5 +56,8 @@ namespace TrueCraft [YamlMember(Alias = "queryPort")] public int QueryPort { get; set; } + + [YamlMember(Alias = "enable-lighting")] + public bool EnableLighting { get; set; } } } \ No newline at end of file