summaryrefslogtreecommitdiff
path: root/src/createObject.c
blob: cf3655c9109c2a8ee977e920f14b7485c371ca03 (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
#include "global.h"
#include "entity.h"
#include "coord.h"
#include "room.h"
#include "createObject.h"
#include "object.h"

Entity* CreateObject(u32 subtype, u32 form, u32 parameter) {
    Entity* entity;

    entity = GetEmptyEntity();
    if (entity != NULL) {
        entity->kind = 6;
        entity->id = subtype;
        entity->type = form;
        entity->type2 = parameter;
        AppendEntityToList(entity, 6);
    }
    return entity;
}

Entity* CreateObjectWithParent(Entity* parentEnt, u32 subtype, u32 form, u32 parameter) {
    Entity* ent;

    ent = CreateObject(subtype, form, parameter);
    if (ent != NULL) {
        ent->parent = parentEnt;
        CopyPosition(parentEnt, ent);
    }

    return ent;
}

Entity* CreateFx(Entity* parentEnt, u32 form, u32 parameter) {
    return CreateObjectWithParent(parentEnt, SPECIAL_FX, form, parameter);
}

void CreateDust(Entity* parent) {
    CreateFx(parent, 2, 0);
}

void CreateDustAt(s32 xOff, s32 yOff, u32 layer) {
    Entity* ent;

    ent = CreateObject(SPECIAL_FX, 2, 0);
    if (ent != NULL) {
        ent->x.HALF.HI = gRoomControls.roomOriginX + xOff;
        ent->y.HALF.HI = gRoomControls.roomOriginY + yOff;
        ent->collisionLayer = layer;
    }
}

void CreateDustSmall(Entity* parent) {
    CreateFx(parent, 0x11, 0);
}

void CreateExplosionBroken(Entity* parent) {
    CreateFx(parent, 0x6, 0);
}

void CreateWaterSplash(Entity* parent) {
    CreateFx(parent, 0xb, 0);
}

Entity* sub_080A2A20(Entity* parent, u32 form, u32 parameter) {
    Entity* ent;

    ent = CreateObjectWithParent(parent, GROUND_ITEM, form, parameter);
    if (ent != NULL) {
        ent->actionDelay = 5;
    }
    return ent;
}

Entity* sub_080A2A3C(Entity* parent, u32 form, u32 subtype, u32 param_4) {
    Entity* ent;

    ent = CreateObjectWithParent(parent, GROUND_ITEM, form, subtype);
    if (ent != NULL) {
        ent->actionDelay = 5;
        ent->field_0x86.HWORD = param_4;
    }
    return ent;
}

Entity* CreateWaterTrace(Entity* parent) {
    Entity* ent;

    ent = CreateFx(parent, 0x20, 0);
    if (ent != NULL) {
        ent->spritePriority.b0 = 7;
    }
    return ent;
}