summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/LifeSuppSystemType.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/LifeSuppSystemType.cs')
-rw-r--r--Client/Assembly-CSharp/LifeSuppSystemType.cs121
1 files changed, 121 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/LifeSuppSystemType.cs b/Client/Assembly-CSharp/LifeSuppSystemType.cs
new file mode 100644
index 0000000..2e77cfc
--- /dev/null
+++ b/Client/Assembly-CSharp/LifeSuppSystemType.cs
@@ -0,0 +1,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());
+ }
+ }
+ }
+}