mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-12 17:30:43 -05:00
Add BotOwnerManualUpdatePatch (!170)
Patch used to stop the allocation of a new `Stopwatch` every frame for all active AI which should save some resources. The data from the stopwatch is unused so I am unsure why BSG left it there. Co-authored-by: Lacyway <20912169+Lacyway@users.noreply.github.com> Reviewed-on: SPT/Modules#170 Co-authored-by: Lacyway <lacyway@noreply.dev.sp-tarkov.com> Co-committed-by: Lacyway <lacyway@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
15a72cfeec
commit
16185f64f6
@ -0,0 +1,81 @@
|
||||
using EFT;
|
||||
using EFT.Game.Spawning;
|
||||
using SPT.Reflection.Patching;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
namespace SPT.SinglePlayer.Patches.RaidFix
|
||||
{
|
||||
/// <summary>
|
||||
/// Patch used to stop the allocation of a new <see cref="System.Diagnostics.Stopwatch"/> every frame for all active AI
|
||||
/// </summary>
|
||||
public class BotOwnerManualUpdatePatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return typeof(BotOwner).GetMethod(nameof(BotOwner.UpdateManual));
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
public static bool Prefix(BotOwner __instance, float ____nextGetGoalTime, ref float ____nextTimeCheckBorn)
|
||||
{
|
||||
if (__instance.BotState == EBotState.Active && __instance.GetPlayer.HealthController.IsAlive)
|
||||
{
|
||||
__instance.StandBy.Update();
|
||||
__instance.LookSensor.ManualUpdate();
|
||||
if (__instance.StandBy.StandByType != BotStandByType.paused)
|
||||
{
|
||||
if (____nextGetGoalTime < Time.time)
|
||||
{
|
||||
__instance.CalcGoal();
|
||||
}
|
||||
__instance.SuppressShoot.ManualUpdate();
|
||||
__instance.HeadData.ManualUpdate();
|
||||
__instance.ShootData.ManualUpdate();
|
||||
__instance.Tilt.ManualUpdate();
|
||||
__instance.NightVision.ManualUpdate();
|
||||
__instance.NearDoorData.Update();
|
||||
__instance.DogFight.ManualUpdate();
|
||||
__instance.FriendChecker.ManualUpdate();
|
||||
__instance.RecoilData.LosingRecoil();
|
||||
__instance.Mover.ManualUpdate();
|
||||
__instance.AimingData.PermanentUpdate();
|
||||
__instance.Medecine.ManualUpdate();
|
||||
__instance.Boss.ManualUpdate();
|
||||
__instance.BotTalk.ManualUpdate();
|
||||
__instance.WeaponManager.ManualUpdate();
|
||||
__instance.BotRequestController.Update();
|
||||
__instance.GrenadeToPortal.ManualUpdate();
|
||||
__instance.Tactic.UpdateChangeTactics();
|
||||
__instance.Memory.ManualUpdate(Time.deltaTime);
|
||||
__instance.Settings.UpdateManual();
|
||||
__instance.BotRequestController.TryToFind();
|
||||
__instance.ArtilleryDangerPlace.ManualUpdate();
|
||||
if (__instance.GetPlayer.UpdateQueue == EUpdateQueue.Update)
|
||||
{
|
||||
__instance.Mover.ManualFixedUpdate();
|
||||
__instance.Steering.ManualFixedUpdate();
|
||||
}
|
||||
__instance.UnityEditorRunChecker.ManualLateUpdate();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (__instance.BotState == EBotState.PreActive && __instance.WeaponManager.IsReady)
|
||||
{
|
||||
if (NavMesh.SamplePosition(__instance.GetPlayer.Position, out _, 0.6f, -1))
|
||||
{
|
||||
__instance.method_10();
|
||||
return false;
|
||||
}
|
||||
if (____nextTimeCheckBorn < Time.time)
|
||||
{
|
||||
____nextTimeCheckBorn = Time.time + 1f;
|
||||
__instance.Transform.position = __instance.BotsGroup.BotZone.SpawnPoints.RandomElement<ISpawnPoint>().Position + Vector3.up * 0.5f;
|
||||
__instance.method_10();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
<Reference Include="ItemComponent.Types" HintPath="..\Shared\Managed\ItemComponent.Types.dll" Private="False" />
|
||||
<Reference Include="Comfort" HintPath="..\Shared\Managed\Comfort.dll" Private="False" />
|
||||
<Reference Include="UnityEngine" HintPath="..\Shared\Managed\UnityEngine.dll" Private="False" />
|
||||
<Reference Include="UnityEngine.AIModule" HintPath="..\Shared\Managed\UnityEngine.AIModule.dll" Private="False" />
|
||||
<Reference Include="UnityEngine.AudioModule" HintPath="..\Shared\Managed\UnityEngine.AudioModule.dll" Private="False" />
|
||||
<Reference Include="UnityEngine.CoreModule" HintPath="..\Shared\Managed\UnityEngine.CoreModule.dll" Private="False" />
|
||||
<Reference Include="Sirenix.Serialization" HintPath="..\Shared\Managed\Sirenix.Serialization.dll" Private="False" />
|
||||
|
@ -61,6 +61,7 @@ namespace SPT.SinglePlayer
|
||||
new RemoveClothingItemExternalObtainLabelPatch().Enable();
|
||||
new FixLocalRaidPatch().Enable();
|
||||
new ScavIsPlayerEnemyPatch().Enable();
|
||||
new BotOwnerManualUpdatePatch().Enable();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user