Walk into the Projector Room screen to enter a black room with 20 ringing red-phone tables. Sweep all phones, then step into the yellow-roofed glass case to restore the lights and claim the FLUORESCENT Light Switch skill. - Blender: phone_table, case_frame and case_glass GLBs + reproducible build_blackout_props.py, concept lineup and source .blend - Sim: BlackoutSequence state machine, Game ownership, spawn freeze during the pocket, FLUORESCENT active skill with unlock flag and buff effect - Render: uAlpha glass blending, three ActorModels, blackout camera/pass, event VFX, HUD progress card and third skill stamp - Dev flags: --blackout-test, --blackout-auto, --blackout-reveal - Tests: headless blackout chain/claim test (8/8 CTest pass) - Docs: BLACKOUT_RITUAL.md plus design/roadmap/art/README updates
1649 lines
77 KiB
C++
1649 lines
77 KiB
C++
#include "render/presenter.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>
|
|
|
|
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);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
class ViewCull {
|
|
public:
|
|
void init(const Camera3D& camera, float aspect, float max_depth = 180.0f) {
|
|
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 {
|
|
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;
|
|
return std::abs(Vector3DotProduct(d, right_)) <= depth * tan_x_ + radius
|
|
&& std::abs(Vector3DotProduct(d, up_)) <= depth * tan_y_ + radius;
|
|
}
|
|
|
|
private:
|
|
Vector3 cam_{};
|
|
float max_depth_ = 180.0f;
|
|
Vector3 forward_{};
|
|
Vector3 right_{};
|
|
Vector3 up_{};
|
|
float tan_x_ = 1.0f;
|
|
float tan_y_ = 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::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);
|
|
|
|
// 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});
|
|
|
|
// Threshold door hazard stripes and green exit lamps.
|
|
for (int i = 0; i < 10; ++i) {
|
|
const float x0 = -2.31f + i * 0.462f;
|
|
b.add_box({x0, 0.045f, arena - 0.6f}, {0.23f, 0.055f, 1.1f},
|
|
(i % 2 == 0) ? Color{198, 153, 13, 255}
|
|
: Color{20, 20, 22, 255});
|
|
}
|
|
const float door_z = arena + 0.45f;
|
|
b.add_box({-10.0f, 2.4f, door_z - 0.2f}, {1.7f, 0.52f, 0.12f},
|
|
Color{46, 170, 76, 255});
|
|
b.add_box({10.0f, 2.4f, door_z - 0.2f}, {1.7f, 0.52f, 0.12f},
|
|
Color{46, 170, 76, 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();
|
|
damage_numbers_.reserve(64);
|
|
sparks_.reserve(160);
|
|
}
|
|
|
|
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();
|
|
player_running_ = false;
|
|
}
|
|
|
|
void Presenter::shutdown() {
|
|
debris_.shutdown();
|
|
concrete_debris_.shutdown();
|
|
debris_.clear();
|
|
concrete_debris_.clear();
|
|
scorch_.clear();
|
|
aura_.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 (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::HazardDoor:
|
|
DrawCube({p.pos.x, p.h * 0.5f + 0.05f, p.pos.y}, p.w, p.h, p.d,
|
|
Color{160, 32, 40, 255});
|
|
for (int i = 0; i < 8; ++i) {
|
|
const float x = p.pos.x - p.w * 0.5f + (i + 0.5f) * p.w / 8.0f;
|
|
DrawCube({x, 0.09f, p.pos.y}, p.w / 16.0f, 0.02f, p.d + 0.4f,
|
|
Color{245, 197, 24, 255});
|
|
}
|
|
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:
|
|
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::Key: {
|
|
if (game.has_key) break;
|
|
const float bob = std::sin(t * 2.4f) * 0.28f;
|
|
DrawCube({p.pos.x, 1.6f + bob, p.pos.y}, 1.8f, 1.8f, 1.8f,
|
|
Color{245, 197, 24, 255});
|
|
DrawCylinder({p.pos.x, 0.09f, p.pos.y}, 3.0f, 3.0f, 0.02f, 18,
|
|
Color{245, 197, 24, 70});
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Clearance-gated doors. Locked openings are solid slabs with a red
|
|
// stripe; once stamped they read as open frames with a green threshold.
|
|
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;
|
|
if (floor.door_open(static_cast<int>(d.id))) {
|
|
DrawCube({cx, 0.07f, cz}, w, 0.06f, depth,
|
|
Color{70, 210, 120, 255});
|
|
for (const float sx : {-w * 0.5f, w * 0.5f}) {
|
|
DrawCube({cx + sx, 1.6f, cz}, 0.18f, 3.2f, 0.18f,
|
|
Color{120, 130, 124, 255});
|
|
}
|
|
} else {
|
|
DrawCube({cx, 1.6f, cz}, w, 3.2f, depth, Color{96, 26, 32, 255});
|
|
DrawCube({cx, 2.4f, cz}, w, 0.14f, depth + 0.2f,
|
|
Color{200, 40, 50, 255});
|
|
}
|
|
}
|
|
|
|
// Control-style thermo thresholds 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});
|
|
}
|
|
}
|
|
|
|
const Vec2 door = floor.door_pos();
|
|
if (cull.visible(door.x, 0.5f, door.y, 5.5f))
|
|
DrawCylinder({door.x, 0.09f, door.y}, 5.5f, 5.5f, 0.02f, 18,
|
|
game.has_key ? Color{60, 200, 110, 75} : Color{200, 30, 40, 55});
|
|
for (const FloorRoom& r : floor.rooms()) {
|
|
if (r.kind != RoomKind::Stairwell) continue;
|
|
const FloorRect& q = r.rect;
|
|
const Vec2 rc{(q.x0 + q.x1) * 0.5f, (q.z0 + q.z1) * 0.5f};
|
|
if (!cull.visible(rc.x, 2.6f, rc.y, q.x1 - q.x0)) continue;
|
|
DrawCube({rc.x, 2.6f, q.z1 - 0.1f},
|
|
q.x1 - q.x0 - 2.0f, 0.5f, 0.12f,
|
|
game.has_key ? Color{70, 210, 120, 255} : Color{200, 40, 50, 255});
|
|
}
|
|
}
|
|
|
|
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 (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);
|
|
|
|
// Threshold door frame (stripes and exit lamps are in the static batch).
|
|
const float door_z = arena + 0.45f;
|
|
if (concrete_fallback) {
|
|
DrawCube({0.0f, 2.9f, door_z}, 5.6f, 5.8f, 0.34f, Color{28, 28, 32, 255});
|
|
}
|
|
DrawCube({0.0f, 2.85f, door_z - 0.2f}, 3.7f, 5.1f, 0.1f,
|
|
Color{190, 28, 38, 255}); // Hiss glow bleeding through
|
|
DrawCube({0.0f, 1.45f, arena + 0.5f}, 38.0f, 0.12f, 0.3f,
|
|
Color{120, 42, 44, 255});
|
|
|
|
// Hiss light spill pools widen as the House decays.
|
|
const unsigned char hiss_alpha =
|
|
static_cast<unsigned char>(std::min<int>(70, 12 + corruption * 28));
|
|
DrawCylinder({0.0f, 0.07f, arena - 3.0f}, 5.0f + corruption, 5.0f + corruption,
|
|
0.02f, 16, Color{200, 24, 34, hiss_alpha});
|
|
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});
|
|
}
|
|
}
|
|
|
|
// 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.25f + 0.4f * 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) {
|
|
DrawCylinder({q.x, 0.04f, q.y}, 1.5f, 1.5f, 0.012f, 14,
|
|
Color{255, 45, 55, static_cast<unsigned char>(110 + 60 * pulse)});
|
|
glow_batch.add_billboard({q.x, 1.35f, q.y}, 6.0f, 6.0f,
|
|
cam_right, cam_up,
|
|
Color{255, 80, 90, 255});
|
|
glow_batch.add_ground({q.x, 0.02f, q.y}, 2.2f,
|
|
Color{220, 30, 40, 120});
|
|
}
|
|
}
|
|
|
|
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, 2.2f,
|
|
WHITE, 0.0f, false, 0.0f, 0.0f, 0.0f, 0.55f);
|
|
// Glass last, blended, with the switch visible through the panes.
|
|
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}, 3.0f, 3.0f, 0.02f, 24,
|
|
Color{245, 197, 24, 120});
|
|
glow_batch.add_billboard({c.x, 1.3f, c.y}, 4.5f, 4.5f,
|
|
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_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) {
|
|
// Both skills telegraph their landing zone; only concrete kicks up
|
|
// dust, warp uses the teal containment palette.
|
|
const bool warp = (e.flags & static_cast<unsigned>(SkillType::Warp)) != 0;
|
|
const bool fluorescent =
|
|
(e.flags & static_cast<unsigned>(SkillType::Fluorescent)) != 0;
|
|
if (fluorescent) {
|
|
spawn_sparks(e.pos, 0.8f, Color{245, 220, 120, 255}, 20, 4.0f);
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y},
|
|
std::max(1.0f, e.magnitude), 1.4f, anim_time_);
|
|
shake_ = std::max(shake_, 0.12f);
|
|
} else if (warp) {
|
|
spawn_sparks(e.pos, 0.6f, Color{80, 225, 205, 255}, 12, 3.0f);
|
|
} else {
|
|
concrete_debris_.burst(game.player.pos, 1.2f, 6);
|
|
spawn_sparks(game.player.pos, 0.35f, Color{180, 176, 166, 255},
|
|
8, 2.6f);
|
|
}
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y},
|
|
std::max(1.0f, e.magnitude),
|
|
warp ? 0.9f : 0.55f, anim_time_);
|
|
shake_ = std::max(shake_, 0.08f);
|
|
} else if (e.type == EventType::WarpBurst) {
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y},
|
|
std::max(1.0f, e.magnitude) * 1.2f, 1.0f,
|
|
anim_time_);
|
|
spawn_sparks(e.pos, 0.9f, Color{120, 240, 220, 255}, 16, 4.5f);
|
|
shake_ = std::max(shake_, 0.22f);
|
|
} 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) {
|
|
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));
|
|
}
|
|
if (e.flags & kDetonateConcrete) {
|
|
concrete_debris_.burst(
|
|
e.pos, radius,
|
|
std::min(28, 12 + static_cast<int>(radius * 3.0f)));
|
|
spawn_sparks(e.pos, 0.25f, Color{170, 166, 158, 255}, 10, 3.4f);
|
|
}
|
|
scorch_.add(e.pos, radius * 0.6f);
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y}, radius * 1.6f,
|
|
1.7f, anim_time_);
|
|
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::KeyAcquired) {
|
|
spawn_sparks(e.pos, 1.6f, Color{245, 197, 24, 255}, 14, 3.2f);
|
|
aura_.spawn_ground({e.pos.x, 0.09f, e.pos.y}, 5.0f, 1.6f, anim_time_);
|
|
} else if (e.type == EventType::FloorCleared) {
|
|
shake_ = std::max(shake_, 0.5f);
|
|
tier_wave_pending_ = true;
|
|
spawn_sparks(e.pos, 1.4f, Color{90, 230, 140, 255}, 18, 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;
|
|
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());
|
|
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;
|
|
const BlackoutSequence& b = game.blackout;
|
|
// 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 (game.blackout.active()) {
|
|
// Wide overhead framing so the whole 5 x 4 phone grid and the agent
|
|
// fit in one shot — the player must see every table in the dark.
|
|
const Vec2 focus{b.screen_pos().x, b.screen_pos().y + 12.0f};
|
|
camera_.position = {focus.x, 44.0f, focus.y + 5.0f};
|
|
camera_.target = {focus.x, 0.0f, focus.y};
|
|
} else 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());
|
|
|
|
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();
|
|
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, flash, e.bob_phase, enemy_hiss(e));
|
|
}
|
|
|
|
// CONCRETE CALL: a rough heap of slabs gathered around the agent, then
|
|
// hurled at the nearest crowd. Six 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 float flight = pile.phase == PilePhase::Flight
|
|
? std::min(1.0f, pile.phase_time
|
|
/ std::max(0.01f, pile.phase_duration))
|
|
: 0.0f;
|
|
const float height = 0.05f
|
|
+ std::sin(flight * 3.14159265f) * 1.7f;
|
|
const float spin = anim_time_ * 2.4f;
|
|
const float scale = 0.42f + 0.78f * 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 = (pile.phase == PilePhase::Gather && 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,
|
|
};
|
|
models_.draw(ActorModel::Debris, center, a, scale, WHITE);
|
|
}
|
|
}
|
|
|
|
// WARP: shrinking containment rings pull the eye (and the horde) into
|
|
// the collapse centre while the sim drags enemies together.
|
|
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 ring{80, 225, 205,
|
|
static_cast<unsigned char>(210 - 90 * t)};
|
|
const Vector3 center{field.pos.x, 0.12f + t * 0.6f, field.pos.y};
|
|
DrawCircle3D(center, r, Vector3{0.0f, 1.0f, 0.0f}, t * 2.0f, ring);
|
|
DrawCircle3D(center, r * 0.62f, Vector3{0.0f, 1.0f, 0.0f},
|
|
-t * 3.0f, ring);
|
|
}
|
|
|
|
// 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);
|
|
|
|
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});
|
|
}
|
|
|
|
// 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});
|
|
}
|
|
}
|