package electrosphere.collision;

import electrosphere.client.scene.ClientWorldData;
import electrosphere.client.terrain.manager.ClientTerrainManager;
import electrosphere.game.server.world.ServerWorldData;
import electrosphere.server.terrain.manager.ServerTerrainManager;

import org.joml.Vector3f;

public class CollisionWorldData {
    
    
    
    ClientWorldData clientWorldData;
    ClientTerrainManager clientTerrainManager;
    
    
    
    ServerWorldData serverWorldData;
    ServerTerrainManager serverTerrainManager;
    
    public CollisionWorldData(ServerWorldData serverWorldData){
        this.serverWorldData = serverWorldData;
    }

    public CollisionWorldData(ClientWorldData clientWorldData){
        this.clientWorldData = clientWorldData;
    }
    
    
    public Vector3f getWorldBoundMin(){
        if(clientWorldData != null){
            return clientWorldData.getWorldBoundMin();
        } else {
            return serverWorldData.getWorldBoundMin();
        }
    }
    
    public Vector3f getWorldBoundMax(){
        if(clientWorldData != null){
            return clientWorldData.getWorldBoundMax();
        } else {
            return serverWorldData.getWorldBoundMax();
        }
    }
    
    public int convertRealToWorld(double real){
        if(clientWorldData != null){
            return clientWorldData.convertRealToChunkSpace(real);
        } else {
            return serverWorldData.convertRealToChunkSpace(real);
        }
    }

    public double convertWorldToReal(int world){
        if(clientWorldData != null){
            return clientWorldData.convertChunkToRealSpace(world);
        } else {
            return serverWorldData.convertChunkToRealSpace(world);
        }
    }

    public int getDynamicInterpolationRatio(){
        if(clientWorldData != null){
            return clientWorldData.getWorldDiscreteSize();
        } else {
            return serverWorldData.getDynamicInterpolationRatio();
        }
    }

    public int getWorldDiscreteSize(){
        if(clientWorldData != null){
            return clientWorldData.getWorldDiscreteSize();
        } else {
            return serverWorldData.getWorldSizeDiscrete();
        }
    }

}
