Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish matching zBusStop #295

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
Object(NonMatching, "SB/Game/zNPCGoalDuplotron.cpp"),
Object(NonMatching, "SB/Game/zNPCSpawner.cpp"),
Object(NonMatching, "SB/Game/zEntTeleportBox.cpp"),
Object(NonMatching, "SB/Game/zBusStop.cpp"),
Object(Matching, "SB/Game/zBusStop.cpp"),
Object(NonMatching, "SB/Game/zNPCSupport.cpp"),
Object(NonMatching, "SB/Game/zTalkBox.cpp"),
Object(NonMatching, "SB/Game/zTextBox.cpp"),
Expand Down
46 changes: 20 additions & 26 deletions src/SB/Game/zBusStop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@
#include "zEntPlayer.h"
#include "zEntCruiseBubble.h"

#define zBusStop_float_minusone -1.0f
#define zBusStop_float_6p25 6.25f
#define zBusStop_float_zero 0.0f
#define zBusStop_float_0p1 0.1f
#define zBusStop_float_0p5 0.5f
#define zBusStop_float_two 2.0f

extern xEnt* sBusStopUI;
uint32 gBusStopIsRunning;
static xEnt* sBusStopUI;

void zBusStop_Init(xBase& base, xDynAsset& asset, ulong32)
{
Expand Down Expand Up @@ -60,7 +54,7 @@ void zBusStop_Setup(zBusStop* bstop)
{
zSceneFindObject(bstop->basset->cameraID);
bstop->bus = (zEnt*)zSceneFindObject(bstop->basset->busID);
bstop->switchTimer = zBusStop_float_minusone;
bstop->switchTimer = -1.0f;
sBusStopUI = (xEnt*)zSceneFindObject(xStrHash("mnu4 busstop"));
}

Expand All @@ -72,7 +66,7 @@ void zBusStop_Update(xBase* to, xScene* scene, float32 dt)
float32 dx = globals.player.ent.bound.box.center.x - bstop->pos.x;
float32 dy = globals.player.ent.bound.box.center.y - bstop->pos.y;
float32 dz = globals.player.ent.bound.box.center.z - bstop->pos.z;
if (dx * dx + dy * dy + dz * dz < zBusStop_float_6p25)
if (dx * dx + dy * dy + dz * dz < 6.25f)
{
if (bstop->currState == 0)
{
Expand All @@ -97,7 +91,7 @@ void zBusStop_Update(xBase* to, xScene* scene, float32 dt)
if (globals.pad0->pressed & (1 << 12))
{
bstop->currState = 2;
zEntPlayer_SNDPlay(ePlayerSnd_Bus, zBusStop_float_zero);
zEntPlayer_SNDPlay(ePlayerSnd_Bus, 0.0f);
}
}
}
Expand All @@ -113,21 +107,21 @@ void zBusStop_Update(xBase* to, xScene* scene, float32 dt)
break;

case 2:
globals.player.ent.frame->vel.x = zBusStop_float_zero;
globals.player.ent.frame->vel.y = zBusStop_float_zero;
globals.player.ent.frame->vel.z = zBusStop_float_zero;
globals.player.ent.frame->vel.x = 0.0f;
globals.player.ent.frame->vel.y = 0.0f;
globals.player.ent.frame->vel.z = 0.0f;
break;

case 3:
xAnimSingle* single = bstop->bus->model->Anim->Single;
if (single->Time < zBusStop_float_0p1 || single->LastTime < zBusStop_float_0p1)
if (single->Time < 0.1f || single->LastTime < 0.1f)
{
bstop->currState = 1;
}

globals.player.ent.frame->vel.x = zBusStop_float_zero;
globals.player.ent.frame->vel.y = zBusStop_float_zero;
globals.player.ent.frame->vel.z = zBusStop_float_zero;
globals.player.ent.frame->vel.x = 0.0f;
globals.player.ent.frame->vel.y = 0.0f;
globals.player.ent.frame->vel.z = 0.0f;
break;
}

Expand All @@ -151,11 +145,11 @@ void zBusStop_Update(xBase* to, xScene* scene, float32 dt)
zEntEvent("mnu4 busstop", eEventUIFocusOff_Unselect);
zEntPlayerControlOff(CONTROL_OWNER_BUS_STOP);
zEntEvent(bstop->basset->cameraID, eEventStartConversation);
zEntEvent(bstop->basset->cameraID, eEventSwitch, zBusStop_float_0p5,
zBusStop_float_zero, zBusStop_float_zero, zBusStop_float_zero);
zEntEvent(bstop->basset->cameraID, eEventSwitch, 0.5f,
0.0f, 0.0f, 0.0f);
zEntEvent(bstop->basset->busID, eEventVisible);
zEntEvent(bstop->basset->busID, eEventAnimPlay, zBusStop_float_two, zBusStop_float_zero,
zBusStop_float_zero, zBusStop_float_zero);
zEntEvent(bstop->basset->busID, eEventAnimPlay, 2.0f, 0.0f,
0.0f, 0.0f);
bstop->switchTimer = bstop->basset->delay;
gBusStopIsRunning = 1;
break;
Expand All @@ -180,18 +174,18 @@ void zBusStop_Update(xBase* to, xScene* scene, float32 dt)

// Advance state
bstop->prevState = bstop->currState;
if (zBusStop_float_zero == bstop->switchTimer && bstop->currState == 2)
if (0.0f == bstop->switchTimer && bstop->currState == 2)
{
bstop->currState = 3;
}

// Advance timer
if (bstop->switchTimer > zBusStop_float_zero)
if (bstop->switchTimer > 0.0f)
{
bstop->switchTimer -= dt;
if (bstop->switchTimer < zBusStop_float_zero)
if (bstop->switchTimer < 0.0f)
{
bstop->switchTimer = zBusStop_float_zero;
bstop->switchTimer = 0.0f;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/SB/Game/zBusStop.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ struct zBusStop : xBase
float32 switchTimer;
};

extern uint32 gBusStopIsRunning;

struct xScene;

int32 zBusStopEventCB(xBase*, xBase*, uint32, const float32*, xBase*);
Expand Down