Presentation follows the committed shot, not the selection (F7)

EntityInstance handed effect managers the shooter's selected target whatever
FireControl decided. A fused round whose target was invalid or out of arc
flies at none, and GuidedProjectileManager dropped a launcher shot with no
target entirely, so a real burst had no missile.

- Zone.TryGetShot: a presentation reads the shot the simulation committed
  (its target, its burst point) by the ShotId OnFire hands it.
- EntityInstance passes the shot's own target; a launcher round with none
  flies to the shot's burst point.

Unity-only; compile-checked by reading.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-29 16:27:54 +02:00
commit 9c0029931a
3 changed files with 30 additions and 3 deletions

View file

@ -203,8 +203,11 @@ public class EntityInstance : MonoBehaviour
// Cut 3 (docs/fire-control-cut.md): carries the ShotId FireControl.Fire assigned so the
// effect manager (and whatever it spawns) can bind its presentation to Zone.ShotCommitted /
// ShotResolved instead of deciding or applying anything itself.
// The target handed to the effect is the shot's own, not the shooter's selection: a fused round
// whose selected target was invalid, or out of arc, flies at none (FireControl.Fire) and the
// effect must not chase one.
instantWeapon.OnFire += shotId =>
_instantWeaponManagers[data].Fire(instantWeapon, item, this, entity.Target.Value != null && ZoneRenderer.EntityInstances.ContainsKey(entity.Target.Value) ? ZoneRenderer.EntityInstances[entity.Target.Value] : null, shotId);
_instantWeaponManagers[data].Fire(instantWeapon, item, this, ShotTarget(shotId), shotId);
if (behavior is ChargedWeapon chargedWeapon)
{
@ -336,6 +339,10 @@ public class EntityInstance : MonoBehaviour
}
}
private EntityInstance ShotTarget(int shotId) =>
Entity.Zone.TryGetShot(shotId, out var shot) && shot.Target != null &&
ZoneRenderer.EntityInstances.TryGetValue(shot.Target, out var instance) ? instance : null;
private void OnSensorPingEnd()
{
Destroy(_currentPing.transform.gameObject);

View file

@ -17,12 +17,17 @@ public class GuidedProjectileManager : InstantWeaponEffectManager
{
if(weapon.Data is LauncherData launcher)
{
if (target == null) return;
// A round the simulation fired at no target (FireControl.Fire: a fused round with no valid targeting
// data, or out of arc) flies to the point it bursts at; one with no target and no burst is not a shot.
PendingShot shot = default;
if (target == null && !(source.Entity.Zone.TryGetShot(shotId, out shot) && shot.Fuse != null)) return;
var burst = shot.BurstPosition.ToUnity();
var p = ProjectilePrototype.Instantiate<GuidedProjectile>();
p.ShotId = shotId;
p.Source = source.transform;
p.SourceEntity = source.Entity;
p.Target = target.transform;
if (target != null) p.Target = target.transform;
else p.TargetPosition = () => burst;
p.Frequency = launcher.DodgeFrequency;
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
var barrel = source.GetBarrel(hp);

View file

@ -43,6 +43,21 @@ public class Zone
private int _nextShotId;
public int NextShotId() => ++_nextShotId;
// The committed shot a presentation was handed the id of by OnFire. It carries what the simulation decided
// -- the target it flies at (null for a round that carries none) and where it bursts -- so a presentation
// reads that rather than the shooter's current selection.
public bool TryGetShot(int shotId, out PendingShot shot)
{
foreach (var pending in PendingShots)
if (pending.ShotId == shotId)
{
shot = pending;
return true;
}
shot = default;
return false;
}
private List<Task> BeltUpdates = new List<Task>();
public float Time