Skip to content

Authority

Runtime, netcode-agnostic authority hooks that determine who may mutate an inventory.

This folder defines authority contracts and resolution logic used by the inventory service to gate write operations.


Purpose

Provide a consistent way to determine whether a caller may mutate inventory state.


What Lives Here

IInventoryAuthority

Minimal policy interface:

public interface IInventoryAuthority
{
    bool HasAuthority(UnityEngine.GameObject owner);
}

Implemented by components that determine whether mutation is allowed for a given owner.


InventoryAuthority (resolver)

Static resolver and cache for locating an authority provider.

Resolves authority using a defined search order and caches the result for reuse.

It is internal, and so is everything on it. There is no public Resolve and no public Invalidate; the public surface is SceneInventoryService.RefreshAuthority(), below. This section used to print the resolver's members as if they were callable, which they are not from any project assembly.


Important Notes

  • This folder defines authority contracts and resolution only
  • It does not provide replication, prediction, or rollback systems
  • It does not enforce networking behaviour

If no authority provider is found, the default runtime behaviour may allow mutations.


Usage Guidance

Service integration

Inventory services consult authority before executing mutation operations.

If denied, operations return InvOpCode.NoAuthority.

Read operations are not gated.


Resolution behaviour

Authority is resolved from:

  • Cached instance (if valid)
  • Same GameObject
  • Parent hierarchy
  • Scene roots
  • Global scan fallback

The first valid provider is used.

Order among providers found by the last two steps is unspecified: scene roots are visited in sibling order and the global scan is unsorted, so with more than one provider in a scene which one answers is stable only for as long as it stays alive and enabled. Keep one per scene, or put yours where the earlier steps will find it.

Scope is the process, not the scene. The cache is a single static instance with no scene key and no scene-load or scene-unload hook, so the first usable authority found anywhere answers for every SceneInventoryService in every loaded scene until it is disabled, destroyed, or displaced by RefreshAuthority(). An authority resolved in one additively-loaded scene will gate a service that wakes up in another, and that scene's own binder is never asked.

A disabled or destroyed authority counts as absent, and absent means permissive. The service re-resolves when the one it holds stops being alive and enabled; if nothing replaces it, mutations are allowed again, silently and with no log. Switching the only binder off does not pause the gate, it removes it.


Runtime updates

Call SceneInventoryService.RefreshAuthority() on the services that should see a provider added at runtime — that is the whole public route, and the shipped Lockdown recipe uses it. The call discards the resolver's cache and re-runs the search, so a provider on the service's own GameObject or a parent takes over. Among scene-wide providers the search still returns the first one it finds, so a newcomer on its own root does not outrank a live one on an earlier root; place it above the service if it has to win, or keep one authority per scene.

A destroyed or disabled provider needs no call: the service notices on its next check.


Not for Production Use

This folder does not:

  • Implement multiplayer systems
  • Replicate inventory state
  • Provide prediction or rollback
  • Guarantee a specific authority model

These concerns must be handled by the host project or networking layer.