LOD emitter service
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-05-24 16:32:00 -04:00
parent 5be0a197c3
commit 6e0acf8b05
5 changed files with 76 additions and 0 deletions

View File

@ -1954,6 +1954,7 @@ Block chunks properly stride
Work on rotating structures
Towns spawn a population of characters when they are max-res'd
Hitbox synchronization work
LOD emitter service

View File

@ -176,6 +176,7 @@ public class ServerEntityUtils {
if(ServerCharacterData.hasServerCharacterDataTree(entity)){
Globals.serverState.characterService.removeEntity(ServerCharacterData.getServerCharacterData(entity).getCharacterData());
}
Globals.serverState.lodEmitterService.deregisterLODEmitter(entity);
//
//Stop inventory watching

View File

@ -11,6 +11,7 @@ import electrosphere.server.datacell.RealmManager;
import electrosphere.server.db.DatabaseController;
import electrosphere.server.saves.Save;
import electrosphere.server.service.CharacterService;
import electrosphere.server.service.LODEmitterService;
import electrosphere.server.service.StructureScanningService;
import electrosphere.server.simulation.MicroSimulation;
@ -59,6 +60,11 @@ public class ServerState {
*/
public final StructureScanningService structureScanningService;
/**
* The lod emitter service
*/
public final LODEmitterService lodEmitterService;
/**
* behavior tree tracking service
*/
@ -85,6 +91,7 @@ public class ServerState {
public ServerState(){
this.characterService = (CharacterService)Globals.engineState.serviceManager.registerService(new CharacterService());
this.structureScanningService = (StructureScanningService)Globals.engineState.serviceManager.registerService(new StructureScanningService());
this.lodEmitterService = (LODEmitterService)Globals.engineState.serviceManager.registerService(new LODEmitterService());
}
}

View File

@ -100,6 +100,7 @@ public class PlayerCharacterCreation {
static void addPlayerServerBTrees(Entity entity, ServerConnectionHandler serverConnectionHandler){
ServerPlayerViewDirTree.attachServerPlayerViewDirTree(entity);
ServerCharacterData.attachServerCharacterData(entity, Globals.serverState.characterService.getCharacter(serverConnectionHandler.getCharacterId()));
Globals.serverState.lodEmitterService.registerLODEmitter(entity);
}
/**

View File

@ -0,0 +1,66 @@
package electrosphere.server.service;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.engine.signal.SignalServiceImpl;
import electrosphere.entity.Entity;
/**
* Manages lod emitters
*/
public class LODEmitterService extends SignalServiceImpl {
/**
* The set of LOD emitters
*/
private List<Entity> emitters = new LinkedList<Entity>();
/**
* Lock for thread-safeing the service
*/
private ReentrantLock lock = new ReentrantLock();
/**
* Creates the LOD emitter service
*/
public LODEmitterService() {
super("LODEmitterService", new SignalType[]{
});
}
/**
* Gets the list of LOD emitters
* @return The list of LOD emitters
*/
public List<Entity> getEmitters(){
lock.lock();
List<Entity> rVal = Collections.unmodifiableList(this.emitters);
lock.unlock();
return rVal;
}
/**
* Registers a LOD emitter
* @param entity The entity
*/
public void registerLODEmitter(Entity entity){
lock.lock();
this.emitters.add(entity);
lock.unlock();
}
/**
* Deregisters a LOD emitter
* @param entity The entity
*/
public void deregisterLODEmitter(Entity entity){
lock.lock();
this.emitters.remove(entity);
lock.unlock();
}
}