cleaning up dead code
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-04-29 20:54:15 -04:00
parent 76e0073177
commit ec7c1371c2
10 changed files with 126 additions and 227 deletions

View File

@ -1601,6 +1601,7 @@ Non-procedural voxel generation fix
Flower foliage item
Texture loading from model files (ie can load texture path from model file)
Clean up material class a bit
Cleaning up dead code

View File

@ -85,7 +85,6 @@ import electrosphere.server.datacell.RealmManager;
import electrosphere.server.db.DatabaseController;
import electrosphere.server.entity.poseactor.PoseModel;
import electrosphere.server.macro.MacroData;
import electrosphere.server.macro.structure.StructureManager;
import electrosphere.server.saves.Save;
import electrosphere.server.simulation.MacroSimulation;
import electrosphere.server.simulation.MicroSimulation;
@ -394,9 +393,6 @@ public class Globals {
//collision world data
public static CollisionWorldData commonWorldData;
//structure manager
public static StructureManager structureManager;
//client level editor data management
public static ClientLevelEditorData clientLevelEditorData = new ClientLevelEditorData();

View File

@ -1,9 +1,5 @@
package electrosphere.server.macro.structure;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import org.joml.AABBd;
import org.joml.Vector3d;
@ -44,16 +40,6 @@ public class Structure extends CharacterData implements MacroAreaObject {
* The type of the structure
*/
String type;
/**
* Data associated with the structure
*/
HashMap<String,Object> data = new HashMap<String,Object>();
/**
* Data keys associated with the structure
*/
LinkedList<String> dataKeys = new LinkedList<String>();
/**
* Constructor
@ -77,33 +63,6 @@ public class Structure extends CharacterData implements MacroAreaObject {
rVal.aabb = new AABBd(new Vector3d(position), new Vector3d(position).add(data.getDimensions()));
return rVal;
}
/**
* Puts some data in the structure
* @param key The key for the data
* @param o The data
*/
public void putData(String key, Object o){
data.put(key,o);
dataKeys.add(key);
}
/**
* Gets the data keys for the structure
* @return
*/
public List<String> getDataKeys(){
return dataKeys;
}
/**
* Gets a piece of data on the structure
* @param key The key of the data
* @return The data if it exists, null otherwise
*/
public Object getData(String key){
return data.get(key);
}
/**
* Gets the type of the structure

View File

@ -1,11 +0,0 @@
package electrosphere.server.macro.structure;
/**
*
* @author satellite
*/
public class StructureDataStrings {
public static final String RESIDENTS = "residents";
}

View File

@ -1,10 +0,0 @@
package electrosphere.server.macro.structure;
/**
* Manages all server views of structures
*/
public class StructureManager {
static int structIDIterator = 0;
}

View File

@ -1,13 +1,5 @@
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
*/
@ -51,20 +43,5 @@ public class VirtualStructureUtils {
// }
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);
}
}

View File

