summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/SecurityCameraSystemType.cs
blob: f7a90ce47af31554360f732eb30330e5f6c7adbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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<byte> PlayersUsing = new HashSet<byte>();

	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();
	}
}