Loot 3 fix1: the loot-3 findings' fixtures, and the held-pose curve has one owner

PickupTests: TheBeamTakesFromWhicheverBayCanStore is a theory over which bay is full.
CapabilityPresentationSmoke: tracked ship's hull hit is drawn; a beam above the held point stays on the ground plane; a grab at the beam keeps its aim; the other entity's grab reaches its own bound beam and not this one.
FloatingItemsDrawnSmoke: a held item's label comes up; the test scene's stand-in pose equals the zone's held pose.
Zone.HeldPull is the one smoothstep of the held pose; FieldDriver's tendril and FieldTester's stand-in call it (FieldTester.PulledPosition, PullProgress), deleting the two copies.
All commits build (Unity compile and both smokes green).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-13 22:25:49 +02:00
commit a345bd3dcb
6 changed files with 109 additions and 38 deletions

View file

@ -81,21 +81,28 @@ public static class CapabilityPresentationSmoke
typeof(ActionGameManager).GetProperty("Instance", Any).SetValue(null, manager);
manager.CurrentEntity = ship;
var instanceObject = new GameObject("Smoke Entity Instance");
var instance = instanceObject.AddComponent<EntityInstance>();
Awaken(instance);
instance.HullColliders = new HullCollider[0];
instance.RadiatorHardpoints = new RadiatorHardpoint[0];
instance.ThrusterHardpoints = new ThrusterHardpoint[0];
instance.WeaponHardpoints = new WeaponHardpoint[0];
instance.ArticulationPoints = new ArticulationPoint[0];
// The beam is a child before SetEntity on both ship paths, so the binder finds it as the game does.
var beamPrefab = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Content/Prefabs/Tractor Beam.prefab")
?? throw new InvalidOperationException("No Tractor Beam prefab.");
var beam = ((GameObject)PrefabUtility.InstantiatePrefab(beamPrefab, instanceObject.transform)).GetComponent<TractorBeam>();
beam.Power = .8f;
beam.Direction = Vector3.forward;
instance.SetEntity(null, ship);
// An entity's instance as the game builds it: the beam is a child before SetEntity on both ship paths, so the
// binder finds it as the game does.
(GameObject Object, EntityInstance Instance, TractorBeam Beam) Bound(string name, Entity entity)
{
var go = new GameObject(name);
var bound = go.AddComponent<EntityInstance>();
Awaken(bound);
bound.HullColliders = new HullCollider[0];
bound.RadiatorHardpoints = new RadiatorHardpoint[0];
bound.ThrusterHardpoints = new ThrusterHardpoint[0];
bound.WeaponHardpoints = new WeaponHardpoint[0];
bound.ArticulationPoints = new ArticulationPoint[0];
var tractor = ((GameObject)PrefabUtility.InstantiatePrefab(beamPrefab, go.transform)).GetComponent<TractorBeam>();
tractor.Power = .8f;
tractor.Direction = Vector3.forward;
bound.SetEntity(null, entity);
return (go, bound, tractor);
}
var (instanceObject, instance, beam) = Bound("Smoke Entity Instance", ship);
var (otherObject, _, otherBeam) = Bound("Smoke Other Instance", other);
int Effects() => instance.GetComponentsInChildren<Prototype>(true).Count(p => p != null && !p.isOriginalPrototype);
void Expect(string what, int effects, int kicks)
@ -123,9 +130,15 @@ public static class CapabilityPresentationSmoke
// An untracked ship is not drawn at (ActionGameManager.DrawsAt, since contact-hud): no hull effect, no impulse.
Expect("hull hit on an untracked ship", 2, 1);
// Once the player's instruments track it, the same hit is drawn.
other.VisibleEntities.Add(ship);
ship.Capabilities.PublishAbsorb(Hit(AbsorbLayer.Hull));
Expect("hull hit on a tracked ship", 3, 1);
other.VisibleEntities.Remove(ship);
manager.CurrentEntity = ship;
ship.Capabilities.PublishAbsorb(Hit(AbsorbLayer.Shield));
Expect("player's shield hit", 2, 2);
Expect("player's shield hit", 3, 2);
// Grabs: the beam presents the simulation's events and nothing else.
float Emission() => beam.ParticleSystem.emission.rateOverTimeMultiplier;
@ -156,12 +169,32 @@ public static class CapabilityPresentationSmoke
ship.Capabilities.PublishGrab(Grab(GrabPhase.Cancelled, float3(0f, 0f, 0f)));
ExpectBeam("grab cancelled", 0f, false);
// The beam belongs to the ship's entity: another entity's grab is no business of its own.
// Aim is on the ground plane: a beam above the held point does not pitch toward it.
var beamHome = beam.transform.position;
beam.transform.position = beamHome + new Vector3(0f, 10f, 0f);
ship.Capabilities.PublishGrab(Grab(GrabPhase.Started, float3(20f, 7f, 0f)));
ExpectBeam("grab from above", .8f, true);
ship.Capabilities.PublishGrab(Grab(GrabPhase.Completed, float3(20f, 7f, 0f)));
beam.transform.position = beamHome;
// A grab held at the beam's own position has no direction to take: the beam keeps the aim it had.
beam.Direction = Vector3.right;
var atBeam = float3(beam.transform.position.x, 0f, beam.transform.position.z);
ship.Capabilities.PublishGrab(Grab(GrabPhase.Started, atBeam));
ExpectBeam("grab at the beam", .8f, true);
ship.Capabilities.PublishGrab(Grab(GrabPhase.Completed, atBeam));
beam.Direction = Vector3.forward;
ExpectBeam("after the grab at the beam", 0f, false);
// The beam belongs to the ship's entity: another entity's grab, with its own beam bound, moves only that beam.
other.Capabilities.PublishGrab(Grab(GrabPhase.Started, float3(20f, 0f, 0f)));
ExpectBeam("another entity's grab", 0f, false);
otherBeam.Update();
if (abs(otherBeam.ParticleSystem.emission.rateOverTimeMultiplier - .8f) > 1e-4f)
throw new InvalidOperationException("The other entity's own beam did not present its grab.");
Debug.Log("CAPABILITY_PRESENTATION_SMOKE ok effects=2 impulses=2 grabs=ok");
return new[] { feedbackObject, effectObject, managerObject, instanceObject };
Debug.Log("CAPABILITY_PRESENTATION_SMOKE ok effects=3 impulses=2 grabs=ok");
return new[] { feedbackObject, effectObject, managerObject, instanceObject, otherObject };
}
private static void Clean(GameObject[] objects, string work)

View file

@ -180,6 +180,32 @@ public static class FloatingItemsDrawnSmoke
At(drawn, released, "step");
Require(drawn.transform.position != before, "the pickup did not move with the body.");
// A held item keeps its label lit, so a pull is read as it happens. The label is let go dark first (nothing views
// it), then the zone holds the item through its own TryHold and the label must come up.
var earlyPickup = Pickups().Single(p => p.Item == early.Item);
earlyPickup.LabelPersistDuration = 1;
earlyPickup.LabelFadeDuration = .2f;
for (var i = 0; i < 1200 && earlyPickup.ScanLabel.color.a > .05f; i++) yield return null;
Require(earlyPickup.ScanLabel.color.a <= .05f, "label: an unviewed, unheld label did not go dark.");
Require(zone.TryHold(taker, early.Id), "label: the zone refused to hold the item.");
for (var i = 0; i < 1200 && earlyPickup.ScanLabel.color.a < .95f; i++) yield return null;
Require(earlyPickup.ScanLabel.color.a >= .95f, "label: a held item's label is not lit.");
// The test scene's stand-in sim and tendril ride the zone's own held-pose curve: its pose at each point of a grab
// is where the zone puts a held item at the same progress.
var (extend, envelop, pull) = (1.5f, .75f, 1.5f);
var holderAt = new CultMath.float3(taker.Position.x, 0f, taker.Position.z);
var claimedAt = new CultMath.float3(early.HeldFrom.x, 0f, early.HeldFrom.y);
foreach (var elapsed in new[] { 0f, extend + envelop - .01f, extend + envelop + .3f, extend + envelop + .75f, extend + envelop + pull })
{
zone.SetHeldProgress(early.Id, FieldTester.PullProgress(elapsed, extend, envelop, pull));
zone.Update(.01f);
var want = FieldTester.PulledPosition(claimedAt, holderAt, elapsed, extend, envelop, pull);
Require(Mathf.Abs(early.Body.Position.x - want.x) < 1e-3f && Mathf.Abs(early.Body.Position.y - want.z) < 1e-3f,
$"stand-in pose at {elapsed}s is {want}, the zone holds the item at {early.Body.Position}.");
}
zone.Free(early.Id);
// Pickup destroys exactly the picked-up item's pickup.
Require(zone.TryPickUp(taker, released.Id), "the station refused a one-cell stack.");
yield return null;