summaryrefslogtreecommitdiff
path: root/src/REL/d/t/d_t_gate_to_ground.cpp
blob: 4f0b47e1f97735b5b86c78a3cde5ad07652ba8f4 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "d/t/d_t_gate_to_ground.h"

#include "common.h"
#include "d/a/d_a_player.h"
#include "d/d_camera.h"
#include "d/d_sc_game.h"
#include "d/flag/storyflag_manager.h"
#include "f/f_base.h"
#include "toBeSorted/actor_event.h"
#include "toBeSorted/area_math.h"
#include "toBeSorted/event.h"

SPECIAL_ACTOR_PROFILE(GATE2GND_TAG, dTgGateToGround_c, fProfile::GATE2GND_TAG, 0x22, 0, 0);

int dTgGateToGround_c::create() {
    matrixCreateFromPosRotYScale(matrix, mPosition, mRotation.y, mScale, nullptr, 0.0f);

    delayFrames = 0;

    union {
        u32 val;
        struct {
            u16 a;
            u8 b;
            u8 c;
        };
    } v;
    v.val = mParams;
    params_FF_FF_00_00 = v.a;
    params_00_00_FF_00 = v.b;
    params_00_00_00_FF = v.c;

    return SUCCEEDED;
}

int dTgGateToGround_c::doDelete() {
    return SUCCEEDED;
}

int dTgGateToGround_c::actorExecute() {
    dAcPy_c *player;

    if (params_FF_FF_00_00 != -1 && StoryflagManager::sInstance->getCounterOrFlag(params_FF_FF_00_00) == 0) {
        return SUCCEEDED;
    }

    player = dAcPy_c::LINK;

    if (checkAreaBox(matrix, player->mPosition)) {
        if (player->getRidingActorType() != dAcPy_c::RIDING_LOFTWING) {
            if (delayFrames > 15) {
                Event e("CloudHole", 100, 0, nullptr, nullptr);
                mEventRelated.scheduleEvent(e, 0);
            } else {
                delayFrames++;
            }
        } else {
            if (params_00_00_00_FF != -1) {
                // TODO Cast is maybe fake but I can't get overrideCam to match otherwise
                dScGame_c::getCamera(0)->getGameCam1()->overrideCam(params_00_00_00_FF, 0, (u16)mRoomID, false);
            }
            delayFrames = 0;
        }
    } else {
        delayFrames = 0;
    }

    return SUCCEEDED;
}

int dTgGateToGround_c::actorExecuteInEvent() {
    if (mEventRelated.isThisActorInEvent() != 0) {
        mEventRelated.advanceNext();
    }
    return SUCCEEDED;
}

int dTgGateToGround_c::draw() {
    return SUCCEEDED;
}