Skip to main content

BuildingAnimationWrapper

A class in Root.Township, the global namespace.

Swaps an original object for a final object, playing a BuildingAnimation spawned from a prefab in between. The spawned animation is created on load and removed before the chunk is saved.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private BuildingAnimation animationPrefabBuildingAnimation prefab to spawn.
private GameObject finalObjectObject shown once the animation finishes.
private static Logger loggerNLog logger for this class.
private GameObject originalObjectObject shown before the animation finishes.
private BuildingAnimation spawnedThe spawned animation instance.

Properties​

MemberWhat it is
Func<AnimationPart, float, bool, IEnumerator, IEnumerator> PreInsertAnimation { get; set; }Passes through to the spawned animation's PreInsertAnimation, spawning it first.

Methods​

MemberWhat it is
void Play()Spawns the animation if needed and plays it, switching to the final object when it finishes.
void SetFinal(bool isFinal)Shows the final object and hides the original, or the reverse.
void SetIsSkippingAnimation(bool isSkipping)Spawns the animation if needed and sets whether it skips to the end.
void Stop()Stops the spawned animation.
7 private and internal methods
MemberWhat it is
private void Awake()Starts with the original object shown and the final one hidden.
private void IChangeWithChunking.BeforeSaving()Destroys the spawned animation object so it isn't saved with the chunk.
private void EnsureNoOcluderChildren(Transform checking)Editor validation hook on the final object. Empty in this build.
private void IChangeWithChunking.Loaded()Spawns the animation when the chunk loads, if a prefab is set.
private void OnValidate()Runs EnsureNoOcluderChildren on the final object.
private void PlayInstant()Switches to the final object. Called when the animation finishes.
private void SpawnIfNeeded()Instantiates the animation prefab under this object if it isn't there yet.

Used in​

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