Skip to content

Commit

Permalink
Only create shared controller when option is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Jun 18, 2024
1 parent 1011fe3 commit 8e257b8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion Fika.Core/Coop/Players/CoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ public static async Task<LocalPlayer> Create(int playerId, Vector3 position, Qua

ISession session = Singleton<ClientApplication<ISession>>.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();

Expand Down
4 changes: 2 additions & 2 deletions Fika.Core/Networking/FikaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions Fika.Core/Networking/FikaServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 8e257b8

Please sign in to comment.