MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / zEntTeleportBox_Update

Function zEntTeleportBox_Update

src/SB/Game/zEntTeleportBox.cpp:193–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191void zEntTeleportBox_Setup(_zEntTeleportBox* ent);
192
193void zEntTeleportBox_Update(xEnt* rawent, xScene* sc, F32 dt)
194{
195 _zEntTeleportBox* ent = (_zEntTeleportBox*)rawent;
196 _zEntTeleportBox* target = (_zEntTeleportBox*)ent->target;
197
198 xEntUpdate(ent, sc, dt);
199
200 F32 dx__ = globals.player.ent.bound.sph.center.x - ent->model->Mat->pos.x;
201 F32 dy__ = globals.player.ent.bound.sph.center.y - ent->model->Mat->pos.y;
202 F32 dz__ = globals.player.ent.bound.sph.center.z - ent->model->Mat->pos.z;
203
204 if (SQR(dx__) + SQR(dy__) + SQR(dz__) < 11.56f)
205 {
206 ent->currPlayerNear = 1;
207 }
208 else
209 {
210 ent->currPlayerNear = 0;
211 }
212
213 if (ent->currPlayerNear != ent->prevPlayerNear)
214 {
215 if (ent->currPlayerNear)
216 {
217 sPlayerNear = 1;
218 }
219 else
220 {
221 sPlayerNear = 0;
222 zEntEvent("mnu4 teleport box", eEventInvisible);
223 }
224 }
225
226 ent->prevPlayerNear = ent->currPlayerNear;
227
228 if (ent->currPlayerNear)
229 {
230 if (cruise_bubble::active())
231 {
232 if (xEntIsVisible(sTeleportUI))
233 {
234 zEntEvent("mnu4 teleport box", eEventInvisible);
235 }
236 }
237 else
238 {
239 if (!xEntIsVisible(sTeleportUI) && target->status == STATUS_CLOSED)
240 {
241 zEntEvent("mnu4 teleport box", eEventVisible);
242 }
243 }
244 }
245
246 xVec3 playerMid;
247 xVec3Copy(&playerMid, (xVec3*)&globals.player.ent.model->Mat->pos);
248
249 playerMid.y += 0.5f;
250

Callers

nothing calls this directly

Calls 15

xEntUpdateFunction · 0.85
xEntIsVisibleFunction · 0.85
xVec3CopyFunction · 0.85
xPointInBoxFunction · 0.85
zEntTeleportBox_isOpenFunction · 0.85
zRumbleStartFunction · 0.85
xMat3x3EulerFunction · 0.85
zEntTeleportBox_isClosedFunction · 0.85
zPadAddRumbleFunction · 0.85
zEntPlayerControlOffFunction · 0.70
xSndPlay3DFunction · 0.70

Tested by

no test coverage detected