Skip to main content

ReviveCompletableActivity

A class in Root.Township, Township.Downed.

The revive minigame for a downed player: spawns a rotating ring of revive orbs around the grave and counts progress as orbs are consumed. Created by DownedState on the server.

Constructors​

MemberWhat it is
ReviveCompletableActivity(PlayerCharacter playerCharacter, DownedStateSettings settings, Vector3 spawnPosition)Creates a ReviveCompletableActivity from playerCharacter, settings and spawnPosition.

Fields​

11 private and internal fields
MemberWhat it is
private float angleBetweenOrbsCached angle between orbs. Never set in this build, so the computed value is used.
private HashSet<uint> consumedOrbIdentifiersIds of orbs that have already counted.
private bool inProgressTrue while progress is being counted.
private List<ReviveOrbMovementModifier> orbPositionModifiersMovement modifiers on each orb anchor, in the same order as spawnedOrbs.
private PlayerCharacter playerCharacterThe downed player's character.
private NetworkEntity rotatorObjectThe spawned entity that spins the orb anchors.
private DownedStateSettings settingsDowned state settings: orb count, distances, heights, speeds and time per orb.
private readonly List<EventOrb> spawnedOrbsThe revive orbs spawned for this activity.
private Vector3 spawnPositionCentre of the ring, usually the grave.
private const float TargetProgressProgress needed to finish (1).
private float totalProgressProgress so far, from 0 to 1.

Properties​

1 private and internal property
MemberWhat it is
private float AngleBetweenOrbs { get; }Angle between orbs in the ring: 360 divided by the number of orbs from the settings.

Events​

MemberWhat it is
event Action CompletedRaised when total progress reaches 1.
event Action<float> TimeIncreasedRaised with seconds to add to the revive timer each time progress is added.

Methods​

MemberWhat it is
void AddProgress(float progress)Adds progress while the activity runs, adds time to the revive timer, and raises Completed once progress reaches 1.
void Cancel()Stops counting progress. Spawned orbs stay.
void DestroyReviveActivityObjects()Server: destroys the spawned orbs and the rotator.
void MakeOrbReachableForDownedPlayer(ReviveOrb orb)Moves an orb's anchor in to the downed-player distance and snaps the orb there. Called when an orb is put in a beacon.
void Restart()Resets, then spawns a new ring and starts again.
bool TryConsumeOrb(uint orbId)Records an orb id as consumed. False if it was already used, so each orb counts once.
8 private and internal methods
MemberWhat it is
private Vector3[] CalculateAllOrbPositions(float orbDistanceFromCentre)Local positions for every orb, evenly spaced on a circle of the given radius.
private Vector3 CalculateOrbPosition(int orbIndex, float distanceFromCentre)Local position of one orb on the circle by index.
private void CreateRotatorAndOrbs()Spawns the rotating object above the spawn position and one revive orb per anchor around it.
private void IncreaseTimeForActivity()Raises TimeIncreased with the seconds the settings add per orb.
private void Reset()Clears progress and destroys the activity objects.
private void SafeDestroyReviveOrbs()Reparents each live orb to the player's chunk and destroys it after a delay.
private void SpawnReviveOrb(Transform spawnTransform)Spawns a revive orb in the chunk at the player's feet, links it to this activity and sets it to follow an anchor.
private async void StartActivity()Spawns the rotator and orbs and marks the activity as in progress.

Used in​

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