Skip to main content

NetworkedGameConditionEvaluator

A class in Root.Township, Features.Gameplay.GameConditions.

Networked AND of several IGameConditions. The server watches them and sends the combined result to clients, so clients can use it as a condition too.

Constructors​

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

Fields​

3 private and internal fields
MemberWhat it is
private bool areAllConditionsMetThe current combined result.
private Object[] gameConditionsObjects implementing IGameCondition that must all be met.
private MethodSyncStruct<bool> syncConditionChangeMethod sync on SyncGameConditionChange for the result.

Properties​

MemberWhat it is
Action OnConditionChanged { get; set; }Callback run on remote clients when a new result arrives.

Methods​

MemberWhat it is
override void Initialize()Creates the sync and, on the server or local test, hooks the conditions and computes the first result.
bool IsConditionMet()The last computed (server) or received (client) result.
override void OnConnected(Player player)Server: sends the current result to the joining player.
4 private and internal methods
MemberWhat it is
private bool AreAllConditionsMet()Returns true if every listed condition is met.
private void ConditionChanged()Recomputes the result and sends it to chunks when it changes. Does not run OnConditionChanged on the server.
private void InitializeEventListeners()Hooks ConditionChanged onto each condition's OnConditionChanged, without adding it twice.
private void SyncGameConditionChange(IPlayer player, Stream stream, bool conditionsMet)Writes the result, and on remote clients stores it and runs OnConditionChanged.