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:
parent
48b42992ee
commit
a345bd3dcb
6 changed files with 109 additions and 38 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -294,8 +294,8 @@ public class FieldDriver : MonoBehaviour, IAbsorbPresenter, IGrabPresenter, IMel
|
|||
_field.SetFloat("_TendrilRadius", TendrilTipScale * TendrilTipRadius);
|
||||
break;
|
||||
case GrabPhase.Pull:
|
||||
// The same curve as Zone's held pose (Zone.cs): the tip rides the item the simulation pulls in.
|
||||
_tendrilTargetPos = lerp(_grabStart.ToCultMath(), transform.position.ToCultMath(), smoothstep(0, 1, _grabTime)).ToUnity();
|
||||
// The curve of Zone's held pose (Zone.HeldPull): the tip rides the item the simulation pulls in.
|
||||
_tendrilTargetPos = lerp(_grabStart.ToCultMath(), transform.position.ToCultMath(), Zone.HeldPull(_grabTime)).ToUnity();
|
||||
_tendrilBendTarget = _grabStart;
|
||||
if (_fadePoint > .99 && transform.InverseTransformPoint(_tendrilTargetPos).sqrMagnitude < 1)
|
||||
_fadePoint = _grabTime;
|
||||
|
|
|
|||
|
|
@ -394,6 +394,10 @@ public class Zone
|
|||
// After StepClouds and before FireControl.Step: each floating item drifts as a KinematicBody on the zone's force
|
||||
// and is removed once its lifetime has run out. A held item is neither integrated nor expired: it is placed
|
||||
// between where it was claimed and its holder, now that the entities have moved.
|
||||
// The curve a held item rides from where it was claimed to its holder: the one owner, which the test scene's
|
||||
// stand-in sim and tendril call rather than spell again.
|
||||
public static float HeldPull(float progress) => smoothstep(0f, 1f, progress);
|
||||
|
||||
private void StepFloatingItems(float deltaTime)
|
||||
{
|
||||
var settings = _itemManager.GameplaySettings;
|
||||
|
|
@ -401,7 +405,7 @@ public class Zone
|
|||
{
|
||||
if (floating.Holder != null)
|
||||
{
|
||||
floating.Body.Position = lerp(floating.HeldFrom, floating.Holder.Position.xz, smoothstep(0f, 1f, floating.HeldProgress));
|
||||
floating.Body.Position = lerp(floating.HeldFrom, floating.Holder.Position.xz, HeldPull(floating.HeldProgress));
|
||||
continue;
|
||||
}
|
||||
floating.Body.Step(deltaTime, GetForce(floating.Body.Position), settings);
|
||||
|
|
|
|||
|
|
@ -148,22 +148,27 @@ public class FieldTester : MonoBehaviour
|
|||
_capabilityEvents.PublishGrab(new GrabEvent(id, GrabPhase.Pull, _grabStart, GrabPullTime));
|
||||
}
|
||||
var pickup = _pickups[_grabIndex].transform;
|
||||
if (_pullPublished)
|
||||
pickup.position = PulledPosition(_grabStart, TestField.transform.position.ToCultMath(), _grabElapsed,
|
||||
GrabExtendTime, GrabEnvelopTime, GrabPullTime).ToUnity();
|
||||
if (_pullPublished && PullProgress(_grabElapsed, GrabExtendTime, GrabEnvelopTime, GrabPullTime) >= 1)
|
||||
{
|
||||
var progress = saturate((_grabElapsed - pullStart) / max(GrabPullTime, 1e-4f));
|
||||
pickup.position = lerp(_grabStart, TestField.transform.position.ToCultMath(), smoothstep(0, 1, progress)).ToUnity();
|
||||
if (progress >= 1)
|
||||
{
|
||||
_capabilityEvents.PublishGrab(new GrabEvent(id, GrabPhase.Completed, pickup.position.ToCultMath(), 0));
|
||||
Destroy(pickup.gameObject);
|
||||
var p = _pickups[_grabIndex];
|
||||
p.transform = null;
|
||||
_pickups[_grabIndex] = p;
|
||||
_grabbing = false;
|
||||
}
|
||||
_capabilityEvents.PublishGrab(new GrabEvent(id, GrabPhase.Completed, pickup.position.ToCultMath(), 0));
|
||||
Destroy(pickup.gameObject);
|
||||
var p = _pickups[_grabIndex];
|
||||
p.transform = null;
|
||||
_pickups[_grabIndex] = p;
|
||||
_grabbing = false;
|
||||
}
|
||||
}
|
||||
|
||||
// How far along the pull a grab is `elapsed` seconds in: 0 through Extend and Envelop, then 0..1 over the pull.
|
||||
public static float PullProgress(float elapsed, float extend, float envelop, float pull) =>
|
||||
saturate((elapsed - extend - envelop) / max(pull, 1e-4f));
|
||||
|
||||
// Where the stand-in sim holds its pickup: still through Extend and Envelop, then along Zone's held-pose curve.
|
||||
public static float3 PulledPosition(float3 start, float3 holder, float elapsed, float extend, float envelop, float pull) =>
|
||||
lerp(start, holder, Zone.HeldPull(PullProgress(elapsed, extend, envelop, pull)));
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var move = _forceThrust ? float2(0,1) : _input.Player.Move.ReadValue<Vector2>().ToCultMath();
|
||||
|
|
|
|||
Loading…
Reference in a new issue