]> git.deb.at Git - rhonda/impostor.git/commitdiff
Implement HeliSabotageSystemType
authorminiduikboot <5243971+miniduikboot@users.noreply.github.com>
Fri, 2 Apr 2021 20:42:15 +0000 (22:42 +0200)
committerminiduikboot <5243971+miniduikboot@users.noreply.github.com>
Fri, 2 Apr 2021 22:29:05 +0000 (00:29 +0200)
It works, although I'm not completely sure why.

src/Impostor.Server/Net/Inner/Objects/InnerShipStatus.cs
src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/HeliSabotageSystemType.cs [new file with mode: 0644]

index d51c0b8d23918f6e69f8f103a5379695266a62fc..575a64ac26f468e52836ec7f220d8c0931d87742 100644 (file)
@@ -29,7 +29,7 @@ namespace Impostor.Server.Net.Inner.Objects
             {
                 [SystemTypes.Electrical] = new SwitchSystem(),
                 [SystemTypes.MedBay] = new MedScanSystem(),
-                [SystemTypes.Reactor] = new ReactorSystemType(),
+                [SystemTypes.Reactor] = game.Options.Map == MapTypes.Airship ? new HeliSabotageSystemType() : new ReactorSystemType(),
                 [SystemTypes.LifeSupp] = new LifeSuppSystemType(),
                 [SystemTypes.Security] = new SecurityCameraSystemType(),
                 [SystemTypes.Comms] = new HudOverrideSystemType(),
diff --git a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/HeliSabotageSystemType.cs b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/HeliSabotageSystemType.cs
new file mode 100644 (file)
index 0000000..f29c4b8
--- /dev/null
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using Impostor.Api.Net.Messages;
+using Microsoft.Extensions.Logging;
+
+namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus
+{
+    public class HeliSabotageSystemType : ISystemType, IActivatable
+    {
+        public HeliSabotageSystemType()
+        {
+            Countdown = 10000f;
+            ActiveConsoles = new HashSet<Tuple<byte, byte>>();
+            CompletedConsoles = new HashSet<byte>();
+        }
+
+        public float Countdown { get; private set; }
+
+        public float Timer { get; private set; }
+
+        public HashSet<Tuple<byte, byte>> ActiveConsoles { get; }
+
+        public HashSet<byte> CompletedConsoles { get; }
+
+        public bool IsActive => Countdown < 10000.0;
+
+        public void Serialize(IMessageWriter writer, bool initialState)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void Deserialize(IMessageReader reader, bool initialState)
+        {
+            // TODO: Find out what these 2 bytes are used for
+            _ = reader.ReadByte();
+            _ = reader.ReadByte();
+            Countdown = reader.ReadSingle();
+            Timer = reader.ReadSingle();
+            ActiveConsoles.Clear(); // TODO: Thread safety
+            CompletedConsoles.Clear(); // TODO: Thread safety
+
+            var count = reader.ReadPackedUInt32();
+
+            for (var i = 0; i < count; i++)
+            {
+                ActiveConsoles.Add(new Tuple<byte, byte>(reader.ReadByte(), reader.ReadByte()));
+            }
+
+            var count2 = reader.ReadPackedUInt32();
+
+            for (var i = 0; i < count2; i++)
+            {
+                CompletedConsoles.Add(reader.ReadByte());
+            }
+        }
+    }
+}