Equipment: weapon-granted abilities + gear mods (DR-027 Phase 1)

Equipment slots reusing the AbilityRef/StatModifier machinery: EquipmentSlot [GhostField] buffer (index=slot), server-only event-driven EquipSystem (RPC). Weapon -> AbilityRef.Id swaps the attack (prefab + base stats, prediction-correct); gear -> StatModifiers tagged a reserved per-slot EquipSourceId, stripped target-agnostically via RemoveBySourceId. Item mods are INLINE on ItemDefBlob (a nested BlobArray reads empty under the by-value TryGetItem copy). Atomic equip-over swap (no item loss); DefaultAbility restores the unarmed ability on weapon-unequip. Client keys + build-safe hooks; HUD equipment panel + click-to-equip. 4 catalog weapon/gear items wired + re-baked.

Play-validated host+client: weapon equip swaps AbilityRef on both worlds, gear folds into EffectiveCharacterStats, unequip reverses + restores DefaultAbility, all replicated to the owner. See DR-027.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-08 11:09:25 -07:00
parent 510c12a980
commit 43f355c06b
28 changed files with 709 additions and 6 deletions
@@ -76,6 +76,27 @@ namespace ProjectM.Simulation
return taken;
}
/// <summary>
/// Non-mutating check: would depositing <paramref name="count"/> of <paramref name="itemId"/> FULLY fit
/// (top-up existing stacks + new stacks within <paramref name="maxSlots"/>)? Used by the equip swap to
/// guarantee the swapped-out item has room BEFORE any withdrawal (no item loss). Mirrors Deposit's space math.
/// </summary>
public static bool CanDeposit(DynamicBuffer<InventorySlot> buffer, ushort itemId, int count, int stackMax, int maxSlots)
{
if (count <= 0) return true;
if (itemId == 0) return false;
if (stackMax < 1) stackMax = int.MaxValue;
long space = 0;
for (int i = 0; i < buffer.Length; i++)
if (buffer[i].ItemId == itemId)
space += stackMax - buffer[i].Count;
int freeSlots = maxSlots - buffer.Length;
if (freeSlots > 0)
space += (long)freeSlots * stackMax;
return space >= count;
}
/// <summary>Total quantity of <paramref name="itemId"/> across all stacks (0 if absent).</summary>
public static int CountOf(DynamicBuffer<InventorySlot> buffer, ushort itemId)
{