macro pathfinding work + reorg
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-05-30 12:37:18 -04:00
parent 63ed9fc06d
commit cde8f35887
32 changed files with 317 additions and 46 deletions

View File

@ -2071,6 +2071,10 @@ Fall and gravity tree fixes
Potential window fix
Sprinting/physics work
(05/30/2025)
Reorganizing macro classes
Start work on macro pathfinding storage

View File

@ -30,7 +30,7 @@ import electrosphere.data.voxel.VoxelData;
import electrosphere.data.voxel.sampler.SamplerFile;
import electrosphere.logger.LoggerInterface;
import electrosphere.net.config.NetConfig;
import electrosphere.server.macro.race.RaceMap;
import electrosphere.server.macro.character.race.RaceMap;
import electrosphere.server.macro.symbolism.SymbolMap;
import electrosphere.util.FileUtils;

View File

@ -12,7 +12,7 @@ import electrosphere.data.entity.common.CommonEntityValidator;
import electrosphere.data.entity.creature.CreatureData;
import electrosphere.data.entity.creature.CreatureDataValidator;
import electrosphere.data.entity.creature.CreatureTypeLoader;
import electrosphere.server.macro.race.RaceValidator;
import electrosphere.server.macro.character.race.RaceValidator;
/**
* Used to validate the config

View File

@ -13,7 +13,7 @@ import electrosphere.server.ai.blackboard.BlackboardKeys;
import electrosphere.server.ai.nodes.AITreeNode;
import electrosphere.server.datacell.Realm;
import electrosphere.server.macro.MacroData;
import electrosphere.server.macro.race.Race;
import electrosphere.server.macro.character.race.Race;
import electrosphere.server.macro.structure.VirtualStructure;
import electrosphere.server.macro.utils.StructurePlacementUtils;
import electrosphere.util.FileUtils;

View File

@ -21,7 +21,7 @@ import electrosphere.server.saves.SaveUtils;
import electrosphere.util.FileUtils;
import electrosphere.util.math.HashUtils;
import electrosphere.server.macro.character.Character;
import electrosphere.server.macro.race.Race;
import electrosphere.server.macro.character.race.Race;
import electrosphere.server.macro.spatial.MacroLODObject;
import electrosphere.server.macro.spatial.MacroObject;

View File

@ -10,16 +10,16 @@ import electrosphere.logger.LoggerInterface;
import electrosphere.server.datacell.ServerWorldData;
import electrosphere.server.macro.character.Character;
import electrosphere.server.macro.character.data.CharacterDataStrings;
import electrosphere.server.macro.character.race.Race;
import electrosphere.server.macro.character.race.RaceMap;
import electrosphere.server.macro.civilization.Civilization;
import electrosphere.server.macro.civilization.CivilizationGenerator;
import electrosphere.server.macro.civilization.road.Road;
import electrosphere.server.macro.race.Race;
import electrosphere.server.macro.race.RaceMap;
import electrosphere.server.macro.civilization.town.Town;
import electrosphere.server.macro.region.MacroRegion;
import electrosphere.server.macro.spatial.MacroAreaObject;
import electrosphere.server.macro.spatial.MacroObject;
import electrosphere.server.macro.structure.VirtualStructure;
import electrosphere.server.macro.town.Town;
import electrosphere.util.FileUtils;
import electrosphere.util.annotation.Exclude;
import electrosphere.util.math.GeomUtils;

View File

@ -3,9 +3,9 @@ package electrosphere.server.macro;
import org.joml.Vector3d;
import electrosphere.server.datacell.Realm;
import electrosphere.server.macro.town.Town;
import electrosphere.server.macro.town.TownLayout;
import electrosphere.server.macro.town.TownPopulator;
import electrosphere.server.macro.civilization.town.Town;
import electrosphere.server.macro.civilization.town.TownLayout;
import electrosphere.server.macro.civilization.town.TownPopulator;
/**
* Updates macro data as a player comes into range of it

View File

@ -10,9 +10,9 @@ import electrosphere.server.macro.MacroData;
import electrosphere.server.macro.character.data.CharacterAssociatedId;
import electrosphere.server.macro.character.data.CharacterDataStrings;
import electrosphere.server.macro.character.diety.Diety;
import electrosphere.server.macro.race.Race;
import electrosphere.server.macro.character.race.Race;
import electrosphere.server.macro.civilization.town.Town;
import electrosphere.server.macro.structure.VirtualStructure;
import electrosphere.server.macro.town.Town;
import electrosphere.server.service.CharacterService;
/**

View File

@ -11,8 +11,8 @@ import com.google.gson.JsonSerializer;
import electrosphere.server.macro.character.diety.Diety;
import electrosphere.server.macro.character.goal.CharacterGoal;
import electrosphere.server.macro.race.Race;
import electrosphere.server.macro.town.Town;
import electrosphere.server.macro.character.race.Race;
import electrosphere.server.macro.civilization.town.Town;
/**
* Deserializes noise modules

View File

@ -1,4 +1,4 @@
package electrosphere.server.macro.race;
package electrosphere.server.macro.character.race;
import java.util.List;

View File

@ -1,4 +1,4 @@
package electrosphere.server.macro.race;
package electrosphere.server.macro.character.race;
import java.util.List;

View File

@ -1,4 +1,4 @@
package electrosphere.server.macro.race;
package electrosphere.server.macro.character.race;
import electrosphere.data.Config;

View File

@ -6,9 +6,9 @@ import java.util.stream.Collectors;
import electrosphere.engine.Globals;
import electrosphere.server.macro.MacroData;
import electrosphere.server.macro.town.Town;
import electrosphere.server.macro.character.Character;
import electrosphere.server.macro.race.Race;
import electrosphere.server.macro.character.race.Race;
import electrosphere.server.macro.civilization.town.Town;
/**
* A civilization

View File

@ -5,8 +5,8 @@ import org.joml.Vector3d;
import electrosphere.data.Config;
import electrosphere.server.datacell.ServerWorldData;
import electrosphere.server.macro.MacroData;
import electrosphere.server.macro.race.Race;
import electrosphere.server.macro.town.Town;
import electrosphere.server.macro.character.race.Race;
import electrosphere.server.macro.civilization.town.Town;
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
/**

View File

@ -0,0 +1,5 @@
package electrosphere.server.macro.civilization.culture;
public class Culture {
}

View File

@ -0,0 +1,5 @@
package electrosphere.server.macro.civilization.culture;
public class Ritual {
}

View File

@ -1,4 +1,4 @@
package electrosphere.server.macro.culture.religion;
package electrosphere.server.macro.civilization.culture.religion;
import java.util.List;

View File

@ -1,4 +1,4 @@
package electrosphere.server.macro.culture.religion;
package electrosphere.server.macro.civilization.culture.religion;
/**
*

View File

@ -1,4 +1,4 @@
package electrosphere.server.macro.culture.religion;
package electrosphere.server.macro.civilization.culture.religion;
/**
* Story data strings

View File

@ -1,4 +1,4 @@
package electrosphere.server.macro.town;
package electrosphere.server.macro.civilization.town;
import electrosphere.engine.Globals;
import electrosphere.server.macro.MacroData;

View File

@ -1,4 +1,4 @@
package electrosphere.server.macro.town;
package electrosphere.server.macro.civilization.town;
import electrosphere.server.macro.structure.VirtualStructure;

View File

@ -1,4 +1,4 @@
package electrosphere.server.macro.town;
package electrosphere.server.macro.civilization.town;
import java.util.LinkedList;
import java.util.List;
@ -15,9 +15,9 @@ import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface;
import electrosphere.server.datacell.Realm;
import electrosphere.server.macro.MacroData;
import electrosphere.server.macro.character.race.Race;
import electrosphere.server.macro.civilization.Civilization;
import electrosphere.server.macro.civilization.road.Road;
import electrosphere.server.macro.race.Race;
import electrosphere.server.macro.region.MacroRegion;
import electrosphere.server.macro.structure.VirtualStructure;
import electrosphere.util.math.HashUtils;

View File

@ -1,4 +1,4 @@
package electrosphere.server.macro.town;
package electrosphere.server.macro.civilization.town;
import java.util.List;
import java.util.Random;
@ -12,7 +12,7 @@ import electrosphere.server.datacell.Realm;
import electrosphere.server.macro.MacroData;
import electrosphere.server.macro.character.Character;
import electrosphere.server.macro.character.CharacterUtils;
import electrosphere.server.macro.race.Race;
import electrosphere.server.macro.character.race.Race;
import electrosphere.server.macro.structure.VirtualStructure;
import electrosphere.server.service.CharacterService;

View File

@ -1,4 +1,4 @@
package electrosphere.server.macro.town;
package electrosphere.server.macro.civilization.town;
/**
* Simulates town

View File

@ -1,5 +0,0 @@
package electrosphere.server.macro.culture;
public class Culture {
}

View File

@ -1,5 +0,0 @@
package electrosphere.server.macro.culture;
public class Ritual {
}

View File

@ -0,0 +1,53 @@
package electrosphere.server.macro.spatial.path;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import electrosphere.util.annotation.Exclude;
/**
* A storage object for macro path nodes
*/
public class MacroPathCache {
/**
* The nodes in the cache
*/
private List<MacroPathNode> nodes = new LinkedList<MacroPathNode>();
/**
* Map of node id -> node
*/
@Exclude
private Map<Integer,MacroPathNode> idNodeMap = new HashMap<Integer,MacroPathNode>();
/**
* Reconstructs the datastructures for this cache after deserialization
*/
public void reconstruct(){
for(MacroPathNode node : nodes){
this.idNodeMap.put(node.getId(),node);
}
}
/**
* Gets the nodes in this cache
* @return The list of nodes
*/
public List<MacroPathNode> getNodes() {
return nodes;
}
/**
* Gets a node by its id
* @param id The id
* @return The corresponding node if it exists, null otherwise
*/
public MacroPathNode getNodeById(int id){
return idNodeMap.get(id);
}
}

