Skip to content

Commit

Permalink
Naming and var usage adjustments after merging a pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
CactusPie committed Nov 18, 2023
1 parent b30d264 commit f55ec69
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/CactusPie.FastSearch/SearchInitialDelayPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,22 @@ public class SearchInitialDelayPatch : ModulePatch
protected override MethodBase GetTargetMethod()
{
_searchOperationClass = PatchConstants.EftTypes.Single(x => x.GetMethod("GetNextDiscoveryTime", BindingFlags.Static | BindingFlags.Public) != null);

_terminatedField = _searchOperationClass.GetField("Terminated", BindingFlags.Instance | BindingFlags.Public);
var searchOperationFields = _searchOperationClass.GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo[] searchOperationFields = _searchOperationClass.GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
_inventoryControllerField = searchOperationFields.Single(x => x.FieldType == typeof(InventoryControllerClass));
_searchableItemField = searchOperationFields.Single(x => x.FieldType == typeof(SearchableItemClass));

return AccessTools.GetDeclaredMethods(_searchOperationClass).FirstOrDefault(IsTargetMethod);
}

private static bool IsTargetMethod(MethodInfo mi)
private static bool IsTargetMethod(MethodInfo methodInfo)
{
var parameters = mi.GetParameters();
ParameterInfo[] parameters = methodInfo.GetParameters();
return parameters.Length >= 2
&& parameters[0].Name == "callback"
&& parameters[1].Name == "isInstant"
&& mi.ReturnType == typeof(System.Collections.IEnumerator);
&& methodInfo.ReturnType == typeof(System.Collections.IEnumerator);
}

[PatchPrefix]
Expand Down

0 comments on commit f55ec69

Please sign in to comment.