macro pathing test
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-31 14:51:21 -04:00
parent c7ea57f350
commit 5aa623ee4f
3 changed files with 44 additions and 1 deletions

View File

@ -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

View File

@ -80,7 +80,7 @@ public class MacroPathingService extends SignalServiceImpl {
* @param end The end area
* @return The path
*/
private List<Vector3d> findPath(MacroData macroData, MacroPathNode start, MacroPathNode end){
protected List<Vector3d> findPath(MacroData macroData, MacroPathNode start, MacroPathNode end){
List<Vector3d> rVal = null;
//tracks whether we've found the goal or not
boolean foundGoal = false;

View File

@ -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<MacroRegion> farmPlots = town.getFarmPlots(macroData);
List<Vector3d> 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();
}
}