From 8e257b8b6650e16563ebacb2c2d4ab7bcb6be9c3 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:53:58 +0200 Subject: [PATCH] Only create shared controller when option is enabled --- .../ClientClasses/CoopClientInventoryController.cs | 2 +- ...ontroller.cs => CoopClientSharedQuestController.cs} | 2 +- Fika.Core/Coop/Players/CoopPlayer.cs | 10 +++++++++- Fika.Core/Networking/FikaClient.cs | 4 ++-- Fika.Core/Networking/FikaServer.cs | 4 ++-- 5 files changed, 15 insertions(+), 7 deletions(-) rename Fika.Core/Coop/ClientClasses/{CoopSharedQuestController.cs => CoopClientSharedQuestController.cs} (97%) diff --git a/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs b/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs index f23d5de6..c42a5668 100644 --- a/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs +++ b/Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs @@ -44,7 +44,7 @@ public override void Execute(GClass2854 operation, [CanBeNull] Callback callback Item lootedItem = moveOperation.Item; if (lootedItem.Template.QuestItem) { - if (CoopPlayer.GClass3227_0 is CoopSharedQuestController sharedQuestController) + if (CoopPlayer.GClass3227_0 is CoopClientSharedQuestController sharedQuestController) { if (!sharedQuestController.CheckForTemplateId(lootedItem.TemplateId)) { diff --git a/Fika.Core/Coop/ClientClasses/CoopSharedQuestController.cs b/Fika.Core/Coop/ClientClasses/CoopClientSharedQuestController.cs similarity index 97% rename from Fika.Core/Coop/ClientClasses/CoopSharedQuestController.cs rename to Fika.Core/Coop/ClientClasses/CoopClientSharedQuestController.cs index 4b0d9a61..5ffc5167 100644 --- a/Fika.Core/Coop/ClientClasses/CoopSharedQuestController.cs +++ b/Fika.Core/Coop/ClientClasses/CoopClientSharedQuestController.cs @@ -8,7 +8,7 @@ namespace Fika.Core.Coop.ClientClasses { - public sealed class CoopSharedQuestController(Profile profile, InventoryControllerClass inventoryController, + public sealed class CoopClientSharedQuestController(Profile profile, InventoryControllerClass inventoryController, IQuestActions session, CoopPlayer player, bool fromServer = true) : GClass3229(profile, inventoryController, session, fromServer) { private readonly CoopPlayer player = player; diff --git a/Fika.Core/Coop/Players/CoopPlayer.cs b/Fika.Core/Coop/Players/CoopPlayer.cs index 2dc3fd61..69f1f85e 100644 --- a/Fika.Core/Coop/Players/CoopPlayer.cs +++ b/Fika.Core/Coop/Players/CoopPlayer.cs @@ -67,7 +67,15 @@ public static async Task Create(int playerId, Vector3 position, Qua ISession session = Singleton>.Instance.GetClientBackEndSession(); - CoopSharedQuestController questController = new(profile, inventoryController, session, player); + GClass3229 questController; + if (FikaPlugin.QuestSharing.Value) + { + questController = new CoopClientSharedQuestController(profile, inventoryController, session, player); + } + else + { + questController = new GClass3229(profile, inventoryController, session, true); + } questController.Init(); questController.Run(); diff --git a/Fika.Core/Networking/FikaClient.cs b/Fika.Core/Networking/FikaClient.cs index 2740c3a9..731d7c01 100644 --- a/Fika.Core/Networking/FikaClient.cs +++ b/Fika.Core/Networking/FikaClient.cs @@ -128,7 +128,7 @@ private void OnQuestItemPacketReceived(QuestItemPacket packet) { if (MyPlayer.HealthController.IsAlive) { - if (MyPlayer.GClass3227_0 is CoopSharedQuestController sharedQuestController) + if (MyPlayer.GClass3227_0 is CoopClientSharedQuestController sharedQuestController) { sharedQuestController.ReceiveQuestItemPacket(ref packet); } @@ -139,7 +139,7 @@ private void OnQuestConditionPacketReceived(QuestConditionPacket packet) { if (MyPlayer.HealthController.IsAlive) { - if (MyPlayer.GClass3227_0 is CoopSharedQuestController sharedQuestController) + if (MyPlayer.GClass3227_0 is CoopClientSharedQuestController sharedQuestController) { sharedQuestController.ReceiveQuestPacket(ref packet); } diff --git a/Fika.Core/Networking/FikaServer.cs b/Fika.Core/Networking/FikaServer.cs index 2e701094..ea7a55f5 100644 --- a/Fika.Core/Networking/FikaServer.cs +++ b/Fika.Core/Networking/FikaServer.cs @@ -199,7 +199,7 @@ private void OnQuestItemPacketReceived(QuestItemPacket packet, NetPeer peer) if (MyPlayer.HealthController.IsAlive) { - if (MyPlayer.GClass3227_0 is CoopSharedQuestController sharedQuestController) + if (MyPlayer.GClass3227_0 is CoopClientSharedQuestController sharedQuestController) { sharedQuestController.ReceiveQuestItemPacket(ref packet); } @@ -213,7 +213,7 @@ private void OnQuestConditionPacketReceived(QuestConditionPacket packet, NetPeer if (MyPlayer.HealthController.IsAlive) { - if (MyPlayer.GClass3227_0 is CoopSharedQuestController sharedQuestController) + if (MyPlayer.GClass3227_0 is CoopClientSharedQuestController sharedQuestController) { sharedQuestController.ReceiveQuestPacket(ref packet); }