A dark, upward-tilted figure now appears occasionally around Floor 01, climbs a few metres with a red Hiss wake and dissolves into the haze. There is deliberately no roof mesh: the tactical camera sits above the room, so a ceiling would hide the play area. The riser is presentation-only - no collision, health, XP, director card or steering - and its fixed anchors never follow the player. - Added ascended.glb (1,474 tris, one merged mesh and material, jacket with trouser legs and boots) and the reproducible tools/blender/build_ambient.py generator - Registered ActorModel::Ascended with rig, Hiss tint, height, name mapping and a dark humanoid fallback - Authored wall-side anchors in map space, validated against cooked walls; one active early, up to three as corruption climbs, visible only ~5 s of a 34-62 s cycle - Added the rise, red ground bloom, haze veil and fade directly in the presenter, plus --ascension-test to stage one mid-rise in the plaza for screenshot QA - README updated; build clean and 17/17 tests pass with staged and normal-play captures reviewed
2080 lines
100 KiB
C++
2080 lines
100 KiB
C++
#include "render/presenter.hpp"
|
|
|
|
#include "core/debug.hpp"
|
|
#include "game/floor.hpp"
|
|
#include "game/weapons.hpp"
|
|
#include "render/layout.hpp"
|
|
#include "render/profiler.hpp"
|
|
#include "raymath.h"
|
|
#include "rlgl.h"
|
|
|
|
// Count every immediate-mode 3D draw issued from this translation unit.
|
|
#define DrawCube(...) do { PROF_DRAW_CALL(); DrawCube(__VA_ARGS__); } while(0)
|
|
#define DrawCylinder(...) do { PROF_DRAW_CALL(); DrawCylinder(__VA_ARGS__); } while(0)
|
|
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
#include <cstddef>
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
#include <iterator>
|
|
|
|
namespace {
|
|
|
|
Color projectile_color(WeaponType type, int tier) {
|
|
if (tier >= 2) return Color{255, 96, 64, 255};
|
|
if (tier == 1) return Color{255, 224, 132, 255};
|
|
switch (type) {
|
|
case WeaponType::Spin: return Color{255, 240, 180, 255};
|
|
case WeaponType::Shatter: return Color{255, 170, 90, 255};
|
|
case WeaponType::Charge: return Color{255, 70, 60, 255};
|
|
case WeaponType::Launch: return Color{140, 220, 200, 255};
|
|
case WeaponType::Projector: return Color{190, 150, 255, 255};
|
|
}
|
|
return WHITE;
|
|
}
|
|
|
|
float projectile_size(WeaponType type) {
|
|
if (type == WeaponType::Charge) return 1.1f;
|
|
if (type == WeaponType::Projector) return 0.7f;
|
|
return 0.45f;
|
|
}
|
|
|
|
Texture2D load_glow_sprite() {
|
|
const char* rel = "assets/sprites/glow.png";
|
|
if (FileExists(rel)) return LoadTexture(rel);
|
|
const char* alt = TextFormat("%s../assets/sprites/glow.png",
|
|
GetApplicationDirectory());
|
|
if (FileExists(alt)) return LoadTexture(alt);
|
|
return Texture2D{};
|
|
}
|
|
|
|
float actor_flash(float timer, float scale) {
|
|
return timer <= 0.0f ? 0.0f : std::min(1.0f, timer * scale);
|
|
}
|
|
|
|
// A genuine PUSH stagger holds the actor in a recoil for longer than a hit
|
|
// flash; ordinary hits still feed the same shader uniform at a lower weight.
|
|
float enemy_stagger(const Enemy& e) {
|
|
return std::max(actor_flash(e.hit_flash, 6.0f),
|
|
std::min(1.0f, e.stagger_timer * 2.5f));
|
|
}
|
|
|
|
} // namespace
|
|
|
|
class ViewCull {
|
|
public:
|
|
void disable() { all_ = true; }
|
|
|
|
void init_ortho(const Camera3D& camera, float extent, float max_depth) {
|
|
all_ = false;
|
|
ortho_ = true;
|
|
cam_ = camera.position;
|
|
max_depth_ = max_depth;
|
|
forward_ = Vector3Normalize(
|
|
Vector3Subtract(camera.target, camera.position));
|
|
right_ = Vector3CrossProduct(forward_, Vector3{0.0f, 1.0f, 0.0f});
|
|
if (Vector3LengthSqr(right_) < 1e-6f) right_ = Vector3{1.0f, 0.0f, 0.0f};
|
|
right_ = Vector3Normalize(right_);
|
|
up_ = Vector3Normalize(Vector3CrossProduct(right_, forward_));
|
|
extent_ = extent * 0.5f;
|
|
}
|
|
|
|
void init(const Camera3D& camera, float aspect, float max_depth = 180.0f) {
|
|
all_ = false;
|
|
ortho_ = false;
|
|
cam_ = camera.position;
|
|
max_depth_ = max_depth;
|
|
forward_ = Vector3Normalize(
|
|
Vector3Subtract(camera.target, camera.position));
|
|
right_ = Vector3CrossProduct(forward_, Vector3{0.0f, 1.0f, 0.0f});
|
|
if (Vector3LengthSqr(right_) < 1e-6f) right_ = Vector3{1.0f, 0.0f, 0.0f};
|
|
right_ = Vector3Normalize(right_);
|
|
up_ = Vector3Normalize(Vector3CrossProduct(right_, forward_));
|
|
const float half = std::tan(camera.fovy * DEG2RAD * 0.5f);
|
|
tan_y_ = half;
|
|
tan_x_ = half * aspect;
|
|
}
|
|
|
|
bool visible(float x, float y, float z, float radius) const {
|
|
if (all_) return true;
|
|
const Vector3 d{x - cam_.x, y - cam_.y, z - cam_.z};
|
|
const float depth = Vector3DotProduct(d, forward_);
|
|
if (depth < -radius || depth > max_depth_ + radius) return false;
|
|
if (ortho_) {
|
|
return std::abs(Vector3DotProduct(d, right_)) <= extent_ + radius
|
|
&& std::abs(Vector3DotProduct(d, up_)) <= extent_ + radius;
|
|
}
|
|
return std::abs(Vector3DotProduct(d, right_)) <= depth * tan_x_ + radius
|
|
&& std::abs(Vector3DotProduct(d, up_)) <= depth * tan_y_ + radius;
|
|
}
|
|
|
|
private:
|
|
bool all_ = false;
|
|
bool ortho_ = false;
|
|
Vector3 cam_{};
|
|
float max_depth_ = 180.0f;
|
|
Vector3 forward_{};
|
|
Vector3 right_{};
|
|
Vector3 up_{};
|
|
float tan_x_ = 1.0f;
|
|
float tan_y_ = 1.0f;
|
|
float extent_ = 1.0f;
|
|
};
|
|
|
|
namespace {
|
|
|
|
float enemy_hiss(const Enemy& e) {
|
|
const EnemyMods& m = e.mods;
|
|
float h = 0.0f;
|
|
if (m.burn_dps > 0.0f) h += 0.5f;
|
|
if (m.speed_mult < 0.99f || m.speed_mult > 1.01f) h += 0.35f;
|
|
if (m.damage_taken_mult > 1.01f) h += 0.35f;
|
|
if (m.immune > 0.0f) h += 0.25f;
|
|
return std::min(1.0f, h);
|
|
}
|
|
|
|
// Glow colors per world-object kind (§4.6): the scene carries a faint
|
|
// readable signal so the player can see what they're about to catch.
|
|
Color world_object_color(const WorldObject& obj) {
|
|
const char* name = obj.name;
|
|
if (std::strcmp(name, "SLOW") == 0) return Color{70, 130, 190, 200};
|
|
if (std::strcmp(name, "VULNERABLE") == 0) return Color{200, 40, 40, 200};
|
|
if (std::strcmp(name, "DOT") == 0) return Color{200, 30, 30, 200};
|
|
if (std::strcmp(name, "TAKEN") == 0) return Color{255, 150, 40, 200};
|
|
if (std::strcmp(name, "CONFUSE") == 0) return Color{245, 197, 24, 200};
|
|
return Color{200, 200, 205, 200};
|
|
}
|
|
|
|
|
|
struct StaticMeshBuilder {
|
|
std::vector<float> pos;
|
|
std::vector<float> nrm;
|
|
std::vector<unsigned char> col;
|
|
std::vector<unsigned int> idx;
|
|
|
|
void add_vertex(float x, float y, float z, Color c,
|
|
float nx, float ny, float nz) {
|
|
pos.push_back(x); pos.push_back(y); pos.push_back(z);
|
|
nrm.push_back(nx); nrm.push_back(ny); nrm.push_back(nz);
|
|
col.push_back(c.r); col.push_back(c.g); col.push_back(c.b); col.push_back(c.a);
|
|
}
|
|
|
|
void add_triangle(float ax, float ay, float az, float bx, float by, float bz,
|
|
float cx, float cy, float cz, Color c) {
|
|
const float ux = bx - ax, uy = by - ay, uz = bz - az;
|
|
const float vx = cx - ax, vy = cy - ay, vz = cz - az;
|
|
float nx = uy * vz - uz * vy;
|
|
float ny = uz * vx - ux * vz;
|
|
float nz = ux * vy - uy * vx;
|
|
const float len = std::sqrt(nx * nx + ny * ny + nz * nz);
|
|
if (len > 1e-6f) { nx /= len; ny /= len; nz /= len; }
|
|
else { nx = 0.0f; ny = 1.0f; nz = 0.0f; }
|
|
const unsigned int base = static_cast<unsigned int>(pos.size() / 3);
|
|
add_vertex(ax, ay, az, c, nx, ny, nz);
|
|
add_vertex(bx, by, bz, c, nx, ny, nz);
|
|
add_vertex(cx, cy, cz, c, nx, ny, nz);
|
|
idx.push_back(base); idx.push_back(base + 1); idx.push_back(base + 2);
|
|
}
|
|
|
|
void add_face(float ax, float ay, float az, float bx, float by, float bz,
|
|
float cx, float cy, float cz, float dx, float dy, float dz,
|
|
Color c) {
|
|
add_triangle(ax, ay, az, bx, by, bz, cx, cy, cz, c);
|
|
add_triangle(ax, ay, az, cx, cy, cz, dx, dy, dz, c);
|
|
}
|
|
|
|
void add_box(Vector3 center, Vector3 size, Color c) {
|
|
const float hx = size.x * 0.5f, hy = size.y * 0.5f, hz = size.z * 0.5f;
|
|
const float x0 = center.x - hx, x1 = center.x + hx;
|
|
const float y0 = center.y - hy, y1 = center.y + hy;
|
|
const float z0 = center.z - hz, z1 = center.z + hz;
|
|
add_face(x1,y0,z0, x0,y0,z0, x0,y1,z0, x1,y1,z0, c);
|
|
add_face(x0,y0,z1, x1,y0,z1, x1,y1,z1, x0,y1,z1, c);
|
|
add_face(x0,y0,z0, x0,y0,z1, x0,y1,z1, x0,y1,z0, c);
|
|
add_face(x1,y0,z1, x1,y0,z0, x1,y1,z0, x1,y1,z1, c);
|
|
add_face(x0,y1,z1, x1,y1,z1, x1,y1,z0, x0,y1,z0, c);
|
|
add_face(x0,y0,z0, x1,y0,z0, x1,y0,z1, x0,y0,z1, c);
|
|
}
|
|
|
|
void add_cylinder(Vector3 center, float r1, float r2, float h, int segs, Color c) {
|
|
const float y0 = center.y, y1 = center.y + h;
|
|
const float cx = center.x, cz = center.z;
|
|
const float step = 2.0f * PI / static_cast<float>(segs);
|
|
for (int i = 0; i < segs; ++i) {
|
|
const float a0 = i * step, a1 = (i + 1) * step;
|
|
const float c0 = std::cos(a0), s0 = std::sin(a0);
|
|
const float c1 = std::cos(a1), s1 = std::sin(a1);
|
|
add_face(cx + r1*c0, y0, cz + r1*s0,
|
|
cx + r2*c0, y1, cz + r2*s0,
|
|
cx + r2*c1, y1, cz + r2*s1,
|
|
cx + r1*c1, y0, cz + r1*s1, c);
|
|
}
|
|
if (h > 0.05f) {
|
|
for (int i = 0; i < segs; ++i) {
|
|
const float a0 = i * step, a1 = (i + 1) * step;
|
|
add_triangle(cx, y0, cz,
|
|
cx + r1*std::cos(a0), y0, cz + r1*std::sin(a0),
|
|
cx + r1*std::cos(a1), y0, cz + r1*std::sin(a1), c);
|
|
add_triangle(cx, y1, cz,
|
|
cx + r2*std::cos(a1), y1, cz + r2*std::sin(a1),
|
|
cx + r2*std::cos(a0), y1, cz + r2*std::sin(a0), c);
|
|
}
|
|
}
|
|
}
|
|
|
|
Mesh to_mesh() {
|
|
Mesh m{};
|
|
const std::size_t verts = pos.size() / 3;
|
|
if (verts == 0 || verts > 65535u || idx.size() > 65535u) {
|
|
TraceLog(LOG_WARNING, "STATIC ENV: batch overflow (%zu verts), skipping",
|
|
verts);
|
|
return m;
|
|
}
|
|
m.vertexCount = static_cast<int>(verts);
|
|
m.triangleCount = static_cast<int>(idx.size() / 3);
|
|
m.vertices = static_cast<float*>(MemAlloc(pos.size() * sizeof(float)));
|
|
std::memcpy(m.vertices, pos.data(), pos.size() * sizeof(float));
|
|
m.normals = static_cast<float*>(MemAlloc(nrm.size() * sizeof(float)));
|
|
std::memcpy(m.normals, nrm.data(), nrm.size() * sizeof(float));
|
|
m.colors = static_cast<unsigned char*>(MemAlloc(col.size()));
|
|
std::memcpy(m.colors, col.data(), col.size());
|
|
m.indices = static_cast<unsigned short*>(MemAlloc(idx.size() * sizeof(unsigned short)));
|
|
for (std::size_t i = 0; i < idx.size(); ++i) {
|
|
m.indices[i] = static_cast<unsigned short>(idx[i]);
|
|
}
|
|
return m;
|
|
}
|
|
};
|
|
|
|
// Accumulates camera-facing glows and flat ground decals into a single
|
|
// rlBegin(RL_QUADS) block, replacing one glDrawElements per particle.
|
|
class QuadBatch {
|
|
public:
|
|
void begin(Texture2D tex) {
|
|
texture_ = tex;
|
|
count_ = 0;
|
|
}
|
|
|
|
void add_billboard(const Vector3& pos, float w, float h,
|
|
const Vector3& right, const Vector3& up, Color tint) {
|
|
if (count_ >= kMax) return;
|
|
const float hw = w * 0.5f, hh = h * 0.5f;
|
|
Quad q;
|
|
q.p0 = {pos.x - right.x*hw + up.x*hh, pos.y - right.y*hw + up.y*hh,
|
|
pos.z - right.z*hw + up.z*hh};
|
|
q.p1 = {pos.x + right.x*hw + up.x*hh, pos.y + right.y*hw + up.y*hh,
|
|
pos.z + right.z*hw + up.z*hh};
|
|
q.p2 = {pos.x + right.x*hw - up.x*hh, pos.y + right.y*hw - up.y*hh,
|
|
pos.z + right.z*hw - up.z*hh};
|
|
q.p3 = {pos.x - right.x*hw - up.x*hh, pos.y - right.y*hw - up.y*hh,
|
|
pos.z - right.z*hw - up.z*hh};
|
|
q.tint = tint;
|
|
quads_[count_++] = q;
|
|
}
|
|
|
|
void add_ground(const Vector3& pos, float radius, Color tint) {
|
|
if (count_ >= kMax) return;
|
|
Quad q;
|
|
q.p0 = {pos.x - radius, pos.y, pos.z - radius};
|
|
q.p1 = {pos.x + radius, pos.y, pos.z - radius};
|
|
q.p2 = {pos.x + radius, pos.y, pos.z + radius};
|
|
q.p3 = {pos.x - radius, pos.y, pos.z + radius};
|
|
q.tint = tint;
|
|
quads_[count_++] = q;
|
|
}
|
|
|
|
void draw() {
|
|
if (count_ == 0 || texture_.id == 0) return;
|
|
|
|
const float u0 = 0.0f, u1 = 1.0f;
|
|
const float v0 = 0.0f, v1 = 1.0f;
|
|
PROF_DRAW_CALL();
|
|
rlSetTexture(texture_.id);
|
|
rlBegin(RL_QUADS);
|
|
for (int i = 0; i < count_; ++i) {
|
|
const Quad& q = quads_[i];
|
|
rlColor4ub(q.tint.r, q.tint.g, q.tint.b, q.tint.a);
|
|
rlTexCoord2f(u0, v0); rlVertex3f(q.p0.x, q.p0.y, q.p0.z);
|
|
rlTexCoord2f(u1, v0); rlVertex3f(q.p1.x, q.p1.y, q.p1.z);
|
|
rlTexCoord2f(u1, v1); rlVertex3f(q.p2.x, q.p2.y, q.p2.z);
|
|
rlTexCoord2f(u0, v1); rlVertex3f(q.p3.x, q.p3.y, q.p3.z);
|
|
}
|
|
rlEnd();
|
|
rlSetTexture(0);
|
|
}
|
|
|
|
private:
|
|
struct Quad {
|
|
Vector3 p0{}, p1{}, p2{}, p3{};
|
|
Color tint{};
|
|
};
|
|
static constexpr int kMax = 640;
|
|
Quad quads_[kMax];
|
|
int count_ = 0;
|
|
Texture2D texture_{};
|
|
};
|
|
|
|
|
|
} // namespace
|
|
|
|
void Presenter::spawn_sparks(Vec2 pos, float height, Color color, int count,
|
|
float speed) {
|
|
for (int i = 0; i < count && sparks_.size() < 160; ++i) {
|
|
const float angle = static_cast<float>(GetRandomValue(0, 360)) * DEG2RAD;
|
|
const float jitter = static_cast<float>(GetRandomValue(40, 120)) / 100.0f;
|
|
const float lift = static_cast<float>(GetRandomValue(120, 320)) / 100.0f;
|
|
sparks_.push_back(Spark{
|
|
{pos.x + static_cast<float>(GetRandomValue(-10, 10)) / 40.0f, height,
|
|
pos.y + static_cast<float>(GetRandomValue(-10, 10)) / 40.0f},
|
|
{std::cos(angle) * speed * jitter, lift,
|
|
std::sin(angle) * speed * jitter},
|
|
color,
|
|
0.0f,
|
|
static_cast<float>(GetRandomValue(50, 90)) / 100.0f,
|
|
static_cast<float>(GetRandomValue(14, 26)) / 100.0f});
|
|
}
|
|
}
|
|
|
|
void Presenter::spawn_skill_ring(Vec2 pos, float radius, float end_radius,
|
|
float life, Color color, float spin,
|
|
float height) {
|
|
if (skill_rings_.size() >= 24) skill_rings_.erase(skill_rings_.begin());
|
|
skill_rings_.push_back({pos, radius, end_radius, 0.0f, life, height,
|
|
spin, color});
|
|
}
|
|
|
|
void Presenter::spawn_push_shards(Vec2 center, float radius) {
|
|
// Eight pieces of the CALL rubble GLB sweep outward with the shockwave.
|
|
// Warm tint + tumbling spin make the shove read at tactical distance; the
|
|
// sim only owns the knockback, so this pool is purely cosmetic.
|
|
constexpr int kCount = 8;
|
|
for (int i = 0; i < kCount && push_shards_.size() < 16; ++i) {
|
|
const float a = 6.2831853f * static_cast<float>(i) / kCount
|
|
+ (static_cast<float>(GetRandomValue(-25, 25)) / 100.0f);
|
|
const float speed = 5.0f
|
|
+ static_cast<float>(GetRandomValue(0, 45)) / 10.0f;
|
|
const float lift = 2.4f
|
|
+ static_cast<float>(GetRandomValue(0, 30)) / 10.0f;
|
|
const float life = 0.7f
|
|
+ static_cast<float>(GetRandomValue(0, 40)) / 100.0f;
|
|
push_shards_.push_back(PushShard{
|
|
{center.x + std::cos(a) * 0.6f, 0.18f,
|
|
center.y + std::sin(a) * 0.6f},
|
|
{std::cos(a) * speed, lift, std::sin(a) * speed},
|
|
a,
|
|
(static_cast<float>(GetRandomValue(-100, 100)) / 100.0f) * 9.0f,
|
|
0.26f + static_cast<float>(GetRandomValue(0, 25)) / 100.0f,
|
|
0.0f,
|
|
life});
|
|
}
|
|
}
|
|
|
|
void Presenter::shed_surface_debris(Vec2 center, float radius) {
|
|
Vector3 origins[12];
|
|
const int n = dressing_.surface_sources_in_radius(
|
|
center, radius, origins, static_cast<int>(std::size(origins)));
|
|
DEBUG_TRACE(debug::Debris,
|
|
"surface query at %.1f %.1f r=%.1f -> %d origins", center.x,
|
|
center.y, radius, n);
|
|
if (n <= 0) return;
|
|
const int paper_count = std::min(24, 6 + n * 2);
|
|
const int rock_count = std::min(18, 5 + n * 2);
|
|
DEBUG_TRACE(debug::Debris, "surface shed: %d paper, %d rock", paper_count,
|
|
rock_count);
|
|
debris_.burst(center, 0.9f, radius, origins, n, paper_count);
|
|
concrete_debris_.burst(center, radius, rock_count, origins, n);
|
|
}
|
|
|
|
void Presenter::init(float arena_half, const Floor& floor) {
|
|
floor_mode_ = true;
|
|
camera_.position = {floor.spawn().x, tuning_.height, floor.spawn().y + tuning_.forward};
|
|
camera_.target = {floor.spawn().x, 0.0f, floor.spawn().y};
|
|
camera_.up = {0.0f, 1.0f, 0.0f};
|
|
camera_.fovy = tuning_.fov; // live-tunable from the dev HUD slider
|
|
camera_.projection = CAMERA_PERSPECTIVE;
|
|
|
|
Image img = GenImageGradientRadial(64, 64, 0.0f, WHITE, Color{255, 255, 255, 0});
|
|
soft_disc_ = LoadTextureFromImage(img);
|
|
UnloadImage(img);
|
|
spr_glow_ = load_glow_sprite();
|
|
models_.init();
|
|
concrete_.init(arena_half, &floor);
|
|
if (!shadow_map_.init(2048)) shadow_map_.init(1024);
|
|
|
|
// Phase 1 batching: bake the repeated outer service-band plant blocks,
|
|
// tops and spill cylinders into one mesh (one draw call).
|
|
{
|
|
StaticMeshBuilder b;
|
|
if (floor_mode_) {
|
|
// Room identity is now a low-strength tint in concrete.fs instead of
|
|
// opaque plates: the PBR concrete stays visible under every room.
|
|
const float gx = Floor::kWidth * 0.5f, gz = Floor::kHeight * 0.5f;
|
|
for (float x = -gx; x <= gx; x += 15.0f) {
|
|
b.add_box({x, 0.037f, 0.0f}, {0.06f, 0.007f, Floor::kHeight},
|
|
Color{34, 34, 39, 255});
|
|
}
|
|
for (float z = -gz; z <= gz; z += 15.0f) {
|
|
b.add_box({0.0f, 0.037f, z}, {Floor::kWidth, 0.007f, 0.06f},
|
|
Color{34, 34, 39, 255});
|
|
}
|
|
} else {
|
|
const float arena = arena_half;
|
|
for (int side = -1; side <= 1; side += 2) {
|
|
const float x = side * (arena + 6.0f);
|
|
for (float z = -arena; z <= arena + 12.0f; z += 9.0f) {
|
|
b.add_box({x, 0.85f, z}, {1.6f, 1.7f, 1.6f}, Color{34, 34, 38, 255});
|
|
b.add_box({x, 1.75f, z}, {1.8f, 0.12f, 1.8f}, Color{56, 56, 61, 255});
|
|
}
|
|
const float z = side * (arena + 7.0f);
|
|
for (float x2 = -arena; x2 <= arena + 10.0f; x2 += 9.0f) {
|
|
b.add_box({x2, 0.75f, z}, {1.5f, 1.5f, 1.5f}, Color{34, 34, 38, 255});
|
|
b.add_box({x2, 1.56f, z}, {1.7f, 0.12f, 1.7f}, Color{56, 56, 61, 255});
|
|
}
|
|
for (float z2 = -arena; z2 <= arena; z2 += 12.0f) {
|
|
b.add_cylinder({side * (arena + 8.0f), 0.05f, z2}, 3.2f, 3.2f, 0.02f, 8,
|
|
Color{190, 186, 164, 12});
|
|
b.add_cylinder({z2, 0.05f, side * (arena + 8.0f)}, 3.2f, 3.2f, 0.02f, 8,
|
|
Color{190, 186, 164, 12});
|
|
}
|
|
}
|
|
// Painted walkway lines + survey grid.
|
|
b.add_box({-12.0f, 0.012f, 0.0f}, {0.18f, 0.024f, arena * 2.0f}, Color{150, 147, 138, 255});
|
|
b.add_box({12.0f, 0.012f, 0.0f}, {0.18f, 0.024f, arena * 2.0f}, Color{150, 147, 138, 255});
|
|
b.add_box({0.0f, 0.012f, -12.0f}, {arena * 2.0f, 0.024f, 0.18f}, Color{150, 147, 138, 255});
|
|
b.add_box({0.0f, 0.012f, 12.0f}, {arena * 2.0f, 0.024f, 0.18f}, Color{150, 147, 138, 255});
|
|
for (const float cross : {-80.0f, -40.0f, 40.0f, 80.0f}) {
|
|
b.add_box({cross, 0.011f, 0.0f}, {0.12f, 0.022f, arena * 2.0f}, Color{112, 110, 104, 255});
|
|
b.add_box({0.0f, 0.011f, cross}, {arena * 2.0f, 0.022f, 0.12f}, Color{112, 110, 104, 255});
|
|
}
|
|
|
|
// Stains.
|
|
const float stains[][4] = {
|
|
{-9.0f, -14.0f, 1.8f, 0.7f}, {8.0f, -11.0f, 1.2f, 0.5f},
|
|
{-16.0f, 4.0f, 2.2f, 0.6f}, {12.5f, 12.0f, 1.6f, 0.8f},
|
|
{-5.0f, 18.0f, 1.4f, 0.5f}, {17.0f, -3.0f, 1.9f, 0.7f},
|
|
{-19.0f, -8.0f, 1.5f, 0.6f}, {3.0f, -20.0f, 2.1f, 0.7f},
|
|
};
|
|
for (const auto& st : stains) {
|
|
b.add_cylinder({st[0], 0.016f, st[1]}, st[2], st[2], 0.012f, 10,
|
|
Color{28, 12, 14, static_cast<unsigned char>(55 * st[3])});
|
|
}
|
|
// Scraps.
|
|
const float scraps[][2] = {
|
|
{-7.5f, -9.0f}, {-6.8f, -9.6f}, {5.5f, -15.0f}, {9.5f, 6.5f},
|
|
{10.2f, 7.1f}, {-14.0f, 11.5f}, {15.5f, -9.0f}, {-17.0f, -13.0f},
|
|
{2.0f, 20.0f}, {-3.0f, -17.0f}, {12.0f, 19.0f}, {-11.0f, 1.5f},
|
|
};
|
|
for (int i = 0; i < 12; ++i) {
|
|
const float x = scraps[i][0], z = scraps[i][1];
|
|
b.add_box({x, 0.022f, z}, {0.28f, 0.012f, 0.38f},
|
|
(i % 3 == 0) ? Color{90, 20, 26, 255} : Color{198, 192, 176, 255});
|
|
}
|
|
// Far stains.
|
|
const float far_stains[][4] = {
|
|
{-38.0f, -28.0f, 2.6f, 0.7f}, {42.0f, 21.0f, 3.1f, 0.6f},
|
|
{-58.0f, 38.0f, 2.2f, 0.8f}, {28.0f, -51.0f, 3.4f, 0.5f},
|
|
{71.0f, -22.0f, 2.8f, 0.6f}, {-72.0f, -68.0f, 3.6f, 0.7f},
|
|
{16.0f, 62.0f, 2.4f, 0.7f}, {-24.0f, -79.0f, 3.0f, 0.6f},
|
|
{83.0f, 74.0f, 2.7f, 0.7f}, {4.0f, -38.0f, 2.0f, 0.8f},
|
|
};
|
|
for (const auto& st : far_stains) {
|
|
b.add_cylinder({st[0], 0.016f, st[1]}, st[2], st[2] * 1.3f, 0.012f, 11,
|
|
Color{26, 12, 14, static_cast<unsigned char>(48 * st[3])});
|
|
}
|
|
// Far scraps.
|
|
const float far_scraps[][2] = {
|
|
{-35.0f, -33.0f}, {-33.6f, -34.2f}, {37.0f, 32.0f}, {38.4f, 31.1f},
|
|
{-60.0f, 12.0f}, {-58.8f, 13.4f}, {52.0f, -44.0f}, {53.2f, -45.1f},
|
|
{-48.0f, -56.0f}, {-46.5f, -57.2f}, {66.0f, 28.0f}, {64.7f, 29.5f},
|
|
{-77.0f, -26.0f}, {-75.6f, -27.5f}, {22.0f, 70.0f}, {20.8f, 71.4f},
|
|
};
|
|
for (std::size_t i = 0; i < 16; ++i) {
|
|
b.add_box({far_scraps[i][0], 0.022f, far_scraps[i][1]}, {0.34f, 0.012f, 0.44f},
|
|
(i % 4 == 0) ? Color{90, 20, 26, 255} : Color{198, 192, 176, 255});
|
|
}
|
|
// Cross lines.
|
|
for (const float cross : {-40.0f, 40.0f}) {
|
|
b.add_box({cross, 0.03f, 0.0f}, {0.09f, 0.03f, 110.0f}, Color{20, 20, 24, 255});
|
|
b.add_box({0.0f, 0.03f, cross}, {110.0f, 0.03f, 0.09f}, Color{20, 20, 24, 255});
|
|
}
|
|
// Red lines.
|
|
for (const float x : {-8.6f, 8.6f}) {
|
|
b.add_box({x, 0.03f, 0.0f}, {0.09f, 0.03f, 34.0f}, Color{20, 20, 24, 255});
|
|
}
|
|
|
|
// Room partitions and entrance signage (previously immediate-mode).
|
|
const layout::Room& room = layout::kOpenRoom;
|
|
const float rx0 = room.cx - room.hx, rx1 = room.cx + room.hx;
|
|
const float rz0 = room.cz - room.hz, rz1 = room.cz + room.hz;
|
|
const Color partition{58, 60, 64, 255};
|
|
b.add_box({room.cx, 0.85f, rz1}, {room.hx * 2.0f, 1.7f, 0.45f}, partition);
|
|
b.add_box({rx0, 0.75f, room.cz}, {0.45f, 1.5f, room.hz * 2.0f}, partition);
|
|
b.add_box({rx1, 0.75f, room.cz}, {0.45f, 1.5f, room.hz * 2.0f}, partition);
|
|
const float south_span = room.hx - 5.0f;
|
|
b.add_box({room.cx - (room.hx + 5.0f) * 0.5f, 0.65f, rz0},
|
|
{south_span, 1.3f, 0.45f}, partition);
|
|
b.add_box({room.cx + (room.hx + 5.0f) * 0.5f, 0.65f, rz0},
|
|
{south_span, 1.3f, 0.45f}, partition);
|
|
for (float x = rx0 + 4.0f; x < rx1; x += 8.0f) {
|
|
b.add_box({x, 1.46f, rz1}, {1.1f, 0.12f, 0.5f},
|
|
Color{198, 192, 176, 255});
|
|
}
|
|
b.add_box({room.cx, 1.02f, rz0 + 0.26f}, {4.6f, 0.32f, 0.08f},
|
|
Color{245, 197, 24, 255});
|
|
|
|
}
|
|
|
|
Mesh batch = b.to_mesh();
|
|
if (batch.vertexCount > 0) {
|
|
UploadMesh(&batch, false);
|
|
static_env_model_ = LoadModelFromMesh(batch);
|
|
static_env_ready_ = true;
|
|
TraceLog(LOG_INFO, "STATIC ENV: %d verts / %d tris in one draw call",
|
|
batch.vertexCount, batch.triangleCount);
|
|
}
|
|
}
|
|
aura_.init();
|
|
dressing_.init(&floor);
|
|
debris_.init();
|
|
concrete_debris_.init();
|
|
scorch_.clear();
|
|
|
|
// Ambient risers are authored in the level's map space and validated
|
|
// against the cooked walls. Keeping them near room walls (rather than at
|
|
// the centre of the plaza) means a rising figure never masks a crowd or
|
|
// the player under the tactical camera.
|
|
static const Vec2 kRiserAnchors[] = {
|
|
{28.0f, 36.0f}, {124.0f, 40.0f}, {78.0f, 84.0f}, // plaza / projector / office
|
|
{102.0f, 66.0f}, {26.0f, 100.0f}, {116.0f, 20.0f}, // plaza / silos / gate
|
|
{134.0f, 102.0f}, {132.0f, 64.0f}, {48.0f, 18.0f},
|
|
{60.0f, 39.0f}, {10.0f, 60.0f}, {154.0f, 52.0f}, // side rooms
|
|
};
|
|
for (int i = 0; i < static_cast<int>(std::size(kRiserAnchors)); ++i) {
|
|
const Vec2 p = Floor::to_world(kRiserAnchors[i].x, kRiserAnchors[i].y);
|
|
if (!floor.is_open(p, 0.8f)) continue;
|
|
// Long gaps between appearances: these are rare environmental beats,
|
|
// not a second horde. Anchors are fixed for the whole run — a figure
|
|
// never drifts toward the player.
|
|
ascensions_.push_back({p, std::fmod(i * 0.191f, 1.0f),
|
|
34.0f + (i % 5) * 7.0f,
|
|
i * 1.37f, 0.92f + (i % 3) * 0.05f});
|
|
}
|
|
TraceLog(LOG_INFO, "GFX: %d ambient riser anchors", (int)ascensions_.size());
|
|
|
|
damage_numbers_.reserve(64);
|
|
sparks_.reserve(160);
|
|
push_shards_.reserve(16);
|
|
}
|
|
|
|
void Presenter::apply_graphics_settings() {
|
|
concrete_.apply_texture_filter();
|
|
}
|
|
|
|
void Presenter::reset() {
|
|
dressing_.reset();
|
|
debris_.clear();
|
|
concrete_debris_.clear();
|
|
scorch_.clear();
|
|
player_walk_ = 0.0f;
|
|
dash_pose_ = 0.0f;
|
|
dash_prev_ = 0.0f;
|
|
fire_pose_ = 0.0f;
|
|
muzzle_flash_ = 0.0f;
|
|
trails_.clear();
|
|
skill_rings_.clear();
|
|
push_shards_.clear();
|
|
player_running_ = false;
|
|
ascension_clock_ = 0.0f;
|
|
}
|
|
|
|
void Presenter::shutdown() {
|
|
dressing_.shutdown();
|
|
debris_.shutdown();
|
|
concrete_debris_.shutdown();
|
|
debris_.clear();
|
|
concrete_debris_.clear();
|
|
scorch_.clear();
|
|
aura_.shutdown();
|
|
shadow_map_.shutdown();
|
|
concrete_.shutdown();
|
|
models_.shutdown();
|
|
if (static_env_ready_) {
|
|
UnloadModel(static_env_model_);
|
|
static_env_ready_ = false;
|
|
}
|
|
if (spr_glow_.id != 0) UnloadTexture(spr_glow_);
|
|
UnloadTexture(soft_disc_);
|
|
}
|
|
|
|
void Presenter::draw_initial_scene(const Game& game, const ViewCull& cull) {
|
|
const FloorRoom* plaza = nullptr;
|
|
for (const FloorRoom& r : game.floor.rooms()) {
|
|
if (r.kind == RoomKind::Plaza) plaza = &r;
|
|
}
|
|
if (plaza == nullptr) return;
|
|
const Vec2 c{(plaza->rect.x0 + plaza->rect.x1) * 0.5f,
|
|
(plaza->rect.z0 + plaza->rect.z1) * 0.5f};
|
|
if (!cull.visible(c.x, 1.0f, c.y, 42.0f)) return;
|
|
const Color carpet{112, 12, 22, 255};
|
|
const Color edge{62, 6, 12, 255};
|
|
|
|
// The original hub's red carpet runners and brass-edged cross.
|
|
DrawCube({c.x, 0.062f, c.y}, 4.4f, 0.06f, 38.0f, carpet);
|
|
DrawCube({c.x, 0.066f, c.y + 7.0f}, 58.0f, 0.064f, 4.4f, carpet);
|
|
for (const float x : {c.x - 2.15f, c.x + 2.15f})
|
|
DrawCube({x, 0.068f, c.y}, 0.3f, 0.064f, 38.0f, edge);
|
|
for (const float z : {c.y + 4.9f, c.y + 9.1f})
|
|
DrawCube({c.x, 0.07f, z}, 58.0f, 0.064f, 0.3f, edge);
|
|
for (float z = c.y - 16.0f; z <= c.y + 16.0f; z += 4.0f)
|
|
DrawCube({c.x, 0.095f, z}, 4.0f, 0.004f, 0.05f, Color{66, 7, 13, 255});
|
|
|
|
const float t = anim_time_;
|
|
int prop_index = 0;
|
|
for (const level::Prop& p : game.floor.data().props) {
|
|
if (p.room_kind != "Plaza" || p.destructible) continue;
|
|
ActorModel model = ActorModel::TV;
|
|
if (!ModelBank::actor_from_name(p.model, model)) continue;
|
|
const float x = c.x + p.pos.x;
|
|
const float z = c.y + p.pos.y;
|
|
float y = p.y;
|
|
float yaw = p.yaw;
|
|
if (p.model == "Hotline") y += std::sin(t * 2.3f) * 0.012f;
|
|
if (p.model == "Duck") {
|
|
y += std::sin(t * 2.0f) * 0.025f;
|
|
yaw += std::sin(t * 1.4f) * 0.09f;
|
|
}
|
|
if (p.model == "Debris") {
|
|
y += std::sin(t * 0.9f + prop_index * 2.1f) * 0.035f;
|
|
yaw += t * 0.12f;
|
|
}
|
|
if (!cull.visible(x, y + 1.0f, z, 3.0f)) continue;
|
|
models_.draw(model, {x, y, z}, yaw, p.scale, WHITE);
|
|
++prop_index;
|
|
}
|
|
const unsigned char alpha = static_cast<unsigned char>(
|
|
std::min<int>(70, 12 + game.corruption.value() * 28));
|
|
DrawCylinder({c.x, 0.075f, c.y - 15.0f}, 5.0f, 5.0f, 0.02f, 16,
|
|
Color{200, 24, 34, alpha});
|
|
}
|
|
|
|
void Presenter::draw_office_suite(const Game& game, const ViewCull& cull) {
|
|
const FloorRoom* suite = nullptr;
|
|
for (const FloorRoom& r : game.floor.rooms()) {
|
|
if (r.kind == RoomKind::OfficeSuite) suite = &r;
|
|
}
|
|
if (suite == nullptr) return;
|
|
const Vec2 c{(suite->rect.x0 + suite->rect.x1) * 0.5f,
|
|
(suite->rect.z0 + suite->rect.z1) * 0.5f};
|
|
if (!cull.visible(c.x, 1.0f, c.y, 46.0f)) return;
|
|
|
|
// The S16 open-plan kit, rebuilt at the new anchor to the right of Silos.
|
|
DrawCube({c.x, 0.05f, c.y}, 72.0f, 0.04f, 32.0f, Color{34, 48, 50, 255});
|
|
for (float x = c.x - 36.0f; x <= c.x + 36.0f; x += 9.0f)
|
|
DrawCube({x, 0.076f, c.y}, 0.07f, 0.004f, 32.0f, Color{24, 36, 38, 255});
|
|
for (float z = c.y - 16.0f; z <= c.y + 16.0f; z += 8.0f)
|
|
DrawCube({c.x, 0.076f, z}, 72.0f, 0.004f, 0.07f, Color{24, 36, 38, 255});
|
|
|
|
for (const level::Prop& p : game.floor.data().props) {
|
|
if (p.room_kind != "OfficeSuite" || p.destructible) continue;
|
|
ActorModel model = ActorModel::OfficeDesk;
|
|
if (!ModelBank::actor_from_name(p.model, model)) continue;
|
|
const float x = c.x + p.pos.x;
|
|
const float z = c.y + p.pos.y;
|
|
if (!cull.visible(x, 1.0f, z, 3.0f)) continue;
|
|
models_.draw(model, {x, p.y, z}, p.yaw, p.scale, WHITE);
|
|
}
|
|
}
|
|
|
|
void Presenter::draw_floor_environment(const Game& game, const ViewCull& cull) {
|
|
if (!shadow_pass_ && static_env_ready_) {
|
|
// Winding was baked outward in StaticMeshBuilder, so back faces can be
|
|
// culled like every other mesh instead of shading both sides.
|
|
rlEnableBackfaceCulling();
|
|
DrawModel(static_env_model_, Vector3{0.0f, 0.0f, 0.0f}, 1.0f, WHITE);
|
|
}
|
|
|
|
draw_initial_scene(game, cull);
|
|
draw_office_suite(game, cull);
|
|
|
|
const Floor& floor = game.floor;
|
|
const float t = anim_time_;
|
|
const Color dark{42, 42, 48, 255};
|
|
const Color metal{108, 108, 116, 255};
|
|
const Color shelf{92, 92, 100, 255};
|
|
|
|
for (const FloorProp& p : floor.props()) {
|
|
if (!p.room_kind.empty()) continue;
|
|
if (!cull.visible(p.pos.x, p.h * 0.5f, p.pos.y,
|
|
std::max(p.w, p.d) * 0.5f + 1.0f)) continue;
|
|
switch (p.kind) {
|
|
case PropKind::Turnstile:
|
|
DrawCube({p.pos.x, p.h * 0.5f + 0.05f, p.pos.y}, p.w, p.h, p.d, dark);
|
|
break;
|
|
case PropKind::Desk:
|
|
DrawCube({p.pos.x, p.h * 0.5f + 0.05f, p.pos.y}, p.w, p.h, p.d, metal);
|
|
DrawCube({p.pos.x, p.h + 0.07f, p.pos.y}, p.w * 0.94f, 0.06f,
|
|
p.d * 0.9f, Color{150, 148, 140, 255});
|
|
break;
|
|
case PropKind::MeetingTable:
|
|
DrawCube({p.pos.x, p.h * 0.5f + 0.05f, p.pos.y}, p.w, p.h, p.d,
|
|
Color{138, 133, 122, 255});
|
|
break;
|
|
case PropKind::Screen:
|
|
DrawCube({p.pos.x, p.h * 0.5f + 0.05f, p.pos.y}, p.w, p.h, p.d, dark);
|
|
DrawCube({p.pos.x, p.h * 0.5f + 0.05f, p.pos.y + p.d * 0.5f + 0.04f},
|
|
p.w * 0.82f, p.h * 0.62f, 0.06f, Color{245, 197, 24, 255});
|
|
break;
|
|
case PropKind::Seat:
|
|
DrawCube({p.pos.x, p.h * 0.5f + 0.05f, p.pos.y}, p.w, p.h, p.d, shelf);
|
|
break;
|
|
case PropKind::Silo:
|
|
DrawCylinder({p.pos.x, 0.05f, p.pos.y}, p.w, p.w, p.h, 18, dark);
|
|
DrawCylinder({p.pos.x, p.h + 0.05f, p.pos.y}, p.w * 1.06f,
|
|
p.w * 1.06f, 0.22f, 18, Color{20, 170, 200, 255});
|
|
break;
|
|
case PropKind::Shelf:
|
|
DrawCube({p.pos.x, p.h * 0.5f + 0.05f, p.pos.y}, p.w, p.h, p.d, shelf);
|
|
break;
|
|
case PropKind::ArchiveShelf:
|
|
models_.draw(ActorModel::ArchiveShelf,
|
|
{p.pos.x, 0.0f, p.pos.y}, 1.5707963f,
|
|
p.w / 14.1f, WHITE);
|
|
break;
|
|
case PropKind::Pillar:
|
|
DrawCube({p.pos.x, p.h - 0.45f, p.pos.y}, p.w + 0.4f, 0.5f,
|
|
p.d + 0.4f, Color{112, 12, 22, 255});
|
|
DrawCube({p.pos.x - 0.2f, p.h - 0.45f, p.pos.y - (p.d * 0.5f + 0.25f)},
|
|
0.8f, 0.12f, 0.04f, Color{232, 228, 216, 255});
|
|
break;
|
|
case PropKind::Decor: {
|
|
// Authored OoP outfits (e.g. the Hissed Floppy Disk in the
|
|
// Security Booth) carry a model name; everything else in this
|
|
// bucket stays the cheap unmodelled cube.
|
|
ActorModel model = ActorModel::Crate;
|
|
if (!p.model.empty() && models_.actor_from_name(p.model, model)) {
|
|
const float bob = std::sin(anim_time_ * 1.6f + p.pos.x * 0.13f)
|
|
* 0.02f;
|
|
models_.draw(model, {p.pos.x, p.y + bob, p.pos.y}, p.yaw,
|
|
p.scale, WHITE);
|
|
} else {
|
|
DrawCube({p.pos.x, p.h * 0.5f + 0.05f, p.pos.y}, p.w, p.h, p.d,
|
|
Color{128, 126, 122, 255});
|
|
}
|
|
break;
|
|
}
|
|
case PropKind::Beacon:
|
|
// Drawn from game.beacons below so the activated tint is shared.
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Clearance-gated doors. Locked openings get full concrete leaves with a
|
|
// red status bar; stamped doors park the leaves and light the sill green.
|
|
for (const level::Door& d : floor.data().doors) {
|
|
const level::Rect world_rect = level::to_world_rect(floor.data(), d.rect);
|
|
const Vec2 a{world_rect.x0, world_rect.y0};
|
|
const Vec2 b{world_rect.x1, world_rect.y1};
|
|
const float cx = (a.x + b.x) * 0.5f;
|
|
const float cz = (a.y + b.y) * 0.5f;
|
|
const float w = std::fabs(b.x - a.x);
|
|
const float depth = std::fabs(b.y - a.y);
|
|
if (!cull.visible(cx, 1.6f, cz, std::max(w, depth) * 0.5f + 1.0f)) continue;
|
|
const bool along_x = w >= depth;
|
|
const float span = along_x ? w : depth;
|
|
const float thick = along_x ? depth : w;
|
|
auto leaf = [&](float along, float length, float height, float y,
|
|
Color color) {
|
|
DrawCube(along_x ? Vector3{cx + along, y, cz}
|
|
: Vector3{cx, y, cz + along},
|
|
along_x ? length : thick, height,
|
|
along_x ? thick : length, color);
|
|
};
|
|
|
|
// Fixed frame, always present: two jambs and a header.
|
|
for (const float side : {-1.0f, 1.0f}) {
|
|
leaf(side * span * 0.5f, 0.24f, 3.5f, 1.75f,
|
|
Color{74, 80, 86, 255});
|
|
}
|
|
leaf(0.0f, span + 0.24f, 0.26f, 3.45f, Color{58, 62, 68, 255});
|
|
|
|
if (floor.door_open(static_cast<int>(d.id))) {
|
|
// Leaves retracted into the jambs, green status bar and lit sill.
|
|
for (const float side : {-1.0f, 1.0f}) {
|
|
leaf(side * (span * 0.5f - 0.14f), 0.28f, 3.1f, 1.55f,
|
|
Color{92, 104, 96, 255});
|
|
}
|
|
leaf(0.0f, span * 0.92f, 0.16f, 2.45f, Color{70, 210, 120, 255});
|
|
leaf(0.0f, span, 0.06f, 0.07f, Color{52, 180, 104, 220});
|
|
} else {
|
|
// Solid slab: two dark leaves, a hot seam and a red status bar.
|
|
for (const float side : {-1.0f, 1.0f}) {
|
|
leaf(side * span * 0.25f, span * 0.49f, 3.1f, 1.55f,
|
|
Color{52, 54, 60, 255});
|
|
}
|
|
leaf(0.0f, 0.10f, 3.1f, 1.55f, Color{150, 28, 36, 255});
|
|
leaf(0.0f, span * 0.92f, 0.16f, 2.45f, Color{220, 48, 58, 255});
|
|
leaf(0.0f, span, 0.06f, 0.07f, Color{170, 26, 34, 200});
|
|
}
|
|
}
|
|
|
|
// Control-style thermo door frames at the four main room connections.
|
|
// Frames are scaled across the gap only; panels stay 4 m tall and sit
|
|
// retracted into the jambs, so the passage is always walkable.
|
|
auto thermo_prop = [&](ActorModel id, float x, float z, float yaw,
|
|
Vector3 stretch) {
|
|
models_.draw(id, {x, 0.0f, z}, yaw, 1.0f, WHITE, 0.0f, false,
|
|
0.0f, 0.0f, 0.0f, 0.0f, stretch);
|
|
};
|
|
for (const level::ThermoDoor& d : floor.data().thermo) {
|
|
const Vec2 center = level::to_world(floor.data(), d.pos);
|
|
const float span = d.span * floor.data().scale;
|
|
if (!cull.visible(center.x, 2.3f, center.y, span * 0.5f + 1.0f))
|
|
continue;
|
|
thermo_prop(ActorModel::ThermoFrame, center.x, center.y, d.yaw,
|
|
{span / 8.0f, 1.0f, 1.0f});
|
|
for (const float side : {-1.0f, 1.0f}) {
|
|
const float off = side * span * 0.6f;
|
|
thermo_prop(ActorModel::ThermoPanel,
|
|
center.x + std::cos(d.yaw) * off,
|
|
center.y - std::sin(d.yaw) * off,
|
|
d.yaw, {span * 0.5f / 3.7f, 1.0f, 1.0f});
|
|
}
|
|
}
|
|
|
|
// Ritual anchors: TV and Light Switch are in the Plaza; the Projector is
|
|
// in the Projector Room (Floor 01's signature OoP ritual).
|
|
if (cull.visible(game.ritual_system.tv_pos().x, 1.0f, game.ritual_system.tv_pos().y, 2.5f))
|
|
models_.draw(ActorModel::TV,
|
|
{game.ritual_system.tv_pos().x, 0.0f, game.ritual_system.tv_pos().y},
|
|
0.0f, 1.0f, WHITE);
|
|
if (cull.visible(game.ritual_system.switch_pos().x, 0.5f,
|
|
game.ritual_system.switch_pos().y, 1.0f))
|
|
models_.draw(ActorModel::Switch,
|
|
{game.ritual_system.switch_pos().x, 0.0f,
|
|
game.ritual_system.switch_pos().y},
|
|
0.0f, 1.0f, WHITE);
|
|
{
|
|
const Vec2 p = game.ritual_system.projector_pos();
|
|
if (cull.visible(p.x, 1.0f, p.y, game.ritual_system.projector_radius() + 1.0f)) {
|
|
const bool projector_ritual =
|
|
game.ritual_system.type() == RitualType::Projector;
|
|
const Color projector_color =
|
|
projector_ritual && game.ritual_system.complete()
|
|
? Color{255, 245, 200, 255}
|
|
: projector_ritual && game.ritual_system.active()
|
|
? Color{245, 197, 24, 255}
|
|
: Color{165, 130, 220, 255};
|
|
DrawCube({p.x, 1.0f, p.y}, 2.4f, 1.6f, 1.8f, projector_color);
|
|
DrawCylinder({p.x, 0.09f, p.y}, game.ritual_system.projector_radius(),
|
|
game.ritual_system.projector_radius(), 0.02f, 18,
|
|
Color{190, 150, 255, 60});
|
|
}
|
|
}
|
|
|
|
// Beacons: inert and grey until walked over, then diffuse bright red.
|
|
// The floor disc shows the proximity trigger and pulses once active.
|
|
for (const BeaconSystem::BeaconState& b : game.beacons.beacons()) {
|
|
if (!cull.visible(b.pos.x, 2.5f, b.pos.y, 4.0f)) continue;
|
|
// Activated: near-white-hot red core plus a strong emissive bloom.
|
|
const Color tint = b.active ? Color{255, 100, 100, 255} : WHITE;
|
|
const float glow = b.active ? 2.4f : 0.0f;
|
|
models_.draw(ActorModel::Beacon, {b.pos.x, 0.0f, b.pos.y}, b.yaw,
|
|
b.scale, tint, 0.0f, false, 0.0f, 0.0f, 0.0f,
|
|
b.active ? 0.36f : 0.22f, // dark-red Hiss wave, not a blackout
|
|
{0.0f, 0.0f, 0.0f}, 1.0f, glow);
|
|
const float pulse = b.active ? 0.85f + 0.15f * std::sin(t * 3.0f) : 1.0f;
|
|
const Color disc = b.active
|
|
? Color{255, 40, 45, static_cast<unsigned char>(95 * pulse)}
|
|
: Color{150, 158, 160, 45};
|
|
DrawCylinder({b.pos.x, 0.09f, b.pos.y}, BeaconSystem::kActivationRadius,
|
|
BeaconSystem::kActivationRadius, 0.02f, 24, disc);
|
|
}
|
|
}
|
|
|
|
void Presenter::draw_environment(const Game& game, const ViewCull& cull) {
|
|
const float arena = game.config.arena_half;
|
|
const float corruption = game.corruption.value();
|
|
|
|
// All concrete (floor, curbs, pillars, door frame) is one merged, triplanar
|
|
// mesh using the same 2K PBR maps as the Blender diorama.
|
|
concrete_.draw(corruption, camera_.position);
|
|
const bool concrete_fallback = !concrete_.ready();
|
|
if (concrete_fallback) {
|
|
if (floor_mode_) {
|
|
DrawCube({0.0f, -0.5f, 0.0f}, Floor::kWidth + 8.0f, 1.0f,
|
|
Floor::kHeight + 8.0f, Color{43, 43, 47, 255});
|
|
} else {
|
|
DrawCube({0.0f, -0.5f, 0.0f}, arena * 2.0f + 40.0f, 1.0f,
|
|
arena * 2.0f + 40.0f, Color{43, 43, 47, 255});
|
|
}
|
|
}
|
|
|
|
if (floor_mode_) {
|
|
draw_floor_environment(game, cull);
|
|
return;
|
|
}
|
|
|
|
// Signal-red carpet runners: deep pile, worn lanes and panel seams.
|
|
const Color carpet{112, 12, 22, 255};
|
|
const Color carpet_edge{62, 6, 12, 255};
|
|
DrawCube({0.0f, 0.03f, 5.0f}, 6.0f, 0.06f, 26.0f, carpet);
|
|
DrawCube({0.0f, 0.034f, 11.0f}, 26.0f, 0.068f, 5.0f, carpet);
|
|
DrawCube({-2.82f, 0.033f, 5.0f}, 0.34f, 0.066f, 26.0f, carpet_edge);
|
|
DrawCube({2.82f, 0.033f, 5.0f}, 0.34f, 0.066f, 26.0f, carpet_edge);
|
|
DrawCube({0.0f, 0.036f, 8.4f}, 26.0f, 0.072f, 0.34f, carpet_edge);
|
|
DrawCube({0.0f, 0.036f, 13.6f}, 26.0f, 0.072f, 0.34f, carpet_edge);
|
|
for (float z = -6.0f; z <= 16.0f; z += 4.0f) {
|
|
DrawCube({0.0f, 0.061f, z}, 5.7f, 0.004f, 0.05f,
|
|
Color{66, 7, 13, 255});
|
|
}
|
|
for (float x = -11.0f; x <= 11.0f; x += 4.0f) {
|
|
DrawCube({x, 0.07f, 11.0f}, 0.06f, 0.004f, 4.6f,
|
|
Color{66, 7, 13, 255});
|
|
}
|
|
for (float x : {-1.35f, 1.35f}) {
|
|
DrawCube({x, 0.063f, 5.0f}, 0.7f, 0.003f, 24.0f,
|
|
Color{90, 9, 17, 255});
|
|
}
|
|
const float carpet_scuffs[][4] = {
|
|
{-1.2f, -2.0f, 0.75f, 0.6f}, {1.5f, 2.4f, 0.55f, 0.5f},
|
|
{-0.9f, 7.5f, 0.9f, 0.7f}, {1.1f, 13.5f, 0.65f, 0.6f},
|
|
{-2.0f, 16.0f, 0.5f, 0.5f}, {-6.5f, 11.0f, 0.8f, 0.6f},
|
|
{4.0f, 11.0f, 0.7f, 0.5f}, {8.5f, 11.0f, 0.9f, 0.7f},
|
|
};
|
|
for (const auto& s : carpet_scuffs) {
|
|
DrawCylinder({s[0], 0.067f, s[1]}, s[2], s[2] * 1.2f, 0.006f, 9,
|
|
Color{64, 6, 13, static_cast<unsigned char>(120 * s[3])});
|
|
}
|
|
|
|
// S16: the expanded floor's north-west wing — an open-plan Research room.
|
|
// A teal-grey carpet island, tiled seams and a red approach runner connect
|
|
// it to the hub; everything sits below the tactical camera so the new
|
|
// furniture silhouettes stay readable.
|
|
const layout::Room& room = layout::kOpenRoom;
|
|
const float rx0 = room.cx - room.hx;
|
|
const float rx1 = room.cx + room.hx;
|
|
const float rz0 = room.cz - room.hz;
|
|
const float rz1 = room.cz + room.hz;
|
|
DrawCube({room.cx * 0.5f, 0.024f, 0.0f}, -room.cx, 0.048f, 6.0f, carpet);
|
|
DrawCube({room.cx, 0.024f, room.cz * 0.5f}, 6.0f, 0.048f, room.cz, carpet);
|
|
DrawCube({room.cx, 0.028f, room.cz}, room.hx * 2.0f, 0.056f,
|
|
room.hz * 2.0f, Color{34, 48, 50, 255});
|
|
for (float x = rx0; x <= rx1; x += 9.5f) {
|
|
DrawCube({x, 0.059f, room.cz}, 0.07f, 0.004f, room.hz * 2.0f,
|
|
Color{24, 36, 38, 255});
|
|
}
|
|
for (float z = rz0; z <= rz1; z += 9.5f) {
|
|
DrawCube({room.cx, 0.059f, z}, room.hx * 2.0f, 0.004f, 0.07f,
|
|
Color{24, 36, 38, 255});
|
|
}
|
|
DrawCube({room.cx, 0.062f, rz0 + 1.2f}, room.hx * 2.0f, 0.006f, 0.5f,
|
|
carpet_edge);
|
|
for (float z = rz0 + 10.0f; z < rz1; z += 14.0f) {
|
|
DrawCylinder({room.cx, 0.064f, z}, 5.2f, 5.2f, 0.02f, 12,
|
|
Color{216, 210, 188, 24});
|
|
}
|
|
// Rugs under the meeting and lounge islands keep the teal slab from
|
|
// reading as one flat expanse; cable trays run down the service aisles.
|
|
const Color rug{84, 18, 26, 255};
|
|
DrawCube({-48.0f, 0.068f, 52.0f}, 17.0f, 0.024f, 9.0f, rug);
|
|
DrawCube({-48.0f, 0.071f, 52.0f}, 15.8f, 0.006f, 7.8f,
|
|
Color{58, 10, 18, 255});
|
|
for (const float z : {34.0f, 68.0f}) {
|
|
DrawCube({-37.0f, 0.068f, z}, 11.0f, 0.024f, 7.0f, rug);
|
|
}
|
|
for (const float z : {40.0f, 52.0f, 64.0f}) {
|
|
DrawCube({(rx0 + rx1) * 0.5f, 0.067f, z}, rx1 - rx0 - 4.0f,
|
|
0.014f, 0.16f, Color{22, 24, 26, 255});
|
|
}
|
|
for (float x = rx0 + 6.0f; x < rx1; x += 14.0f) {
|
|
DrawCube({x, 1.52f, rz1 - 0.30f}, 2.4f, 0.09f, 0.08f,
|
|
Color{235, 230, 205, 255});
|
|
DrawCylinder({x, 0.075f, rz1 - 3.0f}, 3.0f, 3.0f, 0.02f, 10,
|
|
Color{235, 230, 205, 14});
|
|
if (x < room.cx - 6.0f || x > room.cx + 6.0f) {
|
|
DrawCube({x, 1.38f, rz0 + 0.30f}, 2.4f, 0.09f, 0.08f,
|
|
Color{235, 230, 205, 255});
|
|
}
|
|
}
|
|
|
|
// Spilled toner / scorched stains and redacted paper scraps break up the
|
|
// otherwise uniform concrete without touching the tactical lanes.
|
|
// The same scuff language continues across the expanded slab so the far
|
|
// sectors carry detail when the camera follows the player out of the hub.
|
|
|
|
// Perimeter curbs (the textured versions live in ConcreteMaterial).
|
|
if (concrete_fallback) {
|
|
const Color wall{58, 58, 64, 255};
|
|
DrawCube({0.0f, 0.6f, -(arena + 1.0f)}, arena * 2.0f + 4.0f, 1.2f, 1.0f, wall);
|
|
DrawCube({0.0f, 0.6f, arena + 1.0f}, arena * 2.0f + 4.0f, 1.2f, 1.0f, wall);
|
|
DrawCube({-(arena + 1.0f), 0.6f, 0.0f}, 1.0f, 1.2f, arena * 2.0f + 4.0f, wall);
|
|
DrawCube({arena + 1.0f, 0.6f, 0.0f}, 1.0f, 1.2f, arena * 2.0f + 4.0f, wall);
|
|
}
|
|
|
|
// Outer service band: the textured floor continues past the play curb, so
|
|
// dress it with dark plant blocks and dim spill. A player hugging a wall
|
|
// then sees more facility instead of an empty unlit void.
|
|
if (!shadow_pass_ && static_env_ready_) {
|
|
// Winding was baked outward in StaticMeshBuilder, so back faces can be
|
|
// culled like every other mesh instead of shading both sides.
|
|
rlEnableBackfaceCulling();
|
|
DrawModel(static_env_model_, Vector3{0.0f, 0.0f, 0.0f}, 1.0f, WHITE);
|
|
}
|
|
|
|
// Low partitions, entrance signage and door stripes are baked into the
|
|
// static mesh above; only the animated dressing stays per-frame here.
|
|
|
|
// Fluorescent strips live at curb height — the tactical camera sits above
|
|
// the room, so a real ceiling would only occlude the play field. The z=-8
|
|
// row is dead: the sector is failing as containment decays. The
|
|
// lightswitch ritual (§2.3) revives it when it completes.
|
|
const bool lights_revived =
|
|
game.ritual_system.type() == RitualType::Lightswitch
|
|
&& game.ritual_system.complete();
|
|
for (const float z : {-96.0f, -64.0f, -32.0f, -16.0f, -8.0f,
|
|
0.0f, 8.0f, 16.0f, 32.0f, 64.0f, 96.0f}) {
|
|
const bool dead = ((z == -8.0f && !lights_revived)
|
|
|| (z == 16.0f && corruption > 0.7f));
|
|
for (const float x : {-arena, arena}) {
|
|
const float inward = x > 0.0f ? -1.0f : 1.0f;
|
|
DrawCube({x, 1.22f, z}, 0.7f, 0.16f, 6.0f, Color{22, 22, 25, 255});
|
|
DrawCube({x + inward * 0.36f, 1.22f, z}, 0.06f, 0.07f, 5.6f,
|
|
dead ? Color{90, 26, 28, 255} : Color{205, 202, 186, 255});
|
|
if (!dead) {
|
|
DrawCylinder({x + inward * 2.2f, 0.05f, z}, 2.6f, 2.6f,
|
|
0.02f, 12, Color{220, 214, 190, 10});
|
|
}
|
|
}
|
|
}
|
|
|
|
// Lightswitch prop (§2.3): a wall plate at the lightswitch, near the dead
|
|
// beam strip — reads bright once the lightswitch ritual is complete.
|
|
models_.draw(ActorModel::Switch,
|
|
{game.ritual_system.switch_pos().x, 0.0f, game.ritual_system.switch_pos().y},
|
|
0.0f, 1.0f,
|
|
lights_revived ? Color{240, 230, 180, 255} : WHITE);
|
|
|
|
// Ambient Hiss spill widens as the House decays.
|
|
const unsigned char hiss_alpha =
|
|
static_cast<unsigned char>(std::min<int>(70, 12 + corruption * 28));
|
|
DrawCylinder({-arena + 4.0f, 0.07f, -10.0f}, 3.2f, 3.2f, 0.02f, 12,
|
|
Color{190, 20, 30, static_cast<unsigned char>(hiss_alpha / 2)});
|
|
|
|
// Pillars with Hiss bands, dark bases and redacted signage. Central ring
|
|
// keeps its original detail; the outer grid marks the expanded floor.
|
|
auto draw_pillar = [&](const layout::Anchor& a, bool central,
|
|
std::size_t i, float scale) {
|
|
const Vector3 pos{a.x, a.y, a.z};
|
|
const float w = 2.0f * scale;
|
|
const float h = 4.0f * scale;
|
|
if (concrete_fallback) {
|
|
DrawCube({pos.x, a.y, pos.z}, w, h, w, Color{66, 66, 72, 255});
|
|
DrawCube({pos.x, 0.22f, pos.z}, w + 0.5f, 0.44f, w + 0.5f,
|
|
Color{28, 28, 32, 255});
|
|
}
|
|
DrawCube({pos.x, 2.55f, pos.z}, w + 0.46f, 0.5f, w + 0.46f, carpet);
|
|
if (central && i < 4) {
|
|
DrawCube({pos.x, 3.35f, pos.z - 1.03f}, 1.3f, 0.42f, 0.05f,
|
|
Color{232, 228, 216, 255});
|
|
DrawCube({pos.x - 0.2f, 3.35f, pos.z - 1.07f}, 0.7f, 0.1f, 0.02f,
|
|
Color{17, 17, 17, 255});
|
|
}
|
|
};
|
|
for (std::size_t i = 0; i < std::size(layout::kCentralPillars); ++i) {
|
|
draw_pillar(layout::kCentralPillars[i], true, i, 1.0f);
|
|
}
|
|
for (std::size_t i = 0; i < std::size(layout::kMidPillars); ++i) {
|
|
draw_pillar(layout::kMidPillars[i], false, i, 1.1f);
|
|
}
|
|
for (std::size_t i = 0; i < std::size(layout::kOuterPillars); ++i) {
|
|
draw_pillar(layout::kOuterPillars[i], false, i, 1.2f);
|
|
}
|
|
|
|
// S11: Objects of Power + set dressing. Sculpted GLBs share the actor
|
|
// shader; fixed placements keep the tactical lanes clear.
|
|
const float t = anim_time_;
|
|
// Objects of Power get a restrained idle so they feel alive without
|
|
// pulling focus from combat. Furniture (cabinets/crates) stays planted.
|
|
models_.draw(ActorModel::Hotline,
|
|
{-15.0f, std::sin(t * 2.3f) * 0.012f, 16.0f},
|
|
std::atan2(15.0f, -16.0f) + std::sin(t * 1.1f) * 0.05f,
|
|
1.0f, WHITE);
|
|
const unsigned char flick = static_cast<unsigned char>(
|
|
235.0f + 20.0f * (0.5f + 0.5f * std::sin(t * 13.0f) * std::sin(t * 5.0f)));
|
|
models_.draw(ActorModel::TV, {13.0f, 0.0f, 17.0f},
|
|
std::atan2(-13.0f, -17.0f) + std::sin(t * 0.8f) * 0.025f,
|
|
1.0f,
|
|
game.ritual_system.complete() ? Color{255, 250, 220, 255}
|
|
: Color{flick, flick, flick, 255});
|
|
models_.draw(ActorModel::Pedestal, {-7.0f, 0.0f, 10.5f}, 0.0f,
|
|
1.0f + std::sin(t * 1.6f) * 0.012f, WHITE);
|
|
models_.draw(ActorModel::Duck,
|
|
{7.0f, std::sin(t * 2.0f) * 0.025f, 10.5f},
|
|
std::sin(t * 1.4f) * 0.09f, 1.0f, WHITE);
|
|
for (const float z : {-6.0f, -4.4f, -2.8f}) {
|
|
models_.draw(ActorModel::Cabinet, {21.5f, 0.0f, z}, -1.5708f,
|
|
1.0f, WHITE);
|
|
}
|
|
models_.draw(ActorModel::Crate, {18.0f, 0.0f, 6.0f}, 0.4f, 1.0f, WHITE);
|
|
models_.draw(ActorModel::Crate, {-17.5f, 0.0f, 3.0f}, -0.7f, 1.0f, WHITE);
|
|
models_.draw(ActorModel::Crate, {16.0f, 0.0f, -12.0f}, 1.1f, 1.0f, WHITE);
|
|
// Denser centre-adjacent dressing; the carpet cross and combat lanes stay
|
|
// clear, but the arena no longer reads as an empty floor.
|
|
models_.draw(ActorModel::Crate, {-11.0f, 0.0f, 8.0f}, 0.25f, 0.85f, WHITE);
|
|
models_.draw(ActorModel::Crate, {11.5f, 0.0f, 4.0f}, -0.5f, 0.9f, WHITE);
|
|
models_.draw(ActorModel::Cabinet, {-21.6f, 0.0f, -4.0f}, 1.5708f,
|
|
1.0f, WHITE);
|
|
models_.draw(ActorModel::Cabinet, {-21.6f, 0.0f, -2.6f}, 1.5708f,
|
|
1.0f, WHITE);
|
|
const float debris_specs[][4] = {
|
|
{-14.0f, 0.35f, 9.0f, 1.2f}, {15.0f, 0.35f, -7.0f, 0.3f},
|
|
{-12.0f, 0.35f, -12.0f, 2.1f},
|
|
};
|
|
const float debris_scales[] = {0.6f, 0.65f, 0.55f};
|
|
for (int i = 0; i < 3; ++i) {
|
|
const auto& d = debris_specs[i];
|
|
models_.draw(ActorModel::Debris,
|
|
{d[0], d[1] + std::sin(t * 0.9f + i * 2.1f) * 0.035f, d[2]},
|
|
d[3] + t * 0.12f, debris_scales[i], WHITE);
|
|
}
|
|
// Hiss-corrupted slabs drift slowly above the playfield (reference art).
|
|
const float slabs[][4] = {
|
|
{14.0f, 4.6f, 12.0f, 0.0f}, {-13.0f, 5.2f, 7.0f, 1.7f},
|
|
{9.0f, 3.8f, -13.0f, 0.6f}, {-9.0f, 4.2f, -10.0f, 2.3f},
|
|
};
|
|
for (const auto& s : slabs) {
|
|
const float bob = std::sin(anim_time_ * 0.7f + s[3]) * 0.18f;
|
|
models_.draw(ActorModel::Debris, {s[0], s[1] + bob, s[2]},
|
|
anim_time_ * 0.08f + s[3], 1.0f, WHITE);
|
|
}
|
|
|
|
// S16: the open-plan room is furnished with the Blender room kit. Models
|
|
// face +Z; chairs face back across the desk and the meeting table.
|
|
auto prop = [&](ActorModel id, float x, float y, float z, float yaw,
|
|
float scale = 1.0f) {
|
|
models_.draw(id, {x, y, z}, yaw, scale, WHITE);
|
|
};
|
|
for (const float z : {34.0f, 46.0f, 58.0f}) {
|
|
for (int i = 0; i < 6; ++i) {
|
|
const float x = -88.0f + i * 6.0f;
|
|
prop(ActorModel::OfficeDesk, x, 0.0f, z, 0.0f);
|
|
prop(ActorModel::Computer, x, 0.76f, z - 0.16f, 0.0f);
|
|
prop(ActorModel::OfficeChair, x, 0.0f, z + 1.55f, 3.14159f);
|
|
}
|
|
for (const float x : {-85.0f, -67.0f}) {
|
|
prop(ActorModel::Partition, x, 0.0f, z + 3.0f, 0.0f);
|
|
}
|
|
}
|
|
prop(ActorModel::MeetingTable, -48.0f, 0.0f, 52.0f, 0.0f);
|
|
for (const float x : {-52.0f, -50.0f, -48.0f, -46.0f, -44.0f}) {
|
|
prop(ActorModel::OfficeChair, x, 0.0f, 50.3f, 0.0f);
|
|
prop(ActorModel::OfficeChair, x, 0.0f, 53.7f, 3.14159f);
|
|
}
|
|
prop(ActorModel::Sofa, -37.0f, 0.0f, 34.0f, 0.0f);
|
|
prop(ActorModel::Sofa, -37.0f, 0.0f, 68.0f, 3.14159f);
|
|
prop(ActorModel::FloorLamp, -33.0f, 0.0f, 30.5f, 0.0f);
|
|
prop(ActorModel::FloorLamp, -33.0f, 0.0f, 72.0f, 0.0f);
|
|
prop(ActorModel::FloorLamp, -92.0f, 0.0f, 52.0f, 0.0f);
|
|
const float plant_specs[][2] = {
|
|
{-96.0f, 28.0f}, {-28.5f, 28.0f}, {-96.0f, 76.0f}, {-28.5f, 76.0f},
|
|
{-74.0f, 30.0f}, {-56.0f, 66.0f}, {-46.0f, 42.0f}, {-73.0f, 75.0f},
|
|
};
|
|
for (const auto& p : plant_specs) {
|
|
prop(ActorModel::Plant, p[0], 0.0f, p[1], 0.0f, 1.0f);
|
|
}
|
|
for (const float z : {40.0f, 43.0f, 46.0f}) {
|
|
prop(ActorModel::Cabinet, -26.6f, 0.0f, z, -1.5708f);
|
|
}
|
|
prop(ActorModel::Crate, -94.0f, 0.0f, 70.0f, 0.4f);
|
|
prop(ActorModel::Crate, -94.0f, 0.0f, 67.5f, -0.7f, 0.9f);
|
|
|
|
// Satellite work islands break up the rest of the 260 m slab so the
|
|
// expanded floor reads as a facility, not an empty parking lot.
|
|
const float islands[][2] = {
|
|
{50.0f, 44.0f}, {-46.0f, -52.0f}, {58.0f, -48.0f},
|
|
{-52.0f, 64.0f}, {18.0f, 78.0f}, {-80.0f, -22.0f},
|
|
};
|
|
for (const auto& isle : islands) {
|
|
DrawCube({isle[0], 0.018f, isle[1]}, 12.0f, 0.036f, 7.0f,
|
|
Color{86, 16, 24, 255});
|
|
for (int i = 0; i < 3; ++i) {
|
|
const float x = isle[0] - 3.4f + i * 3.4f;
|
|
prop(ActorModel::OfficeDesk, x, 0.0f, isle[1] - 0.8f, 0.0f, 0.9f);
|
|
prop(ActorModel::Computer, x, 0.70f, isle[1] - 0.95f, 0.0f, 0.9f);
|
|
prop(ActorModel::OfficeChair, x, 0.0f, isle[1] + 0.6f, 3.14159f);
|
|
}
|
|
prop(ActorModel::Plant, isle[0] - 5.2f, 0.0f, isle[1] + 2.8f, 0.0f);
|
|
prop(ActorModel::FloorLamp, isle[0] + 5.2f, 0.0f, isle[1] + 2.8f, 0.0f);
|
|
}
|
|
|
|
// Scattered grime patches break up the slab's flat colour.
|
|
const Vector3 grime[] = {{-9.0f, 0.0f, -7.0f}, {8.0f, 0.0f, -14.0f},
|
|
{-16.0f, 0.0f, 9.0f}, {14.0f, 0.0f, 4.0f}};
|
|
for (const Vector3& g : grime) {
|
|
DrawCylinder({g.x, 0.016f, g.z}, 1.6f, 1.8f, 0.01f, 9, Color{30, 30, 33, 70});
|
|
}
|
|
}
|
|
|
|
namespace {
|
|
|
|
// Small FBC placard that only reveals itself when the player walks up to it.
|
|
void draw_inspection_placard(Vector2 screen, const char* title,
|
|
const char* sub, Color accent) {
|
|
const int w = std::max(MeasureText(title, 12), MeasureText(sub, 11)) + 18;
|
|
const int x = static_cast<int>(screen.x) - w / 2;
|
|
const int y = static_cast<int>(screen.y) - 36;
|
|
DrawRectangle(x, y, w, 34, Color{10, 10, 12, 215});
|
|
DrawRectangleLines(x, y, w, 34, Color{accent.r, accent.g, accent.b, 180});
|
|
DrawText(title, x + 9, y + 3, 12, accent);
|
|
DrawText(sub, x + 9, y + 18, 11, Color{205, 200, 190, 220});
|
|
}
|
|
|
|
} // namespace
|
|
|
|
void Presenter::draw_blackout_labels(const Game& game) {
|
|
const BlackoutSequence& b = game.blackout;
|
|
const Vec2 p = game.player.pos;
|
|
|
|
// No placards over the phone tables — the ringing desks read the puzzle on
|
|
// their own. The one world label left is the OoP case, lifted to clear its
|
|
// doubled-height roof.
|
|
if (b.phase() == BlackoutPhase::CaseRevealed &&
|
|
distance(p, b.case_pos()) < 9.0f) {
|
|
const Vec2 c = b.case_pos();
|
|
const Vector2 s = GetWorldToScreen({c.x, 5.6f, c.y}, camera_);
|
|
draw_inspection_placard(s, "OBJECT OF POWER", "LIGHT SWITCH / CLASS IV",
|
|
Color{245, 197, 24, 255});
|
|
}
|
|
}
|
|
|
|
// Inside the projector screen the House goes dark: only the agent, the ringing
|
|
// phone tables and (once earned) the glass case survive the blackout.
|
|
void Presenter::draw_blackout(Game& game) {
|
|
const BlackoutSequence& b = game.blackout;
|
|
const Vec2 p = game.player.pos;
|
|
const Vec2 centre = b.screen_pos();
|
|
|
|
DrawCube({centre.x, -0.09f, centre.y + 10.0f}, 52.0f, 0.12f, 46.0f,
|
|
Color{17, 18, 22, 255});
|
|
|
|
const Vector3 cam_fwd = Vector3Normalize(
|
|
Vector3Subtract(camera_.target, camera_.position));
|
|
const Vector3 cam_right = Vector3Normalize(
|
|
Vector3CrossProduct(cam_fwd, camera_.up));
|
|
const Vector3 cam_up = Vector3CrossProduct(cam_right, cam_fwd);
|
|
|
|
QuadBatch glow_batch;
|
|
const Texture2D glow_tex = spr_glow_.id != 0 ? spr_glow_ : soft_disc_;
|
|
glow_batch.begin(glow_tex);
|
|
|
|
for (int i = 0; i < BlackoutSequence::kPhoneCount; ++i) {
|
|
const Vec2 q = b.phone(i);
|
|
const bool answered = b.phone_answered(i);
|
|
const float pulse = 0.5f + 0.5f * std::sin(anim_time_ * 4.0f + i * 0.7f);
|
|
const float ring_flash = answered ? 0.0f : 0.10f + 0.25f * pulse;
|
|
models_.draw(ActorModel::PhoneTable, {q.x, 0.0f, q.y}, 0.0f, 0.78f,
|
|
answered ? Color{80, 80, 86, 255} : WHITE, ring_flash,
|
|
false, 0.0f, 0.0f, anim_time_ * (answered ? 0.2f : 1.2f));
|
|
if (!answered) {
|
|
// The GLB is authored 1.5x; the ring hugs the desk instead of
|
|
// dwarfing it, and the glows ride the taller handset.
|
|
DrawCylinder({q.x, 0.04f, q.y}, 1.1f, 1.1f, 0.012f, 12,
|
|
Color{255, 45, 55, static_cast<unsigned char>(70 + 40 * pulse)});
|
|
glow_batch.add_billboard({q.x, 1.4f, q.y}, 3.6f, 3.6f,
|
|
cam_right, cam_up,
|
|
Color{255, 80, 90, 200});
|
|
glow_batch.add_ground({q.x, 0.02f, q.y}, 1.7f,
|
|
Color{220, 30, 40, 85});
|
|
}
|
|
}
|
|
|
|
if (b.phase() == BlackoutPhase::CaseRevealed) {
|
|
const Vec2 c = b.case_pos();
|
|
models_.draw(ActorModel::CaseFrame, {c.x, 0.0f, c.y}, 0.0f, 1.5f, WHITE);
|
|
models_.draw(ActorModel::Switch, {c.x, 0.0f, c.y}, 0.0f, 4.4f,
|
|
WHITE, 0.0f, false, 0.0f, 0.0f, 0.0f, 0.55f);
|
|
// Glass last, blended, with the switch visible through the panes.
|
|
// Frame/glass GLBs are authored 2x larger; only this draw scale is used.
|
|
models_.draw(ActorModel::CaseGlass, {c.x, 0.0f, c.y}, 0.0f, 1.5f,
|
|
Color{190, 225, 235, 255}, 0.0f, false, 0.0f, 0.0f, 0.0f,
|
|
0.0f, {0.0f, 0.0f, 0.0f}, 0.30f);
|
|
DrawCylinder({c.x, 0.06f, c.y}, 6.0f, 6.0f, 0.02f, 24,
|
|
Color{245, 197, 24, 120});
|
|
glow_batch.add_billboard({c.x, 2.6f, c.y}, 9.0f, 9.0f,
|
|
cam_right, cam_up, Color{245, 197, 24, 70});
|
|
}
|
|
|
|
const float player_yaw = std::atan2(game.player.facing.x,
|
|
game.player.facing.y);
|
|
models_.draw(ActorModel::Guard, {p.x, 0.0f, p.y}, player_yaw, 1.0f,
|
|
WHITE, game.player.hit_flash, true);
|
|
glow_batch.add_ground({p.x, 0.02f, p.y}, 1.1f, Color{245, 197, 24, 70});
|
|
glow_batch.draw();
|
|
}
|
|
|
|
void Presenter::draw_shadow_map(const Game& game, bool enabled) {
|
|
shadows_active_ = enabled && shadow_map_.ready() && !game.blackout.active();
|
|
if (!shadows_active_) return;
|
|
|
|
const Vec2 focus = game.player.pos;
|
|
shadow_map_.update(focus);
|
|
shadow_map_.begin();
|
|
models_.begin_shadow_frame(anim_time_);
|
|
models_.set_depth_pass(true);
|
|
concrete_.set_depth_pass(true);
|
|
shadow_pass_ = true;
|
|
ViewCull cull;
|
|
cull.init_ortho(shadow_map_.camera(), ShadowMap::kExtent, 200.0f);
|
|
draw_environment(game, cull);
|
|
dressing_.draw(models_, anim_time_, focus);
|
|
models_.draw_shadow(ActorModel::Guard, {focus.x, 0.0f, focus.y},
|
|
player_yaw_, 1.0f, player_walk_, 0.0f, anim_time_);
|
|
for (const Enemy& e : game.enemy_system.enemies) {
|
|
const float dx = e.pos.x - focus.x;
|
|
const float dz = e.pos.y - focus.y;
|
|
if (dx * dx + dz * dz > 45.0f * 45.0f) continue;
|
|
const Vec2 dir = focus - e.pos;
|
|
const bool mold = e.type == EnemyType::MoldSpore;
|
|
float yaw = std::atan2(dir.x, dir.y);
|
|
if (!mold) yaw += std::sin(e.bob_phase * 3.0f) * 0.11f;
|
|
const float bob = std::sin(e.bob_phase) * (mold ? 0.02f : 0.08f);
|
|
const ActorModel model = mold ? ActorModel::MoldSpore
|
|
: (e.type == EnemyType::HissBrute ? ActorModel::HissBrute
|
|
: (e.type == EnemyType::HissGhost ? ActorModel::HissGhost
|
|
: ActorModel::HissStaff));
|
|
models_.draw_shadow(model, {e.pos.x, bob, e.pos.y}, yaw, 1.0f,
|
|
std::min(1.0f, e.speed / 4.5f),
|
|
enemy_stagger(e), e.bob_phase);
|
|
}
|
|
shadow_pass_ = false;
|
|
concrete_.set_depth_pass(false);
|
|
models_.set_depth_pass(false);
|
|
shadow_map_.end();
|
|
}
|
|
|
|
void Presenter::draw_scene(Game& game) {
|
|
for (int i = 0; i < game.events.count; ++i) {
|
|
const GameEvent& e = game.events.items[i];
|
|
if (e.type == EventType::PlayerDamaged) {
|
|
shake_ = std::max(shake_, 0.45f);
|
|
damage_flash_ = 1.0f;
|
|
spawn_sparks(e.pos, 1.0f, Color{255, 80, 70, 255}, 6, 3.0f);
|
|
} else if (e.type == EventType::SkillCast) {
|
|
DEBUG_TRACE(debug::Events,
|
|
"SkillCast flags=%u pos=%.1f %.1f r=%.1f", e.flags,
|
|
e.pos.x, e.pos.y, e.magnitude);
|
|
// Each skill has its own telegraph palette: pale concrete dust,
|
|
// astral-teal containment, Board-yellow light. The red Hiss wave
|
|
// is reserved for corruption events.
|
|
const bool concrete = (e.flags & kCastConcrete) != 0;
|
|
const bool warp = (e.flags & kCastWarp) != 0;
|
|
const bool fluorescent = (e.flags & kCastFluorescent) != 0;
|
|
const bool push = (e.flags & kCastPush) != 0;
|
|
// Keep the landing marker alive until the heap actually lands
|
|
// (~0.38 s gather + travel at 17 m/s from skills.cpp).
|
|
const float flight = 0.38f + distance(game.player.pos, e.pos) / 17.0f;
|
|
if (fluorescent) {
|
|
spawn_sparks(e.pos, 0.8f, Color{245, 220, 120, 255}, 24, 4.2f);
|
|
spawn_skill_ring(e.pos, e.magnitude * 0.4f, e.magnitude, 0.9f,
|
|
Color{245, 220, 120, 210}, 0.0f, 0.16f);
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y},
|
|
std::max(1.0f, e.magnitude), 1.4f, anim_time_,
|
|
Color{245, 220, 120, 255});
|
|
shake_ = std::max(shake_, 0.12f);
|
|
} else if (warp) {
|
|
spawn_sparks(e.pos, 0.6f, Color{78, 201, 176, 255}, 22, 3.4f);
|
|
spawn_skill_ring(e.pos, e.magnitude, e.magnitude * 0.45f, 0.9f,
|
|
Color{78, 201, 176, 225}, 0.0f, 0.18f);
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y},
|
|
std::max(1.0f, e.magnitude), 1.2f, anim_time_,
|
|
Color{78, 201, 176, 255});
|
|
} else if (push) {
|
|
// PUSH reads as one outward shockwave: charged rubble sweeps a
|
|
// ring off the floor, two expanding dust rings and a warm ground
|
|
// pulse travel with it. The same debris pool as CALL is reused.
|
|
concrete_debris_.burst_ring(
|
|
e.pos, e.magnitude, 28, Color{228, 198, 156, 255});
|
|
spawn_push_shards(e.pos, e.magnitude);
|
|
spawn_sparks(e.pos, 0.35f, Color{236, 214, 170, 255}, 30, 6.0f);
|
|
spawn_skill_ring(e.pos, e.magnitude * 0.18f,
|
|
e.magnitude * 1.25f, 0.55f,
|
|
Color{226, 198, 150, 235}, 0.0f, 0.16f);
|
|
spawn_skill_ring(e.pos, e.magnitude * 0.06f,
|
|
e.magnitude * 0.95f, 0.38f,
|
|
Color{252, 238, 208, 200}, 0.0f, 0.36f);
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y},
|
|
e.magnitude * 1.35f, 0.9f, anim_time_,
|
|
Color{224, 198, 150, 255});
|
|
shake_ = std::max(shake_, 0.34f);
|
|
} else {
|
|
concrete_debris_.burst(game.player.pos, 1.2f, 8);
|
|
spawn_sparks(game.player.pos, 0.35f, Color{195, 190, 178, 255},
|
|
14, 2.8f);
|
|
spawn_skill_ring(e.pos, e.magnitude * 0.5f, e.magnitude, flight,
|
|
Color{205, 200, 188, 200}, 0.0f, 0.13f);
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y},
|
|
std::max(1.0f, e.magnitude), flight,
|
|
anim_time_, Color{195, 190, 178, 255});
|
|
}
|
|
// All three skills shake nearby surfaces loose: paper + rock
|
|
// debris flies off shelves, tables and garbage cans while the
|
|
// props themselves stay put.
|
|
shed_surface_debris(game.player.pos, push ? e.magnitude : 5.0f);
|
|
if (distance(e.pos, game.player.pos) > 1.0f) {
|
|
shed_surface_debris(e.pos, std::max(4.0f, e.magnitude));
|
|
}
|
|
// Fluorescent and PUSH already placed their own ground pulse above.
|
|
if (!fluorescent && !warp && !concrete && !push) {
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y},
|
|
std::max(1.0f, e.magnitude), 0.55f, anim_time_);
|
|
}
|
|
shake_ = std::max(shake_, 0.08f);
|
|
} else if (e.type == EventType::WarpBurst) {
|
|
DEBUG_TRACE(debug::Events, "WarpBurst pos=%.1f %.1f r=%.1f",
|
|
e.pos.x, e.pos.y, e.magnitude);
|
|
// The sim removes the field the same tick it bursts, so these
|
|
// presentation-only rings carry the collapse payoff.
|
|
spawn_skill_ring(e.pos, e.magnitude * 0.9f, e.magnitude * 0.05f,
|
|
0.38f, Color{64, 223, 255, 245}, 0.0f, 0.30f);
|
|
spawn_skill_ring(e.pos, e.magnitude * 0.4f, e.magnitude * 1.35f,
|
|
0.60f, Color{78, 201, 176, 220}, 0.0f, 0.18f);
|
|
trails_.push_back({{e.pos.x, 0.55f, e.pos.y},
|
|
Color{150, 255, 235, 255}, 0.0f, 0.35f, 4.0f});
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y},
|
|
std::max(1.0f, e.magnitude) * 1.2f, 1.2f,
|
|
anim_time_, Color{78, 201, 176, 255});
|
|
spawn_sparks(e.pos, 0.9f, Color{120, 240, 220, 255}, 24, 5.2f);
|
|
shed_surface_debris(e.pos, std::max(4.0f, e.magnitude));
|
|
shake_ = std::max(shake_, 0.30f);
|
|
} else if (e.type == EventType::BlackoutStart) {
|
|
shake_ = std::max(shake_, 0.3f);
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y}, 6.0f, 1.6f, anim_time_);
|
|
spawn_sparks(e.pos, 1.6f, Color{255, 60, 70, 255}, 18, 4.0f);
|
|
} else if (e.type == EventType::BlackoutPhone) {
|
|
spawn_sparks(e.pos, 1.0f, Color{255, 70, 80, 255}, 10, 3.0f);
|
|
shake_ = std::max(shake_, 0.06f);
|
|
} else if (e.type == EventType::BlackoutCase) {
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y}, 3.0f, 4.0f, anim_time_);
|
|
spawn_sparks(e.pos, 1.6f, Color{245, 197, 24, 255}, 26, 4.5f);
|
|
} else if (e.type == EventType::BlackoutComplete) {
|
|
shake_ = std::max(shake_, 0.35f);
|
|
spawn_sparks(e.pos, 1.8f, Color{255, 240, 190, 255}, 32, 5.0f);
|
|
} else if (e.type == EventType::EnemyKilled) {
|
|
shake_ = std::max(shake_, 0.10f);
|
|
spawn_sparks(e.pos, 0.9f, Color{255, 60, 50, 255}, 8, 3.4f);
|
|
} else if (e.type == EventType::WeaponFired) {
|
|
const Vec2 aim = e.pos - game.player.pos;
|
|
const int tier = static_cast<int>(e.magnitude);
|
|
muzzle_flash_ = 0.09f;
|
|
muzzle_flash_pos_ = {e.pos.x, kMuzzleHeight, e.pos.y};
|
|
muzzle_flash_yaw_ = std::atan2(aim.x, aim.y);
|
|
muzzle_flash_tier_ = tier;
|
|
fire_pose_ = 0.20f;
|
|
shake_ = std::max(shake_, 0.015f + 0.015f * e.magnitude);
|
|
spawn_sparks(e.pos, kMuzzleHeight,
|
|
tier >= 2 ? Color{255, 110, 60, 235}
|
|
: Color{255, 220, 150, 235},
|
|
2 + tier, 1.8f);
|
|
} else if (e.type == EventType::AreaDetonation) {
|
|
DEBUG_TRACE(debug::Events, "AreaDetonation flags=%u pos=%.1f %.1f r=%.1f",
|
|
e.flags, e.pos.x, e.pos.y, e.magnitude);
|
|
const float radius = std::max(1.0f, e.magnitude);
|
|
Vector3 origins[16];
|
|
const int destroyed = dressing_.destroy_in_radius(
|
|
e.pos, radius, origins, static_cast<int>(std::size(origins)));
|
|
if (destroyed > 0) {
|
|
debris_.burst(e.pos, 0.9f, radius, origins, destroyed,
|
|
std::min(36, 8 + static_cast<int>(radius * 3.0f)
|
|
+ destroyed * 3));
|
|
}
|
|
const bool concrete_blast = (e.flags & kDetonateConcrete) != 0;
|
|
if (concrete_blast) {
|
|
concrete_debris_.burst(
|
|
e.pos, radius,
|
|
std::min(34, 16 + static_cast<int>(radius * 4.0f)));
|
|
// Dust rolls out from the impact rather than a Hiss burn mark.
|
|
spawn_skill_ring(e.pos, radius * 0.35f, radius * 1.55f, 0.85f,
|
|
Color{198, 193, 181, 190}, 0.0f, 0.20f);
|
|
spawn_skill_ring(e.pos, radius * 0.8f, radius * 1.2f, 0.55f,
|
|
Color{225, 220, 208, 150}, 0.0f, 0.28f);
|
|
// The impact shakes nearby furniture as well as the floor.
|
|
shed_surface_debris(e.pos, radius);
|
|
spawn_sparks(e.pos, 0.25f, Color{198, 193, 181, 255}, 16, 3.8f);
|
|
}
|
|
scorch_.add(e.pos, radius * 0.6f,
|
|
concrete_blast ? Color{116, 112, 104, 70}
|
|
: Color{72, 22, 26, 82});
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y}, radius * 1.6f,
|
|
1.7f, anim_time_,
|
|
concrete_blast ? Color{195, 190, 178, 255}
|
|
: Color{66, 4, 7, 255});
|
|
shake_ = std::max(shake_, 0.24f);
|
|
spawn_sparks(e.pos, 0.9f, Color{255, 130, 70, 255}, 14, 4.8f);
|
|
} else if (e.type == EventType::TierUp) {
|
|
shake_ = std::max(shake_, 0.60f);
|
|
tier_wave_pending_ = true;
|
|
spawn_sparks(game.player.pos, 0.8f, Color{255, 210, 90, 255}, 12, 4.0f);
|
|
} else if (e.type == EventType::BeaconActivated) {
|
|
spawn_sparks(e.pos, 1.6f, Color{255, 60, 60, 255}, 18, 3.2f);
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y}, 5.0f, 1.6f, anim_time_);
|
|
} else if (e.type == EventType::BeaconsComplete) {
|
|
shake_ = std::max(shake_, 0.45f);
|
|
tier_wave_pending_ = true;
|
|
spawn_sparks(e.pos, 1.4f, Color{255, 70, 70, 255}, 24, 4.5f);
|
|
} else if (e.type == EventType::EnemyHit) {
|
|
if (damage_numbers_.size() < 48) {
|
|
damage_numbers_.push_back(
|
|
{e.pos + Vec2{static_cast<float>(GetRandomValue(-8, 8)) / 20.0f,
|
|
static_cast<float>(GetRandomValue(-8, 8)) / 20.0f},
|
|
e.magnitude, 0.0f});
|
|
}
|
|
spawn_sparks(e.pos, 1.1f, Color{255, 240, 200, 255}, 3, 2.4f);
|
|
}
|
|
}
|
|
shake_ = std::max(0.0f, shake_ - 0.06f);
|
|
const float frame_dt = GetFrameTime();
|
|
anim_time_ += frame_dt;
|
|
ascension_clock_ += frame_dt;
|
|
aura_.update(frame_dt);
|
|
damage_flash_ = std::max(0.0f, damage_flash_ - frame_dt * 2.2f);
|
|
for (DamageNumber& n : damage_numbers_) n.age += frame_dt;
|
|
damage_numbers_.erase(
|
|
std::remove_if(damage_numbers_.begin(), damage_numbers_.end(),
|
|
[](const DamageNumber& n) { return n.age > 0.8f; }),
|
|
damage_numbers_.end());
|
|
for (Spark& s : sparks_) {
|
|
s.age += frame_dt;
|
|
s.pos.x += s.vel.x * frame_dt;
|
|
s.pos.y += s.vel.y * frame_dt;
|
|
s.pos.z += s.vel.z * frame_dt;
|
|
s.vel.y -= 9.0f * frame_dt;
|
|
s.vel.x *= 0.96f;
|
|
s.vel.z *= 0.96f;
|
|
if (s.pos.y < 0.08f) {
|
|
s.pos.y = 0.08f;
|
|
s.vel.y *= -0.3f;
|
|
}
|
|
}
|
|
sparks_.erase(std::remove_if(sparks_.begin(), sparks_.end(),
|
|
[](const Spark& s) { return s.age > s.life; }),
|
|
sparks_.end());
|
|
fire_pose_ = std::max(0.0f, fire_pose_ - frame_dt);
|
|
muzzle_flash_ = std::max(0.0f, muzzle_flash_ - frame_dt);
|
|
trail_clock_ -= frame_dt;
|
|
for (RoundTrail& tr : trails_) tr.age += frame_dt;
|
|
trails_.erase(std::remove_if(trails_.begin(), trails_.end(),
|
|
[](const RoundTrail& tr) { return tr.age > tr.life; }),
|
|
trails_.end());
|
|
for (SkillRing& r : skill_rings_) r.age += frame_dt;
|
|
skill_rings_.erase(
|
|
std::remove_if(skill_rings_.begin(), skill_rings_.end(),
|
|
[](const SkillRing& r) { return r.age > r.life; }),
|
|
skill_rings_.end());
|
|
for (PushShard& s : push_shards_) {
|
|
s.age += frame_dt;
|
|
s.pos.x += s.vel.x * frame_dt;
|
|
s.pos.y += s.vel.y * frame_dt;
|
|
s.pos.z += s.vel.z * frame_dt;
|
|
s.vel.y -= 11.0f * frame_dt;
|
|
s.vel.x *= 0.98f;
|
|
s.vel.z *= 0.98f;
|
|
if (s.pos.y < 0.10f) {
|
|
s.pos.y = 0.10f;
|
|
s.vel.y = 0.0f;
|
|
}
|
|
s.yaw += s.spin * frame_dt;
|
|
}
|
|
push_shards_.erase(
|
|
std::remove_if(push_shards_.begin(), push_shards_.end(),
|
|
[](const PushShard& s) { return s.age > s.life; }),
|
|
push_shards_.end());
|
|
debris_.update(frame_dt, game.corruption.value());
|
|
concrete_debris_.update(frame_dt);
|
|
|
|
const float sx = static_cast<float>(GetRandomValue(-100, 100)) / 100.0f * shake_;
|
|
const float sy = static_cast<float>(GetRandomValue(-100, 100)) / 100.0f * shake_;
|
|
const Vec2 p = game.player.pos;
|
|
// Keep the arena rim out of frame when the player hugs a wall — showing
|
|
// the unlit floor beyond the curb breaks the contained-facility illusion.
|
|
const float margin = 10.0f;
|
|
const float bound_x = floor_mode_ ? Floor::kWidth * 0.5f - margin
|
|
: game.config.arena_half - margin;
|
|
const float bound_z = floor_mode_ ? Floor::kHeight * 0.5f - margin
|
|
: game.config.arena_half - margin;
|
|
const float cx = std::clamp(p.x, -bound_x, bound_x);
|
|
const float cz = std::clamp(p.y, -bound_z, bound_z);
|
|
if (floor_overview_) {
|
|
camera_.position = {0.0f, Floor::kHeight * 1.23f, 0.01f};
|
|
camera_.target = {0.0f, 0.0f, 0.0f};
|
|
} else if (hiss_test_) {
|
|
camera_.position = {0.0f, 3.4f, 3.2f};
|
|
camera_.target = {0.0f, 1.4f, -4.0f};
|
|
} else {
|
|
camera_.position = {cx + sx * 0.6f, tuning_.height + sy * 0.4f,
|
|
cz + tuning_.forward};
|
|
camera_.target = {cx + sx * 0.3f, 0.0f, cz};
|
|
}
|
|
camera_.fovy = tuning_.fov;
|
|
ViewCull cull;
|
|
cull.init(camera_, static_cast<float>(GetScreenWidth())
|
|
/ static_cast<float>(std::max(1, GetScreenHeight())),
|
|
Floor::kWidth * 2.0f);
|
|
if (tier_wave_pending_) {
|
|
// Reusable scene wave: also callable for boss entrances / events.
|
|
aura_.spawn_ground({p.x, 0.09f, p.y}, 11.0f, 2.6f, anim_time_);
|
|
tier_wave_pending_ = false;
|
|
}
|
|
|
|
models_.begin_frame(anim_time_, game.corruption.value(), camera_.position);
|
|
aura_.begin_frame(anim_time_, game.corruption.value());
|
|
concrete_.set_shadow(shadow_map_, shadows_active_);
|
|
models_.set_shadow(shadow_map_, shadows_active_);
|
|
|
|
BeginMode3D(camera_);
|
|
|
|
QuadBatch shadow_batch;
|
|
shadow_batch.begin(soft_disc_);
|
|
QuadBatch glow_batch;
|
|
const Texture2D glow = spr_glow_.id != 0 ? spr_glow_ : soft_disc_;
|
|
glow_batch.begin(glow);
|
|
const Vector3 cam_fwd = Vector3Normalize(
|
|
Vector3Subtract(camera_.target, camera_.position));
|
|
const Vector3 cam_right = Vector3Normalize(
|
|
Vector3CrossProduct(cam_fwd, camera_.up));
|
|
const Vector3 cam_up = Vector3CrossProduct(cam_right, cam_fwd);
|
|
|
|
if (game.blackout.active()) {
|
|
draw_blackout(game);
|
|
EndMode3D();
|
|
draw_blackout_labels(game);
|
|
return;
|
|
}
|
|
|
|
draw_environment(game, cull);
|
|
scorch_.draw(camera_.position);
|
|
dressing_.draw(models_, anim_time_, {cx, cz});
|
|
|
|
// Blob shadows sit under every actor — batched into one quad draw.
|
|
shadow_batch.add_ground({p.x, 0.02f, p.y}, 0.8f * 1.15f,
|
|
Color{0, 0, 0, 80});
|
|
for (const Enemy& e : game.enemy_system.enemies) {
|
|
if (!cull.visible(e.pos.x, 0.1f, e.pos.y, e.radius)) continue;
|
|
shadow_batch.add_ground({e.pos.x, 0.02f, e.pos.y},
|
|
e.radius * 0.85f * 1.15f,
|
|
Color{0, 0, 0, 80});
|
|
}
|
|
|
|
// Hiss corruption is now baked into the human Resonant models
|
|
// (build_enemies.py) and animated by the actor shader — no detached
|
|
// aura blob. Only event ground waves remain here.
|
|
rlDisableDepthMask();
|
|
aura_.draw_ground_waves();
|
|
rlEnableDepthMask();
|
|
|
|
// Player: the sim owns facing (aim direction while firing, motion otherwise).
|
|
const Vec2 moved = p - last_player_pos_;
|
|
last_player_pos_ = p;
|
|
const float aim_yaw = std::atan2(game.player.facing.x,
|
|
game.player.facing.y);
|
|
const float delta = std::atan2(std::sin(aim_yaw - player_yaw_),
|
|
std::cos(aim_yaw - player_yaw_));
|
|
const float turn = game.player.aim_hold > 0.0f ? 22.0f : 7.0f;
|
|
player_yaw_ += delta * std::min(1.0f, frame_dt * turn);
|
|
|
|
// Speed from distance / time rather than raw per-frame delta: stable
|
|
// when the fixed-step sim runs zero or several ticks in one render.
|
|
const float raw_speed = frame_dt > 1e-5f ? length(moved) / frame_dt : 0.0f;
|
|
const float ref_speed = std::max(0.01f, game.player.stats.move_speed);
|
|
const float target_walk = std::clamp(raw_speed / ref_speed, 0.0f, 1.0f);
|
|
const float walk_k = target_walk > player_walk_ ? 12.0f : 7.0f;
|
|
player_walk_ += (target_walk - player_walk_) *
|
|
(1.0f - std::exp(-walk_k * frame_dt));
|
|
|
|
// Hysteresis keeps a player scraping a wall from flapping Idle <-> Run
|
|
// every frame, which was the main source of the visible stutter.
|
|
if (!player_running_ && player_walk_ > 0.28f) player_running_ = true;
|
|
else if (player_running_ && player_walk_ < 0.12f) player_running_ = false;
|
|
|
|
// The dash burst is only 0.16 s; hold its lean a little longer so the
|
|
// pose reads, then cross-fade back into locomotion.
|
|
if (game.player.dash_timer > 0.0f && dash_prev_ <= 0.0f) dash_pose_ = 0.42f;
|
|
dash_prev_ = game.player.dash_timer;
|
|
dash_pose_ = std::max(0.0f, dash_pose_ - frame_dt);
|
|
|
|
const float player_flash = actor_flash(game.player.hit_flash, 4.0f);
|
|
// The Blender agent carries its own root bob; the old sine bob would
|
|
// double up on top of the skeletal Run/Idle clips. Damage never changes
|
|
// the clip: hits only tint the actor, the walk keeps playing and the
|
|
// simulation never stops the player.
|
|
const char* agent_clip = "Idle";
|
|
if (dash_pose_ > 0.0f) agent_clip = "Dash";
|
|
else if (fire_pose_ > 0.0f) agent_clip = "Fire";
|
|
else if (player_running_) agent_clip = "Run";
|
|
models_.update_animation(ActorModel::Guard, agent_clip, frame_dt, 0.12f);
|
|
// No stagger uniform for the player: a full-body recoil reads as the
|
|
// character freezing up on enemy contact. Only the red flash remains.
|
|
models_.draw(ActorModel::Guard, {p.x, 0.0f, p.y}, player_yaw_, 1.0f,
|
|
WHITE, player_flash, true, player_walk_, 0.0f,
|
|
anim_time_);
|
|
|
|
// Enemies face the player; Hiss units add a nervous jitter.
|
|
for (const Enemy& e : game.enemy_system.enemies) {
|
|
if (!cull.visible(e.pos.x, 1.0f, e.pos.y, e.radius + 0.6f)) continue;
|
|
const Vec2 dir = p - e.pos;
|
|
float yaw = std::atan2(dir.x, dir.y);
|
|
const bool mold = e.type == EnemyType::MoldSpore;
|
|
if (!mold) yaw += std::sin(e.bob_phase * 3.0f) * 0.11f;
|
|
const float bob = std::sin(e.bob_phase) * (mold ? 0.02f : 0.08f);
|
|
const ActorModel model = mold ? ActorModel::MoldSpore
|
|
: (e.type == EnemyType::HissBrute ? ActorModel::HissBrute
|
|
: (e.type == EnemyType::HissGhost ? ActorModel::HissGhost
|
|
: ActorModel::HissStaff));
|
|
const float flash = actor_flash(e.hit_flash, 6.0f);
|
|
const float walk = std::min(1.0f, e.speed / 4.5f);
|
|
models_.draw(model, {e.pos.x, bob, e.pos.y}, yaw, 1.0f, WHITE,
|
|
flash, !mold, walk, enemy_stagger(e), e.bob_phase,
|
|
enemy_hiss(e));
|
|
}
|
|
|
|
// CONCRETE CALL: a rough heap of slabs gathered around the agent, then
|
|
// hurled at the nearest crowd. Three orbiting slabs read as one pile.
|
|
for (const ConcretePile& pile : game.skill_system.piles) {
|
|
if (!cull.visible(pile.pos.x, 1.0f, pile.pos.y, 3.0f)) continue;
|
|
const bool flying = pile.phase == PilePhase::Flight;
|
|
const float flight = flying
|
|
? std::min(1.0f, pile.phase_time
|
|
/ std::max(0.01f, pile.phase_duration))
|
|
: 0.0f;
|
|
// Keep the heap off the floor at both ends of the arc so it never
|
|
// looks like it pops out of / into the concrete.
|
|
const float height = 0.28f + std::sin(flight * 3.14159265f) * 1.5f;
|
|
const float spin = anim_time_ * 3.2f + pile.pos.x * 0.7f;
|
|
const float scale = 0.34f + 0.56f * pile.size;
|
|
// Three rubble heaps drift inward while gathering, then resolve to
|
|
// one solid pile that flies at the crowd. Reuses the existing
|
|
// concrete debris GLB (enhanced in build_props.py).
|
|
const int pieces = (!flying && pile.size < 0.95f) ? 3 : 1;
|
|
for (int k = 0; k < pieces; ++k) {
|
|
const float a = spin + k * 2.0943951f;
|
|
const float drift = pieces == 1 ? 0.0f
|
|
: (1.0f - pile.size) * 1.6f;
|
|
const Vector3 center = {
|
|
pile.pos.x + std::cos(a) * drift,
|
|
height + std::sin(spin + k * 1.7f) * 0.08f * pile.size,
|
|
pile.pos.y + std::sin(a) * drift,
|
|
};
|
|
// Tint down the pale fallback material so the heap reads as
|
|
// concrete, not a white boulder, at tactical camera distance.
|
|
models_.draw(ActorModel::Debris, center, a, scale,
|
|
Color{182, 177, 166, 255});
|
|
}
|
|
// A short dust wake makes the throw legible at tactical distance.
|
|
if (flying) {
|
|
const Vec2 dir = normalized(pile.target - pile.pos);
|
|
for (int k = 1; k <= 3; ++k) {
|
|
const float back = 0.35f * static_cast<float>(k);
|
|
glow_batch.add_billboard(
|
|
{pile.pos.x - dir.x * back, height - 0.12f,
|
|
pile.pos.y - dir.y * back},
|
|
0.75f - 0.12f * k, 0.75f - 0.12f * k,
|
|
cam_right, cam_up,
|
|
Color{196, 191, 179, static_cast<unsigned char>(100 - k * 20)});
|
|
}
|
|
}
|
|
}
|
|
|
|
// WARP: shrinking containment rings, tethers and a bright core pull the
|
|
// eye (and the locked crowd) into the collapse centre.
|
|
for (const WarpField& field : game.skill_system.warps) {
|
|
if (!cull.visible(field.pos.x, 1.0f, field.pos.y, field.radius)) continue;
|
|
const float t = std::clamp(
|
|
field.timer / std::max(0.01f, field.duration), 0.0f, 1.0f);
|
|
const float r = field.radius * (1.0f - 0.55f * t);
|
|
const Color outer{78, 201, 176,
|
|
static_cast<unsigned char>(230 - 55 * t)};
|
|
const Color inner{64, 223, 255,
|
|
static_cast<unsigned char>(215 - 40 * t)};
|
|
const Vector3 center{field.pos.x, 0.18f - 0.06f * t, field.pos.y};
|
|
const float spin = t * 2.0f;
|
|
DrawCircle3D(center, r, Vector3{0.0f, 1.0f, 0.0f}, spin, outer);
|
|
DrawCircle3D(center, r * 0.965f, Vector3{0.0f, 1.0f, 0.0f},
|
|
spin, Color{outer.r, outer.g, outer.b,
|
|
static_cast<unsigned char>(outer.a / 2)});
|
|
DrawCircle3D(center, r * 0.58f, Vector3{0.0f, 1.0f, 0.0f},
|
|
-spin * 0.7f, inner);
|
|
int tethers = 0;
|
|
for (const Enemy& e : game.enemy_system.enemies) {
|
|
if (e.hp <= 0.0f) continue;
|
|
if (field.mark != 0 && e.warp_mark != field.mark) continue;
|
|
if (distance(e.pos, field.pos) > field.radius) continue;
|
|
DrawLine3D({e.pos.x, 0.38f, e.pos.y},
|
|
{field.pos.x, 0.38f + 0.35f * t, field.pos.y},
|
|
Color{78, 201, 176,
|
|
static_cast<unsigned char>(150 * (1.0f - t))});
|
|
if (++tethers >= 12) break;
|
|
}
|
|
glow_batch.add_billboard(
|
|
{field.pos.x, 0.30f + 0.18f * t, field.pos.y},
|
|
1.3f + 1.1f * t, 1.3f + 1.1f * t, cam_right, cam_up,
|
|
Color{120, 240, 220,
|
|
static_cast<unsigned char>(110 + 110 * t)});
|
|
}
|
|
|
|
// PUSH: pieces of the same shattered-concrete GLB the CALL heap uses,
|
|
// tumbling outward with the shockwave before fading into the dust.
|
|
for (const PushShard& s : push_shards_) {
|
|
if (!cull.visible(s.pos.x, 0.5f, s.pos.z, 0.8f)) continue;
|
|
const float t = std::clamp(s.age / std::max(0.01f, s.life),
|
|
0.0f, 1.0f);
|
|
const float fade = 1.0f - t * t;
|
|
models_.draw(ActorModel::Debris, s.pos, s.yaw, s.size,
|
|
Color{228, 198, 156, 255}, 0.0f, false, 0.0f, 0.0f,
|
|
0.0f, 0.0f, {0.0f, 0.0f, 0.0f}, fade);
|
|
}
|
|
|
|
// Telegraphs, dust puffs and post-collapse implosions.
|
|
for (const SkillRing& r : skill_rings_) {
|
|
if (!cull.visible(r.pos.x, r.height, r.pos.y, r.radius)) continue;
|
|
const float t = std::clamp(r.age / std::max(0.01f, r.life), 0.0f, 1.0f);
|
|
const float eased = t * t * (3.0f - 2.0f * t);
|
|
const float radius = std::max(
|
|
0.05f, r.radius + (r.end_radius - r.radius) * eased);
|
|
Color color = r.color;
|
|
color.a = static_cast<unsigned char>(
|
|
static_cast<float>(r.color.a) * (1.0f - t));
|
|
Color echo = color;
|
|
echo.a = static_cast<unsigned char>(color.a / 2);
|
|
// A paired inner circle gives the 1 px line circle some visual
|
|
// weight without needing a mesh or a shader pass.
|
|
DrawCircle3D({r.pos.x, r.height, r.pos.y}, radius,
|
|
Vector3{0.0f, 1.0f, 0.0f}, r.spin, color);
|
|
DrawCircle3D({r.pos.x, r.height + 0.01f, r.pos.y},
|
|
radius * 0.965f, Vector3{0.0f, 1.0f, 0.0f},
|
|
r.spin, echo);
|
|
}
|
|
|
|
// Enemy drops: small cyan Resonance crystals, spun by the crystal rig.
|
|
for (const XpShard& s : game.pickup_system.shards) {
|
|
if (!cull.visible(s.pos.x, 0.25f, s.pos.y, 0.6f)) continue;
|
|
const float dx = s.pos.x - cx, dz = s.pos.y - cz;
|
|
const float dist_sq = dx * dx + dz * dz;
|
|
if (dist_sq > 62.0f * 62.0f) continue;
|
|
const float spin = anim_time_ * 2.6f + s.pos.x * 0.7f;
|
|
const float bob = std::sin(spin * 1.3f) * 0.035f;
|
|
glow_batch.add_billboard({s.pos.x, 0.22f + bob, s.pos.y},
|
|
0.62f, 0.62f, cam_right, cam_up,
|
|
Color{70, 225, 255, 110});
|
|
if (dist_sq <= 20.0f * 20.0f) {
|
|
models_.draw(ActorModel::Shard, {s.pos.x, 0.18f + bob, s.pos.y},
|
|
spin, 0.7f, WHITE, 0.0f, false, 0.0f, 0.0f,
|
|
anim_time_ + s.pos.x * 0.7f);
|
|
}
|
|
}
|
|
|
|
// World objects of power: small camera-facing glows (§4.6).
|
|
for (int i = 0; i < game.buff_system.world_object_count(); ++i) {
|
|
const WorldObject& obj = game.buff_system.world_object(i);
|
|
if (!cull.visible(obj.pos.x, 0.75f, obj.pos.y, 0.8f)) continue;
|
|
glow_batch.add_billboard({obj.pos.x, 0.75f, obj.pos.y},
|
|
0.45f, 0.45f, cam_right, cam_up,
|
|
world_object_color(obj));
|
|
}
|
|
|
|
for (const RoundTrail& tr : trails_) {
|
|
if (!cull.visible(tr.pos.x, tr.pos.y, tr.pos.z, tr.size)) continue;
|
|
const float fade = 1.0f - tr.age / tr.life;
|
|
Color tint = tr.color;
|
|
tint.a = static_cast<unsigned char>(190.0f * fade * fade);
|
|
const float size = tr.size * (0.35f + 0.65f * fade);
|
|
glow_batch.add_billboard(tr.pos, size, size, cam_right, cam_up, tint);
|
|
}
|
|
|
|
const bool emit_trail = trail_clock_ <= 0.0f;
|
|
for (const Projectile& pr : game.weapon_system.projectiles) {
|
|
const Vector3 round_pos{pr.pos.x, kMuzzleHeight, pr.pos.y};
|
|
if (!cull.visible(round_pos.x, round_pos.y, round_pos.z, 1.4f)) continue;
|
|
const float s = projectile_size(pr.source) * (1.0f + 0.22f * pr.tier);
|
|
const ActorModel model = pr.tier >= 2 ? ActorModel::RoundOvercharge
|
|
: pr.tier == 1 ? ActorModel::RoundTuned
|
|
: ActorModel::RoundBasic;
|
|
const float yaw = std::atan2(pr.vel.x, pr.vel.y);
|
|
const float base_scale = pr.source == WeaponType::Charge ? 0.85f
|
|
: pr.source == WeaponType::Projector ? 0.75f
|
|
: 1.0f;
|
|
models_.draw(model, round_pos, yaw,
|
|
base_scale * (1.0f + 0.12f * pr.tier), WHITE,
|
|
0.0f, false, 0.0f, 0.0f,
|
|
anim_time_ * 7.0f + pr.pos.x, 0.0f);
|
|
const float glow_size = s * (2.2f + 0.5f * pr.tier);
|
|
glow_batch.add_billboard(round_pos, glow_size, glow_size, cam_right,
|
|
cam_up, projectile_color(pr.source, pr.tier));
|
|
if (emit_trail && trails_.size() < 220) {
|
|
trails_.push_back({round_pos, projectile_color(pr.source, pr.tier),
|
|
0.0f, 0.22f, s * 0.8f});
|
|
}
|
|
}
|
|
if (emit_trail) trail_clock_ = 0.03f;
|
|
|
|
if (muzzle_flash_ > 0.0f) {
|
|
const float k = muzzle_flash_ / 0.09f;
|
|
const float scale = (0.60f + 0.18f * muzzle_flash_tier_)
|
|
* (0.55f + 0.45f * k);
|
|
models_.draw(ActorModel::MuzzleFlash, muzzle_flash_pos_,
|
|
muzzle_flash_yaw_, scale, WHITE, 0.0f, false, 0.0f,
|
|
0.0f, anim_time_ * 14.0f, 0.0f);
|
|
const float flare = (0.85f + 0.25f * muzzle_flash_tier_) * k;
|
|
glow_batch.add_billboard(muzzle_flash_pos_, flare, flare, cam_right,
|
|
cam_up, Color{255, 228, 170, 210});
|
|
}
|
|
|
|
// Light particles from hits, kills and tier-ups — camera-facing glows.
|
|
for (const Spark& s : sparks_) {
|
|
if (!cull.visible(s.pos.x, s.pos.y, s.pos.z, s.size)) continue;
|
|
const float fade = 1.0f - s.age / s.life;
|
|
Color tint = s.color;
|
|
tint.a = static_cast<unsigned char>(255.0f * fade * fade);
|
|
glow_batch.add_billboard(s.pos, s.size, s.size,
|
|
cam_right, cam_up, tint);
|
|
}
|
|
|
|
debris_.draw(camera_.position);
|
|
concrete_debris_.draw(camera_.position);
|
|
|
|
// Ambient Hiss risers. There is deliberately no roof mesh: from a
|
|
// 16 m tactical camera a ceiling would hide the whole play area. The
|
|
// figure climbs a few metres, thins into the red haze and is gone
|
|
// before it can loom over the player or mask a crowd. Anchors hug room
|
|
// walls (init) so the beat reads at the edge of the frame, not on top
|
|
// of the combat.
|
|
auto draw_riser = [&](const Ascension& a, float cycle, float phase) {
|
|
const float t = std::fmod(ascension_clock_ / cycle + phase, 1.0f);
|
|
// Roughly a five-second appearance every half-minute or so — a
|
|
// visual tidbit you stumble across, not a recurring encounter.
|
|
if (t < 0.06f || t > 0.22f) return;
|
|
const float rise = std::clamp((t - 0.06f) / 0.10f, 0.0f, 1.0f);
|
|
const float ease = 1.0f - (1.0f - rise) * (1.0f - rise);
|
|
const float height = ease * 4.6f
|
|
+ std::max(0.0f, t - 0.16f) * 30.0f;
|
|
const float fade_in = std::clamp((t - 0.06f) / 0.025f, 0.0f, 1.0f);
|
|
const float fade_out = std::clamp((0.22f - t) / 0.06f, 0.0f, 1.0f);
|
|
const float alpha = std::min(fade_in, fade_out) * 0.92f;
|
|
if (!cull.visible(a.pos.x, height + 1.0f, a.pos.y, 1.6f)) return;
|
|
const float hiss = 0.45f + 0.25f * game.corruption.value();
|
|
models_.draw(ActorModel::Ascended,
|
|
{a.pos.x, height, a.pos.y},
|
|
a.yaw + ascension_clock_ * 0.11f, a.scale, WHITE,
|
|
0.0f, false, 0.0f, 0.0f, a.yaw, hiss,
|
|
{0.0f, 0.0f, 0.0f}, alpha, 0.16f);
|
|
// The scorch-red bloom it left on the floor fades as it climbs.
|
|
const unsigned char ground_a = static_cast<unsigned char>(
|
|
150.0f * (1.0f - rise) * fade_in);
|
|
glow_batch.add_ground({a.pos.x, 0.04f, a.pos.y}, 1.7f,
|
|
Color{190, 18, 30, ground_a});
|
|
glow_batch.add_ground({a.pos.x, 0.05f, a.pos.y}, 0.9f,
|
|
Color{255, 48, 52,
|
|
static_cast<unsigned char>(ground_a * 0.7f)});
|
|
// A thin red veil from floor to figure sells the upward pull; it
|
|
// doubles as the Hiss haze in the reference image.
|
|
glow_batch.add_billboard({a.pos.x, height * 0.5f, a.pos.y},
|
|
0.85f, std::max(0.7f, height),
|
|
cam_right, cam_up,
|
|
Color{180, 22, 30,
|
|
static_cast<unsigned char>(ground_a * 0.22f)});
|
|
glow_batch.add_billboard({a.pos.x, height + 0.9f, a.pos.y},
|
|
2.1f, 2.6f, cam_right, cam_up,
|
|
Color{180, 24, 34,
|
|
static_cast<unsigned char>(alpha * 46.0f)});
|
|
};
|
|
if (ascension_test_) {
|
|
// QA entry: one figure a few metres off the agent in the plaza,
|
|
// mid-rise when a screenshot around 9 s is taken.
|
|
const Vec2 at = game.floor.resolve(p + Vec2{5.0f, -3.0f}, 0.8f);
|
|
const Ascension staged{at, 0.497f, 14.0f, 0.6f, 1.0f};
|
|
draw_riser(staged, staged.cycle, staged.phase);
|
|
} else {
|
|
const int active = std::min(
|
|
static_cast<int>(ascensions_.size()),
|
|
1 + static_cast<int>(std::min(1.0f, game.corruption.value()) * 2.9f));
|
|
for (int i = 0; i < active; ++i)
|
|
draw_riser(ascensions_[i], ascensions_[i].cycle,
|
|
ascensions_[i].phase);
|
|
}
|
|
|
|
shadow_batch.draw();
|
|
glow_batch.draw();
|
|
EndMode3D();
|
|
|
|
if (floor_mode_) {
|
|
for (const FloorRoom& r : game.floor.rooms()) {
|
|
if (r.flow == 0 && r.side_index < 0) continue;
|
|
const Vec2 c{(r.rect.x0 + r.rect.x1) * 0.5f,
|
|
(r.rect.z0 + r.rect.z1) * 0.5f};
|
|
const Vector2 s = GetWorldToScreen({c.x, 1.0f, c.y}, camera_);
|
|
if (s.x < 0.0f || s.y < 0.0f || s.x > GetScreenWidth()
|
|
|| s.y > GetScreenHeight()) continue;
|
|
char buf[96];
|
|
if (r.flow > 0) {
|
|
std::snprintf(buf, sizeof(buf), "%d %s", r.flow, r.name.c_str());
|
|
} else {
|
|
std::snprintf(buf, sizeof(buf), "%c %s", 'A' + r.side_index, r.name.c_str());
|
|
}
|
|
const int w = MeasureText(buf, 12);
|
|
DrawRectangle(static_cast<int>(s.x) - w / 2 - 7,
|
|
static_cast<int>(s.y) - 15, w + 14, 19,
|
|
Color{17, 17, 19, 205});
|
|
DrawText(buf, static_cast<int>(s.x) - w / 2,
|
|
static_cast<int>(s.y) - 12, 12, Color{235, 232, 224, 240});
|
|
}
|
|
}
|
|
|
|
// World-object flavor names hover near each glow.
|
|
for (int i = 0; i < game.buff_system.world_object_count(); ++i) {
|
|
const WorldObject& obj = game.buff_system.world_object(i);
|
|
if (obj.name[0] == '\0') continue;
|
|
const Vector2 screen = GetWorldToScreen({obj.pos.x, 0.75f, obj.pos.y}, camera_);
|
|
DrawText(obj.name, static_cast<int>(screen.x) - MeasureText(obj.name, 12) / 2,
|
|
static_cast<int>(screen.y) - 14, 12, Color{255, 255, 255, 200});
|
|
}
|
|
|
|
// The screen carries a redacted placard; it only reads up close. No task
|
|
// list, no counter — the player has to inspect the room to find the beat.
|
|
if (!game.blackout.complete()) {
|
|
const Vec2 screen_pos = game.blackout.screen_pos();
|
|
if (distance(p, screen_pos) < 10.0f) {
|
|
const Vector2 s = GetWorldToScreen({screen_pos.x, 4.6f, screen_pos.y},
|
|
camera_);
|
|
draw_inspection_placard(s, "PROJECTOR SCREEN",
|
|
"DO NOT LOOK INTO THE IMAGE",
|
|
Color{245, 197, 24, 255});
|
|
}
|
|
}
|
|
|
|
// World-anchored health bars for damaged enemies.
|
|
for (const Enemy& e : game.enemy_system.enemies) {
|
|
if (e.hp >= e.max_hp) continue;
|
|
if (!cull.visible(e.pos.x, 1.2f, e.pos.y, e.radius + 0.8f)) continue;
|
|
const ActorModel model = e.type == EnemyType::MoldSpore ? ActorModel::MoldSpore
|
|
: (e.type == EnemyType::HissBrute ? ActorModel::HissBrute
|
|
: (e.type == EnemyType::HissGhost ? ActorModel::HissGhost
|
|
: ActorModel::HissStaff));
|
|
const Vector2 screen = GetWorldToScreen(
|
|
{e.pos.x, ModelBank::height(model) + 0.25f, e.pos.y}, camera_);
|
|
const float w = 46.0f;
|
|
const float frac = std::max(0.0f, e.hp / e.max_hp);
|
|
DrawRectangle(screen.x - w / 2.0f, screen.y, w, 5, Color{20, 20, 22, 200});
|
|
DrawRectangle(screen.x - w / 2.0f, screen.y, w * frac, 5, Color{200, 60, 60, 235});
|
|
}
|
|
|
|
// Floating damage numbers.
|
|
for (const DamageNumber& n : damage_numbers_) {
|
|
if (!cull.visible(n.pos.x, 1.6f, n.pos.y, 1.0f)) continue;
|
|
const float t = n.age / 0.8f;
|
|
const Vector2 screen = GetWorldToScreen(
|
|
{n.pos.x, 1.6f + n.age * 1.8f, n.pos.y}, camera_);
|
|
const unsigned char alpha = static_cast<unsigned char>(255.0f * (1.0f - t));
|
|
const char* text = TextFormat("%d", static_cast<int>(n.value + 0.5f));
|
|
DrawText(text, static_cast<int>(screen.x) - 10, static_cast<int>(screen.y), 20,
|
|
Color{255, 224, 130, alpha});
|
|
}
|
|
}
|