Skip to content

Commit 31a035d

Browse files
authored
Merge pull request #317 from project-fika/1.2.3-dev
1.2.3
2 parents b9e5d8f + ef3cc7b commit 31a035d

34 files changed

+181
-99
lines changed

Fika.Core/Coop/ClientClasses/CoopClientGameWorld.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
using EFT.InventoryLogic;
44
using EFT.SynchronizableObjects;
55
using Fika.Core.Coop.Utils;
6-
using Fika.Core.Networking;
76
using HarmonyLib;
87
using System.Collections.Generic;
9-
using System.Linq;
108
using UnityEngine;
119

1210
namespace Fika.Core.Coop.ClientClasses
@@ -16,7 +14,7 @@ namespace Fika.Core.Coop.ClientClasses
1614
/// </summary>
1715
public class CoopClientGameWorld : ClientLocalGameWorld
1816
{
19-
public FikaClientWorld FikaClientWorld { get; private set; }
17+
public FikaClientWorld FikaClientWorld { get; private set; }
2018

2119
public static CoopClientGameWorld Create(GameObject gameObject, PoolManagerClass objectsFactory, EUpdateQueue updateQueue, string currentProfileId)
2220
{

Fika.Core/Coop/Components/CoopHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ protected void Update()
162162
return;
163163
}
164164

165-
SyncPlayersWithClients();
165+
SyncPlayersWithClients();
166166
}
167167
}
168168
}

Fika.Core/Coop/Components/CorpsePositionSyncer.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
using EFT;
33
using EFT.Interactive;
44
using Fika.Core.Coop.HostClasses;
5-
using HarmonyLib;
6-
using System.Reflection;
75
using UnityEngine;
86

