summaryrefslogtreecommitdiff
path: root/mm/2s2h/Rando/ActorBehavior/EnSi.cpp
blob: 3d99a366e64850f05404b7a014d09d01d97a1b0f (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "ActorBehavior.h"
#include <libultraship/bridge/consolevariablebridge.h>

extern "C" {
#include "functions.h"
#include "variables.h"

#include "overlays/actors/ovl_En_Si/z_en_si.h"
}

void EnSi_DrawCustom(Actor* thisx, PlayState* play) {
    EnSi* enSi = (EnSi*)thisx;

    auto randoStaticCheck = Rando::StaticData::GetCheckFromFlag(FLAG_CYCL_SCENE_CHEST,
                                                                ENSI_GET_CHEST_FLAG(&enSi->actor), gPlayState->sceneId);
    if (randoStaticCheck.randoCheckId == RC_UNKNOWN) {
        return;
    }

    auto randoSaveCheck = RANDO_SAVE_CHECKS[randoStaticCheck.randoCheckId];

    Rando::DrawItem(Rando::ConvertItem(randoSaveCheck.randoItemId, randoStaticCheck.randoCheckId),
                    randoStaticCheck.randoCheckId, thisx);
}

void Rando::ActorBehavior::InitEnSiBehavior() {
    COND_ID_HOOK(OnActorInit, ACTOR_EN_SI, IS_RANDO, [](Actor* actor) {
        EnSi* enSi = (EnSi*)actor;

        auto randoStaticCheck = Rando::StaticData::GetCheckFromFlag(
            FLAG_CYCL_SCENE_CHEST, ENSI_GET_CHEST_FLAG(&enSi->actor), gPlayState->sceneId);
        if (randoStaticCheck.randoCheckId == RC_UNKNOWN) {
            return;
        }

        auto randoSaveCheck = RANDO_SAVE_CHECKS[randoStaticCheck.randoCheckId];

        if (!randoSaveCheck.shuffled) {
            return;
        }

        actor->draw = EnSi_DrawCustom;
    });

    COND_VB_SHOULD(VB_GIVE_ITEM_FROM_SI, IS_RANDO, {
        EnSi* enSi = va_arg(args, EnSi*);

        auto randoStaticCheck = Rando::StaticData::GetCheckFromFlag(
            FLAG_CYCL_SCENE_CHEST, ENSI_GET_CHEST_FLAG(&enSi->actor), gPlayState->sceneId);
        if (randoStaticCheck.randoCheckId == RC_UNKNOWN) {
            return;
        }

        auto randoSaveCheck = RANDO_SAVE_CHECKS[randoStaticCheck.randoCheckId];

        if (!randoSaveCheck.shuffled) {
            return;
        }

        *should = false;
    });
}