#ifndef WORLD_LADDER_H #define WORLD_LADDER_H /* * The telescopic ladder. * * Carried in one hand at the side. It slides out for use and together for * carrying and storing. It leans against anything that would hold it: solid * (a wall, the car, a tree, not a bush), high enough, with level ground and * room for its feet. The top rests on the edge (the gutter of a roof); too * short for that, it leans against the face and you can't get off at the top. * A leaning ladder stands still; people climb it rung by rung. How steady it * stands (angle, ground, what it leans on) decides if it slips when climbed; * somebody holding it keeps it steady. Stood up on its own it falls over. */ #include "world/world.h" /* Slides it out or together (it takes a moment). */ void Ladder_slide(Object *ladder); /* Slid out this far (0..1) right away: mesh and collider too. */ void Ladder_setExtend(Object *ladder, float extend); /* Eases the sliding along, rebuilding mesh and collider as it goes. */ void Ladder_update(World *world, Object *ladder, float dt); /* (world: what it falls against; may be NULL) */ #define LADDER_FOLDING 1 /* variant: two sections on a hinge (unfolds); 0: telescopic (slides out) */ #define LADDER_STEP 2 /* variant: a step ladder (opens and stands on its own) */ enum { LEAN_NOTHING, LEAN_DONE, LEAN_NO }; /* Leans the ladder who carries against what's right in front. LEAN_NO sets why. fit: slides it out as far as it takes (over the edge a bit) first. */ int Ladder_lean(World *world, Object *who, Object *ladder, bool fit, const char **why); /* A leaning ladder who can get on: at its foot, or (from up there) at its top. */ Object *Ladder_near(const World *world, const Object *who, bool *at_top); /* Takes a leaning ladder down into a free hand. */ bool Ladder_take(Object *who, Object *ladder); /* Gets on at the bottom or at the top. */ void Ladder_mount(Object *who, Object *ladder, bool at_top); enum { CLIMB_ON, CLIMB_OFF_BOTTOM, CLIMB_AT_EDGE }; /* On it right away this far up (a game loaded): hands and feet straight onto the rungs. */ void Ladder_mountAt(Object *who, Object *ladder, float at); /* Climbing up (input > 0) or down. CLIMB_AT_EDGE: at the top, wanting over the edge. */ int Ladder_climb(Object *who, float input, float dt); /* Lets go of the ladder (on the ground at its foot, or handed over to a climb). */ void Ladder_getOff(Object *who); /* Where the top rests (on the edge), and the way over it (horizontal, away from the ladder). */ Vec3 Ladder_edge(const Object *ladder); /* How steady it stands now (0..1): its own stability, or 1 with somebody holding it. */ float Ladder_steadiness(const Object *ladder); /* It falls over (away the way dir points, horizontal); anybody on it comes off. */ void Ladder_topple(World *world, Object *ladder, Vec3 dir); /* Holding it steady at its foot (both hands on the rails, a foot on the bottom rung), or not (NULL). */ void Ladder_hold(Object *who, Object *ladder); /* Where somebody stands to hold it (beside its foot, out of the climber's way), and which way they face. */ Vec3 Ladder_holdSpot(const Object *ladder, Vec3 *facing); /* Climbing: hands on the rungs (after Hands_update) and feet on them (after Body_update); holding it: hands on the rails, a foot on the bottom rung. */ void Ladder_poseHands(Object *who, float dt); void Ladder_poseFeet(Object *who, float dt); /* Slid out and in hand: held near its foot, reaching up in front (steeper looking up). */ bool Ladder_isRaised(const Object *ladder); Vec3 Ladder_raisedGrip(const Object *ladder, float along); /* Carried at the side, on edge; slid out, raised. */ void Ladder_placeHeld(Object *who, int hand, Object *ladder); #endif /* WORLD_LADDER_H */