Skip to main content

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 InteriorItemBase instances 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 from DynamicInteriorState)
  • isOwner: Whether the local player has edit rights for this space
  • roomItems: Dictionary of all placed items keyed by instance GUID
  • ActiveRoom: Currently selected logical room area
  • GridSize, UseGrid: Control grid snapping behavior during placement
  • cameraConfiner: Defines bounds for player camera
  • selectedItem: 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 relevant Rpc methods (RequestRemoval_Rpc, MasterClientChanged_Rpc, etc.)
  • Implements IStateAuthorityChanged for handling Fusion master client transitions
  • Uses Spawned() and Despawned() 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:

This class acts as the dynamic runtime brain of the interior systemβ€”handling collaboration, instantiation, UI, and sync with impressive dexterity.