View File

@ -0,0 +1,214 @@
package electrosphere.server.macro.spatial.path;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import org.joml.Vector3d;
import electrosphere.server.macro.structure.VirtualStructure;
/**
* A macro pathfinding node
*/
public class MacroPathNode {
//
// Node types
//
/**
* A node that represents a point in a node
*/
private static final int TYPE_ROAD_NODE = 0;
/**
* A node that represents a structure
*/
private static final int TYPE_VIRTUAL_STRUCTURE = 1;
//
// cost values
//
/**
* Cost of a virtual structure
*/
private static final int COST_VIRTUAL_STRUCTURE = 10;
/**
* Cost of a road node
*/
private static final int COST_ROAD_NODE = 1;
//
// node data
//
/**
* The id of this node
*/
private int id;
/**
* The id of the object that this node corresponds to
*/
private int objectId;
/**
* The type of object at the node
*/
private int objectType;
/**
* The ids of neighboring path nodes
*/
private List<Integer> neighborNodes = new LinkedList<Integer>();
/**
* The position of the node
*/
private Vector3d position;
/**
* The cost of this node
*/
private int cost;
/**
* Private constructor
*/
private MacroPathNode(){ }
/**
* Creates a macro path node
* @param cache The path cache
* @param correspondingObject The object that this pathing node corresponds to
* @param position The position of this node
* @return The macro path node
*/
public static MacroPathNode create(MacroPathCache cache, Object correspondingObject, Vector3d position){
MacroPathNode rVal = new MacroPathNode();
rVal.setId(cache.getNodes().size());
cache.getNodes().add(rVal);
//set data on the node
rVal.position = position;
//set data based on corresponding object
if(correspondingObject instanceof VirtualStructure structObj){
rVal.cost = COST_VIRTUAL_STRUCTURE;
rVal.objectId = structObj.getId();
rVal.objectType = TYPE_VIRTUAL_STRUCTURE;
} else {
throw new Error("Unsupported object type! " + correspondingObject);
}
return rVal;
}
/**
* Creates a macro path node that represents a node in a road
* @param cache The path cache
* @param position The position of this node
* @return The macro path node
*/
public static MacroPathNode createRoadNode(MacroPathCache cache, Vector3d position){
MacroPathNode rVal = new MacroPathNode();
rVal.setId(cache.getNodes().size());
cache.getNodes().add(rVal);
//set data on the node
rVal.position = position;
//set data based on corresponding object
rVal.cost = COST_ROAD_NODE;
rVal.objectType = TYPE_ROAD_NODE;
return rVal;
}
/**
* Gets the associated id
* @return
*/
public int getId() {
return id;
}
/**
* Sets the id of this path node
* @param id The id of this path node
*/
public void setId(int id) {
this.id = id;
}
/**
* Gets the type of the object associated with this node
* @return The type of the object
*/
public int getObjectType() {
return objectType;
}
/**
* Sets the type of the object associated with this node
* @param type The type of the object
*/
public void setObjectType(int type) {
this.objectType = type;
}
/**
* Gets the id of the object associated with this node
* @return The id of the object
*/
public int getObjectId() {
return objectId;
}
/**
* Sets the id of the object associated with this node
* @param objectId The id of the object
*/
public void setObjectId(int objectId) {
this.objectId = objectId;
}
/**
* Gets the list of node ids that are neighbors to this node
* @param cache The pathing cache
* @return The list of node ids
*/
public List<MacroPathNode> getNeighborNodes(MacroPathCache cache) {
return this.neighborNodes.stream().map((Integer id) -> cache.getNodeById(objectId)).collect(Collectors.toList());
}
/**
* Adds a neighbor to this node
* @param neighbor The neighbor
*/
public void addNeighbor(MacroPathNode neighbor){
this.neighborNodes.add(neighbor.getId());
}
/**
* Gets the position of the node
* @return The position of the node
*/
public Vector3d getPosition() {
return position;
}
/**
* Gets the cost of the node
* @return The cost of the node
*/
public int getCost() {
return cost;
}
}

