📏 Policies¶
Defines per-container default sizes through the ContainerSizePolicy asset.
Used by SceneInventoryService when lazily creating containers that do not yet exist.
🎒 Ideal for setting backpack / hotbar / chest defaults
🧩 Optional — if missing, the service falls back to internal rules
Purpose¶
Provides a central, authorable place to define initial container sizes per container name
(e.g. "Backpack", "Hotbar", "ChestA").
This keeps capacity rules: - Out of code - In one ScriptableObject - Easy to audit and adjust
🚀 Quick Start¶
- Create → RevFramework → Inventory → Container Size Policy
- Edit the entries:
new Entry { name = "Backpack", size = 24 }
new Entry { name = "Hotbar", size = 8 }
- Assign the asset to your
SceneInventoryService.
Runtime Behaviour¶
🔍 Matching Rules¶
When a container is first created:
- Container names are canonicalised (
Trim().ToLowerInvariant()) - Matching is case-insensitive
- First match wins
If no policy entry matches:
"Backpack"→ falls back toCharacterInventory.backpackSize(default 24)- All other containers → fall back to 12 slots
🎒 Backpack Special Case¶
Backpack sizing supports two layers:
CharacterInventory.backpackSizeContainerSizePolicy(when allowed)
Controlled by:
SceneInventoryService.policyOverridesBackpack
Behaviour¶
-
OFF (default)
→ Backpack always usesCharacterInventory.backpackSize -
ON
→ If the policy contains a"Backpack"entry, it overrides the CharacterInventory size
→ If the policy does not contain a Backpack entry, the CharacterInventory size is used
This ensures the policy only overrides backpack sizing when explicitly configured.
🏗️ Example¶
[SerializeField] private ContainerSizePolicy sizePolicy;
void Awake()
{
SceneInventoryService.Instance.sizePolicy = sizePolicy;
}
When a container named "Hotbar" is created and exists in the policy,
its size is taken directly from the policy entry.
⚠️ Notes & Gotchas¶
- Policies apply only at container creation time
- Changing the policy does not resize existing containers
- Resizing existing containers must be done explicitly via:
SceneInventoryService.ResizeContainer(...)
- Invalid or zero sizes are clamped to ≥ 1