From 9d3824b523aa4e725f7f86133a64d0ef83c64a01 Mon Sep 17 00:00:00 2001 From: Hubert Gendron Date: Sat, 24 Jul 2021 01:35:59 -0400 Subject: [PATCH] Merge DysonSphere processors --- .../Universe/DysonSphereAddFrameProcessor.cs | 42 ------------- .../Universe/DysonSphereAddLayerProcessor.cs | 31 ---------- .../Universe/DysonSphereAddNodeProcessor.cs | 54 ----------------- .../Universe/DysonSphereAddShellProcessor.cs | 34 ----------- .../DysonSphereRemoveFrameProcessor.cs | 36 ----------- .../DysonSphereRemoveLayerProcessor.cs | 32 ---------- .../DysonSphereRemoveNodeProcessor.cs | 59 ------------------ .../DysonSphereRemoveShellProcessor.cs | 37 ------------ .../Universe/DysonSwarmAddOrbitProcessor.cs | 33 ---------- .../DysonSwarmRemoveOrbitProcessor.cs | 32 ---------- .../Universe/NameInputProcessor.cs | 40 ------------- .../Universe/DysonSphereAddFrameProcessor.cs | 37 ++++++++++-- .../Universe/DysonSphereAddLayerProcessor.cs | 24 +++++++- .../Universe/DysonSphereAddNodeProcessor.cs | 53 +++++++++++----- .../Universe/DysonSphereAddShellProcessor.cs | 25 +++++++- .../Universe/DysonSphereDataProcessor.cs | 2 + .../DysonSphereRemoveFrameProcessor.cs | 28 +++++++-- .../DysonSphereRemoveLayerProcessor.cs | 26 +++++++- .../DysonSphereRemoveNodeProcessor.cs | 60 ++++++++++++------- .../DysonSphereRemoveShellProcessor.cs | 28 +++++++-- .../Universe/DysonSphereRequestProcessor.cs | 2 + .../Universe/DysonSwarmAddOrbitProcessor.cs | 24 +++++++- .../DysonSwarmRemoveOrbitProcessor.cs | 24 +++++++- .../Universe/NameInputProcessor.cs | 47 ++++++++++----- .../Patches/Dynamic/DysonSphereLayer_Patch.cs | 12 ++-- .../Patches/Dynamic/DysonSphere_Patch.cs | 4 +- .../Patches/Dynamic/DysonSwarm_Patch.cs | 4 +- ...phere_Manager.cs => DysonSphereManager.cs} | 4 +- 28 files changed, 315 insertions(+), 519 deletions(-) delete mode 100644 NebulaHost/PacketProcessors/Universe/DysonSphereAddFrameProcessor.cs delete mode 100644 NebulaHost/PacketProcessors/Universe/DysonSphereAddLayerProcessor.cs delete mode 100644 NebulaHost/PacketProcessors/Universe/DysonSphereAddNodeProcessor.cs delete mode 100644 NebulaHost/PacketProcessors/Universe/DysonSphereAddShellProcessor.cs delete mode 100644 NebulaHost/PacketProcessors/Universe/DysonSphereRemoveFrameProcessor.cs delete mode 100644 NebulaHost/PacketProcessors/Universe/DysonSphereRemoveLayerProcessor.cs delete mode 100644 NebulaHost/PacketProcessors/Universe/DysonSphereRemoveNodeProcessor.cs delete mode 100644 NebulaHost/PacketProcessors/Universe/DysonSphereRemoveShellProcessor.cs delete mode 100644 NebulaHost/PacketProcessors/Universe/DysonSwarmAddOrbitProcessor.cs delete mode 100644 NebulaHost/PacketProcessors/Universe/DysonSwarmRemoveOrbitProcessor.cs delete mode 100644 NebulaHost/PacketProcessors/Universe/NameInputProcessor.cs rename {NebulaHost => NebulaNetwork}/PacketProcessors/Universe/DysonSphereRequestProcessor.cs (95%) rename NebulaWorld/Universe/{DysonSphere_Manager.cs => DysonSphereManager.cs} (92%) diff --git a/NebulaHost/PacketProcessors/Universe/DysonSphereAddFrameProcessor.cs b/NebulaHost/PacketProcessors/Universe/DysonSphereAddFrameProcessor.cs deleted file mode 100644 index c0d789a1e..000000000 --- a/NebulaHost/PacketProcessors/Universe/DysonSphereAddFrameProcessor.cs +++ /dev/null @@ -1,42 +0,0 @@ -using NebulaModel.Attributes; -using NebulaModel.Networking; -using NebulaModel.Packets; -using NebulaModel.Packets.Universe; -using NebulaWorld.Universe; - -namespace NebulaNetwork.PacketProcessors.Universe -{ - [RegisterPacketProcessor] - class DysonSphereAddFrameProcessor : PacketProcessor - { - private PlayerManager playerManager; - - public DysonSphereAddFrameProcessor() - { - playerManager = MultiplayerHostSession.Instance.PlayerManager; - } - - public override void ProcessPacket(DysonSphereAddFramePacket packet, NebulaConnection conn) - { - Player player = playerManager.GetPlayer(conn); - if (player != null) - { - playerManager.SendPacketToOtherPlayers(packet, player); - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) - { - DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); - //Check if target nodes exists (if not, assume that AddNode packet is on the way) - if (DysonSphere_Manager.CanCreateFrame(packet.NodeAId, packet.NodeBId, dsl)) - { - dsl.NewDysonFrame(packet.ProtoId, packet.NodeAId, packet.NodeBId, packet.Euler); - } - else - { - DysonSphere_Manager.QueuedAddFramePackets.Add(packet); - } - } - } - } - } -} - diff --git a/NebulaHost/PacketProcessors/Universe/DysonSphereAddLayerProcessor.cs b/NebulaHost/PacketProcessors/Universe/DysonSphereAddLayerProcessor.cs deleted file mode 100644 index 65d0ede3c..000000000 --- a/NebulaHost/PacketProcessors/Universe/DysonSphereAddLayerProcessor.cs +++ /dev/null @@ -1,31 +0,0 @@ -using NebulaModel.Attributes; -using NebulaModel.DataStructures; -using NebulaModel.Networking; -using NebulaModel.Packets; -using NebulaModel.Packets.Universe; -using NebulaWorld.Universe; - -namespace NebulaNetwork.PacketProcessors.Universe -{ - [RegisterPacketProcessor] - public class DysonSphereAddLayerProcessor : PacketProcessor - { - private PlayerManager playerManager; - - public DysonSphereAddLayerProcessor() - { - playerManager = MultiplayerHostSession.Instance.PlayerManager; - } - - public override void ProcessPacket(DysonSphereAddLayerPacket packet, NebulaConnection conn) - { - Player player = playerManager.GetPlayer(conn); - if (player != null) - { - playerManager.SendPacketToOtherPlayers(packet, player); - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) - GameMain.data.dysonSpheres[packet.StarIndex]?.AddLayer(packet.OrbitRadius, DataStructureExtensions.ToQuaternion(packet.OrbitRotation), packet.OrbitAngularSpeed); - } - } - } -} diff --git a/NebulaHost/PacketProcessors/Universe/DysonSphereAddNodeProcessor.cs b/NebulaHost/PacketProcessors/Universe/DysonSphereAddNodeProcessor.cs deleted file mode 100644 index 7a92df2f3..000000000 --- a/NebulaHost/PacketProcessors/Universe/DysonSphereAddNodeProcessor.cs +++ /dev/null @@ -1,54 +0,0 @@ -using NebulaModel.Attributes; -using NebulaModel.DataStructures; -using NebulaModel.Networking; -using NebulaModel.Packets; -using NebulaModel.Packets.Universe; -using NebulaWorld.Universe; - -namespace NebulaNetwork.PacketProcessors.Universe -{ - [RegisterPacketProcessor] - class DysonSphereAddNodeProcessor : PacketProcessor - { - private PlayerManager playerManager; - - public DysonSphereAddNodeProcessor() - { - playerManager = MultiplayerHostSession.Instance.PlayerManager; - } - - public override void ProcessPacket(DysonSphereAddNodePacket packet, NebulaConnection conn) - { - Player player = playerManager.GetPlayer(conn); - if (player != null) - { - playerManager.SendPacketToOtherPlayers(packet, player); - - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) - { - GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId)?.NewDysonNode(packet.NodeProtoId, DataStructureExtensions.ToVector3(packet.Position)); - DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); - - // DysonSphereLayer is missing, we can't do anything now. - if (dsl == null) - { - NebulaModel.Logger.Log.Warn("Could not add Dyson Sphere Node, DysonSphereLayer is null."); - return; - } - - //Try to add queued Dyson Frames that failed due to the missing nodes - DysonSphereAddFramePacket queuedPacked; - for (int i = DysonSphere_Manager.QueuedAddFramePackets.Count - 1; i >= 0; i--) - { - queuedPacked = DysonSphere_Manager.QueuedAddFramePackets[i]; - if (dsl.nodePool[queuedPacked.NodeAId].id != 0 && dsl.nodePool[queuedPacked.NodeBId].id != 0) - { - dsl.NewDysonFrame(queuedPacked.ProtoId, queuedPacked.NodeAId, queuedPacked.NodeBId, queuedPacked.Euler); - DysonSphere_Manager.QueuedAddFramePackets.RemoveAt(i); - } - } - } - } - } - } -} diff --git a/NebulaHost/PacketProcessors/Universe/DysonSphereAddShellProcessor.cs b/NebulaHost/PacketProcessors/Universe/DysonSphereAddShellProcessor.cs deleted file mode 100644 index c98e06bc1..000000000 --- a/NebulaHost/PacketProcessors/Universe/DysonSphereAddShellProcessor.cs +++ /dev/null @@ -1,34 +0,0 @@ -using NebulaModel.Attributes; -using NebulaModel.Networking; -using NebulaModel.Packets; -using NebulaModel.Packets.Universe; -using NebulaWorld.Universe; -using System.Collections.Generic; - -namespace NebulaNetwork.PacketProcessors.Universe -{ - [RegisterPacketProcessor] - class DysonSphereAddShellProcessor : PacketProcessor - { - private PlayerManager playerManager; - - public DysonSphereAddShellProcessor() - { - playerManager = MultiplayerHostSession.Instance.PlayerManager; - } - - public override void ProcessPacket(DysonSphereAddShellPacket packet, NebulaConnection conn) - { - Player player = playerManager.GetPlayer(conn); - if (player != null) - { - playerManager.SendPacketToOtherPlayers(packet, player); - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) - { - GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId)?.NewDysonShell(packet.ProtoId, new List(packet.NodeIds)); - } - } - } - } -} - diff --git a/NebulaHost/PacketProcessors/Universe/DysonSphereRemoveFrameProcessor.cs b/NebulaHost/PacketProcessors/Universe/DysonSphereRemoveFrameProcessor.cs deleted file mode 100644 index 96b1a3f45..000000000 --- a/NebulaHost/PacketProcessors/Universe/DysonSphereRemoveFrameProcessor.cs +++ /dev/null @@ -1,36 +0,0 @@ -using NebulaModel.Attributes; -using NebulaModel.Networking; -using NebulaModel.Packets; -using NebulaModel.Packets.Universe; -using NebulaWorld.Universe; - -namespace NebulaNetwork.PacketProcessors.Universe -{ - [RegisterPacketProcessor] - class DysonSphereRemoveFrameProcessor : PacketProcessor - { - private PlayerManager playerManager; - - public DysonSphereRemoveFrameProcessor() - { - playerManager = MultiplayerHostSession.Instance.PlayerManager; - } - - public override void ProcessPacket(DysonSphereRemoveFramePacket packet, NebulaConnection conn) - { - Player player = playerManager.GetPlayer(conn); - if (player != null) - { - playerManager.SendPacketToOtherPlayers(packet, player); - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) - { - DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); - if (DysonSphere_Manager.CanRemoveFrame(packet.FrameId, dsl)) - { - dsl.RemoveDysonFrame(packet.FrameId); - } - } - } - } - } -} diff --git a/NebulaHost/PacketProcessors/Universe/DysonSphereRemoveLayerProcessor.cs b/NebulaHost/PacketProcessors/Universe/DysonSphereRemoveLayerProcessor.cs deleted file mode 100644 index 69b1d8a04..000000000 --- a/NebulaHost/PacketProcessors/Universe/DysonSphereRemoveLayerProcessor.cs +++ /dev/null @@ -1,32 +0,0 @@ -using NebulaModel.Attributes; -using NebulaModel.Networking; -using NebulaModel.Packets; -using NebulaModel.Packets.Universe; -using NebulaWorld.Universe; - -namespace NebulaNetwork.PacketProcessors.Universe -{ - [RegisterPacketProcessor] - class DysonSphereRemoveLayerProcessor : PacketProcessor - { - private PlayerManager playerManager; - - public DysonSphereRemoveLayerProcessor() - { - playerManager = MultiplayerHostSession.Instance.PlayerManager; - } - - public override void ProcessPacket(DysonSphereRemoveLayerPacket packet, NebulaConnection conn) - { - Player player = playerManager.GetPlayer(conn); - if (player != null) - { - playerManager.SendPacketToOtherPlayers(packet, player); - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) - { - GameMain.data.dysonSpheres[packet.StarIndex]?.RemoveLayer(packet.LayerId); - } - } - } - } -} diff --git a/NebulaHost/PacketProcessors/Universe/DysonSphereRemoveNodeProcessor.cs b/NebulaHost/PacketProcessors/Universe/DysonSphereRemoveNodeProcessor.cs deleted file mode 100644 index cf0ea4e19..000000000 --- a/NebulaHost/PacketProcessors/Universe/DysonSphereRemoveNodeProcessor.cs +++ /dev/null @@ -1,59 +0,0 @@ -using NebulaModel.Attributes; -using NebulaModel.Networking; -using NebulaModel.Packets; -using NebulaModel.Packets.Universe; -using NebulaWorld.Universe; - -namespace NebulaNetwork.PacketProcessors.Universe -{ - [RegisterPacketProcessor] - class DysonSphereRemoveNodeProcessor : PacketProcessor - { - private PlayerManager playerManager; - - public DysonSphereRemoveNodeProcessor() - { - playerManager = MultiplayerHostSession.Instance.PlayerManager; - } - - public override void ProcessPacket(DysonSphereRemoveNodePacket packet, NebulaConnection conn) - { - Player player = playerManager.GetPlayer(conn); - if (player != null) - { - playerManager.SendPacketToOtherPlayers(packet, player); - - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) - { - DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); - if (dsl != null) - { - int num = 0; - DysonNode dysonNode = dsl.nodePool[packet.NodeId]; - //Remove all frames that are part of the node - while (dysonNode.frames.Count > 0) - { - dsl.RemoveDysonFrame(dysonNode.frames[0].id); - if (num++ > 4096) - { - Assert.CannotBeReached(); - break; - } - } - //Remove all shells that are part of the node - while (dysonNode.shells.Count > 0) - { - dsl.RemoveDysonShell(dysonNode.shells[0].id); - if (num++ > 4096) - { - Assert.CannotBeReached(); - break; - } - } - dsl.RemoveDysonNode(packet.NodeId); - } - } - } - } - } -} diff --git a/NebulaHost/PacketProcessors/Universe/DysonSphereRemoveShellProcessor.cs b/NebulaHost/PacketProcessors/Universe/DysonSphereRemoveShellProcessor.cs deleted file mode 100644 index c2897460d..000000000 --- a/NebulaHost/PacketProcessors/Universe/DysonSphereRemoveShellProcessor.cs +++ /dev/null @@ -1,37 +0,0 @@ -using NebulaModel.Attributes; -using NebulaModel.Networking; -using NebulaModel.Packets; -using NebulaModel.Packets.Universe; -using NebulaWorld.Universe; - -namespace NebulaNetwork.PacketProcessors.Universe -{ - [RegisterPacketProcessor] - class DysonSphereRemoveShellProcessor : PacketProcessor - { - private PlayerManager playerManager; - - public DysonSphereRemoveShellProcessor() - { - playerManager = MultiplayerHostSession.Instance.PlayerManager; - } - - public override void ProcessPacket(DysonSphereRemoveShellPacket packet, NebulaConnection conn) - { - Player player = playerManager.GetPlayer(conn); - if (player != null) - { - playerManager.SendPacketToOtherPlayers(packet, player); - - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) - { - DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); - if (DysonSphere_Manager.CanRemoveShell(packet.ShellId, dsl)) - { - dsl.RemoveDysonShell(packet.ShellId); - } - } - } - } - } -} diff --git a/NebulaHost/PacketProcessors/Universe/DysonSwarmAddOrbitProcessor.cs b/NebulaHost/PacketProcessors/Universe/DysonSwarmAddOrbitProcessor.cs deleted file mode 100644 index 0de810fd1..000000000 --- a/NebulaHost/PacketProcessors/Universe/DysonSwarmAddOrbitProcessor.cs +++ /dev/null @@ -1,33 +0,0 @@ -using NebulaModel.Attributes; -using NebulaModel.DataStructures; -using NebulaModel.Networking; -using NebulaModel.Packets; -using NebulaModel.Packets.Universe; -using NebulaWorld.Universe; - -namespace NebulaNetwork.PacketProcessors.Universe -{ - [RegisterPacketProcessor] - class DysonSwarmAddOrbitProcessor : PacketProcessor - { - private PlayerManager playerManager; - - public DysonSwarmAddOrbitProcessor() - { - playerManager = MultiplayerHostSession.Instance.PlayerManager; - } - - public override void ProcessPacket(DysonSwarmAddOrbitPacket packet, NebulaConnection conn) - { - Player player = playerManager.GetPlayer(conn); - if (player != null) - { - playerManager.SendPacketToOtherPlayers(packet, player); - using (DysonSphere_Manager.IncomingDysonSwarmPacket.On()) - { - GameMain.data.dysonSpheres[packet.StarIndex]?.swarm?.NewOrbit(packet.Radius, DataStructureExtensions.ToQuaternion(packet.Rotation)); - } - } - } - } -} diff --git a/NebulaHost/PacketProcessors/Universe/DysonSwarmRemoveOrbitProcessor.cs b/NebulaHost/PacketProcessors/Universe/DysonSwarmRemoveOrbitProcessor.cs deleted file mode 100644 index 5fb2efea1..000000000 --- a/NebulaHost/PacketProcessors/Universe/DysonSwarmRemoveOrbitProcessor.cs +++ /dev/null @@ -1,32 +0,0 @@ -using NebulaModel.Attributes; -using NebulaModel.Networking; -using NebulaModel.Packets; -using NebulaModel.Packets.Universe; -using NebulaWorld.Universe; - -namespace NebulaNetwork.PacketProcessors.Universe -{ - [RegisterPacketProcessor] - class DysonSwarmRemoveOrbitProcessor : PacketProcessor - { - private PlayerManager playerManager; - - public DysonSwarmRemoveOrbitProcessor() - { - playerManager = MultiplayerHostSession.Instance.PlayerManager; - } - - public override void ProcessPacket(DysonSwarmRemoveOrbitPacket packet, NebulaConnection conn) - { - Player player = playerManager.GetPlayer(conn); - if (player != null) - { - playerManager.SendPacketToOtherPlayers(packet, player); - using (DysonSphere_Manager.IncomingDysonSwarmPacket.On()) - { - GameMain.data.dysonSpheres[packet.StarIndex]?.swarm?.RemoveOrbit(packet.OrbitId); - } - } - } - } -} diff --git a/NebulaHost/PacketProcessors/Universe/NameInputProcessor.cs b/NebulaHost/PacketProcessors/Universe/NameInputProcessor.cs deleted file mode 100644 index dafa60852..000000000 --- a/NebulaHost/PacketProcessors/Universe/NameInputProcessor.cs +++ /dev/null @@ -1,40 +0,0 @@ -using NebulaModel.Attributes; -using NebulaModel.Networking; -using NebulaModel.Packets; -using NebulaModel.Packets.Universe; -using NebulaWorld; -using NebulaWorld.Factory; - -namespace NebulaNetwork.PacketProcessors.Universe -{ - /* - * Receives change event for name of planet or star and applies the change - */ - [RegisterPacketProcessor] - class NameInputProcessor : PacketProcessor - { - public override void ProcessPacket(NameInputPacket packet, NebulaConnection conn) - { - using (FactoryManager.IsIncomingRequest.On()) - { - // If stellarId > 100 then it must be a planet - if (packet.StellarId > 100) - { - var planet = GameMain.galaxy.PlanetById(packet.StellarId); - planet.overrideName = packet.Name; - planet.NotifyOnDisplayNameChange(); - } - else - { - var star = GameMain.galaxy.StarById(packet.StellarId); - star.overrideName = packet.Name; - star.NotifyOnDisplayNameChange(); - } - GameMain.galaxy.NotifyAstroNameChange(); - - // Relay packet to other players - LocalPlayer.SendPacket(packet); - } - } - } -} diff --git a/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddFrameProcessor.cs b/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddFrameProcessor.cs index 3ebeedacd..e4fcec8c2 100644 --- a/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddFrameProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddFrameProcessor.cs @@ -9,19 +9,44 @@ namespace NebulaNetwork.PacketProcessors.Universe [RegisterPacketProcessor] class DysonSphereAddFrameProcessor : PacketProcessor { + private PlayerManager playerManager; + + public DysonSphereAddFrameProcessor() + { + playerManager = MultiplayerHostSession.Instance?.PlayerManager; + } + public override void ProcessPacket(DysonSphereAddFramePacket packet, NebulaConnection conn) { - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) + bool valid = true; + + if (IsHost) { - DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); - //Check if target nodes exists (if not, assume that AddNode packet is on the way) - if (DysonSphere_Manager.CanCreateFrame(packet.NodeAId, packet.NodeBId, dsl)) + Player player = playerManager.GetPlayer(conn); + if (player != null) { - dsl.NewDysonFrame(packet.ProtoId, packet.NodeAId, packet.NodeBId, packet.Euler); + playerManager.SendPacketToOtherPlayers(packet, player); } else { - DysonSphere_Manager.QueuedAddFramePackets.Add(packet); + valid = false; + } + } + + if (valid) + { + using (DysonSphereManager.IsIncomingRequest.On()) + { + DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); + //Check if target nodes exists (if not, assume that AddNode packet is on the way) + if (DysonSphereManager.CanCreateFrame(packet.NodeAId, packet.NodeBId, dsl)) + { + dsl.NewDysonFrame(packet.ProtoId, packet.NodeAId, packet.NodeBId, packet.Euler); + } + else + { + DysonSphereManager.QueuedAddFramePackets.Add(packet); + } } } } diff --git a/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddLayerProcessor.cs b/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddLayerProcessor.cs index aebf6e1c9..5b17098d9 100644 --- a/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddLayerProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddLayerProcessor.cs @@ -10,13 +10,31 @@ namespace NebulaNetwork.PacketProcessors.Universe [RegisterPacketProcessor] public class DysonSphereAddLayerProcessor : PacketProcessor { - public static bool IncomingPacket = false; + private PlayerManager playerManager; + + public DysonSphereAddLayerProcessor() + { + playerManager = MultiplayerHostSession.Instance?.PlayerManager; + } public override void ProcessPacket(DysonSphereAddLayerPacket packet, NebulaConnection conn) { - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) + bool valid = true; + if (IsHost) + { + Player player = playerManager.GetPlayer(conn); + if (player != null) + playerManager.SendPacketToOtherPlayers(packet, player); + else + valid = false; + } + + if (valid) { - GameMain.data.dysonSpheres[packet.StarIndex]?.AddLayer(packet.OrbitRadius, DataStructureExtensions.ToQuaternion(packet.OrbitRotation), packet.OrbitAngularSpeed); + using (DysonSphereManager.IsIncomingRequest.On()) + { + GameMain.data.dysonSpheres[packet.StarIndex]?.AddLayer(packet.OrbitRadius, DataStructureExtensions.ToQuaternion(packet.OrbitRotation), packet.OrbitAngularSpeed); + } } } } diff --git a/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddNodeProcessor.cs b/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddNodeProcessor.cs index ed9bdda35..a74ad0048 100644 --- a/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddNodeProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddNodeProcessor.cs @@ -10,29 +10,50 @@ namespace NebulaNetwork.PacketProcessors.Universe [RegisterPacketProcessor] class DysonSphereAddNodeProcessor : PacketProcessor { + private PlayerManager playerManager; + + public DysonSphereAddNodeProcessor() + { + playerManager = MultiplayerHostSession.Instance?.PlayerManager; + } + public override void ProcessPacket(DysonSphereAddNodePacket packet, NebulaConnection conn) { - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) + bool valid = true; + if (IsHost) { - int? addedID = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId)?.NewDysonNode(packet.NodeProtoId, DataStructureExtensions.ToVector3(packet.Position)); - //Try to add frames that failed due to the missing nodes - DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); + Player player = playerManager.GetPlayer(conn); + if (player != null) + playerManager.SendPacketToOtherPlayers(packet, player); + else + valid = false; + } - // DysonSphereLayer is missing, we can't do anything now. - if(dsl == null) + if (valid) + { + using (DysonSphereManager.IsIncomingRequest.On()) { - NebulaModel.Logger.Log.Warn("Could not add Dyson Sphere Node, DysonSphereLayer is null."); - return; - } + GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId)?.NewDysonNode(packet.NodeProtoId, DataStructureExtensions.ToVector3(packet.Position)); + // Try to add frames that failed due to the missing nodes + DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); - DysonSphereAddFramePacket queuedPacked; - for (int i = DysonSphere_Manager.QueuedAddFramePackets.Count - 1; i >= 0; i--) - { - queuedPacked = DysonSphere_Manager.QueuedAddFramePackets[i]; - if (dsl.nodePool[queuedPacked.NodeAId].id != 0 && dsl.nodePool[queuedPacked.NodeBId].id != 0) + // DysonSphereLayer is missing, we can't do anything now. + if(dsl == null) + { + NebulaModel.Logger.Log.Warn("Could not add Dyson Sphere Node, DysonSphereLayer is null."); + return; + } + + // Try to add queued Dyson Frames that failed due to the missing nodes + DysonSphereAddFramePacket queuedPacked; + for (int i = DysonSphereManager.QueuedAddFramePackets.Count - 1; i >= 0; i--) { - dsl.NewDysonFrame(queuedPacked.ProtoId, queuedPacked.NodeAId, queuedPacked.NodeBId, queuedPacked.Euler); - DysonSphere_Manager.QueuedAddFramePackets.RemoveAt(i); + queuedPacked = DysonSphereManager.QueuedAddFramePackets[i]; + if (dsl.nodePool[queuedPacked.NodeAId].id != 0 && dsl.nodePool[queuedPacked.NodeBId].id != 0) + { + dsl.NewDysonFrame(queuedPacked.ProtoId, queuedPacked.NodeAId, queuedPacked.NodeBId, queuedPacked.Euler); + DysonSphereManager.QueuedAddFramePackets.RemoveAt(i); + } } } } diff --git a/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddShellProcessor.cs b/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddShellProcessor.cs index 4ae8546b5..54d224ff8 100644 --- a/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddShellProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Universe/DysonSphereAddShellProcessor.cs @@ -10,11 +10,32 @@ namespace NebulaNetwork.PacketProcessors.Universe [RegisterPacketProcessor] class DysonSphereAddShellProcessor : PacketProcessor { + private PlayerManager playerManager; + + public DysonSphereAddShellProcessor() + { + playerManager = MultiplayerHostSession.Instance?.PlayerManager; + } public override void ProcessPacket(DysonSphereAddShellPacket packet, NebulaConnection conn) { - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) - GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId)?.NewDysonShell(packet.ProtoId, new List(packet.NodeIds)); + bool valid = true; + if (IsHost) + { + Player player = playerManager.GetPlayer(conn); + if (player != null) + playerManager.SendPacketToOtherPlayers(packet, player); + else + valid = false; + } + + if (valid) + { + using (DysonSphereManager.IsIncomingRequest.On()) + { + GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId)?.NewDysonShell(packet.ProtoId, new List(packet.NodeIds)); + } + } } } } diff --git a/NebulaNetwork/PacketProcessors/Universe/DysonSphereDataProcessor.cs b/NebulaNetwork/PacketProcessors/Universe/DysonSphereDataProcessor.cs index d036b9893..8d35f922a 100644 --- a/NebulaNetwork/PacketProcessors/Universe/DysonSphereDataProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Universe/DysonSphereDataProcessor.cs @@ -10,6 +10,8 @@ class DysonSphereDataProcessor : PacketProcessor { public override void ProcessPacket(DysonSphereData packet, NebulaConnection conn) { + if (IsHost) return; + //Failsafe, if client does not have instantiated sphere for the star, it will create dummy one that will be replaced during import if (GameMain.data.dysonSpheres[packet.StarIndex] == null) { diff --git a/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveFrameProcessor.cs b/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveFrameProcessor.cs index 78f455479..347f6a4f7 100644 --- a/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveFrameProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveFrameProcessor.cs @@ -9,14 +9,34 @@ namespace NebulaNetwork.PacketProcessors.Universe [RegisterPacketProcessor] class DysonSphereRemoveFrameProcessor : PacketProcessor { + private PlayerManager playerManager; + + public DysonSphereRemoveFrameProcessor() + { + playerManager = MultiplayerHostSession.Instance?.PlayerManager; + } + public override void ProcessPacket(DysonSphereRemoveFramePacket packet, NebulaConnection conn) { - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) + bool valid = true; + if (IsHost) + { + Player player = playerManager.GetPlayer(conn); + if (player != null) + playerManager.SendPacketToOtherPlayers(packet, player); + else + valid = false; + } + + if (valid) { - DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); - if (DysonSphere_Manager.CanRemoveFrame(packet.FrameId, dsl)) + using (DysonSphereManager.IsIncomingRequest.On()) { - dsl.RemoveDysonFrame(packet.FrameId); + DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); + if (DysonSphereManager.CanRemoveFrame(packet.FrameId, dsl)) + { + dsl.RemoveDysonFrame(packet.FrameId); + } } } } diff --git a/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveLayerProcessor.cs b/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveLayerProcessor.cs index 2179599c0..46dd27768 100644 --- a/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveLayerProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveLayerProcessor.cs @@ -9,10 +9,32 @@ namespace NebulaNetwork.PacketProcessors.Universe [RegisterPacketProcessor] class DysonSphereRemoveLayerProcessor : PacketProcessor { + private PlayerManager playerManager; + + public DysonSphereRemoveLayerProcessor() + { + playerManager = MultiplayerHostSession.Instance?.PlayerManager; + } + public override void ProcessPacket(DysonSphereRemoveLayerPacket packet, NebulaConnection conn) { - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) - GameMain.data.dysonSpheres[packet.StarIndex]?.RemoveLayer(packet.LayerId); + bool valid = true; + if (IsHost) + { + Player player = playerManager.GetPlayer(conn); + if (player != null) + playerManager.SendPacketToOtherPlayers(packet, player); + else + valid = false; + } + + if (valid) + { + using (DysonSphereManager.IsIncomingRequest.On()) + { + GameMain.data.dysonSpheres[packet.StarIndex]?.RemoveLayer(packet.LayerId); + } + } } } } diff --git a/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveNodeProcessor.cs b/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveNodeProcessor.cs index dd7a57f7f..493aabd5b 100644 --- a/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveNodeProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveNodeProcessor.cs @@ -9,36 +9,56 @@ namespace NebulaNetwork.PacketProcessors.Universe [RegisterPacketProcessor] class DysonSphereRemoveNodeProcessor : PacketProcessor { + private PlayerManager playerManager; + + public DysonSphereRemoveNodeProcessor() + { + playerManager = MultiplayerHostSession.Instance?.PlayerManager; + } + public override void ProcessPacket(DysonSphereRemoveNodePacket packet, NebulaConnection conn) { - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) + bool valid = true; + if (IsHost) { - DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); - if (dsl != null) + Player player = playerManager.GetPlayer(conn); + if (player != null) + playerManager.SendPacketToOtherPlayers(packet, player); + else + valid = false; + } + + if (valid) + { + using (DysonSphereManager.IsIncomingRequest.On()) { - int num = 0; - DysonNode dysonNode = dsl.nodePool[packet.NodeId]; - //Remove all frames that are part of the node - while (dysonNode.frames.Count > 0) + DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); + if (dsl != null) { - dsl.RemoveDysonFrame(dysonNode.frames[0].id); - if (num++ > 4096) + int num = 0; + DysonNode dysonNode = dsl.nodePool[packet.NodeId]; + //Remove all frames that are part of the node + while (dysonNode.frames.Count > 0) { - Assert.CannotBeReached(); - break; + dsl.RemoveDysonFrame(dysonNode.frames[0].id); + if (num++ > 4096) + { + Assert.CannotBeReached(); + break; + } } - } - //Remove all shells that are part of the node - while (dysonNode.shells.Count > 0) - { - dsl.RemoveDysonShell(dysonNode.shells[0].id); - if (num++ > 4096) + //Remove all shells that are part of the node + while (dysonNode.shells.Count > 0) { - Assert.CannotBeReached(); - break; + dsl.RemoveDysonShell(dysonNode.shells[0].id); + if (num++ > 4096) + { + Assert.CannotBeReached(); + break; + } } + dsl.RemoveDysonNode(packet.NodeId); } - dsl.RemoveDysonNode(packet.NodeId); } } } diff --git a/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveShellProcessor.cs b/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveShellProcessor.cs index 65bb618c7..be04c4e3b 100644 --- a/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveShellProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Universe/DysonSphereRemoveShellProcessor.cs @@ -9,14 +9,34 @@ namespace NebulaNetwork.PacketProcessors.Universe [RegisterPacketProcessor] class DysonSphereRemoveShellProcessor : PacketProcessor { + private PlayerManager playerManager; + + public DysonSphereRemoveShellProcessor() + { + playerManager = MultiplayerHostSession.Instance?.PlayerManager; + } + public override void ProcessPacket(DysonSphereRemoveShellPacket packet, NebulaConnection conn) { - using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) + bool valid = true; + if (IsHost) + { + Player player = playerManager.GetPlayer(conn); + if (player != null) + playerManager.SendPacketToOtherPlayers(packet, player); + else + valid = false; + } + + if (valid) { - DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); - if (DysonSphere_Manager.CanRemoveShell(packet.ShellId, dsl)) + using (DysonSphereManager.IsIncomingRequest.On()) { - dsl.RemoveDysonShell(packet.ShellId); + DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); + if (DysonSphereManager.CanRemoveShell(packet.ShellId, dsl)) + { + dsl.RemoveDysonShell(packet.ShellId); + } } } } diff --git a/NebulaHost/PacketProcessors/Universe/DysonSphereRequestProcessor.cs b/NebulaNetwork/PacketProcessors/Universe/DysonSphereRequestProcessor.cs similarity index 95% rename from NebulaHost/PacketProcessors/Universe/DysonSphereRequestProcessor.cs rename to NebulaNetwork/PacketProcessors/Universe/DysonSphereRequestProcessor.cs index 2a2ae4c75..f3c70ea3f 100644 --- a/NebulaHost/PacketProcessors/Universe/DysonSphereRequestProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Universe/DysonSphereRequestProcessor.cs @@ -10,6 +10,8 @@ public class DysonSphereRequestProcessor : PacketProcessor { + private PlayerManager playerManager; + + public DysonSwarmAddOrbitProcessor() + { + playerManager = MultiplayerHostSession.Instance?.PlayerManager; + } + public override void ProcessPacket(DysonSwarmAddOrbitPacket packet, NebulaConnection conn) { - using (DysonSphere_Manager.IncomingDysonSwarmPacket.On()) + bool valid = true; + if (IsHost) + { + Player player = playerManager.GetPlayer(conn); + if (player != null) + playerManager.SendPacketToOtherPlayers(packet, player); + else + valid = false; + } + + if (valid) { - GameMain.data.dysonSpheres[packet.StarIndex]?.swarm?.NewOrbit(packet.Radius, DataStructureExtensions.ToQuaternion(packet.Rotation)); + using (DysonSphereManager.IncomingDysonSwarmPacket.On()) + { + GameMain.data.dysonSpheres[packet.StarIndex]?.swarm?.NewOrbit(packet.Radius, DataStructureExtensions.ToQuaternion(packet.Rotation)); + } } } } diff --git a/NebulaNetwork/PacketProcessors/Universe/DysonSwarmRemoveOrbitProcessor.cs b/NebulaNetwork/PacketProcessors/Universe/DysonSwarmRemoveOrbitProcessor.cs index 587cbf98c..07df89c3c 100644 --- a/NebulaNetwork/PacketProcessors/Universe/DysonSwarmRemoveOrbitProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Universe/DysonSwarmRemoveOrbitProcessor.cs @@ -9,11 +9,31 @@ namespace NebulaNetwork.PacketProcessors.Universe [RegisterPacketProcessor] class DysonSwarmRemoveOrbitProcessor : PacketProcessor { + private PlayerManager playerManager; + + public DysonSwarmRemoveOrbitProcessor() + { + playerManager = MultiplayerHostSession.Instance?.PlayerManager; + } + public override void ProcessPacket(DysonSwarmRemoveOrbitPacket packet, NebulaConnection conn) { - using (DysonSphere_Manager.IncomingDysonSwarmPacket.On()) + bool valid = true; + if (IsHost) + { + Player player = playerManager.GetPlayer(conn); + if (player != null) + playerManager.SendPacketToOtherPlayers(packet, player); + else + valid = false; + } + + if (valid) { - GameMain.data.dysonSpheres[packet.StarIndex]?.swarm?.RemoveOrbit(packet.OrbitId); + using (DysonSphereManager.IncomingDysonSwarmPacket.On()) + { + GameMain.data.dysonSpheres[packet.StarIndex]?.swarm?.RemoveOrbit(packet.OrbitId); + } } } } diff --git a/NebulaNetwork/PacketProcessors/Universe/NameInputProcessor.cs b/NebulaNetwork/PacketProcessors/Universe/NameInputProcessor.cs index 39a9e85d7..b25aeeecb 100644 --- a/NebulaNetwork/PacketProcessors/Universe/NameInputProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Universe/NameInputProcessor.cs @@ -13,29 +13,44 @@ namespace NebulaNetwork.PacketProcessors.Universe [RegisterPacketProcessor] class NameInputProcessor : PacketProcessor { + private PlayerManager playerManager; + + public NameInputProcessor() + { + playerManager = MultiplayerHostSession.Instance?.PlayerManager; + } + public override void ProcessPacket(NameInputPacket packet, NebulaConnection conn) { - // We don't want to process events that we sent - if (packet.AuthorId == LocalPlayer.PlayerId) + bool valid = true; + if (IsHost) { - return; + Player player = playerManager.GetPlayer(conn); + if (player != null) + playerManager.SendPacketToOtherPlayers(packet, player); + else + valid = false; } - using (FactoryManager.IsIncomingRequest.On()) + + if (valid) { - // If stellarId > 100 then it must be a planet - if (packet.StellarId > 100) - { - var planet = GameMain.galaxy.PlanetById(packet.StellarId); - planet.overrideName = packet.Name; - planet.NotifyOnDisplayNameChange(); - } - else + using (FactoryManager.IsIncomingRequest.On()) { - var star = GameMain.galaxy.StarById(packet.StellarId); - star.overrideName = packet.Name; - star.NotifyOnDisplayNameChange(); + // If stellarId > 100 then it must be a planet + if (packet.StellarId > 100) + { + var planet = GameMain.galaxy.PlanetById(packet.StellarId); + planet.overrideName = packet.Name; + planet.NotifyOnDisplayNameChange(); + } + else + { + var star = GameMain.galaxy.StarById(packet.StellarId); + star.overrideName = packet.Name; + star.NotifyOnDisplayNameChange(); + } + GameMain.galaxy.NotifyAstroNameChange(); } - GameMain.galaxy.NotifyAstroNameChange(); } } } diff --git a/NebulaPatcher/Patches/Dynamic/DysonSphereLayer_Patch.cs b/NebulaPatcher/Patches/Dynamic/DysonSphereLayer_Patch.cs index 5a4ff223d..fac26207a 100644 --- a/NebulaPatcher/Patches/Dynamic/DysonSphereLayer_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/DysonSphereLayer_Patch.cs @@ -20,7 +20,7 @@ public static bool NewDysonNode_Prefix(DysonSphereLayer __instance, int __result return true; } //Notify others that user added node to the dyson plan - if (!DysonSphere_Manager.IncomingDysonSpherePacket) + if (!DysonSphereManager.IsIncomingRequest) { LocalPlayer.SendPacket(new DysonSphereAddNodePacket(__instance.starData.index, __instance.id, protoId, new Float3(pos))); } @@ -36,7 +36,7 @@ public static bool NewDysonFrame_Prefix(DysonSphereLayer __instance, int __resul return true; } //Notify others that user added frame to the dyson plan - if (!DysonSphere_Manager.IncomingDysonSpherePacket) + if (!DysonSphereManager.IsIncomingRequest) { LocalPlayer.SendPacket(new DysonSphereAddFramePacket(__instance.starData.index, __instance.id, protoId, nodeAId, nodeBId, euler)); } @@ -52,7 +52,7 @@ public static bool RemoveDysonFrame_Prefix(DysonSphereLayer __instance, int fram return true; } //Notify others that user removed frame from the dyson plan - if (!DysonSphere_Manager.IncomingDysonSpherePacket) + if (!DysonSphereManager.IsIncomingRequest) { LocalPlayer.SendPacket(new DysonSphereRemoveFramePacket(__instance.starData.index, __instance.id, frameId)); } @@ -68,7 +68,7 @@ public static bool RemoveDysonNode_Prefix(DysonSphereLayer __instance, int nodeI return true; } //Notify others that user removed node from the dyson plan - if (!DysonSphere_Manager.IncomingDysonSpherePacket) + if (!DysonSphereManager.IsIncomingRequest) { LocalPlayer.SendPacket(new DysonSphereRemoveNodePacket(__instance.starData.index, __instance.id, nodeId)); } @@ -84,7 +84,7 @@ public static bool NewDysonShell_Prefix(DysonSphereLayer __instance, int protoId return true; } //Notify others that user removed node from the dyson plan - if (!DysonSphere_Manager.IncomingDysonSpherePacket) + if (!DysonSphereManager.IsIncomingRequest) { LocalPlayer.SendPacket(new DysonSphereAddShellPacket(__instance.starData.index, __instance.id, protoId, nodeIds)); } @@ -100,7 +100,7 @@ public static bool RemoveDysonShell_Prefix(DysonSphereLayer __instance, int shel return true; } //Notify others that user removed node from the dyson plan - if (!DysonSphere_Manager.IncomingDysonSpherePacket) + if (!DysonSphereManager.IsIncomingRequest) { LocalPlayer.SendPacket(new DysonSphereRemoveShellPacket(__instance.starData.index, __instance.id, shellId)); } diff --git a/NebulaPatcher/Patches/Dynamic/DysonSphere_Patch.cs b/NebulaPatcher/Patches/Dynamic/DysonSphere_Patch.cs index 40dc80829..ffade6d9e 100644 --- a/NebulaPatcher/Patches/Dynamic/DysonSphere_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/DysonSphere_Patch.cs @@ -19,7 +19,7 @@ public static bool AddLayer_Prefix(DysonSphere __instance, DysonSphereLayer __re return true; } //Notify others that user added layer to dyson sphere plan - if (!DysonSphere_Manager.IncomingDysonSpherePacket) + if (!DysonSphereManager.IsIncomingRequest) { LocalPlayer.SendPacket(new DysonSphereAddLayerPacket(__instance.starData.index, orbitRadius, orbitRotation, orbitAngularSpeed)); } @@ -54,7 +54,7 @@ public static bool RemoveLayer_Prefix2(DysonSphere __instance, DysonSphereLayer public static void RemoveLayer(int id, int starIndex) { - if (!DysonSphere_Manager.IncomingDysonSpherePacket) + if (!DysonSphereManager.IsIncomingRequest) { LocalPlayer.SendPacket(new DysonSphereRemoveLayerPacket(starIndex, id)); } diff --git a/NebulaPatcher/Patches/Dynamic/DysonSwarm_Patch.cs b/NebulaPatcher/Patches/Dynamic/DysonSwarm_Patch.cs index 16ce4375a..c22253f43 100644 --- a/NebulaPatcher/Patches/Dynamic/DysonSwarm_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/DysonSwarm_Patch.cs @@ -18,7 +18,7 @@ public static bool NewOrbit_Prefix(DysonSwarm __instance, int __result, float ra return true; } //Notify others that orbit for Dyson Swarm was created - if (!DysonSphere_Manager.IncomingDysonSwarmPacket) + if (!DysonSphereManager.IncomingDysonSwarmPacket) { LocalPlayer.SendPacket(new DysonSwarmAddOrbitPacket(__instance.starData.index, radius, rotation)); } @@ -34,7 +34,7 @@ public static bool RemoveOrbit_Prefix(DysonSwarm __instance, int orbitId) return true; } //Notify others that orbit for Dyson Swarm was deleted - if (!DysonSphere_Manager.IncomingDysonSwarmPacket) + if (!DysonSphereManager.IncomingDysonSwarmPacket) { LocalPlayer.SendPacket(new DysonSwarmRemoveOrbitPacket(__instance.starData.index, orbitId)); } diff --git a/NebulaWorld/Universe/DysonSphere_Manager.cs b/NebulaWorld/Universe/DysonSphereManager.cs similarity index 92% rename from NebulaWorld/Universe/DysonSphere_Manager.cs rename to NebulaWorld/Universe/DysonSphereManager.cs index 135418a39..ad08a3a83 100644 --- a/NebulaWorld/Universe/DysonSphere_Manager.cs +++ b/NebulaWorld/Universe/DysonSphereManager.cs @@ -4,9 +4,9 @@ namespace NebulaWorld.Universe { - public static class DysonSphere_Manager + public static class DysonSphereManager { - public static readonly ToggleSwitch IncomingDysonSpherePacket = new ToggleSwitch(); + public static readonly ToggleSwitch IsIncomingRequest = new ToggleSwitch(); public static readonly ToggleSwitch IncomingDysonSwarmPacket = new ToggleSwitch(); public static List QueuedAddFramePackets = new List();