2026-08-10 14:57:50 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using UnityEngine;
|
2026-09-14 17:39:12 +02:00
|
|
|
|
using CultMath;
|
2026-09-19 14:10:59 +02:00
|
|
|
|
using CultMath.UnityBridge;
|
2026-09-14 17:39:12 +02:00
|
|
|
|
using static CultMath.math;
|
2026-08-10 14:57:50 +01:00
|
|
|
|
using Random = UnityEngine.Random;
|
|
|
|
|
|
using static Noise1D;
|
2026-09-14 17:39:12 +02:00
|
|
|
|
using float3 = CultMath.float3;
|
2026-08-10 14:57:50 +01:00
|
|
|
|
|
Fire control Cut 3: hit authority moves to FireControl
Deletes the Unity physics hit path (HullCollider.Hit/Splash, and the
raycast/shield/SendHit blocks in Projectile, GuidedProjectile, Laser and
Lightning) and replaces it with a single owner in the same cut: FireControl
now decides whether a shot hits, Zone owns the pending-shot lifecycle, and
Entity.DamageSchematic/ApplyHit (moved verbatim from EntityInstance) apply the
result. Presentation subscribes to Zone.ShotCommitted/ShotResolved and applies
nothing.
FireControl.HitProbability is the pure targeting solution (Accuracy * pSensor
* pSpread, gated by detection/range/lock/arc). FireControl.Fire freezes the
weapon's payload and the shooter's resolved targeting stats at the instant the
trigger is pulled (Q6), computes the predicted intercept through the one
shared PredictedIntercept function (CombatState now calls the same function
instead of duplicating first_order_intercept), and queues a PendingShot.
FireControl.Step commits each shot's outcome at ArrivalTime - CommitHorizon --
deviation from the predicted intercept, measured once, live, at that instant
-- and applies it at ArrivalTime. A shot whose flight is shorter than the
horizon commits and resolves in the same tick it fires. Rolls draw from the
shooter's own ItemManager.Random (Q5, seeded and reproducible); an out-of-arc
or otherwise gated shot draws nothing.
Player fire is arc-gated through the same predicate AI and turret fire use
(Weapon.ArcAllowsFire, checked in InstantWeapon.Trigger -- the one point every
shooter's trigger passes through), closing Q2.
Adds GameplaySettings.CommitHorizon, SchematicCellSize and
AgentMinHitProbability (first guesses; the headless suite is the tuning
harness, operator play smoke is the arbiter).
FORK reported, not worked around silently: HullCollider.SendHit/SendSplash
cannot be deleted yet without breaking ConstantLaser.cs, ConstantLightning.cs,
ConstantParticleWeapon.cs, HitscanEffect.cs and Mine.cs, which still call them
from their own live Physics queries -- that's Cut 4's migration. They fire
into the void today: nothing subscribes to Hit/Splash any more for the four
weapon kinds this cut owns.
tests/Aetheria.Shared.Tests/FireAuthorityTests.cs pins the roll's seeding, the
gate-consumes-no-draw rule, resolve-on-arrival, the commit horizon and its
evasion window, short-flight degradation, the frozen-payload snapshot, aimed
hits, the item-then-hull damage order, the planar penetration march and the
shield-absorbs branch. FireControlTests.cs and InputCapacitorTests.cs are
updated for the new AI gate and OnFire(int) signature.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-19 14:07:07 +02:00
|
|
|
|
// Cut 3 (docs/fire-control-cut.md): the raycast, shield branch and SendHit are deleted -- FireControl already
|
|
|
|
|
|
// decided this shot's fate before this object was ever spawned (R8). The homing/guidance flight (the whole
|
|
|
|
|
|
// point of this presentation) is untouched; children spawned on split carry no damage of their own to apply
|
|
|
|
|
|
// either, since they never did anything but inherit their parent's now-deleted fields.
|
2026-08-10 14:57:50 +01:00
|
|
|
|
public class GuidedProjectile : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
public Prototype HitEffect;
|
|
|
|
|
|
public Prototype ChildProjectile;
|
|
|
|
|
|
public int Children;
|
|
|
|
|
|
public float SplitTime;
|
|
|
|
|
|
public float SplitSeparationForwardness;
|
|
|
|
|
|
public float SplitSeparationVelocity;
|
|
|
|
|
|
public ParticleSystem Particles;
|
|
|
|
|
|
public float FadeOutTime;
|
|
|
|
|
|
public AnimationCurve ThrustCurve;
|
|
|
|
|
|
public AnimationCurve GuidanceCurve;
|
|
|
|
|
|
public AnimationCurve LiftCurve;
|
|
|
|
|
|
public float Frequency;
|
|
|
|
|
|
public float Thrust;
|
|
|
|
|
|
public float TopSpeed;
|
|
|
|
|
|
public Transform Source;
|
|
|
|
|
|
public Func<Vector3> TargetPosition;
|
Fire control Cut 3: hit authority moves to FireControl
Deletes the Unity physics hit path (HullCollider.Hit/Splash, and the
raycast/shield/SendHit blocks in Projectile, GuidedProjectile, Laser and
Lightning) and replaces it with a single owner in the same cut: FireControl
now decides whether a shot hits, Zone owns the pending-shot lifecycle, and
Entity.DamageSchematic/ApplyHit (moved verbatim from EntityInstance) apply the
result. Presentation subscribes to Zone.ShotCommitted/ShotResolved and applies
nothing.
FireControl.HitProbability is the pure targeting solution (Accuracy * pSensor
* pSpread, gated by detection/range/lock/arc). FireControl.Fire freezes the
weapon's payload and the shooter's resolved targeting stats at the instant the
trigger is pulled (Q6), computes the predicted intercept through the one
shared PredictedIntercept function (CombatState now calls the same function
instead of duplicating first_order_intercept), and queues a PendingShot.
FireControl.Step commits each shot's outcome at ArrivalTime - CommitHorizon --
deviation from the predicted intercept, measured once, live, at that instant
-- and applies it at ArrivalTime. A shot whose flight is shorter than the
horizon commits and resolves in the same tick it fires. Rolls draw from the
shooter's own ItemManager.Random (Q5, seeded and reproducible); an out-of-arc
or otherwise gated shot draws nothing.
Player fire is arc-gated through the same predicate AI and turret fire use
(Weapon.ArcAllowsFire, checked in InstantWeapon.Trigger -- the one point every
shooter's trigger passes through), closing Q2.
Adds GameplaySettings.CommitHorizon, SchematicCellSize and
AgentMinHitProbability (first guesses; the headless suite is the tuning
harness, operator play smoke is the arbiter).
FORK reported, not worked around silently: HullCollider.SendHit/SendSplash
cannot be deleted yet without breaking ConstantLaser.cs, ConstantLightning.cs,
ConstantParticleWeapon.cs, HitscanEffect.cs and Mine.cs, which still call them
from their own live Physics queries -- that's Cut 4's migration. They fire
into the void today: nothing subscribes to Hit/Splash any more for the four
weapon kinds this cut owns.
tests/Aetheria.Shared.Tests/FireAuthorityTests.cs pins the roll's seeding, the
gate-consumes-no-draw rule, resolve-on-arrival, the commit horizon and its
evasion window, short-flight degradation, the frozen-payload snapshot, aimed
hits, the item-then-hull damage order, the planar penetration march and the
shield-absorbs branch. FireControlTests.cs and InputCapacitorTests.cs are
updated for the new AI gate and OnFire(int) signature.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-19 14:07:07 +02:00
|
|
|
|
|
2026-08-10 14:57:50 +01:00
|
|
|
|
private float _phase;
|
|
|
|
|
|
private float _prevDist;
|
|
|
|
|
|
private bool _active;
|
|
|
|
|
|
private bool _alive;
|
|
|
|
|
|
private Vector3 _targetVelocity;
|
|
|
|
|
|
private Vector3 _previousTargetPosition;
|
Fire control Cut 3: hit authority moves to FireControl
Deletes the Unity physics hit path (HullCollider.Hit/Splash, and the
raycast/shield/SendHit blocks in Projectile, GuidedProjectile, Laser and
Lightning) and replaces it with a single owner in the same cut: FireControl
now decides whether a shot hits, Zone owns the pending-shot lifecycle, and
Entity.DamageSchematic/ApplyHit (moved verbatim from EntityInstance) apply the
result. Presentation subscribes to Zone.ShotCommitted/ShotResolved and applies
nothing.
FireControl.HitProbability is the pure targeting solution (Accuracy * pSensor
* pSpread, gated by detection/range/lock/arc). FireControl.Fire freezes the
weapon's payload and the shooter's resolved targeting stats at the instant the
trigger is pulled (Q6), computes the predicted intercept through the one
shared PredictedIntercept function (CombatState now calls the same function
instead of duplicating first_order_intercept), and queues a PendingShot.
FireControl.Step commits each shot's outcome at ArrivalTime - CommitHorizon --
deviation from the predicted intercept, measured once, live, at that instant
-- and applies it at ArrivalTime. A shot whose flight is shorter than the
horizon commits and resolves in the same tick it fires. Rolls draw from the
shooter's own ItemManager.Random (Q5, seeded and reproducible); an out-of-arc
or otherwise gated shot draws nothing.
Player fire is arc-gated through the same predicate AI and turret fire use
(Weapon.ArcAllowsFire, checked in InstantWeapon.Trigger -- the one point every
shooter's trigger passes through), closing Q2.
Adds GameplaySettings.CommitHorizon, SchematicCellSize and
AgentMinHitProbability (first guesses; the headless suite is the tuning
harness, operator play smoke is the arbiter).
FORK reported, not worked around silently: HullCollider.SendHit/SendSplash
cannot be deleted yet without breaking ConstantLaser.cs, ConstantLightning.cs,
ConstantParticleWeapon.cs, HitscanEffect.cs and Mine.cs, which still call them
from their own live Physics queries -- that's Cut 4's migration. They fire
into the void today: nothing subscribes to Hit/Splash any more for the four
weapon kinds this cut owns.
tests/Aetheria.Shared.Tests/FireAuthorityTests.cs pins the roll's seeding, the
gate-consumes-no-draw rule, resolve-on-arrival, the commit horizon and its
evasion window, short-flight degradation, the frozen-payload snapshot, aimed
hits, the item-then-hull damage order, the planar penetration march and the
shield-absorbs branch. FireControlTests.cs and InputCapacitorTests.cs are
updated for the new AI gate and OnFire(int) signature.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-19 14:07:07 +02:00
|
|
|
|
|
|
|
|
|
|
// Cut 3: FireControl.Fire's ShotId -- this missile's handle onto Zone.ShotCommitted/ShotResolved.
|
|
|
|
|
|
public int ShotId { get; set; }
|
2026-08-10 14:57:50 +01:00
|
|
|
|
public Transform Target { get; set; }
|
|
|
|
|
|
public float3 StartPosition { get; set; }
|
|
|
|
|
|
public float Range { get; set; }
|
|
|
|
|
|
public Vector3 Velocity { get; set; }
|
|
|
|
|
|
public Entity SourceEntity { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public event Action OnKill;
|
|
|
|
|
|
|
|
|
|
|
|
void OnEnable()
|
|
|
|
|
|
{
|
|
|
|
|
|
_active = _alive = true;
|
|
|
|
|
|
_phase = Random.value * 100;
|
|
|
|
|
|
_prevDist = Single.MaxValue;
|
|
|
|
|
|
Particles.startColor = Color.white;
|
|
|
|
|
|
//var main = Particles.main;
|
|
|
|
|
|
//main.startColor = new ParticleSystem.MinMaxGradient { mode = ParticleSystemGradientMode.Color, color = Color.white };
|
|
|
|
|
|
Particles.Clear(true);
|
|
|
|
|
|
Particles.Play(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Update ()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SourceEntity == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
var t = transform;
|
|
|
|
|
|
|
|
|
|
|
|
if (_active)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (TargetPosition == null && !Target)
|
|
|
|
|
|
{
|
|
|
|
|
|
StartCoroutine(FadeOut());
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
Convert engine types through CultMath.UnityBridge
CultMath has no implicit conversions to or from Vector*, Quaternion or
Color, so Assembly-CSharp converts explicitly with ToCultMath/ToUnity at
each engine boundary: FieldDriver, GuidedProjectile(Manager),
EntityInstance, ActionGameManager, HullCollider, GridObject, ShipInstance,
ShieldManager, ItemPickup, FieldTester, PlaceUIElementWorldspace,
MapMenuInput, MapRenderer, SectorRenderer and ZoneRenderer. CultMath math
calls that were handed Unity vectors now take converted values;
Vector3.Scale in FieldDriver becomes a float3 product, and ItemPickup's
Vector3.Dot on float3s becomes dot. packages-lock.json records the
cultmath git package at f0605367 and demotes com.unity.mathematics to a
transitive dependency.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 17:47:33 +02:00
|
|
|
|
var position = t.position.ToCultMath();
|
2026-08-10 14:57:50 +01:00
|
|
|
|
|
|
|
|
|
|
var targetPosition = TargetPosition?.Invoke() ?? Target.position;
|
Convert engine types through CultMath.UnityBridge
CultMath has no implicit conversions to or from Vector*, Quaternion or
Color, so Assembly-CSharp converts explicitly with ToCultMath/ToUnity at
each engine boundary: FieldDriver, GuidedProjectile(Manager),
EntityInstance, ActionGameManager, HullCollider, GridObject, ShipInstance,
ShieldManager, ItemPickup, FieldTester, PlaceUIElementWorldspace,
MapMenuInput, MapRenderer, SectorRenderer and ZoneRenderer. CultMath math
calls that were handed Unity vectors now take converted values;
Vector3.Scale in FieldDriver becomes a float3 product, and ItemPickup's
Vector3.Dot on float3s becomes dot. packages-lock.json records the
cultmath git package at f0605367 and demotes com.unity.mathematics to a
transitive dependency.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 17:47:33 +02:00
|
|
|
|
_targetVelocity = lerp(_targetVelocity.ToCultMath(), (targetPosition - _previousTargetPosition).ToCultMath(), saturate(Time.deltaTime * 5)).ToUnity();
|
2026-08-10 14:57:50 +01:00
|
|
|
|
_previousTargetPosition = targetPosition;
|
Delete AetheriaMath in favour of CultMath
AetheriaMath predates the CultMath swap and re-implemented helpers CultMath
now owns. Callers use CultMath directly: decay (Ship, AetherDrive, Entity),
damp (VelocityConversion, FieldTester, FieldDriver), first_order_intercept
(TurretController, Combat, GuidedProjectile), quadratic_bezier (FieldDriver)
and smootherstep (Ship). Parameter order matches in every case, and those
formulas have the same float evaluation order, so behaviour is unchanged.
Galaxy's commented-out segment check names distance_to_segment.
The other overloads had no callers and are dropped without a CultMath
counterpart being needed: the double Damp overloads, FindDistanceToSegment,
GetCatmullRomPosition, GetCubicSplinePosition, Smoothstep(x), and the
Deg2Rad/Rad2Deg constants.
AetherDb census, factions and hardpoint-fit are byte-identical to the
pre-cut captures.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 18:02:41 +02:00
|
|
|
|
targetPosition = first_order_intercept(position,float3.zero, TopSpeed, targetPosition.ToCultMath(), _targetVelocity.ToCultMath()).ToUnity();
|
2026-08-10 14:57:50 +01:00
|
|
|
|
|
|
|
|
|
|
var diff = targetPosition - transform.position;
|
|
|
|
|
|
var targetDist = diff.magnitude;
|
|
|
|
|
|
var sourceDist = length(StartPosition.xz - position.xz);
|
|
|
|
|
|
|
Convert engine types through CultMath.UnityBridge
CultMath has no implicit conversions to or from Vector*, Quaternion or
Color, so Assembly-CSharp converts explicitly with ToCultMath/ToUnity at
each engine boundary: FieldDriver, GuidedProjectile(Manager),
EntityInstance, ActionGameManager, HullCollider, GridObject, ShipInstance,
ShieldManager, ItemPickup, FieldTester, PlaceUIElementWorldspace,
MapMenuInput, MapRenderer, SectorRenderer and ZoneRenderer. CultMath math
calls that were handed Unity vectors now take converted values;
Vector3.Scale in FieldDriver becomes a float3 product, and ItemPickup's
Vector3.Dot on float3s becomes dot. packages-lock.json records the
cultmath git package at f0605367 and demotes com.unity.mathematics to a
transitive dependency.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 17:47:33 +02:00
|
|
|
|
if (sourceDist > Range || dot(diff.ToCultMath(), Velocity.ToCultMath()) < 0)
|
2026-08-10 14:57:50 +01:00
|
|
|
|
{
|
|
|
|
|
|
StartCoroutine(FadeOut());
|
|
|
|
|
|
if (HitEffect != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var ht = HitEffect.Instantiate<Transform>();
|
|
|
|
|
|
ht.position = t.position;
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
_prevDist = targetDist;
|
|
|
|
|
|
|
|
|
|
|
|
var targetDistFlat = diff.Flatland().magnitude;
|
|
|
|
|
|
var curveLerp = 1 - targetDistFlat / (sourceDist + targetDistFlat);
|
|
|
|
|
|
var dir = diff.normalized;
|
Convert engine types through CultMath.UnityBridge
CultMath has no implicit conversions to or from Vector*, Quaternion or
Color, so Assembly-CSharp converts explicitly with ToCultMath/ToUnity at
each engine boundary: FieldDriver, GuidedProjectile(Manager),
EntityInstance, ActionGameManager, HullCollider, GridObject, ShipInstance,
ShieldManager, ItemPickup, FieldTester, PlaceUIElementWorldspace,
MapMenuInput, MapRenderer, SectorRenderer and ZoneRenderer. CultMath math
calls that were handed Unity vectors now take converted values;
Vector3.Scale in FieldDriver becomes a float3 product, and ItemPickup's
Vector3.Dot on float3s becomes dot. packages-lock.json records the
cultmath git package at f0605367 and demotes com.unity.mathematics to a
transitive dependency.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 17:47:33 +02:00
|
|
|
|
var right = cross(dir.ToCultMath(), float3(0, 1, 0));
|
|
|
|
|
|
var up = cross(dir.ToCultMath(), right);
|
2026-08-10 14:57:50 +01:00
|
|
|
|
|
|
|
|
|
|
if (Children > 0 && SplitTime < curveLerp)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < Children; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var child = ChildProjectile.Instantiate<GuidedProjectile>();
|
|
|
|
|
|
child.transform.position = t.position;
|
|
|
|
|
|
child.StartPosition = StartPosition;
|
Convert engine types through CultMath.UnityBridge
CultMath has no implicit conversions to or from Vector*, Quaternion or
Color, so Assembly-CSharp converts explicitly with ToCultMath/ToUnity at
each engine boundary: FieldDriver, GuidedProjectile(Manager),
EntityInstance, ActionGameManager, HullCollider, GridObject, ShipInstance,
ShieldManager, ItemPickup, FieldTester, PlaceUIElementWorldspace,
MapMenuInput, MapRenderer, SectorRenderer and ZoneRenderer. CultMath math
calls that were handed Unity vectors now take converted values;
Vector3.Scale in FieldDriver becomes a float3 product, and ItemPickup's
Vector3.Dot on float3s becomes dot. packages-lock.json records the
cultmath git package at f0605367 and demotes com.unity.mathematics to a
transitive dependency.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 17:47:33 +02:00
|
|
|
|
var randomDirection = normalize(Random.insideUnitCircle.ToCultMath());
|
2026-08-10 14:57:50 +01:00
|
|
|
|
var perpendicularRandom = randomDirection.x * right + randomDirection.y * up;
|
Convert engine types through CultMath.UnityBridge
CultMath has no implicit conversions to or from Vector*, Quaternion or
Color, so Assembly-CSharp converts explicitly with ToCultMath/ToUnity at
each engine boundary: FieldDriver, GuidedProjectile(Manager),
EntityInstance, ActionGameManager, HullCollider, GridObject, ShipInstance,
ShieldManager, ItemPickup, FieldTester, PlaceUIElementWorldspace,
MapMenuInput, MapRenderer, SectorRenderer and ZoneRenderer. CultMath math
calls that were handed Unity vectors now take converted values;
Vector3.Scale in FieldDriver becomes a float3 product, and ItemPickup's
Vector3.Dot on float3s becomes dot. packages-lock.json records the
cultmath git package at f0605367 and demotes com.unity.mathematics to a
transitive dependency.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 17:47:33 +02:00
|
|
|
|
child.Velocity = (normalize(lerp(perpendicularRandom, dir.ToCultMath(), SplitSeparationForwardness)) * length(Velocity.ToCultMath()) * SplitSeparationVelocity).ToUnity();
|
2026-08-10 14:57:50 +01:00
|
|
|
|
child.Range = Range;
|
|
|
|
|
|
child.Source = Source;
|
|
|
|
|
|
child.Target = Target;
|
|
|
|
|
|
child.SourceEntity = SourceEntity;
|
|
|
|
|
|
child.GuidanceCurve = GuidanceCurve;
|
|
|
|
|
|
child.LiftCurve = LiftCurve;
|
|
|
|
|
|
child.ThrustCurve = ThrustCurve;
|
|
|
|
|
|
child.Thrust = Thrust;
|
|
|
|
|
|
child.TopSpeed = TopSpeed;
|
|
|
|
|
|
child.Frequency = Frequency;
|
|
|
|
|
|
child.Thrust = Thrust;
|
|
|
|
|
|
}
|
|
|
|
|
|
StartCoroutine(Kill());
|
|
|
|
|
|
if (HitEffect != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var ht = HitEffect.Instantiate<Transform>();
|
|
|
|
|
|
ht.position = t.position;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var dodge = normalize(lerp(
|
|
|
|
|
|
normalize(right * noise(Time.time * Frequency + _phase) + up * noise(Time.time * Frequency + (100 + _phase))),
|
Convert engine types through CultMath.UnityBridge
CultMath has no implicit conversions to or from Vector*, Quaternion or
Color, so Assembly-CSharp converts explicitly with ToCultMath/ToUnity at
each engine boundary: FieldDriver, GuidedProjectile(Manager),
EntityInstance, ActionGameManager, HullCollider, GridObject, ShipInstance,
ShieldManager, ItemPickup, FieldTester, PlaceUIElementWorldspace,
MapMenuInput, MapRenderer, SectorRenderer and ZoneRenderer. CultMath math
calls that were handed Unity vectors now take converted values;
Vector3.Scale in FieldDriver becomes a float3 product, and ItemPickup's
Vector3.Dot on float3s becomes dot. packages-lock.json records the
cultmath git package at f0605367 and demotes com.unity.mathematics to a
transitive dependency.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 17:47:33 +02:00
|
|
|
|
float3(0, 1, 0), LiftCurve.Evaluate(curveLerp))).ToUnity();
|
2026-08-10 14:57:50 +01:00
|
|
|
|
var desired = Vector3.Slerp(dodge, dir, GuidanceCurve.Evaluate(curveLerp)).normalized * TopSpeed;
|
|
|
|
|
|
var thrustCurve = ThrustCurve.Evaluate(curveLerp);
|
|
|
|
|
|
var thrust = Thrust * thrustCurve;
|
|
|
|
|
|
var c = Color.white * thrustCurve;
|
|
|
|
|
|
c.a = 1;
|
|
|
|
|
|
Particles.startColor = c;
|
|
|
|
|
|
Velocity += (desired-Velocity).normalized * (thrust * Time.deltaTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(_alive)
|
|
|
|
|
|
{
|
|
|
|
|
|
t.position += Velocity * Time.deltaTime;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerator FadeOut()
|
|
|
|
|
|
{
|
|
|
|
|
|
_active = false;
|
|
|
|
|
|
var startTime = Time.time;
|
|
|
|
|
|
while (Time.time - startTime < FadeOutTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
var lerp = 1 - (Time.time - startTime) / FadeOutTime;
|
|
|
|
|
|
var c = Color.white * lerp;
|
|
|
|
|
|
c.a = 1;
|
|
|
|
|
|
Particles.startColor = c;
|
|
|
|
|
|
//var main = Particles.main;
|
|
|
|
|
|
//main.startColor = new ParticleSystem.MinMaxGradient { mode = ParticleSystemGradientMode.Color, color = Color.white * lerp };
|
|
|
|
|
|
yield return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
StartCoroutine(Kill());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerator Kill()
|
|
|
|
|
|
{
|
|
|
|
|
|
_active = false;
|
|
|
|
|
|
_alive = false;
|
|
|
|
|
|
Particles.Stop(true, ParticleSystemStopBehavior.StopEmitting);
|
|
|
|
|
|
var startTime = Time.time;
|
|
|
|
|
|
var lifetime = Particles.main.startLifetime.constant;
|
|
|
|
|
|
while (Time.time - startTime < lifetime)
|
|
|
|
|
|
{
|
|
|
|
|
|
yield return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
OnKill?.Invoke();
|
|
|
|
|
|
GetComponent<Prototype>().ReturnToPool();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|