97
namespace Fika.Core.Coop.Components
108
{
119
internal class CorpsePositionSyncer : MonoBehaviour
1210
{
13-
private readonly FieldInfo ragdollDoneField = AccessTools.Field(typeof(RagdollClass), "bool_2");
14-
1511
private Corpse corpse;
1612
private RagdollPacketStruct data;
1713
private FikaHostWorld world;
@@ -46,7 +42,7 @@ public void Start()
4642

4743
public void FixedUpdate()
4844
{
49-
if ((bool)ragdollDoneField.GetValue(corpse.Ragdoll))
45+
if (corpse.Ragdoll.bool_2)
5046
{
5147
data.Position = corpse.TrackableTransform.position;
5248
data.TransformSyncs = corpse.TransformSyncs;

Fika.Core/Coop/Components/GCManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected void Update()
2121
{
2222
counter = 0f;
2323
GarbageCollector.GCMode = GarbageCollector.Mode.Enabled;
24-
GarbageCollector.CollectIncremental(10000000);
24+
GarbageCollector.CollectIncremental(1000000);
2525
GarbageCollector.GCMode = GarbageCollector.Mode.Disabled;
2626
}
2727
}

Fika.Core/Coop/Components/ItemPositionSyncer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Comfort.Common;
22
using EFT.Interactive;
3+
using Fika.Core.Coop.Utils;
34
using Fika.Core.Networking;
45
using UnityEngine;
56

@@ -46,13 +47,13 @@ public void Start()
4647
{
4748
if (lootItem == null)
4849
{
49-
FikaPlugin.Instance.FikaLogger.LogError("HostItemPositionSync::Start: LootItem was null!");
50+
FikaGlobals.LogError("HostItemPositionSync::Start: LootItem was null!");
5051
Destroy(this);
5152
}
5253

5354
if (Rigidbody == null)
5455
{
55-
FikaPlugin.Instance.FikaLogger.LogError("HostItemPositionSync::Start: Rigidbody was null!");
56+
FikaGlobals.LogError("HostItemPositionSync::Start: Rigidbody was null!");
5657
Destroy(this);
5758
}
5859
}

Fika.Core/Coop/GameMode/CoopGame.cs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using EFT.EnvironmentEffect;
1414
using EFT.Game.Spawning;
1515
using EFT.GameTriggers;
16+
using EFT.GlobalEvents;
1617
using EFT.HealthSystem;
1718
using EFT.Interactive;
1819
using EFT.Interactive.SecretExfiltrations;
@@ -688,9 +689,14 @@ public override IEnumerator vmethod_2()
688689
private IEnumerator CreateStashes()
689690
{
690691
GameWorld gameWorld = GameWorld_0;
691-
692+
692693
if (gameWorld.TransitController != null)
693694
{
695+
while (gameWorld.TransitController.TransferItemsController == null)
696+
{
697+
yield return null;
698+
}
699+
694700
while (gameWorld.TransitController.TransferItemsController.Stash == null)
695701
{
696702
yield return null;
@@ -699,6 +705,11 @@ private IEnumerator CreateStashes()
699705

700706
if (gameWorld.BtrController != null)
701707
{
708+
while (gameWorld.BtrController.TransferItemsController == null)
709+
{
710+
yield return null;
711+
}
712+
702713
while (gameWorld.BtrController.TransferItemsController.Stash == null)
703714
{
704715
yield return null;
@@ -990,8 +1001,8 @@ public override async Task<LocalPlayer> vmethod_3(GameWorld gameWorld, int playe
9901001
coopHandler.HumanPlayers.Add(coopPlayer);
9911002
coopPlayer.SetupMainPlayer();
9921003

993-
PlayerSpawnRequest body = new(coopPlayer.ProfileId, FikaBackendUtils.GroupId);
994-
await FikaRequestHandler.UpdatePlayerSpawn(body);
1004+
PlayerSpawnRequest body = new(coopPlayer.ProfileId, FikaBackendUtils.GroupId);
1005+
await FikaRequestHandler.UpdatePlayerSpawn(body);
9951006

9961007
coopPlayer.SpawnPoint = spawnPoint;
9971008

@@ -1213,6 +1224,10 @@ public async Task InitPlayer(BotControllerSettings botsSettings, string backendU
12131224
Logger.LogWarning("Spawning BTR controller");
12141225
#endif
12151226
gameWorld.BtrController = new BTRControllerClass(gameWorld);
1227+
if (isServer)
1228+
{
1229+
GlobalEventHandlerClass.Instance.SubscribeOnEvent<BtrSpawnOnThePathEvent>(OnBtrSpawn);
1230+
}
12161231
}
12171232

12181233
if ((FikaBackendUtils.IsHeadless || FikaBackendUtils.IsHeadlessGame) && FikaPlugin.Instance.EnableTransits)
@@ -1332,6 +1347,17 @@ public async Task InitPlayer(BotControllerSettings botsSettings, string backendU
13321347
FikaEventDispatcher.DispatchEvent(new GameWorldStartedEvent(GameWorld_0));
13331348
}
13341349

1350+
private void OnBtrSpawn(BtrSpawnOnThePathEvent spawnEvent)
1351+
{
1352+
GenericPacket packet = new()
1353+
{
1354+
NetId = 0,
1355+
Type = EGenericSubPacketType.SpawnBTR,
1356+
SubPacket = new GenericSubPackets.BtrSpawn(spawnEvent.Position, spawnEvent.Rotation, spawnEvent.PlayerProfileId)
1357+
};
1358+
Singleton<FikaServer>.Instance.SendDataToAll(ref packet, DeliveryMethod.ReliableOrdered);
1359+
}
1360+
13351361
private void InitializeTransitSystem(GameWorld gameWorld, BackendConfigSettingsClass backendConfig)
13361362
{
13371363
bool transitActive;
@@ -1538,7 +1564,7 @@ private async Task<LocalPlayer> CreateLocalPlayer()
15381564
myPlayer.OnEpInteraction += OnEpInteraction;
15391565

15401566
localPlayer = myPlayer as CoopPlayer;
1541-
coopHandler.MyPlayer = localPlayer;
1567+
coopHandler.MyPlayer = localPlayer;
15421568

15431569
Logger.LogInfo("Local player created");
15441570
return myPlayer;
@@ -1612,7 +1638,7 @@ private async Task WaitForHostToStart()
16121638
{
16131639
if (!FikaBackendUtils.IsHeadless)
16141640
{
1615-
startButton = CreateStartButton() ?? throw new NullReferenceException("Start button could not be created!");
1641+
startButton = CreateStartButton() ?? throw new NullReferenceException("Start button could not be created!");
16161642
}
16171643
FikaServer server = Singleton<FikaServer>.Instance;
16181644
server.RaidInitialized = true;
@@ -1702,6 +1728,7 @@ public override async Task vmethod_1(BotControllerSettings controllerSettings, I
17021728

17031729
GameWorld gameWorld = GameWorld_0;
17041730
gameWorld.RegisterRestrictableZones();
1731+
gameWorld.RegisterBorderZones();
17051732

17061733
if (isServer)
17071734
{
@@ -1767,7 +1794,7 @@ public override async Task vmethod_1(BotControllerSettings controllerSettings, I
17671794
DynamicAI = gameObject.AddComponent<FikaDynamicAI>();
17681795
}
17691796

1770-
await WaitForOtherPlayersToLoad();
1797+
await WaitForOtherPlayersToLoad();
17711798

17721799
SetMatchmakerStatus(LocaleUtils.UI_FINISHING_RAID_INIT.Localized());
17731800
Logger.LogInfo("All players are loaded, continuing...");
@@ -1817,7 +1844,6 @@ public override async Task vmethod_1(BotControllerSettings controllerSettings, I
18171844
}*/
18181845

18191846
Singleton<BackendConfigSettingsClass>.Instance.TimeBeforeDeployLocal = Math.Max(Singleton<BackendConfigSettingsClass>.Instance.TimeBeforeDeployLocal, 3);
1820-
GameWorld_0.RegisterBorderZones();
18211847
}
18221848

18231849
private async Task GenerateWeathers()

Fika.Core/Coop/HostClasses/FikaHostTransitController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using LiteNetLib;
1212
using System;
1313
using System.Collections.Generic;
14-
using System.Linq;
1514

1615
namespace Fika.Core.Coop.HostClasses
1716
{
@@ -20,7 +19,7 @@ public class FikaHostTransitController : GClass1676
2019
public FikaHostTransitController(BackendConfigSettingsClass.TransitSettingsClass settings, LocationSettingsClass.Location.TransitParameters[] parameters, Profile profile, LocalRaidSettings localRaidSettings)
2120
: base(settings, parameters, profile, localRaidSettings)
2221
{
23-
this.localRaidSettings = localRaidSettings;
22+
this.localRaidSettings = localRaidSettings;
2423
string[] array = [.. localRaidSettings.transition.visitedLocations.EmptyIfNull(), localRaidSettings.location];
2524
summonedTransits[profile.Id] = new(localRaidSettings.transition.transitionRaidId, localRaidSettings.transition.transitionCount, array,
2625
localRaidSettings.transitionType.HasFlagNoBox(ELocationTransition.Event));

Fika.Core/Coop/Patches/Artillery/GClass622_method_0_Patch.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using CommonAssets.Scripts.ArtilleryShelling;
33
using EFT;
44
using Fika.Core.Coop.GameMode;
5-
using HarmonyLib;
65
using SPT.Reflection.Patching;
76
using System;
87
using System.Linq;

Fika.Core/Coop/Patches/BTR/BTRControllerClass_Init_Patch.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,29 @@ protected override MethodBase GetTargetMethod()
1818
[PatchPrefix]
1919
public static bool Prefix(BTRControllerClass __instance, ref CancellationToken cancellationToken, ref Task __result, ref GameWorld ___gameWorld_0, ref BackendConfigSettingsClass.BTRGlobalSettings ___btrglobalSettings_0, ref bool ___bool_1)
2020
{
21+
if (FikaBackendUtils.IsServer)
22+
{
23+
return true;
24+
}
25+
2126
if (Singleton<BackendConfigSettingsClass>.Instance != null && Singleton<BackendConfigSettingsClass>.Instance.BTRSettings != null)
2227
{
23-
___btrglobalSettings_0 = Singleton<BackendConfigSettingsClass>.Instance.BTRSettings;
28+
___btrglobalSettings_0 = Singleton<BackendConfigSettingsClass>.Instance.BTRSettings;
2429
}
2530
else
2631
{
2732
Logger.LogError("BackendConfigSettingsClass or BTRSettings was null!");
2833
}
2934

30-
if (FikaBackendUtils.IsServer)
35+
__result = __instance.method_5();
36+
__instance.TransferItemsController = new GClass1671(___gameWorld_0, ___btrglobalSettings_0, true);
37+
if (FikaBackendUtils.IsClient)
38+
{
39+
__instance.TransferItemsController.InitItemControllerServer("656f0f98d80a697f855d34b1", "BTR");
40+
}
41+
return false;
42+
43+
/*if (FikaBackendUtils.IsServer)
3144
{
3245
___bool_1 = true;
3346
BTRControllerClass.Instance.method_1(cancellationToken);
@@ -46,7 +59,7 @@ public static bool Prefix(BTRControllerClass __instance, ref CancellationToken c
4659
}
4760
4861
__result = Task.CompletedTask;
49-
return false;
62+
return false;*/
5063
}
5164
}
5265
}

Fika.Core/Coop/Patches/BTR/BTRView_GoIn_Patch.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public static bool Prefix(BTRView __instance, Player player, BTRSide side, byte
3535

3636
if (player.IsYourPlayer)
3737
{
38-
CoopPlayer myPlayer = (CoopPlayer)player;
39-
myPlayer.PacketSender.Enabled = false;
38+
player.InputDirection = new(0, 0);
4039
if (isServer)
4140
{
41+
CoopPlayer myPlayer = (CoopPlayer)player;
4242
BTRInteractionPacket packet = new(myPlayer.NetId)
4343
{
4444
Data = new()
@@ -83,7 +83,7 @@ private static async Task ObservedGoIn(BTRView view, ObservedCoopPlayer observed
8383
{
8484
soundController.UpdateBtrAudioRoom(EnvironmentType.Indoor, observedPlayer);
8585
}
86-
await view.method_15(observedPlayer.MovementContext.PlayerAnimator, fast, false, cancellationToken);
86+
await view.method_15(observedPlayer.MovementContext.PlayerAnimator, fast, true, cancellationToken);
8787
if (!cancellationToken.IsCancellationRequested)
8888
{
8989
if (view.method_20() == 1)

Fika.Core/Coop/Patches/BTR/BTRView_GoOut_Patch.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public static bool Prefix(BTRView __instance, Player player, BTRSide side, bool
3535
if (player.IsYourPlayer)
3636
{
3737
CoopPlayer myPlayer = (CoopPlayer)player;
38-
myPlayer.PacketSender.Enabled = true;
3938
if (FikaBackendUtils.IsServer)
4039
{
4140
BTRInteractionPacket packet = new(myPlayer.NetId)
@@ -68,14 +67,13 @@ private static async Task ObservedGoOut(BTRView view, ObservedCoopPlayer observe
6867
{
6968
soundController.UpdateBtrAudioRoom(EnvironmentType.Outdoor, observedPlayer);
7069
}
71-
await view.method_15(observedPlayer.MovementContext.PlayerAnimator, fast, false, cancellationToken);
70+
await view.method_16(observedPlayer.MovementContext.PlayerAnimator, fast, true, cancellationToken);
7271
ValueTuple<Vector3, Vector3> valueTuple = side.GoOutPoints();
7372
side.ApplyPlayerRotation(observedPlayer.MovementContext, valueTuple.Item1, valueTuple.Item2 + Vector3.up * 1.9f);
7473
observedPlayer.BtrState = EPlayerBtrState.Outside;
7574
observedPlayer.CharacterController.isEnabled = true;
7675
side.RemovePassenger(observedPlayer);
7776
observedPlayer.MovementContext.IsAxesIgnored = false;
78-
//view.method_18(observedPlayer);
7977
observedPlayer.IsInBufferZone = false;
8078
}
8179
catch (Exception ex)

Fika.Core/Coop/Patches/PlayerPatches/Player_HasMarkOfUnknown_Patch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static bool Prefix(Player __instance, ref MarkOfUnknownItemClass markOfUn
3333
}
3434
}
3535
}
36-
36+
3737
return false;
3838
}
3939
}

Fika.Core/Coop/Players/CoopPlayer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
using System.Linq;
2828
using System.Threading.Tasks;
2929
using UnityEngine;
30-
using UnityEngine.Audio;
3130
using static Fika.Core.Coop.ClientClasses.CoopClientInventoryController;
3231
using static Fika.Core.Networking.CommonSubPackets;
3332
using static Fika.Core.Networking.FirearmSubPackets;
@@ -181,7 +180,7 @@ public void AbuseNotification(string reporterId)
181180
{
182181
if (IsYourPlayer)
183182
{
184-
voipController?.ReceiveAbuseNotification(reporterId);
183+
voipController?.ReceiveAbuseNotification(reporterId);
185184
}
186185
}
187186

@@ -242,7 +241,7 @@ public override void SendVoiceMuffledState(bool isMuffled)
242241
SubPacket = new GenericSubPackets.MuffledState(NetId, isMuffled)
243242
};
244243
PacketSender.SendPacket(ref packet);
245-
}
244+
}
246245

247246
public override bool CheckSurface(float range)
248247
{

Fika.Core/Coop/Players/ObservedCoopPlayer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ public void SetInventory(GClass1693 inventoryDescriptor)
11031103

11041104
if (!FikaBackendUtils.IsHeadless)
11051105
{
1106-
RefreshSlotViews();
1106+
RefreshSlotViews();
11071107
}
11081108
}
11091109

@@ -1350,7 +1350,7 @@ public void SetMuffledState(bool muffled)
13501350
VoipEftSource.SetMixerGroup(audioMixerGroup);
13511351
}
13521352
}
1353-
}
1353+
}
13541354

13551355
public override void LandingAdjustments(float d)
13561356
{

Fika.Core/Coop/Utils/FikaGlobals.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,14 @@ public static Action<T, Y> ClearDelegates<T, Y>(Action<T, Y> action)
335335
for (int i = 0; i < list.Length; i++)
336336
{
337337
#if DEBUG
338-
LogWarning($"Clearing {list[i].Method.Name}");
338+
LogWarning($"Clearing {list[i].Method.Name}");
339339
#endif
340340
action = (Action<T, Y>)Delegate.Remove(action, list[i]);
341341
}
342342

343343
return action;
344344
}
345-
345+
346346
public static void LogInfo(string message, [CallerMemberName] string caller = "")
347347
{
348348
if (string.IsNullOrEmpty(message))

0 commit comments

Comments
 (0)