Renderer/src/main/java/electrosphere/server/macro/structure/VirtualStructureUtils.java
austin a7ef1db485
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
macro structure data definitions
2025-04-29 13:41:52 -04:00

71 lines
3.6 KiB
Java

package electrosphere.server.macro.structure;
import electrosphere.engine.Globals;
import electrosphere.server.datacell.Realm;
import electrosphere.server.macro.character.Character;
import java.util.LinkedList;
import java.util.List;
import org.joml.Vector2f;
/**
* Utility functions for dealing with structures on the server
*/
public class VirtualStructureUtils {
// public static Structure placeStructureAtPoint(float posX, float posY, float posZ, String type){
// Realm realm = Globals.realmManager.getRealms().iterator().next();
// int worldX = realm.getServerWorldData().convertRealToChunkSpace(posX);
// int worldY = realm.getServerWorldData().convertRealToChunkSpace(posY);
// Structure rVal = new Structure(worldX,worldY,posX,posY,type);
// Globals.macroData.addStructure(rVal);
// // double centerHeight = Globals.serverTerrainManager.getHeightAtPosition(posX, posY, posZ);
// // StructureType currentTypeObject = Globals.gameConfigCurrent.getStructureTypeMap().getType(type);
// // float radius = currentTypeObject.getRadius();
// // for(int x = -(int)radius; x < radius; x++){
// // for(int y = -(int)radius; y < radius; y++){
// // int newWorldX = Globals.serverWorldData.convertRealToChunkSpace(posX + x);
// // int newWorldY = Globals.serverWorldData.convertRealToChunkSpace(posY + y);
// // double newLocationX = Globals.serverWorldData.getRelativeLocation(posX + x, newWorldX);
// // double newLocationY = Globals.serverWorldData.getRelativeLocation(posY + y, newWorldY);
// // // System.out.println("Set height: " + centerHeight);
// // // System.out.println("Deform in chunk: " + newWorldX + "," + newWorldY);
// // Globals.serverTerrainManager.deformTerrainAtLocationToValue(newWorldX, newWorldY, (int)(newLocationX), (int)(newLocationY), (float)centerHeight);
// // }
// // }
// // StructureUtils.serverSpawnBasicStructure(type, realm, new Vector3d(posX,(float)centerHeight + 2.4f,posY), new Quaternionf());
// return rVal;
// }
public static boolean validStructurePlacementPosition(float posX, float posY, String type){
// StructureType toPlaceType = Globals.gameConfigCurrent.getStructureTypeMap().getType(type);
// Vector2f toPlacePos = new Vector2f(posX, posY);
// for(Structure virtualStruct : Globals.macroData.getStructures()){
// StructureType existantType = Globals.gameConfigCurrent.getStructureTypeMap().getType(virtualStruct.getType());
// Vector2f existantPos = new Vector2f(virtualStruct.getLocationX(),virtualStruct.getLocationY());
// if(existantPos.distance(toPlacePos) < toPlaceType.getRadius() + existantType.getRadius()){
// return false;
// }
// }
return true;
}
public static void addResident(Structure structure, Character character){
List<Character> residents = null;
if(structure.getDataKeys().contains(StructureDataStrings.RESIDENTS)){
residents = (List<Character>)structure.getData(StructureDataStrings.RESIDENTS);
} else {
residents = new LinkedList<Character>();
structure.putData(StructureDataStrings.RESIDENTS, residents);
}
residents.add(character);
}
public static List<Character> getResidents(Structure structure){
return (List<Character>)structure.getData(StructureDataStrings.RESIDENTS);
}
}