summaryrefslogtreecommitdiff
path: root/src/object/gustJarParticle.c
blob: 0da0d398e09de2f12ce6bfee85658461af4315f9 (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
/**
 * @file gustJarParticle.c
 * @ingroup Objects
 *
 * @brief Gust Jar Particle object
 */
#include "asm.h"
#include "entity.h"
#include "physics.h"
#include "player.h"
#include "room.h"

void GustJarParticle_Init(Entity*);
void GustJarParticle_Action1(Entity*);

void GustJarParticle(Entity* this) {
    static void (*const GustJarParticle_Actions[])(Entity*) = {
        GustJarParticle_Init,
        GustJarParticle_Action1,
    };

    GustJarParticle_Actions[this->action](this);
}

void GustJarParticle_Init(Entity* this) {
    this->action = 1;
    this->speed = 0x80;
    this->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3;
    this->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0;
    this->collisionLayer = gPlayerEntity.base.collisionLayer;
    this->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY;
    this->type = Random() & 1;
    InitializeAnimation(this, 0x11);
}

void GustJarParticle_Action1(Entity* this) {
    if (this->type != 0) {
        if ((gRoomTransition.frameCount & 1) == 0) {
            GetNextFrame(this);
        }
    } else {
        GetNextFrame(this);
    }

    if (sub_0806F3E4(this)) {
        DeleteThisEntity();
    } else if ((gPlayerState.gustJarState & 0xf) != 1) {
        DeleteThisEntity();
    }
}