@ -1,123 +1,102 @@
package electrosphere.server.macro.town;
import electrosphere.engine.Globals;
import electrosphere.server.macro.character.Character;
import electrosphere.server.macro.character.CharacterData;
import electrosphere.server.macro.character.CharacterDataStrings;
import electrosphere.server.macro.spatial.MacroAreaObject;
import electrosphere.server.macro.structure.Structure;
import java.util.LinkedList;
import java.util.List;
import org.joml.Vector2i;
import org.joml.AABBd;
import org.joml.Vector3d;
/**
* Server representation of a town
*/
public class Town extends CharacterData {
public class Town extends CharacterData implements MacroAreaObject {
int id;
/**
* The id of the town
*/
private int id;
/**
* Incrementer for IDs
*/
static int idIncrementer = 0;
List<Vector2i> positions = new LinkedList<Vector2i> ();
List<Structure> structures = new LinkedList<Structure>();
List<Character> residents = new LinkedList<Character>();
final static int avgDiffThreshold = 10;
public static Vector2i findValidTownLocation(){
// for(int x = 0; x < Globals.serverTerrainManager.getWorldDiscreteSize(); x++){
// for(int y = 0; y < Globals.serverTerrainManager.getWorldDiscreteSize(); y++){
// // ServerTerrainChunk chunk = Globals.serverTerrainManager.getChunk(x, y);
// // float[][] macroValues = chunk.getMacroValues();
// // float sum = 0;
// // int count = 0;
// // for(int i = 0; i < 5; i++){
// // for(int j = 0; j < 5; j++){
// // sum = sum + macroValues[i][j];
// // count++;
// // }
// // }
// // float average = sum / (float)count;
// // if(average > 1000){
// // float diffSum = 0;
// // for(int i = 0; i < 5; i++){
// // for(int j = 0; j < 5; j++){
// // diffSum = diffSum + (float)Math.abs(average - macroValues[i][j]);
// // }
// // }
// // float averageDiff = diffSum / (float)count;
// // if(averageDiff < avgDiffThreshold){
// // return new Vector2i(x,y);
// // }
// // }
// }
// }
return null;
}
/**
* The position of the town
*/
private Vector3d position;
/**
* The radius of the town
*/
private double radius;
/**
* The structures inside the town
*/
private List<Structure> structures = new LinkedList<Structure>();
/**
* The residents of the town
*/
private List<Character> residents = new LinkedList<Character>();
/**
* Constructor
*/
private Town(){
super(CharacterDataStrings.HOMETOWN);
super(CharacterDataStrings.TOWN);
this.id = idIncrementer;
idIncrementer++;
}
public static Town createTown(int x, int y){
/**
* Creates a town
* @param position The position of the town
* @param radius The radius of the town
* @return The town
*/
public static Town createTown(Vector3d position, double radius){
Town rVal = new Town();
rVal.positions.add(new Vector2i(x,y));
Globals.macroData.addTown(rVal);
// Random rand = new Random();
// int structCount = (rand.nextInt(3) + 2);
// int chunkSize = Globals.serverTerrainManager.getChunkWidth();
// for(int i = 0; i < structCount; i++){
// StructurePlacer.placeStructureAtPoint(x * chunkSize + rand.nextFloat() * 100, y * chunkSize + rand.nextFloat() * 100, "building1");
// }
rVal.position = position;
rVal.radius = radius;
return rVal;
}
public static Town getTownAtPosition(int x, int y){
Town rVal = null;
// DatabaseResult locationLookupResult = Globals.dbController.executeQuery("SELECT townID FROM townWorldPositions WHERE posX = " + x + " AND posY = " + y + ";");
// if(locationLookupResult.hasResultSet()){
// ResultSet rs = locationLookupResult.getResultSet();
// int townID = -1;
// try {
// if(rs.next()){
// townID = rs.getInt("townID");
// }
// } catch (SQLException ex) {
// LoggerInterface.loggerEngine.ERROR("Error reading result set from getTownAtPosition", ex);
// }
// if(townID != -1){
//
// }
// }
for(Town town : Globals.macroData.getTowns()){
for(Vector2i position : town.positions){
if(position.x == x && position.y == y){
return town;
}
}
}
return rVal;
}
public List<Vector2i> getPositions(){
return positions;
}
/**
* Adds a structure to the town
* @param structure The structure
*/
public void addStructure(Structure structure){
structures.add(structure);
}
/**
* Gets the structures that are a part of the town
* @return The list of structures
*/
public List<Structure> getStructures(){
return structures;
}
/**
* Adds a resident to the town
* @param resident The new resident
*/
public void addResident(Character resident){
residents.add(resident);
}
/**
* Gets the list of residents of the town
* @return The list of residents
*/
public List<Character> getResidents(){
return residents;
}
@ -126,5 +105,38 @@ public class Town extends CharacterData {
public String getDataType() {
return CharacterDataStrings.HOMETOWN;
}
@Override
public Vector3d getPos() {
return this.position;
}
@Override
public void setPos(Vector3d pos) {
this.position = pos;
}
@Override
public Vector3d getStartPos() {
return new Vector3d(this.position).sub(this.radius,this.radius,this.radius);
}
@Override
public Vector3d getEndPos() {
return new Vector3d(this.position).add(this.radius,this.radius,this.radius);
}
@Override
public AABBd getAABB() {
return new AABBd(this.getStartPos(), this.getEndPos());
}
/**
* Gets the ID of the town
* @return The ID
*/
public int getId(){
return this.id;
}
}

View File

@ -1,9 +0,0 @@
package electrosphere.server.macro.town;
/**
*
* @author satellite
*/
public class TownUtils {
}

View File

@ -3,56 +3,50 @@ package electrosphere.server.simulation;
import electrosphere.engine.Globals;
import electrosphere.server.macro.character.Character;
import electrosphere.server.macro.character.CharacterDataStrings;
import electrosphere.server.macro.character.CharacterUtils;
import electrosphere.server.macro.structure.Structure;
import electrosphere.server.macro.structure.StructureDataStrings;
import electrosphere.server.macro.structure.VirtualStructureUtils;
import electrosphere.server.macro.town.Town;
import java.util.LinkedList;
import java.util.List;
import org.joml.Vector2f;
import org.joml.Vector2i;
/**
* Performs the macro-level (ie virtual, non-physics based) simulation
*/
public class MacroSimulation {
// List<Civilization> civilizationList = new LinkedList();
// List<Culture> cultureList = new LinkedList();
// List<Religion> religionList = new LinkedList();
// List<CreatureType> creatureList = new LinkedList();
// List<Character> characterList = new LinkedList();
// List<Town> townList = new LinkedList();
// List<Structure> structureList = new LinkedList();
/**
* Tracks whether the macro simulation is ready or not
*/
boolean isReady = false;
public MacroSimulation(){
}
void init(){
// CreatureTypeMap creatureTypeMap = FileLoadingUtils.loadObjectFromAssetPath("Data/creatures.json", CreatureTypeMap.class);
// CivilizationMap civilizationMap = FileLoadingUtils.loadObjectFromAssetPath("Data/civilization.json", CivilizationMap.class);
}
/**
* Iterates the macro simulation
*/
public void simulate(){
for(Character character : Globals.macroData.getAliveCharacters()){
//do something
checkForShelter(character);
checkTownMembership(character);
MacroSimulation.checkForShelter(character);
MacroSimulation.checkTownMembership(character);
}
}
/**
* Sets whether the macro simulation is ready or not
* @param status true for ready, false otherwise
*/
public void setReady(boolean status){
isReady = status;
}
/**
* Gets whether the macro simulation is ready or not
* @return true for ready, false otherwise
*/
public boolean isReady(){
return isReady;
}
/**
* Maximum attempts to place a structure
*/
static final int MAX_PLACE_ATTEMPTS = 10;
static void checkForShelter(Character chara){
private static void checkForShelter(Character chara){
// for(Character chara : Globals.macroData.getAliveCharacters()){
/*
If doesnt have shelter, check if in town
@ -106,14 +100,14 @@ public class MacroSimulation {
// }
}
static void checkTownMembership(Character chara){
private static void checkTownMembership(Character chara){
//TODO: eventually exclude people who shouldn't belong to a town (traders, bandits, etc)
// for(Character chara : Globals.macroData.getAliveCharacters()){
boolean hasHometown = chara.containsKey(CharacterDataStrings.HOMETOWN);
boolean hasShelter = chara.containsKey(CharacterDataStrings.SHELTER);
//if has structure & no hometown
if(!hasHometown && hasShelter){
Structure shelter = CharacterUtils.getShelter(chara);
// Structure shelter = CharacterUtils.getShelter(chara);
//if there's at least one other structure nearby
// Vector2i shelterDiscretePos = new Vector2i(shelter.getWorldX(),shelter.getWorldY());
// List<Structure> nearbyPopulatedStructures = new LinkedList<Structure>();
@ -156,9 +150,9 @@ public class MacroSimulation {
// }
}
static void checkInitCombat(){
for(Character chara : Globals.macroData.getAliveCharacters()){
// Vector2i position = CharacterUtils.getDiscretePosition(chara);
}
}
// private static void checkInitCombat(){
// for(Character chara : Globals.macroData.getAliveCharacters()){
// // Vector2i position = CharacterUtils.getDiscretePosition(chara);
// }
// }
}

View File

@ -1,10 +0,0 @@
package electrosphere.util;
/**
* Utilities for random numbers
*/
public class RandomUtils {
}