diff --git a/Nitrox.Bootloader/Main.cs b/Nitrox.Bootloader/Main.cs index a466472ac3..7a25b6c42f 100644 --- a/Nitrox.Bootloader/Main.cs +++ b/Nitrox.Bootloader/Main.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Linq; using System.Reflection; using System.Threading.Tasks; diff --git a/Nitrox.Bootloader/Nitrox.Bootloader.csproj b/Nitrox.Bootloader/Nitrox.Bootloader.csproj index 501e29ab24..cad927795f 100644 --- a/Nitrox.Bootloader/Nitrox.Bootloader.csproj +++ b/Nitrox.Bootloader/Nitrox.Bootloader.csproj @@ -1,27 +1,27 @@ - + - - - Debug - AnyCPU - {E4226522-9189-410B-93B2-792942FBD588} - Library - Properties - Nitrox.Bootloader - Nitrox.Bootloader - 512 - false - - - AnyCPU - true - full - false - prompt - 4 - - - - - - + + + Debug + AnyCPU + {E4226522-9189-410B-93B2-792942FBD588} + Library + Properties + Nitrox.Bootloader + Nitrox.Bootloader + 512 + false + + + AnyCPU + true + full + false + prompt + 4 + + + + + + \ No newline at end of file diff --git a/NitroxClient/Communication/MultiplayerSession/ConnectionState/Disconnected.cs b/NitroxClient/Communication/MultiplayerSession/ConnectionState/Disconnected.cs index cbb5b6c937..2ecb788001 100644 --- a/NitroxClient/Communication/MultiplayerSession/ConnectionState/Disconnected.cs +++ b/NitroxClient/Communication/MultiplayerSession/ConnectionState/Disconnected.cs @@ -20,7 +20,7 @@ public void NegotiateReservation(IMultiplayerSessionConnectionContext sessionCon IClient client = sessionConnectionContext.Client; string ipAddress = sessionConnectionContext.IpAddress; int port = sessionConnectionContext.ServerPort; - StartClient(ipAddress, client,port); + StartClient(ipAddress, client, port); EstablishSessionPolicy(sessionConnectionContext, client); } } @@ -55,7 +55,7 @@ private static void StartClient(string ipAddress, IClient client, int port) { if (!client.IsConnected) { - client.Start(ipAddress,port); + client.Start(ipAddress, port); if (!client.IsConnected) { diff --git a/NitroxClient/Communication/MultiplayerSession/MultiplayerSessionManager.cs b/NitroxClient/Communication/MultiplayerSession/MultiplayerSessionManager.cs index d1423fe909..652e2bcdde 100644 --- a/NitroxClient/Communication/MultiplayerSession/MultiplayerSessionManager.cs +++ b/NitroxClient/Communication/MultiplayerSession/MultiplayerSessionManager.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using NitroxClient.Communication.Abstract; using NitroxClient.Communication.MultiplayerSession.ConnectionState; -using NitroxClient.Debuggers; using NitroxClient.GameLogic; using NitroxModel; using NitroxModel.Helper; diff --git a/NitroxClient/Communication/Packets/Processors/ChatMessageProcessor.cs b/NitroxClient/Communication/Packets/Processors/ChatMessageProcessor.cs index ed09f510dc..7a93c1a024 100644 --- a/NitroxClient/Communication/Packets/Processors/ChatMessageProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/ChatMessageProcessor.cs @@ -3,7 +3,6 @@ using NitroxClient.Communication.Packets.Processors.Abstract; using NitroxClient.GameLogic; using NitroxClient.GameLogic.ChatUI; -using NitroxModel.Core; using NitroxModel.DataStructures.Util; using NitroxModel.Logger; using NitroxModel.Packets; diff --git a/NitroxClient/Communication/Packets/Processors/ConstructionAmountChangedProcessor.cs b/NitroxClient/Communication/Packets/Processors/ConstructionAmountChangedProcessor.cs index ea65cd4710..2f2fa2afaa 100644 --- a/NitroxClient/Communication/Packets/Processors/ConstructionAmountChangedProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/ConstructionAmountChangedProcessor.cs @@ -11,7 +11,7 @@ public class ConstructionAmountChangedProcessor : ClientPacketProcessor(); BaseDeconstructable baseDeconstructable = deconstructing.GetComponent(); diff --git a/NitroxClient/Communication/Packets/Processors/EntityMetadataUpdateProcessor.cs b/NitroxClient/Communication/Packets/Processors/EntityMetadataUpdateProcessor.cs index 460b76424a..624c59826e 100644 --- a/NitroxClient/Communication/Packets/Processors/EntityMetadataUpdateProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/EntityMetadataUpdateProcessor.cs @@ -16,7 +16,7 @@ public override void Process(EntityMetadataUpdate update) Optional metadataProcessor = EntityMetadataProcessor.FromMetaData(update.NewValue); Validate.IsTrue(metadataProcessor.HasValue, $"No processor found for EntityMetadata of type {update.NewValue.GetType()}"); - + metadataProcessor.Value.ProcessMetadata(gameObject, update.NewValue); } } diff --git a/NitroxClient/Communication/Packets/Processors/EntityTransformUpdatesProcessor.cs b/NitroxClient/Communication/Packets/Processors/EntityTransformUpdatesProcessor.cs index 0dd7f2bcec..a91e7d041c 100644 --- a/NitroxClient/Communication/Packets/Processors/EntityTransformUpdatesProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/EntityTransformUpdatesProcessor.cs @@ -1,6 +1,5 @@ using NitroxClient.Communication.Packets.Processors.Abstract; using NitroxClient.MonoBehaviours; -using NitroxClient.Unity.Smoothing; using NitroxModel.DataStructures.Util; using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures; diff --git a/NitroxClient/Communication/Packets/Processors/EscapePodRadioRepairProcessor.cs b/NitroxClient/Communication/Packets/Processors/EscapePodRadioRepairProcessor.cs index 835109f8a5..7eb1222f03 100644 --- a/NitroxClient/Communication/Packets/Processors/EscapePodRadioRepairProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/EscapePodRadioRepairProcessor.cs @@ -1,6 +1,6 @@ using NitroxClient.Communication.Packets.Processors.Abstract; -using NitroxModel.Packets; using NitroxClient.GameLogic; +using NitroxModel.Packets; namespace NitroxClient.Communication.Packets.Processors { diff --git a/NitroxClient/Communication/Packets/Processors/EscapePodRepairProcessor.cs b/NitroxClient/Communication/Packets/Processors/EscapePodRepairProcessor.cs index beeb95864f..3b6dc02ecb 100644 --- a/NitroxClient/Communication/Packets/Processors/EscapePodRepairProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/EscapePodRepairProcessor.cs @@ -1,6 +1,6 @@ using NitroxClient.Communication.Packets.Processors.Abstract; -using NitroxModel.Packets; using NitroxClient.GameLogic; +using NitroxModel.Packets; namespace NitroxClient.Communication.Packets.Processors { diff --git a/NitroxClient/Communication/Packets/Processors/ExosuitArmActionProcessor.cs b/NitroxClient/Communication/Packets/Processors/ExosuitArmActionProcessor.cs index 1d88d9d7ee..1ba105b059 100644 --- a/NitroxClient/Communication/Packets/Processors/ExosuitArmActionProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/ExosuitArmActionProcessor.cs @@ -41,14 +41,14 @@ public override void Process(ExosuitArmActionPacket packet) case TechType.ExosuitGrapplingArmModule: exosuitModuleEvent.UseGrappling(gameObject.GetComponent(), packet.ArmAction, packet.OpVector); break; - case TechType.ExosuitTorpedoArmModule: - exosuitModuleEvent.UseTorpedo(gameObject.GetComponent(), packet.ArmAction, packet.OpVector, packet.OpRotation); + case TechType.ExosuitTorpedoArmModule: + exosuitModuleEvent.UseTorpedo(gameObject.GetComponent(), packet.ArmAction, packet.OpVector, packet.OpRotation); break; default: Log.Error("Got an arm tech that is not handled: " + packet.TechType + " with action: " + packet.ArmAction + " for id " + packet.ArmId); break; } - + } } } diff --git a/NitroxClient/Communication/Packets/Processors/GameModeChangedProcessor.cs b/NitroxClient/Communication/Packets/Processors/GameModeChangedProcessor.cs index 2b6df04e99..2132f8f012 100644 --- a/NitroxClient/Communication/Packets/Processors/GameModeChangedProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/GameModeChangedProcessor.cs @@ -7,7 +7,7 @@ public class GameModeChangedProcessor : ClientPacketProcessor { public override void Process(GameModeChanged packet) { - GameModeUtils.SetGameMode((GameModeOption)(int) packet.GameMode, GameModeOption.None); + GameModeUtils.SetGameMode((GameModeOption)(int)packet.GameMode, GameModeOption.None); } } } diff --git a/NitroxClient/Communication/Packets/Processors/InitialPlayerSyncProcessor.cs b/NitroxClient/Communication/Packets/Processors/InitialPlayerSyncProcessor.cs index e0b053f3f6..ac64d88d65 100644 --- a/NitroxClient/Communication/Packets/Processors/InitialPlayerSyncProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/InitialPlayerSyncProcessor.cs @@ -1,12 +1,12 @@ -using NitroxClient.Communication.Packets.Processors.Abstract; -using NitroxModel.Packets; +using System; +using System.Collections; using System.Collections.Generic; +using NitroxClient.Communication.Abstract; +using NitroxClient.Communication.Packets.Processors.Abstract; using NitroxClient.GameLogic.InitialSync.Base; -using System; -using NitroxModel.Logger; using NitroxClient.MonoBehaviours; -using System.Collections; -using NitroxClient.Communication.Abstract; +using NitroxModel.Logger; +using NitroxModel.Packets; namespace NitroxClient.Communication.Packets.Processors { diff --git a/NitroxClient/Communication/Packets/Processors/KnownTechEntryAddProcessor.cs b/NitroxClient/Communication/Packets/Processors/KnownTechEntryAddProcessor.cs index 243f98207b..6d2267fcff 100644 --- a/NitroxClient/Communication/Packets/Processors/KnownTechEntryAddProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/KnownTechEntryAddProcessor.cs @@ -2,7 +2,6 @@ using NitroxClient.Communication.Packets.Processors.Abstract; using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures; -using NitroxModel_Subnautica.Helper; namespace NitroxClient.Communication.Packets.Processors { diff --git a/NitroxClient/Communication/Packets/Processors/ModuleRemovedProcessor.cs b/NitroxClient/Communication/Packets/Processors/ModuleRemovedProcessor.cs index d168c1fc1b..089f2f0e31 100644 --- a/NitroxClient/Communication/Packets/Processors/ModuleRemovedProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/ModuleRemovedProcessor.cs @@ -24,7 +24,7 @@ public override void Process(ModuleRemoved packet) Log.Error("Could not find equipment type for " + owner.name); return; } - + GameObject item = NitroxEntity.RequireObjectFrom(packet.ItemId); Pickupable pickupable = item.RequireComponent(); Equipment equipment = opEquipment.Value; @@ -32,7 +32,7 @@ public override void Process(ModuleRemoved packet) InventoryItem inventoryItem = itemsBySlot[packet.Slot]; itemsBySlot[packet.Slot] = null; - equipment.ReflectionCall("UpdateCount",false,false,pickupable.GetTechType(), false); + equipment.ReflectionCall("UpdateCount", false, false, pickupable.GetTechType(), false); Equipment.SendEquipmentEvent(pickupable, UNEQUIP_EVENT_TYPE_ID, owner, packet.Slot); equipment.ReflectionCall("NotifyUnequip", false, false, packet.Slot, inventoryItem); diff --git a/NitroxClient/Communication/Packets/Processors/PDAEncyclopediaEntryAddProcessor.cs b/NitroxClient/Communication/Packets/Processors/PDAEncyclopediaEntryAddProcessor.cs index 75af1855a3..dc7cb863d3 100644 --- a/NitroxClient/Communication/Packets/Processors/PDAEncyclopediaEntryAddProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/PDAEncyclopediaEntryAddProcessor.cs @@ -17,7 +17,7 @@ public override void Process(PDAEncyclopediaEntryAdd packet) { using (packetSender.Suppress()) { - PDAEncyclopedia.Add(packet.Key,true); + PDAEncyclopedia.Add(packet.Key, true); } } } diff --git a/NitroxClient/Communication/Packets/Processors/PDALogEntryAddProcessor.cs b/NitroxClient/Communication/Packets/Processors/PDALogEntryAddProcessor.cs index ebf6042537..4c2523798b 100644 --- a/NitroxClient/Communication/Packets/Processors/PDALogEntryAddProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/PDALogEntryAddProcessor.cs @@ -20,12 +20,11 @@ public override void Process(PDALogEntryAdd packet) using (packetSender.Suppress()) { Dictionary entries = (Dictionary)(typeof(PDALog).GetField("entries", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)); - + if (!entries.ContainsKey(packet.Key)) { - PDALog.EntryData entryData; - if (!PDALog.GetEntryData(packet.Key, out entryData)) + if (!PDALog.GetEntryData(packet.Key, out PDALog.EntryData entryData)) { entryData = new PDALog.EntryData(); entryData.key = packet.Key; diff --git a/NitroxClient/Communication/Packets/Processors/PDAScannerEntryAddProcessor.cs b/NitroxClient/Communication/Packets/Processors/PDAScannerEntryAddProcessor.cs index 4a0a2e1420..c4c948f5c7 100644 --- a/NitroxClient/Communication/Packets/Processors/PDAScannerEntryAddProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/PDAScannerEntryAddProcessor.cs @@ -5,7 +5,6 @@ using NitroxClient.Communication.Packets.Processors.Abstract; using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures; -using NitroxModel_Subnautica.Helper; using UnityEngine; namespace NitroxClient.Communication.Packets.Processors @@ -27,8 +26,7 @@ public override void Process(PDAEntryAdd packet) TechType techType = packet.TechType.ToUnity(); PDAScanner.EntryData entryData = PDAScanner.GetEntryData(techType); - PDAScanner.Entry entry; - if (!PDAScanner.GetPartialEntryByKey(techType, out entry)) + if (!PDAScanner.GetPartialEntryByKey(techType, out PDAScanner.Entry entry)) { MethodInfo methodAdd = typeof(PDAScanner).GetMethod("Add", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(TechType), typeof(int) }, null); entry = (PDAScanner.Entry)methodAdd.Invoke(null, new object[] { techType, packet.Unlocked }); diff --git a/NitroxClient/Communication/Packets/Processors/PDAScannerEntryRemoveProcessor.cs b/NitroxClient/Communication/Packets/Processors/PDAScannerEntryRemoveProcessor.cs index 8240bbf311..b89b15beff 100644 --- a/NitroxClient/Communication/Packets/Processors/PDAScannerEntryRemoveProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/PDAScannerEntryRemoveProcessor.cs @@ -4,7 +4,6 @@ using NitroxClient.Communication.Packets.Processors.Abstract; using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures; -using NitroxModel_Subnautica.Helper; namespace NitroxClient.Communication.Packets.Processors { @@ -21,9 +20,8 @@ public override void Process(PDAEntryRemove packet) { using (packetSender.Suppress()) { - PDAScanner.Entry entry; - if (PDAScanner.GetPartialEntryByKey(packet.TechType.ToUnity(), out entry)) + if (PDAScanner.GetPartialEntryByKey(packet.TechType.ToUnity(), out PDAScanner.Entry entry)) { List partial = (List)(typeof(PDAScanner).GetField("partial", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)); HashSet complete = (HashSet)(typeof(PDAScanner).GetField("complete", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)); diff --git a/NitroxClient/Communication/Packets/Processors/PingRenamedProcessor.cs b/NitroxClient/Communication/Packets/Processors/PingRenamedProcessor.cs index 75c2a5bd66..f5d196ed63 100644 --- a/NitroxClient/Communication/Packets/Processors/PingRenamedProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/PingRenamedProcessor.cs @@ -1,5 +1,4 @@ -using System; -using NitroxClient.Communication.Abstract; +using NitroxClient.Communication.Abstract; using NitroxClient.Communication.Packets.Processors.Abstract; using NitroxClient.MonoBehaviours; using NitroxClient.Unity.Helper; diff --git a/NitroxClient/Communication/Packets/Processors/PlaceBasePieceProcessor.cs b/NitroxClient/Communication/Packets/Processors/PlaceBasePieceProcessor.cs index fb163d1cfa..cedd4a7f98 100644 --- a/NitroxClient/Communication/Packets/Processors/PlaceBasePieceProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/PlaceBasePieceProcessor.cs @@ -1,6 +1,6 @@ using NitroxClient.Communication.Packets.Processors.Abstract; -using NitroxModel.Packets; using NitroxClient.GameLogic.Bases; +using NitroxModel.Packets; namespace NitroxClient.Communication.Packets.Processors { diff --git a/NitroxClient/Communication/Packets/Processors/RemotePlayerEquipmentAddedProcessor.cs b/NitroxClient/Communication/Packets/Processors/RemotePlayerEquipmentAddedProcessor.cs index 4f6ed5cf69..c9cec3fe42 100644 --- a/NitroxClient/Communication/Packets/Processors/RemotePlayerEquipmentAddedProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/RemotePlayerEquipmentAddedProcessor.cs @@ -2,7 +2,6 @@ using NitroxClient.GameLogic; using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures; -using NitroxModel_Subnautica.Helper; namespace NitroxClient.Communication.Packets.Processors { @@ -19,8 +18,7 @@ public override void Process(RemotePlayerEquipmentAdded packet) { ushort playerId = packet.PlayerId; - RemotePlayer player; - if (!playerManager.TryFind(playerId, out player)) + if (!playerManager.TryFind(playerId, out RemotePlayer player)) { return; } diff --git a/NitroxClient/Communication/Packets/Processors/RemotePlayerEquipmentRemovedProcessor.cs b/NitroxClient/Communication/Packets/Processors/RemotePlayerEquipmentRemovedProcessor.cs index ecffa42e2b..ec332ae143 100644 --- a/NitroxClient/Communication/Packets/Processors/RemotePlayerEquipmentRemovedProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/RemotePlayerEquipmentRemovedProcessor.cs @@ -2,7 +2,6 @@ using NitroxClient.GameLogic; using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures; -using NitroxModel_Subnautica.Helper; namespace NitroxClient.Communication.Packets.Processors { @@ -19,8 +18,7 @@ public override void Process(RemotePlayerEquipmentRemoved packet) { ushort playerId = packet.PlayerId; - RemotePlayer player; - if (!playerManager.TryFind(playerId, out player)) + if (!playerManager.TryFind(playerId, out RemotePlayer player)) { return; } diff --git a/NitroxClient/Communication/Packets/Processors/SceneDebuggerChangeProcessor.cs b/NitroxClient/Communication/Packets/Processors/SceneDebuggerChangeProcessor.cs index 5d583f6b34..cfdbd118ad 100644 --- a/NitroxClient/Communication/Packets/Processors/SceneDebuggerChangeProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/SceneDebuggerChangeProcessor.cs @@ -1,10 +1,10 @@ using System.Linq; using System.Reflection; +using NitroxClient.Communication.Abstract; using NitroxClient.Communication.Packets.Processors.Abstract; using NitroxModel.Logger; using NitroxModel.Packets; using UnityEngine; -using NitroxClient.Communication.Abstract; namespace NitroxClient.Communication.Packets.Processors { diff --git a/NitroxClient/Communication/Packets/Processors/SeamothModuleActionProcessor.cs b/NitroxClient/Communication/Packets/Processors/SeamothModuleActionProcessor.cs index d033f22a58..b717f91da3 100644 --- a/NitroxClient/Communication/Packets/Processors/SeamothModuleActionProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/SeamothModuleActionProcessor.cs @@ -4,7 +4,6 @@ using NitroxModel.Helper; using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures; -using NitroxModel_Subnautica.Helper; using UnityEngine; namespace NitroxClient.Communication.Packets.Processors diff --git a/NitroxClient/Communication/Packets/Processors/StorageSlotAddItemProcessor.cs b/NitroxClient/Communication/Packets/Processors/StorageSlotAddItemProcessor.cs index 02f8f7b0bc..f63c4209b5 100644 --- a/NitroxClient/Communication/Packets/Processors/StorageSlotAddItemProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/StorageSlotAddItemProcessor.cs @@ -21,13 +21,13 @@ public StorageSlotAddItemProcessor(IPacketSender packetSender, StorageSlots stor } public override void Process(StorageSlotItemAdd packet) - { + { ItemData itemData = packet.ItemData; - GameObject item = SerializationHelper.GetGameObject(itemData.SerializedData); - + GameObject item = SerializationHelper.GetGameObject(itemData.SerializedData); + NitroxEntity.SetNewId(item, itemData.ItemId); - storageSlots.AddItem(item, itemData.ContainerId); + storageSlots.AddItem(item, itemData.ContainerId); } } } diff --git a/NitroxClient/Communication/Packets/Processors/VehicleDockingProcessor.cs b/NitroxClient/Communication/Packets/Processors/VehicleDockingProcessor.cs index d416f3ad9b..c89809df80 100644 --- a/NitroxClient/Communication/Packets/Processors/VehicleDockingProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/VehicleDockingProcessor.cs @@ -1,15 +1,13 @@ -using NitroxClient.Communication.Abstract; +using System.Collections; +using NitroxClient.Communication.Abstract; using NitroxClient.Communication.Packets.Processors.Abstract; using NitroxClient.GameLogic; +using NitroxClient.MonoBehaviours; using NitroxClient.Unity.Helper; -using NitroxModel.Packets; -using System.Collections; -using UnityEngine; using NitroxModel.DataStructures; -using NitroxClient.MonoBehaviours; using NitroxModel.Logger; -using NitroxModel.Helper; -using NitroxModel.DataStructures.Util; +using NitroxModel.Packets; +using UnityEngine; namespace NitroxClient.Communication.Packets.Processors { @@ -43,7 +41,7 @@ public override void Process(VehicleDocking packet) vehicle.GetComponent().Exit(); } vehicle.StartCoroutine(DelayAnimationAndDisablePiloting(vehicle, vehicleDockingBay, packet.VehicleId, packet.PlayerId)); - } + } IEnumerator DelayAnimationAndDisablePiloting(Vehicle vehicle, VehicleDockingBay vehicleDockingBay, NitroxId vehicleId, ushort playerId) { diff --git a/NitroxClient/Communication/Packets/Processors/VehicleOnPilotModeChangedProcessor.cs b/NitroxClient/Communication/Packets/Processors/VehicleOnPilotModeChangedProcessor.cs index 75145e35d1..7b68515361 100644 --- a/NitroxClient/Communication/Packets/Processors/VehicleOnPilotModeChangedProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/VehicleOnPilotModeChangedProcessor.cs @@ -23,7 +23,7 @@ public override void Process(VehicleOnPilotModeChanged packet) { GameObject vehicleGo = NitroxEntity.RequireObjectFrom(packet.VehicleId); Vehicle vehicle = vehicleGo.RequireComponent(); - + // If the vehicle is docked, then we will manually set the piloting mode // once the animations complete. This prevents weird behaviour such as the // player existing the vehicle while it is about to dock (the event fires diff --git a/NitroxClient/Communication/Packets/Processors/VehicleUndockingProcessor.cs b/NitroxClient/Communication/Packets/Processors/VehicleUndockingProcessor.cs index 71375f7281..131671cdc0 100644 --- a/NitroxClient/Communication/Packets/Processors/VehicleUndockingProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/VehicleUndockingProcessor.cs @@ -1,14 +1,14 @@ -using NitroxClient.Communication.Abstract; +using System.Collections; +using NitroxClient.Communication.Abstract; using NitroxClient.Communication.Packets.Processors.Abstract; using NitroxClient.GameLogic; +using NitroxClient.MonoBehaviours; using NitroxClient.Unity.Helper; +using NitroxModel.DataStructures.Util; using NitroxModel.Helper; +using NitroxModel.Logger; using NitroxModel.Packets; -using System.Collections; using UnityEngine; -using NitroxClient.MonoBehaviours; -using NitroxModel.DataStructures.Util; -using NitroxModel.Logger; namespace NitroxClient.Communication.Packets.Processors { @@ -32,10 +32,10 @@ public override void Process(VehicleUndocking packet) Vehicle vehicle = vehicleGo.RequireComponent(); VehicleDockingBay vehicleDockingBay = vehicleDockingBayGo.RequireComponentInChildren(); - + using (packetSender.Suppress()) { - + if (packet.UndockingStart) { StartVehicleUndocking(packet, vehicleGo, vehicle, vehicleDockingBay); @@ -52,9 +52,9 @@ private void StartVehicleUndocking(VehicleUndocking packet, GameObject vehicleGo Optional player = remotePlayerManager.Find(packet.PlayerId); vehicleDockingBay.subRoot.BroadcastMessage("OnLaunchBayOpening", SendMessageOptions.DontRequireReceiver); SkyEnvironmentChanged.Broadcast(vehicleGo, (GameObject)null); - + if (player.HasValue) - { + { RemotePlayer playerInstance = player.Value; vehicle.mainAnimator.SetBool("player_in", true); playerInstance.Attach(vehicle.playerPosition.transform); @@ -68,7 +68,7 @@ private void StartVehicleUndocking(VehicleUndocking packet, GameObject vehicleGo } vehicleDockingBay.StartCoroutine(StartUndockingAnimation(vehicleDockingBay)); } - + public IEnumerator StartUndockingAnimation(VehicleDockingBay vehicleDockingBay) { yield return new WaitForSeconds(2.0f); diff --git a/NitroxClient/Communication/Packets/Processors/WeldActionProcessor.cs b/NitroxClient/Communication/Packets/Processors/WeldActionProcessor.cs index 3973014c4d..7f502d168c 100644 --- a/NitroxClient/Communication/Packets/Processors/WeldActionProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/WeldActionProcessor.cs @@ -2,7 +2,6 @@ using NitroxClient.Communication.Packets.Processors.Abstract; using NitroxClient.GameLogic; using NitroxClient.MonoBehaviours; -using NitroxModel.DataStructures.Util; using NitroxModel.Logger; using NitroxModel.Packets; using UnityEngine; diff --git a/NitroxClient/Debuggers/EntityDebugger.cs b/NitroxClient/Debuggers/EntityDebugger.cs index d3337a6710..6953f6d821 100644 --- a/NitroxClient/Debuggers/EntityDebugger.cs +++ b/NitroxClient/Debuggers/EntityDebugger.cs @@ -80,7 +80,7 @@ public override void OnGUI() GUI.backgroundColor = labelBgColor; GUI.color = labelFgColor; GUI.Box(drawSize, textContent); - + GUI.backgroundColor = oldBgColor; } } diff --git a/NitroxClient/Debuggers/NetworkDebugger.cs b/NitroxClient/Debuggers/NetworkDebugger.cs index 1b21f1fa9b..7baf2b26af 100644 --- a/NitroxClient/Debuggers/NetworkDebugger.cs +++ b/NitroxClient/Debuggers/NetworkDebugger.cs @@ -192,8 +192,7 @@ private void AddPacket(Packet packet, bool isSent) } } - int count; - if (countByType.TryGetValue(packetType, out count)) + if (countByType.TryGetValue(packetType, out int count)) { countByType[packetType] = count + 1; } diff --git a/NitroxClient/Debuggers/SceneDebugger.cs b/NitroxClient/Debuggers/SceneDebugger.cs index 110ea80177..799c69345c 100644 --- a/NitroxClient/Debuggers/SceneDebugger.cs +++ b/NitroxClient/Debuggers/SceneDebugger.cs @@ -237,7 +237,7 @@ private void RenderTabScenes() using (new GUILayout.VerticalScope("Box")) { GUILayout.Label("All scenes", "header"); - for (int i = 0; i < SceneManager.sceneCountInBuildSettings+1; i++) + for (int i = 0; i < SceneManager.sceneCountInBuildSettings + 1; i++) { Scene currentScene; string path = ""; diff --git a/NitroxClient/GameLogic/Bases/BuildThrottlingQueue.cs b/NitroxClient/GameLogic/Bases/BuildThrottlingQueue.cs index 7ff84b5231..b84bff8c0b 100644 --- a/NitroxClient/GameLogic/Bases/BuildThrottlingQueue.cs +++ b/NitroxClient/GameLogic/Bases/BuildThrottlingQueue.cs @@ -1,7 +1,7 @@ -using NitroxModel.DataStructures.GameLogic; -using NitroxModel.Logger; -using System.Collections.Generic; +using System.Collections.Generic; using NitroxModel.DataStructures; +using NitroxModel.DataStructures.GameLogic; +using NitroxModel.Logger; namespace NitroxClient.GameLogic.Bases { @@ -11,13 +11,13 @@ namespace NitroxClient.GameLogic.Bases * hold build events for future processing. Incoming packets can be converted * to more generic BuildEvent classes that can be re-used. Examples: we want * to re-use logic for ConstructionCompleted packet and InitialPlayerSync build - * packets - this class helps faciliate that. + * packets - this class helps facilitate that. */ public class BuildThrottlingQueue : Queue { public bool NextEventRequiresFreshFrame() { - if(Count > 0) + if (Count > 0) { BuildEvent nextEvent = Peek(); return nextEvent.RequiresFreshFrame(); @@ -28,31 +28,31 @@ public bool NextEventRequiresFreshFrame() public void EnqueueBasePiecePlaced(BasePiece basePiece) { - Log.Info("Enqueuing base piece to be placed techtype: " + basePiece.TechType + " id: " + basePiece.Id + " parentId: " + basePiece.ParentId.OrElse(null) + " build index: " + basePiece.BuildIndex ); + Log.Info($"Enqueuing base piece to be placed - TechType: {basePiece.TechType}, Id: {basePiece.Id}, ParentId: {basePiece.ParentId.OrElse(null)}, BuildIndex: {basePiece.BuildIndex}"); Enqueue(new BasePiecePlacedEvent(basePiece)); } public void EnqueueConstructionCompleted(NitroxId id, NitroxId baseId) { - Log.Info("Enqueuing item to have construction completed id: " + id); + Log.Info($"Enqueuing item to have construction completed - Id: {id}"); Enqueue(new ConstructionCompletedEvent(id, baseId)); } public void EnqueueAmountChanged(NitroxId id, float amount) { - Log.Info("Enqueuing item to have construction amount changed id: " + id); + Log.Info($"Enqueuing item to have construction amount changed - Id: {id}"); Enqueue(new ConstructionAmountChangedEvent(id, amount)); } public void EnqueueDeconstructionBegin(NitroxId id) { - Log.Info("Enqueuing item to have deconstruction beginning id: " + id); + Log.Info($"Enqueuing item to have deconstruction beginning - Id: {id}"); Enqueue(new DeconstructionBeginEvent(id)); } public void EnqueueDeconstructionCompleted(NitroxId id) { - Log.Info("Enqueuing item to have deconstruction completed id: " + id); + Log.Info($"Enqueuing item to have deconstruction completed - Id: {id}"); Enqueue(new DeconstructionCompletedEvent(id)); } } diff --git a/NitroxClient/GameLogic/Bases/Metadata/BasePieceMetadataProcessor.cs b/NitroxClient/GameLogic/Bases/Metadata/BasePieceMetadataProcessor.cs index 336247a3bb..d1e350ba11 100644 --- a/NitroxClient/GameLogic/Bases/Metadata/BasePieceMetadataProcessor.cs +++ b/NitroxClient/GameLogic/Bases/Metadata/BasePieceMetadataProcessor.cs @@ -26,7 +26,7 @@ static BasePieceMetadataProcessor() foreach (BasePieceMetadataProcessor processor in processors) { - + Type metadataType = processor.GetType().BaseType.GetGenericArguments()[0]; processorsByType.Add(metadataType, processor); } @@ -34,9 +34,8 @@ static BasePieceMetadataProcessor() public static BasePieceMetadataProcessor FromMetaData(BasePieceMetadata metadata) { - BasePieceMetadataProcessor processor; - if (processorsByType.TryGetValue(metadata.GetType(), out processor)) + if (processorsByType.TryGetValue(metadata.GetType(), out BasePieceMetadataProcessor processor)) { return processor; } diff --git a/NitroxClient/GameLogic/Bases/Spawning/BaseBioReactorSpawnProcessor.cs b/NitroxClient/GameLogic/Bases/Spawning/BaseBioReactorSpawnProcessor.cs index 27568f95f4..f4d178a0a7 100644 --- a/NitroxClient/GameLogic/Bases/Spawning/BaseBioReactorSpawnProcessor.cs +++ b/NitroxClient/GameLogic/Bases/Spawning/BaseBioReactorSpawnProcessor.cs @@ -1,5 +1,4 @@ -using System.Linq; -using NitroxClient.MonoBehaviours; +using NitroxClient.MonoBehaviours; using NitroxClient.Unity.Helper; using NitroxModel.DataStructures; using NitroxModel.Helper; diff --git a/NitroxClient/GameLogic/Bases/Spawning/BasePieceSpawnPrioritizer.cs b/NitroxClient/GameLogic/Bases/Spawning/BasePieceSpawnPrioritizer.cs index 588fd57b7e..00e79b9c87 100644 --- a/NitroxClient/GameLogic/Bases/Spawning/BasePieceSpawnPrioritizer.cs +++ b/NitroxClient/GameLogic/Bases/Spawning/BasePieceSpawnPrioritizer.cs @@ -66,15 +66,14 @@ public List OrderBasePiecesByPriority(List inputPieces) .ThenBy(piece => piece.IsFurniture) // Ensure base building block go before furniture .ThenBy(piece => ComputeBasePiecePriority(piece)) // Ensure remaining pieces are prioritized by above order. .ThenBy(piece => piece.BuildIndex) - .ToList(); + .ToList(); } private int ComputeBasePiecePriority(BasePiece basePiece) { TechType techType = basePiece.TechType.ToUnity(); - int position; - if (PiecesToPriority.TryGetValue(techType, out position)) + if (PiecesToPriority.TryGetValue(techType, out int position)) { return position; } diff --git a/NitroxClient/GameLogic/Bases/Spawning/BasePieceSpawnProcessor.cs b/NitroxClient/GameLogic/Bases/Spawning/BasePieceSpawnProcessor.cs index 8063e8d5eb..e670337bf3 100644 --- a/NitroxClient/GameLogic/Bases/Spawning/BasePieceSpawnProcessor.cs +++ b/NitroxClient/GameLogic/Bases/Spawning/BasePieceSpawnProcessor.cs @@ -40,9 +40,8 @@ public static BasePieceSpawnProcessor From(BaseDeconstructable baseDeconstructab { TechType techType = (TechType)baseDeconstructable.ReflectionGet("recipe"); - BasePieceSpawnProcessor processor; - if (processorsByType.TryGetValue(techType, out processor)) + if (processorsByType.TryGetValue(techType, out BasePieceSpawnProcessor processor)) { Log.Info("Found custom BasePieceSpawnProcessor for " + techType); return processor; diff --git a/NitroxClient/GameLogic/Bases/Spawning/BaseRoomWaterParkProcessor.cs b/NitroxClient/GameLogic/Bases/Spawning/BaseRoomWaterParkProcessor.cs index 6e2cbc9953..2e442d1080 100644 --- a/NitroxClient/GameLogic/Bases/Spawning/BaseRoomWaterParkProcessor.cs +++ b/NitroxClient/GameLogic/Bases/Spawning/BaseRoomWaterParkProcessor.cs @@ -1,8 +1,8 @@ using NitroxClient.MonoBehaviours; using NitroxModel.DataStructures; -using UnityEngine; -using NitroxModel.Logger; using NitroxModel.Helper; +using NitroxModel.Logger; +using UnityEngine; namespace NitroxClient.GameLogic.Bases.Spawning { @@ -12,7 +12,7 @@ namespace NitroxClient.GameLogic.Bases.Spawning * contains a Planter. When the object spawns, we use this class to set a deterministic id seeded by the parent id. * This keeps inventory actions in sync and allows for persistent storage of each container's contents. */ - public class BaseRoomWaterParkProcessor: BasePieceSpawnProcessor + public class BaseRoomWaterParkProcessor : BasePieceSpawnProcessor { public override TechType[] ApplicableTechTypes { get; } = { @@ -24,7 +24,7 @@ public override void SpawnPostProcess(Base latestBase, Int3 latestCell, GameObje NitroxId pieceId = NitroxEntity.GetId(finishedPiece); WaterParkPiece waterParkPiece = finishedPiece.GetComponent(); - if(!waterParkPiece) + if (!waterParkPiece) { // The BaseWater has multiple base pieces, but only one of them (the bottom) contains the WaterParkPiece component... return; diff --git a/NitroxClient/GameLogic/Building.cs b/NitroxClient/GameLogic/Building.cs index a7bb121008..7ccaa00a5b 100644 --- a/NitroxClient/GameLogic/Building.cs +++ b/NitroxClient/GameLogic/Building.cs @@ -24,7 +24,7 @@ public class Building private readonly RotationMetadataFactory rotationMetadataFactory; private float timeSinceLastConstructionChangeEvent; - + public Building(IPacketSender packetSender, RotationMetadataFactory rotationMetadataFactory) { this.packetSender = packetSender; @@ -37,11 +37,11 @@ public void PlaceBasePiece(BaseGhost baseGhost, ConstructableBase constructableB { return; } - + NitroxId id = NitroxEntity.GetId(constructableBase.gameObject); NitroxId parentBaseId = null; - + if (baseGhost != null) { if (baseGhost.TargetBase != null) @@ -53,8 +53,8 @@ public void PlaceBasePiece(BaseGhost baseGhost, ConstructableBase constructableB parentBaseId = NitroxEntity.GetId(baseGhost.GhostBase.gameObject); } } - - if(parentBaseId == null) + + if (parentBaseId == null) { Base aBase = constructableBase.gameObject.GetComponentInParent(); if (aBase != null) @@ -62,7 +62,7 @@ public void PlaceBasePiece(BaseGhost baseGhost, ConstructableBase constructableB parentBaseId = NitroxEntity.GetId(aBase.gameObject); } } - + Vector3 placedPosition = constructableBase.gameObject.transform.position; Transform camera = Camera.main.transform; Optional rotationMetadata = rotationMetadataFactory.From(baseGhost); @@ -92,7 +92,7 @@ public void PlaceFurniture(GameObject gameObject, TechType techType, Vector3 ite { Base playerBase = gameObject.GetComponentInParent(); - if(playerBase != null) + if (playerBase != null) { parentId = NitroxEntity.GetId(playerBase.gameObject); } @@ -119,7 +119,7 @@ public void ChangeConstructionAmount(GameObject gameObject, float amount) } timeSinceLastConstructionChangeEvent = 0.0f; - + NitroxId id = NitroxEntity.GetId(gameObject); if (amount < 0.95f) // Construction complete event handled by function below @@ -133,7 +133,7 @@ public void ConstructionComplete(GameObject ghost, Optional lastTargetBase { NitroxId baseId = null; Optional opConstructedBase = TransientLocalObjectManager.Get(TransientObjectType.BASE_GHOST_NEWLY_CONSTRUCTED_BASE_GAMEOBJECT); - + NitroxId id = NitroxEntity.GetId(ghost); Log.Info("Construction complete on " + id + " " + ghost.name); @@ -143,7 +143,7 @@ public void ConstructionComplete(GameObject ghost, Optional lastTargetBase GameObject constructedBase = (GameObject)opConstructedBase.Value; baseId = NitroxEntity.GetId(constructedBase); } - + // For base pieces, we must switch the id from the ghost to the newly constructed piece. // Furniture just uses the same game object as the ghost for the final product. if (ghost.GetComponent() != null) @@ -159,16 +159,14 @@ public void ConstructionComplete(GameObject ghost, Optional lastTargetBase // however, there may still be pieces were the ghost base's target offset is authoratitive due to incorrect game object positioning. if (latestCell == default(Int3) || cellTransform == null) { - Vector3 worldPosition; - float distance; - latestBase.GetClosestCell(ghost.transform.position, out latestCell, out worldPosition, out distance); + latestBase.GetClosestCell(ghost.transform.position, out latestCell, out Vector3 worldPosition, out float distance); cellTransform = latestBase.GetCellObject(latestCell); Validate.NotNull(cellTransform, "Unable to find cell transform at " + latestCell); } GameObject finishedPiece = null; - + // There can be multiple objects in a cell (such as a corridor with hatces built into it) // we look for a object that is able to be deconstucted that hasn't been tagged yet. foreach (Transform child in cellTransform) @@ -182,7 +180,7 @@ public void ConstructionComplete(GameObject ghost, Optional lastTargetBase break; } } - + Validate.NotNull(finishedPiece, "Could not find finished piece in cell " + latestCell); Log.Info("Setting id to finished piece: " + finishedPiece.name + " " + id); @@ -193,7 +191,7 @@ public void ConstructionComplete(GameObject ghost, Optional lastTargetBase BasePieceSpawnProcessor customSpawnProcessor = BasePieceSpawnProcessor.From(finishedPiece.GetComponent()); customSpawnProcessor.SpawnPostProcess(latestBase, latestCell, finishedPiece); } - + Log.Info("Construction Completed " + id + " in base " + baseId); ConstructionCompleted constructionCompleted = new ConstructionCompleted(id, baseId); diff --git a/NitroxClient/GameLogic/Containers/ContainerAddItemPostProcessor.cs b/NitroxClient/GameLogic/Containers/ContainerAddItemPostProcessor.cs index 91f5276357..4864f9244e 100644 --- a/NitroxClient/GameLogic/Containers/ContainerAddItemPostProcessor.cs +++ b/NitroxClient/GameLogic/Containers/ContainerAddItemPostProcessor.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using NitroxModel.Logger; using NitroxModel.DataStructures.GameLogic; +using NitroxModel.Logger; using UnityEngine; @@ -32,11 +32,11 @@ static ContainerAddItemPostProcessor() public static ContainerAddItemPostProcessor From(GameObject item) { - foreach( ContainerAddItemPostProcessor processor in processors ) + foreach (ContainerAddItemPostProcessor processor in processors) { - foreach( Type type in processor.ApplicableComponents ) + foreach (Type type in processor.ApplicableComponents) { - if( item.GetComponent(type)) + if (item.GetComponent(type)) { Log.Info("Found custom ContainerAddItemPostProcessor for " + type); return processor; diff --git a/NitroxClient/GameLogic/Containers/NoOpContainerAddItemPostProcessor.cs b/NitroxClient/GameLogic/Containers/NoOpContainerAddItemPostProcessor.cs index a4f94a7404..32b69aa4d0 100644 --- a/NitroxClient/GameLogic/Containers/NoOpContainerAddItemPostProcessor.cs +++ b/NitroxClient/GameLogic/Containers/NoOpContainerAddItemPostProcessor.cs @@ -1,10 +1,10 @@ using System; -using UnityEngine; using NitroxModel.DataStructures.GameLogic; +using UnityEngine; namespace NitroxClient.GameLogic.Containers { - class NoOpContainerAddItemPostProcessor: ContainerAddItemPostProcessor + class NoOpContainerAddItemPostProcessor : ContainerAddItemPostProcessor { public override Type[] ApplicableComponents { get; } = new Type[0]; diff --git a/NitroxClient/GameLogic/Containers/PlantableContainerAddItemPostProcessor.cs b/NitroxClient/GameLogic/Containers/PlantableContainerAddItemPostProcessor.cs index 9f799b9146..9fdd800ed6 100644 --- a/NitroxClient/GameLogic/Containers/PlantableContainerAddItemPostProcessor.cs +++ b/NitroxClient/GameLogic/Containers/PlantableContainerAddItemPostProcessor.cs @@ -1,7 +1,7 @@ using System; +using NitroxModel.DataStructures.GameLogic; using NitroxModel.Logger; using UnityEngine; -using NitroxModel.DataStructures.GameLogic; namespace NitroxClient.GameLogic.Containers diff --git a/NitroxClient/GameLogic/EscapePodManager.cs b/NitroxClient/GameLogic/EscapePodManager.cs index 785b857bbb..282f4f875e 100644 --- a/NitroxClient/GameLogic/EscapePodManager.cs +++ b/NitroxClient/GameLogic/EscapePodManager.cs @@ -1,15 +1,15 @@ using System.Collections.Generic; using NitroxClient.Communication.Abstract; +using NitroxClient.MonoBehaviours; using NitroxClient.Unity.Helper; +using NitroxModel.DataStructures; using NitroxModel.DataStructures.GameLogic; -using NitroxModel.Logger; -using NitroxModel.Packets; -using UnityEngine; using NitroxModel.DataStructures.Util; -using NitroxModel.DataStructures; -using NitroxClient.MonoBehaviours; using NitroxModel.Helper; +using NitroxModel.Logger; +using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures; +using UnityEngine; namespace NitroxClient.GameLogic { @@ -21,7 +21,7 @@ public class EscapePodManager * EscapePod.main to the new escape pod. */ public static bool SURPRESS_ESCAPE_POD_AWAKE_METHOD; - + private readonly IPacketSender packetSender; private readonly IMultiplayerSession multiplayerSession; @@ -53,9 +53,9 @@ public void AssignPlayerToEscapePod(EscapePodModel escapePod, bool firstTimeSpaw { Log.Error("Escape pod did not have a rigid body!"); } - - Player.main.transform.position = EscapePod.main.playerSpawn.position; - Player.main.transform.rotation = EscapePod.main.playerSpawn.rotation; + + Player.main.transform.position = EscapePod.main.playerSpawn.position; + Player.main.transform.rotation = EscapePod.main.playerSpawn.rotation; if (firstTimeSpawning) { Player.main.currentEscapePod = EscapePod.main; @@ -158,7 +158,8 @@ public void OnRepair(NitroxId id) pod.animator.SetFloat("lifepod_damage", 1.0f); pod.fixPanelGoal.Trigger(); pod.fixPanelPowerUp.Play(); - } else + } + else { Log.Warn("No escape pod to be repaired by id " + id); } @@ -168,9 +169,9 @@ public void OnRepairedByMe(EscapePod pod) { NitroxId id = null; - foreach(KeyValuePair dict in escapePodsById) + foreach (KeyValuePair dict in escapePodsById) { - if(NitroxEntity.GetId(dict.Value) == NitroxEntity.GetId(pod.gameObject)) + if (NitroxEntity.GetId(dict.Value) == NitroxEntity.GetId(pod.gameObject)) { id = dict.Key; // we're looking for serverside id here break; @@ -181,7 +182,8 @@ public void OnRepairedByMe(EscapePod pod) { EscapePodRepair repair = new EscapePodRepair(id); packetSender.Send(repair); - } else + } + else { Log.Warn("Couldn't find escape pod id on repair"); } @@ -205,7 +207,7 @@ public void OnRadioRepairedByMe(Radio radio) // todo: can this apply to non-escape pod radios? NitroxId id = NitroxEntity.GetId(radio.gameObject); - + EscapePodRadioRepair repair = new EscapePodRadioRepair(id); packetSender.Send(repair); } diff --git a/NitroxClient/GameLogic/ExosuitModuleEvent.cs b/NitroxClient/GameLogic/ExosuitModuleEvent.cs index f7953e1f62..110e61a348 100644 --- a/NitroxClient/GameLogic/ExosuitModuleEvent.cs +++ b/NitroxClient/GameLogic/ExosuitModuleEvent.cs @@ -2,7 +2,6 @@ using NitroxClient.Communication.Abstract; using NitroxClient.MonoBehaviours; using NitroxModel.DataStructures; -using NitroxModel.DataStructures.Util; using NitroxModel.Helper; using NitroxModel.Logger; using NitroxModel_Subnautica.DataStructures.GameLogic; @@ -26,12 +25,12 @@ public ExosuitModuleEvent(IPacketSender packetSender, IMultiplayerSession multip public void SpawnedArm(Exosuit exosuit) { - NitroxId id = NitroxEntity.GetId(exosuit.gameObject); + NitroxId id = NitroxEntity.GetId(exosuit.gameObject); ExosuitModel exosuitModel = vehicles.GetVehicles(id); - - IExosuitArm rightArm = (IExosuitArm)exosuit.ReflectionGet("rightArm"); - IExosuitArm leftArm = (IExosuitArm)exosuit.ReflectionGet("leftArm"); - + + IExosuitArm rightArm = (IExosuitArm)exosuit.ReflectionGet("rightArm"); + IExosuitArm leftArm = (IExosuitArm)exosuit.ReflectionGet("leftArm"); + try { GameObject rightArmGameObject = rightArm.GetGameObject(); @@ -46,7 +45,7 @@ public void SpawnedArm(Exosuit exosuit) } Log.Debug("Spawn exosuit arms for: " + id); - } + } public void BroadcastClawUse(ExosuitClawArm clawArm, float cooldown) { @@ -76,16 +75,16 @@ public void UseClaw(ExosuitClawArm clawArm, ExosuitArmAction armAction) { clawArm.animator.SetTrigger("use_tool"); } - else if(armAction == ExosuitArmAction.ALT_HIT) + else if (armAction == ExosuitArmAction.ALT_HIT) { clawArm.animator.SetTrigger("bash"); clawArm.fxControl.Play(0); } - } + } public void UseDrill(ExosuitDrillArm drillArm, ExosuitArmAction armAction) { - if(armAction == ExosuitArmAction.START_USE_TOOL) + if (armAction == ExosuitArmAction.START_USE_TOOL) { drillArm.animator.SetBool("use_tool", true); drillArm.loop.Play(); @@ -99,11 +98,11 @@ public void UseDrill(ExosuitDrillArm drillArm, ExosuitArmAction armAction) { Log.Error("Drill arm got an arm action he should not get: " + armAction); } - } + } public void BroadcastArmAction(TechType techType, IExosuitArm exosuitArm, ExosuitArmAction armAction, Vector3? opVector, Quaternion? opRotation) { - NitroxId id = NitroxEntity.GetId(exosuitArm.GetGameObject()); + NitroxId id = NitroxEntity.GetId(exosuitArm.GetGameObject()); ExosuitArmActionPacket packet = new ExosuitArmActionPacket(techType, id, armAction, opVector, opRotation); packetSender.Send(packet); } @@ -120,7 +119,7 @@ public void UseGrappling(ExosuitGrapplingArm grapplingArm, ExosuitArmAction armA if (armAction == ExosuitArmAction.END_USE_TOOL) { grapplingArm.animator.SetBool("use_tool", false); - grapplingArm.ReflectionCall("ResetHook"); + grapplingArm.ReflectionCall("ResetHook"); } else if (armAction == ExosuitArmAction.START_USE_TOOL) { @@ -137,13 +136,13 @@ public void UseGrappling(ExosuitGrapplingArm grapplingArm, ExosuitArmAction armA hook.SetFlying(true); Exosuit componentInParent = grapplingArm.GetComponentInParent(); - + if (!opHitVector.HasValue) { Log.Error("No vector given that contains the hook direction"); return; } - + hook.rb.velocity = opHitVector.Value; global::Utils.PlayFMODAsset(grapplingArm.shootSound, grapplingArm.front, 15f); grapplingArm.ReflectionSet("grapplingStartPos", componentInParent.transform.position); @@ -155,10 +154,10 @@ public void UseGrappling(ExosuitGrapplingArm grapplingArm, ExosuitArmAction armA } public void UseTorpedo(ExosuitTorpedoArm torpedoArm, ExosuitArmAction armAction, Vector3? opVector, Quaternion? opRotation) - { + { if (armAction == ExosuitArmAction.START_USE_TOOL || armAction == ExosuitArmAction.ALT_HIT) { - if(!opVector.HasValue || !opRotation.HasValue) + if (!opVector.HasValue || !opRotation.HasValue) { Log.Error("Torpedo arm action shoot: no vector or rotation present"); return; diff --git a/NitroxClient/GameLogic/FMOD/FMODSystem.cs b/NitroxClient/GameLogic/FMOD/FMODSystem.cs index 64784faeff..21e1633938 100644 --- a/NitroxClient/GameLogic/FMOD/FMODSystem.cs +++ b/NitroxClient/GameLogic/FMOD/FMODSystem.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Globalization; using NitroxClient.Communication.Abstract; using NitroxClient.Properties; diff --git a/NitroxClient/GameLogic/HUD/PlayerVitalsManager.cs b/NitroxClient/GameLogic/HUD/PlayerVitalsManager.cs index a468a3f495..7e6dc0a31d 100644 --- a/NitroxClient/GameLogic/HUD/PlayerVitalsManager.cs +++ b/NitroxClient/GameLogic/HUD/PlayerVitalsManager.cs @@ -24,8 +24,7 @@ public void RemoveForPlayer(ushort playerId) public RemotePlayerVitals CreateForPlayer(ushort playerId) { - RemotePlayerVitals vitals; - if (!vitalsByPlayerId.TryGetValue(playerId, out vitals)) + if (!vitalsByPlayerId.TryGetValue(playerId, out RemotePlayerVitals vitals)) { vitals = RemotePlayerVitals.CreateForPlayer(playerId); vitalsByPlayerId[playerId] = vitals; diff --git a/NitroxClient/GameLogic/Helper/TransientLocalObjectManager.cs b/NitroxClient/GameLogic/Helper/TransientLocalObjectManager.cs index c2304c93eb..8b489c233e 100644 --- a/NitroxClient/GameLogic/Helper/TransientLocalObjectManager.cs +++ b/NitroxClient/GameLogic/Helper/TransientLocalObjectManager.cs @@ -17,7 +17,7 @@ public enum TransientObjectType { CONSTRUCTOR_INPUT_CRAFTED_GAMEOBJECT, BASE_GHOST_NEWLY_CONSTRUCTED_BASE_GAMEOBJECT, - + LATEST_DECONSTRUCTED_BASE_PIECE_GHOST, LATEST_DECONSTRUCTED_BASE_PIECE_GUID } @@ -36,19 +36,17 @@ public static void Remove(TransientObjectType key) public static Optional Get(TransientObjectType key) { - object obj; - localObjectsById.TryGetValue(key, out obj); + localObjectsById.TryGetValue(key, out object obj); return Optional.OfNullable(obj); } public static T Require(TransientObjectType key) { - object obj; - if (!localObjectsById.TryGetValue(key, out obj)) + if (!localObjectsById.TryGetValue(key, out object obj)) { throw new Exception("Did not have an entry for key: " + key); } - + return (T)obj; } } diff --git a/NitroxClient/GameLogic/InitialSync/BasePieceMetadataInitialSyncProcessor.cs b/NitroxClient/GameLogic/InitialSync/BasePieceMetadataInitialSyncProcessor.cs index 23cc60a44d..7e1f10dc22 100644 --- a/NitroxClient/GameLogic/InitialSync/BasePieceMetadataInitialSyncProcessor.cs +++ b/NitroxClient/GameLogic/InitialSync/BasePieceMetadataInitialSyncProcessor.cs @@ -14,7 +14,7 @@ public BasePieceMetadataInitialSyncProcessor() { DependentProcessors.Add(typeof(BuildingInitialSyncProcessor)); // Meta data augments base pieces so they must be spawned first. } - + public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { int basePiecesWithMetadata = 0; diff --git a/NitroxClient/GameLogic/InitialSync/BuildingInitialSyncProcessor.cs b/NitroxClient/GameLogic/InitialSync/BuildingInitialSyncProcessor.cs index c28f089222..18758b45ef 100644 --- a/NitroxClient/GameLogic/InitialSync/BuildingInitialSyncProcessor.cs +++ b/NitroxClient/GameLogic/InitialSync/BuildingInitialSyncProcessor.cs @@ -20,7 +20,7 @@ public class BuildingInitialSyncProcessor : InitialSyncProcessor private readonly BasePieceSpawnPrioritizer basePieceSpawnPrioritizer; private bool completed; - + public BuildingInitialSyncProcessor(IPacketSender packetSender, BuildThrottlingQueue buildEventQueue, BasePieceSpawnPrioritizer basePieceSpawnPrioritizer) { this.packetSender = packetSender; diff --git a/NitroxClient/GameLogic/InitialSync/EquippedItemInitialSyncProcessor.cs b/NitroxClient/GameLogic/InitialSync/EquippedItemInitialSyncProcessor.cs index 57f3e90827..f4d07af3d6 100644 --- a/NitroxClient/GameLogic/InitialSync/EquippedItemInitialSyncProcessor.cs +++ b/NitroxClient/GameLogic/InitialSync/EquippedItemInitialSyncProcessor.cs @@ -21,7 +21,7 @@ public class EquippedItemInitialSyncProcessor : InitialSyncProcessor public EquippedItemInitialSyncProcessor(IPacketSender packetSender) { this.packetSender = packetSender; - + DependentProcessors.Add(typeof(PlayerInitialSyncProcessor)); // the player needs to be configured before we can equip items DependentProcessors.Add(typeof(RemotePlayerInitialSyncProcessor)); // remote players can also equip items DependentProcessors.Add(typeof(VehicleInitialSyncProcessor)); // Equipment also includes vehicles modules @@ -50,7 +50,7 @@ public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualW Optional opEquipment = EquipmentHelper.FindEquipmentComponent(owner); if (opEquipment.HasValue) - { + { Equipment equipment = opEquipment.Value; InventoryItem inventoryItem = new InventoryItem(pickupable); inventoryItem.container = equipment; diff --git a/NitroxClient/GameLogic/InitialSync/EscapePodInitialSyncProcessor.cs b/NitroxClient/GameLogic/InitialSync/EscapePodInitialSyncProcessor.cs index bd04d7f38d..b6c33185de 100644 --- a/NitroxClient/GameLogic/InitialSync/EscapePodInitialSyncProcessor.cs +++ b/NitroxClient/GameLogic/InitialSync/EscapePodInitialSyncProcessor.cs @@ -17,7 +17,7 @@ public EscapePodInitialSyncProcessor(EscapePodManager escapePodManager) public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { EscapePodModel escapePod = packet.EscapePodsData.Find(x => x.Id.Equals(packet.AssignedEscapePodId)); - + escapePodManager.AssignPlayerToEscapePod(escapePod, packet.FirstTimeConnecting); yield return null; diff --git a/NitroxClient/GameLogic/InitialSync/PdaInitialSyncProcessor.cs b/NitroxClient/GameLogic/InitialSync/PdaInitialSyncProcessor.cs index 878dba00e0..78d0fbd042 100644 --- a/NitroxClient/GameLogic/InitialSync/PdaInitialSyncProcessor.cs +++ b/NitroxClient/GameLogic/InitialSync/PdaInitialSyncProcessor.cs @@ -1,13 +1,12 @@ -using System.Collections.Generic; +using System.Collections; +using System.Collections.Generic; using System.Reflection; using NitroxClient.Communication.Abstract; using NitroxClient.GameLogic.InitialSync.Base; using NitroxModel.DataStructures.GameLogic; +using NitroxModel.Helper; using NitroxModel.Logger; using NitroxModel.Packets; -using NitroxModel.Helper; -using NitroxModel_Subnautica.Helper; -using System.Collections; using NitroxModel_Subnautica.DataStructures; namespace NitroxClient.GameLogic.InitialSync @@ -108,8 +107,7 @@ private void SetPDALog(List logEntries) { if (!entries.ContainsKey(logEntry.Key)) { - PDALog.EntryData entryData; - PDALog.GetEntryData(logEntry.Key, out entryData); + PDALog.GetEntryData(logEntry.Key, out PDALog.EntryData entryData); PDALog.Entry entry = new PDALog.Entry(); entry.data = entryData; entry.timestamp = logEntry.Timestamp; diff --git a/NitroxClient/GameLogic/InitialSync/PlayerModulesInitialSyncProcessor.cs b/NitroxClient/GameLogic/InitialSync/PlayerModulesInitialSyncProcessor.cs index eb3f2843a4..8cbf5982fe 100644 --- a/NitroxClient/GameLogic/InitialSync/PlayerModulesInitialSyncProcessor.cs +++ b/NitroxClient/GameLogic/InitialSync/PlayerModulesInitialSyncProcessor.cs @@ -22,7 +22,7 @@ public PlayerModulesInitialSyncProcessor(IPacketSender packetSender, EquipmentSl } public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) - { + { using (packetSender.Suppress()) { equipmentSlots.AddItems(packet.Modules); diff --git a/NitroxClient/GameLogic/InitialSync/RemotePlayerInitialSyncProcessor.cs b/NitroxClient/GameLogic/InitialSync/RemotePlayerInitialSyncProcessor.cs index b30071f819..1ff5be566f 100644 --- a/NitroxClient/GameLogic/InitialSync/RemotePlayerInitialSyncProcessor.cs +++ b/NitroxClient/GameLogic/InitialSync/RemotePlayerInitialSyncProcessor.cs @@ -9,7 +9,6 @@ using NitroxModel.Logger; using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures; -using NitroxModel_Subnautica.Helper; using UnityEngine; namespace NitroxClient.GameLogic.InitialSync @@ -53,8 +52,7 @@ private bool IsSwimming(Vector3 playerPosition, Optional subId) if (subId.HasValue) { Optional sub = NitroxEntity.GetObjectFrom(subId.Value); - SubRoot subroot = null; - sub.Value.TryGetComponent(out subroot); + sub.Value.TryGetComponent(out SubRoot subroot); // Set the animation for the remote player to standing instead of swimming if player is not in a flooded subroot // or in a waterpark if (subroot) @@ -84,8 +82,7 @@ private bool IsSwimming(Vector3 playerPosition, Optional subId) } Log.Debug($"Trying to find escape pod for {subId}."); - EscapePod escapePod = null; - sub.Value.TryGetComponent(out escapePod); + sub.Value.TryGetComponent(out EscapePod escapePod); if (escapePod) { Log.Debug("Found escape pod for player. Will add him and update animation."); diff --git a/NitroxClient/GameLogic/InitialSync/SimulationOwnershipInitialSyncProcessor.cs b/NitroxClient/GameLogic/InitialSync/SimulationOwnershipInitialSyncProcessor.cs index d9d50090e6..14ad90af17 100644 --- a/NitroxClient/GameLogic/InitialSync/SimulationOwnershipInitialSyncProcessor.cs +++ b/NitroxClient/GameLogic/InitialSync/SimulationOwnershipInitialSyncProcessor.cs @@ -1,13 +1,9 @@ using System.Collections; using NitroxClient.Communication.Abstract; -using NitroxClient.GameLogic.Helper; using NitroxClient.GameLogic.InitialSync.Base; -using NitroxClient.MonoBehaviours; -using NitroxModel.DataStructures.GameLogic; +using NitroxModel.DataStructures; using NitroxModel.Logger; using NitroxModel.Packets; -using NitroxModel.DataStructures; -using UnityEngine; namespace NitroxClient.GameLogic.InitialSync { diff --git a/NitroxClient/GameLogic/InitialSync/StoryGoalInitialSyncProcessor.cs b/NitroxClient/GameLogic/InitialSync/StoryGoalInitialSyncProcessor.cs index da9b3b35ac..78d4e159fb 100644 --- a/NitroxClient/GameLogic/InitialSync/StoryGoalInitialSyncProcessor.cs +++ b/NitroxClient/GameLogic/InitialSync/StoryGoalInitialSyncProcessor.cs @@ -9,7 +9,7 @@ namespace NitroxClient.GameLogic.InitialSync { public class StoryGoalInitialSyncProcessor : InitialSyncProcessor { - + public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { SetCompletedStoryGoals(packet.StoryGoalData.CompletedGoals); @@ -30,7 +30,7 @@ private void SetRadioQueue(List radioQueue) StoryGoalManager.main.pendingRadioMessages.AddRange(radioQueue); StoryGoalManager.main.PulsePendingMessages(); } - + private void SetCompletedStoryGoals(List storyGoalData) { StoryGoalManager.main.completedGoals.Clear(); @@ -42,7 +42,7 @@ private void SetCompletedStoryGoals(List storyGoalData) Log.Info("Received initial sync packet with " + storyGoalData.Count + " completed story goals"); } - + private void SetGoalUnlocks(List goalUnlocks) { foreach (string goalUnlock in goalUnlocks) diff --git a/NitroxClient/GameLogic/InitialSync/VehicleInitialSyncProcessor.cs b/NitroxClient/GameLogic/InitialSync/VehicleInitialSyncProcessor.cs index 932ed87158..3dfcf8eb93 100644 --- a/NitroxClient/GameLogic/InitialSync/VehicleInitialSyncProcessor.cs +++ b/NitroxClient/GameLogic/InitialSync/VehicleInitialSyncProcessor.cs @@ -22,7 +22,7 @@ public VehicleInitialSyncProcessor(Vehicles vehicles, IPacketSender packetSender DependentProcessors.Add(typeof(BuildingInitialSyncProcessor)); DependentProcessors.Add(typeof(CyclopsInitialAsyncProcessor)); } - + public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem) { int totalSyncedVehicles = 0; diff --git a/NitroxClient/GameLogic/ItemContainers.cs b/NitroxClient/GameLogic/ItemContainers.cs index 1c3c1f0dc5..4d534c347e 100644 --- a/NitroxClient/GameLogic/ItemContainers.cs +++ b/NitroxClient/GameLogic/ItemContainers.cs @@ -1,6 +1,4 @@ -using System; -using System.Text.RegularExpressions; -using NitroxClient.Communication.Abstract; +using NitroxClient.Communication.Abstract; using NitroxClient.GameLogic.Helper; using NitroxClient.MonoBehaviours; using NitroxClient.Unity.Helper; diff --git a/NitroxClient/GameLogic/ItemDropActions/ItemDropAction.cs b/NitroxClient/GameLogic/ItemDropActions/ItemDropAction.cs index ccbe2d7592..1a67d6f9fd 100644 --- a/NitroxClient/GameLogic/ItemDropActions/ItemDropAction.cs +++ b/NitroxClient/GameLogic/ItemDropActions/ItemDropAction.cs @@ -14,8 +14,7 @@ public abstract class ItemDropAction public static ItemDropAction FromTechType(TechType techType) { - ItemDropAction itemDropAction; - if (dropActionsByTechType.TryGetValue(techType, out itemDropAction)) + if (dropActionsByTechType.TryGetValue(techType, out ItemDropAction itemDropAction)) { return itemDropAction; } diff --git a/NitroxClient/GameLogic/KnownTechEntry.cs b/NitroxClient/GameLogic/KnownTechEntry.cs index fb700f1106..b8ccd51284 100644 --- a/NitroxClient/GameLogic/KnownTechEntry.cs +++ b/NitroxClient/GameLogic/KnownTechEntry.cs @@ -1,7 +1,6 @@ using NitroxClient.Communication.Abstract; using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures; -using NitroxModel_Subnautica.Helper; namespace NitroxClient.GameLogic { diff --git a/NitroxClient/GameLogic/MobileVehicleBay.cs b/NitroxClient/GameLogic/MobileVehicleBay.cs index 43fe9b6108..9debd9dc18 100644 --- a/NitroxClient/GameLogic/MobileVehicleBay.cs +++ b/NitroxClient/GameLogic/MobileVehicleBay.cs @@ -7,7 +7,6 @@ using NitroxModel.DataStructures.Util; using NitroxModel.Logger; using NitroxModel.Packets; -using NitroxModel_Subnautica.Helper; using UnityEngine; using static NitroxClient.GameLogic.Helper.TransientLocalObjectManager; diff --git a/NitroxClient/GameLogic/MovementHelper.cs b/NitroxClient/GameLogic/MovementHelper.cs index ad18d61faa..03ca0949f7 100644 --- a/NitroxClient/GameLogic/MovementHelper.cs +++ b/NitroxClient/GameLogic/MovementHelper.cs @@ -53,9 +53,7 @@ public static Vector3 GetCorrectedAngularVelocity(Quaternion remoteRotation, Vec { Quaternion delta = remoteRotation * gameObject.transform.rotation.GetInverse(); - float angle; - Vector3 axis; - delta.ToAngleAxis(out angle, out axis); + delta.ToAngleAxis(out float angle, out Vector3 axis); // We get an infinite axis in the event that our rotation is already aligned. if (float.IsInfinity(axis.x)) diff --git a/NitroxClient/GameLogic/PlayerManager.cs b/NitroxClient/GameLogic/PlayerManager.cs index 770458ebd7..0959239bfc 100644 --- a/NitroxClient/GameLogic/PlayerManager.cs +++ b/NitroxClient/GameLogic/PlayerManager.cs @@ -32,8 +32,7 @@ public PlayerManager(IPacketSender packetSender, ILocalNitroxPlayer localPlayer, public Optional Find(ushort playerId) { - RemotePlayer player; - playersById.TryGetValue(playerId, out player); + playersById.TryGetValue(playerId, out RemotePlayer player); return Optional.OfNullable(player); } diff --git a/NitroxClient/GameLogic/PlayerModel/ColorSwap/ColorSwapAsyncOperation.cs b/NitroxClient/GameLogic/PlayerModel/ColorSwap/ColorSwapAsyncOperation.cs index 5c4753ce0a..3a06269940 100644 --- a/NitroxClient/GameLogic/PlayerModel/ColorSwap/ColorSwapAsyncOperation.cs +++ b/NitroxClient/GameLogic/PlayerModel/ColorSwap/ColorSwapAsyncOperation.cs @@ -13,7 +13,7 @@ public class ColorSwapAsyncOperation private readonly IEnumerable colorSwapManagers; private readonly Dictionary texturePixelIndexes; private int taskCount = -1; - + public ColorSwapAsyncOperation(INitroxPlayer nitroxPlayer, IEnumerable colorSwapManagers) { this.nitroxPlayer = nitroxPlayer; @@ -71,7 +71,7 @@ private void ExecuteTask(object state) { Action task = state as Action; - if(task == null) + if (task == null) { //TODO: We need to handle job cancellation during stabilization to ensure that the client shuts down gracefully. diff --git a/NitroxClient/GameLogic/PlayerModel/ColorSwap/HsvSwapper.cs b/NitroxClient/GameLogic/PlayerModel/ColorSwap/HsvSwapper.cs index 64786d04bd..acbd4a3604 100644 --- a/NitroxClient/GameLogic/PlayerModel/ColorSwap/HsvSwapper.cs +++ b/NitroxClient/GameLogic/PlayerModel/ColorSwap/HsvSwapper.cs @@ -57,12 +57,9 @@ public void SwapColors(Color[] texturePixels) for (int pixelIndex = 0; pixelIndex < texturePixels.Length; pixelIndex++) { Color pixel = texturePixels[pixelIndex]; - float hue; - float saturation; - float vibrancy; float alpha = pixel.a; - Color.RGBToHSV(pixel, out hue, out saturation, out vibrancy); + Color.RGBToHSV(pixel, out float hue, out float saturation, out float vibrancy); if (hueValueRange.Covers(hue) && saturationValueRange.Covers(saturation) && diff --git a/NitroxClient/GameLogic/PlayerModel/ColorSwap/RadiationSuitColorSwapManager.cs b/NitroxClient/GameLogic/PlayerModel/ColorSwap/RadiationSuitColorSwapManager.cs index 690be1da75..ad98b9f78e 100644 --- a/NitroxClient/GameLogic/PlayerModel/ColorSwap/RadiationSuitColorSwapManager.cs +++ b/NitroxClient/GameLogic/PlayerModel/ColorSwap/RadiationSuitColorSwapManager.cs @@ -75,7 +75,7 @@ public void ApplyPlayerColor(Dictionary pixelIndex, INitroxPlay GameObject playerModel = nitroxPlayer.PlayerModel; SkinnedMeshRenderer radiationSuitRenderer = playerModel.GetRenderer(RADIATION_SUIT_GAME_OBJECT_NAME); - + radiationSuitRenderer.material.UpdateMainTextureColors(legPixels, legTextureBlock); radiationSuitRenderer.material.UpdateMainTextureColors(feetPixels, feetTextureBlock); radiationSuitRenderer.material.UpdateMainTextureColors(beltPixels, beltTextureBlock); diff --git a/NitroxClient/GameLogic/PlayerModel/ColorSwap/Strategy/HueSaturationVibrancySwapper.cs b/NitroxClient/GameLogic/PlayerModel/ColorSwap/Strategy/HueSaturationVibrancySwapper.cs index be006e3382..5e3cb6a4ba 100644 --- a/NitroxClient/GameLogic/PlayerModel/ColorSwap/Strategy/HueSaturationVibrancySwapper.cs +++ b/NitroxClient/GameLogic/PlayerModel/ColorSwap/Strategy/HueSaturationVibrancySwapper.cs @@ -16,11 +16,8 @@ public HueSaturationVibrancySwapper(Color playerColor) public Color SwapColor(Color originalColor) { - float currentHue; - float currentSaturation; - float currentVibrancy; float currentAlpha = originalColor.a; - Color.RGBToHSV(originalColor, out currentHue, out currentSaturation, out currentVibrancy); + Color.RGBToHSV(originalColor, out float currentHue, out float currentSaturation, out float currentVibrancy); return Color .HSVToRGB(replacementHue, replacementSaturation, replacementVibrancy) diff --git a/NitroxClient/GameLogic/PlayerModel/ColorSwap/Strategy/HueSwapper.cs b/NitroxClient/GameLogic/PlayerModel/ColorSwap/Strategy/HueSwapper.cs index 86c69c64cb..7401afcc7b 100644 --- a/NitroxClient/GameLogic/PlayerModel/ColorSwap/Strategy/HueSwapper.cs +++ b/NitroxClient/GameLogic/PlayerModel/ColorSwap/Strategy/HueSwapper.cs @@ -9,18 +9,13 @@ public class HueSwapper : IColorSwapStrategy public HueSwapper(Color playerColor) { - float saturation; - float vibrancy; - Color.RGBToHSV(playerColor, out replacementHue, out saturation, out vibrancy); + Color.RGBToHSV(playerColor, out replacementHue, out float saturation, out float vibrancy); } public Color SwapColor(Color originalColor) { - float currentHue; - float currentSaturation; - float currentVibrancy; float currentAlpha = originalColor.a; - Color.RGBToHSV(originalColor, out currentHue, out currentSaturation, out currentVibrancy); + Color.RGBToHSV(originalColor, out float currentHue, out float currentSaturation, out float currentVibrancy); return Color .HSVToRGB(replacementHue, currentSaturation, currentVibrancy) diff --git a/NitroxClient/GameLogic/PlayerModel/PlayerModelManager.cs b/NitroxClient/GameLogic/PlayerModel/PlayerModelManager.cs index df0abd867b..b232622894 100644 --- a/NitroxClient/GameLogic/PlayerModel/PlayerModelManager.cs +++ b/NitroxClient/GameLogic/PlayerModel/PlayerModelManager.cs @@ -8,7 +8,6 @@ using NitroxClient.GameLogic.PlayerModel.Equipment; using NitroxClient.GameLogic.PlayerModel.Equipment.Abstract; using NitroxClient.MonoBehaviours; -using NitroxModel.DataStructures; using NitroxModel_Subnautica.DataStructures; using UnityEngine; using Object = UnityEngine.Object; diff --git a/NitroxClient/GameLogic/PlayerPreferences/PlayerPreference.cs b/NitroxClient/GameLogic/PlayerPreferences/PlayerPreference.cs index ff815cd69b..de084c8487 100644 --- a/NitroxClient/GameLogic/PlayerPreferences/PlayerPreference.cs +++ b/NitroxClient/GameLogic/PlayerPreferences/PlayerPreference.cs @@ -75,7 +75,7 @@ public override bool Equals(object obj) return Equals((PlayerPreference)obj); } - + public override int GetHashCode() { unchecked @@ -95,6 +95,6 @@ public static class PlayerPreferenceExtensions public static Color PreferredColor(this PlayerPreference playerPreference) { return new Color(playerPreference.RedAdditive, playerPreference.GreenAdditive, playerPreference.BlueAdditive); - } + } } } diff --git a/NitroxClient/GameLogic/PlayerPreferences/PlayerPreferenceManager.cs b/NitroxClient/GameLogic/PlayerPreferences/PlayerPreferenceManager.cs index d53c5843b7..7d2d4f3d36 100644 --- a/NitroxClient/GameLogic/PlayerPreferences/PlayerPreferenceManager.cs +++ b/NitroxClient/GameLogic/PlayerPreferences/PlayerPreferenceManager.cs @@ -45,9 +45,8 @@ public PlayerPreference GetPreference(string ipAddress) { Validate.NotNull(ipAddress); - PlayerPreference preference; - if (state.Preferences.TryGetValue(ipAddress, out preference)) + if (state.Preferences.TryGetValue(ipAddress, out PlayerPreference preference)) { return preference.Clone(); } diff --git a/NitroxClient/GameLogic/SeamothModulesEvent.cs b/NitroxClient/GameLogic/SeamothModulesEvent.cs index 25dee61c9f..9caa206580 100644 --- a/NitroxClient/GameLogic/SeamothModulesEvent.cs +++ b/NitroxClient/GameLogic/SeamothModulesEvent.cs @@ -3,7 +3,6 @@ using NitroxModel.DataStructures; using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures; -using NitroxModel_Subnautica.Helper; using UnityEngine; namespace NitroxClient.GameLogic diff --git a/NitroxClient/GameLogic/Simulation/LockRequest.cs b/NitroxClient/GameLogic/Simulation/LockRequest.cs index 499fd64271..9ccda1eb19 100644 --- a/NitroxClient/GameLogic/Simulation/LockRequest.cs +++ b/NitroxClient/GameLogic/Simulation/LockRequest.cs @@ -23,5 +23,5 @@ public override void LockRequestComplete(NitroxId id, bool lockAquired) } } - } + } } diff --git a/NitroxClient/GameLogic/SimulationOwnership.cs b/NitroxClient/GameLogic/SimulationOwnership.cs index 85caf8f48b..ab47750d6e 100644 --- a/NitroxClient/GameLogic/SimulationOwnership.cs +++ b/NitroxClient/GameLogic/SimulationOwnership.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using NitroxClient.Communication.Abstract; -using NitroxModel.Packets; +using NitroxClient.GameLogic.Simulation; using NitroxModel.DataStructures; using NitroxModel.Logger; -using NitroxClient.GameLogic.Simulation; +using NitroxModel.Packets; namespace NitroxClient.GameLogic { @@ -13,7 +13,7 @@ public class SimulationOwnership private readonly IPacketSender packetSender; private readonly Dictionary simulatedIdsByLockType = new Dictionary(); private readonly Dictionary lockRequestsById = new Dictionary(); - + public SimulationOwnership(IMultiplayerSession muliplayerSession, IPacketSender packetSender) { this.muliplayerSession = muliplayerSession; diff --git a/NitroxClient/GameLogic/Spawning/DefaultEntitySpawner.cs b/NitroxClient/GameLogic/Spawning/DefaultEntitySpawner.cs index 34d5193a7d..51b6d7c57c 100644 --- a/NitroxClient/GameLogic/Spawning/DefaultEntitySpawner.cs +++ b/NitroxClient/GameLogic/Spawning/DefaultEntitySpawner.cs @@ -3,7 +3,6 @@ using NitroxModel.DataStructures.GameLogic; using NitroxModel.DataStructures.Util; using NitroxModel_Subnautica.DataStructures; -using NitroxModel_Subnautica.Helper; using UnityEngine; using UWE; @@ -54,9 +53,8 @@ public Optional Spawn(Entity entity, Optional parent, En private GameObject CreateGameObject(TechType techType, string classId) { - GameObject prefab; IPrefabRequest prefabRequest = PrefabDatabase.GetPrefabAsync(classId); - if (!prefabRequest.TryGetPrefab(out prefab)) + if (!prefabRequest.TryGetPrefab(out GameObject prefab)) { prefab = CraftData.GetPrefabForTechType(techType, false); diff --git a/NitroxClient/GameLogic/Spawning/EntitySpawnerResolver.cs b/NitroxClient/GameLogic/Spawning/EntitySpawnerResolver.cs index ace18b3f17..4e0210716d 100644 --- a/NitroxClient/GameLogic/Spawning/EntitySpawnerResolver.cs +++ b/NitroxClient/GameLogic/Spawning/EntitySpawnerResolver.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using NitroxModel.DataStructures.GameLogic; using NitroxModel_Subnautica.DataStructures; -using NitroxModel_Subnautica.Helper; namespace NitroxClient.GameLogic.Spawning { @@ -11,11 +10,11 @@ public class EntitySpawnerResolver private readonly SerializedEntitySpawner serializedEntitySpawner = new SerializedEntitySpawner(); private readonly ExistingGameObjectSpawner existingGameObjectSpawner = new ExistingGameObjectSpawner(); private readonly CellRootSpawner cellRootSpawner = new CellRootSpawner(); - + private readonly Dictionary customSpawnersByTechType = new Dictionary(); public EntitySpawnerResolver() - { + { customSpawnersByTechType[TechType.Crash] = new CrashEntitySpawner(); customSpawnersByTechType[TechType.Reefback] = new ReefbackEntitySpawner(defaultEntitySpawner); } diff --git a/NitroxClient/GameLogic/Spawning/ExistingGameObjectSpawner.cs b/NitroxClient/GameLogic/Spawning/ExistingGameObjectSpawner.cs index fed6a5faab..3418f88bf5 100644 --- a/NitroxClient/GameLogic/Spawning/ExistingGameObjectSpawner.cs +++ b/NitroxClient/GameLogic/Spawning/ExistingGameObjectSpawner.cs @@ -26,9 +26,9 @@ public Optional Spawn(Entity entity, Optional parent, En Log.Error($"Parent {parent.Value} did not have a child at index {entity.ExistingGameObjectChildIndex.Value}"); return Optional.Empty; } - + GameObject gameObject = parent.Value.transform.GetChild(entity.ExistingGameObjectChildIndex.Value).gameObject; - + NitroxEntity.SetNewId(gameObject, entity.Id); Optional metadataProcessor = EntityMetadataProcessor.FromMetaData(entity.Metadata); @@ -37,7 +37,7 @@ public Optional Spawn(Entity entity, Optional parent, En { metadataProcessor.Value.ProcessMetadata(gameObject, entity.Metadata); } - + return Optional.Of(gameObject); } diff --git a/NitroxClient/GameLogic/Spawning/Metadata/EntityMetadataProcessor.cs b/NitroxClient/GameLogic/Spawning/Metadata/EntityMetadataProcessor.cs index b31674175f..603e3d529e 100644 --- a/NitroxClient/GameLogic/Spawning/Metadata/EntityMetadataProcessor.cs +++ b/NitroxClient/GameLogic/Spawning/Metadata/EntityMetadataProcessor.cs @@ -11,7 +11,7 @@ namespace NitroxClient.GameLogic.Spawning.Metadata public abstract class EntityMetadataProcessor { public abstract void ProcessMetadata(GameObject gameObject, EntityMetadata metadata); - + private static Dictionary> processorsByType = new Dictionary>(); static EntityMetadataProcessor() @@ -19,14 +19,14 @@ static EntityMetadataProcessor() IEnumerable processors = Assembly.GetExecutingAssembly() .GetTypes() .Where(t => typeof(EntityMetadataProcessor).IsAssignableFrom(t) && - t.IsClass && + t.IsClass && !t.IsAbstract ) .Select(Activator.CreateInstance) .Cast(); foreach (EntityMetadataProcessor processor in processors) - { + { Type metadataType = processor.GetType().BaseType.GetGenericArguments()[0]; processorsByType.Add(metadataType, Optional.Of(processor)); } @@ -34,9 +34,8 @@ static EntityMetadataProcessor() public static Optional FromMetaData(EntityMetadata metadata) { - Optional processor; - if (metadata != null && processorsByType.TryGetValue(metadata.GetType(), out processor)) + if (metadata != null && processorsByType.TryGetValue(metadata.GetType(), out Optional processor)) { return processor; } diff --git a/NitroxClient/GameLogic/Spawning/Metadata/StarshipDoorMetadataProcessor.cs b/NitroxClient/GameLogic/Spawning/Metadata/StarshipDoorMetadataProcessor.cs index d2eeb28a83..25231abac8 100644 --- a/NitroxClient/GameLogic/Spawning/Metadata/StarshipDoorMetadataProcessor.cs +++ b/NitroxClient/GameLogic/Spawning/Metadata/StarshipDoorMetadataProcessor.cs @@ -1,5 +1,4 @@ using NitroxModel.DataStructures.GameLogic.Entities.Metadata; -using NitroxModel.Logger; using UnityEngine; namespace NitroxClient.GameLogic.Spawning.Metadata diff --git a/NitroxClient/GameLogic/Spawning/Metadata/WeldableWallPanelGenericMetadataProcessor.cs b/NitroxClient/GameLogic/Spawning/Metadata/WeldableWallPanelGenericMetadataProcessor.cs index 9a3323600e..acf4090556 100644 --- a/NitroxClient/GameLogic/Spawning/Metadata/WeldableWallPanelGenericMetadataProcessor.cs +++ b/NitroxClient/GameLogic/Spawning/Metadata/WeldableWallPanelGenericMetadataProcessor.cs @@ -1,5 +1,4 @@ using NitroxModel.DataStructures.GameLogic.Entities.Metadata; -using NitroxModel.Logger; using UnityEngine; namespace NitroxClient.GameLogic.Spawning.Metadata diff --git a/NitroxClient/GameLogic/Spawning/ReefbackEntitySpawner.cs b/NitroxClient/GameLogic/Spawning/ReefbackEntitySpawner.cs index 69e9c70536..07e7e5e59e 100644 --- a/NitroxClient/GameLogic/Spawning/ReefbackEntitySpawner.cs +++ b/NitroxClient/GameLogic/Spawning/ReefbackEntitySpawner.cs @@ -26,7 +26,7 @@ public Optional Spawn(Entity entity, Optional parent, En { return Optional.Empty; } - + life.initialized = true; life.ReflectionCall("SpawnPlants"); foreach (Entity childEntity in entity.ChildEntities) diff --git a/NitroxClient/GameLogic/Spawning/SerializedEntitySpawner.cs b/NitroxClient/GameLogic/Spawning/SerializedEntitySpawner.cs index e02a497189..7359d16299 100644 --- a/NitroxClient/GameLogic/Spawning/SerializedEntitySpawner.cs +++ b/NitroxClient/GameLogic/Spawning/SerializedEntitySpawner.cs @@ -8,7 +8,6 @@ using NitroxModel.DataStructures.Util; using NitroxModel.Logger; using NitroxModel_Subnautica.DataStructures; -using NitroxModel_Subnautica.Helper; using UnityEngine; namespace NitroxClient.GameLogic.Spawning diff --git a/NitroxClient/GameLogic/Terrain.cs b/NitroxClient/GameLogic/Terrain.cs index 8d8c75519a..37526fd93b 100644 --- a/NitroxClient/GameLogic/Terrain.cs +++ b/NitroxClient/GameLogic/Terrain.cs @@ -1,12 +1,11 @@ using System.Collections; using System.Collections.Generic; -using NitroxClient.Communication; +using NitroxClient.Communication.Abstract; using NitroxClient.Map; using NitroxModel.DataStructures.GameLogic; using NitroxModel.Packets; -using NitroxClient.Communication.Abstract; -using UnityEngine; using NitroxModel_Subnautica.DataStructures; +using UnityEngine; namespace NitroxClient.GameLogic { diff --git a/NitroxClient/GameLogic/Vehicles.cs b/NitroxClient/GameLogic/Vehicles.cs index b912c189c2..978b25f7d0 100644 --- a/NitroxClient/GameLogic/Vehicles.cs +++ b/NitroxClient/GameLogic/Vehicles.cs @@ -596,8 +596,7 @@ public T GetVehicles(NitroxId vehicleId) where T : VehicleModel public Optional TryGetVehicle(NitroxId vehicleId) where T : VehicleModel { - VehicleModel vehicle; - vehiclesById.TryGetValue(vehicleId, out vehicle); + vehiclesById.TryGetValue(vehicleId, out VehicleModel vehicle); return Optional.OfNullable((T)vehicle); } } diff --git a/NitroxClient/Helpers/NitroxProtobufSerializer.cs b/NitroxClient/Helpers/NitroxProtobufSerializer.cs index d484891e04..54565a9054 100644 --- a/NitroxClient/Helpers/NitroxProtobufSerializer.cs +++ b/NitroxClient/Helpers/NitroxProtobufSerializer.cs @@ -14,7 +14,7 @@ public class NitroxProtobufSerializer private readonly Dictionary knownTypes; - protected RuntimeTypeModel Model { get { return model; } } + protected RuntimeTypeModel Model => model; public NitroxProtobufSerializer(params string[] assemblies) { diff --git a/NitroxClient/MonoBehaviours/AnimationController.cs b/NitroxClient/MonoBehaviours/AnimationController.cs index 29bfada97e..09fde7a211 100644 --- a/NitroxClient/MonoBehaviours/AnimationController.cs +++ b/NitroxClient/MonoBehaviours/AnimationController.cs @@ -50,8 +50,8 @@ public void FixedUpdate() public bool this[string name] { - get { return animator.GetBool(name); } - set { animator.SetBool(name, value); } + get => animator.GetBool(name); + set => animator.SetBool(name, value); } internal void SetFloat(string name, float value) diff --git a/NitroxClient/MonoBehaviours/DiscordRP/DiscordJoinRequestGui.cs b/NitroxClient/MonoBehaviours/DiscordRP/DiscordJoinRequestGui.cs index 0f90aa4907..fc6380d06e 100644 --- a/NitroxClient/MonoBehaviours/DiscordRP/DiscordJoinRequestGui.cs +++ b/NitroxClient/MonoBehaviours/DiscordRP/DiscordJoinRequestGui.cs @@ -1,7 +1,6 @@ using System.Collections; using NitroxClient.MonoBehaviours.DiscordRP; using NitroxClient.Unity.Helper; -using NitroxModel.Helper; using NitroxModel_Subnautica.Helper; using UnityEngine; using UnityEngine.Networking; diff --git a/NitroxClient/MonoBehaviours/EntityPositionBroadcaster.cs b/NitroxClient/MonoBehaviours/EntityPositionBroadcaster.cs index da6063026a..4b0038c2e1 100644 --- a/NitroxClient/MonoBehaviours/EntityPositionBroadcaster.cs +++ b/NitroxClient/MonoBehaviours/EntityPositionBroadcaster.cs @@ -39,7 +39,7 @@ public void Update() public static void WatchEntity(NitroxId id, GameObject gameObject) { watchingEntitiesById[id] = gameObject; - + RemotelyControlled remotelyControlled = gameObject.GetComponent(); Object.Destroy(remotelyControlled); } diff --git a/NitroxClient/MonoBehaviours/Gui/Chat/PlayerChat.cs b/NitroxClient/MonoBehaviours/Gui/Chat/PlayerChat.cs index 12948a6bc9..3aed41b6d7 100644 --- a/NitroxClient/MonoBehaviours/Gui/Chat/PlayerChat.cs +++ b/NitroxClient/MonoBehaviours/Gui/Chat/PlayerChat.cs @@ -28,8 +28,8 @@ public class PlayerChat : uGUI_InputGroup public string InputText { - get { return inputField.text; } - set { inputField.text = value; } + get => inputField.text; + set => inputField.text = value; } public IEnumerator SetupChatComponents() diff --git a/NitroxClient/MonoBehaviours/Gui/MainMenu/MainMenuMods.cs b/NitroxClient/MonoBehaviours/Gui/MainMenu/MainMenuMods.cs index 205216cf84..dc5855c815 100644 --- a/NitroxClient/MonoBehaviours/Gui/MainMenu/MainMenuMods.cs +++ b/NitroxClient/MonoBehaviours/Gui/MainMenu/MainMenuMods.cs @@ -1,5 +1,4 @@ -using System.Collections; -using NitroxClient.MonoBehaviours.DiscordRP; +using NitroxClient.MonoBehaviours.DiscordRP; using NitroxClient.Unity.Helper; using UnityEngine; using UnityEngine.SceneManagement; diff --git a/NitroxClient/MonoBehaviours/Multiplayer.cs b/NitroxClient/MonoBehaviours/Multiplayer.cs index b6400029fd..2386e07db5 100644 --- a/NitroxClient/MonoBehaviours/Multiplayer.cs +++ b/NitroxClient/MonoBehaviours/Multiplayer.cs @@ -18,7 +18,6 @@ using NitroxModel.Logger; using NitroxModel.Packets; using NitroxModel.Packets.Processors.Abstract; -using NitroxModel_Subnautica.Helper; using UnityEngine; using UnityEngine.SceneManagement; diff --git a/NitroxClient/MonoBehaviours/NitroxEntity.cs b/NitroxClient/MonoBehaviours/NitroxEntity.cs index b51e86c9e7..1c33a6722e 100644 --- a/NitroxClient/MonoBehaviours/NitroxEntity.cs +++ b/NitroxClient/MonoBehaviours/NitroxEntity.cs @@ -40,8 +40,7 @@ public static Optional GetObjectFrom(NitroxId id) return Optional.Empty; } - GameObject gameObject; - if (!gameObjectsById.TryGetValue(id, out gameObject)) + if (!gameObjectsById.TryGetValue(id, out GameObject gameObject)) { return Optional.Empty; } diff --git a/NitroxClient/MonoBehaviours/Overrides/MultiplayerBuilder.cs b/NitroxClient/MonoBehaviours/Overrides/MultiplayerBuilder.cs index 20fdb6f841..e2f2df7be4 100644 --- a/NitroxClient/MonoBehaviours/Overrides/MultiplayerBuilder.cs +++ b/NitroxClient/MonoBehaviours/Overrides/MultiplayerBuilder.cs @@ -2,15 +2,15 @@ // ReSharper disable InconsistentNaming using System.Collections.Generic; +using NitroxModel.DataStructures.GameLogic.Buildings.Rotation; using NitroxModel.DataStructures.Util; using NitroxModel.Helper; using NitroxModel.Logger; -using UnityEngine; -using UWE; -using NitroxModel.DataStructures.GameLogic.Buildings.Rotation; +using NitroxModel_Subnautica.DataStructures; using NitroxModel_Subnautica.DataStructures.GameLogic.Buildings.Rotation; using NitroxModel_Subnautica.DataStructures.GameLogic.Buildings.Rotation.Metadata; -using NitroxModel_Subnautica.DataStructures; +using UnityEngine; +using UWE; namespace NitroxClient.MonoBehaviours.Overrides { @@ -246,7 +246,7 @@ private static void ApplyRotationMetadata(GameObject ghostModel, RotationMetadat mapRoom.ReflectionSet("connectionMask", mapRoomRotationMetadata.ConnectionMask); Base ghostBase = (Base)mapRoom.ReflectionGet("ghostBase"); - + ghostBase.SetCell(Int3.zero, (Base.CellType)mapRoomRotationMetadata.CellType); mapRoom.ReflectionCall("RebuildGhostGeometry"); } @@ -267,11 +267,11 @@ private static void ApplyRotationMetadata(GameObject ghostModel, RotationMetadat Base.Face face = new Base.Face(baseModuleRotationMetadata.Cell.ToUnity(), (Base.Direction)baseModuleRotationMetadata.Direction); faceGhost.anchoredFace = face; - + Base ghostBase = (Base)faceGhost.ReflectionGet("ghostBase"); Base.FaceType faceType = (Base.FaceType)baseModuleRotationMetadata.FaceType; ghostBase.SetFace(face, faceType); - + faceGhost.ReflectionCall("RebuildGhostGeometry"); } } diff --git a/NitroxClient/MonoBehaviours/PlayerMovement.cs b/NitroxClient/MonoBehaviours/PlayerMovement.cs index a9fe9a5b73..eb0f0680af 100644 --- a/NitroxClient/MonoBehaviours/PlayerMovement.cs +++ b/NitroxClient/MonoBehaviours/PlayerMovement.cs @@ -121,7 +121,7 @@ private Optional GetVehicleMovement() { id = NitroxEntity.GetId(sub.gameObject); position = sub.gameObject.transform.position; - rotation = sub.gameObject.transform.rotation; + rotation = sub.gameObject.transform.rotation; Rigidbody rigidbody = sub.GetComponent(); velocity = rigidbody.velocity; angularVelocity = rigidbody.angularVelocity; diff --git a/NitroxClient/MonoBehaviours/RemotelyControlled.cs b/NitroxClient/MonoBehaviours/RemotelyControlled.cs index 873274cba0..39808b7c39 100644 --- a/NitroxClient/MonoBehaviours/RemotelyControlled.cs +++ b/NitroxClient/MonoBehaviours/RemotelyControlled.cs @@ -6,7 +6,7 @@ namespace NitroxClient.MonoBehaviours { public class RemotelyControlled : MonoBehaviour { - private SmoothVector smoothPosition = new SmoothVector(); + private SmoothVector smoothPosition = new SmoothVector(); private SmoothRotation smoothRotation = new SmoothRotation(); private SwimBehaviour swimBehaviour; @@ -42,7 +42,7 @@ public void UpdateOrientation(Vector3 position, Quaternion rotation) gameObject.transform.position = position; gameObject.transform.rotation = rotation; } - + if (swimBehaviour) { swimBehaviour.SwimTo(position, 3f); diff --git a/NitroxClient/MonoBehaviours/ThrottledBuilder.cs b/NitroxClient/MonoBehaviours/ThrottledBuilder.cs index c8d5290056..ef8c244a1b 100644 --- a/NitroxClient/MonoBehaviours/ThrottledBuilder.cs +++ b/NitroxClient/MonoBehaviours/ThrottledBuilder.cs @@ -1,22 +1,21 @@ -using NitroxClient.Communication.Abstract; +using System; +using System.Reflection; +using NitroxClient.Communication.Abstract; using NitroxClient.GameLogic.Bases; +using NitroxClient.GameLogic.Bases.Spawning; using NitroxClient.GameLogic.Helper; using NitroxClient.MonoBehaviours.Overrides; using NitroxClient.Unity.Helper; using NitroxModel.Core; +using NitroxModel.DataStructures; using NitroxModel.DataStructures.GameLogic; using NitroxModel.DataStructures.Util; using NitroxModel.Helper; using NitroxModel.Logger; using NitroxModel.Packets; -using System; -using System.Reflection; +using NitroxModel_Subnautica.DataStructures; using UnityEngine; using static NitroxClient.GameLogic.Helper.TransientLocalObjectManager; -using NitroxModel_Subnautica.Helper; -using NitroxModel.DataStructures; -using NitroxClient.GameLogic.Bases.Spawning; -using NitroxModel_Subnautica.DataStructures; namespace NitroxClient.MonoBehaviours { @@ -44,7 +43,7 @@ public void Start() public void Update() { - if(LargeWorldStreamer.main == null || !LargeWorldStreamer.main.IsReady() || !LargeWorldStreamer.main.IsWorldSettled()) + if (LargeWorldStreamer.main == null || !LargeWorldStreamer.main.IsReady() || !LargeWorldStreamer.main.IsWorldSettled()) { return; } @@ -53,7 +52,7 @@ public void Update() ProcessBuildEventsUntilFrameBlocked(); - if(queueHadItems && buildEvents.Count == 0 && QueueDrained != null) + if (queueHadItems && buildEvents.Count == 0 && QueueDrained != null) { QueueDrained(this, new EventArgs()); } @@ -121,7 +120,7 @@ private void ActionBuildEvent(BuildEvent buildEvent) private void PlaceBasePiece(BasePiecePlacedEvent basePiecePlacedBuildEvent) { Log.Debug($"BuildBasePiece - {basePiecePlacedBuildEvent.BasePiece.Id} type: {basePiecePlacedBuildEvent.BasePiece.TechType} parentId: {basePiecePlacedBuildEvent.BasePiece.ParentId.OrElse(null)}"); - + BasePiece basePiece = basePiecePlacedBuildEvent.BasePiece; GameObject buildPrefab = CraftData.GetBuildPrefab(basePiece.TechType.ToUnity()); MultiplayerBuilder.overridePosition = basePiece.ItemPosition.ToUnity(); @@ -140,14 +139,14 @@ private void PlaceBasePiece(BasePiecePlacedEvent basePiecePlacedBuildEvent) { parentBase = NitroxEntity.GetObjectFrom(basePiece.ParentId.Value).OrElse(null); } - + Constructable constructable; GameObject gameObject; if (basePiece.IsFurniture) { SubRoot subRoot = (parentBase != null) ? parentBase.GetComponent() : null; - + gameObject = MultiplayerBuilder.TryPlaceFurniture(subRoot); constructable = gameObject.RequireComponentInParent(); } @@ -163,7 +162,7 @@ private void PlaceBasePiece(BasePiecePlacedEvent basePiecePlacedBuildEvent) } NitroxEntity.SetNewId(gameObject, basePiece.Id); - + /** * Manually call start to initialize the object as we may need to interact with it within the same frame. */ @@ -188,7 +187,7 @@ private void ConstructionCompleted(ConstructionCompletedEvent constructionComple // must fetch BEFORE setState or else the BaseGhost gets destroyed BaseGhost baseGhost = constructing.GetComponentInChildren(); - if(baseGhost) + if (baseGhost) { latestCell = baseGhost.TargetOffset; latestBase = baseGhost.TargetBase; @@ -196,14 +195,14 @@ private void ConstructionCompleted(ConstructionCompletedEvent constructionComple constructableBase.constructedAmount = 1f; constructableBase.SetState(true, true); - - if(latestBase == null) + + if (latestBase == null) { Optional opConstructedBase = TransientLocalObjectManager.Get(TransientObjectType.BASE_GHOST_NEWLY_CONSTRUCTED_BASE_GAMEOBJECT); latestBase = ((GameObject)opConstructedBase.Value).GetComponent(); Validate.NotNull(latestBase, "latestBase can not be null"); } - + Transform cellTransform = latestBase.GetCellObject(latestCell); if (latestCell == default(Int3) || cellTransform == null) @@ -229,14 +228,14 @@ private void ConstructionCompleted(ConstructionCompletedEvent constructionComple break; } } - + Validate.NotNull(finishedPiece, $"Could not find finished piece in cell {latestCell} when constructing {constructionCompleted.PieceId}"); Log.Debug($"Construction completed on a base piece: {constructionCompleted.PieceId} {finishedPiece.name}"); UnityEngine.Object.Destroy(constructableBase.gameObject); NitroxEntity.SetNewId(finishedPiece, constructionCompleted.PieceId); - + BasePieceSpawnProcessor customSpawnProcessor = BasePieceSpawnProcessor.From(finishedPiece.GetComponent()); customSpawnProcessor.SpawnPostProcess(latestBase, latestCell, finishedPiece); } @@ -248,7 +247,7 @@ private void ConstructionCompleted(ConstructionCompletedEvent constructionComple Log.Debug($"Construction completed on a piece of furniture: {constructionCompleted.PieceId} {constructable.gameObject.name}"); } - + if (constructionCompleted.BaseId != null && !NitroxEntity.GetObjectFrom(constructionCompleted.BaseId).HasValue) { Log.Debug($"Creating base: {constructionCompleted.BaseId}"); @@ -303,7 +302,7 @@ private void ConstructionAmountChanged(ConstructionAmountChangedEvent amountChan { Constructable constructable = constructing.GetComponentInChildren(); constructable.constructedAmount = amountChanged.Amount; - constructable.Construct(); + constructable.Construct(); } } diff --git a/NitroxClient/NitroxClient.csproj b/NitroxClient/NitroxClient.csproj index 4d7759ed35..28047845da 100644 --- a/NitroxClient/NitroxClient.csproj +++ b/NitroxClient/NitroxClient.csproj @@ -19,139 +19,14 @@ prompt 4 - - - $(SubnauticaManaged)\iTween.dll - false - - - $(SubnauticaManaged)\LitJson.dll - false - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -165,170 +40,275 @@ - + + - - + + + + - + + + + + + + + + + + - - + + + + + + + + + + + - - - - - - - - - - - - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - + + + + + + + + + + - - + + + + - - + - + - - - - + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + - - - + + + + + + + + + + + + + + + - - + + + + + + - - + + + - + + + + + + + + + + + + + + + + + + + - + + + + + @@ -339,10 +319,12 @@ + + @@ -350,49 +332,59 @@ True Resources.resx + - + + - - - {b0a014e4-0392-4e35-aa42-8fb5a40417e0} - LiteNetLib - - - {0a377218-6b36-4522-89a3-a39cfc999209} - NitroxModel-Subnautica - - - + ResXFileCodeGenerator Designer Resources.Designer.cs - + - + 4.9.4 - + + + {b0a014e4-0392-4e35-aa42-8fb5a40417e0} + LiteNetLib + + + {0a377218-6b36-4522-89a3-a39cfc999209} + NitroxModel-Subnautica + + + + + $(SubnauticaManaged)\iTween.dll + false + + + $(SubnauticaManaged)\LitJson.dll + false + + + + + + + + - - + \ No newline at end of file diff --git a/NitroxClient/Unity/Helper/DebugUtils.cs b/NitroxClient/Unity/Helper/DebugUtils.cs index 93bc2574ce..3effc638fe 100644 --- a/NitroxClient/Unity/Helper/DebugUtils.cs +++ b/NitroxClient/Unity/Helper/DebugUtils.cs @@ -1,6 +1,6 @@ -using NitroxModel.Logger; +using NitroxClient.MonoBehaviours; +using NitroxModel.Logger; using UnityEngine; -using NitroxClient.MonoBehaviours; namespace NitroxClient.Unity.Helper { diff --git a/NitroxClient/Unity/Smoothing/ExosuitSmoothRotation.cs b/NitroxClient/Unity/Smoothing/ExosuitSmoothRotation.cs index a0faea90b9..9e2bf88ac3 100644 --- a/NitroxClient/Unity/Smoothing/ExosuitSmoothRotation.cs +++ b/NitroxClient/Unity/Smoothing/ExosuitSmoothRotation.cs @@ -9,7 +9,7 @@ class ExosuitSmoothRotation : SmoothRotation private Quaternion target; public new Quaternion Target { - get { return target; } + get => target; set { timeCount = 0; diff --git a/NitroxLauncher/App.xaml.cs b/NitroxLauncher/App.xaml.cs index 308f806cc5..49b4a682d8 100644 --- a/NitroxLauncher/App.xaml.cs +++ b/NitroxLauncher/App.xaml.cs @@ -12,7 +12,7 @@ public partial class App : Application protected override void OnStartup(StartupEventArgs e) { Log.Setup(); - + // Set default style for all windows to the style with the target type 'Window' (in App.xaml). FrameworkElement.StyleProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata diff --git a/NitroxLauncher/NitroxLauncher.csproj b/NitroxLauncher/NitroxLauncher.csproj index 8be43944fd..99e8f82cd1 100644 --- a/NitroxLauncher/NitroxLauncher.csproj +++ b/NitroxLauncher/NitroxLauncher.csproj @@ -23,69 +23,49 @@ 4 - - + icon.ico - - - - - - True - - - True - - - - - - - - - - - - 4.0 - - - - - - + MSBuild:Compile Designer + + App.xaml + Code + + + - - LaunchGamePage.xaml - - - OptionPage.xaml + + + + + Code - - ServerConsolePage.xaml + + True + True + Resources.resx - - ServerPage.xaml + + True + Settings.settings + True - + + MSBuild:Compile Designer - - App.xaml - Code - MainWindow.xaml Code @@ -94,39 +74,78 @@ Designer MSBuild:Compile + + LaunchGamePage.xaml + Designer MSBuild:Compile + + OptionPage.xaml + Designer MSBuild:Compile + + ServerConsolePage.xaml + Designer MSBuild:Compile - - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True + + ServerPage.xaml + + PublicResXFileCodeGenerator Resources.Designer.cs + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -136,9 +155,6 @@ - - - @@ -149,44 +165,15 @@ - - - - - - - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - - - - - - - - - - - - - - + + + + - - + + - + {e4226522-9189-410b-93b2-792942fbd588} Nitrox.Bootloader @@ -195,82 +182,66 @@ {ed5034bd-66b5-4596-94b7-66a28d3eff49} NitroxClient - - {0a377218-6b36-4522-89a3-a39cfc999209} - NitroxModel-Subnautica - {b16f4de7-21ad-4fef-955b-0a5a365fa4e3} NitroxModel + + {0a377218-6b36-4522-89a3-a39cfc999209} + NitroxModel-Subnautica + {be983e25-24cc-4fc8-9017-61eec43dd618} NitroxPatcher - - {eff1d7a5-efd6-413a-8d5f-dc2408e4c9b7} - NitroxServer-Subnautica - {0fc864b0-694e-4fca-b78c-8ef98bc6f262} NitroxServer + + {eff1d7a5-efd6-413a-8d5f-dc2408e4c9b7} + NitroxServer-Subnautica + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 3.3.2 - - 2.0.4.0 - 1.1.2 1.1.1 + + 2.0.4.0 + + + + + + + + + + + + + + + + + + True + + + True + + + + 4.0 + + @@ -292,8 +263,8 @@ - + diff --git a/NitroxLauncher/PageBase.cs b/NitroxLauncher/PageBase.cs index e24cc95d76..ac8e42d01b 100644 --- a/NitroxLauncher/PageBase.cs +++ b/NitroxLauncher/PageBase.cs @@ -4,6 +4,6 @@ namespace NitroxLauncher { public abstract class PageBase : Page { - + } } diff --git a/NitroxLauncher/Patching/NitroxEntryPatch.cs b/NitroxLauncher/Patching/NitroxEntryPatch.cs index 73ab6df4d3..1ec859a506 100644 --- a/NitroxLauncher/Patching/NitroxEntryPatch.cs +++ b/NitroxLauncher/Patching/NitroxEntryPatch.cs @@ -89,7 +89,7 @@ private Exception RetryWait(Action action, int interval, int retries = 0) } return lastException; } - + public void Remove() { string assemblyCSharp = Path.Combine(subnauticaManagedPath, GAME_ASSEMBLY_NAME); @@ -113,7 +113,7 @@ public void Remove() File.SetAttributes(assemblyCSharp, FileAttributes.Normal); } - + FileSystem.Instance.ReplaceFile(modifiedAssemblyCSharp, assemblyCSharp); } diff --git a/NitroxModel-Subnautica/DataStructures/DataExtensions.cs b/NitroxModel-Subnautica/DataStructures/DataExtensions.cs index 882c7d051d..1ed788357d 100644 --- a/NitroxModel-Subnautica/DataStructures/DataExtensions.cs +++ b/NitroxModel-Subnautica/DataStructures/DataExtensions.cs @@ -36,12 +36,12 @@ public static TechType ToUnity(this NitroxTechType v) { return (TechType)Enum.Parse(typeof(TechType), v.Name); } - + public static Quaternion ToUnity(this NitroxQuaternion v) { return new Quaternion(v.X, v.Y, v.Z, v.W); } - + public static NitroxQuaternion ToDto(this Quaternion v) { return new NitroxQuaternion(v.x, v.y, v.z, v.w); @@ -51,7 +51,7 @@ public static NitroxColor ToDto(this Color v) { return new NitroxColor(v.r, v.g, v.b, v.a); } - + public static Color ToUnity(this NitroxColor v) { return new Color(v.R, v.G, v.B, v.A); @@ -73,7 +73,7 @@ public static NitroxVector3[] ToDto(this Vector3[] v) { return new NitroxVector3[0]; } - + NitroxVector3[] result = new NitroxVector3[v.Length]; for (int i = 0; i < v.Length; i++) { @@ -81,14 +81,14 @@ public static NitroxVector3[] ToDto(this Vector3[] v) } return result; } - + public static Vector3[] ToUnity(this NitroxVector3[] v) { if (v == null) { return new Vector3[0]; } - + Vector3[] result = new Vector3[v.Length]; for (int i = 0; i < v.Length; i++) { diff --git a/NitroxModel-Subnautica/DataStructures/GameLogic/Buildings/Rotation/Metadata/BaseModuleRotationMetadata.cs b/NitroxModel-Subnautica/DataStructures/GameLogic/Buildings/Rotation/Metadata/BaseModuleRotationMetadata.cs index 8f4d555d8c..072aad3a07 100644 --- a/NitroxModel-Subnautica/DataStructures/GameLogic/Buildings/Rotation/Metadata/BaseModuleRotationMetadata.cs +++ b/NitroxModel-Subnautica/DataStructures/GameLogic/Buildings/Rotation/Metadata/BaseModuleRotationMetadata.cs @@ -1,7 +1,7 @@ -using ProtoBufNet; -using System; -using NitroxModel.DataStructures.GameLogic.Buildings.Rotation; +using System; using NitroxModel.DataStructures; +using NitroxModel.DataStructures.GameLogic.Buildings.Rotation; +using ProtoBufNet; namespace NitroxModel_Subnautica.DataStructures.GameLogic.Buildings.Rotation { diff --git a/NitroxModel-Subnautica/DataStructures/GameLogic/Buildings/Rotation/Metadata/CorridorRotationMetadata.cs b/NitroxModel-Subnautica/DataStructures/GameLogic/Buildings/Rotation/Metadata/CorridorRotationMetadata.cs index eb24ccdca3..2b78cbc0e4 100644 --- a/NitroxModel-Subnautica/DataStructures/GameLogic/Buildings/Rotation/Metadata/CorridorRotationMetadata.cs +++ b/NitroxModel-Subnautica/DataStructures/GameLogic/Buildings/Rotation/Metadata/CorridorRotationMetadata.cs @@ -1,6 +1,6 @@ -using ProtoBufNet; -using System; +using System; using NitroxModel.DataStructures.GameLogic.Buildings.Rotation; +using ProtoBufNet; namespace NitroxModel_Subnautica.DataStructures.GameLogic.Buildings.Rotation { diff --git a/NitroxModel-Subnautica/DataStructures/GameLogic/Buildings/Rotation/Metadata/MapRoomRotationMetadata.cs b/NitroxModel-Subnautica/DataStructures/GameLogic/Buildings/Rotation/Metadata/MapRoomRotationMetadata.cs index f19ee21a73..307b872f22 100644 --- a/NitroxModel-Subnautica/DataStructures/GameLogic/Buildings/Rotation/Metadata/MapRoomRotationMetadata.cs +++ b/NitroxModel-Subnautica/DataStructures/GameLogic/Buildings/Rotation/Metadata/MapRoomRotationMetadata.cs @@ -1,6 +1,6 @@ -using ProtoBufNet; -using System; +using System; using NitroxModel.DataStructures.GameLogic.Buildings.Rotation; +using ProtoBufNet; namespace NitroxModel_Subnautica.DataStructures.GameLogic.Buildings.Rotation { diff --git a/NitroxModel-Subnautica/DataStructures/GameLogic/Entities/SubnauticaUwePrefabFactory.cs b/NitroxModel-Subnautica/DataStructures/GameLogic/Entities/SubnauticaUwePrefabFactory.cs index f0da8eff40..05d2a6cc31 100644 --- a/NitroxModel-Subnautica/DataStructures/GameLogic/Entities/SubnauticaUwePrefabFactory.cs +++ b/NitroxModel-Subnautica/DataStructures/GameLogic/Entities/SubnauticaUwePrefabFactory.cs @@ -20,22 +20,21 @@ public SubnauticaUwePrefabFactory(string lootDistributionJson) public override List GetPossiblePrefabs(string biome) { List prefabs = new List(); - + if (biome == null) { return prefabs; } - DstData dstData; BiomeType biomeType = (BiomeType)Enum.Parse(typeof(BiomeType), biome); - if (lootDistributionData.GetBiomeLoot(biomeType, out dstData)) + if (lootDistributionData.GetBiomeLoot(biomeType, out DstData dstData)) { - foreach(PrefabData prefabData in dstData.prefabs) + foreach (PrefabData prefabData in dstData.prefabs) { - UwePrefab prefab = new UwePrefab(prefabData.classId, prefabData.probability, prefabData.count); - prefabs.Add(prefab); + UwePrefab prefab = new UwePrefab(prefabData.classId, prefabData.probability, prefabData.count); + prefabs.Add(prefab); } } @@ -46,7 +45,7 @@ private LootDistributionData GetLootDistributionData(string lootDistributionJson { ForceCultureOverride(); JsonMapper.RegisterImporter((double value) => Convert.ToSingle(value)); - + Dictionary result = JsonMapper.ToObject>(lootDistributionJson); LootDistributionData lootDistributionData = new LootDistributionData(); diff --git a/NitroxModel-Subnautica/DataStructures/GameLogic/ExoSuitMovementData.cs b/NitroxModel-Subnautica/DataStructures/GameLogic/ExoSuitMovementData.cs index 083f5e5c13..2cc2519cea 100644 --- a/NitroxModel-Subnautica/DataStructures/GameLogic/ExoSuitMovementData.cs +++ b/NitroxModel-Subnautica/DataStructures/GameLogic/ExoSuitMovementData.cs @@ -1,7 +1,7 @@ using System; +using NitroxModel.DataStructures; using NitroxModel.DataStructures.GameLogic; using ProtoBufNet; -using NitroxModel.DataStructures; namespace NitroxModel_Subnautica.DataStructures.GameLogic { diff --git a/NitroxModel-Subnautica/DataStructures/GameLogic/ExosuitModel.cs b/NitroxModel-Subnautica/DataStructures/GameLogic/ExosuitModel.cs index 1536b65f23..1b2c2e3e39 100644 --- a/NitroxModel-Subnautica/DataStructures/GameLogic/ExosuitModel.cs +++ b/NitroxModel-Subnautica/DataStructures/GameLogic/ExosuitModel.cs @@ -1,9 +1,9 @@ -using NitroxModel.DataStructures.GameLogic; -using NitroxModel.DataStructures.Util; -using ProtoBufNet; -using System; +using System; using System.Collections.Generic; using NitroxModel.DataStructures; +using NitroxModel.DataStructures.GameLogic; +using NitroxModel.DataStructures.Util; +using ProtoBufNet; namespace NitroxModel_Subnautica.DataStructures.GameLogic { diff --git a/NitroxModel-Subnautica/DataStructures/GameLogic/NeptuneRocketModel.cs b/NitroxModel-Subnautica/DataStructures/GameLogic/NeptuneRocketModel.cs index ae0fa05dd8..793a3094e7 100644 --- a/NitroxModel-Subnautica/DataStructures/GameLogic/NeptuneRocketModel.cs +++ b/NitroxModel-Subnautica/DataStructures/GameLogic/NeptuneRocketModel.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; +using NitroxModel.DataStructures; using NitroxModel.DataStructures.GameLogic; using NitroxModel.DataStructures.Util; -using NitroxModel.DataStructures; using ProtoBufNet; namespace NitroxModel_Subnautica.DataStructures.GameLogic diff --git a/NitroxModel-Subnautica/DataStructures/GameLogic/SeamothModel.cs b/NitroxModel-Subnautica/DataStructures/GameLogic/SeamothModel.cs index fe58fa00d5..7149aba043 100644 --- a/NitroxModel-Subnautica/DataStructures/GameLogic/SeamothModel.cs +++ b/NitroxModel-Subnautica/DataStructures/GameLogic/SeamothModel.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; +using NitroxModel.DataStructures; using NitroxModel.DataStructures.GameLogic; using NitroxModel.DataStructures.Util; using ProtoBufNet; -using NitroxModel.DataStructures; namespace NitroxModel_Subnautica.DataStructures.GameLogic { diff --git a/NitroxModel-Subnautica/DataStructures/Surrogates/Vector3Surrogate.cs b/NitroxModel-Subnautica/DataStructures/Surrogates/Vector3Surrogate.cs index 08c4d04408..250d1e1f98 100644 --- a/NitroxModel-Subnautica/DataStructures/Surrogates/Vector3Surrogate.cs +++ b/NitroxModel-Subnautica/DataStructures/Surrogates/Vector3Surrogate.cs @@ -11,13 +11,13 @@ public class Vector3Surrogate : SerializationSurrogate { [ProtoMember(1)] public float X { get; private set; } - + [ProtoMember(2)] public float Y { get; private set; } - + [ProtoMember(3)] public float Z { get; private set; } - + protected override void GetObjectData(Vector3 vector3, SerializationInfo info) { info.AddValue("x", vector3.x); @@ -32,7 +32,7 @@ protected override Vector3 SetObjectData(Vector3 vector3, SerializationInfo info vector3.z = info.GetSingle("z"); return vector3; } - + public static implicit operator Vector3Surrogate(NitroxVector3 v) { return new Vector3Surrogate @@ -42,12 +42,12 @@ public static implicit operator Vector3Surrogate(NitroxVector3 v) Z = v.Z }; } - + public static implicit operator NitroxVector3(Vector3Surrogate surrogate) { return new NitroxVector3(surrogate.X, surrogate.Y, surrogate.Z); } - + public static implicit operator Vector3Surrogate(Vector3 v) { return new Vector3Surrogate @@ -57,7 +57,7 @@ public static implicit operator Vector3Surrogate(Vector3 v) Z = v.z }; } - + public static implicit operator Vector3(Vector3Surrogate surrogate) { return new Vector3(surrogate.X, surrogate.Y, surrogate.Z); diff --git a/NitroxModel-Subnautica/Helper/VehicleMovementFactory.cs b/NitroxModel-Subnautica/Helper/VehicleMovementFactory.cs index 80e450ae98..00b2bbce1a 100644 --- a/NitroxModel-Subnautica/Helper/VehicleMovementFactory.cs +++ b/NitroxModel-Subnautica/Helper/VehicleMovementFactory.cs @@ -1,8 +1,8 @@ -using NitroxModel.DataStructures.GameLogic; +using NitroxModel.DataStructures; +using NitroxModel.DataStructures.GameLogic; +using NitroxModel_Subnautica.DataStructures; using NitroxModel_Subnautica.DataStructures.GameLogic; using UnityEngine; -using NitroxModel.DataStructures; -using NitroxModel_Subnautica.DataStructures; namespace NitroxModel_Subnautica.Helper { diff --git a/NitroxModel-Subnautica/NitroxModel-Subnautica.csproj b/NitroxModel-Subnautica/NitroxModel-Subnautica.csproj index e6599ac71c..8886deff6b 100644 --- a/NitroxModel-Subnautica/NitroxModel-Subnautica.csproj +++ b/NitroxModel-Subnautica/NitroxModel-Subnautica.csproj @@ -19,22 +19,11 @@ prompt 4 - - - ..\Nitrox.Subnautica.Assets\protobuf-net.dll - - - - - - - - - + - - + + @@ -51,18 +40,18 @@ - + + - - + @@ -79,13 +68,7 @@ - - - {b16f4de7-21ad-4fef-955b-0a5a365fa4e3} - NitroxModel - - - + 4.9.4 @@ -93,5 +76,22 @@ 0.16.0 + + + {b16f4de7-21ad-4fef-955b-0a5a365fa4e3} + NitroxModel + + + + + ..\Nitrox.Subnautica.Assets\protobuf-net.dll + + + + + + + + - + \ No newline at end of file diff --git a/NitroxModel-Subnautica/Packets/CreatureActionChanged.cs b/NitroxModel-Subnautica/Packets/CreatureActionChanged.cs index 09bef38295..da182b2675 100644 --- a/NitroxModel-Subnautica/Packets/CreatureActionChanged.cs +++ b/NitroxModel-Subnautica/Packets/CreatureActionChanged.cs @@ -1,7 +1,7 @@ using System; +using NitroxModel.DataStructures; using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures.GameLogic.Creatures.Actions; -using NitroxModel.DataStructures; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/CyclopsChangeEngineMode.cs b/NitroxModel-Subnautica/Packets/CyclopsChangeEngineMode.cs index ca2ec0824c..b8993da77c 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsChangeEngineMode.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsChangeEngineMode.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/CyclopsChangeShieldMode.cs b/NitroxModel-Subnautica/Packets/CyclopsChangeShieldMode.cs index 9c11ae52cb..b5a69ee7b8 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsChangeShieldMode.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsChangeShieldMode.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/CyclopsChangeSilentRunning.cs b/NitroxModel-Subnautica/Packets/CyclopsChangeSilentRunning.cs index 7ee98bc7dd..96e6d21da9 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsChangeSilentRunning.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsChangeSilentRunning.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/CyclopsChangeSonarMode.cs b/NitroxModel-Subnautica/Packets/CyclopsChangeSonarMode.cs index a33dc919e7..ed9030fdec 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsChangeSonarMode.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsChangeSonarMode.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { @@ -9,7 +9,7 @@ public class CyclopsChangeSonarMode : Packet { public NitroxId Id { get; } public bool IsOn { get; } - + public CyclopsChangeSonarMode(NitroxId id, bool isOn) { Id = id; diff --git a/NitroxModel-Subnautica/Packets/CyclopsDamage.cs b/NitroxModel-Subnautica/Packets/CyclopsDamage.cs index d37315f3bc..59ccc3744d 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsDamage.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsDamage.cs @@ -1,8 +1,8 @@ using System; using System.Linq; +using NitroxModel.DataStructures; using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures.GameLogic; -using NitroxModel.DataStructures; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/CyclopsDamagePointRepaired.cs b/NitroxModel-Subnautica/Packets/CyclopsDamagePointRepaired.cs index 6ff98543c2..974272b1a8 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsDamagePointRepaired.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsDamagePointRepaired.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/CyclopsDecoyLaunch.cs b/NitroxModel-Subnautica/Packets/CyclopsDecoyLaunch.cs index ea84ab0a81..61a3e59cf4 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsDecoyLaunch.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsDecoyLaunch.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/CyclopsDestroyed.cs b/NitroxModel-Subnautica/Packets/CyclopsDestroyed.cs index ab23c82a82..84900efff0 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsDestroyed.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsDestroyed.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/CyclopsFireCreated.cs b/NitroxModel-Subnautica/Packets/CyclopsFireCreated.cs index 4a7bf6642d..3a62ef9b64 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsFireCreated.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsFireCreated.cs @@ -1,7 +1,7 @@ using System; +using NitroxModel.DataStructures; using NitroxModel.Packets; using NitroxModel_Subnautica.DataStructures.GameLogic; -using NitroxModel.DataStructures; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/CyclopsFireSuppression.cs b/NitroxModel-Subnautica/Packets/CyclopsFireSuppression.cs index a2d7a80d25..b5e50672cc 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsFireSuppression.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsFireSuppression.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/CyclopsSonarPing.cs b/NitroxModel-Subnautica/Packets/CyclopsSonarPing.cs index a57f7e6c24..5724a811f4 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsSonarPing.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsSonarPing.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/CyclopsToggleEngineState.cs b/NitroxModel-Subnautica/Packets/CyclopsToggleEngineState.cs index 442ae27ba1..430f9bd1a6 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsToggleEngineState.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsToggleEngineState.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/CyclopsToggleFloodLights.cs b/NitroxModel-Subnautica/Packets/CyclopsToggleFloodLights.cs index 54d02ac36b..aae33667c6 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsToggleFloodLights.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsToggleFloodLights.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/CyclopsToggleInternalLighting.cs b/NitroxModel-Subnautica/Packets/CyclopsToggleInternalLighting.cs index 822e8b872f..477738cf4f 100644 --- a/NitroxModel-Subnautica/Packets/CyclopsToggleInternalLighting.cs +++ b/NitroxModel-Subnautica/Packets/CyclopsToggleInternalLighting.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/RocketElevatorCall.cs b/NitroxModel-Subnautica/Packets/RocketElevatorCall.cs index 1738ae0b40..1edfb80bad 100644 --- a/NitroxModel-Subnautica/Packets/RocketElevatorCall.cs +++ b/NitroxModel-Subnautica/Packets/RocketElevatorCall.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/RocketPreflightComplete.cs b/NitroxModel-Subnautica/Packets/RocketPreflightComplete.cs index b1918b7a4c..de9c9bd136 100644 --- a/NitroxModel-Subnautica/Packets/RocketPreflightComplete.cs +++ b/NitroxModel-Subnautica/Packets/RocketPreflightComplete.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel-Subnautica/Packets/RocketStageUpdate.cs b/NitroxModel-Subnautica/Packets/RocketStageUpdate.cs index 1882c3cc79..f3c8920858 100644 --- a/NitroxModel-Subnautica/Packets/RocketStageUpdate.cs +++ b/NitroxModel-Subnautica/Packets/RocketStageUpdate.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.Packets; using NitroxModel.DataStructures; +using NitroxModel.Packets; namespace NitroxModel_Subnautica.Packets { diff --git a/NitroxModel/DataStructures/GameLogic/BasePiece.cs b/NitroxModel/DataStructures/GameLogic/BasePiece.cs index c04d9b0a39..d76c6cd059 100644 --- a/NitroxModel/DataStructures/GameLogic/BasePiece.cs +++ b/NitroxModel/DataStructures/GameLogic/BasePiece.cs @@ -1,8 +1,8 @@ -using NitroxModel.DataStructures.GameLogic.Buildings.Rotation; +using System; +using NitroxModel.DataStructures.GameLogic.Buildings.Metadata; +using NitroxModel.DataStructures.GameLogic.Buildings.Rotation; using NitroxModel.DataStructures.Util; using ProtoBufNet; -using System; -using NitroxModel.DataStructures.GameLogic.Buildings.Metadata; namespace NitroxModel.DataStructures.GameLogic { diff --git a/NitroxModel/DataStructures/GameLogic/DamageTakenData.cs b/NitroxModel/DataStructures/GameLogic/DamageTakenData.cs index bbbd0f6dde..810a0491f1 100644 --- a/NitroxModel/DataStructures/GameLogic/DamageTakenData.cs +++ b/NitroxModel/DataStructures/GameLogic/DamageTakenData.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using NitroxModel.DataStructures.Util; namespace NitroxModel.DataStructures.GameLogic @@ -19,7 +15,7 @@ public class DamageTakenData public override string ToString() { return $"DamageTakenData: Position: {Position}, DamageType: {DamageType}, DealerId: {DealerId}"; - + } } } diff --git a/NitroxModel/DataStructures/GameLogic/Entities/Metadata/EntityMetadata.cs b/NitroxModel/DataStructures/GameLogic/Entities/Metadata/EntityMetadata.cs index 14740f7767..037a0f6556 100644 --- a/NitroxModel/DataStructures/GameLogic/Entities/Metadata/EntityMetadata.cs +++ b/NitroxModel/DataStructures/GameLogic/Entities/Metadata/EntityMetadata.cs @@ -13,7 +13,7 @@ namespace NitroxModel.DataStructures.GameLogic.Entities.Metadata [ProtoInclude(100, typeof(PrecursorTeleporterActivationTerminalMetadata))] [ProtoInclude(110, typeof(StarshipDoorMetadata))] [ProtoInclude(120, typeof(WeldableWallPanelGenericMetadata))] - [ProtoInclude(130, typeof(IncubatorMetadata))] + [ProtoInclude(130, typeof(IncubatorMetadata))] public abstract class EntityMetadata { } diff --git a/NitroxModel/DataStructures/GameLogic/EquippedItemData.cs b/NitroxModel/DataStructures/GameLogic/EquippedItemData.cs index f327b18fe6..421e09b4be 100644 --- a/NitroxModel/DataStructures/GameLogic/EquippedItemData.cs +++ b/NitroxModel/DataStructures/GameLogic/EquippedItemData.cs @@ -1,5 +1,5 @@ -using ProtoBufNet; -using System; +using System; +using ProtoBufNet; namespace NitroxModel.DataStructures.GameLogic { diff --git a/NitroxModel/DataStructures/GameLogic/InitialRemotePlayerData.cs b/NitroxModel/DataStructures/GameLogic/InitialRemotePlayerData.cs index 6792875153..9306d06d96 100644 --- a/NitroxModel/DataStructures/GameLogic/InitialRemotePlayerData.cs +++ b/NitroxModel/DataStructures/GameLogic/InitialRemotePlayerData.cs @@ -8,7 +8,7 @@ namespace NitroxModel.DataStructures.GameLogic [Serializable] public class InitialRemotePlayerData { - public PlayerContext PlayerContext { get; set; } + public PlayerContext PlayerContext { get; set; } public NitroxVector3 Position { get; set; } public Optional SubRootId { get; } public List EquippedTechTypes { get; } diff --git a/NitroxModel/DataStructures/GameLogic/ItemData.cs b/NitroxModel/DataStructures/GameLogic/ItemData.cs index 0eeb55e944..05d4e24f05 100644 --- a/NitroxModel/DataStructures/GameLogic/ItemData.cs +++ b/NitroxModel/DataStructures/GameLogic/ItemData.cs @@ -1,5 +1,5 @@ -using ProtoBufNet; -using System; +using System; +using ProtoBufNet; namespace NitroxModel.DataStructures.GameLogic { diff --git a/NitroxModel/DataStructures/GameLogic/NitroxQuaternion.cs b/NitroxModel/DataStructures/GameLogic/NitroxQuaternion.cs index f18fcfcdfc..ad9447fcaa 100644 --- a/NitroxModel/DataStructures/GameLogic/NitroxQuaternion.cs +++ b/NitroxModel/DataStructures/GameLogic/NitroxQuaternion.cs @@ -129,11 +129,19 @@ public NitroxVector3 ToEuler() result.Z = Mathf.RAD2DEG * Mathf.Asin(2 * X * Y + 2 * Z * W); if (result.X < 0) + { result.X += 360; + } + if (result.Y < 0) + { result.Y += 360; + } + if (result.Z < 0) + { result.Z += 360; + } } return result; } diff --git a/NitroxModel/DataStructures/GameLogic/NitroxTransform.cs b/NitroxModel/DataStructures/GameLogic/NitroxTransform.cs index fd31573493..79b9e798bd 100644 --- a/NitroxModel/DataStructures/GameLogic/NitroxTransform.cs +++ b/NitroxModel/DataStructures/GameLogic/NitroxTransform.cs @@ -12,11 +12,11 @@ public class NitroxTransform [ProtoMember(2)] public NitroxQuaternion LocalRotation; - + [ProtoMember(3)] public NitroxVector3 LocalScale; - public NitroxMatrix4x4 localToWorldMatrix + public NitroxMatrix4x4 localToWorldMatrix { get { @@ -29,7 +29,7 @@ public NitroxMatrix4x4 localToWorldMatrix public Entity Entity; public NitroxVector3 Position { - get + get { NitroxMatrix4x4 matrix = Parent != null ? Parent.localToWorldMatrix : NitroxMatrix4x4.Identity; return matrix.MultiplyPoint(LocalPosition); @@ -62,8 +62,8 @@ public NitroxQuaternion Rotation public void SetParent(NitroxTransform parent) { Parent = parent; - - + + } public void SetParent(NitroxTransform parent, bool worldPositionStays) @@ -72,7 +72,7 @@ public void SetParent(NitroxTransform parent, bool worldPositionStays) } private NitroxTransform() - {} + { } /// /// NitroxTransform is always attached to an Entity diff --git a/NitroxModel/DataStructures/GameLogic/NitroxVector4.cs b/NitroxModel/DataStructures/GameLogic/NitroxVector4.cs index 7706ab86dd..0aa74c9f0d 100644 --- a/NitroxModel/DataStructures/GameLogic/NitroxVector4.cs +++ b/NitroxModel/DataStructures/GameLogic/NitroxVector4.cs @@ -17,12 +17,6 @@ public NitroxVector4(float x, float y, float z, float w) Z = z; } - public float Magnitude - { - get - { - return (float)Math.Sqrt(X * X + Y * Y + Z * Z + W * W); - } - } + public float Magnitude => (float)Math.Sqrt(X * X + Y * Y + Z * Z + W * W); } } diff --git a/NitroxModel/DataStructures/GameLogic/PlantableItemData.cs b/NitroxModel/DataStructures/GameLogic/PlantableItemData.cs index a95779c31f..dbe1dd9b1b 100644 --- a/NitroxModel/DataStructures/GameLogic/PlantableItemData.cs +++ b/NitroxModel/DataStructures/GameLogic/PlantableItemData.cs @@ -1,5 +1,5 @@ -using ProtoBufNet; using System; +using ProtoBufNet; namespace NitroxModel.DataStructures.GameLogic { @@ -20,8 +20,7 @@ protected PlantableItemData() /// Extends the basic ItemData by adding the game time when the Plantable was added to its Planter container. /// /// Clients will use this to determine expected plant growth progress when connecting - public PlantableItemData(NitroxId containerId, NitroxId itemId, byte[] serializedData, double plantedGameTime) - :base(containerId, itemId, serializedData) + public PlantableItemData(NitroxId containerId, NitroxId itemId, byte[] serializedData, double plantedGameTime) : base(containerId, itemId, serializedData) { PlantedGameTime = plantedGameTime; } diff --git a/NitroxModel/DataStructures/GameLogic/VehicleMovementData.cs b/NitroxModel/DataStructures/GameLogic/VehicleMovementData.cs index 9b70469502..cdf2ea13f2 100644 --- a/NitroxModel/DataStructures/GameLogic/VehicleMovementData.cs +++ b/NitroxModel/DataStructures/GameLogic/VehicleMovementData.cs @@ -1,5 +1,5 @@ -using ProtoBufNet; -using System; +using System; +using ProtoBufNet; namespace NitroxModel.DataStructures.GameLogic { diff --git a/NitroxModel/DataStructures/Optional.cs b/NitroxModel/DataStructures/Optional.cs index 1adf17301e..6c153d96a2 100644 --- a/NitroxModel/DataStructures/Optional.cs +++ b/NitroxModel/DataStructures/Optional.cs @@ -36,7 +36,7 @@ public struct Optional : ISerializable where T : class Type type = typeof(T); bool isObj = type == typeof(object); foreach (KeyValuePair> filter in Optional.ValueConditions) - { + { if (isObj || filter.Key.IsAssignableFrom(type)) { // Only create the list in memory when required. @@ -44,7 +44,7 @@ public struct Optional : ISerializable where T : class { valueChecks = new List>(); } - + // Exclude check for Optional if the type doesn't match the type of the filter (because it'll always fail anyway be null for `o as T`) valueChecks.Add(isObj ? o => !filter.Key.IsInstanceOfType(o) || filter.Value(o) : filter.Value); } diff --git a/NitroxModel/Discovery/GameInstallationFinder.cs b/NitroxModel/Discovery/GameInstallationFinder.cs index e15b81f323..1cedbe2e6a 100644 --- a/NitroxModel/Discovery/GameInstallationFinder.cs +++ b/NitroxModel/Discovery/GameInstallationFinder.cs @@ -39,7 +39,7 @@ public string FindGame(IList errors = null) { continue; } - + errors.Clear(); return Path.GetFullPath(path); } diff --git a/NitroxModel/Helper/Validate.cs b/NitroxModel/Helper/Validate.cs index d08645198b..6a182e0761 100644 --- a/NitroxModel/Helper/Validate.cs +++ b/NitroxModel/Helper/Validate.cs @@ -19,7 +19,7 @@ public static void NotNull(T o) { return; } - + Optional paramName = GetParameterName(); if (paramName.HasValue) { @@ -35,7 +35,7 @@ public static void NotNull(T o, string message) { return; } - + Optional paramName = GetParameterName(); if (paramName.HasValue) { @@ -74,7 +74,7 @@ public static void String(string s) { return; } - + Optional paramName = GetParameterName(); throw new ArgumentException("String must not be null of whitespace", paramName.OrElse(null)); } diff --git a/NitroxModel/NitroxModel.csproj b/NitroxModel/NitroxModel.csproj index 445010a914..d990d9c54c 100644 --- a/NitroxModel/NitroxModel.csproj +++ b/NitroxModel/NitroxModel.csproj @@ -1,4 +1,4 @@ - + @@ -19,151 +19,102 @@ prompt 4 - - - ..\Nitrox.Subnautica.Assets\LZ4.dll - - - - ..\Nitrox.Subnautica.Assets\protobuf-net.dll - - - ..\Nitrox.Subnautica.Assets\Serilog.Sinks.Map.dll - - - - - - - - - - - - - - - + - + + + + + + + + + - - - - - - - - - + + + + + + + + - - - - - + - - - + + + - + + + + - + + + - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + @@ -171,24 +122,32 @@ - + - + + + - - + + + + + - + + + + @@ -202,67 +161,78 @@ + + + + - + + + + + + + + + + + + + + + + + - - - - - + + + + - - - - - - - {b0a014e4-0392-4e35-aa42-8fb5a40417e0} - LiteNetLib - + - + 4.9.4 - - 5.0.0 - 2.10.0 - - 3.1.0 - 1.4.0 + + 5.0.0 + + + 3.1.0 + 3.1.1 @@ -273,5 +243,35 @@ 4.5.3 + + + {b0a014e4-0392-4e35-aa42-8fb5a40417e0} + LiteNetLib + + + + + ..\Nitrox.Subnautica.Assets\LZ4.dll + + + ..\Nitrox.Subnautica.Assets\protobuf-net.dll + + + + + + + + + + + + ..\Nitrox.Subnautica.Assets\Serilog.Sinks.Map.dll + + + + + + \ No newline at end of file diff --git a/NitroxModel/OS/FileSystem.cs b/NitroxModel/OS/FileSystem.cs index 603d07f294..5671a8ac45 100644 --- a/NitroxModel/OS/FileSystem.cs +++ b/NitroxModel/OS/FileSystem.cs @@ -222,7 +222,7 @@ public bool ReplaceFile(string source, string target) Log.Debug($"Renaming file '{target}' to '{backupFileName}' as backup plan if file replace fails"); File.Move(target, backupFileName); File.Copy(source, target); - + // Cleanup redundant files, ignoring errors. try { diff --git a/NitroxModel/OS/Windows/WinFileSystem.cs b/NitroxModel/OS/Windows/WinFileSystem.cs index d4944c06a3..321aaad658 100644 --- a/NitroxModel/OS/Windows/WinFileSystem.cs +++ b/NitroxModel/OS/Windows/WinFileSystem.cs @@ -48,7 +48,7 @@ string SearchExecutableInSameDirectory(string path) { yield break; } - + foreach (char c in mruList) { string fullPath = SearchExecutableInSameDirectory(GetFullPath(rk.GetValue(c.ToString()).ToString())); diff --git a/NitroxModel/Packets/ConstructorBeginCrafting.cs b/NitroxModel/Packets/ConstructorBeginCrafting.cs index 67f5777fd7..74e1cfb61a 100644 --- a/NitroxModel/Packets/ConstructorBeginCrafting.cs +++ b/NitroxModel/Packets/ConstructorBeginCrafting.cs @@ -1,6 +1,6 @@ using System; -using NitroxModel.DataStructures.GameLogic; using NitroxModel.DataStructures; +using NitroxModel.DataStructures.GameLogic; namespace NitroxModel.Packets { diff --git a/NitroxModel/Packets/DroppedItem.cs b/NitroxModel/Packets/DroppedItem.cs index 49219419b9..2c0d5d15f8 100644 --- a/NitroxModel/Packets/DroppedItem.cs +++ b/NitroxModel/Packets/DroppedItem.cs @@ -1,7 +1,7 @@ using System; -using NitroxModel.DataStructures.Util; using NitroxModel.DataStructures; using NitroxModel.DataStructures.GameLogic; +using NitroxModel.DataStructures.Util; namespace NitroxModel.Packets { diff --git a/NitroxModel/Packets/EscapePodChanged.cs b/NitroxModel/Packets/EscapePodChanged.cs index 7d3776cf1d..1c96cda90c 100644 --- a/NitroxModel/Packets/EscapePodChanged.cs +++ b/NitroxModel/Packets/EscapePodChanged.cs @@ -1,6 +1,6 @@ -using NitroxModel.DataStructures.Util; -using System; +using System; using NitroxModel.DataStructures; +using NitroxModel.DataStructures.Util; namespace NitroxModel.Packets { diff --git a/NitroxModel/Packets/ItemContainerAdd.cs b/NitroxModel/Packets/ItemContainerAdd.cs index b566bb92ee..6abe57e1bf 100644 --- a/NitroxModel/Packets/ItemContainerAdd.cs +++ b/NitroxModel/Packets/ItemContainerAdd.cs @@ -1,5 +1,5 @@ -using NitroxModel.DataStructures.GameLogic; -using System; +using System; +using NitroxModel.DataStructures.GameLogic; namespace NitroxModel.Packets { diff --git a/NitroxModel/Packets/LiveMixinHealthChanged.cs b/NitroxModel/Packets/LiveMixinHealthChanged.cs index f20f88a8e4..b6a281d6db 100644 --- a/NitroxModel/Packets/LiveMixinHealthChanged.cs +++ b/NitroxModel/Packets/LiveMixinHealthChanged.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using NitroxModel.DataStructures; using NitroxModel.DataStructures.GameLogic; using NitroxModel.DataStructures.Util; diff --git a/NitroxModel/Packets/PlayerJoinedMultiplayerSession.cs b/NitroxModel/Packets/PlayerJoinedMultiplayerSession.cs index 2513ba8ed3..7264216bb7 100644 --- a/NitroxModel/Packets/PlayerJoinedMultiplayerSession.cs +++ b/NitroxModel/Packets/PlayerJoinedMultiplayerSession.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using NitroxModel.DataStructures; -using NitroxModel.MultiplayerSession; using NitroxModel.DataStructures.GameLogic; using NitroxModel.DataStructures.Util; +using NitroxModel.MultiplayerSession; namespace NitroxModel.Packets { diff --git a/NitroxModel/Packets/Processors/Abstract/PacketProcessor.cs b/NitroxModel/Packets/Processors/Abstract/PacketProcessor.cs index 76517f1f55..3d6d0ecd44 100644 --- a/NitroxModel/Packets/Processors/Abstract/PacketProcessor.cs +++ b/NitroxModel/Packets/Processors/Abstract/PacketProcessor.cs @@ -28,8 +28,7 @@ public static Dictionary GetProcessors(Dictionary { - object v; - if (processorArguments.TryGetValue(pi.ParameterType, out v)) + if (processorArguments.TryGetValue(pi.ParameterType, out object v)) { return v; } diff --git a/NitroxModel/Packets/SimulationOwnershipRequest.cs b/NitroxModel/Packets/SimulationOwnershipRequest.cs index b926709754..273d597b07 100644 --- a/NitroxModel/Packets/SimulationOwnershipRequest.cs +++ b/NitroxModel/Packets/SimulationOwnershipRequest.cs @@ -1,5 +1,5 @@ -using NitroxModel.DataStructures; -using System; +using System; +using NitroxModel.DataStructures; namespace NitroxModel.Packets { diff --git a/NitroxModel/Packets/SimulationOwnershipResponse.cs b/NitroxModel/Packets/SimulationOwnershipResponse.cs index 16c5a11754..a09f3721af 100644 --- a/NitroxModel/Packets/SimulationOwnershipResponse.cs +++ b/NitroxModel/Packets/SimulationOwnershipResponse.cs @@ -1,5 +1,5 @@ -using NitroxModel.DataStructures; -using System; +using System; +using NitroxModel.DataStructures; namespace NitroxModel.Packets { diff --git a/NitroxModel/Serialization/ServerList.cs b/NitroxModel/Serialization/ServerList.cs index baed93334b..f578e779f7 100644 --- a/NitroxModel/Serialization/ServerList.cs +++ b/NitroxModel/Serialization/ServerList.cs @@ -52,7 +52,7 @@ public static ServerList From(string file = null) { continue; } - + list.entries.Add(entry); } return list; @@ -139,7 +139,7 @@ public static Entry FromLine(string line) default: throw new Exception($"Expected server entry to have 2 or 3 parts: {line}"); } - + string name = parts[0].Trim(); return new Entry(name, address, port); } diff --git a/NitroxPatcher/NitroxPatcher.csproj b/NitroxPatcher/NitroxPatcher.csproj index 8157314168..24c58ec4e2 100644 --- a/NitroxPatcher/NitroxPatcher.csproj +++ b/NitroxPatcher/NitroxPatcher.csproj @@ -21,80 +21,34 @@ prompt 4 - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + + - - - + + + + + + + @@ -107,8 +61,8 @@ - + @@ -120,6 +74,7 @@ + @@ -129,6 +84,8 @@ + + @@ -137,41 +94,76 @@ - - - + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -179,71 +171,72 @@ - + + - - + + - - - - - - - - + + + + + + + - + - + + + 4.9.4 + + + 2.0.4.0 + + + {ed5034bd-66b5-4596-94b7-66a28d3eff49} NitroxClient - - {0a377218-6b36-4522-89a3-a39cfc999209} - NitroxModel-Subnautica - {b16f4de7-21ad-4fef-955b-0a5a365fa4e3} NitroxModel + + {0a377218-6b36-4522-89a3-a39cfc999209} + NitroxModel-Subnautica + - - - 4.9.4 - - - 2.0.4.0 - + + + + + + + - - + \ No newline at end of file diff --git a/NitroxPatcher/Patches/Dynamic/BaseAddBulkheadGhost_UpdatePlacement_Patch.cs b/NitroxPatcher/Patches/Dynamic/BaseAddBulkheadGhost_UpdatePlacement_Patch.cs index 355edbab45..e162a96059 100644 --- a/NitroxPatcher/Patches/Dynamic/BaseAddBulkheadGhost_UpdatePlacement_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/BaseAddBulkheadGhost_UpdatePlacement_Patch.cs @@ -46,7 +46,7 @@ public static IEnumerable Transpiler(MethodBase original, IEnum { CodeInstruction instruction = instructionList[i]; yield return instruction; - + if (shouldInject) { shouldInject = false; @@ -69,7 +69,7 @@ private static CodeInstruction GetJumpInstruction(List instruct { CodeInstruction instruction = instructions[i]; - if(instruction.opcode == INSTRUCTION_BEFORE_JUMP && instruction.operand == INSTRUCTION_BEFORE_JUMP_OPERAND) + if (instruction.opcode == INSTRUCTION_BEFORE_JUMP && instruction.operand == INSTRUCTION_BEFORE_JUMP_OPERAND) { // we located the instruction before the jump... the next instruction should be the jump CodeInstruction jmpInstruction = instructions[i + 1]; @@ -83,7 +83,7 @@ private static CodeInstruction GetJumpInstruction(List instruct throw new Exception("Could not locate jump instruction to copy! Injection has failed."); } - + public override void Patch(Harmony harmony) { PatchTranspiler(harmony, TARGET_METHOD); diff --git a/NitroxPatcher/Patches/Dynamic/BaseAddModuleGhost_UpdatePlacement_Patch.cs b/NitroxPatcher/Patches/Dynamic/BaseAddModuleGhost_UpdatePlacement_Patch.cs index 00d6ae0fcb..aa083340b4 100644 --- a/NitroxPatcher/Patches/Dynamic/BaseAddModuleGhost_UpdatePlacement_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/BaseAddModuleGhost_UpdatePlacement_Patch.cs @@ -46,7 +46,7 @@ public static IEnumerable Transpiler(MethodBase original, IEnum { CodeInstruction instruction = instructionList[i]; yield return instruction; - + if (shouldInject) { shouldInject = false; @@ -69,7 +69,7 @@ private static CodeInstruction GetJumpInstruction(List instruct { CodeInstruction instruction = instructions[i]; - if(instruction.opcode == INSTRUCTION_BEFORE_JUMP && instruction.operand == INSTRUCTION_BEFORE_JUMP_OPERAND) + if (instruction.opcode == INSTRUCTION_BEFORE_JUMP && instruction.operand == INSTRUCTION_BEFORE_JUMP_OPERAND) { // we located the instruction before the jump... the next instruction should be the jump CodeInstruction jmpInstruction = instructions[i + 1]; @@ -83,7 +83,7 @@ private static CodeInstruction GetJumpInstruction(List instruct throw new Exception("Could not locate jump instruction to copy! Injection has failed."); } - + public override void Patch(Harmony harmony) { PatchTranspiler(harmony, TARGET_METHOD); diff --git a/NitroxPatcher/Patches/Dynamic/BaseDeconstructable_MakeFaceDeconstructable_Patch.cs b/NitroxPatcher/Patches/Dynamic/BaseDeconstructable_MakeFaceDeconstructable_Patch.cs index 9328485707..8e16108878 100644 --- a/NitroxPatcher/Patches/Dynamic/BaseDeconstructable_MakeFaceDeconstructable_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/BaseDeconstructable_MakeFaceDeconstructable_Patch.cs @@ -18,11 +18,11 @@ public class BaseDeconstructable_MakeFaceDeconstructable_Patch : NitroxPatch, ID */ public static void Postfix(Transform geometry, Base.Face face) { - if(!geometry || !geometry.gameObject) + if (!geometry || !geometry.gameObject) { return; } - + NitroxServiceLocator.LocateService().BaseFaceRespawned(geometry.gameObject, face.cell, face.direction); } diff --git a/NitroxPatcher/Patches/Dynamic/Base_ClearGeometry_Patch.cs b/NitroxPatcher/Patches/Dynamic/Base_ClearGeometry_Patch.cs index 002aeb14aa..c407ab9d06 100644 --- a/NitroxPatcher/Patches/Dynamic/Base_ClearGeometry_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Base_ClearGeometry_Patch.cs @@ -13,14 +13,14 @@ public class Base_ClearGeometry_Patch : NitroxPatch, IDynamicPatch public static void Prefix(Base __instance) { - if(__instance == null) + if (__instance == null) { return; } NitroxServiceLocator.LocateService().GeometryClearedForBase(__instance); } - + public override void Patch(Harmony harmony) { PatchPrefix(harmony, TARGET_METHOD); diff --git a/NitroxPatcher/Patches/Dynamic/Base_CopyFrom_Patch.cs b/NitroxPatcher/Patches/Dynamic/Base_CopyFrom_Patch.cs index 49a1896134..7c67733831 100644 --- a/NitroxPatcher/Patches/Dynamic/Base_CopyFrom_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Base_CopyFrom_Patch.cs @@ -1,5 +1,5 @@ -using HarmonyLib; -using System.Reflection; +using System.Reflection; +using HarmonyLib; using NitroxClient.MonoBehaviours; using NitroxModel.Logger; @@ -12,13 +12,13 @@ class Base_CopyFrom_Patch : NitroxPatch, IDynamicPatch public static void Prefix(Base __instance, Base sourceBase) { NitroxEntity entity = sourceBase.GetComponent(); - + // The game will clone the base when doing things like rebuilding gemometry or placing a new // piece. The copy is normally between a base ghost and a base - and vise versa. When building // a face piece, such as a window, this will clone a ghost base to stage the change which is later // integrated into the real base. For now, prevent guid copies to these staging ghost bases; however, // there is still a pending edge case when a base converts to a BaseGhost for deconstruction. - if(entity != null && __instance.gameObject.name != "BaseGhost") + if (entity != null && __instance.gameObject.name != "BaseGhost") { Log.Debug("Transfering base id : " + entity.Id + " from " + sourceBase.name + " to " + __instance.name); NitroxEntity.SetNewId(__instance.gameObject, entity.Id); diff --git a/NitroxPatcher/Patches/Dynamic/Base_SpawnPiece_Patch.cs b/NitroxPatcher/Patches/Dynamic/Base_SpawnPiece_Patch.cs index 9f23d96582..fdd36f637c 100644 --- a/NitroxPatcher/Patches/Dynamic/Base_SpawnPiece_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Base_SpawnPiece_Patch.cs @@ -11,7 +11,7 @@ public class Base_SpawnPiece_Patch : NitroxPatch, IDynamicPatch { public static readonly Type TARGET_CLASS = typeof(Base); public static readonly MethodInfo TARGET_METHOD = TARGET_CLASS.GetMethod("SpawnPiece", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Base).GetNestedType("Piece", BindingFlags.NonPublic | BindingFlags.Instance), typeof(Int3), typeof(Quaternion), typeof(Base.Direction?) }, null); - + /** * This function is called directly after the game clears all base pieces (to update * the view model - this is done in Base.ClearGeometry, see that patch). The game will @@ -20,7 +20,7 @@ public class Base_SpawnPiece_Patch : NitroxPatch, IDynamicPatch */ public static void Postfix(Base __instance, Transform __result) { - if(__instance == null || __result == null) + if (__instance == null || __result == null) { return; } diff --git a/NitroxPatcher/Patches/Dynamic/Bench_ExitSittingMode_Patch.cs b/NitroxPatcher/Patches/Dynamic/Bench_ExitSittingMode_Patch.cs index dd49252ea8..4491723bb9 100644 --- a/NitroxPatcher/Patches/Dynamic/Bench_ExitSittingMode_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Bench_ExitSittingMode_Patch.cs @@ -1,5 +1,4 @@ -using System; -using System.Reflection; +using System.Reflection; using HarmonyLib; using NitroxClient.GameLogic; using NitroxClient.MonoBehaviours; diff --git a/NitroxPatcher/Patches/Dynamic/Bench_OnHandClick_Patch.cs b/NitroxPatcher/Patches/Dynamic/Bench_OnHandClick_Patch.cs index bfce1a7744..209715bd5a 100644 --- a/NitroxPatcher/Patches/Dynamic/Bench_OnHandClick_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Bench_OnHandClick_Patch.cs @@ -24,7 +24,7 @@ public static bool Prefix(Bench __instance, GUIHand hand) } SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService(); - + NitroxId id = NitroxEntity.GetId(__instance.gameObject); if (simulationOwnership.HasExclusiveLock(id)) diff --git a/NitroxPatcher/Patches/Dynamic/Bench_OnPlayerDeath_Patch.cs b/NitroxPatcher/Patches/Dynamic/Bench_OnPlayerDeath_Patch.cs index da193a27f9..dab9a71446 100644 --- a/NitroxPatcher/Patches/Dynamic/Bench_OnPlayerDeath_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Bench_OnPlayerDeath_Patch.cs @@ -1,5 +1,4 @@ -using System; -using System.Reflection; +using System.Reflection; using HarmonyLib; using NitroxClient.GameLogic; using NitroxClient.MonoBehaviours; diff --git a/NitroxPatcher/Patches/Dynamic/BuilderTool_HandleInput_Patch.cs b/NitroxPatcher/Patches/Dynamic/BuilderTool_HandleInput_Patch.cs index 3771582525..d256796a1f 100644 --- a/NitroxPatcher/Patches/Dynamic/BuilderTool_HandleInput_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/BuilderTool_HandleInput_Patch.cs @@ -16,7 +16,7 @@ public class BuilderTool_HandleInput_Patch : NitroxPatch, IDynamicPatch public static readonly OpCode INJECTION_OPCODE = OpCodes.Callvirt; public static readonly object INJECTION_OPERAND = typeof(Constructable).GetMethod("SetState", BindingFlags.Public | BindingFlags.Instance); - + public static IEnumerable Transpiler(MethodBase original, IEnumerable instructions) { Validate.NotNull(INJECTION_OPERAND); diff --git a/NitroxPatcher/Patches/Dynamic/Constructable_Construct_Patch.cs b/NitroxPatcher/Patches/Dynamic/Constructable_Construct_Patch.cs index 198e930910..f87e2bffca 100644 --- a/NitroxPatcher/Patches/Dynamic/Constructable_Construct_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Constructable_Construct_Patch.cs @@ -21,7 +21,7 @@ public static bool Prefix(Constructable __instance) { NitroxServiceLocator.LocateService().ChangeConstructionAmount(__instance.gameObject, __instance.constructedAmount); } - + // If we are constructing a base piece then we'll want to store all of the BaseGhost information // as it will not be available when the construction hits 100% BaseGhost baseGhost = __instance.gameObject.GetComponentInChildren(); diff --git a/NitroxPatcher/Patches/Dynamic/Constructable_Deconstruct_Patch.cs b/NitroxPatcher/Patches/Dynamic/Constructable_Deconstruct_Patch.cs index 3dc3dd3ba2..5116504350 100644 --- a/NitroxPatcher/Patches/Dynamic/Constructable_Deconstruct_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Constructable_Deconstruct_Patch.cs @@ -10,7 +10,7 @@ public class Constructable_Deconstruct_Patch : NitroxPatch, IDynamicPatch { public static readonly Type TARGET_CLASS = typeof(Constructable); public static readonly MethodInfo TARGET_METHOD = TARGET_CLASS.GetMethod("Deconstruct"); - + public static void Postfix(Constructable __instance, bool __result) { if (__result && __instance.constructedAmount <= 0f) @@ -22,7 +22,7 @@ public static void Postfix(Constructable __instance, bool __result) NitroxServiceLocator.LocateService().ChangeConstructionAmount(__instance.gameObject, __instance.constructedAmount); } } - + public override void Patch(Harmony harmony) { PatchPostfix(harmony, TARGET_METHOD); diff --git a/NitroxPatcher/Patches/Dynamic/Constructable_NotifyConstructedChanged_Patch.cs b/NitroxPatcher/Patches/Dynamic/Constructable_NotifyConstructedChanged_Patch.cs index c8c255f74a..07a219ac24 100644 --- a/NitroxPatcher/Patches/Dynamic/Constructable_NotifyConstructedChanged_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Constructable_NotifyConstructedChanged_Patch.cs @@ -1,5 +1,4 @@ -using System; -using System.Reflection; +using System.Reflection; using HarmonyLib; using NitroxClient.GameLogic; using NitroxClient.GameLogic.Helper; diff --git a/NitroxPatcher/Patches/Dynamic/Constructable_SetState_Patch.cs b/NitroxPatcher/Patches/Dynamic/Constructable_SetState_Patch.cs index 406bdc73cd..650fec8fec 100644 --- a/NitroxPatcher/Patches/Dynamic/Constructable_SetState_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Constructable_SetState_Patch.cs @@ -34,7 +34,7 @@ public static void Postfix(Constructable __instance) NitroxEntity.SetNewId(__instance.gameObject, id); } } - + public override void Patch(Harmony harmony) { PatchPostfix(harmony, TARGET_METHOD); diff --git a/NitroxPatcher/Patches/Dynamic/CyclopsShieldButton_OnClick_Patch.cs b/NitroxPatcher/Patches/Dynamic/CyclopsShieldButton_OnClick_Patch.cs index afb11cbba0..6c17a6af3b 100644 --- a/NitroxPatcher/Patches/Dynamic/CyclopsShieldButton_OnClick_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/CyclopsShieldButton_OnClick_Patch.cs @@ -14,7 +14,7 @@ public class CyclopsShieldButton_OnClick_Patch : NitroxPatch, IDynamicPatch public static readonly OpCode START_CUT_CODE = OpCodes.Ldsfld; public static readonly OpCode START_CUT_CODE_CALL = OpCodes.Callvirt; public static readonly FieldInfo PLAYER_MAIN_FIELD = typeof(Player).GetField("main", BindingFlags.Public | BindingFlags.Static); - public static readonly OpCode END_CUT_CODE = OpCodes.Ret; + public static readonly OpCode END_CUT_CODE = OpCodes.Ret; public static IEnumerable Transpiler(MethodBase original, IEnumerable instructions) { @@ -39,7 +39,7 @@ public static IEnumerable Transpiler(MethodBase original, IEnum endCut = i; } } - instructionList.RemoveRange(startCut, endCut+1); + instructionList.RemoveRange(startCut, endCut + 1); if (startCut == 0) { instructionList.Insert(0, new CodeInstruction(OpCodes.Nop)); @@ -49,7 +49,7 @@ public static IEnumerable Transpiler(MethodBase original, IEnum public override void Patch(Harmony harmony) { - PatchTranspiler(harmony, TARGET_METHOD); - } + PatchTranspiler(harmony, TARGET_METHOD); + } } -} +} diff --git a/NitroxPatcher/Patches/Dynamic/CyclopsSilentRunningAbilityButton_TurnOnSilentRunning_Patch.cs b/NitroxPatcher/Patches/Dynamic/CyclopsSilentRunningAbilityButton_TurnOnSilentRunning_Patch.cs index 782520689f..34cdcc8d24 100644 --- a/NitroxPatcher/Patches/Dynamic/CyclopsSilentRunningAbilityButton_TurnOnSilentRunning_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/CyclopsSilentRunningAbilityButton_TurnOnSilentRunning_Patch.cs @@ -16,7 +16,7 @@ public class CyclopsSilentRunningAbilityButton_TurnOnSilentRunning_Patch : Nitro public static void Postfix(CyclopsSilentRunningAbilityButton __instance) { NitroxId id = NitroxEntity.GetId(__instance.subRoot.gameObject); - NitroxServiceLocator.LocateService().BroadcastChangeSilentRunning(id,true); + NitroxServiceLocator.LocateService().BroadcastChangeSilentRunning(id, true); } public override void Patch(Harmony harmony) diff --git a/NitroxPatcher/Patches/Dynamic/CyclopsSonarButton_OnClick_Patch.cs b/NitroxPatcher/Patches/Dynamic/CyclopsSonarButton_OnClick_Patch.cs index 12784207bb..e26ca53bf8 100644 --- a/NitroxPatcher/Patches/Dynamic/CyclopsSonarButton_OnClick_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/CyclopsSonarButton_OnClick_Patch.cs @@ -17,13 +17,13 @@ public static void Postfix(CyclopsSonarButton __instance) { NitroxId id = NitroxEntity.GetId(__instance.subRoot.gameObject); bool activeSonar = Traverse.Create(__instance).Field("sonarActive").GetValue(); - NitroxServiceLocator.LocateService().BroadcastChangeSonarState(id,activeSonar); - } + NitroxServiceLocator.LocateService().BroadcastChangeSonarState(id, activeSonar); + } public override void Patch(Harmony harmony) { PatchPostfix(harmony, TARGET_METHOD); } - + } } diff --git a/NitroxPatcher/Patches/Dynamic/CyclopsSonarButton_SonarPing_Patch.cs b/NitroxPatcher/Patches/Dynamic/CyclopsSonarButton_SonarPing_Patch.cs index 94a6dba614..e59c5fb836 100644 --- a/NitroxPatcher/Patches/Dynamic/CyclopsSonarButton_SonarPing_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/CyclopsSonarButton_SonarPing_Patch.cs @@ -19,7 +19,7 @@ class CyclopsSonarButton_SonarPing_Patch : NitroxPatch, IDynamicPatch public static readonly OpCode JUMP_TARGET_CODE = OpCodes.Ldsfld; public static readonly FieldInfo JUMP_TARGET_FIELD = typeof(SNCameraRoot).GetField("main", BindingFlags.Public | BindingFlags.Static); - + // Send ping to other players public static void Postfix(CyclopsSonarButton __instance) { @@ -27,7 +27,7 @@ public static void Postfix(CyclopsSonarButton __instance) NitroxServiceLocator.LocateService().BroadcastSonarPing(id); } - + /* As the ping would be always be executed it should be restricted to players, that are in the cyclops * Therefore the code generated from AssembleNewCode will be injected before the ping would be send but after energy consumption * End result: @@ -46,7 +46,7 @@ public static void Postfix(CyclopsSonarButton __instance) * SNCameraRoot.main.SonarPing(); * this.soundFX.Play(); * } - */ + */ public static IEnumerable Transpiler(MethodBase original, IEnumerable instructions, ILGenerator iLGenerator) { List instructionList = instructions.ToList(); @@ -59,10 +59,10 @@ public static IEnumerable Transpiler(MethodBase original, IEnum for (int i = 0; i < instructionList.Count; i++) { CodeInstruction instruction = instructionList[i]; - if(instruction.opcode.Equals(JUMP_TARGET_CODE) && instruction.operand.Equals(JUMP_TARGET_FIELD)) - { + if (instruction.opcode.Equals(JUMP_TARGET_CODE) && instruction.operand.Equals(JUMP_TARGET_FIELD)) + { Label jumpLabel = instruction.labels[0]; - IEnumerable injectInstructions = AssembleNewCode(jumpLabel,toInjectJump); + IEnumerable injectInstructions = AssembleNewCode(jumpLabel, toInjectJump); foreach (CodeInstruction injectInstruction in injectInstructions) { yield return injectInstruction; @@ -83,10 +83,10 @@ public static IEnumerable Transpiler(MethodBase original, IEnum } } yield return instruction; - } + } } - private static IEnumerable AssembleNewCode(Label outJumpLabel,Label innerJumpLabel) + private static IEnumerable AssembleNewCode(Label outJumpLabel, Label innerJumpLabel) { //Code to inject: /* @@ -96,7 +96,7 @@ private static IEnumerable AssembleNewCode(Label outJumpLabel,L * } * */ - List injectInstructions = new List(); + List injectInstructions = new List(); CodeInstruction instruction = new CodeInstruction(OpCodes.Ldsfld); instruction.operand = typeof(Player).GetField("main", BindingFlags.Public | BindingFlags.Static); @@ -107,7 +107,7 @@ private static IEnumerable AssembleNewCode(Label outJumpLabel,L instruction.operand = typeof(Player).GetMethod("get_currentSub", BindingFlags.Public | BindingFlags.Instance); injectInstructions.Add(instruction); - instruction = new CodeInstruction(OpCodes.Ldarg_0); + instruction = new CodeInstruction(OpCodes.Ldarg_0); injectInstructions.Add(instruction); instruction = new CodeInstruction(OpCodes.Ldfld); diff --git a/NitroxPatcher/Patches/Dynamic/DockedVehicleHandTarget_OnHandClick_Patch.cs b/NitroxPatcher/Patches/Dynamic/DockedVehicleHandTarget_OnHandClick_Patch.cs index 1ffe845a8a..a734befe21 100644 --- a/NitroxPatcher/Patches/Dynamic/DockedVehicleHandTarget_OnHandClick_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/DockedVehicleHandTarget_OnHandClick_Patch.cs @@ -25,7 +25,7 @@ public static bool Prefix(DockedVehicleHandTarget __instance, GUIHand hand) { return true; } - + SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService(); NitroxId id = NitroxEntity.GetId(vehicle.gameObject); diff --git a/NitroxPatcher/Patches/Dynamic/ExosuitClawArm_OnPickup_Patch.cs b/NitroxPatcher/Patches/Dynamic/ExosuitClawArm_OnPickup_Patch.cs index d488a7b0ee..4f84675037 100644 --- a/NitroxPatcher/Patches/Dynamic/ExosuitClawArm_OnPickup_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/ExosuitClawArm_OnPickup_Patch.cs @@ -22,7 +22,8 @@ public static bool Prefix(ExosuitClawArm __instance) if (pickupable != null && pickupable.isPickupable && componentInParent.storageContainer.container.HasRoomFor(pickupable)) { NitroxServiceLocator.LocateService().PickedUp(pickupable.gameObject, pickupable.GetTechType()); - } else if(component != null) + } + else if (component != null) { Log.Debug("Delete Pickprefab for exosuit claw arm"); NitroxServiceLocator.LocateService().PickedUp(component.gameObject, component.pickTech); diff --git a/NitroxPatcher/Patches/Dynamic/ExosuitClawArm_TryUse_Patch.cs b/NitroxPatcher/Patches/Dynamic/ExosuitClawArm_TryUse_Patch.cs index f4328d6ade..6e9b2ca96c 100644 --- a/NitroxPatcher/Patches/Dynamic/ExosuitClawArm_TryUse_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/ExosuitClawArm_TryUse_Patch.cs @@ -11,9 +11,9 @@ class ExosuitClawArm_TryUse_Patch : NitroxPatch, IDynamicPatch public static readonly Type TARGET_CLASS = typeof(ExosuitClawArm); public static readonly MethodInfo TARGET_METHOD = TARGET_CLASS.GetMethod("TryUse", BindingFlags.NonPublic | BindingFlags.Instance); - public static void Postfix(bool __result, ExosuitClawArm __instance,float ___cooldownTime) + public static void Postfix(bool __result, ExosuitClawArm __instance, float ___cooldownTime) { - if(__result) + if (__result) { NitroxServiceLocator.LocateService().BroadcastClawUse(__instance, ___cooldownTime); } diff --git a/NitroxPatcher/Patches/Dynamic/ExosuitDrillArm_OnUseDown_Patch.cs b/NitroxPatcher/Patches/Dynamic/ExosuitDrillArm_OnUseDown_Patch.cs index 1a58e88ac8..30d547f229 100644 --- a/NitroxPatcher/Patches/Dynamic/ExosuitDrillArm_OnUseDown_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/ExosuitDrillArm_OnUseDown_Patch.cs @@ -15,11 +15,11 @@ class ExosuitDrillArm_OnUseDown_Patch : NitroxPatch, IDynamicPatch public static void Prefix(ExosuitDrillArm __instance) { - NitroxServiceLocator.LocateService().BroadcastArmAction(TechType.ExosuitDrillArmModule,__instance, ExosuitArmAction.START_USE_TOOL); + NitroxServiceLocator.LocateService().BroadcastArmAction(TechType.ExosuitDrillArmModule, __instance, ExosuitArmAction.START_USE_TOOL); } public override void Patch(Harmony harmony) - { + { InterfaceMapping interfaceMap = TARGET_CLASS.GetInterfaceMap(TARGET_INTERFACE); int i = Array.IndexOf(interfaceMap.InterfaceMethods, TARGET_METHOD_INTERFACE); MethodInfo targetMethod = interfaceMap.TargetMethods[i]; diff --git a/NitroxPatcher/Patches/Dynamic/ExosuitDrillArm_OnUseUp_Patch.cs b/NitroxPatcher/Patches/Dynamic/ExosuitDrillArm_OnUseUp_Patch.cs index e3bb9b4d77..81874b560d 100644 --- a/NitroxPatcher/Patches/Dynamic/ExosuitDrillArm_OnUseUp_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/ExosuitDrillArm_OnUseUp_Patch.cs @@ -14,7 +14,7 @@ class ExosuitDrillArm_OnUseUp_Patch : NitroxPatch, IDynamicPatch public static readonly MethodInfo TARGET_METHOD_INTERFACE = typeof(IExosuitArm).GetMethod("OnUseUp"); public static void Prefix(ExosuitDrillArm __instance) - { + { NitroxServiceLocator.LocateService().BroadcastArmAction(TechType.ExosuitDrillArmModule, __instance, ExosuitArmAction.END_USE_TOOL); } diff --git a/NitroxPatcher/Patches/Dynamic/ExosuitGrapplingArm_OnHit_Patch.cs b/NitroxPatcher/Patches/Dynamic/ExosuitGrapplingArm_OnHit_Patch.cs index da89530202..71b6467533 100644 --- a/NitroxPatcher/Patches/Dynamic/ExosuitGrapplingArm_OnHit_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/ExosuitGrapplingArm_OnHit_Patch.cs @@ -3,9 +3,7 @@ using HarmonyLib; using NitroxClient.GameLogic; using NitroxModel.Core; -using NitroxModel.DataStructures.Util; using NitroxModel_Subnautica.Packets; -using UnityEngine; namespace NitroxPatcher.Patches.Dynamic { @@ -17,17 +15,17 @@ class ExosuitGrapplingArm_OnHit_Patch : NitroxPatch, IDynamicPatch public static bool Prefix(ExosuitGrapplingArm __instance, GrapplingHook ___hook) { Exosuit componentInParent = __instance.GetComponentInParent(); - - if(componentInParent != null ) + + if (componentInParent != null) { - if(!componentInParent.GetPilotingMode()) + if (!componentInParent.GetPilotingMode()) { // We suppress this method if it is called from another player pilot, so we can use our own implementation // See: ExosuitModuleEvents.UseGrapplingarm -> onHit Section return false; } } - + return true; } @@ -39,7 +37,7 @@ public static void Postfix(ExosuitGrapplingArm __instance, GrapplingHook ___hook public override void Patch(Harmony harmony) { - PatchMultiple(harmony, TARGET_METHOD, true, true, false, false); + PatchMultiple(harmony, TARGET_METHOD, true, true, false, false); } } } diff --git a/NitroxPatcher/Patches/Dynamic/ExosuitTorpedoArm_Shoot_Patch.cs b/NitroxPatcher/Patches/Dynamic/ExosuitTorpedoArm_Shoot_Patch.cs index 63e827db6b..cfa8b38ee2 100644 --- a/NitroxPatcher/Patches/Dynamic/ExosuitTorpedoArm_Shoot_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/ExosuitTorpedoArm_Shoot_Patch.cs @@ -4,7 +4,6 @@ using NitroxClient.GameLogic; using NitroxClient.MonoBehaviours; using NitroxModel.Core; -using NitroxModel.DataStructures.Util; using NitroxModel.Logger; using NitroxModel_Subnautica.Packets; using UnityEngine; @@ -18,21 +17,21 @@ class ExosuitTorpedoArm_Shoot_Patch : NitroxPatch, IDynamicPatch public static void Prefix(ExosuitTorpedoArm __instance, bool __result, TorpedoType torpedoType, Transform siloTransform) { - if(torpedoType != null) + if (torpedoType != null) { ExosuitArmAction action = ExosuitArmAction.START_USE_TOOL; - if(siloTransform == __instance.siloSecond) + if (siloTransform == __instance.siloSecond) { action = ExosuitArmAction.ALT_HIT; } - if(siloTransform != __instance.siloFirst && siloTransform != __instance.siloSecond) + if (siloTransform != __instance.siloFirst && siloTransform != __instance.siloSecond) { Log.Error("Exosuit torpedo arm siloTransform is not first or second silo " + NitroxEntity.GetId(__instance.gameObject)); } NitroxServiceLocator.LocateService().BroadcastArmAction(TechType.ExosuitTorpedoArmModule, - __instance, - action, - Player.main.camRoot.GetAimingTransform().forward, + __instance, + action, + Player.main.camRoot.GetAimingTransform().forward, Player.main.camRoot.GetAimingTransform().rotation ); } diff --git a/NitroxPatcher/Patches/Dynamic/GhostCrafter_OnCraftingBegin_Patch.cs b/NitroxPatcher/Patches/Dynamic/GhostCrafter_OnCraftingBegin_Patch.cs index 8fb5360033..cfe2648f36 100644 --- a/NitroxPatcher/Patches/Dynamic/GhostCrafter_OnCraftingBegin_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/GhostCrafter_OnCraftingBegin_Patch.cs @@ -8,7 +8,7 @@ namespace NitroxPatcher.Patches.Dynamic public class GhostCrafter_OnCraftingBegin_Patch : NitroxPatch, IDynamicPatch { public static readonly MethodInfo TARGET_METHOD = typeof(GhostCrafter).GetMethod("OnCraftingBegin", BindingFlags.NonPublic | BindingFlags.Instance); - + public static void Postfix(GhostCrafter __instance, TechType techType, float duration) { NitroxServiceLocator.LocateService().GhostCrafterCrafingStarted(__instance.gameObject, techType, duration); diff --git a/NitroxPatcher/Patches/Dynamic/Incubator_OnHandClick_Patch.cs b/NitroxPatcher/Patches/Dynamic/Incubator_OnHandClick_Patch.cs index 95c6c5e056..a7a93b858f 100644 --- a/NitroxPatcher/Patches/Dynamic/Incubator_OnHandClick_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Incubator_OnHandClick_Patch.cs @@ -39,7 +39,7 @@ public static bool Prefix(Incubator __instance, GUIHand hand) HandInteraction context = new HandInteraction(__instance, hand); LockRequest> lockRequest = new LockRequest>(id, SimulationLockType.EXCLUSIVE, ReceivedSimulationLockResponse, context); - + simulationOwnership.RequestSimulationLock(lockRequest); } diff --git a/NitroxPatcher/Patches/Dynamic/IngameMenu_OnSelect_Patch.cs b/NitroxPatcher/Patches/Dynamic/IngameMenu_OnSelect_Patch.cs index 2e5a7563a8..943d971f9b 100644 --- a/NitroxPatcher/Patches/Dynamic/IngameMenu_OnSelect_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/IngameMenu_OnSelect_Patch.cs @@ -38,14 +38,14 @@ public static IEnumerable Transpiler(MethodBase original, IEnum */ foreach (CodeInstruction instruction in instructions) { - if(GAMEMODEUTILS_ISPERMADEATH_METHOD.Equals(instruction.operand)) + if (GAMEMODEUTILS_ISPERMADEATH_METHOD.Equals(instruction.operand)) { yield return new CodeInstruction(OpCodes.Ret); break; } yield return instruction; - } + } } public override void Patch(Harmony harmony) diff --git a/NitroxPatcher/Patches/Dynamic/IngameMenu_QuitGame_Patch.cs b/NitroxPatcher/Patches/Dynamic/IngameMenu_QuitGame_Patch.cs index b106a69538..fe152c587a 100644 --- a/NitroxPatcher/Patches/Dynamic/IngameMenu_QuitGame_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/IngameMenu_QuitGame_Patch.cs @@ -14,7 +14,7 @@ public class IngameMenu_QuitGame_Patch : NitroxPatch, IDynamicPatch public static void Prefix() { - IMultiplayerSession multiplayerSession = NitroxServiceLocator.LocateService(); + IMultiplayerSession multiplayerSession = NitroxServiceLocator.LocateService(); multiplayerSession.Disconnect(); Application.Quit(); } diff --git a/NitroxPatcher/Patches/Dynamic/KeypadDoorConsole_AcceptNumberField_Patch.cs b/NitroxPatcher/Patches/Dynamic/KeypadDoorConsole_AcceptNumberField_Patch.cs index 89d1b9843d..9ed5ebfa59 100644 --- a/NitroxPatcher/Patches/Dynamic/KeypadDoorConsole_AcceptNumberField_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/KeypadDoorConsole_AcceptNumberField_Patch.cs @@ -13,12 +13,12 @@ public class KeypadDoorConsole_AcceptNumberField_Patch : NitroxPatch, IDynamicPa { public static readonly Type TARGET_CLASS = typeof(KeypadDoorConsole); public static readonly MethodInfo TARGET_METHOD = TARGET_CLASS.GetMethod("AcceptNumberField", BindingFlags.NonPublic | BindingFlags.Instance); - + public static void Postfix(KeypadDoorConsole __instance) { NitroxId id = NitroxEntity.GetId(__instance.gameObject); KeypadMetadata keypadMetadata = new KeypadMetadata(__instance.unlocked); - + Entities entities = NitroxServiceLocator.LocateService(); entities.BroadcastMetadataUpdate(id, keypadMetadata); } diff --git a/NitroxPatcher/Patches/Dynamic/LiveMixin_AddHealth_Patch.cs b/NitroxPatcher/Patches/Dynamic/LiveMixin_AddHealth_Patch.cs index 81ff8cdee0..2b4567d4a4 100644 --- a/NitroxPatcher/Patches/Dynamic/LiveMixin_AddHealth_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/LiveMixin_AddHealth_Patch.cs @@ -50,6 +50,6 @@ public static void Postfix(float? __state, LiveMixin __instance, float healthBac public override void Patch(Harmony harmony) { PatchMultiple(harmony, TARGET_METHOD, true, true, false, false); - } + } } } diff --git a/NitroxPatcher/Patches/Dynamic/OnGoalUnlockTracker_NotifyGoalComplete_Patch.cs b/NitroxPatcher/Patches/Dynamic/OnGoalUnlockTracker_NotifyGoalComplete_Patch.cs index bcbf2bcda7..2d9ba0cc94 100644 --- a/NitroxPatcher/Patches/Dynamic/OnGoalUnlockTracker_NotifyGoalComplete_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/OnGoalUnlockTracker_NotifyGoalComplete_Patch.cs @@ -18,8 +18,7 @@ public class OnGoalUnlockTracker_NotifyGoalComplete_Patch : NitroxPatch, IDynami public static void Prefix(OnGoalUnlockData __instance, string completedGoal) { Dictionary goalUnlocks = __instance.ReflectionGet("goalUnlocks", false, false) as Dictionary; - OnGoalUnlock onGoalUnlock; - if (goalUnlocks.TryGetValue(completedGoal, out onGoalUnlock)) + if (goalUnlocks.TryGetValue(completedGoal, out OnGoalUnlock onGoalUnlock)) { StoryEventSend packet = new StoryEventSend(StoryEventSend.EventType.GOAL_UNLOCK, completedGoal); NitroxServiceLocator.LocateService().Send(packet); diff --git a/NitroxPatcher/Patches/Dynamic/PDAScanner_NotifyRemove_Patch.cs b/NitroxPatcher/Patches/Dynamic/PDAScanner_NotifyRemove_Patch.cs index 8cf573751b..e56a03a6b7 100644 --- a/NitroxPatcher/Patches/Dynamic/PDAScanner_NotifyRemove_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/PDAScanner_NotifyRemove_Patch.cs @@ -14,7 +14,7 @@ public class PDAScanner_NotifyRemove_Patch : NitroxPatch, IDynamicPatch public static void Prefix(PDAScanner.Entry entry) { if (entry != null) - { + { NitroxServiceLocator.LocateService().Remove(entry); } } diff --git a/NitroxPatcher/Patches/Dynamic/PilotingChair_OnHandClick_Patch.cs b/NitroxPatcher/Patches/Dynamic/PilotingChair_OnHandClick_Patch.cs index 4bac83ac1a..bb901d7be3 100644 --- a/NitroxPatcher/Patches/Dynamic/PilotingChair_OnHandClick_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/PilotingChair_OnHandClick_Patch.cs @@ -9,7 +9,6 @@ using NitroxModel.DataStructures; using NitroxModel.Helper; using NitroxModel.Logger; -using static NitroxClient.GameLogic.SimulationOwnership; namespace NitroxPatcher.Patches.Dynamic { @@ -26,7 +25,7 @@ public static bool Prefix(PilotingChair __instance, GUIHand hand) { return true; } - + SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService(); SubRoot subRoot = __instance.GetComponentInParent(); @@ -40,7 +39,7 @@ public static bool Prefix(PilotingChair __instance, GUIHand hand) } HandInteraction context = new HandInteraction(__instance, hand); - LockRequest> lockRequest = new LockRequest> (id, SimulationLockType.EXCLUSIVE, ReceivedSimulationLockResponse, context); + LockRequest> lockRequest = new LockRequest>(id, SimulationLockType.EXCLUSIVE, ReceivedSimulationLockResponse, context); simulationOwnership.RequestSimulationLock(lockRequest); diff --git a/NitroxPatcher/Patches/Dynamic/PilotingChair_ReleaseBy_Patch.cs b/NitroxPatcher/Patches/Dynamic/PilotingChair_ReleaseBy_Patch.cs index 9115d10134..b6a9ff9187 100644 --- a/NitroxPatcher/Patches/Dynamic/PilotingChair_ReleaseBy_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/PilotingChair_ReleaseBy_Patch.cs @@ -13,7 +13,7 @@ public class PilotingChair_ReleaseBy_Patch : NitroxPatch, IDynamicPatch { public static readonly Type TARGET_CLASS = typeof(PilotingChair); public static readonly MethodInfo TARGET_METHOD = TARGET_CLASS.GetMethod("ReleaseBy", BindingFlags.Public | BindingFlags.Instance); - + public static void Postfix(PilotingChair __instance) { SubRoot subRoot = __instance.GetComponentInParent(); diff --git a/NitroxPatcher/Patches/Dynamic/PingManager_NotifyRename_Patch.cs b/NitroxPatcher/Patches/Dynamic/PingManager_NotifyRename_Patch.cs index 641a952447..6f76a9c60b 100644 --- a/NitroxPatcher/Patches/Dynamic/PingManager_NotifyRename_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/PingManager_NotifyRename_Patch.cs @@ -4,10 +4,7 @@ using NitroxClient.Communication.Abstract; using NitroxClient.GameLogic.Helper; using NitroxClient.MonoBehaviours; -using NitroxClient.Unity.Helper; using NitroxModel.Core; -using NitroxModel.DataStructures; -using NitroxModel.Logger; using NitroxModel.Packets; namespace NitroxPatcher.Patches.Dynamic @@ -24,7 +21,7 @@ public static void Postfix(PingInstance instance) { return; } - + PingRenamed packet = new PingRenamed(NitroxEntity.GetId(instance.gameObject), instance.GetLabel(), SerializationHelper.GetBytes(instance.gameObject)); NitroxServiceLocator.LocateService().Send(packet); } diff --git a/NitroxPatcher/Patches/Dynamic/Player_OnKill_Patch.cs b/NitroxPatcher/Patches/Dynamic/Player_OnKill_Patch.cs index f4d628392b..01c99c610b 100644 --- a/NitroxPatcher/Patches/Dynamic/Player_OnKill_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Player_OnKill_Patch.cs @@ -1,12 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Reflection.Emit; using HarmonyLib; -using NitroxClient.MonoBehaviours.Overrides; -using NitroxModel.Helper; -using NitroxModel.Logger; namespace NitroxPatcher.Patches.Dynamic { @@ -30,7 +26,7 @@ public static IEnumerable Transpiler(MethodBase original, IEnum for (int i = 0; i < instructionList.Count; i++) { CodeInstruction instr = instructionList[i]; - + if (instr.opcode == OpCodes.Call && instr.operand.Equals(SKIP_METHOD)) { CodeInstruction newInstr = new CodeInstruction(OpCodes.Ldc_I4_0); diff --git a/NitroxPatcher/Patches/Dynamic/Player_SetCurrentEscapePod_Patch.cs b/NitroxPatcher/Patches/Dynamic/Player_SetCurrentEscapePod_Patch.cs index 16a99aa0e6..19ad7525e2 100644 --- a/NitroxPatcher/Patches/Dynamic/Player_SetCurrentEscapePod_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Player_SetCurrentEscapePod_Patch.cs @@ -6,7 +6,6 @@ using NitroxModel.Core; using NitroxModel.DataStructures; using NitroxModel.DataStructures.Util; -using NitroxModel.Logger; namespace NitroxPatcher.Patches.Dynamic { @@ -27,7 +26,7 @@ public static void Prefix(ref Player __instance, EscapePod value) } public override void Patch(Harmony harmony) - { + { PatchPrefix(harmony, TARGET_PROPERTY.GetSetMethod()); } } diff --git a/NitroxPatcher/Patches/Dynamic/PropulsionCannon_ReleaseGrabbedObject_Patch.cs b/NitroxPatcher/Patches/Dynamic/PropulsionCannon_ReleaseGrabbedObject_Patch.cs index fe2541d3d6..bff0e22f83 100644 --- a/NitroxPatcher/Patches/Dynamic/PropulsionCannon_ReleaseGrabbedObject_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/PropulsionCannon_ReleaseGrabbedObject_Patch.cs @@ -5,7 +5,6 @@ using NitroxClient.MonoBehaviours; using NitroxModel.Core; using NitroxModel.DataStructures; -using NitroxModel.Helper; using UnityEngine; namespace NitroxPatcher.Patches.Dynamic @@ -14,18 +13,18 @@ public class PropulsionCannon_ReleaseGrabbedObject_Patch : NitroxPatch, IDynamic { public static readonly Type TARGET_CLASS = typeof(PropulsionCannon); public static readonly MethodInfo TARGET_METHOD = TARGET_CLASS.GetMethod("ReleaseGrabbedObject", BindingFlags.Public | BindingFlags.Instance); - + public static bool Prefix(PropulsionCannon __instance) { GameObject grabbed = __instance.grabbedObject; - if(!grabbed) + if (!grabbed) { return false; } NitroxId id = NitroxEntity.GetId(grabbed); - + SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService(); // Request to be downgraded to a transient lock so we can still simulate the positioning. diff --git a/NitroxPatcher/Patches/Dynamic/Rocket_Start_Patch.cs b/NitroxPatcher/Patches/Dynamic/Rocket_Start_Patch.cs index 804d1d1fde..138f7bfd0e 100644 --- a/NitroxPatcher/Patches/Dynamic/Rocket_Start_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Rocket_Start_Patch.cs @@ -1,4 +1,5 @@ -using HarmonyLib; +using System.Reflection; +using HarmonyLib; using NitroxClient.GameLogic; using NitroxClient.MonoBehaviours; using NitroxClient.Unity.Helper; @@ -8,7 +9,6 @@ using NitroxModel.Helper; using NitroxModel.Logger; using NitroxModel_Subnautica.DataStructures.GameLogic; -using System.Reflection; using UnityEngine; namespace NitroxPatcher.Patches.Dynamic diff --git a/NitroxPatcher/Patches/Dynamic/SeaMoth_OnUpgradeModuleUse_Patch.cs b/NitroxPatcher/Patches/Dynamic/SeaMoth_OnUpgradeModuleUse_Patch.cs index f11dd5f49e..fd5f0e7bc0 100644 --- a/NitroxPatcher/Patches/Dynamic/SeaMoth_OnUpgradeModuleUse_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/SeaMoth_OnUpgradeModuleUse_Patch.cs @@ -1,5 +1,4 @@ -using System; -using System.Reflection; +using System.Reflection; using HarmonyLib; using NitroxClient.Communication; using NitroxClient.Communication.Abstract; diff --git a/NitroxPatcher/Patches/Dynamic/Sealed_Weld_Patch.cs b/NitroxPatcher/Patches/Dynamic/Sealed_Weld_Patch.cs index c459b92982..61fb39a141 100644 --- a/NitroxPatcher/Patches/Dynamic/Sealed_Weld_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Sealed_Weld_Patch.cs @@ -13,7 +13,7 @@ public class Sealed_Weld_Patch : NitroxPatch, IDynamicPatch { public static readonly Type TARGET_CLASS = typeof(Sealed); public static readonly MethodInfo TARGET_METHOD = TARGET_CLASS.GetMethod("Weld", BindingFlags.Public | BindingFlags.Instance); - + public static void Postfix(Sealed __instance) { NitroxId id = NitroxEntity.GetId(__instance.gameObject); diff --git a/NitroxPatcher/Patches/Dynamic/Seamoth_SubConstructionComplete_Patch.cs b/NitroxPatcher/Patches/Dynamic/Seamoth_SubConstructionComplete_Patch.cs index b7a5cbc30e..9ed89ea523 100644 --- a/NitroxPatcher/Patches/Dynamic/Seamoth_SubConstructionComplete_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Seamoth_SubConstructionComplete_Patch.cs @@ -24,7 +24,7 @@ public static bool Prefix(SeaMoth __instance) GameObject gameObject = __instance.gameObject; NitroxId id = NitroxEntity.GetId(gameObject); Optional model = NitroxServiceLocator.LocateService().TryGetVehicle(id); - + if (!model.HasValue) { Log.Error($"{nameof(Seamoth_SubConstructionComplete_Patch)}: Could not find {nameof(CyclopsModel)} by Nitrox id {id}.\nGO containing wrong id: {__instance.GetHierarchyPath()}"); diff --git a/NitroxPatcher/Patches/Dynamic/SpawnConsoleCommand_OnConsoleCommand_Patch.cs b/NitroxPatcher/Patches/Dynamic/SpawnConsoleCommand_OnConsoleCommand_Patch.cs index ec853436d6..d87ba0b5b7 100644 --- a/NitroxPatcher/Patches/Dynamic/SpawnConsoleCommand_OnConsoleCommand_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/SpawnConsoleCommand_OnConsoleCommand_Patch.cs @@ -33,7 +33,7 @@ public static IEnumerable Transpiler(MethodBase original, IEnum */ if (instruction.opcode == INJECTION_CODE && instruction.operand.Equals(INJECTION_OPERAND)) { - + yield return new CodeInstruction(OpCodes.Dup); yield return new CodeInstruction(OpCodes.Call, typeof(SpawnConsoleCommand_OnConsoleCommand_Patch).GetMethod("Callback", BindingFlags.Static | BindingFlags.Public)); } diff --git a/NitroxPatcher/Patches/Dynamic/Stalker_CheckLoseTooth_Patch.cs b/NitroxPatcher/Patches/Dynamic/Stalker_CheckLoseTooth_Patch.cs index 38dd295b16..aa2033290c 100644 --- a/NitroxPatcher/Patches/Dynamic/Stalker_CheckLoseTooth_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Stalker_CheckLoseTooth_Patch.cs @@ -17,7 +17,7 @@ public static bool Prefix(Stalker __instance, GameObject target) { float dropProbability = 0f; TechType techType = CraftData.GetTechType(target); - + if (techType == TechType.ScrapMetal) { dropProbability = 0.15f; //15% probability diff --git a/NitroxPatcher/Patches/Dynamic/StarshipDoor_OnDoorToggle_Patch.cs b/NitroxPatcher/Patches/Dynamic/StarshipDoor_OnDoorToggle_Patch.cs index 58b65a0a96..666a487de7 100644 --- a/NitroxPatcher/Patches/Dynamic/StarshipDoor_OnDoorToggle_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/StarshipDoor_OnDoorToggle_Patch.cs @@ -1,5 +1,4 @@ -using System; -using System.Reflection; +using System.Reflection; using HarmonyLib; using NitroxClient.GameLogic; using NitroxClient.MonoBehaviours; diff --git a/NitroxPatcher/Patches/Dynamic/SubNameInput_OnColorChange_Patch.cs b/NitroxPatcher/Patches/Dynamic/SubNameInput_OnColorChange_Patch.cs index 6eaae05fe4..ae0a208458 100644 --- a/NitroxPatcher/Patches/Dynamic/SubNameInput_OnColorChange_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/SubNameInput_OnColorChange_Patch.cs @@ -1,5 +1,4 @@ -using System; -using System.Reflection; +using System.Reflection; using HarmonyLib; using NitroxClient.Communication.Abstract; using NitroxClient.MonoBehaviours; diff --git a/NitroxPatcher/Patches/Dynamic/SubNameInput_OnNameChange_Patch.cs b/NitroxPatcher/Patches/Dynamic/SubNameInput_OnNameChange_Patch.cs index 0a72bf8554..e7229ff702 100644 --- a/NitroxPatcher/Patches/Dynamic/SubNameInput_OnNameChange_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/SubNameInput_OnNameChange_Patch.cs @@ -1,5 +1,4 @@ -using System; -using System.Reflection; +using System.Reflection; using HarmonyLib; using NitroxClient.Communication.Abstract; using NitroxClient.MonoBehaviours; diff --git a/NitroxPatcher/Patches/Dynamic/SubRoot_OnPlayerEntered_Patch.cs b/NitroxPatcher/Patches/Dynamic/SubRoot_OnPlayerEntered_Patch.cs index c206e929a1..0842470aad 100644 --- a/NitroxPatcher/Patches/Dynamic/SubRoot_OnPlayerEntered_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/SubRoot_OnPlayerEntered_Patch.cs @@ -14,7 +14,7 @@ class SubRoot_OnPlayerEntered_Patch : NitroxPatch, IDynamicPatch public static readonly OpCode START_INJECTION_CODE = OpCodes.Ldarg_0; public static readonly OpCode START_INJECTION_CODE_INVINCIBLE = OpCodes.Stfld; public static readonly FieldInfo LIVEMIXIN_INVINCIBLE = typeof(LiveMixin).GetField("invincible", BindingFlags.Public | BindingFlags.Instance); - + /* There is a bug, where Subroot.live is not loaded when starting in a cyclops. Therefore this codepiece needs to check that and jump accordingly if not present * * For this change @@ -31,7 +31,7 @@ class SubRoot_OnPlayerEntered_Patch : NitroxPatch, IDynamicPatch public static IEnumerable Transpiler(MethodBase original, IEnumerable instructions, ILGenerator generator) { List instructionList = instructions.ToList(); - + int injectionPoint = 0; Label newJumpPoint = generator.DefineLabel(); for (int i = 3; i < instructionList.Count; i++) @@ -40,14 +40,14 @@ public static IEnumerable Transpiler(MethodBase original, IEnum Equals(instructionList[i].operand, LIVEMIXIN_INVINCIBLE)) { if (instructionList[i - 3].opcode == START_INJECTION_CODE) - { + { instructionList[i + 1].labels.Add(newJumpPoint); - injectionPoint = i - 3; + injectionPoint = i - 3; } } } - if(injectionPoint != 0) + if (injectionPoint != 0) { MethodInfo op_inequality_method = typeof(UnityEngine.Object).GetMethod("op_Inequality"); @@ -59,7 +59,7 @@ public static IEnumerable Transpiler(MethodBase original, IEnum new CodeInstruction(OpCodes.Brfalse, newJumpPoint) }; instructionList.InsertRange(injectionPoint, injectedInstructions); - } + } return instructionList; } diff --git a/NitroxPatcher/Patches/Dynamic/ToggleLights_OnPoweredChanged_Patch.cs b/NitroxPatcher/Patches/Dynamic/ToggleLights_OnPoweredChanged_Patch.cs index c97c790525..a9e0606b1c 100644 --- a/NitroxPatcher/Patches/Dynamic/ToggleLights_OnPoweredChanged_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/ToggleLights_OnPoweredChanged_Patch.cs @@ -22,14 +22,14 @@ public static bool Prefix(ToggleLights __instance, bool powered) GameObject gameObject = null; // Suppress powered on if a seamoth´s default is set to false if (__instance.GetComponentInParent() != null && powered) - { + { gameObject = __instance.transform.parent.gameObject; NitroxId id = NitroxEntity.GetId(gameObject); - SeamothModel model = NitroxServiceLocator.LocateService().GetVehicles(id); + SeamothModel model = NitroxServiceLocator.LocateService().GetVehicles(id); return (model.LightOn == __instance.lightsActive); - } - - return true; + } + + return true; } diff --git a/NitroxPatcher/Patches/Dynamic/ToggleLights_SetLightsActive_Patch.cs b/NitroxPatcher/Patches/Dynamic/ToggleLights_SetLightsActive_Patch.cs index 12fa284e6b..d0f1e2e118 100644 --- a/NitroxPatcher/Patches/Dynamic/ToggleLights_SetLightsActive_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/ToggleLights_SetLightsActive_Patch.cs @@ -34,7 +34,7 @@ public static bool Prefix(ToggleLights __instance, out bool __state) } public static void Postfix(ToggleLights __instance, bool __state) - { + { if (__state != __instance.lightsActive) { // Find the right gameobject in the hierarchy to sync on: @@ -63,7 +63,7 @@ public static void Postfix(ToggleLights __instance, bool __state) NitroxId id = NitroxEntity.GetId(gameObject); // If the floodlight belongs to a seamoth, then set the lights for the model - if(type == typeof(SeaMoth)) + if (type == typeof(SeaMoth)) { NitroxServiceLocator.LocateService().GetVehicles(id).LightOn = __instance.lightsActive; } diff --git a/NitroxPatcher/Patches/Dynamic/Vehicle_OnHandClick_Patch.cs b/NitroxPatcher/Patches/Dynamic/Vehicle_OnHandClick_Patch.cs index 10fd4551b4..4ed44ee5dc 100644 --- a/NitroxPatcher/Patches/Dynamic/Vehicle_OnHandClick_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Vehicle_OnHandClick_Patch.cs @@ -24,9 +24,9 @@ public static bool Prefix(Vehicle __instance, GUIHand hand) { return true; } - + SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService(); - + NitroxId id = NitroxEntity.GetId(__instance.gameObject); if (simulationOwnership.HasExclusiveLock(id)) diff --git a/NitroxPatcher/Patches/Dynamic/Vehicle_OnKill_Patch.cs b/NitroxPatcher/Patches/Dynamic/Vehicle_OnKill_Patch.cs index a355d9ce3e..8c80e8935e 100644 --- a/NitroxPatcher/Patches/Dynamic/Vehicle_OnKill_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Vehicle_OnKill_Patch.cs @@ -5,7 +5,6 @@ using NitroxClient.MonoBehaviours; using NitroxModel.Core; using NitroxModel.DataStructures; -using NitroxModel.Logger; namespace NitroxPatcher.Patches.Dynamic { @@ -15,7 +14,7 @@ public class Vehicle_OnKill_Patch : NitroxPatch, IDynamicPatch public static readonly MethodInfo TARGET_METHOD = TARGET_CLASS.GetMethod("OnKill", BindingFlags.NonPublic | BindingFlags.Instance); public static void Prefix(Vehicle __instance) - { + { NitroxId id = NitroxEntity.GetId(__instance.gameObject); NitroxServiceLocator.LocateService().StopSimulatingEntity(id); } diff --git a/NitroxPatcher/Patches/Dynamic/Welder_Weld_Patch.cs b/NitroxPatcher/Patches/Dynamic/Welder_Weld_Patch.cs index d47cf90e09..49997d3ed0 100644 --- a/NitroxPatcher/Patches/Dynamic/Welder_Weld_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Welder_Weld_Patch.cs @@ -68,7 +68,7 @@ public static float AddHealthOverride(LiveMixin live, float addHealth, Welder we SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService(); NitroxId id = NitroxEntity.GetId(live.gameObject); - + // For now, we only control the LiveMixin for vehicles (not even repair nodes at a cyclops) // If we change that, this if should be removed! Vehicle vehicle = live.GetComponent(); diff --git a/NitroxPatcher/Patches/IDynamicPatch.cs b/NitroxPatcher/Patches/IDynamicPatch.cs index 8e782f7bb7..3ef7cfc70e 100644 --- a/NitroxPatcher/Patches/IDynamicPatch.cs +++ b/NitroxPatcher/Patches/IDynamicPatch.cs @@ -2,6 +2,6 @@ { public interface IDynamicPatch : INitroxPatch { - + } } diff --git a/NitroxPatcher/Patches/IPersistentPatch.cs b/NitroxPatcher/Patches/IPersistentPatch.cs index 19a9cc60a8..5c15b2a2eb 100644 --- a/NitroxPatcher/Patches/IPersistentPatch.cs +++ b/NitroxPatcher/Patches/IPersistentPatch.cs @@ -2,6 +2,6 @@ { public interface IPersistentPatch : INitroxPatch { - + } } diff --git a/NitroxPatcher/Patches/Persistent/CellManager_TryLoadCacheBatchCells_Patch.cs b/NitroxPatcher/Patches/Persistent/CellManager_TryLoadCacheBatchCells_Patch.cs index e18c84f185..81b8fcac89 100644 --- a/NitroxPatcher/Patches/Persistent/CellManager_TryLoadCacheBatchCells_Patch.cs +++ b/NitroxPatcher/Patches/Persistent/CellManager_TryLoadCacheBatchCells_Patch.cs @@ -1,9 +1,9 @@ using System; -using System.Reflection; -using HarmonyLib; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Reflection.Emit; +using HarmonyLib; namespace NitroxPatcher.Patches.Persistent { @@ -11,15 +11,15 @@ class CellManager_TryLoadCacheBatchCells_Patch : NitroxPatch, IPersistentPatch { public static readonly Type TARGET_CLASS = typeof(CellManager); public static readonly MethodInfo TARGET_METHOD = TARGET_CLASS.GetMethod("TryLoadCacheBatchCells", BindingFlags.Public | BindingFlags.Instance); - + public static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List instrList = instructions.ToList(); Label pathPrefixJmp = generator.DefineLabel(); - + Label labeledPathInstructionJmp = generator.DefineLabel(); - + Label fallbackPrefixJmp = generator.DefineLabel(); Label labeledFallbackInstructionJmp = generator.DefineLabel(); @@ -27,7 +27,7 @@ public static IEnumerable Transpiler(IEnumerable i + 2 && instrList[i+2].opcode == OpCodes.Callvirt && instrList[i+2].operand == (object)typeof(LargeWorldStreamer).GetProperty("pathPrefix", BindingFlags.Public | BindingFlags.Instance).GetGetMethod()) + if (instrList.Count > i + 2 && instrList[i + 2].opcode == OpCodes.Callvirt && instrList[i + 2].operand == (object)typeof(LargeWorldStreamer).GetProperty("pathPrefix", BindingFlags.Public | BindingFlags.Instance).GetGetMethod()) { foreach (CodeInstruction instr in TranspilerHelper.IsMultiplayer(pathPrefixJmp, generator)) { diff --git a/NitroxPatcher/Patches/Persistent/EscapePodFirstUseCinematicsController_Initialize_Patch.cs b/NitroxPatcher/Patches/Persistent/EscapePodFirstUseCinematicsController_Initialize_Patch.cs index 6a70e963d1..8b56060308 100644 --- a/NitroxPatcher/Patches/Persistent/EscapePodFirstUseCinematicsController_Initialize_Patch.cs +++ b/NitroxPatcher/Patches/Persistent/EscapePodFirstUseCinematicsController_Initialize_Patch.cs @@ -17,7 +17,7 @@ public static bool Prefix(EscapePodFirstUseCinematicsController __instance) __instance.bottomFirstUseCinematicTarget.gameObject.SetActive(false); __instance.topFirstUseCinematicTarget.gameObject.SetActive(false); - + return !Multiplayer.Active; } diff --git a/NitroxPatcher/Patches/Persistent/PAXTerrainController_LoadAsync_Patch.cs b/NitroxPatcher/Patches/Persistent/PAXTerrainController_LoadAsync_Patch.cs index 5d2c2b20c7..7c07432de3 100644 --- a/NitroxPatcher/Patches/Persistent/PAXTerrainController_LoadAsync_Patch.cs +++ b/NitroxPatcher/Patches/Persistent/PAXTerrainController_LoadAsync_Patch.cs @@ -44,7 +44,7 @@ public static IEnumerable Transpiler(MethodBase original, ILGen instruction.labels.Add(jmpLabelStartOfMethod); yield return instruction; // Add a label for jumping } - else if (instruction.opcode == OpCodes.Stfld && + else if (instruction.opcode == OpCodes.Stfld && Equals(instruction.operand, LARGE_WORLD_STREAMER_FROZEN_FIELD)) { yield return instruction; diff --git a/NitroxPatcher/Patches/Persistent/ProtobufSerializer_Deserialize_Patch.cs b/NitroxPatcher/Patches/Persistent/ProtobufSerializer_Deserialize_Patch.cs index 9cff169e82..7e0c696633 100644 --- a/NitroxPatcher/Patches/Persistent/ProtobufSerializer_Deserialize_Patch.cs +++ b/NitroxPatcher/Patches/Persistent/ProtobufSerializer_Deserialize_Patch.cs @@ -16,8 +16,7 @@ public class ProtobufSerializer_Deserialize_Patch : NitroxPatch, IPersistentPatc public static bool Prefix(Stream stream, object target, Type type) { - int key; - if (Multiplayer.Active && serializer.NitroxTypes.TryGetValue(type, out key)) + if (Multiplayer.Active && serializer.NitroxTypes.TryGetValue(type, out int key)) { serializer.Deserialize(stream, target, type); return false; diff --git a/NitroxPatcher/Patches/Persistent/ProtobufSerializer_Serialize_Patch.cs b/NitroxPatcher/Patches/Persistent/ProtobufSerializer_Serialize_Patch.cs index 4cd5cbd135..2e73d78d34 100644 --- a/NitroxPatcher/Patches/Persistent/ProtobufSerializer_Serialize_Patch.cs +++ b/NitroxPatcher/Patches/Persistent/ProtobufSerializer_Serialize_Patch.cs @@ -20,8 +20,7 @@ public class ProtobufSerializer_Serialize_Patch : NitroxPatch, IPersistentPatch public static bool Prefix(Stream stream, object source, Type type) { - int key; - if (Multiplayer.Active && serializer.NitroxTypes.TryGetValue(type, out key)) + if (Multiplayer.Active && serializer.NitroxTypes.TryGetValue(type, out int key)) { serializer.Serialize(stream, source); return false; diff --git a/NitroxPatcher/Patches/Persistent/SentrySdk_Start_Patch.cs b/NitroxPatcher/Patches/Persistent/SentrySdk_Start_Patch.cs index e7b46863e3..ad681b1247 100644 --- a/NitroxPatcher/Patches/Persistent/SentrySdk_Start_Patch.cs +++ b/NitroxPatcher/Patches/Persistent/SentrySdk_Start_Patch.cs @@ -1,7 +1,6 @@ using System; using System.Reflection; using HarmonyLib; -using NitroxClient.MonoBehaviours; namespace NitroxPatcher.Patches.Persistent { diff --git a/NitroxServer-Subnautica/Communication/Packets/Processors/ToggleLightsProcessor.cs b/NitroxServer-Subnautica/Communication/Packets/Processors/ToggleLightsProcessor.cs index cc7a36df03..a44a7cc9be 100644 --- a/NitroxServer-Subnautica/Communication/Packets/Processors/ToggleLightsProcessor.cs +++ b/NitroxServer-Subnautica/Communication/Packets/Processors/ToggleLightsProcessor.cs @@ -15,7 +15,7 @@ public ToggleLightsProcessor(VehicleManager vehicleManager, PlayerManager player { this.vehicleManager = vehicleManager; this.playerManager = playerManager; - } + } public override void Process(NitroxModel.Packets.ToggleLights packet, NitroxServer.Player player) { diff --git a/NitroxServer-Subnautica/GameLogic/Entities/Spawning/CrashFishBootstrapper.cs b/NitroxServer-Subnautica/GameLogic/Entities/Spawning/CrashFishBootstrapper.cs index 0a76e16dd2..53322dfc7d 100644 --- a/NitroxServer-Subnautica/GameLogic/Entities/Spawning/CrashFishBootstrapper.cs +++ b/NitroxServer-Subnautica/GameLogic/Entities/Spawning/CrashFishBootstrapper.cs @@ -1,7 +1,6 @@ using NitroxModel.DataStructures; using NitroxModel.DataStructures.GameLogic; using NitroxModel_Subnautica.DataStructures; -using NitroxModel_Subnautica.Helper; using NitroxServer.GameLogic.Entities.Spawning; namespace NitroxServer_Subnautica.GameLogic.Entities.Spawning.EntityBootstrappers diff --git a/NitroxServer-Subnautica/GameLogic/Entities/Spawning/ReefbackBootstrapper.cs b/NitroxServer-Subnautica/GameLogic/Entities/Spawning/ReefbackBootstrapper.cs index 521a405c1e..f1477875c9 100644 --- a/NitroxServer-Subnautica/GameLogic/Entities/Spawning/ReefbackBootstrapper.cs +++ b/NitroxServer-Subnautica/GameLogic/Entities/Spawning/ReefbackBootstrapper.cs @@ -20,7 +20,7 @@ public ReefbackBootstrapper() public void Prepare(Entity entity, Entity parentEntity, DeterministicBatchGenerator deterministicBatchGenerator) { - for(int spawnPointCounter = 0; spawnPointCounter < LocalCreatureSpawnPoints.Count; spawnPointCounter++) + for (int spawnPointCounter = 0; spawnPointCounter < LocalCreatureSpawnPoints.Count; spawnPointCounter++) { NitroxVector3 localSpawnPosition = LocalCreatureSpawnPoints[spawnPointCounter]; float targetProbabilitySum = (float)deterministicBatchGenerator.NextDouble() * creatureProbabiltySum; @@ -30,11 +30,11 @@ public void Prepare(Entity entity, Entity parentEntity, DeterministicBatchGenera { probabilitySum += creature.probability; - if(probabilitySum >= targetProbabilitySum) + if (probabilitySum >= targetProbabilitySum) { int totalToSpawn = deterministicBatchGenerator.NextInt(creature.minNumber, creature.maxNumber + 1); - for(int i = 0; i < totalToSpawn; i++) + for (int i = 0; i < totalToSpawn; i++) { NitroxId id = deterministicBatchGenerator.NextId(); Entity child = new Entity(localSpawnPosition, new NitroxQuaternion(0, 0, 0, 1), new NitroxVector3(1, 1, 1), creature.techType.ToDto(), entity.Level, creature.classId, true, id, null, parentEntity); diff --git a/NitroxServer-Subnautica/GameLogic/Entities/Spawning/ReefbackSpawnData.cs b/NitroxServer-Subnautica/GameLogic/Entities/Spawning/ReefbackSpawnData.cs index 54f32107e8..7c7831ef72 100644 --- a/NitroxServer-Subnautica/GameLogic/Entities/Spawning/ReefbackSpawnData.cs +++ b/NitroxServer-Subnautica/GameLogic/Entities/Spawning/ReefbackSpawnData.cs @@ -13,7 +13,7 @@ public struct ReefbackEntity public float probability; public string classId; } - + public static List SpawnableCreatures { get; } = new List() { new ReefbackEntity() { techType = TechType.Peeper, probability = 1, minNumber = 1, maxNumber = 2, classId = "3fcd548b-781f-46ba-b076-7412608deeef" }, diff --git a/NitroxServer-Subnautica/GameLogic/Entities/Spawning/SlotsHelper.cs b/NitroxServer-Subnautica/GameLogic/Entities/Spawning/SlotsHelper.cs index f535dacdc4..def833f2b6 100644 --- a/NitroxServer-Subnautica/GameLogic/Entities/Spawning/SlotsHelper.cs +++ b/NitroxServer-Subnautica/GameLogic/Entities/Spawning/SlotsHelper.cs @@ -12,14 +12,14 @@ public static class SlotsHelper { EntitySlotData.EntitySlotType.Tall, EntitySlot.Type.Tall }, { EntitySlotData.EntitySlotType.Creature, EntitySlot.Type.Creature } }; - + public static List GetEntitySlotTypes(IEntitySlot entitySlot) { - if(entitySlot is EntitySlot) + if (entitySlot is EntitySlot) { return ((EntitySlot)entitySlot).allowedTypes; } - else if(entitySlot is EntitySlotData) + else if (entitySlot is EntitySlotData) { return ConvertSlotTypes(((EntitySlotData)entitySlot).allowedTypes); } diff --git a/NitroxServer-Subnautica/GameLogic/Entities/Spawning/SubnauticaEntitySpawnPointFactory.cs b/NitroxServer-Subnautica/GameLogic/Entities/Spawning/SubnauticaEntitySpawnPointFactory.cs index ff746c6adb..307e294fe1 100644 --- a/NitroxServer-Subnautica/GameLogic/Entities/Spawning/SubnauticaEntitySpawnPointFactory.cs +++ b/NitroxServer-Subnautica/GameLogic/Entities/Spawning/SubnauticaEntitySpawnPointFactory.cs @@ -45,8 +45,7 @@ public override List From(AbsoluteEntityCell absoluteEntityCel private void HandleParenting(List spawnPoints, EntitySpawnPoint entitySpawnPoint, GameObject gameObject) { - EntitySpawnPoint parent; - if (gameObject.Parent != null && spawnPointsByUid.TryGetValue(gameObject.Parent, out parent)) + if (gameObject.Parent != null && spawnPointsByUid.TryGetValue(gameObject.Parent, out EntitySpawnPoint parent)) { entitySpawnPoint.Parent = parent; parent.Children.Add(entitySpawnPoint); diff --git a/NitroxServer-Subnautica/NitroxServer-Subnautica.csproj b/NitroxServer-Subnautica/NitroxServer-Subnautica.csproj index 0ef11e38a5..1fcf742764 100644 --- a/NitroxServer-Subnautica/NitroxServer-Subnautica.csproj +++ b/NitroxServer-Subnautica/NitroxServer-Subnautica.csproj @@ -21,22 +21,10 @@ 4 - + - - - ..\Nitrox.Subnautica.Assets\protobuf-net.dll - - - - - - - - - - - + + @@ -53,63 +41,75 @@ - + + + - + + + - - - - - - + - - - {0a377218-6b36-4522-89a3-a39cfc999209} - NitroxModel-Subnautica - + + + 4.9.4 + + + 0.11.3 + + + 2.0.6 + + + {b16f4de7-21ad-4fef-955b-0a5a365fa4e3} NitroxModel + + {0a377218-6b36-4522-89a3-a39cfc999209} + NitroxModel-Subnautica + {0fc864b0-694e-4fca-b78c-8ef98bc6f262} NitroxServer - - - 2.0.6 - - - 4.9.4 - - - 0.11.3 - + + + ..\Nitrox.Subnautica.Assets\protobuf-net.dll + + + + + + + + + - + \ No newline at end of file diff --git a/NitroxServer-Subnautica/Serialization/Resources/Parsers/Images/Texture2DAssetParser.cs b/NitroxServer-Subnautica/Serialization/Resources/Parsers/Images/Texture2DAssetParser.cs index c7a6998d7e..9eec14570e 100644 --- a/NitroxServer-Subnautica/Serialization/Resources/Parsers/Images/Texture2DAssetParser.cs +++ b/NitroxServer-Subnautica/Serialization/Resources/Parsers/Images/Texture2DAssetParser.cs @@ -3,12 +3,10 @@ using System.Drawing; using System.Drawing.Imaging; using System.IO; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; using AssetsTools.NET; -using NitroxServer.Serialization.Resources.Datastructures; using NitroxModel.DataStructures.GameLogic; +using NitroxServer.Serialization.Resources.Datastructures; namespace NitroxServer_Subnautica.Serialization.Resources.Parsers.Images { @@ -17,7 +15,7 @@ public class Texture2DAssetParser : AssetParser public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, ResourceAssets resourceAssets, Dictionary relativeFileIdToPath) { string assetName = reader.ReadCountStringInt32(); - + if (assetName == "RandomStart") { reader.Position += 9; @@ -42,7 +40,7 @@ public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, bmp.UnlockBits(picData); resourceAssets.NitroxRandom = new RandomStartGenerator(bmp); - } + } } } } diff --git a/NitroxServer-Subnautica/Serialization/Resources/Parsers/MonobehaviourAssetParser.cs b/NitroxServer-Subnautica/Serialization/Resources/Parsers/MonobehaviourAssetParser.cs index a817369a4f..7ef4e490a6 100644 --- a/NitroxServer-Subnautica/Serialization/Resources/Parsers/MonobehaviourAssetParser.cs +++ b/NitroxServer-Subnautica/Serialization/Resources/Parsers/MonobehaviourAssetParser.cs @@ -18,7 +18,7 @@ public class MonobehaviourAssetParser : AssetParser { "PrefabIdentifier", new PrefabIdentifierParser() }, { "EntitySlot", new EntitySlotParser() } }; - + public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, ResourceAssets resourceAssets, Dictionary relativeFileIdToPath) { MonobehaviourAsset monobehaviour = new MonobehaviourAsset(); @@ -33,7 +33,7 @@ public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, // that we do not care about. Monoscripts should be fully loaded before we actually parse anything // we do care about in resource.assets. If this becomes a problem later, we can do two passes and // load monobeahviours in the second pass. - if(!MonoscriptAssetParser.MonoscriptsByAssetId.ContainsKey(monobehaviour.MonoscriptIdentifier)) + if (!MonoscriptAssetParser.MonoscriptsByAssetId.ContainsKey(monobehaviour.MonoscriptIdentifier)) { return; } @@ -41,9 +41,8 @@ public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, MonoscriptAsset monoscript = MonoscriptAssetParser.MonoscriptsByAssetId[monobehaviour.MonoscriptIdentifier]; monobehaviour.MonoscriptName = monoscript.Name; - MonobehaviourParser monoResourceParser; - if (monobehaviourParsersByMonoscriptName.TryGetValue(monoscript.Name, out monoResourceParser)) + if (monobehaviourParsersByMonoscriptName.TryGetValue(monoscript.Name, out MonobehaviourParser monoResourceParser)) { monoResourceParser.Parse(identifier, monobehaviour.GameObjectIdentifier, reader, resourceAssets, relativeFileIdToPath); } diff --git a/NitroxServer-Subnautica/Serialization/Resources/Parsers/Monobehaviours/PrefabPlaceholderParser.cs b/NitroxServer-Subnautica/Serialization/Resources/Parsers/Monobehaviours/PrefabPlaceholderParser.cs index 2f0b9b0185..d9ebc9c72d 100644 --- a/NitroxServer-Subnautica/Serialization/Resources/Parsers/Monobehaviours/PrefabPlaceholderParser.cs +++ b/NitroxServer-Subnautica/Serialization/Resources/Parsers/Monobehaviours/PrefabPlaceholderParser.cs @@ -14,7 +14,7 @@ public override void Parse(AssetIdentifier identifier, AssetIdentifier gameObjec prefabPlaceholderAsset.Identifier = identifier; prefabPlaceholderAsset.GameObjectIdentifier = gameObjectIdentifier; prefabPlaceholderAsset.ClassId = reader.ReadCountStringInt32(); - + PrefabPlaceholderIdToPlaceholderAsset.Add(identifier, prefabPlaceholderAsset); } } diff --git a/NitroxServer-Subnautica/Serialization/Resources/Parsers/Monobehaviours/PrefabPlaceholdersGroupParser.cs b/NitroxServer-Subnautica/Serialization/Resources/Parsers/Monobehaviours/PrefabPlaceholdersGroupParser.cs index 5f5314c68e..cad624a861 100644 --- a/NitroxServer-Subnautica/Serialization/Resources/Parsers/Monobehaviours/PrefabPlaceholdersGroupParser.cs +++ b/NitroxServer-Subnautica/Serialization/Resources/Parsers/Monobehaviours/PrefabPlaceholdersGroupParser.cs @@ -13,7 +13,7 @@ public override void Parse(AssetIdentifier identifier, AssetIdentifier gameObjec List prefabPlaceholderIds = new List(); int placeholders = reader.ReadInt32(); - + for (int i = 0; i < placeholders; i++) { AssetIdentifier prefabPlaceholderId = new AssetIdentifier(relativeFileIdToPath[reader.ReadInt32()], reader.ReadInt64()); diff --git a/NitroxServer-Subnautica/Serialization/Resources/Parsers/TextAssetParser.cs b/NitroxServer-Subnautica/Serialization/Resources/Parsers/TextAssetParser.cs index 66cc1f9666..03380f358b 100644 --- a/NitroxServer-Subnautica/Serialization/Resources/Parsers/TextAssetParser.cs +++ b/NitroxServer-Subnautica/Serialization/Resources/Parsers/TextAssetParser.cs @@ -16,9 +16,8 @@ public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, { string assetName = reader.ReadCountStringInt32(); - AssetParser textResourceParser; - if (textParsersByAssetName.TryGetValue(assetName, out textResourceParser)) + if (textParsersByAssetName.TryGetValue(assetName, out AssetParser textResourceParser)) { textResourceParser.Parse(identifier, reader, resourceAssets, relativeFileIdToPath); } diff --git a/NitroxServer-Subnautica/Serialization/Resources/Processing/PrefabPlaceholderExtractor.cs b/NitroxServer-Subnautica/Serialization/Resources/Processing/PrefabPlaceholderExtractor.cs index 9e27c7cddc..84d5636f73 100644 --- a/NitroxServer-Subnautica/Serialization/Resources/Processing/PrefabPlaceholderExtractor.cs +++ b/NitroxServer-Subnautica/Serialization/Resources/Processing/PrefabPlaceholderExtractor.cs @@ -27,9 +27,8 @@ public void LoadInto(ResourceAssets resourceAssets) foreach (GameObjectAsset placeholderGroup in GameObjectAssetParser.GameObjectsByAssetId.Values) { - List prefabPlaceholders; - if (!PrefabPlaceholdersGroupParser.PrefabPlaceholderIdsByGameObjectId.TryGetValue(placeholderGroup.Identifier, out prefabPlaceholders)) + if (!PrefabPlaceholdersGroupParser.PrefabPlaceholderIdsByGameObjectId.TryGetValue(placeholderGroup.Identifier, out List prefabPlaceholders)) { continue; } @@ -72,9 +71,8 @@ private List GetChildPrefabs(TransformAsset parentTransform) { TransformAsset childTransform = TransformAssetParser.TransformsByAssetId[childTransformId]; - string childClassId; - PrefabIdentifierParser.ClassIdByGameObjectId.TryGetValue(childTransform.GameObjectIdentifier, out childClassId); + PrefabIdentifierParser.ClassIdByGameObjectId.TryGetValue(childTransform.GameObjectIdentifier, out string childClassId); children.Add(CreatePrefabAsset(childTransform.GameObjectIdentifier, childClassId)); } @@ -86,9 +84,8 @@ private Optional GetEntitySlot(string classId) { AssetIdentifier prefabId = PrefabIdentifierParser.GameObjectIdByClassId[classId]; GameObjectAsset gameObject = GameObjectAssetParser.GameObjectsByAssetId[prefabId]; - NitroxEntitySlot entitySlot; - EntitySlotParser.EntitySlotsByIdentifier.TryGetValue(gameObject.Identifier, out entitySlot); + EntitySlotParser.EntitySlotsByIdentifier.TryGetValue(gameObject.Identifier, out NitroxEntitySlot entitySlot); return Optional.OfNullable(entitySlot); } @@ -97,9 +94,8 @@ private TransformAsset GetTransform(GameObjectAsset gameObjectAsset) { foreach (AssetIdentifier componentIdentifier in gameObjectAsset.Components) { - TransformAsset transform; - if (TransformAssetParser.TransformsByAssetId.TryGetValue(componentIdentifier, out transform)) + if (TransformAssetParser.TransformsByAssetId.TryGetValue(componentIdentifier, out TransformAsset transform)) { return transform; } diff --git a/NitroxServer-Subnautica/Serialization/Resources/ResourceAssets.cs b/NitroxServer-Subnautica/Serialization/Resources/ResourceAssets.cs index d63075f0ed..583b1ca026 100644 --- a/NitroxServer-Subnautica/Serialization/Resources/ResourceAssets.cs +++ b/NitroxServer-Subnautica/Serialization/Resources/ResourceAssets.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; -using NitroxModel.Helper; using NitroxModel.DataStructures.GameLogic; -using UWE; +using NitroxModel.Helper; using NitroxServer.Serialization.Resources.Datastructures; +using UWE; namespace NitroxServer_Subnautica.Serialization.Resources diff --git a/NitroxServer-Subnautica/Serialization/Resources/ResourceAssetsParser.cs b/NitroxServer-Subnautica/Serialization/Resources/ResourceAssetsParser.cs index cbe019fad4..d19f45232f 100644 --- a/NitroxServer-Subnautica/Serialization/Resources/ResourceAssetsParser.cs +++ b/NitroxServer-Subnautica/Serialization/Resources/ResourceAssetsParser.cs @@ -3,11 +3,10 @@ using System.IO; using AssetsTools.NET; using NitroxModel.Discovery; +using NitroxServer.Serialization.Resources.Datastructures; using NitroxServer_Subnautica.Serialization.Resources.Parsers; using NitroxServer_Subnautica.Serialization.Resources.Parsers.Images; using NitroxServer_Subnautica.Serialization.Resources.Processing; -using NitroxServer.Serialization.Resources.Datastructures; -using NitroxModel.Logger; namespace NitroxServer_Subnautica.Serialization.Resources { @@ -104,9 +103,8 @@ private static void ParseAssetManifest(string basePath, string fileName, Resourc AssetIdentifier identifier = new AssetIdentifier(path, assetFileInfo.index); - AssetParser assetParser; - if (assetParsersByClassId.TryGetValue(assetFileInfo.curFileType, out assetParser)) + if (assetParsersByClassId.TryGetValue(assetFileInfo.curFileType, out AssetParser assetParser)) { assetParser.Parse(identifier, reader, resourceAssets, relativeFileIdToPath); } diff --git a/NitroxServer-Subnautica/Serialization/SubnauticaServerProtoBufSerializer.cs b/NitroxServer-Subnautica/Serialization/SubnauticaServerProtoBufSerializer.cs index 931828ab7b..6990e3f5a7 100644 --- a/NitroxServer-Subnautica/Serialization/SubnauticaServerProtoBufSerializer.cs +++ b/NitroxServer-Subnautica/Serialization/SubnauticaServerProtoBufSerializer.cs @@ -30,7 +30,7 @@ private void RegisterHardCodedTypes() Model.Add(typeof(NitroxQuaternion), false).SetSurrogate(typeof(QuaternionSurrogate)); Model.Add(typeof(Transform), false).SetSurrogate(typeof(NitroxTransform)); Model.Add(typeof(GameObject), false).SetSurrogate(typeof(NitroxServer.UnityStubs.GameObject)); - + MetaType vehicleModel = Model.Add(typeof(VehicleModel), false); vehicleModel.AddSubType(100, typeof(ExosuitModel)); vehicleModel.AddSubType(200, typeof(SeamothModel)); diff --git a/NitroxServer/Communication/Packets/PacketHandler.cs b/NitroxServer/Communication/Packets/PacketHandler.cs index 8fb9869ff0..b27f36f1b8 100644 --- a/NitroxServer/Communication/Packets/PacketHandler.cs +++ b/NitroxServer/Communication/Packets/PacketHandler.cs @@ -1,12 +1,12 @@ using System; +using NitroxModel.Core; +using NitroxModel.DataStructures.Util; using NitroxModel.Logger; using NitroxModel.Packets; using NitroxModel.Packets.Processors.Abstract; using NitroxServer.Communication.Packets.Processors; using NitroxServer.Communication.Packets.Processors.Abstract; using NitroxServer.GameLogic; -using NitroxModel.Core; -using NitroxModel.DataStructures.Util; namespace NitroxServer.Communication.Packets { diff --git a/NitroxServer/Communication/Packets/Processors/BasePieceMetadataChangedPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/BasePieceMetadataChangedPacketProcessor.cs index 2042eba5c6..506b2d8ca2 100644 --- a/NitroxServer/Communication/Packets/Processors/BasePieceMetadataChangedPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/BasePieceMetadataChangedPacketProcessor.cs @@ -9,7 +9,7 @@ public class BasePieceMetadataChangedPacketProcessor : AuthenticatedPacketProces { private readonly BaseManager baseManager; private readonly PlayerManager playerManager; - + public BasePieceMetadataChangedPacketProcessor(BaseManager baseManager, PlayerManager playerManager) { this.baseManager = baseManager; diff --git a/NitroxServer/Communication/Packets/Processors/ChatMessageProcessor.cs b/NitroxServer/Communication/Packets/Processors/ChatMessageProcessor.cs index 5f832df77b..5ea5242631 100644 --- a/NitroxServer/Communication/Packets/Processors/ChatMessageProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/ChatMessageProcessor.cs @@ -1,6 +1,6 @@ using NitroxModel.Logger; -using NitroxServer.Communication.Packets.Processors.Abstract; using NitroxModel.Packets; +using NitroxServer.Communication.Packets.Processors.Abstract; using NitroxServer.GameLogic; namespace NitroxServer.Communication.Packets.Processors diff --git a/NitroxServer/Communication/Packets/Processors/ConstructionAmountChangedPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/ConstructionAmountChangedPacketProcessor.cs index 196edfe0e8..24bd04af4e 100644 --- a/NitroxServer/Communication/Packets/Processors/ConstructionAmountChangedPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/ConstructionAmountChangedPacketProcessor.cs @@ -9,7 +9,7 @@ public class ConstructionAmountChangedPacketProcessor : AuthenticatedPacketProce { private readonly BaseManager baseManager; private readonly PlayerManager playerManager; - + public ConstructionAmountChangedPacketProcessor(BaseManager baseManager, PlayerManager playerManager) { this.baseManager = baseManager; diff --git a/NitroxServer/Communication/Packets/Processors/ConstructionCompletedPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/ConstructionCompletedPacketProcessor.cs index 178c25ef30..b630bedbef 100644 --- a/NitroxServer/Communication/Packets/Processors/ConstructionCompletedPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/ConstructionCompletedPacketProcessor.cs @@ -9,7 +9,7 @@ public class ConstructionCompletedPacketProcessor : AuthenticatedPacketProcessor { private readonly BaseManager baseManager; private readonly PlayerManager playerManager; - + public ConstructionCompletedPacketProcessor(BaseManager baseManager, PlayerManager playerManager) { this.baseManager = baseManager; diff --git a/NitroxServer/Communication/Packets/Processors/DeconstructionBeginPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/DeconstructionBeginPacketProcessor.cs index 5e0570ef0b..6eb005e6e2 100644 --- a/NitroxServer/Communication/Packets/Processors/DeconstructionBeginPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/DeconstructionBeginPacketProcessor.cs @@ -9,7 +9,7 @@ public class DeconstructionBeginPacketProcessor : AuthenticatedPacketProcessor updates, { Optional currentCell = entityManager.UpdateEntityPosition(update.Id, update.Position, update.Rotation); - if(!currentCell.HasValue) + if (!currentCell.HasValue) { // Normal behaviour if the entity was removed at the same time as someone trying to simulate a postion update. // we log an info inside entityManager.UpdateEntityPosition just in case. diff --git a/NitroxServer/Communication/Packets/Processors/EscapePodRadioRepairProcessor.cs b/NitroxServer/Communication/Packets/Processors/EscapePodRadioRepairProcessor.cs index 96140254b7..3bfe9789b3 100644 --- a/NitroxServer/Communication/Packets/Processors/EscapePodRadioRepairProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/EscapePodRadioRepairProcessor.cs @@ -19,7 +19,7 @@ public EscapePodRadioRepairProcessor(World world, PlayerManager playerManager) public override void Process(EscapePodRadioRepair packet, Player player) { world.EscapePodManager.RepairEscapePodRadio(packet.Id); - playerManager.SendPacketToOtherPlayers(packet, player); + playerManager.SendPacketToOtherPlayers(packet, player); } } diff --git a/NitroxServer/Communication/Packets/Processors/EscapePodRepairProcessor.cs b/NitroxServer/Communication/Packets/Processors/EscapePodRepairProcessor.cs index 75667e3635..38e6e3c1dd 100644 --- a/NitroxServer/Communication/Packets/Processors/EscapePodRepairProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/EscapePodRepairProcessor.cs @@ -19,7 +19,7 @@ public EscapePodRepairProcessor(World world, PlayerManager playerManager) public override void Process(EscapePodRepair packet, Player player) { world.EscapePodManager.RepairEscapePod(packet.Id); - playerManager.SendPacketToOtherPlayers(packet, player); + playerManager.SendPacketToOtherPlayers(packet, player); } } diff --git a/NitroxServer/Communication/Packets/Processors/KnownTechEntryAddProcessor.cs b/NitroxServer/Communication/Packets/Processors/KnownTechEntryAddProcessor.cs index 1dac22fe2c..909fbc92e4 100644 --- a/NitroxServer/Communication/Packets/Processors/KnownTechEntryAddProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/KnownTechEntryAddProcessor.cs @@ -19,7 +19,7 @@ public KnownTechEntryAddProcessor(PlayerManager playerManager, PDAStateData pdaS public override void Process(KnownTechEntryAdd packet, Player player) { pdaStateData.AddKnownTechType(packet.TechType); - playerManager.SendPacketToOtherPlayers(packet, player); + playerManager.SendPacketToOtherPlayers(packet, player); } } diff --git a/NitroxServer/Communication/Packets/Processors/ModuleRemovedProcessor.cs b/NitroxServer/Communication/Packets/Processors/ModuleRemovedProcessor.cs index f644df5b2d..7e8b7c5020 100644 --- a/NitroxServer/Communication/Packets/Processors/ModuleRemovedProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/ModuleRemovedProcessor.cs @@ -1,5 +1,4 @@ -using System; -using NitroxModel.Packets; +using NitroxModel.Packets; using NitroxServer.Communication.Packets.Processors.Abstract; using NitroxServer.GameLogic; using NitroxServer.GameLogic.Items; diff --git a/NitroxServer/Communication/Packets/Processors/MultiplayerSessionPolicyRequestProcessor.cs b/NitroxServer/Communication/Packets/Processors/MultiplayerSessionPolicyRequestProcessor.cs index 0c0e8a90ed..e7504bfb24 100644 --- a/NitroxServer/Communication/Packets/Processors/MultiplayerSessionPolicyRequestProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/MultiplayerSessionPolicyRequestProcessor.cs @@ -1,6 +1,5 @@ using NitroxModel.Logger; using NitroxModel.Packets; -using NitroxModel.Server; using NitroxServer.Communication.Packets.Processors.Abstract; using NitroxServer.Serialization; diff --git a/NitroxServer/Communication/Packets/Processors/PickupItemPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/PickupItemPacketProcessor.cs index f474076449..ba5d2a2e22 100644 --- a/NitroxServer/Communication/Packets/Processors/PickupItemPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/PickupItemPacketProcessor.cs @@ -20,13 +20,13 @@ public PickupItemPacketProcessor(EntityManager entityManager, PlayerManager play public override void Process(PickupItem packet, Player player) { - if(simulationOwnershipData.RevokeOwnerOfId(packet.Id)) + if (simulationOwnershipData.RevokeOwnerOfId(packet.Id)) { ushort serverId = ushort.MaxValue; SimulationOwnershipChange simulationOwnershipChange = new SimulationOwnershipChange(packet.Id, serverId, NitroxModel.DataStructures.SimulationLockType.TRANSIENT); playerManager.SendPacketToAllPlayers(simulationOwnershipChange); } - + entityManager.PickUpEntity(packet.Id); playerManager.SendPacketToOtherPlayers(packet, player); } diff --git a/NitroxServer/Communication/Packets/Processors/PlaceBasePiecePacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/PlaceBasePiecePacketProcessor.cs index 01893f9c00..6f92c3d786 100644 --- a/NitroxServer/Communication/Packets/Processors/PlaceBasePiecePacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/PlaceBasePiecePacketProcessor.cs @@ -9,7 +9,7 @@ public class PlaceBasePiecePacketProcessor : AuthenticatedPacketProcessor + public class RadioPlayPendingMessageProcessor : AuthenticatedPacketProcessor { private readonly StoryGoalData storyGoalData; private readonly PlayerManager playerManager; @@ -15,7 +15,7 @@ public RadioPlayPendingMessageProcessor(StoryGoalData storyGoalData, PlayerManag this.storyGoalData = storyGoalData; this.playerManager = playerManager; } - + public override void Process(RadioPlayPendingMessage packet, Player player) { storyGoalData.RemovedLatestRadioMessage(); diff --git a/NitroxServer/Communication/Packets/Processors/SimulationOwnershipRequestProcessor.cs b/NitroxServer/Communication/Packets/Processors/SimulationOwnershipRequestProcessor.cs index eb3bb0510f..2ef5947446 100644 --- a/NitroxServer/Communication/Packets/Processors/SimulationOwnershipRequestProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/SimulationOwnershipRequestProcessor.cs @@ -18,7 +18,7 @@ public SimulationOwnershipRequestProcessor(PlayerManager playerManager, Simulati public override void Process(SimulationOwnershipRequest ownershipRequest, Player player) { bool aquiredLock = simulationOwnershipData.TryToAcquire(ownershipRequest.Id, player, ownershipRequest.LockType); - + if (aquiredLock) { SimulationOwnershipChange simulationOwnershipChange = new SimulationOwnershipChange(ownershipRequest.Id, player.Id, ownershipRequest.LockType); diff --git a/NitroxServer/Communication/Packets/Processors/StorageSlotRemoveItemProcessor.cs b/NitroxServer/Communication/Packets/Processors/StorageSlotRemoveItemProcessor.cs index 956e484780..d3fb79ec06 100644 --- a/NitroxServer/Communication/Packets/Processors/StorageSlotRemoveItemProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/StorageSlotRemoveItemProcessor.cs @@ -19,8 +19,8 @@ public StorageSlotRemoveItemProcessor(PlayerManager playerManager, InventoryMana public override void Process(StorageSlotItemRemove packet, Player player) { // Only need to send to other players, if an synced item was really removed - if (inventoryManager.StorageItemRemoved(packet.OwnerId)) - { + if (inventoryManager.StorageItemRemoved(packet.OwnerId)) + { playerManager.SendPacketToOtherPlayers(packet, player); } } diff --git a/NitroxServer/Communication/Packets/Processors/WeldActionProcessor.cs b/NitroxServer/Communication/Packets/Processors/WeldActionProcessor.cs index c659c80b4e..035c3e76ea 100644 --- a/NitroxServer/Communication/Packets/Processors/WeldActionProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/WeldActionProcessor.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NitroxModel.Logger; +using NitroxModel.Logger; using NitroxModel.Packets; using NitroxServer.Communication.Packets.Processors.Abstract; using NitroxServer.GameLogic; diff --git a/NitroxServer/Communication/PortForward.cs b/NitroxServer/Communication/PortForward.cs index 92f864e1bd..87f5b60d2a 100644 --- a/NitroxServer/Communication/PortForward.cs +++ b/NitroxServer/Communication/PortForward.cs @@ -57,10 +57,10 @@ public static string GetError(int port) { return ex.Message; } - + return null; } - + public static async Task IsPortOpenAsync(int port, TimeSpan timeout) { CancellationTokenSource source = new(timeout); diff --git a/NitroxServer/ConsoleCommands/AutosaveCommand.cs b/NitroxServer/ConsoleCommands/AutosaveCommand.cs index b3dc2a373e..94c04029b6 100644 --- a/NitroxServer/ConsoleCommands/AutosaveCommand.cs +++ b/NitroxServer/ConsoleCommands/AutosaveCommand.cs @@ -1,5 +1,4 @@ using NitroxModel.DataStructures.GameLogic; -using NitroxModel.Serialization; using NitroxServer.ConsoleCommands.Abstract; using NitroxServer.ConsoleCommands.Abstract.Type; using NitroxServer.Serialization; diff --git a/NitroxServer/ConsoleCommands/ChangeAdminPasswordCommand.cs b/NitroxServer/ConsoleCommands/ChangeAdminPasswordCommand.cs index d423a9d3b6..bb8e1df3cc 100644 --- a/NitroxServer/ConsoleCommands/ChangeAdminPasswordCommand.cs +++ b/NitroxServer/ConsoleCommands/ChangeAdminPasswordCommand.cs @@ -25,7 +25,7 @@ protected override void Execute(CallArgs args) c.AdminPassword = newPassword; Log.InfoSensitive("Admin password changed to {password} by {playername}", newPassword, args.SenderName); }); - + SendMessageToPlayer(args.Sender, "Admin password has been updated"); } } diff --git a/NitroxServer/ConsoleCommands/ChangeServerGamemodeCommand.cs b/NitroxServer/ConsoleCommands/ChangeServerGamemodeCommand.cs index a5f7a87c6b..9e3356a9d0 100644 --- a/NitroxServer/ConsoleCommands/ChangeServerGamemodeCommand.cs +++ b/NitroxServer/ConsoleCommands/ChangeServerGamemodeCommand.cs @@ -1,6 +1,5 @@ using NitroxModel.DataStructures.GameLogic; using NitroxModel.Packets; -using NitroxModel.Serialization; using NitroxModel.Server; using NitroxServer.ConsoleCommands.Abstract; using NitroxServer.ConsoleCommands.Abstract.Type; diff --git a/NitroxServer/ConsoleCommands/ChangeServerPasswordCommand.cs b/NitroxServer/ConsoleCommands/ChangeServerPasswordCommand.cs index b73a99d597..67e4af7c1f 100644 --- a/NitroxServer/ConsoleCommands/ChangeServerPasswordCommand.cs +++ b/NitroxServer/ConsoleCommands/ChangeServerPasswordCommand.cs @@ -1,6 +1,5 @@ using NitroxModel.DataStructures.GameLogic; using NitroxModel.Logger; -using NitroxModel.Serialization; using NitroxServer.ConsoleCommands.Abstract; using NitroxServer.ConsoleCommands.Abstract.Type; using NitroxServer.Serialization; diff --git a/NitroxServer/ConsoleCommands/ConfigCommand.cs b/NitroxServer/ConsoleCommands/ConfigCommand.cs index 15e0c96619..cbb4d77b97 100644 --- a/NitroxServer/ConsoleCommands/ConfigCommand.cs +++ b/NitroxServer/ConsoleCommands/ConfigCommand.cs @@ -7,7 +7,6 @@ using NitroxModel.DataStructures.GameLogic; using NitroxModel.Logger; using NitroxModel.OS; -using NitroxModel.Serialization; using NitroxServer.ConsoleCommands.Abstract; using NitroxServer.Serialization; diff --git a/NitroxServer/ConsoleCommands/DebugStartMapCommand.cs b/NitroxServer/ConsoleCommands/DebugStartMapCommand.cs index 9961fc2273..628c99eb87 100644 --- a/NitroxServer/ConsoleCommands/DebugStartMapCommand.cs +++ b/NitroxServer/ConsoleCommands/DebugStartMapCommand.cs @@ -1,10 +1,10 @@ #if DEBUG +using System.Collections.Generic; using NitroxModel.DataStructures.GameLogic; +using NitroxModel.Packets; using NitroxServer.ConsoleCommands.Abstract; -using NitroxServer.Serialization.World; -using System.Collections.Generic; using NitroxServer.GameLogic; -using NitroxModel.Packets; +using NitroxServer.Serialization.World; namespace NitroxServer.ConsoleCommands { diff --git a/NitroxServer/ConsoleCommands/LoginCommand.cs b/NitroxServer/ConsoleCommands/LoginCommand.cs index 4d7bf592dd..f8e64f7b7f 100644 --- a/NitroxServer/ConsoleCommands/LoginCommand.cs +++ b/NitroxServer/ConsoleCommands/LoginCommand.cs @@ -1,5 +1,4 @@ using NitroxModel.DataStructures.GameLogic; -using NitroxModel.Helper; using NitroxServer.ConsoleCommands.Abstract; using NitroxServer.ConsoleCommands.Abstract.Type; using NitroxServer.Serialization; diff --git a/NitroxServer/ConsoleCommands/SwapSerializerCommand.cs b/NitroxServer/ConsoleCommands/SwapSerializerCommand.cs index db833a1913..badc2b26e9 100644 --- a/NitroxServer/ConsoleCommands/SwapSerializerCommand.cs +++ b/NitroxServer/ConsoleCommands/SwapSerializerCommand.cs @@ -1,5 +1,4 @@ using NitroxModel.DataStructures.GameLogic; -using NitroxModel.Serialization; using NitroxModel.Server; using NitroxServer.ConsoleCommands.Abstract; using NitroxServer.ConsoleCommands.Abstract.Type; diff --git a/NitroxServer/GameLogic/Bases/BaseData.cs b/NitroxServer/GameLogic/Bases/BaseData.cs index 2c004aaf5a..f558cab842 100644 --- a/NitroxServer/GameLogic/Bases/BaseData.cs +++ b/NitroxServer/GameLogic/Bases/BaseData.cs @@ -1,6 +1,6 @@ -using NitroxModel.DataStructures.GameLogic; -using System.Collections.Generic; +using System.Collections.Generic; using Newtonsoft.Json; +using NitroxModel.DataStructures.GameLogic; using ProtoBufNet; namespace NitroxServer.GameLogic.Bases diff --git a/NitroxServer/GameLogic/Bases/BaseManager.cs b/NitroxServer/GameLogic/Bases/BaseManager.cs index ed0f521df8..175746bc74 100644 --- a/NitroxServer/GameLogic/Bases/BaseManager.cs +++ b/NitroxServer/GameLogic/Bases/BaseManager.cs @@ -1,10 +1,10 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Linq; +using NitroxModel.DataStructures; using NitroxModel.DataStructures.GameLogic; using NitroxModel.DataStructures.GameLogic.Buildings.Metadata; -using NitroxModel.DataStructures; -using System.Linq; using NitroxModel.DataStructures.Util; -using System; namespace NitroxServer.GameLogic.Bases { @@ -27,7 +27,7 @@ public BaseManager(List partiallyConstructedPieces, List c public List GetCompletedBasePieceHistory() { - lock(completedBasePieceHistory) + lock (completedBasePieceHistory) { return new List(completedBasePieceHistory); } @@ -52,11 +52,10 @@ public void AddBasePiece(BasePiece basePiece) public void BasePieceConstructionAmountChanged(NitroxId id, float constructionAmount) { - BasePiece basePiece; lock (partiallyConstructedPiecesById) { - if (partiallyConstructedPiecesById.TryGetValue(id, out basePiece)) + if (partiallyConstructedPiecesById.TryGetValue(id, out BasePiece basePiece)) { basePiece.ConstructionAmount = constructionAmount; @@ -70,16 +69,15 @@ public void BasePieceConstructionAmountChanged(NitroxId id, float constructionAm public void BasePieceConstructionCompleted(NitroxId id, NitroxId baseId) { - BasePiece basePiece; lock (partiallyConstructedPiecesById) { - if (partiallyConstructedPiecesById.TryGetValue(id, out basePiece)) + if (partiallyConstructedPiecesById.TryGetValue(id, out BasePiece basePiece)) { basePiece.ConstructionAmount = 1.0f; basePiece.ConstructionCompleted = true; - if(!basePiece.IsFurniture) + if (!basePiece.IsFurniture) { // For standard base pieces, the baseId is may not be finialized until construction // completes because Subnautica uses a GhostBase in the world if there hasn't yet been @@ -113,12 +111,12 @@ public void BasePieceDeconstructionBegin(NitroxId id) basePiece.ConstructionCompleted = false; completedBasePieceHistory.Remove(basePiece); - lock(partiallyConstructedPiecesById) + lock (partiallyConstructedPiecesById) { partiallyConstructedPiecesById[basePiece.Id] = basePiece; } } - } + } } public void BasePieceDeconstructionCompleted(NitroxId id) diff --git a/NitroxServer/GameLogic/Entities/EntityManager.cs b/NitroxServer/GameLogic/Entities/EntityManager.cs index 34040a2466..32b9cd8433 100644 --- a/NitroxServer/GameLogic/Entities/EntityManager.cs +++ b/NitroxServer/GameLogic/Entities/EntityManager.cs @@ -1,10 +1,10 @@ -using NitroxModel.DataStructures.GameLogic; -using NitroxServer.GameLogic.Entities.Spawning; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using NitroxModel.DataStructures; +using NitroxModel.DataStructures.GameLogic; using NitroxModel.DataStructures.Util; using NitroxModel.Logger; -using NitroxModel.DataStructures; +using NitroxServer.GameLogic.Entities.Spawning; namespace NitroxServer.GameLogic.Entities { @@ -153,9 +153,8 @@ public void RegisterNewEntity(Entity entity) { lock (phasingEntitiesByAbsoluteCell) { - List phasingEntitiesInCell = null; - if (!phasingEntitiesByAbsoluteCell.TryGetValue(entity.AbsoluteEntityCell, out phasingEntitiesInCell)) + if (!phasingEntitiesByAbsoluteCell.TryGetValue(entity.AbsoluteEntityCell, out List phasingEntitiesInCell)) { phasingEntitiesInCell = phasingEntitiesByAbsoluteCell[entity.AbsoluteEntityCell] = new List(); } @@ -187,9 +186,8 @@ public void PickUpEntity(NitroxId id) { lock (phasingEntitiesByAbsoluteCell) { - List entities; - if (phasingEntitiesByAbsoluteCell.TryGetValue(entity.AbsoluteEntityCell, out entities)) + if (phasingEntitiesByAbsoluteCell.TryGetValue(entity.AbsoluteEntityCell, out List entities)) { entities.Remove(entity); } diff --git a/NitroxServer/GameLogic/Entities/EntitySimulator.cs b/NitroxServer/GameLogic/Entities/EntitySimulator.cs index e0975e2abd..8bbe19868f 100644 --- a/NitroxServer/GameLogic/Entities/EntitySimulator.cs +++ b/NitroxServer/GameLogic/Entities/EntitySimulator.cs @@ -60,8 +60,8 @@ public SimulatedEntity AssignNewEntityToPlayer(Entity entity, Player player) public IEnumerable AssignGlobalRootEntities(Player player) { List globalRootEntities = entityManager.GetGlobalRootEntities(); - IEnumerable entities = globalRootEntities.Where(entity => simulationOwnershipData.TryToAcquire(entity.Id, player, SimulationLockType.TRANSIENT)); - foreach(Entity entity in entities) + IEnumerable entities = globalRootEntities.Where(entity => simulationOwnershipData.TryToAcquire(entity.Id, player, SimulationLockType.TRANSIENT)); + foreach (Entity entity in entities) { yield return entity.Id; } diff --git a/NitroxServer/GameLogic/Entities/Spawning/BatchEntitySpawner.cs b/NitroxServer/GameLogic/Entities/Spawning/BatchEntitySpawner.cs index 9a3ac74762..20e2f054ba 100644 --- a/NitroxServer/GameLogic/Entities/Spawning/BatchEntitySpawner.cs +++ b/NitroxServer/GameLogic/Entities/Spawning/BatchEntitySpawner.cs @@ -228,9 +228,8 @@ private IEnumerable CreateEntityWithChildren(EntitySpawnPoint entitySpaw CreatePrefabPlaceholdersWithChildren(spawnedEntity, classId, deterministicBatchGenerator); - IEntityBootstrapper bootstrapper; - if (customBootstrappersByTechType.TryGetValue(techType, out bootstrapper)) + if (customBootstrappersByTechType.TryGetValue(techType, out IEntityBootstrapper bootstrapper)) { bootstrapper.Prepare(spawnedEntity, parentEntity, deterministicBatchGenerator); } @@ -288,13 +287,12 @@ private List SpawnEntities(List entitySpawnPoints, Det private void CreatePrefabPlaceholdersWithChildren(Entity entity, string classId, DeterministicBatchGenerator deterministicBatchGenerator) { - PrefabPlaceholdersGroupAsset group; // Check to see if this entity is a PrefabPlaceholderGroup. If it is, // we want to add the children that would be spawned here. This is // surpressed on the client so we don't get virtual entities that the // server doesn't know about. - if (prefabPlaceholderGroupsbyClassId.TryGetValue(classId, out group)) + if (prefabPlaceholderGroupsbyClassId.TryGetValue(classId, out PrefabPlaceholdersGroupAsset group)) { foreach (PrefabAsset prefab in group.SpawnablePrefabs) { @@ -362,7 +360,7 @@ private List ConvertComponentPrefabsToEntities(List prefabs parent); prefabEntity.ChildEntities = ConvertComponentPrefabsToEntities(prefab.Children, prefabEntity, deterministicBatchGenerator); - + entities.Add(prefabEntity); } diff --git a/NitroxServer/GameLogic/Entities/Spawning/DeterministicBatchGenerator.cs b/NitroxServer/GameLogic/Entities/Spawning/DeterministicBatchGenerator.cs index 0aba47f820..2845e04bc2 100644 --- a/NitroxServer/GameLogic/Entities/Spawning/DeterministicBatchGenerator.cs +++ b/NitroxServer/GameLogic/Entities/Spawning/DeterministicBatchGenerator.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using NitroxModel.DataStructures; namespace NitroxServer.GameLogic.Entities.Spawning diff --git a/NitroxServer/GameLogic/Entities/Spawning/IEntitySpawner.cs b/NitroxServer/GameLogic/Entities/Spawning/IEntitySpawner.cs index c85c4011d3..b2db952f78 100644 --- a/NitroxServer/GameLogic/Entities/Spawning/IEntitySpawner.cs +++ b/NitroxServer/GameLogic/Entities/Spawning/IEntitySpawner.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -using NitroxModel.DataStructures.GameLogic; using NitroxModel.DataStructures; +using NitroxModel.DataStructures.GameLogic; namespace NitroxServer.GameLogic.Entities.Spawning { diff --git a/NitroxServer/GameLogic/EscapePodManager.cs b/NitroxServer/GameLogic/EscapePodManager.cs index f13f2954cd..d73b4bb18c 100644 --- a/NitroxServer/GameLogic/EscapePodManager.cs +++ b/NitroxServer/GameLogic/EscapePodManager.cs @@ -1,10 +1,8 @@ -using NitroxModel.DataStructures; +using System; +using System.Collections.Generic; +using NitroxModel.DataStructures; using NitroxModel.DataStructures.GameLogic; using NitroxModel.DataStructures.Util; -using NitroxServer.Serialization; -using NitroxModel.Core; -using System.Collections.Generic; -using System; namespace NitroxServer.GameLogic { @@ -67,7 +65,7 @@ public void RepairEscapePodRadio(NitroxId id) EscapePodModel escapePod = EscapePods.Find(ep => ep.RadioId == id); escapePod.RadioDamaged = false; } - + private EscapePodModel CreateNewEscapePod() { EscapePodModel escapePod = new EscapePodModel(); diff --git a/NitroxServer/GameLogic/GameData.cs b/NitroxServer/GameLogic/GameData.cs index d2ed5e9ad1..f73bbfb208 100644 --- a/NitroxServer/GameLogic/GameData.cs +++ b/NitroxServer/GameLogic/GameData.cs @@ -1,6 +1,6 @@ -using NitroxServer.GameLogic.Unlockables; -using System; +using System; using Newtonsoft.Json; +using NitroxServer.GameLogic.Unlockables; using ProtoBufNet; namespace NitroxServer.GameLogic.Bases diff --git a/NitroxServer/GameLogic/SimulationOwnership.cs b/NitroxServer/GameLogic/SimulationOwnership.cs index c0ef044049..efaa9e4d8b 100644 --- a/NitroxServer/GameLogic/SimulationOwnership.cs +++ b/NitroxServer/GameLogic/SimulationOwnership.cs @@ -1,5 +1,5 @@ -using NitroxModel.DataStructures; -using System.Collections.Generic; +using System.Collections.Generic; +using NitroxModel.DataStructures; namespace NitroxServer.GameLogic { @@ -18,7 +18,7 @@ public PlayerLock(Player player, SimulationLockType lockType) } Dictionary playerLocksById = new Dictionary(); - + public bool TryToAcquire(NitroxId id, Player player, SimulationLockType requestedLock) { lock (playerLocksById) @@ -44,13 +44,13 @@ public bool TryToAcquire(NitroxId id, Player player, SimulationLockType requeste playerLocksById[id] = new PlayerLock(player, requestedLock); return true; } - + // We must be requesting a transient lock and the owner already has a lock (either transient or exclusive). // there is no way to break it so we will return false. return false; } } - + public bool RevokeIfOwner(NitroxId id, Player player) { lock (playerLocksById) @@ -71,15 +71,15 @@ public List RevokeAllForOwner(Player player) { List revokedIds = new List(); - foreach(KeyValuePair idWithPlayerLock in playerLocksById) + foreach (KeyValuePair idWithPlayerLock in playerLocksById) { - if(idWithPlayerLock.Value.Player == player) + if (idWithPlayerLock.Value.Player == player) { revokedIds.Add(idWithPlayerLock.Key); } } - foreach(NitroxId id in revokedIds) + foreach (NitroxId id in revokedIds) { playerLocksById.Remove(id); } @@ -100,7 +100,7 @@ public Player GetPlayerForLock(NitroxId id) { lock (playerLocksById) { - if(playerLocksById.TryGetValue(id, out PlayerLock playerLock)) + if (playerLocksById.TryGetValue(id, out PlayerLock playerLock)) { return playerLock.Player; } diff --git a/NitroxServer/GameLogic/Unlockables/PDAStateData.cs b/NitroxServer/GameLogic/Unlockables/PDAStateData.cs index 495543f365..ee8e207e56 100644 --- a/NitroxServer/GameLogic/Unlockables/PDAStateData.cs +++ b/NitroxServer/GameLogic/Unlockables/PDAStateData.cs @@ -47,8 +47,7 @@ public void AddPDALogEntry(PDALogEntry entry) public void EntryProgressChanged(NitroxTechType techType, float progress, int unlocked) { - PDAEntry pdaEntry; - if (!PartiallyUnlockedByTechType.TryGetValue(techType, out pdaEntry)) + if (!PartiallyUnlockedByTechType.TryGetValue(techType, out PDAEntry pdaEntry)) { PartiallyUnlockedByTechType[techType] = pdaEntry = new PDAEntry(techType, progress, unlocked); } diff --git a/NitroxServer/GameLogic/Vehicles/VehicleData.cs b/NitroxServer/GameLogic/Vehicles/VehicleData.cs index 1b46b94d5c..45db5ba2a9 100644 --- a/NitroxServer/GameLogic/Vehicles/VehicleData.cs +++ b/NitroxServer/GameLogic/Vehicles/VehicleData.cs @@ -1,7 +1,7 @@ -using NitroxModel.DataStructures.GameLogic; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; +using NitroxModel.DataStructures.GameLogic; using ProtoBufNet; namespace NitroxServer.GameLogic.Vehicles diff --git a/NitroxServer/GameLogic/Vehicles/VehicleManager.cs b/NitroxServer/GameLogic/Vehicles/VehicleManager.cs index ed4ec5ba2a..156f4b672f 100644 --- a/NitroxServer/GameLogic/Vehicles/VehicleManager.cs +++ b/NitroxServer/GameLogic/Vehicles/VehicleManager.cs @@ -100,8 +100,7 @@ public void RemoveVehicle(NitroxId id) public Optional GetVehicleModel(NitroxId id) { - VehicleModel vehicleModel; - vehiclesById.TryGetValue(id, out vehicleModel); + vehiclesById.TryGetValue(id, out VehicleModel vehicleModel); return Optional.OfNullable(vehicleModel); } diff --git a/NitroxServer/NitroxServer.csproj b/NitroxServer/NitroxServer.csproj index c76cbad0db..f36e1ab695 100644 --- a/NitroxServer/NitroxServer.csproj +++ b/NitroxServer/NitroxServer.csproj @@ -38,84 +38,71 @@ Library - - - - ..\Nitrox.Subnautica.Assets\protobuf-net.dll - - - - - - - - - - + - - - + + + + + + + + + + + - - + + + + + + + + + + + + + + + + - - + + + + + - - - - - - - - - - - + + - - - - - - - - - + + - - - - - - - - - @@ -131,97 +118,108 @@ + + - - - - - - - - + - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - - + - + + + 4.9.4 + + + 12.0.3 + + + 3.0.1 + + + {b0a014e4-0392-4e35-aa42-8fb5a40417e0} LiteNetLib @@ -231,23 +229,23 @@ NitroxModel - + False .NET Framework 3.5 SP1 false - - - - 4.9.4 - - - 12.0.3 - - - 3.0.1 - + + ..\Nitrox.Subnautica.Assets\protobuf-net.dll + + + + + + + + + \ No newline at end of file diff --git a/NitroxServer/Serialization/BatchCellsParser.cs b/NitroxServer/Serialization/BatchCellsParser.cs index 9506cb8a4e..cf7f72b024 100644 --- a/NitroxServer/Serialization/BatchCellsParser.cs +++ b/NitroxServer/Serialization/BatchCellsParser.cs @@ -86,11 +86,10 @@ private void ParseCacheCells(NitroxInt3 batchId, string fileName, List(stream); - bool wasLegacy; byte[] serialData = new byte[cellHeader.DataLength]; stream.Read(serialData, 0, cellHeader.DataLength); - ParseGameObjectsWithHeader(serialData, batchId, cellHeader.CellId, cellHeader.Level, spawnPoints, out wasLegacy); + ParseGameObjectsWithHeader(serialData, batchId, cellHeader.CellId, cellHeader.Level, spawnPoints, out bool wasLegacy); if (!wasLegacy) { diff --git a/NitroxServer/ServerAutoFacRegistrar.cs b/NitroxServer/ServerAutoFacRegistrar.cs index 87ce0e2dee..d7a3826476 100644 --- a/NitroxServer/ServerAutoFacRegistrar.cs +++ b/NitroxServer/ServerAutoFacRegistrar.cs @@ -1,7 +1,6 @@ using System.Reflection; using Autofac; using NitroxModel.Core; -using NitroxModel.Serialization; using NitroxServer.Communication.LiteNetLib; using NitroxServer.Communication.Packets; using NitroxServer.Communication.Packets.Processors; diff --git a/NitroxServer/UnityStubs/GameObject.cs b/NitroxServer/UnityStubs/GameObject.cs index c7759a245d..04a0c25cf7 100644 --- a/NitroxServer/UnityStubs/GameObject.cs +++ b/NitroxServer/UnityStubs/GameObject.cs @@ -14,7 +14,7 @@ public class GameObject public string ClassId { get; } public string Parent { get; } - public int TotalComponents { get { return components.Count; } } + public int TotalComponents => components.Count; private readonly Dictionary components = new Dictionary(); @@ -30,8 +30,7 @@ public GameObject(GameObjectData goData) public override string ToString() { - object transform = null; - components.TryGetValue(typeof(NitroxTransform), out transform); // Honestly this should never be null every gameObject has a Transform + components.TryGetValue(typeof(NitroxTransform), out object transform); // Honestly this should never be null every gameObject has a Transform return string.Format("Id: {0}, Class Id: {1}, Transform: {2}", Id, ClassId, transform as NitroxTransform); } @@ -43,8 +42,7 @@ public void AddComponent(object component, Type componentType) public object GetComponent(Type type) { - object res; - if (components.TryGetValue(type, out res)) + if (components.TryGetValue(type, out object res)) { return res; } diff --git a/NitroxTest/Client/Communication/MultiplayerSessionTests/ConnectionStateTests/DisconnectedStateTests.cs b/NitroxTest/Client/Communication/MultiplayerSessionTests/ConnectionStateTests/DisconnectedStateTests.cs index 06a816e056..3142d095b1 100644 --- a/NitroxTest/Client/Communication/MultiplayerSessionTests/ConnectionStateTests/DisconnectedStateTests.cs +++ b/NitroxTest/Client/Communication/MultiplayerSessionTests/ConnectionStateTests/DisconnectedStateTests.cs @@ -18,7 +18,7 @@ public void NegotiateShouldStartTheClientOnTheContext() IClient serverClient = Substitute.For(); serverClient.IsConnected.Returns(false); serverClient - .When(client => client.Start(Arg.Any(),TestConstants.TEST_SERVER_PORT)) + .When(client => client.Start(Arg.Any(), TestConstants.TEST_SERVER_PORT)) .Do(info => serverClient.IsConnected.Returns(true)); IMultiplayerSessionConnectionContext connectionContext = Substitute.For(); @@ -41,7 +41,7 @@ public void NegotiateShouldSendMultiplayerSessionPolicyRequestPacketToClient() IClient serverClient = Substitute.For(); serverClient.IsConnected.Returns(false); serverClient - .When(client => client.Start(Arg.Any(),TestConstants.TEST_SERVER_PORT)) + .When(client => client.Start(Arg.Any(), TestConstants.TEST_SERVER_PORT)) .Do(info => serverClient.IsConnected.Returns(true)); IMultiplayerSessionConnectionContext connectionContext = Substitute.For(); @@ -64,7 +64,7 @@ public void NegotiateShouldTransitionToEstablishingSessionPolicyState() IClient serverClient = Substitute.For(); serverClient.IsConnected.Returns(false); serverClient - .When(client => client.Start(Arg.Any(),TestConstants.TEST_SERVER_PORT)) + .When(client => client.Start(Arg.Any(), TestConstants.TEST_SERVER_PORT)) .Do(info => serverClient.IsConnected.Returns(true)); IMultiplayerSessionConnectionContext connectionContext = Substitute.For(); diff --git a/NitroxTest/Client/Communication/MultiplayerSessionTests/MultiplayerSessionMangerTests.cs b/NitroxTest/Client/Communication/MultiplayerSessionTests/MultiplayerSessionMangerTests.cs index 8d9bddc28a..88c7a57720 100644 --- a/NitroxTest/Client/Communication/MultiplayerSessionTests/MultiplayerSessionMangerTests.cs +++ b/NitroxTest/Client/Communication/MultiplayerSessionTests/MultiplayerSessionMangerTests.cs @@ -45,7 +45,7 @@ public void ConnectShouldSetIpAddress() IMultiplayerSession multiplayerSession = new MultiplayerSessionManager(client, TestConstants.TEST_CONNECTION_STATE); // Act - multiplayerSession.Connect(TestConstants.TEST_IP_ADDRESS,TestConstants.TEST_SERVER_PORT); + multiplayerSession.Connect(TestConstants.TEST_IP_ADDRESS, TestConstants.TEST_SERVER_PORT); // Assert multiplayerSession.IpAddress.Should().Be(TestConstants.TEST_IP_ADDRESS); diff --git a/NitroxTest/DataStructures/ThreadSafeCollectionTest.cs b/NitroxTest/DataStructures/ThreadSafeCollectionTest.cs index ff2b3a2bf6..42144c4a9e 100644 --- a/NitroxTest/DataStructures/ThreadSafeCollectionTest.cs +++ b/NitroxTest/DataStructures/ThreadSafeCollectionTest.cs @@ -76,7 +76,7 @@ public void Find() list.Find(s => s == "test 1").Should().Be("test 1"); list.Find(s => s == "tesT 1").Should().BeNull(); list.Find(s => s == "test 1361").Should().BeNull(); - + set.Find(s => s == "test 7").Should().Be("test 7"); set.Find(s => s == "tesT 7").Should().BeNull(); set.Find(s => s == "test 1361").Should().BeNull(); diff --git a/NitroxTest/NitroxTest.csproj b/NitroxTest/NitroxTest.csproj index d3e7ce86c4..c8e88af44b 100644 --- a/NitroxTest/NitroxTest.csproj +++ b/NitroxTest/NitroxTest.csproj @@ -30,14 +30,7 @@ prompt 4 - - - - - - - - + @@ -72,39 +65,10 @@ - - - {ed5034bd-66b5-4596-94b7-66a28d3eff49} - NitroxClient - - - {0a377218-6b36-4522-89a3-a39cfc999209} - NitroxModel-Subnautica - - - {b16f4de7-21ad-4fef-955b-0a5a365fa4e3} - NitroxModel - - - {be983e25-24cc-4fc8-9017-61eec43dd618} - NitroxPatcher - - - {eff1d7a5-efd6-413a-8d5f-dc2408e4c9b7} - NitroxServer-Subnautica - - - {0fc864b0-694e-4fca-b78c-8ef98bc6f262} - NitroxServer - - - - - - + - + 4.9.4 @@ -122,7 +86,7 @@ 2.1.2 - true + true 2.1.2 @@ -130,12 +94,48 @@ 4.2.2 - - 4.7.1 - 4.5.4 + + 4.7.1 + + + + + {ed5034bd-66b5-4596-94b7-66a28d3eff49} + NitroxClient + + + {b16f4de7-21ad-4fef-955b-0a5a365fa4e3} + NitroxModel + + + {0a377218-6b36-4522-89a3-a39cfc999209} + NitroxModel-Subnautica + + + {be983e25-24cc-4fc8-9017-61eec43dd618} + NitroxPatcher + + + {0fc864b0-694e-4fca-b78c-8ef98bc6f262} + NitroxServer + + + {eff1d7a5-efd6-413a-8d5f-dc2408e4c9b7} + NitroxServer-Subnautica + + + + + + + + + + + @@ -145,4 +145,4 @@ - + \ No newline at end of file diff --git a/NitroxTest/Patcher/Patches/BuilderPatchTest.cs b/NitroxTest/Patcher/Patches/BuilderPatchTest.cs index 1c10e5961c..38939d6252 100644 --- a/NitroxTest/Patcher/Patches/BuilderPatchTest.cs +++ b/NitroxTest/Patcher/Patches/BuilderPatchTest.cs @@ -4,9 +4,8 @@ using System.Reflection; using HarmonyLib; using Microsoft.VisualStudio.TestTools.UnitTesting; -using NitroxTest.Patcher.Test; -using System.Reflection.Emit; using NitroxPatcher.Patches.Dynamic; +using NitroxTest.Patcher.Test; namespace NitroxTest.Patcher.Patches { diff --git a/NitroxTest/Patcher/Patches/BuilderTool_HandleInput_PatchTest.cs b/NitroxTest/Patcher/Patches/BuilderTool_HandleInput_PatchTest.cs index c7874aec97..d96cb20b1b 100644 --- a/NitroxTest/Patcher/Patches/BuilderTool_HandleInput_PatchTest.cs +++ b/NitroxTest/Patcher/Patches/BuilderTool_HandleInput_PatchTest.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; -using System.Reflection.Emit; using HarmonyLib; using Microsoft.VisualStudio.TestTools.UnitTesting; using NitroxPatcher.Patches.Dynamic; diff --git a/NitroxTest/Patcher/Patches/ConstructorInput_OnCraftingBegin_PatchTest.cs b/NitroxTest/Patcher/Patches/ConstructorInput_OnCraftingBegin_PatchTest.cs index e2608b7314..2af17cdf5a 100644 --- a/NitroxTest/Patcher/Patches/ConstructorInput_OnCraftingBegin_PatchTest.cs +++ b/NitroxTest/Patcher/Patches/ConstructorInput_OnCraftingBegin_PatchTest.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; -using System.Reflection.Emit; using HarmonyLib; using Microsoft.VisualStudio.TestTools.UnitTesting; using NitroxPatcher.Patches.Dynamic; diff --git a/NitroxTest/Patcher/Test/PatchTestHelper.cs b/NitroxTest/Patcher/Test/PatchTestHelper.cs index e3a496d269..6a794589a2 100644 --- a/NitroxTest/Patcher/Test/PatchTestHelper.cs +++ b/NitroxTest/Patcher/Test/PatchTestHelper.cs @@ -25,7 +25,7 @@ public static ReadOnlyCollection GetInstructionsFromMethod(Dyna Validate.NotNull(targetMethod); return GetInstructionsFromIL(GetILInstructions(targetMethod)); } - + public static ReadOnlyCollection GetInstructionsFromMethod(MethodInfo targetMethod) { Validate.NotNull(targetMethod); diff --git a/NitroxTest/Threading/ThreadSafeCollectionTest.cs b/NitroxTest/Threading/ThreadSafeCollectionTest.cs index 4dc87dc83f..3959211cfc 100644 --- a/NitroxTest/Threading/ThreadSafeCollectionTest.cs +++ b/NitroxTest/Threading/ThreadSafeCollectionTest.cs @@ -82,7 +82,7 @@ public void IterateAndAdd() nums.Add(10); } } - + nums.Count.Should().Be(6); nums.Last().Should().Be(10); } @@ -97,7 +97,7 @@ private void DoReaderWriter(Action reader, Action writer, int iterators) reader(); Thread.Yield(); } - + // Read one last time after writer finishes reader(); });