package wtf.beatrice.retrorender.engine.world;

import com.badlogic.gdx.graphics.g3d.ModelInstance;

public class TownFactory {

    private final ModelLibrary models;

    public TownFactory(ModelLibrary models) {
        this.models = models;
    }

    public WorldObject createHouse(String id, float x, float z) {
        ModelInstance inst = new ModelInstance(models.houseBlockModel);
        // houseBlockModel is 4x3x4 → center at y=1.5
        inst.transform.setToTranslation(x, 1.5f, z);

        Collider col = Collider.box(2f, 1.5f, 2f);

        WorldObject obj = new WorldObject(id, inst, col);
        obj.staticObject     = true;
        obj.castsShadow      = true;
        obj.walkableSurface  = false; // you don't walk on roofs
        obj.collidable       = true;  // blocks movement
        return obj;
    }

    public WorldObject createCrate(String id, float x, float z) {
        ModelInstance inst = new ModelInstance(models.unitCubeModel);
        // unit cube is 1x1x1 → center at y=0.5
        inst.transform.setToTranslation(x, 0.5f, z);

        Collider col = Collider.box(0.5f, 0.5f, 0.5f);

        WorldObject obj = new WorldObject(id, inst, col);
        obj.staticObject     = true;
        obj.castsShadow      = true;
        obj.walkableSurface  = true;  // you can stand on it
        obj.collidable       = true;  // also blocks sides
        return obj;
    }

    public WorldObject createPathTile(String id, float x, float z) {
        ModelInstance inst = new ModelInstance(models.pathTileModel);
        inst.transform.setToTranslation(x, 0f, z);

        WorldObject obj = new WorldObject(id, inst, Collider.none());
        obj.staticObject     = true;
        obj.walkableSurface  = false; // ground plane already gives height 0
        obj.collidable       = false;
        return obj;
    }
}
