Presenters read the drawn pose: HUD markers, wells, rounds, ping, shield hit, compass, loot view, guided aim
HUD target, lock, incoming-lock, bearing and sweep markers anchor on DrawAhead.Position / AtBearing at Clock.Lead. GravityLowering's record fill is DrawAhead.Well (pure, pinned at non-zero lead). Rounds take DrawAhead.Time instead of float Zone.Time + lead. Sensor ping, shield hit, compass icons, wormhole bearing, loot ViewOrigin and the guided-projectile aim read the drawn pose. Not built in Unity yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6c865b2cc9
commit
2cb1e83353
10 changed files with 121 additions and 35 deletions
|
|
@ -1460,13 +1460,15 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
if (CurrentEntity == null || CurrentEntity.Parent != null) return;
|
||||
|
||||
var lead = Clock.Lead;
|
||||
var ownDrawn = DrawAhead.Position(CurrentEntity, lead);
|
||||
ViewDot.Target = ZoneRenderer.EntityInstances[CurrentEntity].LookAtPoint.position;
|
||||
var target = CurrentEntity.Target.Value;
|
||||
if (target.Chunk is ChunkId chunk)
|
||||
TargetIndicator.Target = ChunkWorldPosition(chunk).ToUnity();
|
||||
else if (target.Entity != null)
|
||||
TargetIndicator.Target = target.Entity.Position.ToUnity();
|
||||
var distance = length(ViewDot.Target.ToCultMath() - CurrentEntity.Position);
|
||||
TargetIndicator.Target = DrawAhead.Position(target.Entity, lead).ToUnity();
|
||||
var distance = length(ViewDot.Target.ToCultMath() - ownDrawn);
|
||||
foreach (var (_, barrels, crosshair) in _articulationGroups)
|
||||
{
|
||||
var averagePosition = Vector3.zero;
|
||||
|
|
@ -1484,7 +1486,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
indicator.gameObject.SetActive(showIndicator);
|
||||
if(showIndicator)
|
||||
{
|
||||
indicator.Target = targetEntity.Position.ToUnity();
|
||||
indicator.Target = DrawAhead.Position(targetEntity, lead).ToUnity();
|
||||
ApplyLockProgress(indicator, spin, value);
|
||||
}
|
||||
}
|
||||
|
|
@ -1501,8 +1503,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
if (strongest >= 0)
|
||||
{
|
||||
var warning = warnings[strongest];
|
||||
incomingIndicator.Target = CurrentEntity.Position.ToUnity() +
|
||||
new Vector3(warning.Bearing.x, 0, warning.Bearing.y) * IncomingLockIndicatorDistance;
|
||||
incomingIndicator.Target = DrawAhead.AtBearing(CurrentEntity, warning.Bearing, IncomingLockIndicatorDistance, lead).ToUnity();
|
||||
ApplyLockProgress(incomingIndicator, incomingSpin, warning.Strength);
|
||||
}
|
||||
|
||||
|
|
@ -1533,7 +1534,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
marker.gameObject.SetActive(true);
|
||||
var bearing = CurrentEntity.ContactOf(subject).Bearing;
|
||||
marker.Place.Target = CurrentEntity.Position.ToUnity() + new Vector3(bearing.x, 0, bearing.y) * BearingMarkerDistance;
|
||||
marker.Place.Target = DrawAhead.AtBearing(CurrentEntity, bearing, BearingMarkerDistance, Clock.Lead).ToUnity();
|
||||
marker.ShowLabel(string.Join(", ", CurrentEntity.ClaimedClasses(subject).Select(c => c.Name)));
|
||||
}
|
||||
}
|
||||
|
|
@ -1572,7 +1573,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
_sweepFlashes.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
indicator.Target = CurrentEntity.Position.ToUnity() + new Vector3(bearing.x, 0, bearing.y) * IncomingLockIndicatorDistance;
|
||||
indicator.Target = DrawAhead.AtBearing(CurrentEntity, bearing, IncomingLockIndicatorDistance, Clock.Lead).ToUnity();
|
||||
if (image != null) image.color = new Color(image.color.r, image.color.g, image.color.b, 1 - age / SearchFlashSeconds);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ public class EntityInstance : MonoBehaviour
|
|||
{
|
||||
var pingInstance = Instantiate(PingPrefab);
|
||||
var pingMesh = pingInstance.GetComponent<MeshRenderer>();
|
||||
pingInstance.position = entity.Position.ToUnity();
|
||||
pingInstance.position = DrawAhead.Position(entity, ActionGameManager.Clock.Lead).ToUnity();
|
||||
_pingBrightness = pingMesh.material.GetFloat("_Depth");
|
||||
_currentPing = (pingInstance, pingMesh);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class ShieldManager : MonoBehaviour, IAbsorbPresenter
|
|||
{
|
||||
if (contact.A != Entity && contact.B != Entity) return;
|
||||
if (Entity.Shield != null && Entity.Shield.Item.Active.Value)
|
||||
ShowHit(new Vector3(contact.Point.x, Entity.Position.y, contact.Point.y), CollisionHitDuration);
|
||||
ShowHit(DrawAhead.Carried(Entity, float3(contact.Point.x, Entity.Position.y, contact.Point.y), ActionGameManager.Clock.Lead).ToUnity(), CollisionHitDuration);
|
||||
}
|
||||
|
||||
private ShieldEnvelope _envelope;
|
||||
|
|
|
|||
|
|
@ -77,7 +77,11 @@ public class GuidedProjectileManager : InstantWeaponEffectManager
|
|||
p.Velocity = barrel.forward * weapon.Velocity;
|
||||
p.Thrust = item.Evaluate(MunitionParts.Of<MunitionThrusterData>(item).Acceleration);
|
||||
p.TopSpeed = item.Evaluate(MunitionParts.Of<MunitionThrusterData>(item).MaxSpeed);
|
||||
p.TargetPosition = () => (source.Entity.Position + length(source.LookAtPoint.position.ToCultMath() - source.Entity.Position) * source.Entity.Aim).ToUnity();
|
||||
p.TargetPosition = () =>
|
||||
{
|
||||
var drawn = DrawAhead.Position(source.Entity, ActionGameManager.Clock.Lead);
|
||||
return (drawn + length(source.LookAtPoint.position.ToCultMath() - drawn) * source.Entity.Aim).ToUnity();
|
||||
};
|
||||
Bind(p, source.Entity.Zone, shotId);
|
||||
}
|
||||
else Debug.LogError($"Weapon {item.Data.Name} linked to {name} effect, but is not a Launcher!");
|
||||
|
|
|
|||
|
|
@ -50,8 +50,9 @@ public class Projectile : MonoBehaviour
|
|||
private void Draw()
|
||||
{
|
||||
var lead = ActionGameManager.Clock.Lead;
|
||||
transform.position = V(DrawAhead.Round(_shot, _known, _barrel, BlendTime, _zone.Time, lead));
|
||||
if (DrawAhead.RoundOver(_shot, _known, _zone.Time, lead)) Finish();
|
||||
var drawn = DrawAhead.Time(_zone, lead);
|
||||
transform.position = V(DrawAhead.Round(_shot, _known, _barrel, BlendTime, drawn, lead));
|
||||
if (DrawAhead.RoundOver(_shot, _known, drawn)) Finish();
|
||||
}
|
||||
|
||||
// The sim's commit: the record it holds now (a contact burst's arrival is shortened here) and what it decided.
|
||||
|
|
|
|||
|
|
@ -40,6 +40,32 @@ public static class DrawAhead
|
|||
return float3(planar.x, entity.RideHeight(planar, Time(entity.Zone, lead)), planar.y);
|
||||
}
|
||||
|
||||
// The point `distance` out along a planar bearing from the ship's drawn position: where the HUD anchors a marker to the
|
||||
// ship the camera follows (an incoming lock, a remembered contact, a ping's flash).
|
||||
public static float3 AtBearing(Entity origin, float2 bearing, float distance, float lead)
|
||||
{
|
||||
var at = Position(origin, lead);
|
||||
return float3(at.x + bearing.x * distance, at.y, at.z + bearing.y * distance);
|
||||
}
|
||||
|
||||
// One well as the shader takes it: its body's rail at the drawn time, with the strength, core and reference the sim's
|
||||
// GetHeight sums with. GravityLowering copies it into the shader's record and decides nothing.
|
||||
public readonly struct DrawnWell
|
||||
{
|
||||
public readonly float2 Position;
|
||||
public readonly float Strength, CoreRadius, Reference;
|
||||
public DrawnWell(float2 position, float strength, float coreRadius, float reference)
|
||||
{
|
||||
Position = position;
|
||||
Strength = strength;
|
||||
CoreRadius = coreRadius;
|
||||
Reference = reference;
|
||||
}
|
||||
}
|
||||
|
||||
public static DrawnWell Well(Zone zone, Planet body, float lead) =>
|
||||
new DrawnWell(Orbit(zone, body.BodyData.Orbit.Key, lead), body.WellStrength, body.RocheLimit, zone.WellReference(body));
|
||||
|
||||
// A free body (a vapour cloud) drawn where the frame falls lead sim seconds after the last step, by the velocity
|
||||
// that step moved it with: the launch velocity and the drift together.
|
||||
public static float2 Position(KinematicBody body, float lead) => body.Position + body.TotalVelocity * lead;
|
||||
|
|
@ -65,13 +91,13 @@ public static class DrawAhead
|
|||
t.w * q.w - t.x * q.x - t.y * q.y - t.z * q.z));
|
||||
}
|
||||
|
||||
// A ballistic round at a sim time (the clock's Zone.Time + Lead): on its frozen line while the outcome is unknown or a
|
||||
// A ballistic round at the drawn time (DrawAhead.Time, passed in by the caller, as lead is): on its frozen line while the outcome is unknown or a
|
||||
// miss, with the barrel's offset from that line decaying to nothing over blendTime sim seconds from the moment of firing.
|
||||
// A round the sim published as a hit or burst steers from its line, from the commit tick, onto where it ends by the
|
||||
// time damage lands: a burst's frozen point, else the impact cell on the target's drawn pose; and is held there after.
|
||||
public static float3 Round(in PendingShot shot, ShotOutcome known, float3 barrel, float blendTime, float simTime, float lead)
|
||||
public static float3 Round(in PendingShot shot, ShotOutcome known, float3 barrel, float blendTime, double drawnTime, float lead)
|
||||
{
|
||||
var time = simTime + lead;
|
||||
var time = (float) drawnTime;
|
||||
var drawn = Lifted(shot, Line(shot, known?.Result, time), barrel, blendTime, time);
|
||||
if (known == null || known.Result == ShotResult.Miss) return drawn;
|
||||
var end = known.HasBurstPoint
|
||||
|
|
@ -101,8 +127,8 @@ public static class DrawAhead
|
|||
}
|
||||
|
||||
// Whether the drawn flight is over by time: only a published miss ends by the clock. A hit or burst ends on ShotResolved.
|
||||
public static bool RoundOver(in PendingShot shot, ShotOutcome known, float simTime, float lead) =>
|
||||
known != null && known.Result == ShotResult.Miss && simTime + lead >= RoundEnd(shot, ShotResult.Miss);
|
||||
public static bool RoundOver(in PendingShot shot, ShotOutcome known, double drawnTime) =>
|
||||
known != null && known.Result == ShotResult.Miss && (float) drawnTime >= RoundEnd(shot, ShotResult.Miss);
|
||||
|
||||
// The sim time a round's drawn line ends, for what is known of its outcome. A round that hit or burst (or whose outcome
|
||||
// is not yet published) ends at its ArrivalTime; a round the sim has published as a Miss flies on to the weapon's frozen
|
||||
|
|
|
|||
|
|
@ -50,13 +50,13 @@ public static class GravityLowering
|
|||
if (zone != null)
|
||||
foreach (var body in zone.PlanetInstances.Values)
|
||||
{
|
||||
var at = DrawAhead.Orbit(zone, body.BodyData.Orbit.Key, lead);
|
||||
var well = DrawAhead.Well(zone, body, lead);
|
||||
_records[i++] = new WellRecord
|
||||
{
|
||||
Position = new Vector2(at.x, at.y),
|
||||
Strength = body.WellStrength,
|
||||
CoreRadius = body.RocheLimit,
|
||||
Reference = zone.WellReference(body)
|
||||
Position = new Vector2(well.Position.x, well.Position.y),
|
||||
Strength = well.Strength,
|
||||
CoreRadius = well.CoreRadius,
|
||||
Reference = well.Reference
|
||||
};
|
||||
}
|
||||
wells.SetData(_records);
|
||||
|
|
|
|||
|
|
@ -524,7 +524,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
GravityLowering.Lower(Zone, lead, ref _gravityWells);
|
||||
foreach (var loot in _floatingItems.Values)
|
||||
{
|
||||
loot.ViewOrigin = PerspectiveEntity.Position;
|
||||
loot.ViewOrigin = DrawAhead.Position(PerspectiveEntity, lead);
|
||||
loot.ViewDirection = PerspectiveEntity.Aim;
|
||||
}
|
||||
|
||||
|
|
@ -601,7 +601,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
{
|
||||
if(entityInstance.CompassIcon)
|
||||
{
|
||||
var difference = entityInstance.Entity.Position.xz - PerspectiveEntity.Position.xz;
|
||||
var difference = DrawAhead.Position(entityInstance.Entity, lead).xz - DrawAhead.Position(PerspectiveEntity, lead).xz;
|
||||
var distance = length(difference);
|
||||
|
||||
entityInstance.CompassIcon.gameObject.SetActive(
|
||||
|
|
@ -613,7 +613,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
|
||||
foreach (var wormhole in WormholeInstances.Values)
|
||||
{
|
||||
var difference = wormhole.gravity.transform.position.Flatland() - PerspectiveEntity.Position.xz.ToUnity();
|
||||
var difference = wormhole.gravity.transform.position.Flatland() - DrawAhead.Position(PerspectiveEntity, lead).xz.ToUnity();
|
||||
var distance = difference.magnitude;
|
||||
wormhole.icon.gameObject.SetActive(distance > _minimapDistance);
|
||||
wormhole.icon.transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg - 90);
|
||||
|
|
|
|||
Loading…
Reference in a new issue