1
0
forked from noxious/client

#258 - Made it so zoneEffects only overrides defined effects instead of all

This commit is contained in:
Colin Kallemein 2024-12-23 23:23:16 +01:00
parent 5d9b4fd19a
commit 420e63b724

View File

@ -76,20 +76,21 @@ const initializeEffects = (scene: Phaser.Scene) => {
// Effect updates
const updateScene = () => {
const timeBasedLight = calculateLightStrength(gameStore.world.date)
const defaultEffects = {
light: timeBasedLight,
rain: weatherState.value.isRainEnabled ? weatherState.value.rainPercentage : 0,
fog: weatherState.value.isFogEnabled ? weatherState.value.fogDensity * 100 : 0
}
const zoneEffects = zoneStore.zone?.zoneEffects?.reduce((acc, curr) => ({
...acc,
[curr.effect]: curr.strength
}), {}) as { [key: string]: number }
if (zoneEffects && Object.keys(zoneEffects).length) {
applyEffects(zoneEffects)
} else {
applyEffects({
light: timeBasedLight,
rain: weatherState.value.isRainEnabled ? weatherState.value.rainPercentage : 0,
fog: weatherState.value.isFogEnabled ? weatherState.value.fogDensity * 100 : 0
})
}
applyEffects({
...defaultEffects,
...(zoneEffects || {})
})
}
const applyEffects = (effectValues: any) => {