summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/PlayerTask.cs
blob: ddccafefb25de67b3d4db84ac6af74c183e18352 (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;

public abstract class PlayerTask : MonoBehaviour
{
	public int Index { get; internal set; }

	public uint Id { get; internal set; }

	public PlayerControl Owner { get; internal set; }

	public abstract int TaskStep { get; }

	public abstract bool IsComplete { get; }

	public Vector2 Location
	{
		get
		{
			this.LocationDirty = false;
			return this.FindObjectPos().transform.position;
		}
	}

	public SystemTypes StartAt;

	public TaskTypes TaskType;

	public Minigame MinigamePrefab;

	public bool HasLocation;

	public bool LocationDirty = true;

	public abstract void Initialize();

	public virtual void OnRemove()
	{
	}

	public abstract bool ValidConsole(global::Console console);

	public abstract void Complete();

	public abstract void AppendTaskText(StringBuilder sb);

	internal static bool TaskIsEmergency(PlayerTask arg)
	{
		return arg is NoOxyTask || arg is HudOverrideTask || arg is ReactorTask || arg is ElectricTask;
	}

	protected List<global::Console> FindConsoles()
	{
		List<global::Console> list = new List<global::Console>();
		global::Console[] allConsoles = ShipStatus.Instance.AllConsoles;
		for (int i = 0; i < allConsoles.Length; i++)
		{
			if (this.ValidConsole(allConsoles[i]))
			{
				list.Add(allConsoles[i]);
			}
		}
		return list;
	}

	public static bool PlayerHasHudTask(PlayerControl localPlayer)
	{
		if (!localPlayer)
		{
			return true;
		}
		for (int i = 0; i < localPlayer.myTasks.Count; i++)
		{
			if (localPlayer.myTasks[i] is HudOverrideTask)
			{
				return true;
			}
		}
		return false;
	}

	protected List<Vector2> FindObjectsPos()
	{
		List<Vector2> list = new List<Vector2>();
		global::Console[] allConsoles = ShipStatus.Instance.AllConsoles;
		for (int i = 0; i < allConsoles.Length; i++)
		{
			if (this.ValidConsole(allConsoles[i]))
			{
				list.Add(allConsoles[i].transform.position);
			}
		}
		return list;
	}

	protected global::Console FindSpecialConsole(Func<global::Console, bool> func)
	{
		global::Console[] allConsoles = ShipStatus.Instance.AllConsoles;
		for (int i = 0; i < allConsoles.Length; i++)
		{
			if (func(allConsoles[i]))
			{
				return allConsoles[i];
			}
		}
		return null;
	}

	protected global::Console FindObjectPos()
	{
		global::Console[] allConsoles = ShipStatus.Instance.AllConsoles;
		for (int i = 0; i < allConsoles.Length; i++)
		{
			if (this.ValidConsole(allConsoles[i]))
			{
				return allConsoles[i];
			}
		}
		Debug.LogError("Couldn't find location for task: " + base.name);
		return null;
	}

	protected static bool AllTasksCompleted(PlayerControl player)
	{
		for (int i = 0; i < player.myTasks.Count; i++)
		{
			PlayerTask playerTask = player.myTasks[i];
			if (playerTask is NormalPlayerTask && !playerTask.IsComplete)
			{
				return false;
			}
		}
		return true;
	}
}