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 CompletedConsoles = new HashSet(); 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.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.Instance.OxyFlash != null) { DestroyableSingleton.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()); } } } }