A click on a remote character's wielded weapon reported nothing. The picker was already correct: RetailSelectionScene publishes every drawn part under its own live-entity server GUID and RetailWorldPicker returns the weapon as the polygon winner. The failure was downstream eligibility - WorldSelectionQuery required TryGetInteractionEligibleRecord, whose _visible set admits LiveEntityProjectionKind.World only, so the winning hit was discarded. Retail has no such gate. Render::GfxObjUnderSelectionRay @ 0x0054C740 accumulates each hit under the drawn part's own physics-object id (CPhysicsPart::get_physobj_id @ 0x0050D490), and CPhysicsPart::Draw @ 0x0050D7A0 admits any drawn part whose physobj id is nonzero. An equipped item is a first-class CPhysicsObj with its own id and part array (CPhysicsObj::add_child @ 0x0050F870 via CSetup::GetHoldingLocation @ 0x005213F0). There is no parent redirection and no wielded-specific rule, so a click on a wielded weapon returns THE WEAPON'S GUID. PositionState.WIELDED is distinct from IN_CONTAINER (acclient.h:6802), so container suppression never hid a wielded selection either. LiveEntityRuntime gains two scoped predicates: TryGetAttachedProjectedRecord (a current Attached projection that is spatially projected) and TryGetPickEligibleRecord (that arm plus today's World visible-set arm, with the same WorldEntity.Id staleness recheck). TryGetInteractionEligibleRecord and the _visible set are deliberately NOT widened - they feed radar, auto-target, sticky/MoveTo establishment, and CombatAttackTargetSource, and retail's radar has no wielded blips. A regression test asserts an attached child stays out of that set while picking admits it. Marker anchoring had the twin problem. SmartBox::GetObjectBoundingBox @ 0x00452E20 pushes the picked object's OWN m_position - which for a child is the frame CPhysicsObj::UpdateChild @ 0x00512D50 recomposes each tick as Frame::combine(parent part frame, holding frame) - and CPartArray::GetSelectionSphere @ 0x00518B80 scales the authored sphere by that object's own part-array scale. acdream stores the PARENT's root in the child projection's Position/Rotation because the child's MeshRefs are parent-relative, which put the vivid brackets at the wielder's feet. The composed child root is already published per frame to EntityEffectPoseRegistry by EquippedChildRenderController.PublishChildPose, so selection now borrows it through an injected Func<uint, Matrix4x4?> wired in LivePresentationComposition beside the existing selection-sphere hook. There is no parent fallback: a child with no published composed root has no live frame this tick and no sphere. Its part-array scale comes from the spawn record, the same source EquippedChildRenderController.TryRealize reads, because an Attached WorldEntity carries the parent-derived pose rather than its own ObjScale. The sr_Use branch of RecvNotice_SmartBoxObjectFound @ 0x004E5AD0 guards ItemHolder::UseObject with `found->pwd._wielderID != SmartBox::player_id` at 0x004E5BE9 while still selecting and flashing. Equipped-child picking makes that click reachable, so the gate ships with it as IWorldSelectionQuery.IsWieldedByPlayer. CPhysicsObj::SetLighting @ 0x00511A80 is non-recursive, so the pulse lights the clicked object's own part array only - clicking a weapon never flashes its wielder. That follows from routing the pulse identity through the same predicate. RetailWorldPicker, RetailSelectionScene, WbDrawDispatcher, and EquippedChildRenderController are untouched, as are all wire and physics paths. The slice REMOVES an undocumented deviation (Attached projections excluded from pick eligibility versus retail's part-id pick) and introduces none, so no retail-divergence-register row is owed in either direction. Gates: dotnet build green; AcDream.App.Tests 3,951 passed / 3 skipped; complete Release solution 9,783 passed / 5 skipped; tools\run-connected-world-lifecycle-gate.ps1 RESULT=PASS. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
70 lines
2.5 KiB
C#
70 lines
2.5 KiB
C#
using System.Numerics;
|
|
using AcDream.App.Combat;
|
|
using AcDream.App.Interaction;
|
|
using AcDream.Core.Combat;
|
|
using AcDream.Core.Selection;
|
|
|
|
namespace AcDream.App.Tests.Combat;
|
|
|
|
public sealed class CombatCameraTargetSourceTests
|
|
{
|
|
[Fact]
|
|
public void GetTrackedTargetPoint_RequiresOptionTargetedModeAndSelection()
|
|
{
|
|
const uint target = 0x70000001u;
|
|
Vector3 point = new(10f, 20f, 30f);
|
|
var settings = new GameplaySettingsState();
|
|
var combat = new CombatState();
|
|
var selection = new SelectionState();
|
|
var world = new TargetQuery(point);
|
|
var source = new CombatCameraTargetSource(
|
|
settings,
|
|
combat,
|
|
selection,
|
|
world);
|
|
|
|
Assert.Null(source.GetTrackedTargetPoint());
|
|
|
|
settings.Value = settings.Value with { ViewCombatTarget = true };
|
|
combat.SetCombatMode(CombatMode.Melee);
|
|
selection.Select(target, SelectionChangeSource.World);
|
|
|
|
Assert.Equal(point, source.GetTrackedTargetPoint());
|
|
Assert.Equal(target, world.LastGuid);
|
|
|
|
combat.SetCombatMode(CombatMode.Magic);
|
|
Assert.Null(source.GetTrackedTargetPoint());
|
|
}
|
|
|
|
private sealed class TargetQuery(Vector3 point) : IWorldSelectionQuery
|
|
{
|
|
public uint LastGuid { get; private set; }
|
|
public Vector3? GetCombatCameraTargetPoint(uint serverGuid)
|
|
{
|
|
LastGuid = serverGuid;
|
|
return point;
|
|
}
|
|
|
|
public uint? PickAtCursor(bool includeSelf) => null;
|
|
public uint? PickAt(float mouseX, float mouseY, bool includeSelf) => null;
|
|
public void BeginLightingPulse(uint serverGuid) { }
|
|
public bool TryCaptureIdentity(uint serverGuid, out uint localEntityId)
|
|
{
|
|
localEntityId = 0;
|
|
return false;
|
|
}
|
|
public bool IsCurrent(uint serverGuid, uint localEntityId) => false;
|
|
public string Describe(uint serverGuid) => string.Empty;
|
|
public bool IsCreature(uint serverGuid) => false;
|
|
public bool IsHostileMonster(uint serverGuid) => false;
|
|
public ClosestCombatTarget? FindClosestHostileMonster() => null;
|
|
public bool IsUseable(uint serverGuid) => false;
|
|
public bool IsPickupable(uint serverGuid) => false;
|
|
public bool IsWieldedByPlayer(uint serverGuid) => false;
|
|
public bool TryGetApproach(uint serverGuid, out InteractionApproach approach)
|
|
{
|
|
approach = default;
|
|
return false;
|
|
}
|
|
}
|
|
}
|