Skip to content

Commit

Permalink
try catch flags as well
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaPiggy committed Sep 22, 2024
1 parent 9b969a3 commit 80d7725
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions Winch/Util/BoatUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,18 +368,25 @@ public static void TakeFlag(string flagId)

public static void ChangeBoatFlag(string flagId)
{
WinchCore.Log.Debug($"ChangeBoatFlag({flagId})");
if (TryGetBoatFlagData(flagId, out BoatFlagData boatFlagData))
try
{
bool isVanilla = boatFlagData is VanillaBoatFlagData;
int flagIndex = boatFlagData is VanillaBoatFlagData vanilla ? vanilla.Index : -1;
GameManager.Instance.SaveData.BoatFlagStyle = flagIndex;
SaveUtil.ActiveSaveData.SetBoatFlagStyle(isVanilla ? string.Empty : flagId);
GameEvents.Instance.TriggerBoatFlagChanged(flagIndex);
DredgeEvent.TriggerBoatFlagChanged(flagId);
WinchCore.Log.Debug($"ChangeBoatFlag({flagId})");
if (TryGetBoatFlagData(flagId, out BoatFlagData boatFlagData))
{
bool isVanilla = boatFlagData is VanillaBoatFlagData;
int flagIndex = boatFlagData is VanillaBoatFlagData vanilla ? vanilla.Index : -1;
GameManager.Instance.SaveData.BoatFlagStyle = flagIndex;
SaveUtil.ActiveSaveData.SetBoatFlagStyle(isVanilla ? string.Empty : flagId);
GameEvents.Instance.TriggerBoatFlagChanged(flagIndex);
DredgeEvent.TriggerBoatFlagChanged(flagId);
}
else
WinchCore.Log.Error($"{flagId} is an invalid flag ID!");
}
catch (Exception ex)
{
WinchCore.Log.Error(ex);
}
else
WinchCore.Log.Error($"{flagId} is an invalid flag ID!");
}

public static void ChangeBoatColor(BoatArea area, string paintId)
Expand Down

0 comments on commit 80d7725

Please sign in to comment.