Skip to content

Commit

Permalink
More ways to grab stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaPiggy committed Sep 3, 2024
1 parent 760a240 commit 504a1e3
Show file tree
Hide file tree
Showing 8 changed files with 542 additions and 9 deletions.
1 change: 1 addition & 0 deletions Winch/Core/AssetLoaderObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private void OnGameEnded()
{
WinchCore.Log.Debug("[AssetLoaderObject] OnGameEnded()");
VibrationUtil.ClearVibrationDatas();
AbilityUtil.Clear();
PoiUtil.Clear();
HarvestZoneUtil.Clear();
CharacterUtil.ClearSpeakerData();
Expand Down
4 changes: 2 additions & 2 deletions Winch/Patches/API/DurableThawableItemDataPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public static bool FreshnessCoroutine_AdjustFreshnessForGrid_Prefix(Serializable
{
fishChange = proportionOfDayJustElapsed * GameManager.Instance.GameConfigData.FreshnessLossPerDay;
coolingChange = 0;
WinchCore.Log.Debug($"[FreshnessCoroutine] AdjustFreshnessForGrid({grid.GridConfiguration}, {proportionOfDayJustElapsed}) fishChange: {fishChange}");
//WinchCore.Log.Debug($"[FreshnessCoroutine] AdjustFreshnessForGrid({grid.GridConfiguration}, {proportionOfDayJustElapsed}) fishChange: {fishChange}");
}
else
{
Expand All @@ -280,7 +280,7 @@ public static bool FreshnessCoroutine_AdjustFreshnessForGrid_Prefix(Serializable
float actualVal = 1 - reductionVal;
coolingChange = proportionOfDayJustElapsed * actualVal;
fishChange = coolingChange * GameManager.Instance.GameConfigData.FreshnessLossPerDay;
WinchCore.Log.Debug($"[FreshnessCoroutine] AdjustFreshnessForGrid({grid.GridConfiguration}, {proportionOfDayJustElapsed}) cooledCells: {cooledCells} | propOfMaxReduction: {propOfMaxReduction} | reductionVal: {reductionVal} | actualVal: {actualVal} | coolingChange: {coolingChange} | fishChange: {fishChange}");
//WinchCore.Log.Debug($"[FreshnessCoroutine] AdjustFreshnessForGrid({grid.GridConfiguration}, {proportionOfDayJustElapsed}) cooledCells: {cooledCells} | propOfMaxReduction: {propOfMaxReduction} | reductionVal: {reductionVal} | actualVal: {actualVal} | coolingChange: {coolingChange} | fishChange: {fishChange}");
}
instances.ForEach(i => i.durability -= coolingChange);
instances.Where(WinchExtensions.IsBroken).ForEach(i => grid.RemoveObjectFromGridData(i, true));
Expand Down
30 changes: 30 additions & 0 deletions Winch/Util/AbilityUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,24 @@ internal static bool PopulateAbilityDataFromMetaWithConverter(ModdedAbilityData
return UtilHelpers.PopulateObjectFromMeta(abilityData, meta, Converter);
}

internal static Dictionary<string, AbilityData> AllAbilityDataDict = new();
internal static Dictionary<string, ModdedAbilityData> ModdedAbilityDataDict = new();
internal static Dictionary<string, ModdedAbility> ModdedAbilityDict = new();

public static AbilityData GetAbilityData(string id)
{
if (string.IsNullOrWhiteSpace(id))
return null;

if (AllAbilityDataDict.TryGetValue(id, out AbilityData abilityData))
return abilityData;

if (ModdedAbilityDataDict.TryGetValue(id, out ModdedAbilityData moddedAbilityData))
return moddedAbilityData;

return null;
}

public static ModdedAbilityData GetModdedAbilityData(string id)
{
if (string.IsNullOrWhiteSpace(id))
Expand Down Expand Up @@ -122,6 +137,16 @@ internal static void AddModdedAbilitiesToManager(IDictionary<string, AbilityData
modAbilityData.Populate();
abilityDatas.Add(modAbilityData.id, modAbilityData);
}
foreach (var abilityDataByKey in abilityDatas)
{
AllAbilityDataDict.Add(abilityDataByKey.Key, abilityDataByKey.Value);
WinchCore.Log.Debug($"Added ability {abilityDataByKey.Key} to AllAbilityDataDict");
}
}

internal static void Clear()
{
AllAbilityDataDict.Clear();
}

internal static void AddModdedAbilitiesToRadial(GameObject buttonCenter, Transform abiltiesParent, List<AbilityRadialWedge> wedges, Sprite lockedSprite)
Expand All @@ -145,4 +170,9 @@ internal static void AddModdedAbilitiesToRadial(GameObject buttonCenter, Transfo
abilityRadialWedge.attentionCallout = attentionCalloutPrefab.Instantiate(abilityRadialWedgeObj.transform, false);
}
}

public static AbilityData[] GetAllAbilityData()
{
return AllAbilityDataDict.Values.ToArray();
}
}
33 changes: 33 additions & 0 deletions Winch/Util/CharacterUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Winch.Components;
using Winch.Core;
using Winch.Data.Character;
using Winch.Data.GridConfig;
using Winch.Serialization;
using Winch.Serialization.Character;

Expand All @@ -28,6 +29,20 @@ internal static bool PopulateSpeakerDataFromMetaWithConverter(AdvancedSpeakerDat
internal static Dictionary<string, AdvancedSpeakerData> ModdedSpeakerDataDict = new();
internal static Dictionary<string, SpeakerData> AllSpeakerDataDict = new();

public static SpeakerData GetSpeakerData(string id)
{
if (string.IsNullOrWhiteSpace(id))
return null;

if (AllSpeakerDataDict.TryGetValue(id, out var speakerData) || AllSpeakerDataDict.Values.TryGetValue(s => s.name == id, out speakerData))
return speakerData;

if (ModdedSpeakerDataDict.TryGetValue(id, out AdvancedSpeakerData advancedSpeakerData))
return advancedSpeakerData;

return null;
}

public static AdvancedSpeakerData GetModdedSpeakerData(string id)
{
if (string.IsNullOrWhiteSpace(id))
Expand Down Expand Up @@ -100,6 +115,24 @@ internal static void AddCharacterFromMeta(string metaPath)
}
}

internal static List<SpeakerData> TryGetSpeakers(List<string> ids)
{
List<SpeakerData> speakers = new List<SpeakerData>();

if (ids == null)
return speakers;

foreach (var speaker in ids)
{
if (!string.IsNullOrWhiteSpace(speaker) && (AllSpeakerDataDict.TryGetValue(speaker, out var speakerData) || AllSpeakerDataDict.Values.TryGetValue(s => s.name == speaker, out speakerData)))
{
speakers.Add(speakerData);
}
}

return speakers;
}

public static SpeakerData[] GetAllSpeakerData()
{
return AllSpeakerDataDict.Values.ToArray();
Expand Down
16 changes: 15 additions & 1 deletion Winch/Util/GridConfigUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,21 @@ internal static void Initialize()
internal static Dictionary<string, DeferredGridConfiguration> ModdedGridConfigDict = new();
internal static Dictionary<string, GridConfiguration> AllGridConfigDict = new();

public static GridConfiguration GetModdedGridConfiguration(string id)
public static GridConfiguration GetGridConfiguration(string id)
{
if (string.IsNullOrWhiteSpace(id))
return null;

if (AllGridConfigDict.TryGetValue(id, out GridConfiguration gridConfig))
return gridConfig;

if (ModdedGridConfigDict.TryGetValue(id, out DeferredGridConfiguration deferredGridConfig))
return deferredGridConfig;

return null;
}

public static DeferredGridConfiguration GetModdedGridConfiguration(string id)
{
if (string.IsNullOrWhiteSpace(id))
return null;
Expand Down
Loading

0 comments on commit 504a1e3

Please sign in to comment.