Skip to main content

PlayerScreenFader

An abstract class in Root.Township, the global namespace.

Fades the local player's view to and from black. Subclasses draw the fade. Lockers can hold the screen black (and the player controller locked) until all are removed.

Constructors​

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

Fields​

MemberWhat it is
protected Action currentCallbackCallback to run when the current fade ends.
protected AltaCoroutine currentFadeThe running fade coroutine.
protected PlayerController playerControllerThe player controller the fade belongs to; fade coroutines run on it.
2 private and internal fields
MemberWhat it is
private HashSet<object> fadeInLockersObjects holding the screen black. The first one blacks it out and locks the player controller.
private IPlayerControllerMultiLockModel playerControllerMultiLockModelInjected lock model used to lock the player while fade lockers exist.

Events​

MemberWhat it is
event Action ScreenFadedEvent declared for when the screen fades; not raised in this class.

Methods​

MemberWhat it is
void AddFadeInLocker(object locker)Adds a lock. The first lock snaps to black and locks the player controller.
void CancelCurrentFade(bool isInvokingCallback)Stops the current fade. Its callback always runs, whatever the flag says.
AltaCoroutine CustomFade(float alphaStart, float alphaEnd, float fadeDuration, Action fadeCallback = null, float startDelay = 0)Cancels any fade, then fades from one alpha to another over a time after an optional delay.
AltaCoroutine FadeBackIn(float fadeInDuration, Action fadeCallback = null, float startDelay = 0)Fades from black to clear.
void FadeInIfNotLocked(float fadeDuration)Fades back in unless a locker is holding it black.
AltaCoroutine FadeToBlack(float fadeOutDuration, Action fadeCallback = null, float startDelay = 0)Fades from clear to black.
void InstantSet(float alpha)Cancels any fade and sets the alpha at once.
void RemoveFadeInLocker(object locker, float fadeDuration)Removes a lock and fades back in if none are left.
AltaCoroutine SetFadedAndFadeBackIn(float fadeInDuration, Action fadeCallback = null, float startDelay = 0)Snaps to black, then fades back in.
protected void Inject(IPlayerControllerMultiLockModel playerControllerMultiLockModel)VContainer injection of the player controller lock model.
protected bool IsFadeLocked()True while any locker is held.
protected abstract IEnumerator LerpFadeScreen(float duration, float alphaStart, float alphaEnd)Subclass: animates the alpha over a duration.
protected abstract void Set(float alpha)Subclass: sets the alpha straight away.
1 private and internal method
MemberWhat it is
private IEnumerator HandleFade(float duration, float alphaStart, float alphaEnd, float delay) (iterator)Coroutine behind CustomFade: waits the delay, fades, runs the callback, and holds the faded-to-black render lock while black.

Used in​

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