Skip to content

Commit

Permalink
Fixes the range finder locally
Browse files Browse the repository at this point in the history
- Also bump version
  • Loading branch information
Lacyway committed Dec 11, 2024
1 parent 3a4c533 commit 8640324
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using EFT;
using EFT.InventoryLogic;
using Fika.Core.Coop.Players;
using Fika.Core.Networking;

namespace Fika.Core.Coop.ClientClasses
{
public class CoopClientPortableRangeFinderController : PortableRangeFinderController
{
protected CoopPlayer player;

public static CoopClientPortableRangeFinderController Create(CoopPlayer player, Item item)
{
CoopClientPortableRangeFinderController controller = smethod_6<CoopClientPortableRangeFinderController>(player, item);
controller.player = player;
return controller;
}

public override void CompassStateHandler(bool isActive)
{
base.CompassStateHandler(isActive);
UsableItemPacket packet = new(player.NetId)
{
HasCompassState = true,
CompassState = isActive
};
player.PacketSender.SendPacket(ref packet);
}

public override bool ExamineWeapon()
{
bool flag = base.ExamineWeapon();
if (flag)
{
UsableItemPacket packet = new(player.NetId)
{
ExamineWeapon = true
};
player.PacketSender.SendPacket(ref packet);
}
return flag;
}

public override void SetAim(bool value)
{
bool isAiming = IsAiming;
base.SetAim(value);
if (IsAiming != isAiming)
{
UsableItemPacket packet = new(player.NetId)
{
HasAim = value,
AimState = isAiming
};
player.PacketSender.SendPacket(ref packet);
}
}
}
}
45 changes: 45 additions & 0 deletions Fika.Core/Coop/Players/CoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,17 @@ public override void Proceed(MedsItemClass meds, EBodyPart bodyPart, Callback<GI

public override void Proceed<T>(Item item, Callback<GInterface164> callback, bool scheduled = true)
{
if (item is PortableRangeFinderItemClass)
{
PortableRangeFinderControllerHandler rangeFinderHandler = new(this, item);

Func<PortableRangeFinderController> rangeFinderFunc = new(rangeFinderHandler.ReturnController);
rangeFinderHandler.process = new(this, rangeFinderFunc, item, false);
rangeFinderHandler.confirmCallback = new(rangeFinderHandler.SendPacket);
rangeFinderHandler.process.method_0(new(rangeFinderHandler.HandleResult), callback, scheduled);
return;
}

UsableItemControllerHandler handler = new(this, item);

Func<UsableItemController> func = new(handler.ReturnController);
Expand Down Expand Up @@ -1469,6 +1480,40 @@ internal void HandleResult(IResult result)
}
}

private class PortableRangeFinderControllerHandler(CoopPlayer coopPlayer, Item item)
{
private readonly CoopPlayer coopPlayer = coopPlayer;
private readonly Item item = item;
public Process<PortableRangeFinderController, GInterface164> process;
public Action confirmCallback;

internal CoopClientPortableRangeFinderController ReturnController()
{
return CoopClientPortableRangeFinderController.Create(coopPlayer, item);
}

internal void SendPacket()
{
coopPlayer.PacketSender.CommonPlayerPackets.Enqueue(new()
{
Type = ECommonSubPacketType.Proceed,
SubPacket = new ProceedPacket()
{
ProceedType = EProceedType.UsableItem,
ItemId = item.Id
}
});
}

internal void HandleResult(IResult result)
{
if (result.Succeed)
{
confirmCallback();
}
}
}

private class QuickUseItemControllerHandler(CoopPlayer coopPlayer, Item item)
{
private readonly CoopPlayer coopPlayer = coopPlayer;
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/FikaPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace Fika.Core
[BepInDependency("com.SPT.debugging", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after spt-debugging, that way we can disable its patches
public class FikaPlugin : BaseUnityPlugin
{
public const string FikaVersion = "1.0.4";
public const string FikaVersion = "1.0.5";
public static FikaPlugin Instance;
public static InternalBundleLoader BundleLoaderPlugin { get; private set; }
public static string EFTVersionMajor { get; internal set; }
Expand Down

0 comments on commit 8640324

Please sign in to comment.