Skip to content

Commit

Permalink
Fix tripwiremanager init on dedi
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Oct 29, 2024
1 parent a7aacee commit aaee67b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public override void ChangeFireMode(Weapon.EFireMode fireMode)
return;
}

// Check for GClass increments
Class1111 currentOperation = CurrentOperation;
if (currentOperation != null)
{
Expand Down
18 changes: 16 additions & 2 deletions Fika.Core/Coop/HostClasses/CoopHostGameWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using EFT;
using EFT.InventoryLogic;
using EFT.SynchronizableObjects;
using Fika.Core.Coop.HostClasses;
using Fika.Core.Coop.Utils;
using Fika.Core.Networking;
using HarmonyLib;
Expand All @@ -13,7 +12,7 @@
using System.Threading.Tasks;
using UnityEngine;

namespace Fika.Core.Coop.ClientClasses
namespace Fika.Core.Coop.HostClasses
{
/// <summary>
/// <see cref="ClientLocalGameWorld"/> used in Fika for hosts to override methods and logic
Expand Down Expand Up @@ -95,13 +94,28 @@ public override void InitAirdrop(string lootTemplateId = null, bool takeNearbyPo
ClientSynchronizableObjectLogicProcessor.InitSyncObject(synchronizableObject, gameObject.transform.position, Vector3.forward, -1);
}

public override GClass2329 SyncObjectProcessorFactory()
{
ClientSynchronizableObjectLogicProcessor = new SynchronizableObjectLogicProcessorClass
{
TripwireManager = new(Singleton<GameWorld>.Instance)
};
return ClientSynchronizableObjectLogicProcessor;
}

public override void PlantTripwire(Item item, string profileId, Vector3 fromPosition, Vector3 toPosition)
{
if (item is not GrenadeClass grenadeClass)
{
return;
}

if (SynchronizableObjectLogicProcessor.TripwireManager == null)
{
FikaPlugin.Instance.FikaLogger.LogError("TripwireManager was null! Creating new...");
SynchronizableObjectLogicProcessor.TripwireManager = new GClass2331(this);
}

TripwireSynchronizableObject tripwireSynchronizableObject = (TripwireSynchronizableObject)SynchronizableObjectLogicProcessor.TakeFromPool(SynchronizableObjectType.Tripwire);
tripwireSynchronizableObject.transform.SetPositionAndRotation(fromPosition, Quaternion.identity);
SynchronizableObjectLogicProcessor.InitSyncObject(tripwireSynchronizableObject, fromPosition, Vector3.forward, -1);
Expand Down
1 change: 1 addition & 0 deletions Fika.Core/Coop/Patches/GameWorld/GameWorld_Create_Patch.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using EFT;
using Fika.Core.Coop.ClientClasses;
using Fika.Core.Coop.HostClasses;
using Fika.Core.Coop.Utils;
using HarmonyLib;
using SPT.Reflection.Patching;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using EFT.InventoryLogic;
using Fika.Core.Coop.ObservedClasses;
using Fika.Core.Coop.Players;
using Fika.Core.Coop.Utils;
using LiteNetLib.Utils;
using System;
using System.Collections.Generic;
Expand Down

0 comments on commit aaee67b

Please sign in to comment.