summaryrefslogtreecommitdiff
path: root/mm/2s2h/Enhancements/Graphics/RainEverywhere.cpp
blob: d88f0f7ba2ac4114ca6c8e858d2c6aac535815f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <libultraship/bridge/consolevariablebridge.h>
#include "2s2h/GameInteractor/GameInteractor.h"
#include "2s2h/BenGui/CosmeticEditor.h"
#include "2s2h/ShipInit.hpp"

extern "C" {
#include "functions.h"
extern PlayState* gPlayState;
}

#define CVAR_NAME CVAR_COSMETIC("Silly.RainEverywhere")
#define CVAR CVarGetInteger(CVAR_NAME, 0)

void RegisterRainEverywhere() {
    COND_HOOK(OnPlayDrawWorldStart, CVAR, []() {
        gPlayState->envCtx.precipitation[PRECIP_SOS_MAX] = 60;
        gPlayState->envCtx.precipitation[PRECIP_SNOW_MAX] = 0;
        gPlayState->envCtx.precipitation[PRECIP_SNOW_CUR] = 0;
    });

    COND_HOOK(OnSceneInit, CVAR, [](s8 sceneId, s8 spawnNum) { Environment_PlayStormNatureAmbience(gPlayState); });

    if (gPlayState == NULL) {
        return;
    }

    if (CVAR) {
        Environment_PlayStormNatureAmbience(gPlayState);
    } else {
        gPlayState->envCtx.precipitation[PRECIP_SOS_MAX] = 0;
        Environment_StopStormNatureAmbience(gPlayState);
    }
}

static RegisterShipInitFunc initFunc(RegisterRainEverywhere, { CVAR_NAME });