FestiveFeature
A class in Root.Township, the global namespace.
Turns components and child objects on or off while a Festivity is active, for seasonal decorations. Runs on each side from the festivity's synced state.
- Listed in Global namespace: E to H
- Inherits or implements
MonoBehaviour,IBuildRendererPostBake,IBuildBakeable,IForcePresenceOnAndroidClient,IIgnoreForStaticFlatten,IDontSplit
Constructors
| Member | What it is |
|---|---|
FestiveFeature() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
7 private and internal fields
| Member | What it is |
|---|---|
private AltaEvent activated | Event fired when the festivity turns on (also on enable if it is already on). |
private AltaEvent changedWhileSpawned | Event fired only when the state changes after the object is enabled. |
private Behaviour[] components | Behaviours whose enabled follows the festivity state. |
private AltaEvent deactivated | Event fired when the festivity turns off (also on enable if it is off). |
private Festivity festivity | The festivity this feature follows. |
private GameObject[] gameObjects | Game objects set active or inactive with the festivity. |
private static readonly Logger logger | NLog logger for this class. |
Methods
7 private and internal methods
| Member | What it is |
|---|---|
private void Modify(bool isActive) | Enables or disables every listed component and game object, then fires activated or deactivated. |
private void OnDisable() | Unsubscribes from the festivity's ActivationChanged event. |
private void OnEnable() | Swaps in the resources copy of the festivity, applies its current state and subscribes to changes. Logs an error if none is assigned. |
private void OnFestivityActivationChanged(Festivity festivity) | Handler for ActivationChanged: applies the new state and fires changedWhileSpawned. |
private void IBuildRendererPostBake.PostBake() | Build step that strips null entries from components and gameObjects. |
private void SetActive(bool isActive) | Applies a state by hand and fires changedWhileSpawned. Private and not called in this code. |
private bool TryGetFestivityFromResources() | Replaces the serialized festivity with the instance from HashedGeneralValue by hash, so it shares the live state. False if not found. |