Skip to content

Commit c2ad03d

Browse files
committed
Support the latest version of the game (2.0.2)
1 parent d3d2e21 commit c2ad03d

219 files changed

Lines changed: 1072 additions & 41989 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ csharp_style_expression_bodied_lambdas = true:silent
2323
csharp_style_expression_bodied_local_functions = false:silent
2424

2525
# 4 space indentation
26-
[*.{cs}]
26+
[*.{cs,csproj}]
2727
indent_style = space
2828
indent_size = 4
2929

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,4 @@ MigrationBackup/
362362
# Fody - auto-generated XML schema
363363
FodyWeavers.xsd
364364
.vshistory
365+
/ProjectSettings.custom.props

BetterPayableUpgrade/BetterPayableUpgrade.cs

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,29 @@ public static void PatchAll()
3434
}
3535
}
3636

37-
[HarmonyPatch(typeof(CoinBag), "Init")]
37+
[HarmonyPatch(typeof(CurrencyBag), "Init")]
3838
public class CoinBagInitPatcher
3939
{
40-
public static void Prefix(CoinBag __instance)
40+
public static void Prefix(CurrencyBag __instance)
4141
{
42-
log.LogMessage($"CoinBagInitPatcher localScale: {__instance.bagCoinPrefab.gameObject.transform.localScale}");
42+
for (int i = 0; i < CurrencyManager.AllCurrencyTypes.Length; i++)
43+
{
44+
CurrencyType type = CurrencyManager.AllCurrencyTypes[i];
45+
if (!SingletonMonoBehaviour<Managers>.Inst.currency.TryGetData(type, out var currencyConfig))
46+
{
47+
throw new Exception(string.Format("Cannot get CurrencyData for {0}!", type));
48+
}
4349

44-
__instance.bagCoinPrefab.gameObject.transform.localScale = new Vector3(0.668f, 0.668f, 0.668f);
45-
__instance.bagGemPrefab.gameObject.transform.localScale = new Vector3(0.668f, 0.668f, 0.668f);
50+
if (currencyConfig.BagPrefab)
51+
{
52+
log.LogMessage($"CoinBagInitPatcher localScale: {currencyConfig.BagPrefab.gameObject.transform.localScale}");
4653

47-
var bagCoinPrefab = BiomeData.GetPrefabSwap(__instance.bagCoinPrefab);
48-
bagCoinPrefab.gameObject.transform.localScale = new Vector3(0.668f, 0.668f, 0.668f);
54+
currencyConfig.BagPrefab.gameObject.transform.localScale = new Vector3(0.668f, 0.668f, 0.668f);
55+
56+
var bagCoinPrefab = BiomeData.GetPrefabSwap(currencyConfig.BagPrefab);
57+
bagCoinPrefab.gameObject.transform.localScale = new Vector3(0.668f, 0.668f, 0.668f);
58+
}
59+
}
4960
}
5061
}
5162
}
@@ -175,7 +186,7 @@ public void AdjustCosts()
175186
if (obj == null) continue;
176187
var scaffolding = obj.GetComponent<Scaffolding>();
177188
if (scaffolding == null) continue;
178-
var go = scaffolding.building;
189+
var go = scaffolding.Building;
179190
if (go == null) continue;
180191

