using System; using System.Collections.Generic; using Hazel; using UnityEngine; public class MedScanSystem : ISystemType { public byte CurrentUser { get; private set; } = byte.MaxValue; public const byte Request = 128; public const byte Release = 64; public const byte NumMask = 31; public const byte NoPlayer = 255; public List UsersList = new List(); public bool Detoriorate(float deltaTime) { if (this.UsersList.Count > 0) { if (this.CurrentUser != this.UsersList[0]) { if (this.CurrentUser != 255) { Debug.Log("Released scanner from: " + this.CurrentUser); } this.CurrentUser = this.UsersList[0]; Debug.Log("Acquired scanner for: " + this.CurrentUser); return true; } } else if (this.CurrentUser != 255) { Debug.Log("Released scanner from: " + this.CurrentUser); this.CurrentUser = byte.MaxValue; return true; } return false; } public void RepairDamage(PlayerControl player, byte data) { byte playerId = data & 31; if ((data & 128) != 0) { if (!this.UsersList.Contains(playerId)) { Debug.Log("Added to queue: " + playerId); this.UsersList.Add(playerId); return; } } else if ((data & 64) != 0) { Debug.Log("Removed from queue: " + playerId); this.UsersList.RemoveAll((byte v) => v == playerId); } } public void Serialize(MessageWriter writer, bool initialState) { writer.WritePacked(this.UsersList.Count); for (int i = 0; i < this.UsersList.Count; i++) { writer.Write(this.UsersList[i]); } } public void Deserialize(MessageReader reader, bool initialState) { this.UsersList.Clear(); int num = reader.ReadPackedInt32(); for (int i = 0; i < num; i++) { this.UsersList.Add(reader.ReadByte()); } } }