diff options
Diffstat (limited to 'Client/Assembly-CSharp/DoorsSystemType.cs')
-rw-r--r-- | Client/Assembly-CSharp/DoorsSystemType.cs | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/DoorsSystemType.cs b/Client/Assembly-CSharp/DoorsSystemType.cs new file mode 100644 index 0000000..e642713 --- /dev/null +++ b/Client/Assembly-CSharp/DoorsSystemType.cs @@ -0,0 +1,119 @@ +using System; +using System.Linq; +using Hazel; + +//c 管理场景中的门,同步门的开启状态 +public class DoorsSystemType : ISystemType, IActivatable +{ + public bool IsActive + { + get + { + return this.doors.Any((AutoOpenDoor b) => !b.Open); + } + } + + private AutoOpenDoor[] doors; // 场景所有的门 + + private uint dirtyBits; + + public void SetDoors(AutoOpenDoor[] doors) + { + this.doors = doors; + } + + public bool Detoriorate(float deltaTime) + { + if (this.doors == null) + { + return false; + } + for (int i = 0; i < this.doors.Length; i++) + { + if (this.doors[i].DoUpdate(deltaTime)) + { + this.dirtyBits |= 1U << i; + } + } + return this.dirtyBits > 0U; + } + + public void RepairDamage(PlayerControl player, byte amount) + { + } + + //c 同步场景中所有门的开启状态 + + public void Serialize(MessageWriter writer, bool initialState) + { + if (initialState) + { + for (int i = 0; i < this.doors.Length; i++) + { + this.doors[i].Serialize(writer); + } + return; + } + writer.WritePacked(this.dirtyBits); + for (int j = 0; j < this.doors.Length; j++) + { + if ((this.dirtyBits & 1U << j) != 0U) + { + this.doors[j].Serialize(writer); + } + } + this.dirtyBits = 0U; + } + + public void Deserialize(MessageReader reader, bool initialState) + { + if (initialState) + { + for (int i = 0; i < this.doors.Length; i++) + { + this.doors[i].Deserialize(reader); + } + return; + } + uint num = reader.ReadPackedUInt32(); + for (int j = 0; j < this.doors.Length; j++) + { + if ((num & 1U << j) != 0U) + { + this.doors[j].Deserialize(reader); + } + } + } + + public void SetDoor(AutoOpenDoor door, bool open) + { + door.SetDoorway(open); + this.dirtyBits |= 1U << this.doors.IndexOf(door); + } + + public void CloseDoorsOfType(SystemTypes room) + { + for (int i = 0; i < this.doors.Length; i++) + { + AutoOpenDoor autoOpenDoor = this.doors[i]; + if (autoOpenDoor.Room == room) + { + autoOpenDoor.SetDoorway(false); + this.dirtyBits |= 1U << i; + } + } + } + + public float GetTimer(SystemTypes room) + { + for (int i = 0; i < this.doors.Length; i++) + { + AutoOpenDoor autoOpenDoor = this.doors[i]; + if (autoOpenDoor.Room == room) + { + return autoOpenDoor.CooldownTimer; + } + } + return 0f; + } +} |