Skip to main content

PlayerSpecialEffectsController

A class in Root.Township, the global namespace.

Visual effects on a player character: teleport and streaming trails, combat wave, shell effects for combat, stat effects and spirit mode, the death animation and level up effects. A component on the player character; most of it does nothing on headless servers.

Constructors​

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

Fields​

MemberWhat it is
float ContrastColour contrast pushed to post processing during the death animation (local player).
float EmbersProgressDeath animation progress of the ash material.
float HeatWaveProgressDeath animation progress of the second shell burst.
bool IsDisablingShadowsDeath animation flag: turn off the body's shadows.
bool IsIncreasingFogDeath animation flag: apply the dead atmosphere fog.
bool IsUsingDeathVisualDeath animation flag: spawn the death particles.
bool IsUsingPreVisualDeath animation flag: spawn the pre-death particles.
float ShellBreakProgressDeath animation progress of the first shell burst.
float TemperatureColour temperature pushed to post processing during the death animation (local player).
float TintColour tint pushed to post processing during the death animation (local player).
43 private and internal fields
MemberWhat it is
private static readonly int _ColorShader property ID for _Color.
private static readonly int _MainTexShader property ID for _MainTex.
private static readonly int _ProgressShader property ID for _Progress, used by the wave, shell and ashes materials.
private TeleporterTrailLerper activeStreamingTrailThe pooled trail shown while the player is streaming, or null.
private TeleporterTrailLerper activeTeleportTrailThe pooled trail currently left by a teleport, or null.
private float baseDissolveStrengthUnused field.
private Texture2D baseRamp1Unused field.
private Texture2D baseRamp2Unused field.
private Material combatShellMaterialSampleMaterial the combat shell animator copies for its shell.
private CharacterComponentController[] controllersToDisableOnDeathCharacter controllers that SetActiveStateForOnDeathControllers turns on or off.
private AtmosphereSet deadAtmosphereSetAtmosphere set loaded by IncreaseFog for the local player when dying.
private DeathAnimationSettings deathAnimationSettingsAshes material, burst shell settings and pre-death and death visuals used by the death animation.
private Animation deathAnimatorLegacy Animation played at the start of the death animation; it animates the public progress fields.
private DockVisual[] destroyOnDeathDock visuals cleared when the death animation starts.
private static readonly int DieAnimator hash for a Die parameter. Not used in this class.
private TransformEvent EffectOnLevelUpSerialized event meant for level-up. Not used in this class.
private DurationCurve enterSpiritModeCurveCurve used by PlayEnterSpiritModeEffect.
private DurationCurve exitSpiritModeCurveCurve used by PlayExitSpiritModeEffect.
private bool hasRolledInFogSet once the death animation has called IncreaseFog, so it only happens once.
private bool hasUsedPreVisualSet once the pre-death visual has spawned during the death animation.
private bool hasUsedVisualSet once the death visual has spawned during the death animation.
private bool isInitializedSet by CheckInitialize so the shell animators are only initialized once.
private PooledObjectDefinition levelUpPooledEffectPooled effect meant for level-up. Not used in this class.
private static Logger loggerNLog logger for this class.
private Dictionary<Renderer, Material> materialMapRemembers each main renderer's original material when the death animation swaps it for ashes.
private float minimumDistanceForTrailShortest move, in metres, for which EditorTrail spawns a teleport trail.
private Transform particlesOriginTransform the pre-death and death visuals spawn at and attach to.
private PlayerCharacter playerCharacterThe player character this controller belongs to.
private IPostProcessController postProcessControllerInjected post-processing controller the death animation drives for the local player.
private PooledObjectDefinition randomParticlesPooled particles spawned by PlayRandomCustomizationPartsParticles.
private Material shellMaterialUnused field; the death animation uses a local copy from the combat shell animator.
private Coroutine spiritModeAnimationCoroutineSpirit-mode coroutine to stop before playing a new one. Never assigned in this class.
private Material spiritModeShellMaterialSampleMaterial the spirit-mode shell animator copies for its shell.
private float statBarPingDurationHow long, in seconds, PingStatBars shows the stat bars.
private StatBarVisibilityGroup[] statBarsStat bar groups shown by PingStatBars.
private Material statEffectShellMaterialSampleMaterial the stat-effect shell animator copies for its shell.
private PooledObjectDefinition streamingLocomotionTrailPooled trail definition used while the player is streaming.
private EffectPlayStatus streamingTrailPlayStatusPlay status given to new streaming trails; visuals are disabled for the local player.
private PooledObjectDefinition teleporterTrailPooled trail definition left behind when a player teleports.
private Dictionary<Material, Material> uniqueMaterialsUnused field; the death animation keeps its own local map of original to ashes materials.
private DurationCurve waveCurveCurve and duration for the combat wave animation.
private Material waveMaterialPer-instance copy of the wave renderer's material, made on the first wave.
private MeshRenderer waveRendererMesh renderer for the combat wave effect; hidden except while AnimateWave runs.

