Skip to content

Commit

Permalink
Add patch PlayerTool to find dummy by name.
Browse files Browse the repository at this point in the history
  • Loading branch information
DiFFoZ committed Oct 17, 2020
1 parent f1ae1fe commit bf8a51f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Dummy/Patches/Patch_PlayerTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class Patch_PlayerTool
public static void getSteamPlayerBySteamId(CSteamID steamID, ref SteamPlayer __result)
{
if (__result != null || OnNeedDummyProvider == null) return;
var dummy = OnNeedDummyProvider.Invoke().Dummies.FirstOrDefault(x => x.SteamID == steamID);
var dummy = OnNeedDummyProvider().Dummies.FirstOrDefault(x => x.SteamID == steamID);
if (dummy != null)
{
__result = dummy.SteamPlayer;
Expand All @@ -29,12 +29,26 @@ public static void getSteamPlayerByUlong(ulong steamID, ref SteamPlayer __result
{
if (__result != null || OnNeedDummyProvider == null) return;

var dummy = OnNeedDummyProvider.Invoke().Dummies.FirstOrDefault(x => x.SteamID == (CSteamID)steamID);
var dummy = OnNeedDummyProvider().Dummies.FirstOrDefault(x => x.SteamID == (CSteamID)steamID);
if (dummy != null)
{
__result = dummy.SteamPlayer;
}
}

[HarmonyPatch("getSteamPlayer", new Type[] { typeof(string) })]
[HarmonyPostfix]
public static void getSteamPlayerByString(string name, ref SteamPlayer __result)
{
if (__result != null || OnNeedDummyProvider == null) return;

var dummy = OnNeedDummyProvider().Dummies
.FirstOrDefault(x => NameTool.checkNames(name, x.DisplayName)
|| NameTool.checkNames(name, x.SteamPlayer.playerID.playerName));
if (dummy != null)
{
__result = dummy.SteamPlayer;
}
}
// todo: add patch to get by name
}
}

0 comments on commit bf8a51f

Please sign in to comment.