Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 52 additions & 2 deletions src/SB/Game/zNPCMgr.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "zNPCMgr.h"
#include "xLightKit.h"
#include "xRMemData.h"
#include "zNPCTypeCommon.h"
#include "zNPCTypeRobot.h"
#include "zNPCTypeVillager.h"
Expand All @@ -8,7 +10,10 @@
#include "zNPCTypes.h"
#include "zNPCSpawner.h"
#include "zNPCMessenger.h"
#include "zNPCGoals.h"
#include "zGlobals.h"
#include "xFactory.h"
#include "zRenderState.h"

#include "xBehaveMgr.h"

Expand Down Expand Up @@ -56,7 +61,7 @@ void zNPCMgr_Startup()
if (g_modinit++ == 0)
{
xBehaveMgr_Startup();
zNPCMgr* npc = new (0x4e50434d, NULL) zNPCMgr(); //NPCM
zNPCMgr* npc = new ('NPCM', NULL) zNPCMgr();
g_npcmgr = npc;
npc->Startup();
}
Expand Down Expand Up @@ -124,6 +129,21 @@ xEnt* zNPCMgr_createNPCInst(S32, xEntAsset* assdat)
return zNPCMgrSelf()->CreateNPC(assdat);
}

void zNPCMgr::Startup()
{
PrepTypeTable();
selfbase.id = 'NPCM';
selfbase.baseType = 0xAB;
npcFactory = new ('NPCM', NULL) xFactory(0x60);
zNPCMsg_Startup();
zNPCSpawner_Startup();
zNPCTypes_StartupTypes();
zNPCTypes_RegisterTypes(npcFactory);
bmgr = xBehaveMgr_GetSelf();
xFactory* behaveMgrFactory = bmgr->GetFactory();
zNPCGoals_RegisterTypes(behaveMgrFactory);
}

void zNPCMgr::Shutdown()
{
if (this->npcFactory != NULL)
Expand Down Expand Up @@ -228,7 +248,6 @@ S32 zNPCMgr_OrdComp_npcid(void* vkey, void* vitem)
return rc;
}


zNPCMgr::zNPCMgr()
{
}
Expand Down Expand Up @@ -261,3 +280,34 @@ void zNPCCommon::RenderExtra()
void zNPCCommon::RenderExtraPostParticles()
{
}

void zNPCMgr::ScenePostRender()
{
xLightKit_Enable(globals.player.ent.lightKit, globals.currWorld);
enum _SDRenderState old_rendstat = zRenderStateCurrent();
zRenderState(SDRS_NPCVisual);
for (int i = 0; i < npclist.cnt; i++)
{
zNPCCommon* npc = (zNPCCommon*)npclist.list[i];
if (npc->flg_xtrarend & 0x1)
{
npc->flg_xtrarend &= ~0x1;
}
else
{
continue;
}

if (npc->baseFlags & 0x40)
{
continue;
}

if (npc->model == NULL || !(npc->model->Flags & 0x400))
{
npc->RenderExtra();
}
}
xLightKit_Enable(0, globals.currWorld);
zRenderState(old_rendstat);
}