Properties​

MemberWhat it is
CombatShellAnimator CombatShellAnimator { get; private set; }Shell effect used in combat; also the shell used by the death animation.
SpiritModeShellAnimator SpiritModeShellAnimator { get; private set; }Shell effect for spirit mode.
StatEffectShellAnimator StatEffectShellAnimator { get; private set; }Shell effect for stat effects.
1 private and internal property
MemberWhat it is
private int IBuildRendererBakeable.SortingOrder { get; }Bake order for the build step; always 0.

Methods​

MemberWhat it is
void AnimateWave()Plays the combat wave effect around the player.
void CheckInitialize(SkinnedMeshRenderer[] opaqueClothes, SkinnedMeshRenderer[] headOpaqueClothes)Sets up the three shell animators with the character's clothes once.
void EditorTrail(float distance)Starts or refreshes a teleport trail if the move was longer than the minimum trail distance.
void IncreaseFog()For the local player, applies the dead atmosphere set.
void PingStatBars()Briefly shows the player's stat bars.
void PlayEnterSpiritModeEffect()Plays the shell effect for entering spirit mode.
void PlayExitSpiritModeEffect()Plays the shell effect for leaving spirit mode.
void PlayRandomCustomizationPartsParticles(Transform target)Spawns the customization particles at a transform.
void RemoteTrail(Vector3 from, bool isUsingTrail)Starts, refreshes or ends the teleport trail from a position.
void SetActiveStateForOnDeathControllers(bool isActive)Turns on or off the character controllers listed to stop on death.
static void SetMaterial(Material original, Material newMaterial)Copies colour and main texture from one material to another, using a plain colour texture if there is none.
AltaCoroutine StartDeathAnimation()Starts the death animation: body turns to ash, shell bursts and, for the local player, colour grading changes.
void StreamingTrail(bool isEnabled)Does nothing in this build.
protected void Inject(IPostProcessController postProcessController)Receives the post process controller through dependency injection.
11 private and internal methods
MemberWhat it is
private IEnumerator AnimateWaveCoroutine() (iterator)Coroutine behind AnimateWave: shows the wave renderer and drives its _Progress along waveCurve, then hides it.
private void Awake()Client only: builds the combat, stat-effect and spirit-mode shell animators and hooks trail cleanup to the entity's destruction.
private void IBuildRendererBakeable.Bake(bool isSaving)Build step: disables the wave renderer so it starts hidden.
private void IBuildRendererBakeable.Clean()Build step counterpart to Bake; does nothing.
private void CleanTrail(NetworkEntity entity, bool isUnload)Releases the active teleport trail when the player entity is destroyed by the scene.
private void DeactivateTrail(PooledObject oldTrail)Called when a teleport trail goes back to its pool; clears activeTeleportTrail if it was that trail.
private IEnumerator DeathAnimation() (iterator)Coroutine behind StartDeathAnimation: swaps body materials for ashes, plays the death visuals and fog, and drives the shell and post-processing from the animated progress fields.
private void OnDestroy()Client only: tears down the three shell animators.
private void RespositionTrail(PlayerController player, Vector3 oldPosition, Vector3 newPosition, LocomotionFunction function)Handles locomotion position changes: moves the streaming trail, and on teleport locomotion also spawns a teleport trail from the old position.
private void SetStreamingTrail(bool isEnabled)Spawns or releases the streaming locomotion trail when the player starts or stops streaming.
private void Start()Client only: subscribes to the locomotion controller's streaming changes and sets the streaming trail to match. The local player's trail visuals are disabled.

Used in​

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