package electrosphere.server.datacell.interfaces;

import org.joml.Vector3i;

import electrosphere.server.fluid.manager.ServerFluidChunk;
import electrosphere.server.terrain.manager.ServerTerrainChunk;

/**
 * Extension of a DataCellManager that provides voxel terrain access and editing functions
 */
public interface VoxelCellManager {

    /**
     * Gets the weight of a single voxel at a position
     * @param worldPosition The position in world coordinates of the chunk to grab data from
     * @param voxelPosition The position in voxel coordinates (local/relative to the chunk) to get voxel values from
     * @return The weight of the described voxel
     */
    public float getVoxelWeightAtLocalPosition(Vector3i worldPosition, Vector3i voxelPosition);

    /**
     * Gets the type of a single voxel at a position
     * @param worldPosition The position in world coordinates of the chunk to grab data from
     * @param voxelPosition The position in voxel coordinates (local/relative to the chunk) to get voxel values from
     * @return The type of the described voxel
     */
    public int getVoxelTypeAtLocalPosition(Vector3i worldPosition, Vector3i voxelPosition);

    /**
     * Gets the chunk data at a given world position
     * @param worldPosition The position in world coordinates
     * @return The ServerTerrainChunk of data at that position, or null if it is out of bounds or otherwise doesn't exist
     */
    public ServerTerrainChunk getChunkAtPosition(Vector3i worldPosition);

    /**
     * Edits a single voxel
     * @param worldPosition The world position of the chunk to edit
     * @param voxelPosition The voxel position of the voxel to edit
     * @param weight The weight to set the voxel to
     * @param type The type to set the voxel to
     */
    public void editChunk(Vector3i worldPosition, Vector3i voxelPosition, float weight, int type);


    /**
     * Gets the fluid chunk at a given world position
     * @param worldPosition The world position
     * @return the fluid chunk
     */
    public ServerFluidChunk getFluidChunkAtPosition(Vector3i worldPosition);
    
}
