Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
77 lines
2.5 KiB
Java
77 lines
2.5 KiB
Java
package electrosphere.entity;
|
|
|
|
import java.util.List;
|
|
|
|
import org.joml.Quaterniond;
|
|
import org.joml.Vector3d;
|
|
|
|
import electrosphere.engine.Globals;
|
|
import electrosphere.entity.state.attach.AttachUtils;
|
|
import electrosphere.entity.state.hitbox.HitboxCollectionState;
|
|
import electrosphere.entity.types.collision.CollisionObjUtils;
|
|
import electrosphere.renderer.actor.ActorUtils;
|
|
|
|
/**
|
|
* Client only entity utility functions
|
|
*/
|
|
public class ClientEntityUtils {
|
|
|
|
|
|
|
|
/**
|
|
* Called when the creature is first spawned to serialize to all people in its initial chunk
|
|
* @param entity
|
|
* @param position
|
|
*/
|
|
public static void initiallyPositionEntity(Entity entity, Vector3d position, Quaterniond rotation){
|
|
//reposition entity
|
|
CollisionObjUtils.clientPositionCharacter(entity, position, rotation);
|
|
}
|
|
|
|
/**
|
|
* Destroys an entity on the client
|
|
* @param entity the entity to destroy
|
|
*/
|
|
public static void destroyEntity(Entity entity){
|
|
|
|
if(entity != null){
|
|
//
|
|
//destroy the child entities, too
|
|
if(AttachUtils.hasChildren(entity)){
|
|
List<Entity> children = AttachUtils.getChildrenList(entity);
|
|
for(Entity child : children){
|
|
ClientEntityUtils.destroyEntity(child);
|
|
}
|
|
}
|
|
|
|
//delete unique model if present
|
|
if(entity.containsKey(EntityDataStrings.HAS_UNIQUE_MODEL)){
|
|
ActorUtils.queueActorForDeletion(entity);
|
|
}
|
|
|
|
//check for client-specific stuff
|
|
Globals.renderingEngine.getLightManager().destroyPointLight(entity);
|
|
|
|
//deregister all behavior trees
|
|
EntityUtils.cleanUpEntity(entity);
|
|
|
|
if(Globals.clientSceneWrapper != null){
|
|
Globals.clientSceneWrapper.getScene().deregisterEntity(entity);
|
|
Globals.clientSceneWrapper.deregisterTranslationMapping(entity);
|
|
if(Globals.clientSceneWrapper.getCollisionEngine() != null){
|
|
Globals.clientSceneWrapper.getCollisionEngine().destroyPhysics(entity);
|
|
}
|
|
}
|
|
if(Globals.clientScene != null){
|
|
Globals.clientScene.deregisterEntity(entity);
|
|
}
|
|
HitboxCollectionState.destroyHitboxState(entity,false);
|
|
if(entity == Globals.playerEntity && Globals.firstPersonEntity != null){
|
|
ClientEntityUtils.destroyEntity(Globals.firstPersonEntity);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|