summaryrefslogtreecommitdiff
path: root/src/manager/moveableObjectManager.c
blob: 5cf898fad0e06025c46818e8fc6b8c729830a3d8 (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
/**
 * @file moveableObjectManager.c
 * @ingroup Managers
 *
 * @brief Create object at different place depending on if the flag is set.
 *
 * E.g. for pushable rock.
 */
#include "manager/moveableObjectManager.h"
#include "flags.h"
#include "room.h"
#include "object.h"

void MoveableObjectManager_Main(MoveableObjectManager* this) {
    Entity* object = CreateObject(super->timer, super->type, super->type2);
    if (!object)
        return;
    ((GenericEntity*)object)->field_0x86.HWORD = this->flags;
    if (CheckFlags(this->flags)) {
        object->x.HALF.HI = this->unk_36 | (this->unk_37 & 0xF) << 8; // r1
        object->y.HALF.HI = this->unk_3c & 0xFFF;
        object->collisionLayer = this->unk_3c >> 0xC;
    } else {
        object->x.HALF.HI = this->unk_38;
        object->y.HALF.HI = this->unk_3a;
        object->collisionLayer = this->unk_37 >> 4;
    }
    object->x.HALF.HI += gRoomControls.origin_x;
    object->y.HALF.HI += gRoomControls.origin_y;
    DeleteManager(super);
}