summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/NoOxyTask.cs
blob: 47f9e88d76af878a6c2fdd6ffacd642a263e89c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Linq;
using System.Text;
using UnityEngine;

public class NoOxyTask : SabotageTask
{
	public override int TaskStep
	{
		get
		{
			return this.reactor.UserCount;
		}
	}

	public override bool IsComplete
	{
		get
		{
			return this.isComplete;
		}
	}

	private bool isComplete;

	private LifeSuppSystemType reactor;

	private bool even;

	public int targetNumber;

	public override void Initialize()
	{
		this.targetNumber = IntRange.Next(0, 99999);
		ShipStatus instance = ShipStatus.Instance;
		this.reactor = (LifeSuppSystemType)instance.Systems[SystemTypes.LifeSupp];
		DestroyableSingleton<HudManager>.Instance.StartOxyFlash();
		base.SetupArrows();
	}

	private void FixedUpdate()
	{
		if (this.isComplete)
		{
			return;
		}
		if (!this.reactor.IsActive)
		{
			this.Complete();
			return;
		}
		for (int i = 0; i < this.Arrows.Length; i++)
		{
			this.Arrows[i].gameObject.SetActive(!this.reactor.GetConsoleComplete(i));
		}
	}

	public override bool ValidConsole(global::Console console)
	{
		return !this.reactor.GetConsoleComplete(console.ConsoleId) && console.TaskTypes.Contains(TaskTypes.RestoreOxy);
	}

	public override void OnRemove()
	{
	}

	public override void Complete()
	{
		this.isComplete = true;
		PlayerControl.LocalPlayer.RemoveTask(this);
		if (this.didContribute)
		{
			StatsManager instance = StatsManager.Instance;
			uint sabsFixed = instance.SabsFixed;
			instance.SabsFixed = sabsFixed + 1U;
		}
	}

	public override void AppendTaskText(StringBuilder sb)
	{
		this.even = !this.even;
		Color color = this.even ? Color.yellow : Color.red;
		if (this.reactor != null)
		{
			sb.Append(color.ToTextColor());
			sb.Append(DestroyableSingleton<TranslationController>.Instance.GetString(TaskTypes.RestoreOxy));
			sb.Append(" ");
			sb.Append(Mathf.CeilToInt(this.reactor.Countdown));
			sb.AppendLine(string.Format(" ({0}/{1})[]", this.reactor.UserCount, 2));
		}
		else
		{
			sb.AppendLine(color.ToTextColor() + "Oxygen depleting[]");
		}
		for (int i = 0; i < this.Arrows.Length; i++)
		{
			try
			{
				this.Arrows[i].image.color = color;
			}
			catch
			{
			}
		}
	}
}