DynamicInteriorController
The authoritative manager for runtime-spawned interior spaces. Works with DynamicInteriorState to support item placement, room transitions, multiplayer collaboration, and Fusion networking in fully dynamic, player-owned environments.
public class DynamicInteriorController : SelfRegisteredInjectionNetworkBehaviour, IStateAuthorityChanged, IRootControllerUIProvider
Purposeβ
- Controls runtime placement and lifecycle of interior items
- Handles player-owned or shared-room scenarios with permission checks
- Interfaces with UI and multiplayer services
- Manages camera boundaries, room visuals, grid snapping, and Firebase sync
Key Responsibilitiesβ
- π§© Track all
InteriorItemBaseinstances via GUIDs - π Manage room switching and room-specific visibility
- π Sync interior item updates from Firebase backend
- π¬ Serve UI for selection, grid previews, and placement
- π§ Register item ownership and permissions
- π οΈ Support editing workflows: confirm, deploy, remove, dismiss
Propertiesβ
InteriorID: ID of the current interior space (derived fromDynamicInteriorState)isOwner: Whether the local player has edit rights for this spaceroomItems: Dictionary of all placed items keyed by instance GUIDActiveRoom: Currently selected logical room areaGridSize,UseGrid: Control grid snapping behavior during placementcameraConfiner: Defines bounds for player cameraselectedItem: Currently selected/interacting item
Item Management Methodsβ
RegisterItem() / UnregisterItem()β
Track or remove item instances from the room registry.
ConfirmItemPlacement()β
Saves local item state to Firebase backend.
RemoveItem(), RemoveItemAndSurface(), RemoveItems()β
Handles single or batch removal of placed items.
DeployItem()β
Spawns a new item based on buildable prefab logic and player inventory.
Room & UI Logicβ
ChangeRoom(InteriorRoom)β
Switches visual focus to another room.
ShowGridPreview() / HideGridPreview()β
Toggles grid overlay for item placement.
GetSpawnPosition() / GetSpawnRotation()β
Used by GameStateWithPlayer to determine player spawn points.
Interior Syncβ
LoadInteriorByID()β
Initial load of interior data from backend and sets ownership/collaboration state.
InteriorItemsUpdated()β
Processes incoming backend updates, manages diffs, spawns/despawns items as needed.
Networkingβ
- Full use of Fusion's
NetworkBehaviour, with relevantRpcmethods (RequestRemoval_Rpc,MasterClientChanged_Rpc, etc.) - Implements
IStateAuthorityChangedfor handling Fusion master client transitions - Uses
Spawned()andDespawned()lifecycle to register/unregister content
UI Provider Contractβ
Implements IRootControllerUIProvider to inject scene-specific UI during item selection:
public Task<GameObject> GetUIPrefab()
public void ReleaseUIPrefab()
public void RequestDismissal()
Example Useβ
// Select an item and bring up the selection UI
dynamicInteriorController.SelectItem(myItem, isOwned: true);
// Confirm placement and sync with backend
await dynamicInteriorController.ConfirmItemPlacement(myItem);
// Deploy a new item from player inventory
dynamicInteriorController.DeployItem(itemData);
Integrationβ
Works in tandem with:
DynamicInteriorStateInteriorItemBaseGameStateManager- Firebase-based providers via
GameServiceFactory
This class acts as the dynamic runtime brain of the interior systemβhandling collaboration, instantiation, UI, and sync with impressive dexterity.