From 5aa623ee4fa260d255be44e74d587552030d0109 Mon Sep 17 00:00:00 2001 From: austin Date: Sat, 31 May 2025 14:51:21 -0400 Subject: [PATCH] macro pathing test --- docs/src/progress/renderertodo.md | 1 + .../server/service/MacroPathingService.java | 2 +- .../service/MacroPathingServiceTests.java | 42 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/test/java/electrosphere/server/service/MacroPathingServiceTests.java diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 4c8f74fe..2a74a885 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -2095,6 +2095,7 @@ Error logging in entity-character assignment Potential fix for macro pathing continuous loop Unit test for generating a world TownLayout test +Macro pathing test diff --git a/src/main/java/electrosphere/server/service/MacroPathingService.java b/src/main/java/electrosphere/server/service/MacroPathingService.java index 9a2ce449..f34312e6 100644 --- a/src/main/java/electrosphere/server/service/MacroPathingService.java +++ b/src/main/java/electrosphere/server/service/MacroPathingService.java @@ -80,7 +80,7 @@ public class MacroPathingService extends SignalServiceImpl { * @param end The end area * @return The path */ - private List findPath(MacroData macroData, MacroPathNode start, MacroPathNode end){ + protected List findPath(MacroData macroData, MacroPathNode start, MacroPathNode end){ List rVal = null; //tracks whether we've found the goal or not boolean foundGoal = false; diff --git a/src/test/java/electrosphere/server/service/MacroPathingServiceTests.java b/src/test/java/electrosphere/server/service/MacroPathingServiceTests.java new file mode 100644 index 00000000..56789940 --- /dev/null +++ b/src/test/java/electrosphere/server/service/MacroPathingServiceTests.java @@ -0,0 +1,42 @@ +package electrosphere.server.service; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; + +import org.joml.Vector3d; + +import electrosphere.engine.Globals; +import electrosphere.server.datacell.ServerWorldData; +import electrosphere.server.entity.ServerContentManager; +import electrosphere.server.macro.MacroData; +import electrosphere.server.macro.civilization.town.Town; +import electrosphere.server.macro.civilization.town.TownLayout; +import electrosphere.server.macro.region.MacroRegion; +import electrosphere.server.macro.spatial.path.MacroPathCache; +import electrosphere.test.annotations.IntegrationTest; + +/** + * Testing the macro pathing service + */ +public class MacroPathingServiceTests { + + @IntegrationTest + public void test_findPath_1(){ + Globals.initGlobals(); + ServerWorldData worldData = ServerWorldData.createGenerationTestWorldData(); + MacroData macroData = MacroData.generateWorld(0, worldData); + MacroPathCache pathCache = macroData.getPathCache(); + Globals.serverState.realmManager.createGriddedRealm(worldData, ServerContentManager.createServerContentManager(false, macroData)); + Town town = Town.createTown(macroData, new Vector3d(1000,0,1000), 256, 0); + TownLayout.layoutTown(Globals.serverState.realmManager.first(), macroData, town); + List farmPlots = town.getFarmPlots(macroData); + + List path = Globals.serverState.macroPathingService.findPath(macroData, pathCache.getPathingNode(farmPlots.get(0).getPos()), pathCache.getPathingNode(farmPlots.get(1).getPos())); + assertTrue(path.size() > 0); + + Globals.unloadScene(); + Globals.resetGlobals(); + } + +}