summaryrefslogtreecommitdiff
path: root/src/manager/entitySpawnManager.c
blob: 6303d9984e783140e0742b7461b9887b72672244 (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
/**
 * @file entitySpawnManager.c
 * @ingroup Managers
 *
 * @brief Load a entity list when a flag is set.
 *
 * e.g. spawns the heart container and teleporter after getting the element in DWS
 */
#include "manager/entitySpawnManager.h"
#include "entity.h"
#include "flags.h"
#include "functions.h"
#include "room.h"
#include "sound.h"

void EntitySpawnManager_Main(EntitySpawnManager* this) {
    if (super->action == 0) {
        super->action = 1;
        if (CheckFlags(this->flag)) {
            DeleteManager(super);
            return;
        }
    }
    if (!CheckFlags(this->flag))
        return;
    if (super->type2 != 0) {
        super->type2 = 0;
        SetPlayerControl(0xff);
        PausePlayer();
    }
    if (this->spawnTimer == 0) {
        if (this->sound != 0) {
            SoundReq(this->sound);
        }
        LoadRoomEntityList(GetCurrentRoomProperty(super->type));
        DeleteThisEntity();
    } else {
        this->spawnTimer--;
    }
}