View File

@ -14,10 +14,10 @@ import electrosphere.data.voxel.sampler.SamplerFile;
import electrosphere.engine.Globals;
import electrosphere.server.datacell.ServerWorldData;
import electrosphere.server.macro.civilization.road.Road;
import electrosphere.server.macro.civilization.town.Town;
import electrosphere.server.macro.region.MacroRegion;
import electrosphere.server.macro.spatial.MacroObject;
import electrosphere.server.macro.structure.VirtualStructure;
import electrosphere.server.macro.town.Town;
import electrosphere.server.physics.terrain.generation.heightmap.EmptySkyGen;
import electrosphere.server.physics.terrain.generation.heightmap.HeightmapGenerator;
import electrosphere.server.physics.terrain.generation.heightmap.HeightmapNoiseGen;

View File

@ -13,11 +13,11 @@ import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface;
import electrosphere.server.datacell.ServerWorldData;
import electrosphere.server.macro.MacroData;
import electrosphere.server.macro.civilization.town.Town;
import electrosphere.server.macro.spatial.MacroAreaObject;
import electrosphere.server.macro.spatial.MacroLODObject;
import electrosphere.server.macro.spatial.MacroObject;
import electrosphere.server.macro.structure.VirtualStructure;
import electrosphere.server.macro.town.Town;
import electrosphere.server.physics.terrain.diskmap.ChunkDiskMap;
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;

View File

@ -5,8 +5,8 @@ import java.util.List;
import electrosphere.engine.Globals;
import electrosphere.server.datacell.Realm;
import electrosphere.server.macro.character.Character;
import electrosphere.server.macro.town.Town;
import electrosphere.server.macro.town.TownSimulator;
import electrosphere.server.macro.civilization.town.Town;
import electrosphere.server.macro.civilization.town.TownSimulator;
import electrosphere.server.service.CharacterService;
import electrosphere.server.simulation.chara.CharaSimulation;

View File

@ -12,8 +12,8 @@ import electrosphere.server.macro.character.CharacterUtils;
import electrosphere.server.macro.character.data.CharacterDataStrings;
import electrosphere.server.macro.character.goal.CharacterGoal;
import electrosphere.server.macro.character.goal.CharacterGoal.CharacterGoalType;
import electrosphere.server.macro.civilization.town.Town;
import electrosphere.server.macro.structure.VirtualStructure;
import electrosphere.server.macro.town.Town;
import electrosphere.server.macro.utils.StructurePlacementUtils;
import electrosphere.server.macro.utils.StructureRepairUtils;
import electrosphere.util.FileUtils;