Sensor Ping

Added ping feature to sensors, pulsing a wave of revealing light into the level
Added IEventBehavior interface, used by sensors and weapons, for behaviors containing event subscriptions which need to be reset when EntityInstance is disposed
Implemented sensor impact for locked weapons (lock speed varies with sensor acquisition)
Added ping cooldown bar to HUD
Added spline curve implementations to AetheriaMath, applied better mapping to wormhole transition animation
Tweaked loadout generator to prefer larger items to a controllable degree (e.g. very important for cargo bays, less for shop inventory), shop inventory bans non-ship hulls and manages internal space more effectively
This commit is contained in:
Reinier Vens 2021-03-21 01:55:25 +00:00
commit 645fcf4b09
62 changed files with 115821 additions and 79 deletions

View file

@ -112,4 +112,81 @@ public static class AetheriaMath
return sqrt(dx * dx + dy * dy);
}
//Returns a position between 4 float3s with Catmull-Rom spline algorithm
//http://www.iquilezles.org/www/articles/minispline/minispline.htm
public static float GetCatmullRomPosition(float p0, float p1, float p2, float p3, float t)
{
//The coefficients of the cubic polynomial (except the 0.5f * which I added later for performance)
var a = 2f * p1;
var b = p2 - p0;
var c = 2f * p0 - 5f * p1 + 4f * p2 - p3;
var d = -p0 + 3f * p1 - 3f * p2 + p3;
//The cubic polynomial: a + b * t + c * t^2 + d * t^3
var pos = 0.5f * (a + (b * t) + (c * t * t) + (d * t * t * t));
return pos;
}
public static float3 GetCatmullRomPosition(float3 p0, float3 p1, float3 p2, float3 p3, float t)
{
//The coefficients of the cubic polynomial (except the 0.5f * which I added later for performance)
var a = 2f * p1;
var b = p2 - p0;
var c = 2f * p0 - 5f * p1 + 4f * p2 - p3;
var d = -p0 + 3f * p1 - 3f * p2 + p3;
//The cubic polynomial: a + b * t + c * t^2 + d * t^3
var pos = 0.5f * (a + (b * t) + (c * t * t) + (d * t * t * t));
return pos;
}
// https://catlikecoding.com/unity/tutorials/curves-and-splines/
public static float GetQuadraticSplinePosition(float p0, float p1, float p2, float t)
{
t = saturate(t);
var oneMinusT = 1f - t;
return
oneMinusT * oneMinusT * p0 +
2f * oneMinusT * t * p1 +
t * t * p2;
}
public static float3 GetQuadraticSplinePosition(float3 p0, float3 p1, float3 p2, float t)
{
t = saturate(t);
var oneMinusT = 1f - t;
return
oneMinusT * oneMinusT * p0 +
2f * oneMinusT * t * p1 +
t * t * p2;
}
public static float3 GetCubicSplinePosition (float p0, float p1, float p2, float p3, float t) {
t = saturate(t);
var oneMinusT = 1f - t;
return
oneMinusT * oneMinusT * oneMinusT * p0 +
3f * oneMinusT * oneMinusT * t * p1 +
3f * oneMinusT * t * t * p2 +
t * t * t * p3;
}
public static float3 GetCubicSplinePosition (float3 p0, float3 p1, float3 p2, float3 p3, float t) {
t = saturate(t);
var oneMinusT = 1f - t;
return
oneMinusT * oneMinusT * oneMinusT * p0 +
3f * oneMinusT * oneMinusT * t * p1 +
3f * oneMinusT * t * t * p2 +
t * t * t * p3;
}
public static float Smoothstep(float x)
{
x = saturate(x);
return x * x * (3 - 2 * x);
}
}