Skip to content

Commit

Permalink
Change minimap colour of additional cursed battles
Browse files Browse the repository at this point in the history
  • Loading branch information
Neoshrimp committed Sep 7, 2021
1 parent 99a9f49 commit 12e9440
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/More-cursed-battles/More-cursed-battles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\..\CAx64_libs\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ParticleSystemModule">
<HintPath>..\..\..\..\CAx64_libs\UnityEngine.ParticleSystemModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="SactuaryGolemAIPatch.cs" />
Expand Down
38 changes: 33 additions & 5 deletions src/More-cursed-battles/MoreCursedBattlesPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ static void StageStartPrefix()

}



// Fisher–Yates shuffle
private static void KnuthShuffle<T>(List<T> list)
{
Expand All @@ -90,6 +92,8 @@ private static void KnuthShuffle<T>(List<T> list)
}
}

static private List<MapTile> ogCursedTiles = new List<MapTile>();

[HarmonyPatch(typeof(StageSystem))]
class Generate_Cursed_Battles_Patch
{
Expand All @@ -107,7 +111,9 @@ static void InstantiateIsometric(HexMap ___Map)
List<MapTile> battleList =
___Map.EventTileList.FindAll(x => (x.Info.Type is Monster) ||
(x.TileEventObject != null && x.TileEventObject.ObjectData != null && x.TileEventObject.Monster));
int curseCount = battleList.FindAll(x => x.Info.Cursed == true).Count;

ogCursedTiles = battleList.FindAll(x => x.Info.Cursed == true);
int curseCount = ogCursedTiles.Count;

KnuthShuffle(battleList);
foreach (MapTile mt in battleList)
Expand All @@ -129,6 +135,8 @@ static void InstantiateIsometric(HexMap ___Map)
___Map.EventTileList.FindAll(x => (x.Info.Type is Monster) ||
(x.TileEventObject != null && x.TileEventObject.ObjectData != null && x.TileEventObject.Monster));

ogCursedTiles = battleList.FindAll(x => x.Info.Cursed == true);

List<MapTile> updatedBattleList = new List<MapTile>();
List<MapTile> chainList = new List<MapTile>();

Expand All @@ -153,6 +161,7 @@ static void InstantiateIsometric(HexMap ___Map)
}
}


int curseCount = updatedBattleList.FindAll(mt => mt.Info.Cursed).Count;
KnuthShuffle(updatedBattleList);

Expand Down Expand Up @@ -180,7 +189,26 @@ static void InstantiateIsometric(HexMap ___Map)
}
}


// changes emitted particle colour for additionally generated cursed battles
[HarmonyPatch(typeof(MiniHex), nameof(MiniHex.SightUpdate))]
class MiniHexPatch
{
static void Postfix(MiniHex __instance)
{
if (__instance.MyTile != null && __instance.Cursed != null)
{
if (!ogCursedTiles.Contains(__instance.MyTile))
{
ParticleSystem ps = __instance.Cursed.GetComponent<ParticleSystem>();
if (ps != null)
{
var main = ps.main;
main.startColor = new ParticleSystem.MinMaxGradient(new Color(216f / 255f, 43f / 255f, 200f / 255f), Color.black);
}
}
}
}
}



Expand Down Expand Up @@ -209,12 +237,12 @@ void addGold(int amount)
}
if (__instance.BChar.Info.KeyData == GDEItemKeys.Enemy_S4_Summoner || __instance.BChar.Info.KeyData == GDEItemKeys.Enemy_S4_SleepDochi
|| __instance.BChar.Info.KeyData == GDEItemKeys.Enemy_S4_Golem || __instance.BChar.Info.KeyData == GDEItemKeys.Enemy_S4_Golem2)
{
{
___Itemviews.Add(ItemBase.GetItem(PlayData.GetEquipRandom(3)));
}
if (__instance.BChar.Info.KeyData == GDEItemKeys.Enemy_S4_4thDochi || __instance.BChar.Info.KeyData == GDEItemKeys.Enemy_S4_MagicDochi
if (__instance.BChar.Info.KeyData == GDEItemKeys.Enemy_S4_4thDochi || __instance.BChar.Info.KeyData == GDEItemKeys.Enemy_S4_MagicDochi
|| __instance.BChar.Info.KeyData == GDEItemKeys.Enemy_S4_AngryDochi)
{
{
___Itemviews.AddRange(InventoryManager.RewardKey(GDEItemKeys.Reward_R_GetPotion, false, false));
}
}
Expand Down

0 comments on commit 12e9440

Please sign in to comment.