Table of Contents

Class WeatherExposureController

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Turns the weather a character is standing in into buffs — wet, chilled, wind-burnt — and does it inside the prediction replicate, so the owner sees the state change at the moment it earns it rather than a round trip later.

[DisallowMultipleComponent]
public class WeatherExposureController : CharacterBehaviour, ICharacterBehaviour, IPredictableController
Inheritance
Object
Component
Behaviour
MonoBehaviour
NetworkBehaviour
WeatherExposureController
Implements
Inherited Members
NetworkBehaviour.IsSpawned
NetworkBehaviour.ComponentIndex
NetworkBehaviour.NetworkObject
NetworkBehaviour.MAXIMUM_NETWORKBEHAVIOURS
NetworkBehaviour.UNSET_NETWORKBEHAVIOUR_ID
NetworkBehaviour.ToString()
NetworkBehaviour.Reset()
NetworkBehaviour.OnValidate()
NetworkBehaviour.IsBehaviourReconciling
NetworkBehaviour.ClearReplicateCache()
NetworkBehaviour.RequestReconcileSends()
NetworkBehaviour.CreateReconcile()
NetworkBehaviour.Reconcile_Reader_Remote<T>(PooledReader, ref T)
NetworkBehaviour.ClearBuffedRpcs()
NetworkBehaviour.IsClientOnly
NetworkBehaviour.IsServerOnly
NetworkBehaviour.IsHost
NetworkBehaviour.IsClient
NetworkBehaviour.IsServer
NetworkBehaviour.IsDeinitializing
NetworkBehaviour.NetworkManager
NetworkBehaviour.ServerManager
NetworkBehaviour.ClientManager
NetworkBehaviour.ObserverManager
NetworkBehaviour.TransportManager
NetworkBehaviour.TimeManager
NetworkBehaviour.SceneManager
NetworkBehaviour.PredictionManager
NetworkBehaviour.RollbackManager
NetworkBehaviour.NetworkObserver
NetworkBehaviour.IsClientInitialized
NetworkBehaviour.IsClientStarted
NetworkBehaviour.IsClientOnlyInitialized
NetworkBehaviour.IsClientOnlyStarted
NetworkBehaviour.IsServerInitialized
NetworkBehaviour.IsServerStarted
NetworkBehaviour.IsServerOnlyInitialized
NetworkBehaviour.IsServerOnlyStarted
NetworkBehaviour.IsHostInitialized
NetworkBehaviour.IsHostStarted
NetworkBehaviour.IsOffline
NetworkBehaviour.IsNetworked
NetworkBehaviour.GetIsNetworked()
NetworkBehaviour.IsManagerReconciling
NetworkBehaviour.Observers
NetworkBehaviour.IsOwner
NetworkBehaviour.IsController
NetworkBehaviour.HasAuthority
NetworkBehaviour.Owner
NetworkBehaviour.OwnerId
NetworkBehaviour.ObjectId
NetworkBehaviour.LocalConnection
NetworkBehaviour.OwnerMatches(NetworkConnection)
NetworkBehaviour.Despawn(GameObject, DespawnType?)
NetworkBehaviour.Despawn(NetworkObject, DespawnType?)
NetworkBehaviour.Despawn(DespawnType?)
NetworkBehaviour.Spawn(GameObject, NetworkConnection, Scene)
NetworkBehaviour.Spawn(NetworkObject, NetworkConnection, Scene)
NetworkBehaviour.RemoveOwnership()
NetworkBehaviour.GiveOwnership(NetworkConnection)
NetworkBehaviour.GetInstance<T>()
NetworkBehaviour.TryRegisterInstance<T>(T)
NetworkBehaviour.UnregisterInstance<T>()
NetworkBehaviour.CanLog(LoggingType)
NetworkBehaviour.OnStartServerCalled
NetworkBehaviour.OnStartClientCalled
NetworkBehaviour.WritePayload(NetworkConnection, Writer)
NetworkBehaviour.ReadPayload(NetworkConnection, Reader)
NetworkBehaviour.OnStartNetwork()
NetworkBehaviour.OnStopNetwork()
NetworkBehaviour.OnStartServer()
NetworkBehaviour.OnStopServer()
NetworkBehaviour.OnOwnershipServer(NetworkConnection)
NetworkBehaviour.OnSpawnServer(NetworkConnection)
NetworkBehaviour.OnDespawnServer(NetworkConnection)
NetworkBehaviour.OnStartClient()
NetworkBehaviour.OnStopClient()
NetworkBehaviour.OnOwnershipClient(NetworkConnection)
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.didStart
MonoBehaviour.didAwake
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.GetComponentIndex()
Component.CompareTag(TagHandle)
Component.transform
Component.transformHandle
Component.gameObject
Component.tag
Object.GetEntityId()
Object.MemberwiseClone()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.name
Object.hideFlags

Remarks

Who simulates. The server and the owning client, driven from CharacterPredictionController's single [Replicate] like every other controller. An observer never runs it: state forwarding is off on every prefab, and the buffs it applies reach observers the way all buffs do.

Why it can be predicted at all. Everything it reads is a pure function of the tick and the position. The weather timeline is deterministic from its seed and clock anchor, both of which the client already holds; shelter is a point-in-collider test (WeatherVolume.Contains, and so RegionGeometry.ContainsPoint) rather than a physics trigger, which matters because triggers poll in OnPostPhysicsSimulation, outside the replicate, are not rolled back, and re-fire their Enter/Exit on every replay (N12). So the owner can work out the same answer the server will, and a replay of the same tick gives the same answer again.

Which clock. The weather is evaluated at a SYNCHRONISED tick, and the replicate's tick is the owner's unsynchronised counter: see WeatherExposureTick, which is where that conversion lives and is tested.

