using System; using UnityEngine; public class ReactorMinigame : Minigame { private Color bad = new Color(1f, 0.16078432f, 0f); private Color good = new Color(0.3019608f, 0.8862745f, 0.8352941f); private ReactorSystemType reactor; public TextRenderer statusText; public SpriteRenderer hand; private FloatRange YSweep = new FloatRange(-2.15f, 1.56f); public SpriteRenderer sweeper; public AudioClip HandSound; private bool isButtonDown; public override void Begin(PlayerTask task) { ShipStatus instance = ShipStatus.Instance; if (!instance) { this.reactor = new ReactorSystemType(); } else { this.reactor = (instance.Systems[SystemTypes.Reactor] as ReactorSystemType); } this.hand.color = this.bad; } public void ButtonDown() { if (PlayerControl.LocalPlayer.Data.IsImpostor) { return; } if (!this.reactor.IsActive) { return; } this.isButtonDown = !this.isButtonDown; if (this.isButtonDown) { if (Constants.ShouldPlaySfx()) { SoundManager.Instance.PlaySound(this.HandSound, true, 1f); } ShipStatus.Instance.RpcRepairSystem(SystemTypes.Reactor, (int)((byte)(64 | base.ConsoleId))); } else { SoundManager.Instance.StopSound(this.HandSound); ShipStatus.Instance.RpcRepairSystem(SystemTypes.Reactor, (int)((byte)(32 | base.ConsoleId))); } try { ((SabotageTask)this.MyTask).MarkContributed(); } catch { } } public void FixedUpdate() { if (!this.reactor.IsActive) { if (this.amClosing == Minigame.CloseState.None) { this.hand.color = this.good; this.statusText.Text = "Reactor Nominal"; this.sweeper.enabled = false; SoundManager.Instance.StopSound(this.HandSound); base.StartCoroutine(base.CoStartClose(0.75f)); return; } } else { if (!this.isButtonDown) { this.statusText.Text = "Hold to stop meltdown"; this.sweeper.enabled = false; return; } this.statusText.Text = "Waiting for second user"; Vector3 localPosition = this.sweeper.transform.localPosition; localPosition.y = this.YSweep.Lerp(Mathf.Sin(Time.time) * 0.5f + 0.5f); this.sweeper.transform.localPosition = localPosition; this.sweeper.enabled = true; } } public override void Close() { SoundManager.Instance.StopSound(this.HandSound); if (ShipStatus.Instance) { ShipStatus.Instance.RpcRepairSystem(SystemTypes.Reactor, (int)((byte)(32 | base.ConsoleId))); } base.Close(); } }