Table of Contents

Class SwitchTargetObject

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

A ISwitchTarget that enables and disables a set of GameObjects.

public class SwitchTargetObject : MonoBehaviour, ISwitchTarget
Inheritance
Object
Component
Behaviour
MonoBehaviour
SwitchTargetObject
Implements
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.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

The simplest thing a switch can usefully drive: force fields, barriers, light sources, particle effects, a bridge that appears. Objects in ActivateObjects are switched on when the switch is activated; objects in DeactivateObjects are switched off at the same moment, which is what lets one switch swap a closed barrier for an open one rather than needing two switches.

Runs identically on server and client. The server toggles because colliders in these hierarchies are real to the character controller; the client toggles because the player has to see it. Neither derives the state locally — Switch is authoritative and the client is driven by SwitchStateBroadcast.

Properties

ActivateObjects

Objects switched on by activation.

public List<GameObject> ActivateObjects { get; }

Property Value

List<GameObject>

DeactivateObjects

Objects switched off by activation.

public List<GameObject> DeactivateObjects { get; }

Property Value

List<GameObject>

IsActivated

Whether this target is currently in the activated state.

public bool IsActivated { get; }

Property Value

bool

Methods

Activate(IPlayerCharacter)

Activates this target (e.g., opens a door, unlocks a chest, disarms a trap).

public void Activate(IPlayerCharacter activator)

Parameters

activator IPlayerCharacter

The player character who triggered the switch.

Deactivate(IPlayerCharacter)

Deactivates this target (e.g., closes a door, locks a chest, re-arms a trap).

public void Deactivate(IPlayerCharacter activator)

Parameters

activator IPlayerCharacter

The player character who triggered the switch.

SnapTo(bool)

Puts this target into the given state with no transition.

public void SnapTo(bool activated)

Parameters

activated bool

The state to adopt immediately.

Remarks

For catching up rather than for reacting. A client that starts observing a switch reads the switch's current state out of its spawn payload, and that state describes something that happened before the player arrived — possibly hours before. Replaying it through Activate(IPlayerCharacter) would play the transition too, so walking into a room would set every door in it swinging. Nothing on the interaction path calls this.