using System; using PowerTools; using UnityEngine; public class SkinLayer : MonoBehaviour { public bool Flipped { set { this.layer.flipX = value; } } public bool Visible { set { this.layer.enabled = value; } } public SpriteRenderer layer; public SpriteAnim animator; public SkinData skin; public void SetRun() { if (!this.skin || !this.animator) { this.SetGhost(); return; } if (!this.animator.IsPlaying(this.skin.RunAnim)) { this.animator.Play(this.skin.RunAnim, 1f); } } public void SetSpawn(float time = 0f) { if (!this.skin || !this.animator) { this.SetGhost(); return; } this.animator.Play(this.skin.SpawnAnim, 1f); this.animator.Time = time; } public void SetExitVent() { if (!this.skin || !this.animator) { this.SetGhost(); return; } this.animator.Play(this.skin.ExitVentAnim, 1f); } public void SetEnterVent() { if (!this.skin || !this.animator) { this.SetGhost(); return; } this.animator.Play(this.skin.EnterVentAnim, 1f); } public void SetIdle() { if (!this.skin || !this.animator) { this.SetGhost(); return; } if (!this.animator.IsPlaying(this.skin.IdleAnim)) { this.animator.Play(this.skin.IdleAnim, 1f); } } public void SetGhost() { if (!this.animator) { return; } this.animator.Stop(); this.layer.sprite = null; } internal void SetSkin(uint skinId) { this.skin = DestroyableSingleton.Instance.GetSkinById(skinId); this.SetIdle(); } }