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.
- Listed in ATT, Features and other game namespaces
- Inherits or implements
NetworkEntityBehaviour,IGameCondition
Constructors
| Member | What it is |
|---|---|
NetworkedGameConditionEvaluator() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
3 private and internal fields
| Member | What it is |
|---|---|
private bool areAllConditionsMet | The current combined result. |
private Object[] gameConditions | Objects implementing IGameCondition that must all be met. |
private MethodSyncStruct<bool> syncConditionChange | Method sync on SyncGameConditionChange for the result. |
Properties
| Member | What it is |
|---|---|
Action OnConditionChanged { get; set; } | Callback run on remote clients when a new result arrives. |
Methods
| Member | What 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
| Member | What 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. |