Skip to content

Commit

Permalink
Use EftBulletClass now
Browse files Browse the repository at this point in the history
  • Loading branch information
sailro committed Jan 7, 2025
1 parent 4e2ffd7 commit 778eaa7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 38 deletions.
12 changes: 5 additions & 7 deletions Features/Ammunition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Comfort.Common;
using EFT.Ballistics;
using EFT.InventoryLogic;
using EFT.Trainer.Model;
using EFT.Trainer.Properties;
using JetBrains.Annotations;

Expand All @@ -19,21 +18,20 @@ internal class Ammunition : ToggleFeature
public override bool Enabled { get; set; } = false;

[UsedImplicitly]
private static void ShootPostfix(object shot)
private static void ShootPostfix(EftBulletClass shot)
{
var feature = FeatureFactory.GetFeature<Ammunition>();
if (feature == null || !feature.Enabled)
return;

var shotWrapper = new ShotWrapper(shot);
if (shotWrapper.Weapon is not Weapon weapon)
if (shot.Weapon is not Weapon weapon)
return;

var ammo = shotWrapper.Ammo;
var ammo = shot.Ammo;
if (ammo == null)
return;

var player = shotWrapper.Player;
var player = shot.Player.iPlayer;
if (player is not { IsYourPlayer: true })
return;

Expand Down Expand Up @@ -75,7 +73,7 @@ protected override void UpdateWhenEnabled()
{
HarmonyPatchOnce(harmony =>
{
HarmonyPostfix(harmony, typeof(BallisticsCalculator), nameof(BallisticsCalculator.Shoot), nameof(ShootPostfix));
HarmonyPostfix(harmony, typeof(BallisticsCalculator), nameof(BallisticsCalculator.Shoot), nameof(ShootPostfix), [typeof(EftBulletClass)]);
});
}
}
5 changes: 2 additions & 3 deletions Features/WallShoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ internal class WallShoot : ToggleFeature

#pragma warning disable IDE0060
[UsedImplicitly]
protected static bool IsPenetratedPrefix(object shot, Vector3 hitPoint, BallisticCollider __instance, ref bool __result)
protected static bool IsPenetratedPrefix(EftBulletClass shot, Vector3 hitPoint, BallisticCollider __instance, ref bool __result)
{
var feature = FeatureFactory.GetFeature<WallShoot>();
if (feature == null || !feature.Enabled)
return true; // keep using original code, we are not enabled

var shotWrapper = new ShotWrapper(shot);
var player = shotWrapper.Player;
var player = shot.Player.iPlayer;
if (player is not { IsYourPlayer: true })
return true; // keep using original code for other players

Expand Down
27 changes: 0 additions & 27 deletions Model/ShotWrapper.cs

This file was deleted.

1 change: 0 additions & 1 deletion NLog.EFT.Trainer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@
<Compile Include="Features\WorldInteractiveObjects.cs" />
<Compile Include="Model\ReflectionWrapper.cs" />
<Compile Include="Model\ActiveHealthControllerWrapper.cs" />
<Compile Include="Model\ShotWrapper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Strings.fr.Designer.cs">
<DependentUpon>Strings.fr.resx</DependentUpon>
Expand Down

0 comments on commit 778eaa7

Please sign in to comment.