summaryrefslogtreecommitdiff
path: root/src/npc/gentari.c
blob: 91bd3d4393583aaf927152b1483dbea2448f727e (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
/**
 * @file gentari.c
 * @ingroup NPCs
 *
 * @brief Gentari NPC
 */
#include "entity.h"
#include "npc.h"
#include "script.h"
#include "player.h"
#include "physics.h"

typedef struct {
    /*0x00*/ Entity base;
    /*0x68*/ u8 fusionOffer;
} GentariEntity;

void Gentari(GentariEntity* this) {
    switch (super->action) {
        case 0:
            super->action = 1;
            super->spriteSettings.draw = TRUE;
            SetEntityPriority(super, PRIO_MESSAGE);
            this->fusionOffer = GetFusionToOffer(super);
            AddInteractableWhenBigFuser(super, this->fusionOffer);
            InitScriptForNPC(super);
            break;
        case 1:
            if (super->interactType == INTERACTION_FUSE) {
                super->action = 2;
                super->interactType = INTERACTION_NONE;
                InitAnimationForceUpdate(
                    super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)));
                InitializeNPCFusion(super);
            } else {
                ExecuteScriptAndHandleAnimation(super, NULL);
            }
            break;
        case 2:
            if (UpdateFuseInteraction(super)) {
                super->action = 1;
            }
    }
}

void Gentari_Fusion(Entity* this) {
    if (this->action == 0) {
        this->action++;
        this->spriteSettings.draw = TRUE;
        SetEntityPriority(this, PRIO_MESSAGE);
        InitAnimationForceUpdate(this, 10);
    } else {
        UpdateAnimationSingleFrame(this);
    }
}