Skip to main content

ReviveOrb

A class in Root.Township, Township.Downed.

One of the orbs spawned around a downed player. Another player carries it into the gravestone's beam, then the downed player grabs and releases it to add revive progress. Server decides; clients show who can grab it.

Constructors​

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

Fields​

13 private and internal fields
MemberWhat it is
private ReviveCompletableActivity activityServer: the revive activity this orb adds progress to.
private float activityProgressProgress one orb adds: 1 over the number of orbs spawned.
private IPlayer downedPlayerThe downed player this orb belongs to.
private bool hasSwappedStateTrue once the orb has been delivered to the beam; it can't re-enter after that.
private bool isInBeamTrue while the orb is inside the downed player's gravestone trigger.
private Vector3 orbOriginPosition the out of bounds distance is measured from.
private Pickup orbPickupThe orb's pickup.
private SoundEffectSet orbTransitionSfxSound played when the orb swaps to the downed player's side.
private GameObject[] orbVisualsToToggleObjects shown only while the orb is grabbable for the local player.
private AnimateScaleOverTime scaleAnimationScale animation played when the orb is released outside the beam.
private DownedStateSettings settingsDowned state settings: orb count and force release distance.
private MethodSyncStruct<int> syncDownedPlayerIdentifierSync that sends the downed player's identifier to clients.
private MethodSync syncOrbConsumedByBeaconSync that tells clients the orb reached the beam.

Methods​

MemberWhat it is
void ConsumeByDownedPlayer()Server, on release: if the downed player let go of it, adds revive progress and destroys the orb.
void LinkReviveActionToActivity(ReviveCompletableActivity completableActivity, IPlayer newDownedPlayer, DownedStateSettings newSettings, Vector3 newOrbOrigin)Sets the settings and origin. Server: also links the revive activity and downed player and syncs the player to clients.
override void OnDisconnected(Player player)Destroys the orb if its downed player disconnects.
protected override void Awake()Hooks the action orb's grab and release, stops the orb being saved, and sets up the two syncs.
protected override void ValidatePickupInteraction(Interactor interactor, Interactable interactable, ref bool result)Stops downed players grabbing the orb unless it's theirs.
17 private and internal methods
MemberWhat it is
private bool CanConsumeOrb()Server: true if the downed player was the last to hold the orb.
private void CheckEnterOrExitBeacon(GameObject playerGrave, bool isEnteringBeam)Marks the orb as in the beam when it enters this downed player's gravestone trigger, until it has swapped state.
private void ConsumeByBeacon()Server: flips the orb to the downed player's side, moves it within their reach and tells clients.
private void InvertOrbInteractability()Client: makes the orb grabbable only for the downed player.
private bool IsOrbConnectedToPlayer(IPlayer player)True if the player is this orb's downed player.
private void MovedOutOfBounds(PlayerController player, Vector3 oldPosition, Vector3 newPosition, LocomotionFunction function)Server: force drops the orb if the holder moves too far from the orb's origin.
private void OnInteractionEnded(Interactable interactable, Interactor interactor)On release: makes it kinematic, plays the scale animation if outside the beam, and consumes it if inside.
private void OnInteractionStarted(Interactable interactable, Interactor interactor)Server: starts watching the holder's movement for the out of bounds check.
private void OnTriggerEnter(Collider other)Checks whether the orb entered its downed player's gravestone beam.
private void OnTriggerExit(Collider other)Checks whether the orb left its downed player's gravestone beam.
private void PlayTransitionSoundEffect()Plays the transition sound on the orb.
private void SetActionOrbHapticFeedback()Client: haptics on the orb only for the downed player.
private void SetIsOrbInteractable(bool isInteractable)Client: turns the pickup and its visuals on or off.
private void SyncDownedPlayerIdentifierToClient(IPlayer player, Stream stream, int downedPlayerIdentifier)Client receive: stores the downed player and makes the orb grabbable for everyone except them.
private void SyncOrbConsumedByBeacon(IPlayer player, Stream stream)Client receive: plays the transition sound and swaps who can grab the orb.
private void TryConsumeOrbInBeacon()Server: calls ConsumeByBeacon if the orb was released in the beam.
private void TryScaleOrb()Plays the scale animation once unless the orb is in the beam.

Used in​

Members of other types that take, return or hold a ReviveOrb: