Skip to content

Commit

Permalink
Implement EnemyManager::EnemyManager
Browse files Browse the repository at this point in the history
  • Loading branch information
roblabla committed Nov 19, 2024
1 parent ed41801 commit 93b0857
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions config/implemented.csv
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ th06::EffectManager::EffectUpdateCallback4
th06::EffectManager::EffectCallbackAttract
th06::EffectManager::EffectCallbackAttractSlow
th06::EnemyManager::Initialize
th06::EnemyManager::EnemyManager
th06::EnemyManager::RegisterChain
th06::EnemyManager::CutChain
th06::EnemyManager::AddedCallback
Expand Down
2 changes: 1 addition & 1 deletion src/EclManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ ZunResult EclManager::RunEcl(Enemy *enemy)
break;
case ECL_OPCODE_ENEMYKILLALL:
for (local_b4 = &g_EnemyManager.enemies[0], local_b8 = 0;
local_b8 < ARRAY_SIZE_SIGNED(g_EnemyManager.enemies); local_b8++, local_b4++)
local_b8 < ARRAY_SIZE_SIGNED(g_EnemyManager.enemies) - 1; local_b8++, local_b4++)
{
if (!local_b4->flags.unk5)
{
Expand Down
15 changes: 10 additions & 5 deletions src/EnemyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,19 @@ void EnemyManager::Initialize()
enemy->bulletRankSpeedHigh = 0.5f;
}

EnemyManager::EnemyManager()
{
this->Initialize();
}

Enemy *EnemyManager::SpawnEnemy(i32 eclSubId, D3DXVECTOR3 *pos, i16 life, i16 itemDrop, i32 score)
{
Enemy *newEnemy;
i32 idx;

newEnemy = this->enemies;
idx = 0;
for (; idx < ARRAY_SIZE_SIGNED(this->enemies); idx++, newEnemy++)
for (; idx < ARRAY_SIZE_SIGNED(this->enemies) - 1; idx++, newEnemy++)
{
if (newEnemy->flags.unk5)
continue;
Expand Down Expand Up @@ -352,7 +357,7 @@ ZunBool Enemy::HandleLifeCallback()
this->stackDepth = 0;

curEnemy = g_EnemyManager.enemies;
for (i = 0; i < ARRAY_SIZE_SIGNED(g_EnemyManager.enemies); i++, curEnemy++)
for (i = 0; i < ARRAY_SIZE_SIGNED(g_EnemyManager.enemies) - 1; i++, curEnemy++)
{
if (!curEnemy->flags.unk5)
{
Expand Down Expand Up @@ -410,7 +415,7 @@ ZunBool Enemy::HandleTimerCallback()
}

curEnemy = g_EnemyManager.enemies;
for (i = 0; i < ARRAY_SIZE_SIGNED(g_EnemyManager.enemies); i++, curEnemy++)
for (i = 0; i < ARRAY_SIZE_SIGNED(g_EnemyManager.enemies) - 1; i++, curEnemy++)
{
if (!curEnemy->flags.unk5)
{
Expand Down Expand Up @@ -524,7 +529,7 @@ ChainCallbackResult EnemyManager::OnUpdate(EnemyManager *mgr)

local_8 = 0;
mgr->RunEclTimeline();
for (curEnemy = &mgr->enemies[0], mgr->enemyCount = 0, enemyIdx = 0; enemyIdx < ARRAY_SIZE_SIGNED(mgr->enemies);
for (curEnemy = &mgr->enemies[0], mgr->enemyCount = 0, enemyIdx = 0; enemyIdx < ARRAY_SIZE_SIGNED(mgr->enemies) - 1;
enemyIdx++, curEnemy++)
{
if (!curEnemy->flags.unk5)
Expand Down Expand Up @@ -768,7 +773,7 @@ ChainCallbackResult EnemyManager::OnDraw(EnemyManager *mgr)
i32 curEnemyVmIdx;
i32 curEnemyIdx;

for (curEnemy = &mgr->enemies[0], curEnemyIdx = 0; curEnemyIdx < ARRAY_SIZE_SIGNED(mgr->enemies);
for (curEnemy = &mgr->enemies[0], curEnemyIdx = 0; curEnemyIdx < ARRAY_SIZE_SIGNED(mgr->enemies) - 1;
curEnemyIdx++, curEnemy++)
{
if (!curEnemy->flags.unk5)
Expand Down
4 changes: 2 additions & 2 deletions src/EnemyManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ C_ASSERT(sizeof(RunningSpellcardInfo) == 0x14);
struct EnemyManager
{
void Initialize();
EnemyManager();
static ZunResult RegisterChain(char *stgEnm1, char *stgEnm2);
static void CutChain();
static ChainCallbackResult OnUpdate(EnemyManager *enemyManager);
Expand All @@ -35,8 +36,7 @@ struct EnemyManager
char *stgEnmAnmFilename;
char *stgEnm2AnmFilename;
Enemy enemyTemplate;
Enemy enemies[256];
Enemy dummyEnemyForFailedSpawns;
Enemy enemies[257];
Enemy *bosses[8];
u16 randomItemSpawnIndex;
u16 randomItemTableIndex;
Expand Down

0 comments on commit 93b0857

Please sign in to comment.