#include "Entities.hpp" #include "Components.hpp" #include "EnergyBarRaygui.hpp" #include "raylib-cpp.hpp" #include std::shared_ptr CreateProbe() { auto e = std::make_shared(); auto &transform = e->AddComponent(); transform.x = 96.0f; transform.y = 230.0f; e->AddComponent(); auto &physics = e->AddComponent(); physics.vx = 16.0f; physics.vy = 0.0f; physics.speedCap = 8192.0f; auto &collider = e->AddComponent(); collider.radius = 7.0f; collider.monitorable = true; auto &probeState = e->AddComponent(); probeState.spawnX = 96.0f; probeState.spawnY = 230.0f; probeState.spawnVx = 165.0f; probeState.spawnVy = 0.0f; e->AddComponent(); e->AddComponent(); auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); if (!transform) { return; } const raylib::Color probeColor(120, 210, 255, 255); const raylib::Color probeHighlight(255, 255, 255, 120); raylib::Vector2(transform->get().x, transform->get().y).DrawCircle(7.0f, probeColor); raylib::Vector2(transform->get().x - 1.0f, transform->get().y - 1.0f) .DrawCircle(3.0f, probeHighlight); }; return e; } std::shared_ptr CreateGravityWell() { auto e = std::make_shared(); auto &transform = e->AddComponent(); transform.x = 96.0f; transform.y = 230.0f; auto &well = e->AddComponent(); well.mass = 0.0f; well.minDist = 28.0f; return e; } std::shared_ptr CreateBlackHole(float x, float y) { auto e = std::make_shared(); auto &transform = e->AddComponent(); transform.x = x; transform.y = y; auto &scrollable = e->AddComponent(); scrollable.worldX = x; auto &well = e->AddComponent(); well.mass = static_cast(1 << 21); well.minDist = 24.0f; well.controlledByMouse = false; well.alwaysActive = true; // shader removed: previously used for black hole lensing auto &collider = e->AddComponent(); collider.radius = 18.0f; e->AddComponent(); auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); if (!transform) { return; } const int cx = static_cast(transform->get().x); const int cy = static_cast(transform->get().y); raylib::Vector2(static_cast(cx), static_cast(cy)) .DrawCircle(18.0f, raylib::Color(8, 10, 20, 255)); ::DrawCircleLines(cx, cy, 18.0f, raylib::Color(70, 95, 170, 240)); ::DrawCircleLines(cx, cy, 24.0f, raylib::Color(95, 120, 200, 120)); }; return e; } std::shared_ptr CreatePlayerBlackHole(float worldX, float y, float scrollX, float ttl) { auto e = std::make_shared(); auto &transform = e->AddComponent(); transform.x = worldX - scrollX; transform.y = y; auto &scrollable = e->AddComponent(); scrollable.worldX = worldX; auto &well = e->AddComponent(); well.mass = static_cast(1 << 22); well.minDist = 28.0f; well.controlledByMouse = false; well.alwaysActive = true; // shader removed: previously used for black hole lensing auto &lifetime = e->AddComponent(); lifetime.remaining = ttl; // Mark this as a player-created black hole so it can be removed via right-click e->AddComponent(); auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); if (!transform) { return; } auto lifetime = e->GetComponent(); if (!lifetime) { return; } const int cx = static_cast(transform->get().x); const int cy = static_cast(transform->get().y); float t = 360 * lifetime->get().remaining / 1; ::DrawCircleSector({(float)cx, (float)cy}, 28.0f, 0.0f, t, 32, raylib::Color(70, 95, 170, 25)); ::DrawCircleLines(cx, cy, 18.0f, raylib::Color(70, 95, 170, 240)); ::DrawCircleLines(cx, cy, 24.0f, raylib::Color(95, 120, 200, 120)); }; return e; } std::shared_ptr CreateStar(float x, float y) { auto e = std::make_shared(); auto &t = e->AddComponent(); t.x = x; t.y = y; auto &scrollable = e->AddComponent(); scrollable.worldX = x; auto &collider = e->AddComponent(); collider.radius = 20.0f; e->AddComponent(); auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); if (!transform) { return; } raylib::Vector2 center(transform->get().x, transform->get().y); const raylib::Color starColor(255, 223, 86, 255); const raylib::Color glowColor(255, 223, 86, 80); center.DrawCircle(20.0f, glowColor); center.DrawPoly(3, 10.0f, transform->get().x, starColor); center.DrawPoly(3, 10.0f, transform->get().x + 180.0f, starColor); }; return e; } std::shared_ptr CreateAsteroid(float x, float y) { auto e = std::make_shared(); auto &t = e->AddComponent(); t.x = x; t.y = y; auto &scrollable = e->AddComponent(); scrollable.worldX = x; auto &collider = e->AddComponent(); collider.radius = 13.0f; e->AddComponent(); auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); if (!transform) { return; } raylib::Vector2(transform->get().x, transform->get().y) .DrawCircle(13.0f, raylib::Color(116, 126, 142, 255)); }; return e; } std::shared_ptr CreateDebris(float x, float y, float vx, float vy, float ttl) { auto e = std::make_shared(); auto &t = e->AddComponent(); t.x = x; t.y = y; auto &physics = e->AddComponent(); physics.vx = vx; physics.vy = vy; physics.speedCap = 260.0f; auto &lifetime = e->AddComponent(); lifetime.remaining = ttl; auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); if (!transform) { return; } raylib::Vector2(transform->get().x, transform->get().y) .DrawCircle(3.0f, raylib::Color(245, 196, 104, 220)); }; return e; } std::shared_ptr CreateNullZone(float x, float width) { auto e = std::make_shared(); auto &t = e->AddComponent(); t.x = x; auto &scrollable = e->AddComponent(); scrollable.worldX = x; auto &nullZone = e->AddComponent(); nullZone.width = width; auto &render = e->AddComponent(); render.draw = [e]() { auto transform = e->GetComponent(); auto zone = e->GetComponent(); if (!transform || !zone) { return; } int x = (int)(transform->get().x); raylib::Color(96, 64, 146, 80) .DrawRectangle(x, 0, (int)(zone->get().width), raylib::Window::GetHeight()); raylib::Color(96, 64, 146, 200).DrawText("Null Zone", x + 8, 12, 16); }; return e; } std::shared_ptr CreateWorld() { auto e = std::make_shared(); e->AddComponent(); e->AddComponent(); return e; } std::shared_ptr CreateStats() { auto e = std::make_shared(); e->AddComponent(); auto &audio = e->AddComponent(); audio.volume = 0.6f; audio.Load("assets/audio/ping.wav"); auto &render = e->AddComponent(); render.draw = [e]() { auto stats = e->GetComponent(); if (!stats) { return; } const float ratio = std::clamp(stats->get().value / stats->get().maxValue, 0.0f, 1.0f); DrawHud(ratio, stats->get().GetStarCount()); }; return e; }