diff options
Diffstat (limited to 'Client/Assembly-CSharp/MedScanSystem.cs')
-rw-r--r-- | Client/Assembly-CSharp/MedScanSystem.cs | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/MedScanSystem.cs b/Client/Assembly-CSharp/MedScanSystem.cs new file mode 100644 index 0000000..8a5f672 --- /dev/null +++ b/Client/Assembly-CSharp/MedScanSystem.cs @@ -0,0 +1,81 @@ +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<byte> UsersList = new List<byte>(); + + 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()); + } + } +} |