fix(ui): restore radar, retail wield switching, and protection meshes
Late-bind radar snapshots to the canonical LiveEntityRuntime maps so the retained radar survives bootstrap and session replacement instead of capturing empty sentinels. Route paperdoll drops through the retail AutoWield blocker transaction. Move conflicting held weapons, shields, explicit jewelry destinations, and mismatched ammo to the backpack one authoritative confirmation at a time; preserve compatible arrows when switching to melee. Render mode-1 and no-degrade particle GfxObjs as their authored modern-pipeline meshes, retain Always2D billboards, interleave both paths back-to-front, balance emitter mesh ownership, and fail safely on corrupt DAT material metadata. This restores the closed apex on Armor Self/protection effects. Retain Studio fixture controller lifetimes, add installed-DAT and adversarial regression coverage, synchronize retail research/divergence bookkeeping, and pass all three review tracks plus the full Release suite. Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
parent
8d63e5c28a
commit
b26f84cc69
26 changed files with 1361 additions and 141 deletions
|
|
@ -0,0 +1,175 @@
|
|||
using AcDream.App.Rendering;
|
||||
using AcDream.Content.Vfx;
|
||||
using AcDream.Core.Meshing;
|
||||
using AcDream.Core.Vfx;
|
||||
using DatReaderWriter;
|
||||
using DatReaderWriter.DBObjs;
|
||||
using DatReaderWriter.Enums;
|
||||
using DatReaderWriter.Options;
|
||||
using DatReaderWriter.Types;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace AcDream.App.Tests.Rendering;
|
||||
|
||||
public sealed class RetailParticleGeometryClassifierTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(null, RetailParticleGeometryKind.FullMesh)]
|
||||
[InlineData(1, RetailParticleGeometryKind.FullMesh)]
|
||||
[InlineData(0, RetailParticleGeometryKind.Billboard)]
|
||||
[InlineData(2, RetailParticleGeometryKind.Billboard)]
|
||||
[InlineData(3, RetailParticleGeometryKind.Billboard)]
|
||||
public void Classify_matchesRetailAlways2D(
|
||||
int? firstDegradeMode,
|
||||
RetailParticleGeometryKind expected)
|
||||
{
|
||||
Assert.Equal(
|
||||
expected,
|
||||
RetailParticleGeometryClassifier.Classify(
|
||||
firstDegradeMode is int mode ? (uint)mode : null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Classify_unknownUnsignedMode_isBillboardWithoutOverflow()
|
||||
=> Assert.Equal(
|
||||
RetailParticleGeometryKind.Billboard,
|
||||
RetailParticleGeometryClassifier.Classify(uint.MaxValue));
|
||||
|
||||
[Fact]
|
||||
public void SubmissionOrdering_interleavesGeometryByDistanceAndPreservesEqualDistanceSequence()
|
||||
{
|
||||
var submissions = new List<ParticleSubmission>
|
||||
{
|
||||
new(ParticleSubmissionKind.Mesh, 0, 4f, 0),
|
||||
new(ParticleSubmissionKind.Billboard, 0, 9f, 1),
|
||||
new(ParticleSubmissionKind.Mesh, 1, 9f, 2),
|
||||
new(ParticleSubmissionKind.Billboard, 1, 1f, 3),
|
||||
};
|
||||
|
||||
ParticleSubmissionOrdering.Sort(submissions);
|
||||
|
||||
Assert.Equal(
|
||||
new[]
|
||||
{
|
||||
(ParticleSubmissionKind.Billboard, 1),
|
||||
(ParticleSubmissionKind.Mesh, 2),
|
||||
(ParticleSubmissionKind.Mesh, 0),
|
||||
(ParticleSubmissionKind.Billboard, 3),
|
||||
},
|
||||
submissions.Select(static item => (item.Kind, item.Sequence)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MeshReferenceTracker_balancesDuplicateReleaseAndDispose()
|
||||
{
|
||||
var increments = new List<uint>();
|
||||
var decrements = new List<uint>();
|
||||
var tracker = new ParticleMeshReferenceTracker(increments.Add, decrements.Add);
|
||||
|
||||
tracker.Register(7, 0x01001666u);
|
||||
tracker.Register(7, 0x01001666u);
|
||||
tracker.Register(8, 0x01001667u);
|
||||
tracker.Release(7);
|
||||
tracker.Release(7);
|
||||
tracker.Dispose();
|
||||
tracker.Dispose();
|
||||
|
||||
Assert.Equal(new[] { 0x01001666u, 0x01001667u }, increments);
|
||||
Assert.Equal(new[] { 0x01001666u, 0x01001667u }, decrements);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlendResolver_corruptSurfaceFallsBackAndReportsItsDid()
|
||||
{
|
||||
var diagnostics = new List<string>();
|
||||
|
||||
TranslucencyKind blend = RetailParticleBlendResolver.Resolve(
|
||||
0x08001234u,
|
||||
batchIsAdditive: true,
|
||||
_ => throw new InvalidDataException("bad surface"),
|
||||
diagnostics.Add);
|
||||
|
||||
Assert.Equal(TranslucencyKind.Additive, blend);
|
||||
string diagnostic = Assert.Single(diagnostics);
|
||||
Assert.Contains("0x08001234", diagnostic, StringComparison.Ordinal);
|
||||
Assert.Contains("bad surface", diagnostic, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InstalledArmorSelfShieldPieces_areModeOneMeshesWithAuthoredApexFaces()
|
||||
{
|
||||
string? datDir = ResolveDatDir();
|
||||
if (datDir is null)
|
||||
throw SkipException.ForSkip(
|
||||
"Installed client_portal.dat is required for the Armor Self asset-chain gate.");
|
||||
|
||||
using var dats = new DatCollection(datDir, DatAccessType.Read);
|
||||
var tableResolver = new PhysicsScriptTableResolver(
|
||||
id => dats.Get<PhysicsScriptTable>(id));
|
||||
uint? scriptDid = tableResolver.Resolve(
|
||||
0x34000004u,
|
||||
rawScriptType: 0x37u, // PS_ShieldUpGrey / TargetEffect 55
|
||||
intensity: 1f);
|
||||
Assert.Equal(0x3300068Fu, scriptDid);
|
||||
|
||||
var scriptLoader = new RetailPhysicsScriptLoader(dats);
|
||||
DatReaderWriter.DBObjs.PhysicsScript script = Assert.IsType<DatReaderWriter.DBObjs.PhysicsScript>(
|
||||
scriptLoader.LoadPhysicsScript(scriptDid!.Value));
|
||||
uint[] emitterIds = script.ScriptData
|
||||
.Select(static item => item.Hook)
|
||||
.OfType<CreateParticleHook>()
|
||||
.Select(static hook => hook.EmitterInfoId.DataId)
|
||||
.ToArray();
|
||||
Assert.Equal(
|
||||
new[] { 0x32000350u, 0x32000351u, 0x32000355u, 0x32000356u, 0x32000379u },
|
||||
emitterIds);
|
||||
|
||||
var emitters = new EmitterDescRegistry(dats);
|
||||
uint[] greyShieldPieces = emitterIds
|
||||
.Select(id => emitters.Get(id).HwGfxObjId)
|
||||
.Take(4)
|
||||
.ToArray();
|
||||
Assert.Equal(
|
||||
new[] { 0x01001666u, 0x01001667u, 0x01001668u, 0x01001669u },
|
||||
greyShieldPieces);
|
||||
Assert.Equal(0x01001098u, emitters.Get(emitterIds[4]).HwGfxObjId);
|
||||
|
||||
foreach (uint gfxObjId in greyShieldPieces)
|
||||
{
|
||||
GfxObj gfx = Assert.IsType<GfxObj>(dats.Get<GfxObj>(gfxObjId));
|
||||
Assert.Equal(5, gfx.VertexArray.Vertices.Count);
|
||||
Assert.True(gfx.Flags.HasFlag(GfxObjFlags.HasDIDDegrade));
|
||||
|
||||
GfxObjDegradeInfo degrade = Assert.IsType<GfxObjDegradeInfo>(
|
||||
dats.Get<GfxObjDegradeInfo>(gfx.DIDDegrade));
|
||||
Assert.NotEmpty(degrade.Degrades);
|
||||
Assert.Equal(1u, degrade.Degrades[0].DegradeMode);
|
||||
|
||||
var apex = gfx.VertexArray.Vertices.MaxBy(static pair => pair.Value.Origin.Z);
|
||||
Assert.InRange(apex.Value.Origin.Z, 2.31f, 2.33f);
|
||||
Assert.Contains(
|
||||
gfx.Polygons.Values,
|
||||
polygon => polygon.VertexIds.Any(id => Convert.ToUInt16(id) == apex.Key));
|
||||
}
|
||||
}
|
||||
|
||||
private static string? ResolveDatDir()
|
||||
{
|
||||
string? configured = System.Environment.GetEnvironmentVariable("ACDREAM_DAT_DIR");
|
||||
if (!string.IsNullOrWhiteSpace(configured)
|
||||
&& File.Exists(Path.Combine(configured, "client_portal.dat")))
|
||||
return configured;
|
||||
|
||||
const string installed = @"C:\Turbine\Asheron's Call";
|
||||
if (File.Exists(Path.Combine(installed, "client_portal.dat")))
|
||||
return installed;
|
||||
|
||||
string conventional = Path.Combine(
|
||||
System.Environment.GetFolderPath(System.Environment.SpecialFolder.UserProfile),
|
||||
"Documents",
|
||||
"Asheron's Call");
|
||||
return File.Exists(Path.Combine(conventional, "client_portal.dat"))
|
||||
? conventional
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@ public sealed class ItemInteractionControllerTests
|
|||
public readonly List<(uint Item, uint Amount)> SplitDrops = new();
|
||||
public readonly List<(uint Target, uint Item, uint Amount)> Gives = new();
|
||||
public readonly List<string> Toasts = new();
|
||||
public readonly List<string> SystemMessages = new();
|
||||
public readonly StackSplitQuantityState SplitQuantity = new();
|
||||
public uint SelectedObject;
|
||||
public bool NonCombatMode;
|
||||
|
|
@ -63,7 +64,8 @@ public sealed class ItemInteractionControllerTests
|
|||
sendPutItemInContainer: (item, container, placement) =>
|
||||
Puts.Add((item, container, placement)),
|
||||
sendGive: (target, item, amount) => Gives.Add((target, item, amount)),
|
||||
dragOnPlayerOpensSecureTrade: () => DragOnPlayerOpensSecureTrade);
|
||||
dragOnPlayerOpensSecureTrade: () => DragOnPlayerOpensSecureTrade,
|
||||
systemMessage: SystemMessages.Add);
|
||||
}
|
||||
|
||||
public ItemInteractionController Controller { get; }
|
||||
|
|
@ -661,6 +663,209 @@ public sealed class ItemInteractionControllerTests
|
|||
Assert.Equal(new[] { (bow, (uint)EquipMask.MissileWeapon) }, h.Wields);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PaperdollWeaponSwitch_toSword_keepsEquippedArrows()
|
||||
{
|
||||
var h = new Harness();
|
||||
const uint bow = 0x50000B51u;
|
||||
const uint arrows = 0x50000B52u;
|
||||
const uint sword = 0x50000B53u;
|
||||
h.Objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = bow,
|
||||
Name = "Shortbow",
|
||||
Type = ItemType.MissileWeapon,
|
||||
CombatUse = 2,
|
||||
AmmoType = 1,
|
||||
ValidLocations = EquipMask.MissileWeapon,
|
||||
});
|
||||
h.Objects.MoveItem(bow, Player, -1, EquipMask.MissileWeapon);
|
||||
h.Objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = arrows,
|
||||
Name = "Arrows",
|
||||
Type = ItemType.MissileWeapon,
|
||||
CombatUse = 3,
|
||||
AmmoType = 1,
|
||||
ValidLocations = EquipMask.MissileAmmo,
|
||||
});
|
||||
h.Objects.MoveItem(arrows, Player, -1, EquipMask.MissileAmmo);
|
||||
h.AddContained(sword, item =>
|
||||
{
|
||||
item.Name = "Katar";
|
||||
item.Type = ItemType.MeleeWeapon;
|
||||
item.CombatUse = 1;
|
||||
item.ValidLocations = EquipMask.MeleeWeapon;
|
||||
});
|
||||
|
||||
Assert.True(h.Controller.WieldFromPaperdoll(sword, EquipMask.MeleeWeapon));
|
||||
Assert.Equal(new[] { (bow, Player, 0) }, h.Puts);
|
||||
Assert.Empty(h.Wields);
|
||||
Assert.Equal(new[] { "Moving Shortbow to your backpack" }, h.SystemMessages);
|
||||
|
||||
h.Objects.MoveItem(bow, Player, 0, EquipMask.None);
|
||||
|
||||
Assert.Equal(new[] { (sword, (uint)EquipMask.MeleeWeapon) }, h.Wields);
|
||||
Assert.Equal(EquipMask.MissileAmmo,
|
||||
h.Objects.Get(arrows)!.CurrentlyEquippedLocation);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PaperdollWeaponSwitch_fromWandToSword_movesHeldCasterFirst()
|
||||
{
|
||||
var h = new Harness();
|
||||
const uint wand = 0x50000B54u;
|
||||
const uint sword = 0x50000B55u;
|
||||
h.Objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = wand,
|
||||
Name = "Wand",
|
||||
Type = ItemType.Caster,
|
||||
ValidLocations = EquipMask.Held,
|
||||
});
|
||||
h.Objects.MoveItem(wand, Player, -1, EquipMask.Held);
|
||||
h.AddContained(sword, item =>
|
||||
{
|
||||
item.Name = "Katar";
|
||||
item.Type = ItemType.MeleeWeapon;
|
||||
item.CombatUse = 1;
|
||||
item.ValidLocations = EquipMask.MeleeWeapon;
|
||||
});
|
||||
|
||||
Assert.True(h.Controller.WieldFromPaperdoll(sword, EquipMask.MeleeWeapon));
|
||||
Assert.Equal(new[] { (wand, Player, 0) }, h.Puts);
|
||||
Assert.Empty(h.Wields);
|
||||
Assert.Equal(new[] { "Moving Wand to your backpack" }, h.SystemMessages);
|
||||
|
||||
h.Objects.MoveItem(wand, Player, 0, EquipMask.None);
|
||||
|
||||
Assert.Equal(new[] { (sword, (uint)EquipMask.MeleeWeapon) }, h.Wields);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PaperdollWeaponSwitch_toCrossbow_movesIncompatibleArrowsAfterBow()
|
||||
{
|
||||
var h = new Harness();
|
||||
const uint bow = 0x50000B61u;
|
||||
const uint arrows = 0x50000B62u;
|
||||
const uint crossbow = 0x50000B63u;
|
||||
h.Objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = bow,
|
||||
Name = "Shortbow",
|
||||
Type = ItemType.MissileWeapon,
|
||||
CombatUse = 2,
|
||||
AmmoType = 1,
|
||||
ValidLocations = EquipMask.MissileWeapon,
|
||||
});
|
||||
h.Objects.MoveItem(bow, Player, -1, EquipMask.MissileWeapon);
|
||||
h.Objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = arrows,
|
||||
Name = "Arrows",
|
||||
Type = ItemType.MissileWeapon,
|
||||
CombatUse = 3,
|
||||
AmmoType = 1,
|
||||
ValidLocations = EquipMask.MissileAmmo,
|
||||
});
|
||||
h.Objects.MoveItem(arrows, Player, -1, EquipMask.MissileAmmo);
|
||||
h.AddContained(crossbow, item =>
|
||||
{
|
||||
item.Name = "Heavy Crossbow";
|
||||
item.Type = ItemType.MissileWeapon;
|
||||
item.CombatUse = 2;
|
||||
item.AmmoType = 2;
|
||||
item.ValidLocations = EquipMask.MissileWeapon;
|
||||
});
|
||||
|
||||
Assert.True(h.Controller.WieldFromPaperdoll(
|
||||
crossbow, EquipMask.MissileWeapon));
|
||||
Assert.Equal(new[] { (bow, Player, 0) }, h.Puts);
|
||||
|
||||
h.Objects.MoveItem(bow, Player, 0, EquipMask.None);
|
||||
|
||||
Assert.Equal(
|
||||
new[] { (bow, Player, 0), (arrows, Player, 0) },
|
||||
h.Puts);
|
||||
Assert.Empty(h.Wields);
|
||||
|
||||
h.Objects.MoveItem(arrows, Player, 0, EquipMask.None);
|
||||
|
||||
Assert.Equal(
|
||||
new[] { (crossbow, (uint)EquipMask.MissileWeapon) },
|
||||
h.Wields);
|
||||
Assert.Equal(
|
||||
new[]
|
||||
{
|
||||
"Moving Shortbow to your backpack",
|
||||
"Moving Arrows to your backpack",
|
||||
},
|
||||
h.SystemMessages);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PaperdollDrop_relocatesAlreadyEquippedItemToExplicitCompatibleSlot()
|
||||
{
|
||||
var h = new Harness();
|
||||
const uint ring = 0x50000B71u;
|
||||
h.Objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = ring,
|
||||
Name = "Ring",
|
||||
Type = ItemType.Jewelry,
|
||||
ValidLocations = EquipMask.FingerWearLeft | EquipMask.FingerWearRight,
|
||||
});
|
||||
h.Objects.MoveItem(ring, Player, -1, EquipMask.FingerWearLeft);
|
||||
|
||||
Assert.True(h.Controller.WieldFromPaperdoll(ring, EquipMask.FingerWearRight));
|
||||
|
||||
Assert.Equal(
|
||||
new[] { (ring, (uint)EquipMask.FingerWearRight) },
|
||||
h.Wields);
|
||||
Assert.Equal(
|
||||
EquipMask.FingerWearRight,
|
||||
h.Objects.Get(ring)!.CurrentlyEquippedLocation);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PaperdollDrop_movesExplicitDestinationBlockerBeforeRelocatingEquippedItem()
|
||||
{
|
||||
var h = new Harness();
|
||||
const uint leftRing = 0x50000B72u;
|
||||
const uint rightRing = 0x50000B73u;
|
||||
EquipMask valid = EquipMask.FingerWearLeft | EquipMask.FingerWearRight;
|
||||
h.Objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = leftRing,
|
||||
Name = "Left Ring",
|
||||
Type = ItemType.Jewelry,
|
||||
ValidLocations = valid,
|
||||
});
|
||||
h.Objects.MoveItem(leftRing, Player, -1, EquipMask.FingerWearLeft);
|
||||
h.Objects.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = rightRing,
|
||||
Name = "Right Ring",
|
||||
Type = ItemType.Jewelry,
|
||||
ValidLocations = valid,
|
||||
});
|
||||
h.Objects.MoveItem(rightRing, Player, -1, EquipMask.FingerWearRight);
|
||||
|
||||
Assert.True(h.Controller.WieldFromPaperdoll(leftRing, EquipMask.FingerWearRight));
|
||||
Assert.Equal(new[] { (rightRing, Player, 0) }, h.Puts);
|
||||
Assert.Empty(h.Wields);
|
||||
Assert.Equal(new[] { "Moving Right Ring to your backpack" }, h.SystemMessages);
|
||||
|
||||
h.Objects.MoveItem(rightRing, Player, 0, EquipMask.None);
|
||||
|
||||
Assert.Equal(
|
||||
new[] { (leftRing, (uint)EquipMask.FingerWearRight) },
|
||||
h.Wields);
|
||||
Assert.Equal(
|
||||
EquipMask.FingerWearRight,
|
||||
h.Objects.Get(leftRing)!.CurrentlyEquippedLocation);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlocksUseOfShield_matchesRetailCombatUseAndAmmoRules()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,13 +44,28 @@ public class PaperdollControllerTests
|
|||
private static PaperdollController Bind(ImportedLayout layout, ClientObjectTable objects,
|
||||
List<(uint item, uint mask)>? wields = null, uint emptySlot = 0u,
|
||||
SelectionState? selection = null,
|
||||
IReadOnlyDictionary<uint, uint>? emptySlotSprites = null)
|
||||
=> PaperdollController.Bind(layout, objects, () => Player,
|
||||
iconIds: (_, _, _, _, _) => 0x1234u,
|
||||
IReadOnlyDictionary<uint, uint>? emptySlotSprites = null,
|
||||
List<(uint item, uint container, int placement)>? puts = null,
|
||||
List<string>? systemMessages = null)
|
||||
{
|
||||
var itemInteraction = new ItemInteractionController(
|
||||
objects,
|
||||
() => Player,
|
||||
sendUse: null,
|
||||
sendUseWithTarget: null,
|
||||
sendWield: wields is null ? null : (i, m) => wields.Add((i, m)),
|
||||
sendDrop: null,
|
||||
sendPutItemInContainer: puts is null
|
||||
? null
|
||||
: (item, container, placement) => puts.Add((item, container, placement)),
|
||||
systemMessage: systemMessages is null ? null : systemMessages.Add);
|
||||
return PaperdollController.Bind(layout, objects, () => Player,
|
||||
iconIds: (_, _, _, _, _) => 0x1234u,
|
||||
itemInteraction: itemInteraction,
|
||||
emptySlotSprite: emptySlot,
|
||||
selection: selection ?? new SelectionState(),
|
||||
emptySlotSprites: emptySlotSprites);
|
||||
}
|
||||
|
||||
private static void SeedEquipped(ClientObjectTable t, uint guid, EquipMask loc)
|
||||
{
|
||||
|
|
@ -225,6 +240,46 @@ public class PaperdollControllerTests
|
|||
Assert.Equal((0xD01u, (uint)EquipMask.HeadWear), wields[0]); // GetAndWieldItem wire
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HandleDropRelease_weaponSlot_delegatesToConfirmedAutoWieldTransaction()
|
||||
{
|
||||
var (layout, lists) = BuildLayout();
|
||||
var objects = new ClientObjectTable();
|
||||
const uint bow = 0xD11u;
|
||||
const uint sword = 0xD12u;
|
||||
SeedEquipped(objects, bow, EquipMask.MissileWeapon);
|
||||
objects.Get(bow)!.Name = "Shortbow";
|
||||
SeedPackItem(objects, sword, EquipMask.MeleeWeapon);
|
||||
objects.Get(sword)!.Name = "Katar";
|
||||
var wields = new List<(uint item, uint mask)>();
|
||||
var puts = new List<(uint item, uint container, int placement)>();
|
||||
var messages = new List<string>();
|
||||
var ctrl = Bind(
|
||||
layout,
|
||||
objects,
|
||||
wields,
|
||||
puts: puts,
|
||||
systemMessages: messages);
|
||||
var payload = new ItemDragPayload(
|
||||
sword,
|
||||
ItemDragSource.Inventory,
|
||||
0,
|
||||
lists[WeaponSlot].Cell);
|
||||
|
||||
ctrl.HandleDropRelease(lists[WeaponSlot], lists[WeaponSlot].Cell, payload);
|
||||
|
||||
Assert.Equal(new[] { (bow, Player, 0) }, puts);
|
||||
Assert.Empty(wields);
|
||||
Assert.Equal(EquipMask.None, objects.Get(sword)!.CurrentlyEquippedLocation);
|
||||
Assert.Equal(new[] { "Moving Shortbow to your backpack" }, messages);
|
||||
|
||||
objects.MoveItem(bow, Player, 0, EquipMask.None);
|
||||
|
||||
Assert.Equal(new[] { (sword, (uint)EquipMask.MeleeWeapon) }, wields);
|
||||
Assert.Equal(EquipMask.MeleeWeapon,
|
||||
objects.Get(sword)!.CurrentlyEquippedLocation);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HandleDropRelease_resolves_the_finger_bit_for_a_dual_finger_ring()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Numerics;
|
||||
using AcDream.App.UI;
|
||||
using AcDream.App.UI.Layout;
|
||||
using AcDream.Core.Items;
|
||||
using AcDream.Core.Net;
|
||||
|
|
@ -35,7 +36,7 @@ public sealed class RadarSnapshotProviderTests
|
|||
|
||||
uint? selected = monster;
|
||||
var provider = new RadarSnapshotProvider(
|
||||
objects, entities, spawns,
|
||||
objects, () => entities, () => spawns,
|
||||
playerGuid: () => player,
|
||||
playerYawRadians: () => MathF.PI / 2f, // retail heading 0 degrees
|
||||
playerCellId: () => 0xA9B40001u,
|
||||
|
|
@ -81,7 +82,7 @@ public sealed class RadarSnapshotProviderTests
|
|||
[hidden] = Spawn(hidden),
|
||||
};
|
||||
var provider = new RadarSnapshotProvider(
|
||||
objects, entities, spawns,
|
||||
objects, () => entities, () => spawns,
|
||||
playerGuid: () => player,
|
||||
playerYawRadians: () => 0f,
|
||||
playerCellId: () => 0xA9B40100u, // EnvCell: no landscape coordinate
|
||||
|
|
@ -120,15 +121,15 @@ public sealed class RadarSnapshotProviderTests
|
|||
};
|
||||
var provider = new RadarSnapshotProvider(
|
||||
objects,
|
||||
interactionVisible,
|
||||
spawns,
|
||||
() => interactionVisible,
|
||||
() => spawns,
|
||||
playerGuid: () => player,
|
||||
playerYawRadians: () => 0f,
|
||||
playerCellId: () => 0xA9B40001u,
|
||||
selectedGuid: () => hiddenTarget,
|
||||
coordinatesOnRadar: () => true,
|
||||
uiLocked: () => false,
|
||||
playerEntities: canonical);
|
||||
playerEntities: () => canonical);
|
||||
|
||||
var snapshot = provider.BuildSnapshot();
|
||||
|
||||
|
|
@ -136,6 +137,56 @@ public sealed class RadarSnapshotProviderTests
|
|||
Assert.Empty(snapshot.Blips);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildSnapshot_ResolvesLiveViewsAfterRuntimeBootstraps()
|
||||
{
|
||||
const uint player = 30u;
|
||||
const uint monster = 31u;
|
||||
var objects = new ClientObjectTable();
|
||||
objects.Ingest(Weenie(player, "Player", ItemType.Creature));
|
||||
objects.Ingest(Weenie(monster, "Drudge", ItemType.Creature) with
|
||||
{
|
||||
RadarBehavior = (byte)RadarBehavior.ShowAlways,
|
||||
});
|
||||
|
||||
IReadOnlyDictionary<uint, WorldEntity> visible =
|
||||
new Dictionary<uint, WorldEntity>();
|
||||
IReadOnlyDictionary<uint, WorldEntity> canonical =
|
||||
new Dictionary<uint, WorldEntity>();
|
||||
IReadOnlyDictionary<uint, WorldSession.EntitySpawn> spawns =
|
||||
new Dictionary<uint, WorldSession.EntitySpawn>();
|
||||
var provider = new RadarSnapshotProvider(
|
||||
objects,
|
||||
() => visible,
|
||||
() => spawns,
|
||||
playerGuid: () => player,
|
||||
playerYawRadians: () => MathF.PI / 2f,
|
||||
playerCellId: () => 0xA9B40001u,
|
||||
selectedGuid: () => null,
|
||||
coordinatesOnRadar: () => true,
|
||||
uiLocked: () => false,
|
||||
playerEntities: () => canonical);
|
||||
|
||||
Assert.Null(provider.BuildSnapshot().CoordinatesText);
|
||||
|
||||
visible = new Dictionary<uint, WorldEntity>
|
||||
{
|
||||
[player] = Entity(player, Vector3.Zero, Quaternion.Identity),
|
||||
[monster] = Entity(monster, new Vector3(0f, 15f, 0f), Quaternion.Identity),
|
||||
};
|
||||
canonical = visible;
|
||||
spawns = new Dictionary<uint, WorldSession.EntitySpawn>
|
||||
{
|
||||
[player] = Spawn(player),
|
||||
[monster] = Spawn(monster) with { ObjectDescriptionFlags = 0x00000010u },
|
||||
};
|
||||
|
||||
UiRadarSnapshot snapshot = provider.BuildSnapshot();
|
||||
|
||||
Assert.NotNull(snapshot.CoordinatesText);
|
||||
Assert.Equal(monster, Assert.Single(snapshot.Blips).ObjectId);
|
||||
}
|
||||
|
||||
private static WorldEntity Entity(uint guid, Vector3 position, Quaternion rotation) => new()
|
||||
{
|
||||
Id = guid,
|
||||
|
|
|
|||
|
|
@ -194,16 +194,26 @@ public sealed class RetailUiInteractionFlowTests
|
|||
public void BindPaperdoll(
|
||||
ItemInteractionController? itemInteraction = null,
|
||||
PaperdollClickMap? clickMap = null)
|
||||
=> PaperdollController.Bind(
|
||||
{
|
||||
itemInteraction ??= new ItemInteractionController(
|
||||
Objects,
|
||||
() => Player,
|
||||
sendUse: null,
|
||||
sendUseWithTarget: null,
|
||||
sendWield: (item, mask) => Wields.Add((item, mask)),
|
||||
sendDrop: null,
|
||||
sendPutItemInContainer: (item, container, placement) =>
|
||||
Puts.Add((item, container, placement)));
|
||||
PaperdollController.Bind(
|
||||
Layout,
|
||||
Objects,
|
||||
playerGuid: () => Player,
|
||||
iconIds: static (_, _, _, _, _) => 0x1234u,
|
||||
selection: Selection,
|
||||
sendWield: (item, mask) => Wields.Add((item, mask)),
|
||||
emptySlotSprite: 0x06004D20u,
|
||||
itemInteraction: itemInteraction,
|
||||
emptySlotSprite: 0x06004D20u,
|
||||
clickMap: clickMap ?? SolidClickMap(0x00, 0x00, 0xFF));
|
||||
}
|
||||
|
||||
public static PaperdollClickMap SolidClickMap(byte r, byte g, byte b)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -75,9 +75,12 @@ public sealed class ParticleSystemTests
|
|||
public void SpawnEmitter_ReturnsPositiveHandle_AndTracksEmitter()
|
||||
{
|
||||
var sys = MakeSystem();
|
||||
int h = sys.SpawnEmitter(MakeDesc(), Vector3.Zero);
|
||||
int h = sys.SpawnEmitter(
|
||||
MakeInitialParticleDesc(ParticleType.Still, Vector3.Zero, Vector3.Zero, Vector3.Zero),
|
||||
Vector3.Zero);
|
||||
Assert.True(h > 0);
|
||||
Assert.Equal(1, sys.ActiveEmitterCount);
|
||||
Assert.Equal(h, Assert.Single(sys.EnumerateLive().ToList()).Emitter.Handle);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue