summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/UseButtonManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/UseButtonManager.cs')
-rw-r--r--Client/Assembly-CSharp/UseButtonManager.cs108
1 files changed, 108 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/UseButtonManager.cs b/Client/Assembly-CSharp/UseButtonManager.cs
new file mode 100644
index 0000000..c6a7f65
--- /dev/null
+++ b/Client/Assembly-CSharp/UseButtonManager.cs
@@ -0,0 +1,108 @@
+using System;
+using UnityEngine;
+
+public class UseButtonManager : MonoBehaviour
+{
+ private static readonly Color DisabledColor = new Color(1f, 1f, 1f, 0.3f);
+
+ private static readonly Color EnabledColor = new Color(1f, 1f, 1f, 1f);
+
+ public SpriteRenderer UseButton;
+
+ public Sprite UseImage;
+
+ public Sprite SabotageImage;
+
+ public Sprite VentImage;
+
+ public Sprite AdminMapImage;
+
+ public Sprite SecurityImage;
+
+ public Sprite OptionsImage;
+
+ private IUsable currentTarget;
+
+ public void SetTarget(IUsable target)
+ {
+ this.currentTarget = target;
+ if (target != null)
+ {
+ if (target is Vent)
+ {
+ this.UseButton.sprite = this.VentImage;
+ }
+ else if (target is MapConsole)
+ {
+ this.UseButton.sprite = this.AdminMapImage;
+ }
+ else if (target is OptionsConsole)
+ {
+ this.UseButton.sprite = this.OptionsImage;
+ }
+ else if (target is SystemConsole)
+ {
+ SystemConsole systemConsole = (SystemConsole)target;
+ if (systemConsole.name.StartsWith("Surv"))
+ {
+ this.UseButton.sprite = this.SecurityImage;
+ }
+ else if (systemConsole.name.StartsWith("TaskAdd"))
+ {
+ this.UseButton.sprite = this.OptionsImage;
+ }
+ else
+ {
+ this.UseButton.sprite = this.UseImage;
+ }
+ }
+ else
+ {
+ this.UseButton.sprite = this.UseImage;
+ }
+ this.UseButton.SetCooldownNormalizedUvs();
+ this.UseButton.material.SetFloat("_Percent", target.PercentCool);
+ this.UseButton.color = UseButtonManager.EnabledColor;
+ return;
+ }
+ if (PlayerControl.LocalPlayer.Data.IsImpostor && PlayerControl.LocalPlayer.CanMove)
+ {
+ this.UseButton.sprite = this.SabotageImage;
+ this.UseButton.SetCooldownNormalizedUvs();
+ this.UseButton.color = UseButtonManager.EnabledColor;
+ return;
+ }
+ this.UseButton.sprite = this.UseImage;
+ this.UseButton.color = UseButtonManager.DisabledColor;
+ }
+
+ public void DoClick()
+ {
+ if (!base.isActiveAndEnabled)
+ {
+ return;
+ }
+ if (!PlayerControl.LocalPlayer)
+ {
+ return;
+ }
+ GameData.PlayerInfo data = PlayerControl.LocalPlayer.Data;
+ if (this.currentTarget != null)
+ {
+ PlayerControl.LocalPlayer.UseClosest();
+ return;
+ }
+ if (data != null && data.IsImpostor)
+ {
+ DestroyableSingleton<HudManager>.Instance.ShowMap(delegate(MapBehaviour m)
+ {
+ m.ShowInfectedMap();
+ });
+ }
+ }
+
+ internal void Refresh()
+ {
+ this.SetTarget(this.currentTarget);
+ }
+}