import { Player, PlayerSpawnAfterEvent, system, world, WorldAfterEvents, WorldInitializeAfterEvent } from "@minecraft/server";
import BiomeObserver from "./BiomeObserver";


/**
 * Very simplistic fog controller
 */
class BiomeFogSystem {
    constructor() {
        BiomeObserver.subscribeToBiomeChange(this.#setFog.bind(this));
    }

    /**
     * 
     * @param {Player} player 
     * @param {string} biome 
     */
    #setFog(player, biome) {
        if (biome == 'vanilla') {
            player.runCommandAsync('fog @s remove ecbl_bc:biome_fog_controller');
            return;
        }

        player.runCommandAsync(`fog @s push ecbl_bc:fog_${biome} ecbl_bc:biome_fog_controller`);
    }
}


export default new BiomeFogSystem();