-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73f4d9a
commit abb781e
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net48</TargetFramework> | ||
<AssemblyName>HeroDeckShow</AssemblyName> | ||
<Description>My first plugin</Description> | ||
<Version>1.0.0</Version> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" /> | ||
<PackageReference Include="BepInEx.Core" Version="5.*" /> | ||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> | ||
<PackageReference Include="UnityEngine.Modules" Version="2021.2.14" IncludeAssets="compile" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>../libs/Assembly-CSharp.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'"> | ||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" /> | ||
</packageSources> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using BepInEx; | ||
using HarmonyLib; | ||
|
||
namespace HeroDeckShow | ||
{ | ||
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)] | ||
public class Plugin : BaseUnityPlugin | ||
{ | ||
private void Awake() | ||
{ | ||
// Plugin startup logic | ||
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!"); | ||
|
||
Harmony.CreateAndPatchAll(typeof(Plugin)); | ||
} | ||
|
||
[HarmonyPatch(typeof(DeckWindowUI), "SetCombatCard")] | ||
[HarmonyPrefix] | ||
public static bool SetCombatCardPrefix(DeckWindowUI __instance, Hero hero,ref string cardId, int position, int total){ | ||
var heroIndex = GetHeroIndex(hero); | ||
var heroDeck = MatchManager.Instance.GetHeroDeck(heroIndex); | ||
|
||
// 抽牌时查看牌堆顺序, 不是线程安全的 | ||
// position 可能会超出牌堆数量 | ||
if (position < heroDeck.Count) | ||
{ | ||
cardId = heroDeck[position]; | ||
} | ||
return true; | ||
} | ||
|
||
|
||
public static int GetHeroIndex(Hero target){ | ||
var hero = AtOManager.Instance.GetHero(0); | ||
if (hero == target){ | ||
return 0; | ||
} | ||
|
||
hero = AtOManager.Instance.GetHero(1); | ||
if (hero == target){ | ||
return 1; | ||
} | ||
|
||
hero = AtOManager.Instance.GetHero(2); | ||
if (hero == target){ | ||
return 2; | ||
} | ||
|
||
return 3; | ||
} | ||
} | ||
} |
Binary file not shown.