sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

beta_holdable_object.inc.c (1946B)


      1 
      2 /**
      3  * Behavior for bhvBetaHoldableObject.
      4  * This is a simple implementation of a holdable object, probably used
      5  * for testing. This was previously assumed to be a beta shell, as there
      6  * are unused shell models left in the game; however, there is no evidence
      7  * to support this theory.
      8  */
      9 
     10 /**
     11  * Initialization function for bhvBetaHoldableObject.
     12  * Just sets various physics constants for the object.
     13  */
     14 void bhv_beta_holdable_object_init(void) {
     15     o->oGravity = 2.5f;
     16     o->oFriction = 0.8f;
     17     o->oBuoyancy = 1.3f;
     18 }
     19 
     20 /**
     21  * Drop the object.
     22  */
     23 static void beta_holdable_object_drop(void) {
     24     // Re-enable rendering
     25     cur_obj_enable_rendering();
     26 
     27     cur_obj_get_dropped();
     28 
     29     o->oHeldState = HELD_FREE;
     30 
     31     o->oForwardVel = 0.0f;
     32     o->oVelY = 0.0f;
     33 }
     34 
     35 /**
     36  * Throw the object.
     37  */
     38 static void beta_holdable_object_throw(void) {
     39     // cur_obj_enable_rendering_2 just calls cur_obj_enable_rendering and does
     40     // nothing else; it's useless here. Maybe it originally did more?
     41     cur_obj_enable_rendering_2();
     42     cur_obj_enable_rendering();
     43 
     44     o->oHeldState = HELD_FREE;
     45 
     46     // This flag is never set, why is it cleared?
     47     o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW;
     48 
     49     // Set initial velocity
     50     o->oForwardVel = 40.0f;
     51     o->oVelY = 20.0f;
     52 }
     53 
     54 /**
     55  * Update function for bhvBetaHoldableObject.
     56  * Apply standard physics to the object if not held;
     57  * otherwise, handle holding logic.
     58  */
     59 void bhv_beta_holdable_object_loop(void) {
     60     switch (o->oHeldState) {
     61         case HELD_FREE:
     62             // Apply standard physics
     63             object_step();
     64             break;
     65 
     66         case HELD_HELD:
     67             // Disable rendering to hide the object while it's held
     68             cur_obj_disable_rendering();
     69             break;
     70 
     71         case HELD_THROWN:
     72             beta_holdable_object_throw();
     73             break;
     74 
     75         case HELD_DROPPED:
     76             beta_holdable_object_drop();
     77             break;
     78     }
     79 }