using System; using System.Collections.Generic; using Hazel; //监控器 public class SecurityCameraSystemType : ISystemType { public bool InUse { get { return this.PlayersUsing.Count > 0; } } public const byte IncrementOp = 1; public const byte DecrementOp = 2; private HashSet PlayersUsing = new HashSet(); public bool Detoriorate(float deltaTime) { return false; } public void RepairDamage(PlayerControl player, byte amount) { if (amount == 1) { this.PlayersUsing.Add(player.PlayerId); } else { this.PlayersUsing.Remove(player.PlayerId); } this.UpdateCameras(); } private void UpdateCameras() { for (int i = 0; i < ShipStatus.Instance.AllRooms.Length; i++) { ShipRoom shipRoom = ShipStatus.Instance.AllRooms[i]; if (shipRoom.survCamera) { if (this.InUse) { shipRoom.survCamera.Image.Play(shipRoom.survCamera.OnAnim, 1f); } else { shipRoom.survCamera.Image.Play(shipRoom.survCamera.OffAnim, 1f); } } } } public void Serialize(MessageWriter writer, bool initialState) { writer.WritePacked(this.PlayersUsing.Count); foreach (byte value in this.PlayersUsing) { writer.Write(value); } } public void Deserialize(MessageReader reader, bool initialState) { this.PlayersUsing.Clear(); int num = reader.ReadPackedInt32(); for (int i = 0; i < num; i++) { this.PlayersUsing.Add(reader.ReadByte()); } this.UpdateCameras(); } }