No new field in the input. Nothing is sent up from the client; the whole step is derived from the tick, the character's own position and the timeline both sides already have (N12). What does ride the reconcile is the levels, because they are timers — see Exposure.

Fields

Recipes

[Tooltip("States that exist only where two or more of the above do at once: soaked AND chilled is frozen. Evaluated from the levels, so they cost nothing on the wire.")]
public List<WeatherExposureRecipe> Recipes

Field Value

List<WeatherExposureRecipe>

SampleSeconds

[Tooltip("How often the weather is sampled, in seconds. The level is stepped by exactly this much each time, so a slower sample is cheaper without changing how fast a state builds.")]
[Range(0.1, 5)]
public float SampleSeconds

Field Value

float

States

[Header("Exposure")]
[Tooltip("The states this character can be put into by the weather. Empty: the controller does nothing.")]
public List<WeatherExposureTemplate> States

Field Value

List<WeatherExposureTemplate>

VerboseLogging

[Tooltip("Log every level change. Very noisy; for working on exposure only.")]
public bool VerboseLogging

Field Value

bool

Properties

Order

After movement (KCCPlayer, 80) so the position is this tick's, and before buffs (BuffController, 85) so a buff applied here is ticked in the same step rather than the next one.

public int Order { get; }

Property Value

int

OrderedRecipes

Every recipe this controller can satisfy, nulls and duplicates removed.

public IReadOnlyList<WeatherExposureRecipe> OrderedRecipes { get; }

Property Value

IReadOnlyList<WeatherExposureRecipe>

OrderedStates

Every state this controller can enter, in reconcile order.

public IReadOnlyList<WeatherExposureTemplate> OrderedStates { get; }

Property Value

IReadOnlyList<WeatherExposureTemplate>

Methods

CreateReconcileSnapshot()

The levels as they go on the wire, sorted by template ID and quantised.

public ExposureReconcileEntry[] CreateReconcileSnapshot()

Returns

ExposureReconcileEntry[]

Remarks

The cached array is returned unchanged when nothing moved, so the delta serializer's ReferenceEquals shortcut skips the comparison entirely — the same trick the buff and attribute snapshots use.

IsHolding(WeatherExposureRecipe)

True while the recipe is satisfied and holding its buff.

public bool IsHolding(WeatherExposureRecipe recipe)

Parameters

recipe WeatherExposureRecipe

Returns

bool

IsHolding(WeatherExposureTemplate)

True while the state's buff is held.

public bool IsHolding(WeatherExposureTemplate state)

Parameters

state WeatherExposureTemplate

Returns

bool

IsSuppressed(WeatherExposureTemplate)

True while a recipe is holding this state's buff in its place.

public bool IsSuppressed(WeatherExposureTemplate state)

Parameters

state WeatherExposureTemplate

Returns

bool

LevelOf(WeatherExposureTemplate)

The level of one state, 0..1. For the recipes, the UI and tests.

public float LevelOf(WeatherExposureTemplate state)

Parameters

state WeatherExposureTemplate

Returns

float

OnCreateReconcile(ref CharacterReconcileData)

Writes this controller's authoritative state into the reconcile data (server only). Called once per tick after OnReplicate(ref CharacterReplicateData, ReplicateState, Channel).

public void OnCreateReconcile(ref CharacterReconcileData reconcileData)

Parameters

reconcileData CharacterReconcileData

OnReconcile(CharacterReconcileData, Channel)

Restores this controller's state from the server's authoritative reconcile data.

public void OnReconcile(CharacterReconcileData rd, Channel channel)

Parameters

rd CharacterReconcileData
channel Channel

OnReplicate(ref CharacterReplicateData, ReplicateState, Channel)

Executes this controller's simulation for the current tick. May modify input for observer prediction.

public void OnReplicate(ref CharacterReplicateData input, ReplicateState state, Channel channel)

Parameters

input CharacterReplicateData
state ReplicateState
channel Channel

PopulateInput(ref CharacterReplicateData)

Populates this controller's portion of the unified input data (owner only). Called once per tick before OnReplicate(ref CharacterReplicateData, ReplicateState, Channel).

public void PopulateInput(ref CharacterReplicateData input)

Parameters

input CharacterReplicateData

ResetState(bool)

Resets this NetworkBehaviour so that it may be added to an object pool.

public override void ResetState(bool asServer)

Parameters

asServer bool

RestoreFromReconcile(ExposureReconcileEntry[])

Takes the server's levels as the truth, and re-derives which buffs are held.

public void RestoreFromReconcile(ExposureReconcileEntry[] entries)

Parameters

entries ExposureReconcileEntry[]

Remarks

The held set is rebuilt from the restored levels rather than carried across the reconcile, because the levels have just been overwritten: a buff whose level the server says never reached the threshold must not still be marked as held, or it would never be applied again. Dequantising here — the same function the server quantised with — leaves both peers on bit-identical levels, so the replay that follows starts from the server's state exactly.

RestoreFromReconcile(ExposureReconcileEntry[], BuffReconcileEntry[])

RestoreFromReconcile(ExposureReconcileEntry[]), with the server's buffs for the same tick: they say which side of a hysteresis band a state or a recipe was on, which the levels alone cannot.

public void RestoreFromReconcile(ExposureReconcileEntry[] entries, BuffReconcileEntry[] serverBuffs)

Parameters

entries ExposureReconcileEntry[]
serverBuffs BuffReconcileEntry[]

Remarks

Inside the band (between release and apply) "held" depends on which way the level was travelling. The server's answer is in the same correction: the buff is on its list or it is not. Without it a state in the band kept whatever this client last believed, and every recipe was read as NOT held, so a buff the server was holding by its release margin was taken off by the owner at its next sample, put back by the next correction, and taken off again by the replay: an icon and an effect flickering once a second.