#pragma once #include "raylib.h" // Low-poly GLB actors authored in Blender (tools/blender/build_enemies.py). // All models are metres, origin at the feet, facing +Z (the game camera). // The set-dressing models share the same one-mesh / painted-vertex pipeline. enum class ActorModel { Guard, HissStaff, MoldSpore, HissBrute, HissGhost, Shard, Hotline, TV, Pedestal, Duck, Cabinet, Crate, Debris, Switch, OfficeDesk, MeetingTable, OfficeChair, Computer, Plant, Sofa, FloorLamp, Partition, GarbageCan, DocumentStack, LooseSheet, RoundBasic, RoundTuned, RoundOvercharge, MuzzleFlash, Count }; class ModelBank { public: void init(); void shutdown(); bool ready() const { return ready_; } // Frame-wide shader uniforms (time / corruption / camera). void begin_frame(float time, float corruption, Vector3 camera_pos); // Draws one actor. `flash` is a 0..1 hit flash; `yaw` rotates around Y. // `outline` adds a back-face ink silhouette (guard / bosses, not the horde). void draw(ActorModel id, Vector3 pos, float yaw, float scale, Color tint, float flash = 0.0f, bool outline = false, float walk = 0.0f, float stagger = 0.0f, float phase = 0.0f, float hiss = 0.0f); // Plays a named GLB action on a skinned model (dt in seconds, 60 fps clips). // blend_seconds > 0 cross-fades from the outgoing clip into the new one via // raylib's two-animation blend; 0 keeps the old hard cut. void update_animation(ActorModel id, const char* name, float dt, float blend_seconds = 0.0f); // Layers a short upper-body flinch over the pose left by update_animation(). // Legs/root keep their locomotion pose, so a hit never freezes the walk. // Call after update_animation() with amount in 0..1. void flinch(ActorModel id, float amount); // Per-model visual height, used for health bars / floating labels. static float height(ActorModel id); private: // Single-frame clip holding the current locomotion pose plus a hit lean. // Only chest/head/arms are changed, so re-applying it leaves the legs alone. struct FlinchOverlay { ModelAnimation anim{}; int chest = -1; int head = -1; int arm_l = -1; int arm_r = -1; bool ready = false; }; struct Entry { Model model{}; ModelAnimation* animations = nullptr; int animation_count = 0; int current_animation = -1; float animation_clock = 0.0f; int blend_from = -1; // outgoing clip during a cross-fade float blend_from_clock = 0.0f; float blend_time = 0.0f; float blend_duration = 0.0f; // 0 => no cross-fade in progress FlinchOverlay flinch{}; bool loaded = false; }; static const char* file_name(ActorModel id); void draw_fallback(ActorModel id, Vector3 pos, float yaw, float scale, Color tint); Entry entries_[static_cast(ActorModel::Count)]; Shader shader_{}; Texture2D ramp_{}; int loc_time_ = -1; int loc_flash_ = -1; int loc_corruption_ = -1; int loc_camera_ = -1; int loc_outline_ = -1; int loc_glow_ = -1; int loc_ramp_ = -1; int loc_walk_ = -1; int loc_stagger_ = -1; int loc_phase_ = -1; int loc_rig_ = -1; int loc_rig_scale_ = -1; int loc_rig_mode_ = -1; int loc_hiss_ = -1; bool shader_ok_ = false; bool ready_ = false; };