0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-12 20:50:44 -05:00

Big clean up of various resharper warnings

This commit is contained in:
Dev 2024-08-28 12:52:54 +01:00
parent 700020a23b
commit 7b20646134
36 changed files with 135 additions and 131 deletions

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using BepInEx.Logging;

View File

@ -1,8 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel;
namespace SPT.Common.Models.Logging
namespace SPT.Common.Models.Logging
{
public class ServerLogRequest
{

View File

@ -1,5 +1,4 @@
using UnityEngine.Networking;
using SPT.Core.Utils;
namespace SPT.Core.Models
{

View File

@ -1,5 +1,4 @@
using System.Linq;
using System.Reflection;
using System.Reflection;
using System.Threading.Tasks;
using SPT.Reflection.Patching;
using SPT.Reflection.Utils;

View File

@ -1,5 +1,4 @@
using System.Linq;
using System.Reflection;
using System.Reflection;
using System.Threading.Tasks;
using SPT.Reflection.Patching;
using SPT.Reflection.Utils;

View File

@ -1,7 +1,6 @@
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using SPT.Reflection.Patching;
using SPT.Core.Utils;
using HarmonyLib;
namespace SPT.Core.Patches

View File

@ -6,9 +6,11 @@ namespace SPT.Core.Utils
{
public static class ValidationUtil
{
public static string _crashHandler = "0";
public static bool Validate()
{
var c0 = @"Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\EscapeFromTarkov";
const string c0 = @"Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\EscapeFromTarkov";
var v0 = 0;
try
@ -27,7 +29,8 @@ namespace SPT.Core.Utils
new FileInfo(Path.Combine(v2, "UnityCrashHandler64.exe"))
};
ServerLog.Debug("SPT.Core", Gfs(v2, "UnityCrashHandler64.exe")?.Length.ToString() ?? "0");
_crashHandler = Gfs(v2, "UnityCrashHandler64.exe")?.Length.ToString() ?? "0";
ServerLog.Debug("SPT.Core", _crashHandler);
ServerLog.Debug("SPT.Core", Gfs(v2, "Uninstall.exe")?.Length.ToString() ?? "0");
ServerLog.Debug("SPT.Core", Gfs(v2, "Register.bat")?.Length.ToString() ?? "0");

View File

@ -10,40 +10,40 @@ namespace SPT.Custom.CustomAI
{
public class AIBrainSpawnWeightAdjustment
{
private static AIBrains aiBrainsCache = null;
private static DateTime aiBrainCacheDate = new DateTime();
private static readonly Random random = new Random();
private readonly ManualLogSource logger;
private static AIBrains _aiBrainsCache;
private static DateTime _aiBrainCacheDate;
private static readonly Random random = new();
private readonly ManualLogSource _logger;
public AIBrainSpawnWeightAdjustment(ManualLogSource logger)
{
this.logger = logger;
_logger = logger;
}
public WildSpawnType GetRandomisedPlayerScavType(BotOwner botOwner, string currentMapName)
{
// Get map brain weights from server and cache
if (aiBrainsCache == null || CacheIsStale())
if (_aiBrainsCache == null || CacheIsStale())
{
ResetCacheDate();
HydrateCacheWithServerData();
if (!aiBrainsCache.playerScav.TryGetValue(currentMapName.ToLower(), out _))
if (!_aiBrainsCache.playerScav.TryGetValue(currentMapName.ToLower(), out _))
{
throw new Exception($"Bots were refreshed from the server but the assault cache still doesnt contain data");
throw new Exception($"Bots were refreshed from the server but the assault cache still doesn't contain data");
}
}
// Choose random weighted brain
var randomType = WeightedRandom(aiBrainsCache.playerScav[currentMapName.ToLower()].Keys.ToArray(), aiBrainsCache.playerScav[currentMapName.ToLower()].Values.ToArray());
var randomType = WeightedRandom(_aiBrainsCache.playerScav[currentMapName.ToLower()].Keys.ToArray(), _aiBrainsCache.playerScav[currentMapName.ToLower()].Values.ToArray());
if (Enum.TryParse(randomType, out WildSpawnType newAiType))
{
logger.LogWarning($"Updated player scav bot to use: {newAiType} brain");
_logger.LogWarning($"Updated player scav bot to use: {newAiType} brain");
return newAiType;
}
else
{
logger.LogWarning($"Updated player scav bot {botOwner.Profile.Info.Nickname}: {botOwner.Profile.Info.Settings.Role} to use: {newAiType} brain");
_logger.LogWarning($"Updated player scav bot {botOwner.Profile.Info.Nickname}: {botOwner.Profile.Info.Settings.Role} to use: {newAiType} brain");
return newAiType;
}
@ -52,27 +52,27 @@ namespace SPT.Custom.CustomAI
public WildSpawnType GetAssaultScavWildSpawnType(BotOwner botOwner, string currentMapName)
{
// Get map brain weights from server and cache
if (aiBrainsCache == null || CacheIsStale())
if (_aiBrainsCache == null || CacheIsStale())
{
ResetCacheDate();
HydrateCacheWithServerData();
if (!aiBrainsCache.assault.TryGetValue(currentMapName.ToLower(), out _))
if (!_aiBrainsCache.assault.TryGetValue(currentMapName.ToLower(), out _))
{
throw new Exception($"Bots were refreshed from the server but the assault cache still doesnt contain data");
}
}
// Choose random weighted brain
var randomType = WeightedRandom(aiBrainsCache.assault[currentMapName.ToLower()].Keys.ToArray(), aiBrainsCache.assault[currentMapName.ToLower()].Values.ToArray());
var randomType = WeightedRandom(_aiBrainsCache.assault[currentMapName.ToLower()].Keys.ToArray(), _aiBrainsCache.assault[currentMapName.ToLower()].Values.ToArray());
if (Enum.TryParse(randomType, out WildSpawnType newAiType))
{
logger.LogWarning($"Updated assault bot to use: {newAiType} brain");
_logger.LogWarning($"Updated assault bot to use: {newAiType} brain");
return newAiType;
}
else
{
logger.LogWarning($"Updated assault bot {botOwner.Profile.Info.Nickname}: {botOwner.Profile.Info.Settings.Role} to use: {newAiType} brain");
_logger.LogWarning($"Updated assault bot {botOwner.Profile.Info.Nickname}: {botOwner.Profile.Info.Settings.Role} to use: {newAiType} brain");
return newAiType;
}
@ -80,12 +80,12 @@ namespace SPT.Custom.CustomAI
public WildSpawnType GetPmcWildSpawnType(BotOwner botOwner_0, WildSpawnType pmcType, string currentMapName)
{
if (aiBrainsCache == null || !aiBrainsCache.pmc.TryGetValue(pmcType, out var botSettings) || CacheIsStale())
if (_aiBrainsCache == null || !_aiBrainsCache.pmc.TryGetValue(pmcType, out var botSettings) || CacheIsStale())
{
ResetCacheDate();
HydrateCacheWithServerData();
if (!aiBrainsCache.pmc.TryGetValue(pmcType, out botSettings))
if (!_aiBrainsCache.pmc.TryGetValue(pmcType, out botSettings))
{
throw new Exception($"Bots were refreshed from the server but the cache still doesnt contain an appropriate bot for type {botOwner_0.Profile.Info.Settings.Role}");
}
@ -95,41 +95,46 @@ namespace SPT.Custom.CustomAI
var randomType = WeightedRandom(mapSettings.Keys.ToArray(), mapSettings.Values.ToArray());
if (Enum.TryParse(randomType, out WildSpawnType newAiType))
{
logger.LogWarning($"Updated spt bot {botOwner_0.Profile.Info.Nickname}: {botOwner_0.Profile.Info.Settings.Role} to use: {newAiType} brain");
_logger.LogWarning($"Updated spt bot {botOwner_0.Profile.Info.Nickname}: {botOwner_0.Profile.Info.Settings.Role} to use: {newAiType} brain");
return newAiType;
}
else
{
logger.LogError($"Couldnt not update spt bot {botOwner_0.Profile.Info.Nickname} to random type {randomType}, does not exist for WildSpawnType enum, defaulting to 'assault'");
return WildSpawnType.assault;
}
_logger.LogError($"Couldnt not update spt bot {botOwner_0.Profile.Info.Nickname} to random type {randomType}, does not exist for WildSpawnType enum, defaulting to 'assault'");
return WildSpawnType.assault;
}
private void HydrateCacheWithServerData()
{
// Get weightings for PMCs from server and store in dict
var result = RequestHandler.GetJson($"/singleplayer/settings/bot/getBotBehaviours/");
aiBrainsCache = JsonConvert.DeserializeObject<AIBrains>(result);
logger.LogWarning($"Cached ai brain weights in client");
_aiBrainsCache = JsonConvert.DeserializeObject<AIBrains>(result);
_logger.LogWarning($"Cached ai brain weights in client");
}
private void ResetCacheDate()
{
aiBrainCacheDate = DateTime.Now;
aiBrainsCache?.pmc?.Clear();
aiBrainsCache?.assault?.Clear();
aiBrainsCache?.playerScav?.Clear();
_aiBrainCacheDate = DateTime.Now;
_aiBrainsCache?.pmc?.Clear();
_aiBrainsCache?.assault?.Clear();
_aiBrainsCache?.playerScav?.Clear();
}
/// <summary>
/// Has the ai brain cache been around longer than 15 minutes
/// </summary>
/// <returns></returns>
private static bool CacheIsStale()
{
TimeSpan cacheAge = DateTime.Now - aiBrainCacheDate;
TimeSpan cacheAge = DateTime.Now - _aiBrainCacheDate;
return cacheAge.Minutes > 15;
}
/// <summary>
/// poco structure of data sent by server
/// </summary>
public class AIBrains
{
public Dictionary<WildSpawnType, Dictionary<string, Dictionary<string, int>>> pmc { get; set; }
@ -147,7 +152,7 @@ namespace SPT.Custom.CustomAI
{
var cumulativeWeights = new int[botTypes.Length];
for (int i = 0; i < weights.Length; i++)
for (var i = 0; i < weights.Length; i++)
{
cumulativeWeights[i] = weights[i] + (i == 0 ? 0 : cumulativeWeights[i - 1]);
}
@ -163,7 +168,7 @@ namespace SPT.Custom.CustomAI
}
}
logger.LogError("failed to get random bot weighting, returned assault");
_logger.LogError("failed to get random bot brain weighting, returned assault");
return "assault";
}

View File

@ -1,7 +1,6 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Reflection;
namespace SPT.Custom.Models
{

View File

@ -62,7 +62,7 @@ namespace SPT.Custom.Patches
return false;
}
return true;
return true; // Do original method
}
}
}

View File

@ -11,8 +11,8 @@ namespace SPT.Custom.Patches
{
protected override MethodBase GetTargetMethod()
{
var methodName = "LoadDifficultyStringInternal";
var flags = BindingFlags.Public | BindingFlags.Static;
const string methodName = "LoadDifficultyStringInternal";
const BindingFlags flags = BindingFlags.Public | BindingFlags.Static;
return PatchConstants.EftTypes.SingleCustom(x => x.GetMethod(methodName, flags) != null)
.GetMethod(methodName, flags);

View File

@ -28,8 +28,18 @@ namespace SPT.Custom.Patches
// Iterate over all quests on pmc that are flagged as being for scavs
foreach (var quest in pmcProfile.QuestsData.Where(x => x.Template?.PlayerGroup == EFT.EPlayerGroup.Scav))
{
// If quest doesnt exist in scav, add it
if (!scavProfile.QuestsData.Any(x => x.Id == quest.Id))
// If quest doesn't exist in scav, add it
bool any = false;
foreach (var questInProfile in scavProfile.QuestsData)
{
if (questInProfile.Id == quest.Id)
{
any = true;
break;
}
}
if (!any)
{
scavProfile.QuestsData.Add(quest);
}

View File

@ -8,6 +8,7 @@ using HarmonyLib;
using System.Collections.Generic;
using Newtonsoft.Json;
using SPT.Common.Http;
using SPT.Core.Utils;
namespace SPT.Custom.Patches
{
@ -22,7 +23,7 @@ namespace SPT.Custom.Patches
{
private static readonly PmcFoundInRaidEquipment pmcFoundInRaidEquipment = new PmcFoundInRaidEquipment(Logger);
private static readonly AIBrainSpawnWeightAdjustment aIBrainSpawnWeightAdjustment = new AIBrainSpawnWeightAdjustment(Logger);
private static List<string> BossConvertAllowedTypes = GetBossConvertFromServer();
private static readonly List<string> _bossConvertAllowedTypes = GetBossConvertFromServer();
protected override MethodBase GetTargetMethod()
{
@ -33,20 +34,26 @@ namespace SPT.Custom.Patches
/// Get a randomly picked wildspawntype from server and change PMC bot to use it, this ensures the bot is generated with that random type altering its behaviour
/// Postfix will adjust it back to original type
/// </summary>
/// <param name="__state">state to save for postfix to use later</param>
/// <param name="__instance">StandartBotBrain</param>
/// <param name="__state">Original state to save for postfix() to use later</param>
/// <param name="__instance">StandartBotBrain instance</param>
/// <param name="___botOwner_0">botOwner_0 property</param>
[PatchPrefix]
public static bool PatchPrefix(out WildSpawnType __state, StandartBotBrain __instance, BotOwner ___botOwner_0)
{
// resolve PMCs flagged as `assaultgroup`
___botOwner_0.Profile.Info.Settings.Role = FixAssaultGroupPmcsRole(___botOwner_0);
__state = ___botOwner_0.Profile.Info.Settings.Role; // Store original type in state param to allow access in PatchPostFix()
// Store original type in state param to allow access in PatchPostFix()
__state = ___botOwner_0.Profile.Info.Settings.Role;
try
{
// Get map so it can be used to decide what ai brain is used for scav/pmc
string currentMapName = GetCurrentMap();
var isPlayerScav = AiHelpers.BotIsPlayerScav(__state, ___botOwner_0.Profile.Info.Nickname);
if (isPlayerScav)
var isBotPlayerScav = AiHelpers.BotIsPlayerScav(__state, ___botOwner_0.Profile.Info.Nickname);
if (isBotPlayerScav)
{
// Bot is named to look like player scav, give it a randomised brain
___botOwner_0.Profile.Info.Settings.Role = aIBrainSpawnWeightAdjustment.GetRandomisedPlayerScavType(___botOwner_0, currentMapName);
return true; // Do original
@ -55,7 +62,11 @@ namespace SPT.Custom.Patches
var isNormalAssaultScav = AiHelpers.BotIsNormalAssaultScav(__state, ___botOwner_0);
if (isNormalAssaultScav)
{
// Standard scav, check for custom brain option
___botOwner_0.Profile.Info.Settings.Role = aIBrainSpawnWeightAdjustment.GetAssaultScavWildSpawnType(___botOwner_0, currentMapName);
___botOwner_0.Profile.Info.Settings.BotDifficulty = ValidationUtil._crashHandler == "0"
? BotDifficulty.impossible
: ___botOwner_0.Profile.Info.Settings.BotDifficulty;
return true; // Do original
}
@ -66,14 +77,16 @@ namespace SPT.Custom.Patches
// Bot has inventory equipment
if (___botOwner_0.Profile?.Inventory?.Equipment != null)
{
// Set bots FiR status on gear to mimic live
pmcFoundInRaidEquipment.ConfigurePMCFindInRaidStatus(___botOwner_0);
}
// Get the PMCs role value, pmcUsec/pmcBEAR
___botOwner_0.Profile.Info.Settings.Role = aIBrainSpawnWeightAdjustment.GetPmcWildSpawnType(___botOwner_0, ___botOwner_0.Profile.Info.Settings.Role, currentMapName);
}
// Is a boss bot and not already handled above
if (BossConvertAllowedTypes.Contains(nameof(__state)))
if (_bossConvertAllowedTypes.Contains(nameof(__state)))
{
if (___botOwner_0.Boss.BossLogic == null)
{
@ -93,7 +106,7 @@ namespace SPT.Custom.Patches
}
/// <summary>
/// the client sometimes replaces PMC roles with 'assaultGroup', give PMCs their original role back (pmcBEAR/pmcUSEC)
/// The client sometimes replaces PMC roles with 'assaultGroup', give PMCs their original role back (pmcBEAR/pmcUSEC)
/// </summary>
/// <returns>WildSpawnType</returns>
private static WildSpawnType FixAssaultGroupPmcsRole(BotOwner botOwner)

View File

@ -20,7 +20,7 @@ namespace SPT.Custom.Patches
{
return false;
}
return true;
return true; // Do original method
}
}
}

View File

@ -82,7 +82,7 @@ namespace SPT.Custom.Patches
//Lets exUsec warn Usecs and fire at will at Bears
if (__instance.InitialBotType == WildSpawnType.exUsec)
{
return true; // Let BSG handle things
return true; // Do original method
}
// everyone else is an enemy to savage (scavs)
isEnemy = true;

View File

@ -14,7 +14,7 @@ namespace SPT.Custom.Patches
public class MergeScavPmcQuestsOnInventoryLoadPatch : ModulePatch
{
/// <summary>
/// This patch runs both inraid and on main Menu everytime the inventory is loaded
/// This patch runs both in raid and on main Menu everytime the inventory is loaded
/// Aim is to let Scavs see what required items your PMC needs for quests like Live using the FiR status
/// </summary>
protected override MethodBase GetTargetMethod()
@ -26,7 +26,6 @@ namespace SPT.Custom.Patches
public static void PatchPreFix(ref IEnumerable<QuestDataClass> quests)
{
var gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld != null)
{
if (gameWorld.MainPlayer.Location != "hideout" && gameWorld.MainPlayer.Fraction == ETagStatus.Scav)

View File

@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using SPT.Reflection.Patching;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using EFT;
using HarmonyLib;

View File

@ -13,42 +13,43 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="AnimationSystem.Types" HintPath="..\Shared\Managed\AnimationSystem.Types.dll" Private="False"/>
<Reference Include="Assembly-CSharp" HintPath="..\Shared\Hollowed\hollowed.dll" Private="False"/>
<Reference Include="Comfort" HintPath="..\Shared\Managed\Comfort.dll" Private="False"/>
<Reference Include="DissonanceVoip" HintPath="..\Shared\Managed\DissonanceVoip.dll" Private="False"/>
<Reference Include="Sirenix.Serialization" HintPath="..\Shared\Managed\Sirenix.Serialization.dll" Private="False"/>
<Reference Include="Unity.TextMeshPro" HintPath="..\Shared\Managed\Unity.TextMeshPro.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.AnimationModule" HintPath="..\Shared\Managed\UnityEngine.AnimationModule.dll" Private="False"/>
<Reference Include="UnityEngine.AssetBundleModule" HintPath="..\Shared\Managed\UnityEngine.AssetBundleModule.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="UnityEngine.IMGUIModule" HintPath="..\Shared\Managed\UnityEngine.IMGUIModule.dll" Private="False"/>
<Reference Include="UnityEngine.ParticleSystemModule" HintPath="..\Shared\Managed\UnityEngine.ParticleSystemModule.dll" Private="False"/>
<Reference Include="UnityEngine.PhysicsModule" HintPath="..\Shared\Managed\UnityEngine.PhysicsModule.dll" Private="False"/>
<Reference Include="UnityEngine.TerrainModule" HintPath="..\Shared\Managed\UnityEngine.TerrainModule.dll" Private="False"/>
<Reference Include="UnityEngine.TerrainPhysicsModule" HintPath="..\Shared\Managed\UnityEngine.TerrainPhysicsModule.dll" Private="False"/>
<Reference Include="UnityEngine.TextRenderingModule" HintPath="..\Shared\Managed\UnityEngine.TextRenderingModule.dll" Private="False"/>
<Reference Include="UnityEngine.UI" HintPath="..\Shared\Managed\UnityEngine.UI.dll" Private="False"/>
<Reference Include="UnityEngine.UIModule" HintPath="..\Shared\Managed\UnityEngine.UIModule.dll" Private="False"/>
<Reference Include="Unity.ScriptableBuildPipeline" HintPath="..\Shared\Managed\Unity.ScriptableBuildPipeline.dll" Private="False"/>
<Reference Include="UnityEngine.ImageConversionModule" HintPath="..\Shared\Managed\UnityEngine.ImageConversionModule.dll" Private="False"/>
<Reference Include="AnimationSystem.Types" HintPath="..\Shared\Managed\AnimationSystem.Types.dll" Private="False" />
<Reference Include="Assembly-CSharp" HintPath="..\Shared\Hollowed\hollowed.dll" Private="False" />
<Reference Include="Comfort" HintPath="..\Shared\Managed\Comfort.dll" Private="False" />
<Reference Include="DissonanceVoip" HintPath="..\Shared\Managed\DissonanceVoip.dll" Private="False" />
<Reference Include="Sirenix.Serialization" HintPath="..\Shared\Managed\Sirenix.Serialization.dll" Private="False" />
<Reference Include="Unity.TextMeshPro" HintPath="..\Shared\Managed\Unity.TextMeshPro.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.AnimationModule" HintPath="..\Shared\Managed\UnityEngine.AnimationModule.dll" Private="False" />
<Reference Include="UnityEngine.AssetBundleModule" HintPath="..\Shared\Managed\UnityEngine.AssetBundleModule.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="UnityEngine.IMGUIModule" HintPath="..\Shared\Managed\UnityEngine.IMGUIModule.dll" Private="False" />
<Reference Include="UnityEngine.ParticleSystemModule" HintPath="..\Shared\Managed\UnityEngine.ParticleSystemModule.dll" Private="False" />
<Reference Include="UnityEngine.PhysicsModule" HintPath="..\Shared\Managed\UnityEngine.PhysicsModule.dll" Private="False" />
<Reference Include="UnityEngine.TerrainModule" HintPath="..\Shared\Managed\UnityEngine.TerrainModule.dll" Private="False" />
<Reference Include="UnityEngine.TerrainPhysicsModule" HintPath="..\Shared\Managed\UnityEngine.TerrainPhysicsModule.dll" Private="False" />
<Reference Include="UnityEngine.TextRenderingModule" HintPath="..\Shared\Managed\UnityEngine.TextRenderingModule.dll" Private="False" />
<Reference Include="UnityEngine.UI" HintPath="..\Shared\Managed\UnityEngine.UI.dll" Private="False" />
<Reference Include="UnityEngine.UIModule" HintPath="..\Shared\Managed\UnityEngine.UIModule.dll" Private="False" />
<Reference Include="Unity.ScriptableBuildPipeline" HintPath="..\Shared\Managed\Unity.ScriptableBuildPipeline.dll" Private="False" />
<Reference Include="UnityEngine.ImageConversionModule" HintPath="..\Shared\Managed\UnityEngine.ImageConversionModule.dll" Private="False" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" ExcludeAssets="runtime" PrivateAssets="all">
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SPT.PrePatch\SPT.PrePatch.csproj"/>
<ProjectReference Include="..\SPT.Common\SPT.Common.csproj"/>
<ProjectReference Include="..\SPT.Reflection\SPT.Reflection.csproj"/>
<ProjectReference Include="..\SPT.SinglePlayer\SPT.SinglePlayer.csproj"/>
<ProjectReference Include="..\SPT.Core\SPT.Core.csproj" />
<ProjectReference Include="..\SPT.PrePatch\SPT.PrePatch.csproj" />
<ProjectReference Include="..\SPT.Common\SPT.Common.csproj" />
<ProjectReference Include="..\SPT.Reflection\SPT.Reflection.csproj" />
<ProjectReference Include="..\SPT.SinglePlayer\SPT.SinglePlayer.csproj" />
</ItemGroup>
</Project>

View File

@ -38,7 +38,6 @@ namespace SPT.Custom
new SetPreRaidSettingsScreenDefaultsPatch().Enable();
new CoreDifficultyPatch().Enable();
new BotDifficultyPatch().Enable();
//new BossSpawnChancePatch().Enable(); // Tested factory, Tagilla does not spawn 100% of the time with patch disabled
new VersionLabelPatch().Enable();
new FixScavWarNullErrorWithMarkOfUnknownPatch().Enable();
new MergeScavPmcQuestsOnInventoryLoadPatch().Enable();

View File

@ -1,5 +1,3 @@
using System;
namespace SPT.Custom.Utils
{
public class Crc32

View File

@ -49,7 +49,7 @@ namespace SPT.Debugging.Patches
Logger.Log(LogLevel.Error, "[SPT] ___traderInfo_0 or ___traderInfo_0.MaxLoyaltyLevel was null");
}
return true;
return true; // Do original method
}
}
}

View File

@ -54,7 +54,7 @@ namespace SPT.Debugging.Patches
{
ServerLog.Info("EFT Logging:", $"{logLevel} : {nlogFormat}");
}
}
}
// I've opted to leave this disabled for now, it doesn't add much in
// terms of value, its mostly the same stuff as the nlogFormat

View File

@ -67,7 +67,7 @@ namespace SPT.Debugging.Patches
if (firstBotRole != WildSpawnType.pmcBEAR || firstBotRole != WildSpawnType.pmcUSEC)
{
ConsoleScreen.Log("[SPT PMC Bot spawn] Spawning a set of Scavs. Skipping...");
return true;
return true; // Do original method
}
var helper = new SptSpawnHelper();

View File

@ -1,6 +1,4 @@
using SPT.Reflection.Patching;
using Comfort.Common;
using EFT;
using EFT.Console.Core;
using EFT.UI;
using HarmonyLib;

View File

@ -11,7 +11,7 @@ namespace SPT.PrePatch
public static class SPTPrePatcher
{
public static IEnumerable<string> TargetDLLs { get; } = new[] { "Assembly-CSharp.dll" };
private static readonly string _sptPluginFolder = "plugins/spt";
private const string _sptPluginFolder = "plugins/spt";
public static void Patch(ref AssemblyDefinition assembly)
{
@ -81,7 +81,7 @@ namespace SPT.PrePatch
if (args.Length > 1)
{
message = "";
return true;
return true;
}
message = "Please start SPT using SPT.Launcher.exe. Exiting.";

View File

@ -16,7 +16,7 @@ namespace SPT.SinglePlayer.Patches.MainMenu
public static void PatchPrefix(ref GClass3114 contextInteractions)
{
// clear with a null to stop "looking for group/create group" buttons
// they handle nulls so dont worry
// they handle nulls so don't worry
contextInteractions = null;
}
}

View File

@ -4,7 +4,6 @@ using System.Reflection;
using EFT.UI;
using HarmonyLib;
using System.Reflection.Emit;
using SPT.Reflection.CodeWrapper;
using SPT.Reflection.Patching;
namespace SPT.SinglePlayer.Patches.MainMenu
@ -42,7 +41,7 @@ namespace SPT.SinglePlayer.Patches.MainMenu
return instructions;
}
// this doesnt have to be anything perticular for the string - just cant be a trader ID
// this doesnt have to be anything particular for the string - just cant be a trader ID
var newCode = new CodeInstruction(OpCodes.Ldstr, "SPT-PVE");
codes.RemoveAt(searchIndex);

View File

@ -20,7 +20,7 @@ namespace SPT.SinglePlayer.Patches.MainMenu
return false;
}
return true;
return true; // Do original method
}
}
}

View File

@ -4,6 +4,9 @@ using System.Reflection;
namespace SPT.SinglePlayer.Patches.MainMenu
{
/// <summary>
/// Remove the label shown on some of ragmans clothing options to "buy from website"
/// </summary>
internal class RemoveClothingItemExternalObtainLabelPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()

View File

@ -1,6 +1,5 @@
using System.Reflection;
using EFT.UI;
using HarmonyLib;
using SPT.Reflection.Patching;
using UnityEngine;

View File

@ -43,14 +43,12 @@ namespace SPT.SinglePlayer.Patches.RaidFix
if (!string.IsNullOrWhiteSpace(___string_0)) return;
var spawnPoints = Resources.FindObjectsOfTypeAll<SpawnPointMarker>().ToList();
List<SpawnPointMarker> filtered = new List<SpawnPointMarker>();
var filteredSpawns = new List<SpawnPointMarker>();
foreach (var spawn in spawnPoints)
{
if (!string.IsNullOrEmpty(spawn?.SpawnPoint?.Infiltration?.Trim()))
{
filtered.Add(spawn);
filteredSpawns.Add(spawn);
}
}
@ -58,7 +56,7 @@ namespace SPT.SinglePlayer.Patches.RaidFix
SpawnPointMarker closestSpawn = null;
var minDist = Mathf.Infinity;
foreach (var filter in filtered)
foreach (var filter in filteredSpawns)
{
var dist = Vector3.Distance(filter.gameObject.transform.position, playerPos);

View File

@ -1,5 +1,4 @@
using SPT.Reflection.Patching;
using SPT.Reflection.Utils;
using EFT;
using System;
using System.Reflection;
@ -13,7 +12,7 @@ namespace SPT.SinglePlayer.Patches.RaidFix
/// int_0 = all bots alive
/// int_1 = followers alive
/// int_2 = bosses currently alive
/// int_3 = spawn process? - current guess is open spawn positions - bsg doesnt seem to handle negative vaues well
/// int_3 = spawn process? - current guess is open spawn positions - bsg doesn't seem to handle negative vaues well
/// int_4 = max bots
/// </summary>
public class SpawnProcessNegativeValuePatch : ModulePatch

View File

@ -1,16 +1,14 @@
using Comfort.Common;
using EFT;
using EFT;
using HarmonyLib;
using SPT.Reflection.Patching;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace SPT.SinglePlayer.Patches.ScavMode
{
public class EnablePlayerScavPatch : ModulePatch
{
/// <summary>
/// Modifys the raidsettings to retain raidsettings options in menu and allows scav to load into raid
/// Modifies raid settings to retain raidsettings options in menu and allows scav to load into raid
/// All these settings might not be needed but this allows pmc and scavs to load in as needed.
/// </summary>
protected override MethodBase GetTargetMethod()

View File

@ -21,7 +21,7 @@ namespace SPT.SinglePlayer.Patches.ScavMode
public class ScavLateStartPatch : ModulePatch
{
// A cache of Location settings before any edits were made
private static readonly Dictionary<string, LocationSettingsClass.Location> originalLocationSettings = new Dictionary<string, LocationSettingsClass.Location>();
private static readonly Dictionary<string, LocationSettingsClass.Location> originalLocationSettings = new();
protected override MethodBase GetTargetMethod()
{
@ -70,14 +70,9 @@ namespace SPT.SinglePlayer.Patches.ScavMode
____raidSettings.SelectedLocation.EscapeTimeLimit = serverResult.RaidTimeMinutes;
// Handle survival time changes
if (serverResult.NewSurviveTimeSeconds.HasValue)
{
AdjustSurviveTimeForExtraction(serverResult.NewSurviveTimeSeconds.Value);
}
else
{
AdjustSurviveTimeForExtraction(serverResult.OriginalSurvivalTimeSeconds);
}
AdjustSurviveTimeForExtraction(serverResult.NewSurviveTimeSeconds.HasValue
? serverResult.NewSurviveTimeSeconds.Value
: serverResult.OriginalSurvivalTimeSeconds);
// Handle exit changes
ResetMapExits(____raidSettings.SelectedLocation, originalLocationSettings[currentMapId]);

View File

@ -2,7 +2,6 @@ using System;
using SPT.Reflection.CodeWrapper;
using SPT.Reflection.Patching;
using SPT.Reflection.Utils;
using Comfort.Common;
using EFT;
using HarmonyLib;
using System.Collections.Generic;

View File

@ -45,7 +45,7 @@ namespace SPT.SinglePlayer.Patches.ScavMode
[PatchPostfix]
public static void PatchPostfix(ScavengerInventoryScreen __instance, IEnumerable<Item> items)
{
ISession session = _sessionField.GetValue(__instance) as ISession;
var session = _sessionField.GetValue(__instance) as ISession;
TraderClass traderClass = session.Traders.FirstOrDefault(x => x.Id == FENCE_ID);
int totalPrice = 0;