59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
/**
|
|
* BaseScene.js
|
|
*
|
|
* Base class for all game scenes
|
|
* Automatically integrates MasterWeatherSystem
|
|
*
|
|
* All scenes should extend this instead of Phaser.Scene
|
|
*/
|
|
|
|
export default class BaseScene extends Phaser.Scene {
|
|
constructor(config) {
|
|
super(config);
|
|
|
|
this.weather = null;
|
|
}
|
|
|
|
/**
|
|
* Initialize weather system (call in create())
|
|
*
|
|
* @param {string} biomeName - Optional biome name for auto-config
|
|
*/
|
|
initWeather(biomeName = null) {
|
|
// Get weather from global manager
|
|
if (this.game.weatherManager) {
|
|
this.weather = this.game.weatherManager.createForScene(this);
|
|
|
|
// Set biome if provided
|
|
if (biomeName) {
|
|
this.weather.setBiomeWeather(biomeName);
|
|
this.game.weatherManager.setBiome(biomeName);
|
|
}
|
|
|
|
console.log(`🌦️ Weather initialized for ${this.scene.key}`);
|
|
} else {
|
|
console.warn('⚠️ GlobalWeatherManager not found! Weather disabled.');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Update weather (call in update())
|
|
*/
|
|
updateWeather(delta) {
|
|
if (this.weather) {
|
|
this.weather.update(delta);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Shutdown (automatic cleanup)
|
|
*/
|
|
shutdown() {
|
|
if (this.game.weatherManager) {
|
|
this.game.weatherManager.destroyForScene(this.scene.key);
|
|
}
|
|
|
|
this.weather = null;
|
|
}
|
|
}
|