summaryrefslogtreecommitdiff
path: root/src/d/tg/d_t_event_f.cpp
blob: 3300eda083f11df6826394a327a01958d302d88d (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
#include "d/t/d_t_event_f.h"

#include "d/a/d_a_player.h"
#include "d/flag/storyflag_manager.h"
#include "f/f_base.h"
#include "toBeSorted/area_math.h"

SPECIAL_ACTOR_PROFILE(EVENTF_TAG, dTgEventF_c, fProfile::EVENTF_TAG, 0x14, 0, 0);

int dTgEventF_c::create() {
    matrixCreateFromPosRotYScale(mMatrix, mPosition, mRotation.y, mScale, 0x0, 0.0f);
    mEventId = getFromParams(0, 0xFF);
    mSetStoryflag = getFromParams(8, 0x7FF);
    if ((s32)mSetStoryflag == 0x3FF) {
        mSetStoryflag = 0xFFFFFFFF;
    }
    mTrigStoryflag = getFromParams(19, 0x7FF);
    if ((s32)mTrigStoryflag == 0x3FF) {
        mTrigStoryflag = 0xFFFFFFFF;
    }
    mSubtype = getFromParams(30, 0x3);
    return SUCCEEDED;
}

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

int dTgEventF_c::checkStoryflagValid(u32 counterIdx) {
    return StoryflagManager::sInstance->checkFlagValid(counterIdx);
}

bool dTgEventF_c::checkUncommitedStoryFlagValue(u32 flag) {
    return StoryflagManager::sInstance->getUncommittedValue(flag);
}

void dTgEventF_c::setStoryFlag(StoryFlags_e flag) {
    StoryflagManager::sInstance->setFlag(flag);
}

void dTgEventF_c::unsetStoryFlag(StoryFlags_e flag) {
    StoryflagManager::sInstance->unsetFlag(flag);
}

int dTgEventF_c::actorExecute() {
    if ((!checkStoryflagValid(mTrigStoryflag) || checkUncommitedStoryFlagValue(mTrigStoryflag))) {
        if ((mSubtype != 0 && !(checkStoryflagValid(mSetStoryflag) && checkUncommitedStoryFlagValue(mSetStoryflag))) ||
            (mSubtype == 0 && checkStoryflagValid(mSetStoryflag) && checkUncommitedStoryFlagValue(mSetStoryflag))) {
            if (checkAreaBox(mMatrix, dAcPy_c::LINK->mPosition)) {
                Event EStack_48 = Event(mEventId, (int)mRoomID, 0x100001, 0, 0);
                mActorEvent.scheduleEvent(EStack_48, 0);
            }
        }
    }
    return SUCCEEDED;
}
int dTgEventF_c::actorExecuteInEvent() {
    if (mActorEvent.isThisActorInEvent()) {
        mActorEvent.advanceNext();
        if (!(mSubtype == 0 || !checkStoryflagValid(mSetStoryflag) || checkUncommitedStoryFlagValue(mSetStoryflag))) {
            setStoryFlag((StoryFlags_e)mSetStoryflag);
        } else if ((mSubtype == 0 && checkStoryflagValid(mSetStoryflag)) &&
                   checkUncommitedStoryFlagValue(mSetStoryflag)) {
            unsetStoryFlag((StoryFlags_e)mSetStoryflag);
        }
    }
    return SUCCEEDED;
}

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