InteriorItemBase
An abstract, networked component that represents an interactive, placeable item within a dynamic interior space. It handles placement logic, state sync, ownership, collision checking, and visual instantiation within a Fusion multiplayer and Firebase-persisted environment.
public abstract class InteriorItemBase : NetworkBehaviour, IStateAuthorityChanged
Purpose
- 🧱 Manages placement, snapping, and rotation of individual interior items
- 🔄 Synchronizes ownership, visual state, and spatial data across networked clients
- 🧩 Supports nested child items and composite construction
- 💾 Interfaces with Firebase via
FirebaseGameDataProvider.InteriorItem - 🎮 Responds to player interaction, edit state, and UI visualization
Core Features
✅ Placement State
isValidPlacement: Ensures spatial validity via bounds checking and collision detectionSetValidPlacement()/SetValidPlacementVisual(): Mark item as valid/invalid and update visuals accordingly
🔄 Network Sync
Networkedfields:position,rotation,isOwned,isDeployed,roomIndex,parentID,NetworkGUID- RPCs: Position/rotation changes, edit requests, update relay
👁️ Visuals
ShowVisual()/HideVisual()manage addressable instantiation- Supports
InteriorItemVisualwith outline and placement feedback materials
🛠️ Placement Logic
- Smart grid snapping
- Collision-aware movement
- Surface-based anchoring (
PlacementSurface) - Recursive containment checks for valid room bounds
👥 Ownership & Edit State
isBeingEdited,SetBeingEdited(): Determines if item is in edit mode- Applies visual and collider/interaction state accordingly
Key Methods
MoveItem(Vector3, PlacementSurface)
Moves the item, snapping to grid or anchoring to a surface. Performs collision checks and room boundary validation.
RotateInIncrement(RotationIncrement)
Rotates the item in standard increments (15/30/45/90 degrees).
CheckAgainstOtherItems(bool)
Determines spatial validity by checking overlap with other items and room walls.
IsContainedInRoom(Collider[])
Verifies whether the item is fully contained in a valid room.
RegisterInteriorManager()
Assigns ownership, registers with manager, applies remote data.
RemoteDataReceived()
Applies data from Firebase into live simulation, including position, rotation, and metadata.
Nested Items
nestedItems: Allows child items to be attached hierarchicallyRegisterItem()/UnregisterItem(): Manage children and maintain consistent parent linksUpdateChildren()cascades remote update logic
Collision & Containment
Uses a combination of:
Physics.ComputePenetration()for dynamic overlap detection- Manual bounding box corner checks against
BoxColliders - Smart correction vectors when partially clipping
Abstract Members
public abstract void OnFocusLost();
public abstract void RemoveItem();
public abstract void CancelSelection();
public abstract Task UpdateItemRemote();
These must be implemented to handle selection lifecycle, server update push, and teardown logic.
Integration
Works seamlessly with:
DynamicInteriorController- Firebase via
FirebaseGameDataProvider.InteriorItem - Fusion's
NetworkRunnersystem InteriorItemVisualfor dynamic rendering feedback
This class is the foundational building block for user-generated interiors, powering a robust and intuitive editing experience.