summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/ReactorSystemType.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/ReactorSystemType.cs')
-rw-r--r--Client/Assembly-CSharp/ReactorSystemType.cs137
1 files changed, 137 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/ReactorSystemType.cs b/Client/Assembly-CSharp/ReactorSystemType.cs
new file mode 100644
index 0000000..a1e1fa0
--- /dev/null
+++ b/Client/Assembly-CSharp/ReactorSystemType.cs
@@ -0,0 +1,137 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Hazel;
+
+public class ReactorSystemType : ISystemType, IActivatable
+{
+ public int UserCount
+ {
+ get
+ {
+ int num = 0;
+ int num2 = 0;
+ foreach (Tuple<byte, byte> tuple in this.UserConsolePairs)
+ {
+ int num3 = 1 << (int)tuple.Item2;
+ if ((num3 & num2) == 0)
+ {
+ num++;
+ num2 |= num3;
+ }
+ }
+ return num;
+ }
+ }
+
+ 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 RemoveUserOp = 32;
+
+ public const byte ClearCountdown = 16;
+
+ public const float CountdownStopped = 10000f;
+
+ public const float ReactorDuration = 30f;
+
+ public const byte ConsoleIdMask = 3;
+
+ public const byte RequiredUserCount = 2;
+
+ public float Countdown = 10000f;
+
+ private HashSet<Tuple<byte, byte>> UserConsolePairs = new HashSet<Tuple<byte, byte>>();
+
+ public bool GetConsoleComplete(int consoleId)
+ {
+ return this.UserConsolePairs.Any((Tuple<byte, byte> kvp) => (int)kvp.Item2 == consoleId);
+ }
+
+ public void RepairDamage(PlayerControl player, byte opCode)
+ {
+ int num = (int)(opCode & 3);
+ if (opCode == 128 && !this.IsActive)
+ {
+ this.Countdown = 30f;
+ this.UserConsolePairs.Clear();
+ return;
+ }
+ if (opCode == 16)
+ {
+ this.Countdown = 10000f;
+ return;
+ }
+ if (opCode.HasAnyBit(64))
+ {
+ this.UserConsolePairs.Add(new Tuple<byte, byte>(player.PlayerId, (byte)num));
+ if (this.UserCount >= 2)
+ {
+ this.Countdown = 10000f;
+ return;
+ }
+ }
+ else if (opCode.HasAnyBit(32))
+ {
+ this.UserConsolePairs.Remove(new Tuple<byte, byte>(player.PlayerId, (byte)num));
+ }
+ }
+
+ public bool Detoriorate(float deltaTime)
+ {
+ if (this.IsActive)
+ {
+ if (DestroyableSingleton<HudManager>.Instance.ReactorFlash == null)
+ {
+ PlayerControl.LocalPlayer.AddSystemTask(SystemTypes.Reactor);
+ }
+ this.Countdown -= deltaTime;
+ this.timer += deltaTime;
+ if (this.timer > 2f)
+ {
+ this.timer = 0f;
+ return true;
+ }
+ }
+ else if (DestroyableSingleton<HudManager>.Instance.ReactorFlash != null)
+ {
+ ((ReactorShipRoom)ShipStatus.Instance.AllRooms.First((ShipRoom r) => r.RoomId == SystemTypes.Reactor)).StopMeltdown();
+ }
+ return false;
+ }
+
+ public void Serialize(MessageWriter writer, bool initialState)
+ {
+ writer.Write(this.Countdown);
+ writer.WritePacked(this.UserConsolePairs.Count);
+ foreach (Tuple<byte, byte> tuple in this.UserConsolePairs)
+ {
+ writer.Write(tuple.Item1);
+ writer.Write(tuple.Item2);
+ }
+ }
+
+ public void Deserialize(MessageReader reader, bool initialState)
+ {
+ this.Countdown = reader.ReadSingle();
+ this.UserConsolePairs.Clear();
+ int num = reader.ReadPackedInt32();
+ for (int i = 0; i < num; i++)
+ {
+ this.UserConsolePairs.Add(new Tuple<byte, byte>(reader.ReadByte(), reader.ReadByte()));
+ }
+ }
+}