Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
27 changes: 17 additions & 10 deletions scripts/api/entity/blackhole.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,46 @@
--- Upon reaching the center, any entity 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)
Comment thread
dkapell marked this conversation as resolved.
--- @type creation
function BlackHole()
function BlackHole(radius)
radius = radius or 5000
Comment thread
dkapell marked this conversation as resolved.
radius = math.max(0, radius)
local e = createEntity()
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, max_effect_strength=1 }
}
return e
end


--- 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.
--- 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.
Comment thread
dkapell marked this conversation as resolved.
Outdated
--- 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()
function WormHole(radius)
radius = radius or 2500
radius = math.max(0, radius)
local e = createEntity()
local radius = 2500
e.components = {
transform = {},
never_radar_blocked = {},
gravity = {range=radius, damage=false},
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, max_effect_strength=20}
}
return e
end
Expand Down
9 changes: 9 additions & 0 deletions src/components/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/components/postprocessor.cpp
Original file line number Diff line number Diff line change
@@ -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";
}
}
31 changes: 31 additions & 0 deletions src/components/postprocessor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

// Base class for Postproccessor components, never created directtly

class PostProcessorComponent
{
public:
enum class Type
{
Glitch,
Warp
};
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;
};

string getPostProcessorType(PostProcessorComponent::Type postprocessor);


class GlitchPostProcessor: public PostProcessorComponent{
public:
//Config

};

class WarpPostProcessor: public PostProcessorComponent{
public:
// Config
};
3 changes: 3 additions & 0 deletions src/hardware/hardwareController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion src/init/ecs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -129,10 +131,14 @@ void initSystemsAndComponents()
sp::ecs::MultiplayerReplication::registerComponentReplication<WarpDriveReplication>();
sp::ecs::MultiplayerReplication::registerComponentReplication<WarpJammerReplication>();
sp::ecs::MultiplayerReplication::registerComponentReplication<ZoneReplication>();
sp::ecs::MultiplayerReplication::registerComponentReplication<GlitchPostProcessorReplication>();
sp::ecs::MultiplayerReplication::registerComponentReplication<WarpPostProcessorReplication>();
sp::ecs::MultiplayerReplication::registerComponentReplication<sp::multiplayer::TransformReplication>();
sp::ecs::MultiplayerReplication::registerComponentReplication<sp::multiplayer::PhysicsReplication>();


engine->registerSystem<AISystem>();
engine->registerSystem<PlayerSystem>();
engine->registerSystem<DamageSystem>();
engine->registerSystem<EnergySystem>();
engine->registerSystem<DockingSystem>();
Expand Down Expand Up @@ -164,6 +170,8 @@ void initSystemsAndComponents()
engine->registerSystem<ZoneSystem>();
engine->registerSystem<GMRadarRender>();
engine->registerSystem<PickupSystem>();
engine->registerSystem<PostProcessorSystem>();

#ifdef DEBUG
engine->registerSystem<DebugRenderSystem>();
#endif
Expand Down
7 changes: 7 additions & 0 deletions src/multiplayer/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ BASIC_REPLICATION_IMPL(PlayerControlReplication, PlayerControl)

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);
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)
Expand Down
17 changes: 17 additions & 0 deletions src/multiplayer/postprocessor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#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(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(max_effect_strength);
BASIC_REPLICATION_FIELD(min_effect_strength);
}
7 changes: 7 additions & 0 deletions src/multiplayer/postprocessor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include "multiplayer/basic.h"
#include "components/postprocessor.h"

BASIC_REPLICATION_CLASS(GlitchPostProcessorReplication, GlitchPostProcessor);
BASIC_REPLICATION_CLASS(WarpPostProcessorReplication, WarpPostProcessor);
35 changes: 27 additions & 8 deletions src/screenComponents/indicatorOverlays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -92,23 +93,41 @@ void GuiIndicatorOverlays::onDraw(sp::RenderTarget& renderer)
{
auto jump = my_spaceship.getComponent<JumpDrive>();
auto warp = my_spaceship.getComponent<WarpDrive>();
auto player = my_spaceship.getComponent<PlayerControl>();
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 (player && player->just_teleported > 0.0f)
glitchMagnitude = std::max(glitchMagnitude, player->just_teleported * 10.0f);

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{
Expand Down
22 changes: 21 additions & 1 deletion src/script/components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "components/customshipfunction.h"
#include "components/zone.h"
#include "components/shiplog.h"
#include "components/postprocessor.h"


#define STRINGIFY(n) #n
Expand Down Expand Up @@ -609,6 +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(MissileTubes, mounts, direction);
BIND_ARRAY_MEMBER(MissileTubes, mounts, size);
BIND_ARRAY_MEMBER(MissileTubes, mounts, type_loaded);
Expand Down Expand Up @@ -652,6 +654,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<HackingDevice>::name("hacking_device");
BIND_MEMBER(HackingDevice, effectiveness);
sp::script::ComponentHandler<ShipLog>::name("ship_log");
Expand Down Expand Up @@ -775,7 +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");

sp::script::ComponentHandler<CollisionCallback>::name("collision_callback");
BIND_MEMBER(CollisionCallback, callback);
BIND_MEMBER(CollisionCallback, player);
Expand All @@ -789,6 +797,18 @@ 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<GlitchPostProcessor>::name("glitchpostprocessor");
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<WarpPostProcessor>::name("warppostprocessor");
BIND_MEMBER(WarpPostProcessor, min_effect_strength);
BIND_MEMBER(WarpPostProcessor, max_effect_strength);
BIND_MEMBER(WarpPostProcessor, min_radius);
BIND_MEMBER(WarpPostProcessor, max_radius);

sp::script::ComponentHandler<Zone>::name("zone");
BIND_MEMBER(Zone, color);
BIND_MEMBER(Zone, label);
Expand Down
17 changes: 9 additions & 8 deletions src/systems/gravity.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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<PlayerControl>();
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) {
Expand All @@ -46,8 +45,10 @@ void GravitySystem::update(float delta)
LuaConsole::checkResult(grav.on_teleportation.call<void>(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;
}
}
}
Expand Down
Loading