summaryrefslogtreecommitdiff
path: root/src/d/actor/d_a_swc00.cpp
blob: 8fd36a6158d2b32d1dc2ab89ed40136fd9179ec8 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//
// Generated by dtk
// Translation Unit: d_a_swc00.cpp
//

#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/actor/d_a_swc00.h"
#include "f_op/f_op_actor_mng.h"
#include "d/d_com_inf_game.h"

/* 00000078-00000180       .text daSwc00_Execute__FP11swc00_class */
static BOOL daSwc00_Execute(swc00_class* i_this) {
    fopAc_ac_c* actor = i_this;
    int enable_sw = daSwc00_getSw2No(i_this);
    if(enable_sw == 0xFF || dComIfGs_isSwitch(enable_sw, fopAcM_GetRoomNo(actor))) {
        int swBit = daSwc00_getSw1No(i_this);

        f32 xz_dist2 = fopAcM_searchPlayerDistanceXZ2(actor);
        f32 y_diff = fopAcM_searchPlayerDistanceY(actor);
        if(xz_dist2 < actor->scale.x && (-100.0f < y_diff && y_diff < actor->scale.y)) {
            dComIfGs_onSwitch(swBit, fopAcM_GetRoomNo(actor));

            if(daSwc00_getType(i_this) != 0) {
                fopAcM_delete(i_this);
            }
        }
        else if(daSwc00_getType(i_this) == 0) {
            dComIfGs_offSwitch(swBit, fopAcM_GetRoomNo(actor));
        }
    }

    return TRUE;
}

/* 00000180-00000188       .text daSwc00_IsDelete__FP11swc00_class */
static BOOL daSwc00_IsDelete(swc00_class* i_this) {
    return TRUE;
}

/* 00000188-00000190       .text daSwc00_Delete__FP11swc00_class */
static BOOL daSwc00_Delete(swc00_class* i_this) {
    return TRUE;
}

/* 00000190-00000274       .text daSwc00_Create__FP10fopAc_ac_c */
static cPhs_State daSwc00_Create(fopAc_ac_c* i_this) {
    fopAcM_ct_Retail(i_this, swc00_class);

    swc00_class* a_this = (swc00_class*)i_this;

    u8 swBit = daSwc00_getSw1No(a_this);
    if(dComIfGs_isSwitch(swBit, fopAcM_GetRoomNo(i_this))) {
        if(daSwc00_getType(a_this) == 0) {
            dComIfGs_offSwitch(daSwc00_getSw1No(a_this), fopAcM_GetRoomNo(i_this));
        }
        else {
            return cPhs_ERROR_e;
        }
    }

    fopAcM_ct_Demo(i_this, swc00_class);

    i_this->scale.x *= 100.0f;
    i_this->scale.x += 30.0f;
    i_this->scale.x = SQUARE(i_this->scale.x);
    i_this->scale.y *= 100.0f;

    return cPhs_COMPLEATE_e;
}

static actor_method_class l_daSwc00_Method = {
    (process_method_func)daSwc00_Create,
    (process_method_func)daSwc00_Delete,
    (process_method_func)daSwc00_Execute,
    (process_method_func)daSwc00_IsDelete,
    (process_method_func)NULL,
};

actor_process_profile_definition g_profile_SWC00 = {
    /* Layer ID     */ fpcLy_CURRENT_e,
    /* List ID      */ 0x0007,
    /* List Prio    */ fpcPi_CURRENT_e,
    /* Proc Name    */ fpcNm_SWC00_e,
    /* Proc SubMtd  */ &g_fpcLf_Method.base,
    /* Size         */ sizeof(swc00_class),
    /* Size Other   */ 0,
    /* Parameters   */ 0,
    /* Leaf SubMtd  */ &g_fopAc_Method.base,
    /* Draw Prio    */ fpcDwPi_SWC00_e,
    /* Actor SubMtd */ &l_daSwc00_Method,
    /* Status       */ fopAcStts_UNK40000_e,
    /* Group        */ fopAc_ACTOR_e,
    /* Cull Type    */ fopAc_CULLBOX_0_e,
};