blob: 2e77cfc94fc0d70bc379d0dcf5674d61a3984d17 (
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
|
using System;
using System.Collections.Generic;
using Hazel;
public class LifeSuppSystemType : ISystemType, IActivatable
{
public int UserCount
{
get
{
return this.CompletedConsoles.Count;
}
}
public bool IsActive
{
get
{
return this.Countdown < 10000f;
}
}
private const float SyncRate = 2f;
private float timer;
public const byte StartCountdown = 128;
public const byte AddUserOp = 64;
public const byte ClearCountdown = 16;
public const float CountdownStopped = 10000f;
public const float LifeSuppDuration = 45f;
public const byte ConsoleIdMask = 3;
public const byte RequiredUserCount = 2;
public float Countdown = 10000f;
private HashSet<int> CompletedConsoles = new HashSet<int>();
public bool GetConsoleComplete(int consoleId)
{
return this.CompletedConsoles.Contains(consoleId);
}
public void RepairDamage(PlayerControl player, byte opCode)
{
int item = (int)(opCode & 3);
if (opCode == 128 && !this.IsActive)
{
this.Countdown = 45f;
this.CompletedConsoles.Clear();
return;
}
if (opCode == 16)
{
this.Countdown = 10000f;
return;
}
if (opCode.HasAnyBit(64))
{
this.CompletedConsoles.Add(item);
}
}
public bool Detoriorate(float deltaTime)
{
if (this.IsActive)
{
if (DestroyableSingleton<HudManager>.Instance.OxyFlash == null)
{
PlayerControl.LocalPlayer.AddSystemTask(SystemTypes.LifeSupp);
}
this.Countdown -= deltaTime;
if (this.UserCount >= 2)
{
this.Countdown = 10000f;
return true;
}
this.timer += deltaTime;
if (this.timer > 2f)
{
this.timer = 0f;
return true;
}
}
else if (DestroyableSingleton<HudManager>.Instance.OxyFlash != null)
{
DestroyableSingleton<HudManager>.Instance.StopOxyFlash();
}
return false;
}
public void Serialize(MessageWriter writer, bool initialState)
{
writer.Write(this.Countdown);
writer.WritePacked(this.CompletedConsoles.Count);
foreach (int value in this.CompletedConsoles)
{
writer.WritePacked(value);
}
}
public void Deserialize(MessageReader reader, bool initialState)
{
this.Countdown = reader.ReadSingle();
if (reader.Position < reader.Length)
{
this.CompletedConsoles.Clear();
int num = reader.ReadPackedInt32();
for (int i = 0; i < num; i++)
{
this.CompletedConsoles.Add(reader.ReadPackedInt32());
}
}
}
}
|