Skip to main content

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.

Constructors​

MemberWhat it is
FestiveFeature()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

7 private and internal fields
MemberWhat it is
private AltaEvent activatedEvent fired when the festivity turns on (also on enable if it is already on).
private AltaEvent changedWhileSpawnedEvent fired only when the state changes after the object is enabled.
private Behaviour[] componentsBehaviours whose enabled follows the festivity state.
private AltaEvent deactivatedEvent fired when the festivity turns off (also on enable if it is off).
private Festivity festivityThe festivity this feature follows.
private GameObject[] gameObjectsGame objects set active or inactive with the festivity.
private static readonly Logger loggerNLog logger for this class.

Methods​

7 private and internal methods
MemberWhat 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.