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