Skip to main content

FestivityManager

A class in Root.Township, the global namespace.

Network entity that turns festivities on and off by the real date and syncs their state to players. The server checks dates; clients only receive.

Constructors​

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

Fields​

3 private and internal fields
MemberWhat it is
private CancellationTokenSource cancelCancels the recheck loop when the manager is destroyed.
private MethodSyncClass<Festivity> syncMethod sync (SyncA) used to send festivity state.
private float updateIntervalSecondsSeconds between date checks. Default 1.

Methods​

MemberWhat it is
override void Initialize()Both sides: resets every festivity to inactive and sets up the sync message.
override void InitializeAsServer(SpawnData spawnData)Server: starts the Recheck loop.
override void OnConnected(Player player)Server: sends each active festivity to a joining player.
void SetFestivityActive(Festivity festivity, bool isActive)Sets a festivity's state and, if it changed, sends it to all chunks. Used by Check and the console commands.
5 private and internal methods
MemberWhat it is
private void Check()Server: sets each festivity active if it is enabled and the current MonthDayHour is between its start and end.
private void OnDestroy()Cancels the recheck loop.
private void OnValidate()Editor while playing on a server: restarts the check loop after inspector changes.
private async void Recheck(CancellationToken token)Server: async loop that runs Check every updateIntervalSeconds until cancelled.
private void SyncFestivity(IPlayer player, Stream stream, Festivity festivity)Sync handler: writes the festivity hash and state; remote clients apply the state on read.