From e31ceeab5e04d24945d69ecdf54abaf343f77d3a Mon Sep 17 00:00:00 2001 From: Dave Kapell Date: Wed, 4 Mar 2026 10:02:58 -0500 Subject: [PATCH 01/12] Create Post Processor Component and System --- CMakeLists.txt | 6 +++ scripts/api/entity/blackhole.lua | 18 ++++--- src/components/player.h | 9 ++++ src/components/postprocessor.cpp | 12 +++++ src/components/postprocessor.h | 30 ++++++++++++ src/hardware/hardwareController.cpp | 3 ++ src/init/ecs.cpp | 10 +++- src/multiplayer/player.cpp | 9 +++- src/multiplayer/postprocessor.cpp | 15 ++++++ src/multiplayer/postprocessor.h | 7 +++ src/screenComponents/indicatorOverlays.cpp | 32 +++++++++---- src/script/components.cpp | 17 +++++++ src/systems/gravity.cpp | 17 +++---- src/systems/player.cpp | 22 +++++++++ src/systems/player.h | 10 ++++ src/systems/postprocessor.cpp | 55 ++++++++++++++++++++++ src/systems/postprocessor.h | 22 +++++++++ 17 files changed, 269 insertions(+), 25 deletions(-) create mode 100644 src/components/postprocessor.cpp create mode 100644 src/components/postprocessor.h create mode 100644 src/multiplayer/postprocessor.cpp create mode 100644 src/multiplayer/postprocessor.h create mode 100644 src/systems/player.cpp create mode 100644 src/systems/player.h create mode 100644 src/systems/postprocessor.cpp create mode 100644 src/systems/postprocessor.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ee87e496e4..bd29ebf440 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -424,6 +424,10 @@ set(MAIN_SOURCES src/systems/scanning.cpp src/systems/planet.h src/systems/planet.cpp + src/systems/player.h + src/systems/player.cpp + src/systems/postprocessor.h + src/systems/postprocessor.cpp src/systems/gm.h src/systems/gm.cpp src/systems/radar.h @@ -450,6 +454,8 @@ set(MAIN_SOURCES src/multiplayer/radarblock.cpp src/multiplayer/player.h src/multiplayer/player.cpp + src/multiplayer/postprocessor.h + src/multiplayer/postprocessor.cpp src/multiplayer/name.h src/multiplayer/name.cpp src/multiplayer/impulse.h diff --git a/scripts/api/entity/blackhole.lua b/scripts/api/entity/blackhole.lua index ce45ed6c9f..074547812b 100644 --- a/scripts/api/entity/blackhole.lua +++ b/scripts/api/entity/blackhole.lua @@ -7,23 +7,26 @@ --- @type creation function BlackHole() local e = createEntity() + local radius = 5000 e.components = { transform = {}, never_radar_blocked = {}, - gravity = {range=5000, damage=true}, - avoid_object = {range=7000}, + gravity = {range=radius, damage=true}, + avoid_object = {range=radius*1.4}, radar_signature = {gravity=0.9}, - radar_trace = {icon="radar/blackHole.png", min_size=0, max_size = 2048, radius=5000}, - billboard_render = {texture="blackHole3d.png", size=5000} + radar_trace = {icon="radar/blackHole.png", min_size=0, max_size = 2048, radius=radius}, + billboard_render = {texture="blackHole3d.png", size=radius}, + warppostprocessor = { max_radius = radius, effect_strength=1 } } return e end ---- A WormHole is a piece of space terrain that pulls all nearby SpaceObjects within a 5U radius, including otherwise immobile objects like SpaceStations, toward its center. +--- A WormHole is a piece of space terrain that pulls all nearby SpaceObjects within a 2.5U radius, including otherwise immobile objects like SpaceStations, toward its center. --- Any SpaceObject that reaches its center is teleported to another point in space. ---- AI behaviors avoid WormHoles by a 2U margin. +--- AI behaviors avoid WormHoles by a 3U margin. --- Example: wormhole = WormHole():setPosition(1000,1000):setTargetPosition(10000,10000) +--- @type creation function WormHole() local e = createEntity() local radius = 2500 @@ -34,7 +37,8 @@ function WormHole() avoid_object = {range=radius*1.2}, radar_signature = {gravity=0.9}, radar_trace = {icon="radar/wormHole.png", min_size=0, max_size=2048, radius=radius}, - billboard_render = {texture="wormHole3d.png", size=5000} + billboard_render = {texture="wormHole3d.png", size=radius*2}, + glitchpostprocessor = { max_radius = radius, effect_strength=20} } return e end diff --git a/src/components/player.h b/src/components/player.h index d962fa14ce..a45754c4ec 100644 --- a/src/components/player.h +++ b/src/components/player.h @@ -44,6 +44,15 @@ class PlayerControl string control_code; CrewPositions allowed_positions = CrewPositions::all(); + + float glitch_alpha = 0.0f; //[output] used for visual effect in range of a glitchpostprocessor component. + float warp_alpha = 0.0f; //[output] used for visual effect in range of a warppostprocessor component. + float glitch_alpha_decay_rate = 20.0f; + float warp_alpha_decay_rate = 2.0f; + + float just_teleported = 0.0f; //[output] used for triggers after going through a wormhole. + + float in_gravity = 0.0f; //[output] used when in a gravity well. }; class Waypoints diff --git a/src/components/postprocessor.cpp b/src/components/postprocessor.cpp new file mode 100644 index 0000000000..9f23128042 --- /dev/null +++ b/src/components/postprocessor.cpp @@ -0,0 +1,12 @@ +#include "postprocessor.h" + +string getPostProcessorType(PostProcessor::Type postprocessor) +{ + switch(postprocessor) + { + case PostProcessor::Type::Glitch: return "glitch"; + case PostProcessor::Type::Warp: return "warp"; + default: + return "UNKNOWN"; + } +} diff --git a/src/components/postprocessor.h b/src/components/postprocessor.h new file mode 100644 index 0000000000..0665c4f1ae --- /dev/null +++ b/src/components/postprocessor.h @@ -0,0 +1,30 @@ +#pragma once + +// Base class for Postproccessor components, never created directtly + +class PostProcessorComponent +{ +public: + enum class Type + { + Glitch, + Warp + }; + float effect_strength = 1.0f; // postprocessor effect strength at min_radius + float min_radius = 0.0f; + float max_radius = 5000.0f; +}; + +string getPostProcessorType(PostProcessorComponent::Type postprocessor); + + +class GlitchPostProcessor: public PostProcessorComponent{ +public: + //Config + +}; + +class WarpPostProcessor: public PostProcessorComponent{ +public: + // Config +}; diff --git a/src/hardware/hardwareController.cpp b/src/hardware/hardwareController.cpp index 8ad4637994..a41fda5176 100644 --- a/src/hardware/hardwareController.cpp +++ b/src/hardware/hardwareController.cpp @@ -404,6 +404,9 @@ bool HardwareController::getVariableValue(string variable_name, float& value) SHIP_VARIABLE("RedAlert", PlayerControl, c->alert_level != AlertLevel::RedAlert ? 1.0f : 0.0f); SHIP_VARIABLE("SelfDestruct", SelfDestruct, c->active ? 1.0f : 0.0f); SHIP_VARIABLE("SelfDestructCountdown", SelfDestruct, c->countdown / 10.0f); + SHIP_VARIABLE("Gravity", PlayerControl, c->in_gravity * 100); + SHIP_VARIABLE("Teleported", PlayerControl, c->just_teleported > 0.0f ? 1.0f : 0.0f); + for(unsigned int n=0; n<16; n++) { SHIP_VARIABLE("TubeLoaded" + string(n), MissileTubes, c->mounts.size() > n && c->mounts[n].state == MissileTubes::MountPoint::State::Loaded ? 1.0f : 0.0f); diff --git a/src/init/ecs.cpp b/src/init/ecs.cpp index 86cf8dab21..3c309eb726 100644 --- a/src/init/ecs.cpp +++ b/src/init/ecs.cpp @@ -38,6 +38,7 @@ #include "multiplayer/radarblock.h" #include "multiplayer/shiplog.h" #include "multiplayer/zone.h" +#include "multiplayer/postprocessor.h" #include "systems/ai.h" #include "systems/docking.h" @@ -67,7 +68,8 @@ #include "systems/gm.h" #include "systems/pickup.h" #include "systems/debugrender.h" - +#include "systems/player.h" +#include "systems/postprocessor.h" void initSystemsAndComponents() { @@ -129,10 +131,14 @@ void initSystemsAndComponents() sp::ecs::MultiplayerReplication::registerComponentReplication(); sp::ecs::MultiplayerReplication::registerComponentReplication(); sp::ecs::MultiplayerReplication::registerComponentReplication(); + sp::ecs::MultiplayerReplication::registerComponentReplication(); + sp::ecs::MultiplayerReplication::registerComponentReplication(); sp::ecs::MultiplayerReplication::registerComponentReplication(); sp::ecs::MultiplayerReplication::registerComponentReplication(); + engine->registerSystem(); + engine->registerSystem(); engine->registerSystem(); engine->registerSystem(); engine->registerSystem(); @@ -164,6 +170,8 @@ void initSystemsAndComponents() engine->registerSystem(); engine->registerSystem(); engine->registerSystem(); + engine->registerSystem(); + #ifdef DEBUG engine->registerSystem(); #endif diff --git a/src/multiplayer/player.cpp b/src/multiplayer/player.cpp index ea0bd81a98..6e12712ea0 100644 --- a/src/multiplayer/player.cpp +++ b/src/multiplayer/player.cpp @@ -12,8 +12,15 @@ BASIC_REPLICATION_IMPL(PlayerControlReplication, PlayerControl) BASIC_REPLICATION_FIELD(main_screen_overlay); BASIC_REPLICATION_FIELD(alert_level); - BASIC_REPLICATION_FIELD(control_code); //TODO: Instead of replicating this to clients, check it on receiving the commandSetShip in playerinfo + BASIC_REPLICATION_FIELD(control_code); //TODO: Indstead of replicating this to clients, check it on receiving the commandSetShip in playerinfo BASIC_REPLICATION_FIELD(allowed_positions.mask); + BASIC_REPLICATION_FIELD(in_gravity); + BASIC_REPLICATION_FIELD(glitch_alpha); + BASIC_REPLICATION_FIELD(glitch_alpha_decay_rate); + BASIC_REPLICATION_FIELD(warp_alpha_decay_rate); + BASIC_REPLICATION_FIELD(warp_alpha); + + BASIC_REPLICATION_FIELD(just_teleported); } BASIC_REPLICATION_IMPL(WaypointsReplication, Waypoints) diff --git a/src/multiplayer/postprocessor.cpp b/src/multiplayer/postprocessor.cpp new file mode 100644 index 0000000000..8e796d9f5c --- /dev/null +++ b/src/multiplayer/postprocessor.cpp @@ -0,0 +1,15 @@ +#include "multiplayer/postprocessor.h" +#include "multiplayer.h" + + +BASIC_REPLICATION_IMPL(GlitchPostProcessorReplication, GlitchPostProcessor) + BASIC_REPLICATION_FIELD(max_radius); + BASIC_REPLICATION_FIELD(min_radius); + BASIC_REPLICATION_FIELD(effect_strength); +} + +BASIC_REPLICATION_IMPL(WarpPostProcessorReplication, WarpPostProcessor) + BASIC_REPLICATION_FIELD(max_radius); + BASIC_REPLICATION_FIELD(min_radius); + BASIC_REPLICATION_FIELD(effect_strength); +} diff --git a/src/multiplayer/postprocessor.h b/src/multiplayer/postprocessor.h new file mode 100644 index 0000000000..bd28dc0397 --- /dev/null +++ b/src/multiplayer/postprocessor.h @@ -0,0 +1,7 @@ +#pragma once + +#include "multiplayer/basic.h" +#include "components/postprocessor.h" + +BASIC_REPLICATION_CLASS(GlitchPostProcessorReplication, GlitchPostProcessor); +BASIC_REPLICATION_CLASS(WarpPostProcessorReplication, WarpPostProcessor); diff --git a/src/screenComponents/indicatorOverlays.cpp b/src/screenComponents/indicatorOverlays.cpp index 3d347bf723..7162723306 100644 --- a/src/screenComponents/indicatorOverlays.cpp +++ b/src/screenComponents/indicatorOverlays.cpp @@ -9,6 +9,7 @@ #include "components/jumpdrive.h" #include "components/shields.h" #include "components/hull.h" +#include "components/player.h" #include "multiplayer_server.h" #include "i18n.h" @@ -92,23 +93,38 @@ void GuiIndicatorOverlays::onDraw(sp::RenderTarget& renderer) { auto jump = my_spaceship.getComponent(); auto warp = my_spaceship.getComponent(); + auto player = my_spaceship.getComponent(); + float glitchMagnitude = 0.0f; + float warpAmount = 0.0f; + if (jump && jump->just_jumped > 0.0f) + glitchMagnitude = jump->just_jumped * 10.0f; + + if (player && player->glitch_alpha > 0.0f) + glitchMagnitude = std::max(glitchMagnitude, player->glitch_alpha); + + if (glitchMagnitude > 0.0f) { glitchPostProcessor->enabled = true; - glitchPostProcessor->setUniform("u_magtitude", jump->just_jumped * 10.0f); + glitchPostProcessor->setUniform("u_magtitude", glitchMagnitude); glitchPostProcessor->setUniform("u_delta", random(0, 360)); - }else{ + } else { glitchPostProcessor->enabled = false; } + if (warp && warp->current > 0.0f && PreferencesManager::get("warp_post_processor_disable").toInt() != 1) + warpAmount = warp->current * 0.01f; + else if (jump && jump->delay > 0.0f && jump->delay < 2.0f && PreferencesManager::get("warp_post_processor_disable").toInt() != 1) + warpAmount = (2.0f - jump->delay) * 0.1f; + + if(player && player->warp_alpha > 0.0f) + warpAmount = std::max(warpAmount, player->warp_alpha); + + if (warpAmount > 0.0f) { warpPostProcessor->enabled = true; - warpPostProcessor->setUniform("u_amount", warp->current * 0.01f); - }else if (jump && jump->delay > 0.0f && jump->delay < 2.0f && PreferencesManager::get("warp_post_processor_disable").toInt() != 1) - { - warpPostProcessor->enabled = true; - warpPostProcessor->setUniform("u_amount", (2.0f - jump->delay) * 0.1f); - }else{ + warpPostProcessor->setUniform("u_amount", warpAmount); + } else { warpPostProcessor->enabled = false; } }else{ diff --git a/src/script/components.cpp b/src/script/components.cpp index aa0bb4d9ae..5e322a5125 100644 --- a/src/script/components.cpp +++ b/src/script/components.cpp @@ -45,6 +45,7 @@ #include "components/customshipfunction.h" #include "components/zone.h" #include "components/shiplog.h" +#include "components/postprocessor.h" #define STRINGIFY(n) #n @@ -652,6 +653,12 @@ void initComponentScriptBindings() BIND_MEMBER(PlayerControl, alert_level); BIND_MEMBER(PlayerControl, control_code); BIND_MEMBER(PlayerControl, allowed_positions); + BIND_MEMBER(PlayerControl, glitch_alpha); + BIND_MEMBER(PlayerControl, glitch_alpha_decay_rate); + BIND_MEMBER(PlayerControl, warp_alpha); + BIND_MEMBER(PlayerControl, warp_alpha_decay_rate); + BIND_MEMBER(PlayerControl, in_gravity); + BIND_MEMBER(PlayerControl, just_teleported); sp::script::ComponentHandler::name("hacking_device"); BIND_MEMBER(HackingDevice, effectiveness); sp::script::ComponentHandler::name("ship_log"); @@ -789,6 +796,16 @@ void initComponentScriptBindings() BIND_ARRAY_DIRTY_FLAG_MEMBER(CustomShipFunctions, functions, callback, functions_dirty); BIND_ARRAY_DIRTY_FLAG_MEMBER(CustomShipFunctions, functions, order, functions_dirty); + sp::script::ComponentHandler::name("glitchpostprocessor"); + BIND_MEMBER(GlitchPostProcessor, effect_strength); + BIND_MEMBER(GlitchPostProcessor, min_radius); + BIND_MEMBER(GlitchPostProcessor, max_radius); + + sp::script::ComponentHandler::name("warppostprocessor"); + BIND_MEMBER(WarpPostProcessor, effect_strength); + BIND_MEMBER(WarpPostProcessor, min_radius); + BIND_MEMBER(WarpPostProcessor, max_radius); + sp::script::ComponentHandler::name("zone"); BIND_MEMBER(Zone, color); BIND_MEMBER(Zone, label); diff --git a/src/systems/gravity.cpp b/src/systems/gravity.cpp index ba25da5d5a..c43e7867f0 100644 --- a/src/systems/gravity.cpp +++ b/src/systems/gravity.cpp @@ -1,6 +1,7 @@ #include "systems/gravity.h" #include "components/gravity.h" #include "components/collision.h" +#include "components/player.h" #include "components/hull.h" #include "systems/collision.h" #include "systems/damage.h" @@ -30,13 +31,11 @@ void GravitySystem::update(float delta) force = max_force; tt->setPosition(tt->getPosition() + diff / std::sqrt(dist2) * delta * force); - if (grav.wormhole_target.x || grav.wormhole_target.y) { - /*TODO - // Warp postprocessor-alpha is calculated using alpha = (1 - (delay/10)) - if (spaceship) - spaceship->wormhole_alpha = ((distance / grav.range) * ALPHA_MULTIPLIER); - */ + auto player = target.getComponent(); + if (player) + player->in_gravity = (1 - (dist2 / (grav.range * grav.range))); + if (grav.wormhole_target.x || grav.wormhole_target.y) { if (force >= max_force) { if (game_server) { @@ -46,8 +45,10 @@ void GravitySystem::update(float delta) LuaConsole::checkResult(grav.on_teleportation.call(source, target)); continue; //callback could destroy the entity, so do no extra processing. } - //if (spaceship) - // spaceship->wormhole_alpha = 0.0; + if (player) + // set just_teleported for use by hardware + player->just_teleported = 2.0f; + player->in_gravity = 0.0f; } } } diff --git a/src/systems/player.cpp b/src/systems/player.cpp new file mode 100644 index 0000000000..fdd89c6cdd --- /dev/null +++ b/src/systems/player.cpp @@ -0,0 +1,22 @@ +#include "systems/player.h" +#include "components/player.h" +#include "ecs/query.h" + +void PlayerSystem::update(float delta) +{ + if (delta <= 0.0f) return; + for(auto [entity, player] : sp::ecs::Query()) + { + // Decrease glitch postprocessor visual effects + if (player.glitch_alpha > 0.0f) + player.glitch_alpha -= delta * player.glitch_alpha_decay_rate; + + // Decrease warp postprocessor visual effects + if (player.warp_alpha > 0.0f) + player.warp_alpha -= delta * player.warp_alpha_decay_rate; + + // Decrease post-wormhole teleport + if (player.just_teleported > 0.0f) + player.just_teleported -= delta; + } +} diff --git a/src/systems/player.h b/src/systems/player.h new file mode 100644 index 0000000000..4babfc0089 --- /dev/null +++ b/src/systems/player.h @@ -0,0 +1,10 @@ +#pragma once + +#include "ecs/system.h" + + +class PlayerSystem : public sp::ecs::System +{ +public: + void update(float delta) override; +}; diff --git a/src/systems/postprocessor.cpp b/src/systems/postprocessor.cpp new file mode 100644 index 0000000000..0c4b023c94 --- /dev/null +++ b/src/systems/postprocessor.cpp @@ -0,0 +1,55 @@ +#include "systems/postprocessor.h" +#include "components/postprocessor.h" +#include "components/collision.h" +#include "components/player.h" +#include "systems/collision.h" +#include "tween.h" +#include + + +void PostProcessorSystem::update(float delta) +{ + if (delta <= 0.0f) return; + for(auto [source, postprocessor, source_transform] : sp::ecs::Query()) + updatePostProcessor(source, postprocessor, delta, source_transform, EffectType::Glitch); + for(auto [source, postprocessor, source_transform] : sp::ecs::Query()) + updatePostProcessor(source, postprocessor, delta, source_transform, EffectType::Warp); +} + +void PostProcessorSystem::updatePostProcessor(sp::ecs::Entity& source, PostProcessorComponent& postprocessor, float delta, sp::Transform source_transform, EffectType type) +{ + for(auto target : sp::CollisionSystem::queryArea(source_transform.getPosition() - glm::vec2(postprocessor.max_radius, postprocessor.max_radius), source_transform.getPosition() + glm::vec2(postprocessor.max_radius, postprocessor.max_radius))) + { + if (target == source) continue; + auto player = target.getComponent(); + if (!player) continue; + + auto tt = target.getComponent(); + auto diff = source_transform.getPosition() - tt->getPosition(); + float dist2 = std::max(1.0f, glm::length2(diff)); + if (dist2 > postprocessor.max_radius*postprocessor.max_radius) + continue; + + float alpha_strength = 0.0f; + printf("max: %f\n", postprocessor.effect_strength); + + if (dist2 < postprocessor.min_radius*postprocessor.min_radius){ + // Inside of min_radius, use max strength effect + alpha_strength = postprocessor.effect_strength; + } else { + // Outside of min_radius, scale effect by distance + alpha_strength = Tween::easeInQuartic(dist2, postprocessor.max_radius*postprocessor.max_radius, postprocessor.min_radius*postprocessor.min_radius, 0.0f, postprocessor.effect_strength ); + } + + switch (type){ + case EffectType::Glitch: + player->glitch_alpha = std::max(player->glitch_alpha, alpha_strength); + break; + case EffectType::Warp: + player->warp_alpha = std::max(player->warp_alpha, alpha_strength); + break; + default: + break; + } + } +} diff --git a/src/systems/postprocessor.h b/src/systems/postprocessor.h new file mode 100644 index 0000000000..f41a21986e --- /dev/null +++ b/src/systems/postprocessor.h @@ -0,0 +1,22 @@ +#pragma once + +#include "ecs/system.h" +#include "ecs/query.h" +#include "components/postprocessor.h" +#include "components/collision.h" +#include "systems/collision.h" + +enum class EffectType +{ + Glitch, + Warp +}; + +class PostProcessorSystem : public sp::ecs::System +{ +public: + void update(float delta) override; +private: + void updatePostProcessor(sp::ecs::Entity& source, PostProcessorComponent& postprocessor, float delta, sp::Transform source_transform, EffectType type); + +}; From f4d3c76ffbb29454e4c2cba75184feb253859cf7 Mon Sep 17 00:00:00 2001 From: Dave Kapell Date: Wed, 4 Mar 2026 14:51:20 -0500 Subject: [PATCH 02/12] Update player.cpp --- src/multiplayer/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/multiplayer/player.cpp b/src/multiplayer/player.cpp index 6e12712ea0..0e11174d31 100644 --- a/src/multiplayer/player.cpp +++ b/src/multiplayer/player.cpp @@ -12,7 +12,7 @@ BASIC_REPLICATION_IMPL(PlayerControlReplication, PlayerControl) BASIC_REPLICATION_FIELD(main_screen_overlay); BASIC_REPLICATION_FIELD(alert_level); - BASIC_REPLICATION_FIELD(control_code); //TODO: Indstead of replicating this to clients, check it on receiving the commandSetShip in playerinfo + BASIC_REPLICATION_FIELD(control_code); //TODO: Instead of replicating this to clients, check it on receiving the commandSetShip in playerinfo BASIC_REPLICATION_FIELD(allowed_positions.mask); BASIC_REPLICATION_FIELD(in_gravity); BASIC_REPLICATION_FIELD(glitch_alpha); From ed4c77b468862f1f4de909843938c2e414032921 Mon Sep 17 00:00:00 2001 From: Dave Kapell Date: Mon, 9 Mar 2026 14:10:05 -0400 Subject: [PATCH 03/12] remove debug message --- src/systems/postprocessor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/systems/postprocessor.cpp b/src/systems/postprocessor.cpp index 0c4b023c94..8c0a32c074 100644 --- a/src/systems/postprocessor.cpp +++ b/src/systems/postprocessor.cpp @@ -31,8 +31,7 @@ void PostProcessorSystem::updatePostProcessor(sp::ecs::Entity& source, PostProce continue; float alpha_strength = 0.0f; - printf("max: %f\n", postprocessor.effect_strength); - + if (dist2 < postprocessor.min_radius*postprocessor.min_radius){ // Inside of min_radius, use max strength effect alpha_strength = postprocessor.effect_strength; From 9e146d1a2cf083f0cf281cb3ab97aecdf507ea31 Mon Sep 17 00:00:00 2001 From: Dave Kapell Date: Tue, 10 Mar 2026 10:53:17 -0400 Subject: [PATCH 04/12] Allow setting size of blackholes and wormholes --- scripts/api/entity/blackhole.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/api/entity/blackhole.lua b/scripts/api/entity/blackhole.lua index 074547812b..7c9acedf71 100644 --- a/scripts/api/entity/blackhole.lua +++ b/scripts/api/entity/blackhole.lua @@ -5,9 +5,9 @@ --- In 3D space, a BlackHole resembles a black sphere with blue horizon. --- Example: black_hole = BlackHole():setPosition(1000,2000) --- @type creation -function BlackHole() +function BlackHole(radius) + radius = radius or 5000 local e = createEntity() - local radius = 5000 e.components = { transform = {}, never_radar_blocked = {}, @@ -27,9 +27,9 @@ end --- AI behaviors avoid WormHoles by a 3U margin. --- Example: wormhole = WormHole():setPosition(1000,1000):setTargetPosition(10000,10000) --- @type creation -function WormHole() +function WormHole(radius) + radius = radius or 2500 local e = createEntity() - local radius = 2500 e.components = { transform = {}, never_radar_blocked = {}, From 1df8360ed14b904e971d3b1d3134710073ba1a4a Mon Sep 17 00:00:00 2001 From: Dave Kapell Date: Tue, 10 Mar 2026 11:49:31 -0400 Subject: [PATCH 05/12] Give just_teleported the same glitch overlay as just_jumped --- src/screenComponents/indicatorOverlays.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/screenComponents/indicatorOverlays.cpp b/src/screenComponents/indicatorOverlays.cpp index 7162723306..66ccb0a107 100644 --- a/src/screenComponents/indicatorOverlays.cpp +++ b/src/screenComponents/indicatorOverlays.cpp @@ -102,6 +102,9 @@ void GuiIndicatorOverlays::onDraw(sp::RenderTarget& renderer) if (player && player->glitch_alpha > 0.0f) glitchMagnitude = std::max(glitchMagnitude, player->glitch_alpha); + + if (player && player->just_teleported > 0.0f) + glitchMagnitude = std::max(glitchMagnitude, player->just_teleported * 10.0f); if (glitchMagnitude > 0.0f) { From 2229e669e192c1bba7a17d3706cb3cc03eb2be53 Mon Sep 17 00:00:00 2001 From: Dave Kapell Date: Tue, 10 Mar 2026 12:52:25 -0400 Subject: [PATCH 06/12] Add min_effect_strength --- scripts/api/entity/blackhole.lua | 10 +++++++--- src/components/postprocessor.h | 3 ++- src/multiplayer/postprocessor.cpp | 6 ++++-- src/script/components.cpp | 11 +++++++++-- src/systems/postprocessor.cpp | 6 +++--- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/scripts/api/entity/blackhole.lua b/scripts/api/entity/blackhole.lua index 7c9acedf71..d008fe8616 100644 --- a/scripts/api/entity/blackhole.lua +++ b/scripts/api/entity/blackhole.lua @@ -3,10 +3,12 @@ --- Upon reaching the center, any SpaceObject is instantly destroyed even if it's otherwise incapable of taking damage. --- AI behaviors avoid BlackHoles by a 2U margin. --- In 3D space, a BlackHole resembles a black sphere with blue horizon. +--- The optional radius parameter specifies the radius of the BlackHole, default 5000 --- Example: black_hole = BlackHole():setPosition(1000,2000) --- @type creation function BlackHole(radius) radius = radius or 5000 + radius = math.max(0, radius) local e = createEntity() e.components = { transform = {}, @@ -16,7 +18,7 @@ function BlackHole(radius) radar_signature = {gravity=0.9}, radar_trace = {icon="radar/blackHole.png", min_size=0, max_size = 2048, radius=radius}, billboard_render = {texture="blackHole3d.png", size=radius}, - warppostprocessor = { max_radius = radius, effect_strength=1 } + warppostprocessor = { max_radius = radius, max_effect_strength=1 } } return e end @@ -24,11 +26,13 @@ end --- A WormHole is a piece of space terrain that pulls all nearby SpaceObjects within a 2.5U radius, including otherwise immobile objects like SpaceStations, toward its center. --- Any SpaceObject that reaches its center is teleported to another point in space. ---- AI behaviors avoid WormHoles by a 3U margin. +--- AI behaviors avoid WormHoles by a 0.5U margin. +--- The optional radius parameter specifies the radius of the WormHole, default 2500 --- Example: wormhole = WormHole():setPosition(1000,1000):setTargetPosition(10000,10000) --- @type creation function WormHole(radius) radius = radius or 2500 + radius = math.max(0, radius) local e = createEntity() e.components = { transform = {}, @@ -38,7 +42,7 @@ function WormHole(radius) radar_signature = {gravity=0.9}, radar_trace = {icon="radar/wormHole.png", min_size=0, max_size=2048, radius=radius}, billboard_render = {texture="wormHole3d.png", size=radius*2}, - glitchpostprocessor = { max_radius = radius, effect_strength=20} + glitchpostprocessor = { max_radius = radius, max_effect_strength=20} } return e end diff --git a/src/components/postprocessor.h b/src/components/postprocessor.h index 0665c4f1ae..da07066e66 100644 --- a/src/components/postprocessor.h +++ b/src/components/postprocessor.h @@ -10,7 +10,8 @@ class PostProcessorComponent Glitch, Warp }; - float effect_strength = 1.0f; // postprocessor effect strength at min_radius + float min_effect_strength = 0.0f; //postprocessor effect strength at max_radius + float max_effect_strength = 1.0f; // postprocessor effect strength at min_radius float min_radius = 0.0f; float max_radius = 5000.0f; }; diff --git a/src/multiplayer/postprocessor.cpp b/src/multiplayer/postprocessor.cpp index 8e796d9f5c..dd57efb321 100644 --- a/src/multiplayer/postprocessor.cpp +++ b/src/multiplayer/postprocessor.cpp @@ -5,11 +5,13 @@ BASIC_REPLICATION_IMPL(GlitchPostProcessorReplication, GlitchPostProcessor) BASIC_REPLICATION_FIELD(max_radius); BASIC_REPLICATION_FIELD(min_radius); - BASIC_REPLICATION_FIELD(effect_strength); + BASIC_REPLICATION_FIELD(max_effect_strength); + BASIC_REPLICATION_FIELD(min_effect_strength); } BASIC_REPLICATION_IMPL(WarpPostProcessorReplication, WarpPostProcessor) BASIC_REPLICATION_FIELD(max_radius); BASIC_REPLICATION_FIELD(min_radius); - BASIC_REPLICATION_FIELD(effect_strength); + BASIC_REPLICATION_FIELD(max_effect_strength); + BASIC_REPLICATION_FIELD(min_effect_strength); } diff --git a/src/script/components.cpp b/src/script/components.cpp index 5e322a5125..f8ba81f17d 100644 --- a/src/script/components.cpp +++ b/src/script/components.cpp @@ -602,6 +602,8 @@ void initComponentScriptBindings() BIND_MEMBER_NAMED(MissileTubes, storage_max[int(MW_EMP)], "max_emp"); BIND_MEMBER_NAMED(MissileTubes, storage[int(MW_HVLI)], "storage_hvli"); BIND_MEMBER_NAMED(MissileTubes, storage_max[int(MW_HVLI)], "max_hvli"); + BIND_MEMBER_NAMED(MissileTubes, storage[int(MW_Pylon)], "storage_pylon"); + BIND_MEMBER_NAMED(MissileTubes, storage_max[int(MW_Pylon)], "max_pylon"); BIND_ARRAY(MissileTubes, mounts); BIND_ARRAY_MEMBER(MissileTubes, mounts, position); BIND_ARRAY_MEMBER(MissileTubes, mounts, load_time); @@ -610,6 +612,8 @@ void initComponentScriptBindings() BIND_ARRAY_MEMBER_FLAG(MissileTubes, mounts, type_allowed_mask, "allow_mine", 1 << MW_Mine); BIND_ARRAY_MEMBER_FLAG(MissileTubes, mounts, type_allowed_mask, "allow_emp", 1 << MW_EMP); BIND_ARRAY_MEMBER_FLAG(MissileTubes, mounts, type_allowed_mask, "allow_hvli", 1 << MW_HVLI); + BIND_ARRAY_MEMBER_FLAG(MissileTubes, mounts, type_allowed_mask, "allow_pylon", 1 << MW_Pylon); + BIND_ARRAY_MEMBER(MissileTubes, mounts, direction); BIND_ARRAY_MEMBER(MissileTubes, mounts, size); BIND_ARRAY_MEMBER(MissileTubes, mounts, type_loaded); @@ -782,6 +786,7 @@ void initComponentScriptBindings() BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_Mine)], "give_mine"); BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_EMP)], "give_emp"); BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_HVLI)], "give_hvli"); + BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_Pylon)], "give_pylon"); sp::script::ComponentHandler::name("collision_callback"); BIND_MEMBER(CollisionCallback, callback); @@ -797,12 +802,14 @@ void initComponentScriptBindings() BIND_ARRAY_DIRTY_FLAG_MEMBER(CustomShipFunctions, functions, order, functions_dirty); sp::script::ComponentHandler::name("glitchpostprocessor"); - BIND_MEMBER(GlitchPostProcessor, effect_strength); + BIND_MEMBER(GlitchPostProcessor, min_effect_strength); + BIND_MEMBER(GlitchPostProcessor, max_effect_strength); BIND_MEMBER(GlitchPostProcessor, min_radius); BIND_MEMBER(GlitchPostProcessor, max_radius); sp::script::ComponentHandler::name("warppostprocessor"); - BIND_MEMBER(WarpPostProcessor, effect_strength); + BIND_MEMBER(WarpPostProcessor, min_effect_strength); + BIND_MEMBER(WarpPostProcessor, max_effect_strength); BIND_MEMBER(WarpPostProcessor, min_radius); BIND_MEMBER(WarpPostProcessor, max_radius); diff --git a/src/systems/postprocessor.cpp b/src/systems/postprocessor.cpp index 8c0a32c074..42ea49d108 100644 --- a/src/systems/postprocessor.cpp +++ b/src/systems/postprocessor.cpp @@ -31,13 +31,13 @@ void PostProcessorSystem::updatePostProcessor(sp::ecs::Entity& source, PostProce continue; float alpha_strength = 0.0f; - + if (dist2 < postprocessor.min_radius*postprocessor.min_radius){ // Inside of min_radius, use max strength effect - alpha_strength = postprocessor.effect_strength; + alpha_strength = postprocessor.max_effect_strength; } else { // Outside of min_radius, scale effect by distance - alpha_strength = Tween::easeInQuartic(dist2, postprocessor.max_radius*postprocessor.max_radius, postprocessor.min_radius*postprocessor.min_radius, 0.0f, postprocessor.effect_strength ); + alpha_strength = Tween::easeInQuartic(dist2, postprocessor.max_radius*postprocessor.max_radius, postprocessor.min_radius*postprocessor.min_radius, postprocessor.min_effect_strength, postprocessor.max_effect_strength ); } switch (type){ From 66fa58713b46ddf367118e4c6eb8fa206d0a687f Mon Sep 17 00:00:00 2001 From: Dave Kapell Date: Tue, 10 Mar 2026 13:29:30 -0400 Subject: [PATCH 07/12] Remove custom code --- src/script/components.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/script/components.cpp b/src/script/components.cpp index f8ba81f17d..d2c99e2744 100644 --- a/src/script/components.cpp +++ b/src/script/components.cpp @@ -602,8 +602,6 @@ void initComponentScriptBindings() BIND_MEMBER_NAMED(MissileTubes, storage_max[int(MW_EMP)], "max_emp"); BIND_MEMBER_NAMED(MissileTubes, storage[int(MW_HVLI)], "storage_hvli"); BIND_MEMBER_NAMED(MissileTubes, storage_max[int(MW_HVLI)], "max_hvli"); - BIND_MEMBER_NAMED(MissileTubes, storage[int(MW_Pylon)], "storage_pylon"); - BIND_MEMBER_NAMED(MissileTubes, storage_max[int(MW_Pylon)], "max_pylon"); BIND_ARRAY(MissileTubes, mounts); BIND_ARRAY_MEMBER(MissileTubes, mounts, position); BIND_ARRAY_MEMBER(MissileTubes, mounts, load_time); @@ -612,8 +610,7 @@ void initComponentScriptBindings() BIND_ARRAY_MEMBER_FLAG(MissileTubes, mounts, type_allowed_mask, "allow_mine", 1 << MW_Mine); BIND_ARRAY_MEMBER_FLAG(MissileTubes, mounts, type_allowed_mask, "allow_emp", 1 << MW_EMP); BIND_ARRAY_MEMBER_FLAG(MissileTubes, mounts, type_allowed_mask, "allow_hvli", 1 << MW_HVLI); - BIND_ARRAY_MEMBER_FLAG(MissileTubes, mounts, type_allowed_mask, "allow_pylon", 1 << MW_Pylon); - + BIND_ARRAY_MEMBER(MissileTubes, mounts, direction); BIND_ARRAY_MEMBER(MissileTubes, mounts, size); BIND_ARRAY_MEMBER(MissileTubes, mounts, type_loaded); @@ -786,8 +783,7 @@ void initComponentScriptBindings() BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_Mine)], "give_mine"); BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_EMP)], "give_emp"); BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_HVLI)], "give_hvli"); - BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_Pylon)], "give_pylon"); - + sp::script::ComponentHandler::name("collision_callback"); BIND_MEMBER(CollisionCallback, callback); BIND_MEMBER(CollisionCallback, player); From 61b41365b5c4adaa34f07141c7f2c9fb61356264 Mon Sep 17 00:00:00 2001 From: Dave Kapell Date: Tue, 10 Mar 2026 14:00:35 -0400 Subject: [PATCH 08/12] merge changes from upstream --- src/script/components.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/script/components.cpp b/src/script/components.cpp index d2c99e2744..2e92be6c8e 100644 --- a/src/script/components.cpp +++ b/src/script/components.cpp @@ -783,7 +783,11 @@ void initComponentScriptBindings() BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_Mine)], "give_mine"); BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_EMP)], "give_emp"); BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_HVLI)], "give_hvli"); +<<<<<<< Updated upstream +======= + +>>>>>>> Stashed changes sp::script::ComponentHandler::name("collision_callback"); BIND_MEMBER(CollisionCallback, callback); BIND_MEMBER(CollisionCallback, player); From 4f4b1b33a69b3a8438a71363d531a1bbf1015fa7 Mon Sep 17 00:00:00 2001 From: Dave Kapell Date: Tue, 10 Mar 2026 14:05:57 -0400 Subject: [PATCH 09/12] update comments from master --- scripts/api/entity/blackhole.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/api/entity/blackhole.lua b/scripts/api/entity/blackhole.lua index 4b7364a8c8..32705a17b4 100644 --- a/scripts/api/entity/blackhole.lua +++ b/scripts/api/entity/blackhole.lua @@ -24,8 +24,8 @@ function BlackHole(radius) end ---- A WormHole is a piece of space terrain that pulls all nearby SpaceObjects within a 2.5U radius, including otherwise immobile objects like SpaceStations, toward its center. ---- Any SpaceObject that reaches its center is teleported to another point in space. +--- A WormHole is a piece of space terrain that pulls all nearby entities within a 2.5U radius, including otherwise immobile entities like stations, toward its center. +--- Any entity that reaches its center is teleported to another point in space. --- AI behaviors avoid WormHoles by a 0.5U margin. --- The optional radius parameter specifies the radius of the WormHole, default 2500 --- Example: wormhole = WormHole():setPosition(1000,1000):setTargetPosition(10000,10000) From d8c63743e7a85dca2efb3801683b12d4e20f2f76 Mon Sep 17 00:00:00 2001 From: Dave Kapell Date: Tue, 10 Mar 2026 14:16:56 -0400 Subject: [PATCH 10/12] Remove git diff message --- src/script/components.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/script/components.cpp b/src/script/components.cpp index 2e92be6c8e..2261115047 100644 --- a/src/script/components.cpp +++ b/src/script/components.cpp @@ -783,11 +783,7 @@ void initComponentScriptBindings() BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_Mine)], "give_mine"); BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_EMP)], "give_emp"); BIND_MEMBER_NAMED(PickupCallback, give_missile[int(MW_HVLI)], "give_hvli"); -<<<<<<< Updated upstream - -======= ->>>>>>> Stashed changes sp::script::ComponentHandler::name("collision_callback"); BIND_MEMBER(CollisionCallback, callback); BIND_MEMBER(CollisionCallback, player); From 9761ad223bafa28ac2b7a77300ad5c810f79ccd8 Mon Sep 17 00:00:00 2001 From: Dave Kapell Date: Tue, 10 Mar 2026 14:18:03 -0400 Subject: [PATCH 11/12] remove added whitespace --- src/script/components.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/script/components.cpp b/src/script/components.cpp index 2261115047..20ca25a2eb 100644 --- a/src/script/components.cpp +++ b/src/script/components.cpp @@ -610,7 +610,6 @@ void initComponentScriptBindings() BIND_ARRAY_MEMBER_FLAG(MissileTubes, mounts, type_allowed_mask, "allow_mine", 1 << MW_Mine); BIND_ARRAY_MEMBER_FLAG(MissileTubes, mounts, type_allowed_mask, "allow_emp", 1 << MW_EMP); BIND_ARRAY_MEMBER_FLAG(MissileTubes, mounts, type_allowed_mask, "allow_hvli", 1 << MW_HVLI); - BIND_ARRAY_MEMBER(MissileTubes, mounts, direction); BIND_ARRAY_MEMBER(MissileTubes, mounts, size); BIND_ARRAY_MEMBER(MissileTubes, mounts, type_loaded); From 85dc9c4436aee2da72cdc003e9a6d91d3ed4d865 Mon Sep 17 00:00:00 2001 From: Dave Kapell Date: Wed, 11 Mar 2026 07:21:55 -0400 Subject: [PATCH 12/12] Add braces to if statement to make gravity hardware parameter correct --- src/systems/gravity.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/systems/gravity.cpp b/src/systems/gravity.cpp index c43e7867f0..901845d5dc 100644 --- a/src/systems/gravity.cpp +++ b/src/systems/gravity.cpp @@ -45,10 +45,11 @@ void GravitySystem::update(float delta) LuaConsole::checkResult(grav.on_teleportation.call(source, target)); continue; //callback could destroy the entity, so do no extra processing. } - if (player) + if (player){ // set just_teleported for use by hardware player->just_teleported = 2.0f; player->in_gravity = 0.0f; + } } } }