Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Add and update extra variables for autosplitter
Browse files Browse the repository at this point in the history
  • Loading branch information
paperman5 committed Feb 11, 2024
1 parent 655ba1c commit 38a61c1
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 20 deletions.
1 change: 1 addition & 0 deletions BiomeManagerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public static bool UpdateOverallPollution_Prefix(BiomeManager __instance, bool s
float weightedPlasticPollution = (__instance.maxPlasticCloudPollution > 0f) ? (__instance.currentPlasticCloudPollution / __instance.maxPlasticCloudPollution * __instance.plasticCloudContributionToBiomePollution) : 0f;
__instance.biomePollution = weightedGoopPollution + __instance.weightedLitterPollution + weightedPlasticPollution;
__instance.biomePollution = BloopTools.SnapToZero(__instance.biomePollution, 1E-06f);
ExtraTrackersMod.nonBiomeIsComplete = __instance.biomePollution < 1E-06f;
if (skipEffects)
{
__instance.externalPollutionUpdateQueued = true;
Expand Down
2 changes: 1 addition & 1 deletion ExtraTrackers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net471</TargetFramework>
<AssemblyName>ExtraTrackers</AssemblyName>
<Description>Loddlenaut mod for tracking more stuff</Description>
<Version>1.1.1</Version>
<Version>1.1.2</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down
46 changes: 29 additions & 17 deletions ExtraTrackersMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using HarmonyLib.Tools;
using I2.Loc;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
Expand All @@ -22,6 +23,12 @@ public static class ExtraTrackersMod

public static BiomeManager nonBiomeManager;

// For autosplitter tracking
public static bool nonBiomeIsComplete = false;
public static bool allHoloBadgesFound = false;
public static bool allLoddleTypesFound = false;
public static bool allGoopyLoddlesCleaned = false;

public static Dictionary<LoddleAI.LoddleType, string> typeRemarkMapping = new Dictionary<LoddleAI.LoddleType, string>()
{
{ LoddleAI.LoddleType.Eel, GoogleSheetsEntryNames.SirenEvoIntro },
Expand Down Expand Up @@ -162,6 +169,10 @@ public static float GetGlobalPollutionAmount()
return BloopTools.SnapToZero(totalPollution, 1E-06f);
}

public static void GetGoopyLoddlesCount(GameEvent e)
{
allGoopyLoddlesCleaned = GetGoopyLoddlesCount() == 0;
}
public static int GetGoopyLoddlesCount()
{
int goopyLoddles = 0;
Expand All @@ -173,22 +184,23 @@ public static int GetGoopyLoddlesCount()
return goopyLoddles;
}

//[HarmonyPatch(typeof(GameManager), nameof(GameManager.Update))]
//[HarmonyPostfix]
//public static void Update_Postfix()
//{
// if (Input.GetKeyDown(KeyCode.F3))
// {
// foreach (int bi in biomePollution.Keys)
// {
// BiomeManager bm;
// bm = bi != -1 ? EngineHub.BiomeSaver.LookUpBiomeByID(bi) : nonBiomeManager;
// log.LogInfo(bm.biomeDisplayName);
// log.LogInfo($"goop: {biomePollution[bi]["goopPollution"]}");
// log.LogInfo($"plastic: {biomePollution[bi]["plasticCloudPollution"]}");
// log.LogInfo($"litter: {biomePollution[bi]["litterPollution"]}");
// }
// }
//}
public static void OnHoloBadgeCollected(GameEvent e)
{
allHoloBadgesFound = ((HoloBadgeCollected)e).allHaveBeenCollected;
}

public static void OnLoddleMetPlayer(GameEvent e)
{
EngineHub.GameProgressTracker.StartCoroutine(ExtraTrackersMod.UpdateAllLoddleTypesFound());
}

public static IEnumerator UpdateAllLoddleTypesFound()
{
for (int i = 0; i < 2; i++)
{
yield return new WaitForEndOfFrame();
}
allLoddleTypesFound = GetEncounteredLoddleTypes().Count == typeRemarkMapping.Count;
}
}
}
2 changes: 1 addition & 1 deletion ExtraTrackersPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ExtraTrackersPlugin : BaseUnityPlugin
{
public const string myGUID = "com.paperish.extratrackers";
public const string pluginName = "Extra Trackers";
public const string versionString = "1.1.1";
public const string versionString = "1.1.2";

private static readonly Harmony harmony = new Harmony(myGUID);
private void Awake()
Expand Down
9 changes: 9 additions & 0 deletions GameProgressTrackerPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,14 @@ public static bool HandleBiomePollutionShift_Prefix(GameEvent e)
}
return true;
}

[HarmonyPatch(nameof(GameProgressTracker.RegisterForEvents))]
[HarmonyPostfix]
public static void RegisterForEvents_Postfix(GameProgressTracker __instance)
{
EngineHub.EventManager.Register<LoddleGotClean>(new GameEvent.Handler(ExtraTrackersMod.GetGoopyLoddlesCount));
EngineHub.EventManager.Register<HoloBadgeCollected>(new GameEvent.Handler(ExtraTrackersMod.OnHoloBadgeCollected));
EngineHub.EventManager.Register<LoddleMetPlayer>(new GameEvent.Handler(ExtraTrackersMod.OnLoddleMetPlayer));
}
}
}
7 changes: 6 additions & 1 deletion MenuPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ public static void MainMenuStart_Postfix(MainMenu __instance)
string version = versionLabel.text;
versionLabel.text = $"{version}\n{ExtraTrackersPlugin.pluginName} v{ExtraTrackersPlugin.versionString}";
versionLabel.alignment = TextAlignmentOptions.BottomRight;
}

ExtraTrackersMod.nonBiomeIsComplete = false;
ExtraTrackersMod.allHoloBadgesFound = false;
ExtraTrackersMod.allLoddleTypesFound = false;
ExtraTrackersMod.allGoopyLoddlesCleaned = false;
}
}
}

0 comments on commit 38a61c1

Please sign in to comment.