Skip to main content

OrbBasinVfxController

A class in Root.Township, Features.Gameplay.

Plays the particle trail from a climbing tower orb basin to a player: orb obtained, permanent unlock or tower completion. The server picks which and tells clients in the chunk, who play it.

Constructors​

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

Fields​

9 private and internal fields
MemberWhat it is
private AddUnlockToPlayer addUnlockToPlayerThe basin's AddUnlockToPlayer, whose unlock decides the permanent unlock effect.
private VfxData orbObtainedVfxDataEffect played when a player in spirit mode gets an orb. Saved.
private Transform particleOriginWhere the particles start.
private VfxData permanentUnlockVfxDataEffect played when a player gets the permanent unlock. Saved.
private PlayerUnlockStation playerUnlockStationThe unlock station this basin belongs to.
private MethodSyncStruct<int> syncOrbBasinParticlesMethod sync that plays an effect for a player.
private MethodSync syncSetupMethod sync for the VFX data references.
private IPlayer targetPlayerThe player the current effect is for.
private VfxData towerCompletionVfxDataEffect played at a completion station. Saved.

Methods​

MemberWhat it is
override void Initialize()Creates the setup sync on VfxData and the play sync on EnchantmentEffect.
void Load(OrbBasinVfxControllerSaveData data, ISerializeChildren childSerializer)Restores the three VFX data references from save data.
override void OnConnected(Player player)Server: sends the VFX data references to the joining player.
OrbBasinVfxControllerSaveData Save(ISerializeChildren childSerializer)Saves the three VFX data references.
void TryPlayParticlesForPlayer(IPlayer player)Server: sets the target player and plays whichever effects apply. Usually called from the scene.
15 private and internal methods
MemberWhat it is
private bool CanPlayBasinParticles()False on a headless server; in a local test, true when there is a target player; true on clients.
private bool CanPlayParticlesForPermanentUnlock()True if the player is in spirit mode and does not have the basin's unlock yet.
private bool CanPlayParticlesForTowerCompletion()True if the unlock station is a completion station.
private VfxData GetVfxData(OrbBasinVfxController.ParticleType type)Returns the VFX data for an orb obtained, permanent unlock or tower completion effect.
private bool HasValidReferences(IPlayer player)True if the player and their unlock manager exist and the unlock station is set.
private bool IsStartUnlockStation()True if the unlock station is a start station.
private bool IsTargetPlayerInSpiritMode()True if the target player has a current unlock.
private bool IsValid(VfxData vfxData)True if the references are valid and the VFX data exists and is set to play.
private void PlayParticle(VfxData vfxData)Client: spawns the pooled particles at particleOrigin and sends them flying to the target player.
private void PlayParticlesForOrbBasin()Server: tells chunks to play the orb obtained effect.
private void PlayParticlesForPermanentUnlock()Server: tells chunks to play the permanent unlock effect.
private void PlayParticlesForTowerCompletion()Server: tells chunks to play the tower completion effect.
private void SyncOrbBasinParticles(IPlayer player, Stream stream, int particleTypeAsInt)Sends the target player and effect type; the receiver looks up the player and plays the effect.
private void SyncSetup(IPlayer player, Stream stream)Server to client: sends the three VFX data references. Logged as unauthorized if a client sends it.
private void TryPlayParticles()Picks which effects fit the target player and station, and sends them.