CullingGroupHandler
A class in Root.Township, the global namespace.
Client: one hidden shared Unity CullingGroup on the local player's camera that other scripts register bounding spheres with to get visibility callbacks. Created on first RegisterSphere.
- Listed in Global namespace: C to D
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
CullingGroupHandler() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
8 private and internal fields
| Member | What it is |
|---|---|
private CullingGroup culling | The Unity CullingGroup, bound to the local player's camera. |
private Dictionary<int, Action<CullingGroupEvent>> events | Callback for each registered sphere index. |
private static CullingGroupHandler handler | The single shared instance. |
private bool isSetup | Unused flag. |
private int nextIndex | Next free slot to use for a new sphere. |
private int sphereCount | How many array slots the culling group checks (one past the highest used slot). |
private BoundingSphere[] spheres | Bounding spheres; starts at 16 and doubles when full. |
private bool[] usage | Which sphere slots are in use. |
Methods
| Member | What it is |
|---|---|
static void DeregisterSphere(ref int index) | Removes a sphere by index, shrinks the active count if it was last, and sets the caller's index to -1. |
static int RegisterSphere(Vector3 center, float radius, Action<CullingGroupEvent> callback) | Registers a sphere and callback, creating the handler if needed; returns the index to pass to DeregisterSphere. Used by StorageOrganizer and SphereVisibilityCheck. |
5 private and internal methods
| Member | What it is |
|---|---|
private void OnDestroy() | Clears the singleton, disposes the culling group and unsubscribes from PlayerController.LocalPlayerSet. |
private int RegisterSphereInternal(Vector3 center, float radius, Action<CullingGroupEvent> callback) | Stores the sphere in the next free slot, doubles the arrays when full, and updates the culling group. |
private void SetupCulling(PlayerController player) | Creates a new culling group on the given player's camera. Runs again whenever the local player is set. |
private void SetupSpheres() | Pushes the sphere array and count to the culling group. |
private void UpdateStates(CullingGroupEvent sphere) | Culling group callback: forwards the event to the callback registered for that sphere index. |