SBGItemFramework
Shared backbone for custom item mods. Register an ItemType and a use-handler; it owns the Harmony plumbing for inventory injection, localized names, hotkey labels, tooltips, and pool-spawn injection. Required by dependent mods.
CHANGELOG
Changelog
v0.1.0
- Initial release. Provides the
Cray.SBGItemFrameworklibrary used by other custom-item mods. Surface:ItemKit.Register(RegisteredItem)— entry point, takes a builder-built immutable item description.RegisteredItem.Define(id, displayName)— fluent builder. Optional knobs:WithIconFromVanillaItem,WithIconOverride,WithIconTint,WithMaxUses,WithTooltip,WithSpawnWeight(poolIndex, weight),WithConfigBindings(consumerConfig, bindMaxUses, bindSpawnWeights),AllowVanillaSwingEligibility.IItemHandler/ItemHandlerBasefor the consumer to implement gameplay callbacks (OnUse, optionalOnEquip/OnUnequip).
- Framework-owned Harmony patches:
ItemCollection.Initialize/OnEnableextend the privateitems[]array idempotently so vanillaCount/GetItemAtIndex/TryGetItemDatasee custom items natively, with no per-mod prefix coordination.PlayerInventory.TryUseItemdispatches to the registered handler.PlayerInventory.GetEffectivelyEquippedItem(false)masks custom items toNoneso vanilla swing/aim eligibility doesn't get confused by an unknown ItemType.LocalizedString.GetLocalizedStringrewritesITEM_<rawId>keys to the registered display name.PauseMenu.UpdateItemProbabilitesappends the optional tooltip text alongside the vanilla per-pool weight rows.ItemSpawnerSettings.ResetRuntimeDatainjects custom items into the requested pools'spawnChancesarrays and recalculates the totals.
- Icon tinting goes through a CPU-pixel path on readable source textures and falls back to
a
Graphics.Blitthrough a temporaryRenderTexturefor unreadable ones, with results cached by(textureInstanceId, packedRgba). - Localization-table seeding runs once a frame from a hidden host until the
Datatable finishes loading, so vanilla code that bypasses the LocalizedString postfix still resolves the same display names.