181192
HandlePayable(go, false, false);
@@ -212,8 +223,8 @@ private static void HandlePayable(GameObject go, bool isPrefab, bool modifyBuild
212223
var payable = go.GetComponent<CitizenHousePayable>();
213224
if (payable != null)
214225
{
215-
log.LogDebug($"Change {go.name} price from {payable.price} to 3");
216-
payable.price = 3;
226+
log.LogDebug($"Change {go.name} price from {payable.Price} to 3");
227+
payable.Price = 3;
217228
}
218229
break;
219230
}
@@ -225,8 +236,8 @@ private static void HandlePayable(GameObject go, bool isPrefab, bool modifyBuild
225236
var payable = payableWorkshop.barrelCounterpart;
226237
if (payable != null)
227238
{
228-
log.LogDebug($"Change {go.name} price from {payable.price} to 3");
229-
payable.price = 3;
239+
log.LogDebug($"Change {go.name} price from {payable.Price} to 3");
240+
payable.Price = 3;
230241
}
231242
}
232243
break;
@@ -236,8 +247,8 @@ private static void HandlePayable(GameObject go, bool isPrefab, bool modifyBuild
236247
var payable = go.GetComponent<PayableShop>();
237248
if (payable != null)
238249
{
239-
log.LogDebug($"Change {go.name} price from {payable.price} to 2");
240-
payable.price = 2;
250+
log.LogDebug($"Change {go.name} price from {payable.Price} to 2");
251+
payable.Price = 2;
241252
}
242253
break;
243254
}
@@ -265,16 +276,18 @@ private static void HandleTower(GameObject go, PrefabIDs prefabId, bool isPrefab
265276
var workable = go.GetComponent<WorkableBuilding>();
266277
if (workable != null)
267278
{
268-
log.LogDebug($"Change {go.name} buildPoints from {workable.buildPoints} to {modifyData.BuildPoints}");
269-
workable.buildPoints = modifyData.BuildPoints;
279+
var constructionBuilding = Require.Component<ConstructionBuildingComponent>(workable);
280+
var buildPoints = constructionBuilding.GetFieldOrPropertyValue<int>("_buildPoints");
281+
log.LogDebug($"Change {go.name} buildPoints from {buildPoints} to {modifyData.BuildPoints}");
282+
constructionBuilding.SetFieldOrPropertyValue("_buildPoints", modifyData.BuildPoints);
270283
}
271284
}
272285

