Table of Contents

Class BuffVolume

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

A region of a scene that buffs whoever is standing in it, tested by position inside the prediction replicate so the owner gets the buff at the step they walk in.

[DisallowMultipleComponent]
public class BuffVolume : MonoBehaviour
Inheritance
Object
Component
Behaviour
MonoBehaviour
BuffVolume
Inherited Members
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.ToString()
Object.name
Object.hideFlags

Remarks

Why not a trigger. A NetworkTrigger would have been the obvious way to build this and is the wrong one (N13). Trigger callbacks are raised by the physics scene in OnPostPhysicsSimulation — outside the replicate, so they cannot be predicted; they are not rolled back, so a reconcile leaves them stale; and they re-fire Enter and Exit on every replayed tick, so one reconcile of thirty ticks would apply and remove the buff thirty times. A point-in-collider test has none of those problems: it is a pure function of a position the replicate already has, it gives the same answer every time that tick is replayed, and the server computes it from the same position the owner did.

Nothing of it rides the wire. Whether a character is inside is derivable from its position, and the position already reconciles — so the volume adds nothing to the reconcile payload, and both peers reach the same answer from the same coordinates. The same property that makes exposure recipes free.

Can sit on a Region's GameObject and share its collider; the Region keeps its own enter and exit actions for anything cosmetic.

Fields

Buff

[Tooltip("The buff applied while a character is inside.")]
public BaseBuffTemplate Buff

Field Value

BaseBuffTemplate

MinimumExposure

[Tooltip("Only buff while a character standing here is this exposed to the sky. 0 lets it work under any roof.")]
[Range(0, 1)]
public float MinimumExposure

Field Value

float

RequiredWeather

[Header("Weather gate (optional)")]
[Tooltip("Only buff while the weather here is doing one of the chosen things. None: always.")]
public WeatherKindMask RequiredWeather

Field Value

WeatherKindMask

Shape

[Tooltip("The shape. Defaults to this GameObject's collider.")]
public Collider Shape

Field Value

Collider

Properties

NeedsWeather

True when this volume needs the weather sampled to answer at all.

public bool NeedsWeather { get; }

Property Value

bool

Methods

AppliesAt(Vector3, in WeatherReading)

Whether this volume's buff should be on a character at that point, weather gate included.

public bool AppliesAt(Vector3 worldPoint, in WeatherReading weather)

Parameters

worldPoint Vector3

Where the character is.

weather WeatherReading

The weather there, already sampled by the caller.

Returns

bool

Remarks

The gate is evaluated from the weather at the character's own position rather than the volume's centre, so a long valley whose far end is under the storm behaves as the two different places it is.

Contains(Vector3)

public bool Contains(Vector3 worldPoint)

Parameters

worldPoint Vector3

Returns

bool

Register()

Puts this volume into its scene's registry, defaulting the shape to this GameObject's collider first.

public void Register()

Remarks

Separate from OnEnable rather than inlined into it so that it can be driven directly. Edit mode does not run MonoBehaviour lifecycle callbacks on a component that is not [ExecuteAlways], and this one deliberately is not — a volume has no business registering itself while somebody is merely editing the scene. That leaves the one-line callback as the only part a test cannot reach, instead of the whole body of it.

Unregister()

Takes this volume back out of the registry it last registered with.

public void Unregister()