forked from noxious/server
Continue working on spritesheet generator
This commit is contained in:
@ -39,7 +39,7 @@ class WeatherManager {
|
||||
return { ...this.weatherState }
|
||||
}
|
||||
|
||||
public randomWeatherValue(type: 'rain' | 'fog' ) {
|
||||
public randomWeatherValue(type: 'rain' | 'fog') {
|
||||
switch (type) {
|
||||
case 'rain':
|
||||
return this.getRandomNumber(WeatherManager.CONFIG.RAIN_PERCENTAGE_RANGE.min, WeatherManager.CONFIG.RAIN_PERCENTAGE_RANGE.max)
|
||||
@ -48,7 +48,7 @@ class WeatherManager {
|
||||
}
|
||||
}
|
||||
|
||||
public async setRainValue(value : number | null): Promise<void> {
|
||||
public async setRainValue(value: number | null): Promise<void> {
|
||||
if (value === null) {
|
||||
value = this.randomWeatherValue('rain')
|
||||
}
|
||||
@ -57,7 +57,7 @@ class WeatherManager {
|
||||
await this.saveAndEmitWeather()
|
||||
}
|
||||
|
||||
public async setFogValue(value : number | null): Promise<void> {
|
||||
public async setFogValue(value: number | null): Promise<void> {
|
||||
if (value === null) {
|
||||
value = this.randomWeatherValue('fog')
|
||||
}
|
||||
@ -90,7 +90,7 @@ class WeatherManager {
|
||||
|
||||
private updateRandomWeather(): void {
|
||||
if (Math.random() < WeatherManager.CONFIG.RAIN_CHANCE) {
|
||||
this.updateWeatherProperty('rain', this.randomWeatherValue('rain') )
|
||||
this.updateWeatherProperty('rain', this.randomWeatherValue('rain'))
|
||||
}
|
||||
if (Math.random() < WeatherManager.CONFIG.FOG_CHANCE) {
|
||||
this.updateWeatherProperty('fog', this.randomWeatherValue('fog'))
|
||||
@ -99,11 +99,11 @@ class WeatherManager {
|
||||
|
||||
private updateWeatherProperty(type: 'rain' | 'fog', value: number): void {
|
||||
if (type === 'rain') {
|
||||
this.weatherState.rainPercentage = value
|
||||
this.weatherState.rainPercentage = value
|
||||
}
|
||||
|
||||
if (type === 'fog') {
|
||||
this.weatherState.fogDensity = value
|
||||
this.weatherState.fogDensity = value
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,10 +124,7 @@ class WeatherManager {
|
||||
if (!world) world = new World()
|
||||
|
||||
//the data model still contains the booleans
|
||||
await world
|
||||
.setRainPercentage(this.weatherState.rainPercentage)
|
||||
.setFogDensity(this.weatherState.fogDensity)
|
||||
.save()
|
||||
await world.setRainPercentage(this.weatherState.rainPercentage).setFogDensity(this.weatherState.fogDensity).save()
|
||||
} catch (error) {
|
||||
this.logError('save', error)
|
||||
}
|
||||
|
Reference in New Issue
Block a user