Skip to content

Commit efd9ca1

Browse files
Fix opponents count with custom tribes
1 parent 23f7c1f commit efd9ca1

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/ModLoader.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ public class PreviewTile
7474
public static Dictionary<string, AudioSource> audioClips = new();
7575
public static Dictionary<string, Mod> mods = new();
7676
public static Dictionary<int, int> climateToTribeData = new();
77-
public static Dictionary<string, List<PreviewTile>> tribePreviews = new();
78-
public static int climateAutoidx = (int)Enum.GetValues(typeof(TribeData.Type)).Cast<TribeData.Type>().Last();
79-
public static bool shouldInitializeSprites = true;
77+
private static List<TribeData.Type> customTribes = new();
78+
internal static Dictionary<string, List<PreviewTile>> tribePreviews = new();
79+
private static int climateAutoidx = (int)Enum.GetValues(typeof(TribeData.Type)).Cast<TribeData.Type>().Last();
80+
private static bool shouldInitializeSprites = true;
8081

8182

8283
[HarmonyPrefix]
@@ -100,6 +101,16 @@ private static void PurchaseManager_IsSkinUnlocked(ref bool __result, SkinType s
100101
__result = ((int)skinType >= Plugin.AUTOIDX_STARTS_FROM && (int)skinType != 2000) || __result;
101102
}
102103

104+
[HarmonyPostfix]
105+
[HarmonyPatch(typeof(PurchaseManager), nameof(PurchaseManager.GetUnlockedTribes))]
106+
private static void PurchaseManager_GetUnlockedTribes(
107+
ref Il2CppSystem.Collections.Generic.List<TribeData.Type> __result,
108+
bool forceUpdate = false
109+
)
110+
{
111+
foreach (var tribe in customTribes) __result.Add(tribe);
112+
}
113+
103114
[HarmonyPrefix]
104115
[HarmonyPatch(typeof(AudioManager), nameof(AudioManager.SetAmbienceClimate))]
105116
private static void AudioManager_SetAmbienceClimatePrefix(ref int climate)
@@ -419,6 +430,7 @@ private static void GameLogicDataPatch(JObject gld, JObject patch)
419430
{
420431
case "tribeData":
421432
EnumCache<TribeData.Type>.AddMapping(id, (TribeData.Type)autoidx);
433+
customTribes.Add((TribeData.Type)autoidx);
422434
climateToTribeData[climateAutoidx++] = autoidx;
423435
break;
424436
case "techData":

0 commit comments

Comments
 (0)