blob: bd5133af08db24c1d3fdb214223c60eed13717c5 (
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
public class NormalPlayerTask : PlayerTask
{
public override int TaskStep
{
get
{
return this.taskStep;
}
}
public override bool IsComplete
{
get
{
return this.taskStep >= this.MaxStep;
}
}
public int taskStep;
public int MaxStep;
public bool ShowTaskStep = true;
public bool ShowTaskTimer;
public NormalPlayerTask.TimerState TimerStarted;
public float TaskTimer;
public byte[] Data;
public ArrowBehaviour Arrow;
public enum TimerState
{
NotStarted,
Started,
Finished
}
public override void Initialize()
{
if (this.Arrow && !base.Owner.AmOwner)
{
this.Arrow.gameObject.SetActive(false);
}
this.HasLocation = true;
this.LocationDirty = true;
TaskTypes taskType = this.TaskType;
switch (taskType)
{
case TaskTypes.PrimeShields:
{
this.Data = new byte[1];
int num = 0;
for (int i = 0; i < 7; i++)
{
byte b = (byte)(1 << i);
if (BoolRange.Next(0.7f))
{
byte[] data = this.Data;
int num2 = 0;
data[num2] |= b;
num++;
}
}
byte[] data2 = this.Data;
int num3 = 0;
data2[num3] &= 118;
return;
}
case TaskTypes.FuelEngines:
this.Data = new byte[2];
return;
case TaskTypes.ChartCourse:
this.Data = new byte[4];
return;
case TaskTypes.StartReactor:
this.Data = new byte[6];
return;
case TaskTypes.SwipeCard:
case TaskTypes.ClearAsteroids:
case TaskTypes.UploadData:
case TaskTypes.EmptyChute:
case TaskTypes.EmptyGarbage:
break;
case TaskTypes.InspectSample:
this.Data = new byte[2];
return;
case TaskTypes.AlignEngineOutput:
this.Data = new byte[2];
this.Data[0] = AlignGame.ToByte((float)IntRange.RandomSign() * FloatRange.Next(1f, 3f));
this.Data[1] = (byte)(IntRange.RandomSign() * IntRange.Next(25, 255));
return;
case TaskTypes.FixWiring:
{
this.Data = new byte[this.MaxStep];
List<global::Console> list = (from t in ShipStatus.Instance.AllConsoles
where t.TaskTypes.Contains(TaskTypes.FixWiring)
select t).ToList<global::Console>();
List<global::Console> list2 = new List<global::Console>(list);
for (int j = 0; j < this.Data.Length; j++)
{
int index = list2.RandomIdx<global::Console>();
this.Data[j] = (byte)list2[index].ConsoleId;
list2.RemoveAt(index);
}
Array.Sort<byte>(this.Data);
global::Console console = list.First((global::Console v) => v.ConsoleId == (int)this.Data[0]);
this.StartAt = console.Room;
break;
}
default:
if (taskType == TaskTypes.EnterIdCode)
{
this.Data = BitConverter.GetBytes(IntRange.Next(1, 99999));
return;
}
break;
}
}
public void NextStep()
{
this.taskStep++;
this.UpdateArrow();
if (this.taskStep >= this.MaxStep)
{
this.taskStep = this.MaxStep;
if (PlayerControl.LocalPlayer)
{
if (DestroyableSingleton<HudManager>.InstanceExists)
{
DestroyableSingleton<HudManager>.Instance.ShowTaskComplete();
StatsManager instance = StatsManager.Instance;
uint num = instance.TasksCompleted;
instance.TasksCompleted = num + 1U;
if (PlayerTask.AllTasksCompleted(PlayerControl.LocalPlayer))
{
StatsManager instance2 = StatsManager.Instance;
num = instance2.CompletedAllTasks;
instance2.CompletedAllTasks = num + 1U;
}
}
PlayerControl.LocalPlayer.RpcCompleteTask(base.Id);
return;
}
}
else if (this.ShowTaskStep && Constants.ShouldPlaySfx())
{
SoundManager.Instance.PlaySound(DestroyableSingleton<HudManager>.Instance.TaskUpdateSound, false, 1f);
}
}
public void UpdateArrow()
{
if (!this.Arrow)
{
return;
}
if (!base.Owner.AmOwner)
{
this.Arrow.gameObject.SetActive(false);
return;
}
if (!this.IsComplete)
{
this.Arrow.gameObject.SetActive(true);
if (this.TaskType == TaskTypes.FixWiring)
{
global::Console console3 = base.FindSpecialConsole((global::Console c) => c.TaskTypes.Contains(TaskTypes.FixWiring) && c.ConsoleId == (int)this.Data[this.taskStep]);
this.Arrow.target = console3.transform.position;
this.StartAt = console3.Room;
}
else if (this.TaskType == TaskTypes.AlignEngineOutput)
{
if (AlignGame.IsSuccess(this.Data[0]))
{
this.Arrow.target = base.FindSpecialConsole((global::Console c) => c.TaskTypes.Contains(TaskTypes.AlignEngineOutput) && c.ConsoleId == 1).transform.position;
this.StartAt = SystemTypes.UpperEngine;
}
else
{
this.Arrow.target = base.FindSpecialConsole((global::Console console) => console.TaskTypes.Contains(TaskTypes.AlignEngineOutput) && console.ConsoleId == 0).transform.position;
this.StartAt = SystemTypes.LowerEngine;
}
}
else
{
global::Console console2 = base.FindObjectPos();
this.Arrow.target = console2.transform.position;
this.StartAt = console2.Room;
}
this.LocationDirty = true;
return;
}
this.Arrow.gameObject.SetActive(false);
}
private void FixedUpdate()
{
if (this.TimerStarted == NormalPlayerTask.TimerState.Started)
{
this.TaskTimer -= Time.fixedDeltaTime;
if (this.TaskTimer <= 0f)
{
this.TaskTimer = 0f;
this.TimerStarted = NormalPlayerTask.TimerState.Finished;
}
}
}
public override bool ValidConsole(global::Console console)
{
if (this.TaskType == TaskTypes.FixWiring)
{
return console.TaskTypes.Contains(this.TaskType) && console.ConsoleId == (int)this.Data[this.taskStep];
}
if (this.TaskType == TaskTypes.AlignEngineOutput)
{
return console.TaskTypes.Contains(this.TaskType) && !AlignGame.IsSuccess(this.Data[console.ConsoleId]);
}
if (this.TaskType == TaskTypes.FuelEngines)
{
return (console.TaskTypes.Contains(this.TaskType) && console.ConsoleId == (int)this.Data[1]) || console.ValidTasks.Any((TaskSet set) => this.TaskType == set.taskType && set.taskStep.Contains((int)this.Data[1]));
}
return console.TaskTypes.Any((TaskTypes tt) => tt == this.TaskType) || console.ValidTasks.Any((TaskSet set) => this.TaskType == set.taskType && set.taskStep.Contains(this.taskStep));
}
public override void Complete()
{
this.taskStep = this.MaxStep;
}
public override void AppendTaskText(StringBuilder sb)
{
bool flag = this.ShouldYellowText();
if (flag)
{
if (this.IsComplete)
{
sb.Append("[00DD00FF]");
}
else
{
sb.Append("[FFFF00FF]");
}
}
sb.Append(DestroyableSingleton<TranslationController>.Instance.GetString(this.StartAt));
sb.Append(": ");
sb.Append(DestroyableSingleton<TranslationController>.Instance.GetString(this.TaskType));
if (this.ShowTaskTimer && this.TimerStarted == NormalPlayerTask.TimerState.Started)
{
sb.Append(" (");
sb.Append((int)this.TaskTimer);
sb.Append("s)");
}
else if (this.ShowTaskStep)
{
sb.Append(" (");
sb.Append(this.taskStep);
sb.Append("/");
sb.Append(this.MaxStep);
sb.Append(")");
}
if (flag)
{
sb.Append("[]");
}
sb.AppendLine();
}
private bool ShouldYellowText()
{
return (this.TaskType == TaskTypes.FuelEngines && this.Data[1] > 0) || this.taskStep > 0 || this.TimerStarted > NormalPlayerTask.TimerState.NotStarted;
}
}
|