diff options
Diffstat (limited to 'Client/Assembly-CSharp/SkinLayer.cs')
-rw-r--r-- | Client/Assembly-CSharp/SkinLayer.cs | 101 |
1 files changed, 101 insertions, 0 deletions
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<HatManager>.Instance.GetSkinById(skinId); + this.SetIdle(); + } +} |