Skip to content

Commit

Permalink
zPlatform matches + fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
escape209 committed Sep 29, 2024
1 parent 4a88323 commit f17441b
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/SB/Core/x/xEnt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void xEntAddHittableFlag(xEnt* ent)
{
if (ent->baseType == eBaseTypeNPC || ent->baseType == eBaseTypeDestructObj ||
ent->baseType == eBaseTypeButton || ent->baseType == eBaseTypeBoulder ||
(ent->baseType == eBaseTypePlatform && ent->subType == ZPLATFROM_SUBTYPE_PADDLE))
(ent->baseType == eBaseTypePlatform && ent->subType == ZPLATFORM_SUBTYPE_PADDLE))
{
ent->moreFlags |= 0x10;
}
Expand Down
1 change: 1 addition & 0 deletions src/SB/Core/x/xEntDrive.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ struct xEntDrive
void xEntDriveInit(xEntDrive* drv, xEnt* driven);
void xEntDriveMount(xEntDrive* drv, xEnt* driver, F32 mt, const xCollis* coll);
void xEntDriveDismount(xEntDrive* drv, F32 dmt);
void xEntDriveUpdate(xEntDrive* drv, xScene* s, F32 dt, xEntFrame* frame);

#endif
1 change: 1 addition & 0 deletions src/SB/Game/zEntPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ void zEntPlayer_ShadowModelEnable();
void zEntPlayer_ShadowModelDisable();

void zEntPlayerJumpStart(class xEnt* ent, class zJumpParam* jump);
bool zEntPlayer_IsSneaking();

void zEntPlayer_setBoulderMode(U32 mode);
void zEntPlayer_GiveHealth(S32);
Expand Down
105 changes: 105 additions & 0 deletions src/SB/Game/zPlatform.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
#include "zPlatform.h"
#include "zEnt.h"
#include "zEntPlayer.h"
#include "xEntDrive.h"
#include "zParEmitter.h"

#include "xMath.h"

#include <types.h>

zParEmitter* sEmitTremble;
zParEmitter* sEmitBreakaway;

extern char stringBase0[];

void genericPlatRender(xEnt* ent)
{
if (!ent->model || !xEntIsVisible(ent))
Expand All @@ -26,3 +37,97 @@ void zPlatform_Load(zPlatform* ent, xSerial* s)
{
zEntLoad(ent, s);
}

void zPlatform_Move(xEnt* entPlat, xScene* s, float dt, xEntFrame* frame)
{
zPlatform* plat = (zPlatform*)entPlat;
xEntMotionMove(&plat->motion, s, dt, frame);
xEntDriveUpdate(&plat->drv, s, dt, NULL);
}

void zPlatform_Tremble(zPlatform* plat, float ampl, float freq, float dur);

void zPlatform_Mount(zPlatform* ent)
{
if (ent->subType == ZPLATFORM_SUBTYPE_BREAKAWAY)
{
if (ent->state == 0)
{
if ((ent->passet->ba.breakflags & 1) && zEntPlayer_IsSneaking())
{
ent->state = 1;
}
else
{
ent->state = 2;

// Needs to be used or the comparison's operands will be swapped.
F32 restingSpeed = 0.0f;
if ( ent->passet->fr.fspeed != restingSpeed )
{
zPlatform_Tremble(ent, 0.06f, DEG2RAD(720), ent->passet->fr.fspeed + 1.0f);
}
}

}
}
}

void zPlatform_Setup(zPlatform* ent, xScene* sc)
{
zEntSetup((zEnt *)ent);
sEmitTremble = zParEmitterFind(stringBase0 + 0x36); // "PAREMIT_PLAT_TREMBLE"
sEmitBreakaway = zParEmitterFind(stringBase0 + 0x4b); // "PAREMIT_PLAT_BREAKAWAY"
if (ent->subType == ZPLATFORM_SUBTYPE_PADDLE)
{
ent->tmr = -1e38;
ent->state = 2;
ent->ctr = ent->passet->paddle.startOrient;
}
}

void zPlatformTranslate(xEnt* xent, xVec3* dpos, xMat4x3* dmat)
{
zPlatform* plat = (zPlatform*)xent;
xEntDefaultTranslate(xent,dpos,dmat);
xEntMotionTranslate(&plat->motion, dpos, dmat);
}

void zPlatform_BreakawayFallFX(zPlatform* ent, F32 dt)
{
if (sEmitBreakaway != NULL)
{
xParEmitterCustomSettings info;
info.custom_flags = 0x100;
info.pos = *xEntGetCenter(ent);
info.pos.y += 0.5f;
for (int iVar2 = 0; iVar2 < 25; iVar2++)
{
xParEmitterEmitCustom(sEmitBreakaway, 0.03333333f, &info);
}
}
}

U32 zMechIsStartingForth(zPlatform* ent, U16 param_2)
{
if (ent->motion.asset->mech.type == 4)
{
return param_2 == 1;
}
else
{
return param_2 == 0;
}
}

U32 zMechIsStartingBack(zPlatform* ent, U16 param_2)
{
if (ent->motion.asset->mech.type == 4)
{
return param_2 == 4;
}
else
{
return param_2 == 3;
}
}
2 changes: 1 addition & 1 deletion src/SB/Game/zPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ struct zPlatform : zEnt
#define ZPLATFORM_SUBTYPE_BREAKAWAY 9
#define ZPLATFORM_SUBTYPE_SPRINGBOARD 10
#define ZPLATFORM_SUBTYPE_TEETER 11
#define ZPLATFROM_SUBTYPE_PADDLE 12
#define ZPLATFORM_SUBTYPE_PADDLE 12
#define ZPLATFORM_SUBTYPE_FM 13

void genericPlatRender(xEnt* ent);
Expand Down

0 comments on commit f17441b

Please sign in to comment.