273286
var payable = go.GetComponent<PayableUpgrade>();
274287
if (payable != null)
275288
{
276-
log.LogDebug($"Change {go.name} price from {payable.price} to {modifyData.Price}");
277-
payable.price = modifyData.Price;
289+
log.LogDebug($"Change {go.name} price from {payable.Price} to {modifyData.Price}");
290+
payable.Price = modifyData.Price;
278291

279292
if (modifyData.NextPrefab != PrefabIDs.None)
280293
{
Lines changed: 115 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,121 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<Import Project="..\ProjectSettings.shared.props" />
3+
<Import Project="..\ProjectSettings.custom.props" />
24

3-
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
5-
<AssemblyName>KingdomMod.BetterPayableUpgrade</AssemblyName>
6-
<Description>KingdomMod.BetterPayableUpgrade</Description>
7-
<Version>2.2.0</Version>
8-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
9-
<LangVersion>latest</LangVersion>
10-
<RestoreAdditionalProjectSources>
11-
https://api.nuget.org/v3/index.json;
12-
https://nuget.bepinex.dev/v3/index.json;
13-
https://nuget.samboy.dev/v3/index.json
14-
</RestoreAdditionalProjectSources>
15-
<RootNamespace>KingdomMod</RootNamespace>
16-
<Configurations>Debug;BIE6_IL2CPP;BIE6_Mono</Configurations>
17-
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
18-
</PropertyGroup>
19-
20-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
21-
<DefineConstants>IL2CPP,BIE,BIE6</DefineConstants>
22-
<WarningsAsErrors>$(WarningsAsErrors);NU1605</WarningsAsErrors>
23-
<BepInExPluginsDir>D:\SteamLibrary\steamapps\common\Kingdom Two Crowns\BepInEx\plugins\</BepInExPluginsDir>
24-
</PropertyGroup>
25-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='BIE6_IL2CPP|AnyCPU'">
26-
<DefineConstants>IL2CPP,BIE,BIE6</DefineConstants>
27-
<WarningsAsErrors>$(WarningsAsErrors);NU1605</WarningsAsErrors>
28-
<BepInExPluginsDir>D:\SteamLibrary\steamapps\common\Kingdom Two Crowns\BepInEx\plugins\</BepInExPluginsDir>
29-
</PropertyGroup>
30-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='BIE6_Mono|AnyCPU'">
31-
<TargetFramework>net472</TargetFramework>
32-
<DefineConstants>MONO,BIE,BIE6</DefineConstants>
33-
<WarningsAsErrors>$(WarningsAsErrors);NU1605</WarningsAsErrors>
34-
<BepInExPluginsDir>D:\Game\Kingdom Two Crowns v1.1.18\BepInEx\plugins\</BepInExPluginsDir>
35-
</PropertyGroup>
5+
<PropertyGroup>
6+
<AssemblyName>KingdomMod.BetterPayableUpgrade</AssemblyName>
7+
<Description>KingdomMod.BetterPayableUpgrade</Description>
8+
<Version>2.3.0</Version>
9+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
10+
<LangVersion>latest</LangVersion>
11+
<RestoreAdditionalProjectSources>
12+
https://api.nuget.org/v3/index.json;
13+
https://nuget.bepinex.dev/v3/index.json;
14+
https://nuget.samboy.dev/v3/index.json
15+
</RestoreAdditionalProjectSources>
16+
<RootNamespace>KingdomMod</RootNamespace>
17+
<Configurations>Debug;BIE6_IL2CPP;BIE6_Mono</Configurations>
18+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
19+
</PropertyGroup>
3620

37-
<ItemGroup>
38-
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
39-
</ItemGroup>
21+
<ItemGroup>
22+
<Compile Include="..\Shared\TypeExtensions.cs" Link="Shared\TypeExtensions.cs" />
23+
<Compile Include="..\Shared\ObjectExtensions.cs" Link="Shared\ObjectExtensions.cs" />
24+
</ItemGroup>
4025

41-
<!-- BIE6_IL2CPP -->
42-
<ItemGroup Condition="'$(Configuration)'=='BIE6_IL2CPP' or '$(Configuration)'=='Debug'">
43-
<Reference Include="0Harmony">
44-
<HintPath>..\_libs\BIE6_IL2CPP\core\0Harmony.dll</HintPath>
45-
<Private>False</Private>
46-
</Reference>
47-
<Reference Include="Assembly-CSharp">
48-
<HintPath>..\_libs\BIE6_IL2CPP\interop\Assembly-CSharp.dll</HintPath>
49-
<Private>False</Private>
50-
</Reference>
51-
<Reference Include="BepInEx.Core">
52-
<HintPath>..\_libs\BIE6_IL2CPP\core\BepInEx.Core.dll</HintPath>
53-
<Private>False</Private>
54-
</Reference>
55-
<Reference Include="BepInEx.Unity.IL2CPP">
56-
<HintPath>..\_libs\BIE6_IL2CPP\core\BepInEx.Unity.IL2CPP.dll</HintPath>
57-
<Private>False</Private>
58-
</Reference>
59-
<Reference Include="Il2CppInterop.Runtime">
60-
<HintPath>..\_libs\BIE6_IL2CPP\core\Il2CppInterop.Runtime.dll</HintPath>
61-
<Private>False</Private>
62-
</Reference>
63-
<Reference Include="Il2Cppmscorlib">
64-
<HintPath>..\_libs\BIE6_IL2CPP\interop\Il2Cppmscorlib.dll</HintPath>
65-
<Private>False</Private>
66-
</Reference>
67-
<Reference Include="UnityEngine">
68-
<HintPath>..\_libs\BIE6_IL2CPP\interop\UnityEngine.dll</HintPath>
69-
<Private>False</Private>
70-
</Reference>
71-
<Reference Include="UnityEngine.CoreModule">
72-
<HintPath>..\_libs\BIE6_IL2CPP\interop\UnityEngine.CoreModule.dll</HintPath>
73-
<Private>False</Private>
74-
</Reference>
75-
<Reference Include="UnityEngine.IMGUIModule">
76-
<HintPath>..\_libs\BIE6_IL2CPP\interop\UnityEngine.IMGUIModule.dll</HintPath>
77-
<Private>False</Private>
78-
</Reference>
79-
<Reference Include="UnityEngine.InputLegacyModule">
80-
<HintPath>..\_libs\BIE6_IL2CPP\interop\UnityEngine.InputLegacyModule.dll</HintPath>
81-
<Private>False</Private>
82-
</Reference>
83-
</ItemGroup>
26+
<ItemGroup>
27+
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
28+
</ItemGroup>
8429

85-
<!-- BIE6_Mono -->
86-
<ItemGroup Condition="'$(Configuration)'=='BIE6_Mono'">
87-
<Reference Include="0Harmony">
88-
<HintPath>..\_libs\BIE6_Mono\core\0Harmony.dll</HintPath>
89-
<Private>False</Private>
90-
</Reference>
91-
<Reference Include="Assembly-CSharp">
92-
<HintPath>..\_libs\BIE6_Mono\Managed\Assembly-CSharp.dll</HintPath>
93-
<Private>False</Private>
94-
</Reference>
95-
<Reference Include="BepInEx.Core">
96-
<HintPath>..\_libs\BIE6_Mono\core\BepInEx.Core.dll</HintPath>
97-
<Private>False</Private>
98-
</Reference>
99-
<Reference Include="BepInEx.Unity.Mono">
100-
<HintPath>..\_libs\BIE6_Mono\core\BepInEx.Unity.Mono.dll</HintPath>
101-
<Private>False</Private>
102-
</Reference>
103-
<Reference Include="Mono.Cecil">
104-
<HintPath>..\_libs\BIE6_Mono\core\Mono.Cecil.dll</HintPath>
105-
<Private>False</Private>
106-
</Reference>
107-
<Reference Include="UnityEngine">
108-
<HintPath>..\_libs\BIE6_Mono\Managed\UnityEngine.dll</HintPath>
109-
<Private>False</Private>
110-
</Reference>
111-
<Reference Include="UnityEngine.CoreModule">
112-
<HintPath>..\_libs\BIE6_Mono\Managed\UnityEngine.CoreModule.dll</HintPath>
113-
<Private>False</Private>
114-
</Reference>
115-
<Reference Include="UnityEngine.IMGUIModule">
116-
<HintPath>..\_libs\BIE6_Mono\Managed\UnityEngine.IMGUIModule.dll</HintPath>
117-
<Private>False</Private>
118-
</Reference>
119-
<Reference Include="UnityEngine.InputLegacyModule">
120-
<HintPath>..\_libs\BIE6_Mono\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
121-
<Private>False</Private>
122-
</Reference>
123-
</ItemGroup>
30+
<!-- BIE6_IL2CPP -->
31+
<ItemGroup Condition="'$(Configuration)'=='BIE6_IL2CPP'">
32+
<Reference Include="0Harmony">
33+
<HintPath>..\_libs\BIE6_IL2CPP\core\0Harmony.dll</HintPath>
34+
<Private>False</Private>
35+
</Reference>
36+
<Reference Include="Assembly-CSharp">
37+
<HintPath>..\_libs\BIE6_IL2CPP\interop\Assembly-CSharp.dll</HintPath>
38+
<Private>False</Private>
39+
</Reference>
40+
<Reference Include="BepInEx.Core">
41+
<HintPath>..\_libs\BIE6_IL2CPP\core\BepInEx.Core.dll</HintPath>
42+
<Private>False</Private>
43+
</Reference>
44+
<Reference Include="BepInEx.Unity.IL2CPP">
45+
<HintPath>..\_libs\BIE6_IL2CPP\core\BepInEx.Unity.IL2CPP.dll</HintPath>
46+
<Private>False</Private>
47+
</Reference>
48+
<Reference Include="Il2CppInterop.Runtime">
49+
<HintPath>..\_libs\BIE6_IL2CPP\core\Il2CppInterop.Runtime.dll</HintPath>
50+
<Private>False</Private>
51+
</Reference>
52+
<Reference Include="Il2Cppmscorlib">
53+
<HintPath>..\_libs\BIE6_IL2CPP\interop\Il2Cppmscorlib.dll</HintPath>
54+
<Private>False</Private>
55+
</Reference>
56+
<Reference Include="UnityEngine">
57+
<HintPath>..\_libs\BIE6_IL2CPP\interop\UnityEngine.dll</HintPath>
58+
<Private>False</Private>
59+
</Reference>
60+
<Reference Include="UnityEngine.CoreModule">
61+
<HintPath>..\_libs\BIE6_IL2CPP\interop\UnityEngine.CoreModule.dll</HintPath>
62+
<Private>False</Private>
63+
</Reference>
64+
<Reference Include="UnityEngine.IMGUIModule">
65+
<HintPath>..\_libs\BIE6_IL2CPP\interop\UnityEngine.IMGUIModule.dll</HintPath>
66+
<Private>False</Private>
67+
</Reference>
68+
<Reference Include="UnityEngine.InputLegacyModule">
69+
<HintPath>..\_libs\BIE6_IL2CPP\interop\UnityEngine.InputLegacyModule.dll</HintPath>
70+
<Private>False</Private>
71+
</Reference>
72+
</ItemGroup>
12473

125-
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
126-
<Exec Command="xcopy &quot;$(OutputPath)$(AssemblyName).dll&quot; &quot;$(BepInExPluginsDir)$(AssemblyName)\&quot; /Y&#xD;&#xA;xcopy &quot;$(OutputPath)$(AssemblyName).pdb&quot; &quot;$(BepInExPluginsDir)$(AssemblyName)\&quot; /Y" />
127-
</Target>
74+
<!-- BIE6_Mono -->
75+
<ItemGroup Condition="'$(Configuration)'=='BIE6_Mono' or '$(Configuration)'=='Debug'">
76+
<Reference Include="0Harmony">
77+
<HintPath>..\_libs\BIE6_Mono\core\0Harmony.dll</HintPath>
78+
<Private>False</Private>
79+
</Reference>
80+
<Reference Include="Assembly-CSharp">
81+
<HintPath>..\_libs\BIE6_Mono\Managed\Assembly-CSharp.dll</HintPath>
82+
<Private>False</Private>
83+
</Reference>
84+
<Reference Include="BepInEx.Core">
85+
<HintPath>..\_libs\BIE6_Mono\core\BepInEx.Core.dll</HintPath>
86+
<Private>False</Private>
87+
</Reference>
88+
<Reference Include="BepInEx.Unity.Mono">
89+
<HintPath>..\_libs\BIE6_Mono\core\BepInEx.Unity.Mono.dll</HintPath>
90+
<Private>False</Private>
91+
</Reference>
92+
<Reference Include="Mono.Cecil">
93+
<HintPath>..\_libs\BIE6_Mono\core\Mono.Cecil.dll</HintPath>
94+
<Private>False</Private>
95+
</Reference>
96+
<Reference Include="UnityEngine">
97+
<HintPath>..\_libs\BIE6_Mono\Managed\UnityEngine.dll</HintPath>
98+
<Private>False</Private>
99+
</Reference>
100+
<Reference Include="UnityEngine.CoreModule">
101+
<HintPath>..\_libs\BIE6_Mono\Managed\UnityEngine.CoreModule.dll</HintPath>
102+
<Private>False</Private>
103+
</Reference>
104+
<Reference Include="UnityEngine.IMGUIModule">
105+
<HintPath>..\_libs\BIE6_Mono\Managed\UnityEngine.IMGUIModule.dll</HintPath>
106+
<Private>False</Private>
107+
</Reference>
108+
<Reference Include="UnityEngine.InputLegacyModule">
109+
<HintPath>..\_libs\BIE6_Mono\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
110+
<Private>False</Private>
111+
</Reference>
112+
</ItemGroup>
113+
114+
<Target Name="CopyOutput" AfterTargets="Build">
115+
<Copy SourceFiles="$(OutputPath)\$(AssemblyName).dll"
116+
DestinationFolder="$(BepInExPluginsPath)\$(AssemblyName)\" OverwriteReadOnlyFiles="true" />
117+
<Copy SourceFiles="$(OutputPath)\$(AssemblyName).pdb"
118+
DestinationFolder="$(BepInExPluginsPath)\$(AssemblyName)\" OverwriteReadOnlyFiles="true" />
119+
<Message Text="Copied output to: $(BepInExPluginsPath)\$(AssemblyName)\" Importance="high" />
120+
</Target>
128121
</Project>

BetterPayableUpgrade/version.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)