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 Flower foliage item
Texture loading from model files (ie can load texture path from model file) Texture loading from model files (ie can load texture path from model file)
Clean up material class a bit 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.db.DatabaseController;
import electrosphere.server.entity.poseactor.PoseModel; import electrosphere.server.entity.poseactor.PoseModel;
import electrosphere.server.macro.MacroData; import electrosphere.server.macro.MacroData;
import electrosphere.server.macro.structure.StructureManager;
import electrosphere.server.saves.Save; import electrosphere.server.saves.Save;
import electrosphere.server.simulation.MacroSimulation; import electrosphere.server.simulation.MacroSimulation;
import electrosphere.server.simulation.MicroSimulation; import electrosphere.server.simulation.MicroSimulation;
@ -395,9 +394,6 @@ public class Globals {
//collision world data //collision world data
public static CollisionWorldData commonWorldData; public static CollisionWorldData commonWorldData;
//structure manager
public static StructureManager structureManager;
//client level editor data management //client level editor data management
public static ClientLevelEditorData clientLevelEditorData = new ClientLevelEditorData(); public static ClientLevelEditorData clientLevelEditorData = new ClientLevelEditorData();

View File

@ -1,9 +1,5 @@
package electrosphere.server.macro.structure; package electrosphere.server.macro.structure;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import org.joml.AABBd; import org.joml.AABBd;
import org.joml.Vector3d; import org.joml.Vector3d;
@ -45,16 +41,6 @@ public class Structure extends CharacterData implements MacroAreaObject {
*/ */
String type; 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 * Constructor
* @param dataType The data type of the structure * @param dataType The data type of the structure
@ -78,33 +64,6 @@ public class Structure extends CharacterData implements MacroAreaObject {
return rVal; 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 * Gets the type of the structure
* @return The type * @return The type

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; 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 * Utility functions for dealing with structures on the server
*/ */
@ -52,19 +44,4 @@ public class VirtualStructureUtils {
return true; 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; package electrosphere.server.macro.town;
import electrosphere.engine.Globals;
import electrosphere.server.macro.character.Character; import electrosphere.server.macro.character.Character;
import electrosphere.server.macro.character.CharacterData; import electrosphere.server.macro.character.CharacterData;
import electrosphere.server.macro.character.CharacterDataStrings; import electrosphere.server.macro.character.CharacterDataStrings;
import electrosphere.server.macro.spatial.MacroAreaObject;
import electrosphere.server.macro.structure.Structure; import electrosphere.server.macro.structure.Structure;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.joml.Vector2i;
import org.joml.AABBd;
import org.joml.Vector3d;
/** /**
* Server representation of a town * 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; static int idIncrementer = 0;
List<Vector2i> positions = new LinkedList<Vector2i> (); /**
* The position of the town
*/
private Vector3d position;
List<Structure> structures = new LinkedList<Structure>(); /**
List<Character> residents = new LinkedList<Character>(); * The radius of the town
*/
private double radius;
final static int avgDiffThreshold = 10; /**
* The structures inside the town
*/
private List<Structure> structures = new LinkedList<Structure>();
public static Vector2i findValidTownLocation(){ /**
// for(int x = 0; x < Globals.serverTerrainManager.getWorldDiscreteSize(); x++){ * The residents of the town
// for(int y = 0; y < Globals.serverTerrainManager.getWorldDiscreteSize(); y++){ */
// // ServerTerrainChunk chunk = Globals.serverTerrainManager.getChunk(x, y); private List<Character> residents = new LinkedList<Character>();
// // 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;
}
/**
* Constructor
*/
private Town(){ private Town(){
super(CharacterDataStrings.HOMETOWN); super(CharacterDataStrings.TOWN);
this.id = idIncrementer; this.id = idIncrementer;
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(); Town rVal = new Town();
rVal.positions.add(new Vector2i(x,y)); rVal.position = position;
Globals.macroData.addTown(rVal); rVal.radius = radius;
// 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");
// }
return rVal; return rVal;
} }
public static Town getTownAtPosition(int x, int y){ /**
Town rVal = null; * Adds a structure to the town
// DatabaseResult locationLookupResult = Globals.dbController.executeQuery("SELECT townID FROM townWorldPositions WHERE posX = " + x + " AND posY = " + y + ";"); * @param structure The structure
// 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;
}
public void addStructure(Structure structure){ public void addStructure(Structure structure){
structures.add(structure); structures.add(structure);
} }
/**
* Gets the structures that are a part of the town
* @return The list of structures
*/
public List<Structure> getStructures(){ public List<Structure> getStructures(){
return structures; return structures;
} }
/**
* Adds a resident to the town
* @param resident The new resident
*/
public void addResident(Character resident){ public void addResident(Character resident){
residents.add(resident); residents.add(resident);
} }
/**
* Gets the list of residents of the town
* @return The list of residents
*/
public List<Character> getResidents(){ public List<Character> getResidents(){
return residents; return residents;
} }
@ -127,4 +106,37 @@ public class Town extends CharacterData {
return CharacterDataStrings.HOMETOWN; 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.engine.Globals;
import electrosphere.server.macro.character.Character; import electrosphere.server.macro.character.Character;
import electrosphere.server.macro.character.CharacterDataStrings; 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 { public class MacroSimulation {
// List<Civilization> civilizationList = new LinkedList(); /**
// List<Culture> cultureList = new LinkedList(); * Tracks whether the macro simulation is ready or not
// 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();
boolean isReady = false; boolean isReady = false;
public MacroSimulation(){ /**
} * Iterates the macro simulation
*/
void init(){
// CreatureTypeMap creatureTypeMap = FileLoadingUtils.loadObjectFromAssetPath("Data/creatures.json", CreatureTypeMap.class);
// CivilizationMap civilizationMap = FileLoadingUtils.loadObjectFromAssetPath("Data/civilization.json", CivilizationMap.class);
}
public void simulate(){ public void simulate(){
for(Character character : Globals.macroData.getAliveCharacters()){ for(Character character : Globals.macroData.getAliveCharacters()){
//do something //do something
checkForShelter(character); MacroSimulation.checkForShelter(character);
checkTownMembership(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){ public void setReady(boolean status){
isReady = status; isReady = status;
} }
/**
* Gets whether the macro simulation is ready or not
* @return true for ready, false otherwise
*/
public boolean isReady(){ public boolean isReady(){
return isReady; return isReady;
} }
/**
* Maximum attempts to place a structure
*/
static final int MAX_PLACE_ATTEMPTS = 10; static final int MAX_PLACE_ATTEMPTS = 10;
static void checkForShelter(Character chara){ private static void checkForShelter(Character chara){
// for(Character chara : Globals.macroData.getAliveCharacters()){ // for(Character chara : Globals.macroData.getAliveCharacters()){
/* /*
If doesnt have shelter, check if in town 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) //TODO: eventually exclude people who shouldn't belong to a town (traders, bandits, etc)
// for(Character chara : Globals.macroData.getAliveCharacters()){ // for(Character chara : Globals.macroData.getAliveCharacters()){
boolean hasHometown = chara.containsKey(CharacterDataStrings.HOMETOWN); boolean hasHometown = chara.containsKey(CharacterDataStrings.HOMETOWN);
boolean hasShelter = chara.containsKey(CharacterDataStrings.SHELTER); boolean hasShelter = chara.containsKey(CharacterDataStrings.SHELTER);
//if has structure & no hometown //if has structure & no hometown
if(!hasHometown && hasShelter){ if(!hasHometown && hasShelter){
Structure shelter = CharacterUtils.getShelter(chara); // Structure shelter = CharacterUtils.getShelter(chara);
//if there's at least one other structure nearby //if there's at least one other structure nearby
// Vector2i shelterDiscretePos = new Vector2i(shelter.getWorldX(),shelter.getWorldY()); // Vector2i shelterDiscretePos = new Vector2i(shelter.getWorldX(),shelter.getWorldY());
// List<Structure> nearbyPopulatedStructures = new LinkedList<Structure>(); // List<Structure> nearbyPopulatedStructures = new LinkedList<Structure>();
@ -156,9 +150,9 @@ public class MacroSimulation {
// } // }
} }
static void checkInitCombat(){ // private static void checkInitCombat(){
for(Character chara : Globals.macroData.getAliveCharacters()){ // for(Character chara : Globals.macroData.getAliveCharacters()){
// Vector2i position = CharacterUtils.getDiscretePosition(chara); // // Vector2i position = CharacterUtils.getDiscretePosition(chara);
} // }
} // }
} }

View File

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