From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Client/Assembly-CSharp/SkinLayer.cs | 101 ++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Client/Assembly-CSharp/SkinLayer.cs (limited to 'Client/Assembly-CSharp/SkinLayer.cs') diff --git a/Client/Assembly-CSharp/SkinLayer.cs b/Client/Assembly-CSharp/SkinLayer.cs new file mode 100644 index 0000000..80f0cf6 --- /dev/null +++ b/Client/Assembly-CSharp/SkinLayer.cs @@ -0,0 +1,101 @@ +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(); + } +} -- cgit v1.1-26-g67d0