sm64pc/src/game/behaviors/beta_holdable_object.inc.c

79 lines
1.9 KiB
C
Raw Normal View History

2019-08-25 04:46:40 +00:00
/**
* Behavior for bhvBetaHoldableObject.
* This is a simple implementation of a holdable object, probably used
* for testing. This was previously assumed to be a beta shell, as there
* are unused shell models left in the game; however, there is no evidence
* to support this theory.
*/
/**
* Initialization function for bhvBetaHoldableObject.
* Just sets various physics constants for the object.
*/
void bhv_beta_holdable_object_init(void) {
o->oGravity = 2.5;
o->oFriction = 0.8;
o->oBuoyancy = 1.3;
}
/**
* Drop the object.
*/
static void beta_holdable_object_drop(void) {
// Re-enable rendering
2020-03-02 03:42:52 +00:00
cur_obj_enable_rendering();
2019-08-25 04:46:40 +00:00
2020-03-02 03:42:52 +00:00
cur_obj_get_dropped();
2019-08-25 04:46:40 +00:00
o->oHeldState = HELD_FREE;
o->oForwardVel = 0;
o->oVelY = 0;
}
/**
* Throw the object.
*/
static void beta_holdable_object_throw(void) {
2020-03-02 03:42:52 +00:00
// cur_obj_enable_rendering_2 just calls cur_obj_enable_rendering and does
2019-08-25 04:46:40 +00:00
// nothing else; it's useless here. Maybe it originally did more?
2020-03-02 03:42:52 +00:00
cur_obj_enable_rendering_2();
cur_obj_enable_rendering();
2019-08-25 04:46:40 +00:00
o->oHeldState = HELD_FREE;
// This flag is never set, why is it cleared?
o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW;
// Set initial velocity
o->oForwardVel = 40.0;
o->oVelY = 20.0;
}
/**
* Update function for bhvBetaHoldableObject.
* Apply standard physics to the object if not held;
* otherwise, handle holding logic.
*/
void bhv_beta_holdable_object_loop(void) {
switch (o->oHeldState) {
case HELD_FREE:
// Apply standard physics
2019-12-02 02:52:53 +00:00
object_step();
2019-08-25 04:46:40 +00:00
break;
case HELD_HELD:
// Disable rendering to hide the object while it's held
2020-03-02 03:42:52 +00:00
cur_obj_disable_rendering();
2019-08-25 04:46:40 +00:00
break;
case HELD_THROWN:
beta_holdable_object_throw();
break;
case HELD_DROPPED:
beta_holdable_object_drop();
break;
}
}