Expose item reference API on runtime instances
This commit is contained in:
parent
d163b3064c
commit
22e7d0a972
5 changed files with 25 additions and 12 deletions
Binary file not shown.
|
|
@ -1626,7 +1626,7 @@ public class EquippedCargoBay : EquippedItem
|
|||
// For simple commodities, search for existing item stacks to add to
|
||||
foreach (var cargoItem in Cargo.Keys)
|
||||
{
|
||||
if (item.Data != cargoItem.Data) continue;
|
||||
if (item.ItemId != cargoItem.ItemId) continue;
|
||||
|
||||
var cargoCommodity = (SimpleCommodity) cargoItem;
|
||||
if (cargoCommodity.Quantity >= maxStack) continue;
|
||||
|
|
@ -1722,7 +1722,7 @@ public class EquippedCargoBay : EquippedItem
|
|||
ItemsOfType[item.ItemId] = new List<ItemInstance>();
|
||||
ItemsOfType[item.ItemId].Add(item);
|
||||
}
|
||||
else if (Occupancy[cargoCoord.x, cargoCoord.y] is SimpleCommodity cargoCommodity && cargoCommodity.Data == item.Data)
|
||||
else if (Occupancy[cargoCoord.x, cargoCoord.y] is SimpleCommodity cargoCommodity && cargoCommodity.ItemId == item.ItemId)
|
||||
{
|
||||
if (cargoCommodity.Quantity + item.Quantity <= maxStack)
|
||||
{
|
||||
|
|
@ -1799,7 +1799,7 @@ public class EquippedCargoBay : EquippedItem
|
|||
item.Quantity -= quantity;
|
||||
Mass -= GetUnitMass(item) * quantity;
|
||||
ThermalMass -= GetUnitThermalMass(item) * quantity;
|
||||
return new SimpleCommodity{Data = item.Data, Quantity = quantity, Rotation = item.Rotation};
|
||||
return new SimpleCommodity{Reference = item.Reference, Quantity = quantity, Rotation = item.Rotation};
|
||||
}
|
||||
|
||||
public void Remove(CraftedItemInstance item)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,12 @@ public abstract class ItemInstance
|
|||
{
|
||||
public RuntimeItemReference Data;
|
||||
public ItemRotation Rotation;
|
||||
public RuntimeItemReference Reference
|
||||
{
|
||||
get => Data;
|
||||
set => Data = value;
|
||||
}
|
||||
|
||||
public Guid ItemId => Data?.ItemId ?? Guid.Empty;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ public class ItemManager
|
|||
{
|
||||
return new SimpleCommodity
|
||||
{
|
||||
Data = CreateReference(itemId),
|
||||
Reference = CreateReference(itemId),
|
||||
Quantity = count
|
||||
};
|
||||
}
|
||||
|
|
@ -444,14 +444,14 @@ public class ItemManager
|
|||
{
|
||||
return new ConsumableItem
|
||||
{
|
||||
Data = CreateReference(itemId),
|
||||
Reference = CreateReference(itemId),
|
||||
Quality = quality
|
||||
};
|
||||
}
|
||||
|
||||
return new CompoundCommodity
|
||||
{
|
||||
Data = CreateReference(itemId),
|
||||
Reference = CreateReference(itemId),
|
||||
Quality = quality
|
||||
};
|
||||
}
|
||||
|
|
@ -471,7 +471,7 @@ public class ItemManager
|
|||
|
||||
return new EquippableItem
|
||||
{
|
||||
Data = CreateReference(itemId),
|
||||
Reference = CreateReference(itemId),
|
||||
Quality = quality,
|
||||
Durability = item.Durability > 0 ? (float)item.Durability : 1f
|
||||
};
|
||||
|
|
|
|||
|
|
@ -545,10 +545,12 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
|
|||
escape `ItemManager`;
|
||||
gameplay stat modifiers target live behavior instances and package-owned
|
||||
behavior metadata instead of rebuilding config DTOs for lookup.
|
||||
`ItemInstance.ItemId` is the runtime identity surface; `RuntimeItemReference`
|
||||
remains only the backing compatibility reference until native typed item
|
||||
instances replace it. The reader interface for this bridge is named
|
||||
`IRuntimeItemCatalogReader` and exposes only typed catalog row lookup. Behavior
|
||||
`ItemInstance.ItemId` is the runtime identity surface and
|
||||
`ItemInstance.Reference` is the explicit item-reference API;
|
||||
`RuntimeItemReference Data` remains only the backing compatibility field
|
||||
until native typed item instances replace it. The reader interface for this
|
||||
bridge is named `IRuntimeItemCatalogReader` and exposes only typed catalog
|
||||
row lookup. Behavior
|
||||
type selection now uses an explicit runtime catalog map instead of
|
||||
`UnionAttribute` reflection, and the temporary behavior config constructor
|
||||
map is keyed by typed behavior payload kind rather than legacy union key.
|
||||
|
|
@ -1057,6 +1059,10 @@ First Aetheria surfaces to publish:
|
|||
move live runtime/UI/catalog lookup call sites off `.Data.ItemId`. The old
|
||||
`Data` field is now compatibility backing state rather than the identity
|
||||
API callers use.
|
||||
- Done: add `ItemInstance.Reference` as the explicit item-reference API and
|
||||
move factories/cargo stacking off direct `.Data` comparisons and
|
||||
assignments. `Data` remains only the serialized/backing compatibility
|
||||
field.
|
||||
- Done: delete the dead `ItemManager.GetRuntimeItemProjection<T>` bridge
|
||||
after loadout generation stopped hydrating selected typed rows into
|
||||
`EquippableItemData` merely to instantiate equipment.
|
||||
|
|
@ -1124,7 +1130,8 @@ First Aetheria surfaces to publish:
|
|||
- `rg ".Data.Value|SetValue|GetCatalogEntry|IRuntimeItemCatalogReader|BindRuntimeItemCatalog|ResolveRuntimeItemCatalog|private static IRuntimeItemCatalogReader"` in
|
||||
`Assets/Scripts` is zero for the old item value/catalog-entry/resolver path.
|
||||
- Live Unity source has no `RuntimeCatalogLink<T>` or `RuntimeCatalogLinkBase`;
|
||||
item instances use `RuntimeItemReference` and expose `Data.ItemId`.
|
||||
item instances expose `ItemId` and `Reference`; direct `Data.ItemId` reads are
|
||||
contained inside the `ItemInstance.ItemId` bridge.
|
||||
- Live Unity source has no `RuntimeCatalogEntry` or `RuntimeItemProjectionEntry`.
|
||||
- Live Unity source has no `InspectableRuntimeCatalogLinkAttribute`;
|
||||
`LegacyPayloadKeyAttribute` remains only as the temporary mapper key.
|
||||
|
|
|
|||
Loading…
Reference in a new issue