using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using PotionCraft.Assemblies.GamepadNavigation;
using PotionCraft.Core;
using PotionCraft.Core.Cursor;
using PotionCraft.Core.Extensions;
using PotionCraft.ManagersSystem;
using PotionCraft.ManagersSystem.RecipeMap;
using PotionCraft.ManagersSystem.Room;
using PotionCraft.ManagersSystem.SaveLoad;
using PotionCraft.ObjectBased.InteractiveItem;
using PotionCraft.ObjectBased.Potion;
using PotionCraft.ObjectBased.RecipeMap;
using PotionCraft.ObjectBased.RecipeMap.Buttons;
using PotionCraft.ObjectBased.RecipeMap.Path;
using PotionCraft.ObjectBased.RecipeMap.RecipeMapItem;
using PotionCraft.ObjectBased.RecipeMap.RecipeMapItem.PathMapItem;
using PotionCraft.ObjectBased.RecipeMap.RecipeMapItem.PotionEffectMapItem;
using PotionCraft.ObjectBased.UIElements;
using PotionCraft.ObjectBased.UIElements.Bookmarks;
using PotionCraft.ObjectBased.UIElements.Books;
using PotionCraft.ObjectBased.UIElements.Books.RecipeBook;
using PotionCraft.ObjectBased.UIElements.Tooltip;
using PotionCraft.SaveFileSystem;
using PotionCraft.SaveLoadSystem;
using PotionCraft.ScriptableObjects;
using PotionCraft.ScriptableObjects.Potion;
using PotionCraft.Settings;
using PotionCraftRecipeWaypoints.Scripts.Services;
using PotionCraftRecipeWaypoints.Scripts.Storage;
using PotionCraftRecipeWaypoints.Scripts.UIComponents;
using RecipeMapItem.RecipeMapItemsUpdater;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PotionCraftRecipeWaypoints")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Recipe Waypoint Mod for Potion Craft")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PotionCraftRecipeWaypoints")]
[assembly: AssemblyTitle("PotionCraftRecipeWaypoints")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace PotionCraftRecipeWaypoints
{
[BepInPlugin("com.fahlgorithm.potioncraftrecipewaypoints", "PotionCraftRecipeWaypoints", "1.1.0.0")]
[BepInProcess("Potion Craft.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.fahlgorithm.potioncraftrecipewaypoints";
public static ManualLogSource PluginLogger { get; private set; }
private void Awake()
{
PluginLogger = ((BaseUnityPlugin)this).Logger;
PluginLogger.LogInfo((object)"Plugin com.fahlgorithm.potioncraftrecipewaypoints is loaded!");
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.fahlgorithm.potioncraftrecipewaypoints");
PluginLogger.LogInfo((object)"Plugin com.fahlgorithm.potioncraftrecipewaypoints: Patch Succeeded!");
StaticStorage.BrewFromHereInstalled = Chainloader.PluginInfos.Any((KeyValuePair<string, PluginInfo> plugin) => plugin.Value.Metadata.GUID.Equals("com.fahlgorithm.potioncraftbrewfromhere"));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "PotionCraftRecipeWaypoints";
public const string PLUGIN_NAME = "PotionCraftRecipeWaypoints";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace PotionCraftRecipeWaypoints.Scripts
{
public static class Ex
{
public static bool RunSafe(Func<bool> action, Func<bool> errorAction = null)
{
try
{
return action();
}
catch (Exception ex)
{
LogException(ex);
}
return errorAction?.Invoke() ?? true;
}
public static void RunSafe(Action action, Action errorAction = null)
{
try
{
action();
}
catch (Exception ex)
{
LogException(ex);
errorAction?.Invoke();
}
}
public static void LogException(Exception ex)
{
string text = $"{ex.GetType()}: {ex.Message}\r\n{ex.StackTrace}\r\n{ex.InnerException?.Message}";
Plugin.PluginLogger.LogError((object)text);
}
}
[HarmonyPatch(typeof(MapState), "LoadState")]
public class LoadWaypointsPatch
{
private static void Postfix()
{
Ex.RunSafe(delegate
{
SaveLoadService.LoadWaypoints();
});
}
}
[HarmonyPatch(typeof(RecipeBook), "OnLoad")]
public class LoadWaypointsOnRecipeLoadPatch
{
private static void Postfix()
{
Ex.RunSafe(delegate
{
RecipeService.LoadWaypointsForRecipeLoad();
});
}
}
[HarmonyPatch(typeof(RecipeBook), "EraseRecipe")]
public class DeleteWaypointOnRecipeDeletePatch
{
private static bool Prefix(Potion potion)
{
return Ex.RunSafe(() => RecipeService.RecipeDeletedFromBook(potion));
}
}
[HarmonyPatch(typeof(RecipeBookBrewPotionButton), "UpdateVisual")]
public class ModifyBrewPotionButtonForWaypointRecipesPatch
{
private static void Postfix(RecipeBookBrewPotionButton __instance, RecipeBookRightPageContent ___rightPageContent)
{
Ex.RunSafe(delegate
{
UIService.ModifyBrewPotionButtonForWaypointRecipes(__instance, ___rightPageContent);
});
}
}
[HarmonyPatch(typeof(RecipeBookBrewPotionButton), "BrewPotion")]
public class ViewWaypointOnMapPatch
{
private static bool Prefix(RecipeBookRightPageContent ___rightPageContent)
{
return Ex.RunSafe(() => UIService.ViewWaypointOnMap(___rightPageContent), () => OnError(___rightPageContent));
}
private static bool OnError(RecipeBookRightPageContent rightPageContent)
{
try
{
if ((Object)(object)rightPageContent.pageContentPotion == (Object)null)
{
return true;
}
if (!RecipeService.IsWaypointRecipe(rightPageContent.pageContentPotion))
{
return true;
}
return false;
}
catch (Exception ex)
{
Ex.LogException(ex);
}
return true;
}
}
[HarmonyPatch(typeof(Slot), "SaveSettingsFromChild")]
public class FixButtonInitializationExceptionPatch
{
private static bool Prefix(Slot __instance)
{
return Ex.RunSafe(() => UIService.FixButtonInitializationException(__instance));
}
}
[HarmonyPatch(typeof(TooltipContentProvider), "GetTooltipContent")]
public class RemoveBrewPotionTooltipForWaypointRecipePatch
{
private static void Postfix(ref TooltipContent __result, InteractiveItem ___interactiveItem)
{
try
{
RecipeBookBrewPotionButton val = (RecipeBookBrewPotionButton)(object)((___interactiveItem is RecipeBookBrewPotionButton) ? ___interactiveItem : null);
if (val != null && RecipeService.IsWaypointRecipe(((RecipeBookRightPageContent)/*isinst with value type is only supported in some contexts*/).pageContentPotion))
{
__result = null;
}
}
catch (Exception ex)
{
Ex.LogException(ex);
}
}
}
[HarmonyPatch(typeof(SavedState), "ToJson")]
public class InjectSavedRecipesPatch
{
private static void Postfix(ref string __result)
{
SaveLoadService.StoreIgnoredWaypoints(ref __result);
}
}
[HarmonyPatch(typeof(File), "Load")]
public class RetrieveStateJsonStringPatch
{
private static bool Prefix(File __instance)
{
return Ex.RunSafe(() => SaveLoadService.RetrieveStateJsonString(__instance));
}
}
[HarmonyPatch(typeof(SaveLoadManager), "LoadSelectedState")]
public class RetreiveSavedAlchemyMachineRecipesFromSavedStatePatch
{
private static bool Prefix(Type type)
{
return Ex.RunSafe(() => SaveLoadService.RetreiveStoredIgnoredWaypoints(type));
}
}
[HarmonyPatch(typeof(SaveLoadManager), "LoadFile")]
public class ClearFileSpecificDataOnFileLoadPatch
{
private static bool Prefix()
{
return Ex.RunSafe(() => SaveLoadService.ClearFileSpecificDataOnFileLoad());
}
}
public class RecipeIndex
{
public Potion Recipe;
public int Index;
public bool IsWaypoint => !StaticStorage.IgnoredWaypoints.Contains(Index);
}
}
namespace PotionCraftRecipeWaypoints.Scripts.UIComponents
{
public class WaypointMapItem : RecipeMapItem, IPrimaryCursorEventsHandler, ICustomCursorStateOnUse, ICustomCursorStateOnHover, IHoverable
{
public const float WaypointAlpha = 0.75f;
public RecipeIndex Recipe;
public SpriteRenderer IconRenderer;
public CircleCollider2D circleCollider;
public GameObject path;
public bool IsTailEndWaypoint;
private bool loadedPath;
public void OnPrimaryCursorClick()
{
RecipeService.OpenPageOnWaypointClick(this);
}
public bool OnPrimaryCursorRelease()
{
return true;
}
public override TooltipContent GetTooltipContent()
{
return ((InventoryItem)Recipe.Recipe).GetTooltipContent(1, (ItemsPanel)null, false);
}
public CursorVisualState CursorStateOnUse()
{
return (CursorVisualState)2;
}
public CursorVisualState CursorStateOnHover()
{
return (CursorVisualState)2;
}
public void SetHovered(bool hovered)
{
if (hovered && !loadedPath)
{
UIService.CreateWaypointHoverPath(this);
loadedPath = true;
}
path.SetActive(hovered);
if (IsTailEndWaypoint)
{
((Renderer)IconRenderer).enabled = !hovered;
}
}
}
public class WaypointToggleButton : InteractiveItem, IPrimaryCursorEventsHandler, ICustomCursorStateOnUse, ICustomCursorStateOnHover, IHoverable
{
public SpriteRenderer iconRenderer;
public BoxCollider2D collider;
public GameObject spriteSlot;
public FollowIndicatorButton followButton;
public RecipeIndex currentRecipe => RecipeService.GetWaypointRecipeAtIndex(((Book)Managers.Potion.recipeBook).currentPageIndex);
public bool IsMapWaypointToggleButton => (Object)(object)followButton != (Object)null;
public float OffAlpha => 0.5f;
public void OnPrimaryCursorClick()
{
if (IsMapWaypointToggleButton)
{
UIService.ShowHideWaypoints();
}
else
{
RecipeService.ToggleWaypointForSelectedRecipe(currentRecipe);
}
}
public bool OnPrimaryCursorRelease()
{
return true;
}
public override TooltipContent GetTooltipContent()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
if (!IsMapWaypointToggleButton)
{
RecipeIndex recipeIndex = currentRecipe;
if (recipeIndex != null)
{
bool flag = recipeIndex.Recipe.Effects.Length != 0 && (ComparableScriptableObject<PotionEffect>)(object)recipeIndex.Recipe.Effects[0] != (ComparableScriptableObject<PotionEffect>)null;
string header = ((!recipeIndex.IsWaypoint) ? (flag ? "Mark this recipe as a waypoint" : "Show this waypoint on the map") : (flag ? "Unmark this recipe as a waypoint" : "Hide this waypoint on the map"));
return new TooltipContent
{
header = header
};
}
return new TooltipContent();
}
return new TooltipContent
{
header = "Show or Hide Waypoints"
};
}
public CursorVisualState CursorStateOnUse()
{
return (CursorVisualState)2;
}
public CursorVisualState CursorStateOnHover()
{
return (CursorVisualState)2;
}
public void SetHovered(bool hovered)
{
FollowIndicatorButton obj = followButton;
if (obj != null)
{
((Button)obj).SetHovered(hovered);
}
}
}
}
namespace PotionCraftRecipeWaypoints.Scripts.Storage
{
public static class StaticStorage
{
public const string RecipeWaypointsJsonSaveName = "FahlgorithmRecipeWaypoints";
public static List<WaypointMapItem> Waypoints = new List<WaypointMapItem>();
public static List<int> IgnoredWaypoints = new List<int>();
public static WaypointMapItem TemporaryWaypoint;
public static WaypointToggleButton WaypointToggleButton;
public static Dictionary<RecipeBookRightPageContent, WaypointToggleButton> WaypointToggleButtonRecipeBook = new Dictionary<RecipeBookRightPageContent, WaypointToggleButton>();
public static Dictionary<RecipeBookRightPageContent, RecipeBookBrewPotionButton> WaypointBrewPotionButton = new Dictionary<RecipeBookRightPageContent, RecipeBookBrewPotionButton>();
public static List<PotionBase> LoadedPotionBases = new List<PotionBase>();
public static bool RecipesLoaded;
public static Sprite RecipeWaypointSprite;
public static bool WaypointsVisible;
public static bool AddedListeners;
public static string StateJsonString;
public static bool BrewFromHereInstalled;
}
}
namespace PotionCraftRecipeWaypoints.Scripts.Services
{
public static class RecipeService
{
[CompilerGenerated]
private static class <>O
{
public static UnityAction <0>__RecipeAdded;
public static UnityAction<BookmarkController, List<int>> <1>__BookmarksRearranged;
}
public static void LoadWaypointsForRecipeLoad()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
StaticStorage.RecipesLoaded = true;
if (!StaticStorage.AddedListeners)
{
UnityEvent onRecipeAdded = Managers.Potion.recipeBook.onRecipeAdded;
object obj = <>O.<0>__RecipeAdded;
if (obj == null)
{
UnityAction val = RecipeAdded;
<>O.<0>__RecipeAdded = val;
obj = (object)val;
}
onRecipeAdded.AddListener((UnityAction)obj);
((UnityEvent<BookmarkController, List<int>>)(object)((Book)Managers.Potion.recipeBook).bookmarkControllersGroupController.onBookmarksRearranged).AddListener((UnityAction<BookmarkController, List<int>>)BookmarksRearranged);
StaticStorage.AddedListeners = true;
}
SaveLoadService.LoadWaypoints();
}
public static void OpenPageOnWaypointClick(WaypointMapItem waypoint)
{
if (StaticStorage.BrewFromHereInstalled && (Object)(object)waypoint != (Object)(object)StaticStorage.TemporaryWaypoint)
{
((UnityEvent<int, int>)(object)((Book)Managers.Potion.recipeBook).onPageChanged).Invoke(((Book)Managers.Potion.recipeBook).currentPageIndex, waypoint.Recipe.Index);
}
((Book)Managers.Potion.recipeBook).OpenPageAt(waypoint.Recipe.Index);
}
public static Vector2 GetMapPositionForRecipe(RecipeIndex recipe)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return GetMapPositionForRecipe(recipe.Recipe);
}
public static bool IsTailEndWaypoint(Potion recipe)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
return GetMapPositionForRecipe(recipe, forceReturnIndicatorPosition: true) != GetMapPositionForRecipe(recipe);
}
public static bool RecipeDeletedFromBook(Potion recipe)
{
int item = Managers.Potion.recipeBook.savedRecipes.IndexOf(recipe);
if (StaticStorage.IgnoredWaypoints.Contains(item))
{
StaticStorage.IgnoredWaypoints.Remove(item);
return true;
}
RemoveWaypoint(recipe);
return true;
}
public static Vector2 GetMapPositionForRecipe(Potion recipe, bool forceReturnIndicatorPosition = false)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = recipe.potionFromPanel.serializedPath.indicatorTargetPosition;
if (forceReturnIndicatorPosition)
{
return val;
}
float waypointExclusionZone = GetWaypointExclusionZone();
if (Vector2.Distance(Vector2.zero, val) < waypointExclusionZone || HasLongRemainingPath(recipe))
{
val = GetTailEndMapPositionForRecipe(recipe);
}
return val;
}
public static Vector2 GetTailEndMapPositionForRecipe(Potion recipe)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = (Vector3)(((??)((IEnumerable<SerializedPathPoints>)recipe.potionFromPanel.serializedPath.fixedPathPoints).LastOrDefault((Func<SerializedPathPoints, bool>)((SerializedPathPoints fpp) => fpp.graphicsPoints?.Any() ?? false))?.graphicsPoints?.LastOrDefault()) ?? Vector2.op_Implicit(Vector2.zero));
Vector2 val2 = recipe.potionFromPanel.serializedPath.indicatorTargetPosition + recipe.potionFromPanel.serializedPath.pathPosition;
return new Vector2(val.x, val.y) + val2;
}
public static List<RecipeIndex> GetWaypointRecipes(PotionBase loadedPotionBase)
{
List<Potion> savedRecipes = Managers.Potion.recipeBook.savedRecipes;
List<RecipeIndex> list = new List<RecipeIndex>();
for (int i = 0; i < savedRecipes.Count; i++)
{
Potion val = savedRecipes[i];
if (!((Object)(object)val == (Object)null) && !(((Object)val.potionBase).name != ((Object)loadedPotionBase).name) && IsWaypointRecipe(val))
{
list.Add(new RecipeIndex
{
Index = i,
Recipe = val
});
}
}
return list;
}
public static void RemoveWaypoint(Potion recipe)
{
WaypointMapItem waypointMapItem = StaticStorage.Waypoints.FirstOrDefault((WaypointMapItem w) => (Object)(object)w.Recipe.Recipe == (Object)(object)recipe);
if (!((Object)(object)waypointMapItem == (Object)null))
{
UIService.AddMissingWaypointsAroundDeletedWaypoint(waypointMapItem);
UIService.DeleteWaypoint(waypointMapItem);
}
}
public static void RecipeAdded()
{
Ex.RunSafe(delegate
{
List<int> existingWaypointIndexes = StaticStorage.Waypoints.Select((WaypointMapItem w) => w.Recipe.Index).ToList();
RecipeIndex recipeIndex = GetWaypointRecipes(UIService.GetCurrentPotionBase()).FirstOrDefault((RecipeIndex p) => !existingWaypointIndexes.Contains(p.Index));
if (recipeIndex != null)
{
UIService.AddWaypointToMap(recipeIndex);
}
});
}
private static void BookmarksRearranged(BookmarkController bookmarksController, List<int> intList)
{
Ex.RunSafe(delegate
{
List<int> list = StaticStorage.IgnoredWaypoints.ToList();
List<int> list2 = new List<int>();
var source = StaticStorage.Waypoints.Select((WaypointMapItem w) => new
{
waypoint = w,
oldIndex = w.Recipe.Index
}).ToList();
for (int i = 0; i < intList.Count; i++)
{
int oldIndex = intList[i];
if (list.Contains(oldIndex))
{
list2.Add(i);
}
if (intList[i] != i)
{
var anon = source.FirstOrDefault(w => w.oldIndex == oldIndex);
if (anon != null)
{
anon.waypoint.Recipe.Index = i;
}
}
}
StaticStorage.IgnoredWaypoints = list2;
});
}
public static bool IsWaypointRecipe(Potion recipe, bool returnIgnored = false)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)recipe == (Object)null)
{
return false;
}
if (!returnIgnored && StaticStorage.IgnoredWaypoints.Contains(Managers.Potion.recipeBook.savedRecipes.IndexOf(recipe)))
{
return false;
}
if (IsLegendaryRecipe(recipe))
{
return false;
}
Vector2 mapPositionForRecipe = GetMapPositionForRecipe(recipe, forceReturnIndicatorPosition: true);
float waypointExclusionZone = GetWaypointExclusionZone();
if (Vector2.Distance(Vector2.zero, mapPositionForRecipe) < waypointExclusionZone)
{
return Vector2.Distance(Vector2.zero, GetTailEndMapPositionForRecipe(recipe)) > waypointExclusionZone;
}
if (recipe.Effects.Length == 0 || (ComparableScriptableObject<PotionEffect>)(object)recipe.Effects[0] == (ComparableScriptableObject<PotionEffect>)null)
{
return true;
}
if (Vector2.Distance(mapPositionForRecipe, UIService.GetEffectMapLocation(recipe.Effects.Last(), recipe.potionBase)) >= waypointExclusionZone)
{
return true;
}
if (HasLongRemainingPath(recipe))
{
return true;
}
return false;
}
private static bool HasLongRemainingPath(Potion recipe)
{
return recipe.potionFromPanel.serializedPath.fixedPathPoints.Count > 1;
}
public static float GetWaypointExclusionZone()
{
return UIService.GetIndicatorDiameter() * 5f;
}
public static RecipeIndex GetWaypointRecipeAtIndex(int index)
{
Potion recipe = Managers.Potion.recipeBook.savedRecipes[index];
if (!IsWaypointRecipe(recipe, returnIgnored: true))
{
return null;
}
return new RecipeIndex
{
Index = index,
Recipe = recipe
};
}
public static void ToggleWaypointForSelectedRecipe(RecipeIndex recipe)
{
if (recipe != null)
{
if (StaticStorage.IgnoredWaypoints.Contains(recipe.Index))
{
StaticStorage.IgnoredWaypoints.Remove(recipe.Index);
RecipeAdded();
}
else
{
StaticStorage.IgnoredWaypoints.Add(recipe.Index);
RemoveWaypoint(recipe.Recipe);
}
UIService.UpdateCurrentRecipePage();
}
}
public static bool IsLegendaryRecipe(Potion recipe)
{
return recipe.potionFromPanel.recipeMarks.Count((SerializedRecipeMark m) => (int)m.type == 0) > 1;
}
public static RecipeIndex GetRecipeIndexObject(Potion recipe)
{
return new RecipeIndex
{
Recipe = recipe,
Index = Managers.Potion.recipeBook.savedRecipes.IndexOf(recipe)
};
}
}
public static class SaveLoadService
{
private class IgnoredWaypointsDeserialized
{
[JsonProperty("FahlgorithmRecipeWaypoints")]
public List<int> IgnoredWaypoints { get; set; }
}
public static void StoreIgnoredWaypoints(ref string result)
{
string modifiedResult = null;
string savedStateJson = result;
Ex.RunSafe(delegate
{
if (StaticStorage.IgnoredWaypoints.Any())
{
StringBuilder sbIgnoredWaypoints = new StringBuilder();
sbIgnoredWaypoints.Append('[');
bool firstRecipe = true;
StaticStorage.IgnoredWaypoints.ForEach(delegate(int index)
{
if (!firstRecipe)
{
sbIgnoredWaypoints.Append(',');
}
firstRecipe = false;
sbIgnoredWaypoints.Append(index);
});
sbIgnoredWaypoints.Append(']');
string value = string.Format(",\"{0}\":{1}", "FahlgorithmRecipeWaypoints", sbIgnoredWaypoints);
int startIndex = savedStateJson.LastIndexOf('}');
modifiedResult = savedStateJson.Insert(startIndex, value);
}
});
if (!string.IsNullOrEmpty(modifiedResult))
{
result = modifiedResult;
}
}
public static bool RetreiveStoredIgnoredWaypoints(Type type)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
if (type != typeof(ProgressState))
{
return true;
}
string stateJsonString = StaticStorage.StateJsonString;
StaticStorage.StateJsonString = null;
if (string.IsNullOrEmpty(stateJsonString))
{
Plugin.PluginLogger.LogInfo((object)"Error: stateJsonString is empty. Cannot load ignored waypoints");
return true;
}
if (stateJsonString.IndexOf("FahlgorithmRecipeWaypoints") == -1)
{
Plugin.PluginLogger.LogInfo((object)"No existing ignored recipes found during load");
return true;
}
IgnoredWaypointsDeserialized ignoredWaypointsDeserialized = JsonConvert.DeserializeObject<IgnoredWaypointsDeserialized>(stateJsonString, new JsonSerializerSettings
{
ReferenceLoopHandling = (ReferenceLoopHandling)1
});
if (ignoredWaypointsDeserialized.IgnoredWaypoints == null)
{
Plugin.PluginLogger.LogError((object)"Error: An error occured during ignored recipie deserialization");
return true;
}
StaticStorage.IgnoredWaypoints = ignoredWaypointsDeserialized.IgnoredWaypoints;
return true;
}
public static bool RetrieveStateJsonString(File instance)
{
StaticStorage.StateJsonString = instance.StateJsonString;
return true;
}
public static bool ClearFileSpecificDataOnFileLoad()
{
StaticStorage.Waypoints.ForEach(delegate(WaypointMapItem waypoint)
{
Object.Destroy((Object)(object)((Component)waypoint).gameObject);
});
StaticStorage.LoadedPotionBases.Clear();
StaticStorage.Waypoints.Clear();
StaticStorage.IgnoredWaypoints.Clear();
StaticStorage.RecipesLoaded = false;
return true;
}
public static void LoadWaypoints()
{
if (StaticStorage.RecipesLoaded)
{
if (StaticStorage.LoadedPotionBases == null)
{
StaticStorage.LoadedPotionBases = new List<PotionBase>();
}
PotionBase loadedPotionBase = UIService.GetCurrentPotionBase();
if ((ComparableScriptableObject<SerializablePanelElement>)(object)loadedPotionBase == (ComparableScriptableObject<SerializablePanelElement>)null)
{
Plugin.PluginLogger.LogInfo((object)"Error: failed to get current potion base");
return;
}
if (StaticStorage.LoadedPotionBases.Any((PotionBase b) => ((Object)b).name == ((Object)loadedPotionBase).name))
{
Plugin.PluginLogger.LogInfo((object)"Error: already loaded potion base");
return;
}
StaticStorage.LoadedPotionBases.Add(loadedPotionBase);
UIService.AddWaypointsToMap(RecipeService.GetWaypointRecipes(loadedPotionBase));
UIService.CreateWaypointToggleButton(Managers.RecipeMap.recipeMapObject.followIndicatorButton);
}
}
private static int GetEndJsonIndex(string input, int startIndex, bool useBrackets)
{
int num = startIndex + 1;
int num2 = 1;
char value = (useBrackets ? '[' : '{');
char value2 = (useBrackets ? ']' : '}');
while (num2 > 0 && num < input.Length - 1)
{
int num3 = input.IndexOf(value, num);
int num4 = input.IndexOf(value2, num);
if (num3 == -1 && num4 == -1)
{
break;
}
if (num3 == -1)
{
num3 = int.MaxValue;
}
if (num4 == -1)
{
num4 = int.MaxValue;
}
if (num3 < num4)
{
num = num3 + 1;
num2++;
}
else if (num4 < num3)
{
num = num4 + 1;
num2--;
}
}
return num;
}
}
public static class UIService
{
private const float WaypointProximityExclusionZone = 1f;
public static void AddWaypointsToMap(List<RecipeIndex> waypointRecipes)
{
StaticStorage.Waypoints = new List<WaypointMapItem>();
waypointRecipes.ForEach(delegate(RecipeIndex recipe)
{
AddWaypointToMap(recipe);
});
}
public static void AddMissingWaypointsAroundDeletedWaypoint(WaypointMapItem deletedWaypoint)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if ((ComparableScriptableObject<SerializablePanelElement>)(object)deletedWaypoint.Recipe.Recipe.potionBase != (ComparableScriptableObject<SerializablePanelElement>)(object)GetCurrentPotionBase())
{
return;
}
Vector3 pos = ((Component)deletedWaypoint).transform.position;
(from r in RecipeService.GetWaypointRecipes(deletedWaypoint.Recipe.Recipe.potionBase)
where Vector2.Distance(Vector2.op_Implicit(pos), RecipeService.GetMapPositionForRecipe(r)) <= 1f
where StaticStorage.Waypoints.Any((WaypointMapItem w) => w.Recipe.Index == r.Index)
select r).ToList().ForEach(delegate(RecipeIndex recipe)
{
AddWaypointToMap(recipe);
});
}
public static WaypointMapItem AddWaypointToMap(RecipeIndex recipe, bool addToWaypointList = true)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
Vector2 pos = RecipeService.GetMapPositionForRecipe(recipe);
if (StaticStorage.Waypoints.Any((WaypointMapItem w) => Vector2.Distance(Vector2.op_Implicit(((Component)w).transform.localPosition), pos) < 1f))
{
Plugin.PluginLogger.LogInfo((object)("Waypoint not added to map due to proximity to existing waypoint: " + ((InventoryItem)recipe.Recipe).GetLocalizedTitle()));
Plugin.PluginLogger.LogInfo((object)$"{pos.x}-{pos.y}");
return null;
}
GameObject val = new GameObject($"waypoint ({StaticStorage.Waypoints.Count})");
val.layer = LayerMask.NameToLayer("RecipeMapContent");
Scene sceneByName = SceneManager.GetSceneByName(recipe.Recipe.potionBase.mapSceneName);
SceneManager.MoveGameObjectToScene(val, sceneByName);
val.transform.parent = ((Scene)(ref sceneByName)).GetRootGameObjects().First((GameObject go) => ((Object)go).name == "MapItemsContainer").transform;
WaypointMapItem waypointMapItem = val.AddComponent<WaypointMapItem>();
waypointMapItem.IsTailEndWaypoint = RecipeService.GetMapPositionForRecipe(recipe.Recipe, forceReturnIndicatorPosition: true) != pos;
typeof(RecipeMapItem).GetField("canBeInteracted", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(waypointMapItem, true);
RecipeMapItemsUpdater.generalCollection.RegisterItem((IRecipeMapItemsUpdaterTarget)(object)waypointMapItem);
waypointMapItem.IconRenderer = ((Component)waypointMapItem).gameObject.AddComponent<SpriteRenderer>();
((InteractiveItem)waypointMapItem).sortingGroup = val.AddComponent<SortingGroup>();
SortingGroup sortingGroup = ((InteractiveItem)waypointMapItem).sortingGroup;
string sortingLayerName = (((Renderer)waypointMapItem.IconRenderer).sortingLayerName = "RecipeMapContent");
sortingGroup.sortingLayerName = sortingLayerName;
SortingGroup sortingGroup2 = ((InteractiveItem)waypointMapItem).sortingGroup;
int sortingLayerID = (((Renderer)waypointMapItem.IconRenderer).sortingLayerID = SortingLayer.NameToID(((Renderer)waypointMapItem.IconRenderer).sortingLayerName));
sortingGroup2.sortingLayerID = sortingLayerID;
SortingGroup sortingGroup3 = ((InteractiveItem)waypointMapItem).sortingGroup;
sortingLayerID = (((Renderer)waypointMapItem.IconRenderer).sortingOrder = 29502);
sortingGroup3.sortingOrder = sortingLayerID;
waypointMapItem.IconRenderer.sprite = GetWaypointSprite();
waypointMapItem.IconRenderer.color = GetWaypointMapItemColor();
CircleCollider2D circleCollider = val.AddComponent<CircleCollider2D>();
waypointMapItem.circleCollider = circleCollider;
waypointMapItem.circleCollider.radius = 0.5f;
((Component)waypointMapItem).transform.localPosition = Vector2.op_Implicit(pos);
waypointMapItem.Recipe = recipe;
if (addToWaypointList)
{
StaticStorage.Waypoints.Add(waypointMapItem);
}
if (!StaticStorage.WaypointsVisible)
{
val.SetActive(false);
}
return waypointMapItem;
}
public static bool ViewWaypointOnMap(RecipeBookRightPageContent rightPageContent)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
Potion pageContentPotion = rightPageContent.pageContentPotion;
if (!RecipeService.IsWaypointRecipe(pageContentPotion))
{
return true;
}
MapStatesManager.SelectMapIfNotSelected(pageContentPotion.potionBase, false);
Vector2 mapPositionForRecipe = RecipeService.GetMapPositionForRecipe(pageContentPotion);
Managers.RecipeMap.CenterMapOn(mapPositionForRecipe, true, (float?)1f, true);
Managers.Room.GoTo((RoomIndex)1, true);
if (!StaticStorage.WaypointsVisible)
{
ShowHideWaypoints(show: true);
}
return false;
}
public static void CreateWaypointHoverPath(WaypointMapItem waypointMapItem)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_033d: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
waypointMapItem.path = new GameObject("WaypointPath");
waypointMapItem.path.transform.parent = ((Component)waypointMapItem).transform;
RecipeMapManagerPathSettings pathSettings = Settings<RecipeMapManagerPathSettings>.Asset;
SerializedPath serializedPath = waypointMapItem.Recipe.Recipe.potionFromPanel.serializedPath;
List<SerializedPathPoints> fixedPathPoints = serializedPath.fixedPathPoints;
if (fixedPathPoints.Any((SerializedPathPoints p) => p.isTeleportationHint))
{
return;
}
List<FixedHint> fixedPathHints = new List<FixedHint>();
bool isFirst = true;
fixedPathPoints.Select((SerializedPathPoints f) => f.Clone()).ToList().ForEach(delegate(SerializedPathPoints points)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
FixedHint component = Object.Instantiate<GameObject>(pathSettings.nonTeleportationFixedHint, waypointMapItem.path.transform).GetComponent<FixedHint>();
component.evenlySpacedPointsFixedPhysics = new EvenlySpacedPoints((IEnumerable<Vector3>)points.physicsPoints);
component.evenlySpacedPointsFixedGraphics = new EvenlySpacedPoints((IEnumerable<Vector3>)points.graphicsPoints);
component.SetPathStartParameters(points.pathStartParameters);
component.SetPathEndParameters(points.pathEndParameters);
List<FixedHint> fixedPathHints3 = Managers.RecipeMap.path.fixedPathHints;
float deletedGraphicsSegments2 = Managers.RecipeMap.path.deletedGraphicsSegments;
component.UpdateState((State)2, 0f, (Action)null);
component.ShowPathEnds(true, 0f, true);
float num = serializedPath.deletedGraphicsSegments;
if (isFirst)
{
isFirst = false;
num += 1f;
}
Managers.RecipeMap.path.fixedPathHints = fixedPathHints;
Managers.RecipeMap.path.deletedGraphicsSegments = num;
component.MakePathVisible(false, false);
Managers.RecipeMap.path.fixedPathHints = fixedPathHints3;
Managers.RecipeMap.path.deletedGraphicsSegments = deletedGraphicsSegments2;
fixedPathHints.Add(component);
});
List<FixedHint> fixedPathHints2 = Managers.RecipeMap.path.fixedPathHints;
float deletedGraphicsSegments = Managers.RecipeMap.path.deletedGraphicsSegments;
Managers.RecipeMap.path.fixedPathHints = fixedPathHints;
Managers.RecipeMap.path.deletedGraphicsSegments = serializedPath.deletedGraphicsSegments;
MethodInfo method = typeof(NonTeleportationFixedHint).GetMethod("UpdatePathAlpha", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo method2 = typeof(NonTeleportationFixedHint).GetMethod("UpdatePathEndAlpha", BindingFlags.Instance | BindingFlags.NonPublic);
for (int i = 0; i < fixedPathHints.Count; i++)
{
FixedHint val = fixedPathHints[i];
val.MakePathVisible(false, false);
method.Invoke(val, new object[1] { 0.75f });
method2.Invoke(val, new object[1] { (i == fixedPathHints.Count - 1) ? 0.75f : 0f });
}
Managers.RecipeMap.path.fixedPathHints = fixedPathHints2;
Managers.RecipeMap.path.deletedGraphicsSegments = deletedGraphicsSegments;
Vector2 mapPositionForRecipe = RecipeService.GetMapPositionForRecipe(waypointMapItem.Recipe.Recipe, forceReturnIndicatorPosition: true);
Vector2 mapPositionForRecipe2 = RecipeService.GetMapPositionForRecipe(waypointMapItem.Recipe.Recipe);
Vector2 val2 = (waypointMapItem.IsTailEndWaypoint ? (mapPositionForRecipe - mapPositionForRecipe2) : Vector2.zero);
waypointMapItem.path.transform.localPosition = Vector2.op_Implicit(serializedPath.pathPosition + val2);
if (!waypointMapItem.IsTailEndWaypoint)
{
return;
}
Transform val3 = Object.Instantiate<Transform>(((Component)Managers.RecipeMap.indicator).gameObject.transform.Find("Bottle"), waypointMapItem.path.transform);
Vector2 val4 = serializedPath.indicatorTargetPosition + serializedPath.pathPosition;
((Component)val3).transform.localPosition = Vector2.op_Implicit(mapPositionForRecipe - val4);
((Component)val3).transform.eulerAngles = FloatExtension.RecalculateEulerAngle(serializedPath.indicatorRotationValue, (AngleType)0) * Vector3.forward;
Color waypointMapItemColor = GetWaypointMapItemColor();
waypointMapItemColor = new Color(waypointMapItemColor.r, waypointMapItemColor.g, waypointMapItemColor.b, 0.375f);
SpriteRenderer background = ((Component)((Component)val3).transform.Find("Background")).GetComponent<SpriteRenderer>();
List<SpriteRenderer> obj = new List<SpriteRenderer>
{
background,
((Component)((Component)val3).transform.Find("Liquid Sprites Container/Sprite Liquid Main")).GetComponent<SpriteRenderer>(),
((Component)((Component)val3).transform.Find("Liquid Sprites Container(Clone)/Sprite Liquid Main")).GetComponent<SpriteRenderer>(),
((Component)((Component)val3).transform.Find("Foreground")).GetComponent<SpriteRenderer>(),
((Component)((Component)val3).transform.Find("Contour")).GetComponent<SpriteRenderer>()
};
LineRenderer fixedPathSprite = ((Component)fixedPathHints.First()).GetComponentInChildren<LineRenderer>();
obj.ForEach(delegate(SpriteRenderer sprite)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)sprite != (Object)(object)background)
{
sprite.color = waypointMapItemColor;
}
((Renderer)sprite).sortingLayerName = ((Renderer)fixedPathSprite).sortingLayerName;
((Renderer)sprite).sortingOrder = ((Renderer)fixedPathSprite).sortingOrder + ((Renderer)sprite).sortingOrder;
});
List<SortingGroup> list = new List<SortingGroup>();
list.Add(((Component)((Component)val3).transform.Find("Liquid Sprites Container")).GetComponent<SortingGroup>());
list.Add(((Component)((Component)val3).transform.Find("Liquid Sprites Container(Clone)")).GetComponent<SortingGroup>());
list.ForEach(delegate(SortingGroup group)
{
group.sortingLayerName = ((Renderer)fixedPathSprite).sortingLayerName;
group.sortingOrder = ((Renderer)fixedPathSprite).sortingOrder + group.sortingOrder;
});
((Component)((Component)val3).transform.Find("Cork")).gameObject.SetActive(false);
((Component)((Component)val3).transform.Find("Scratches")).gameObject.SetActive(false);
}
public static void UpdateCurrentRecipePage()
{
((Component)Managers.Potion.recipeBook).GetComponentsInChildren<RecipeBookRightPageContent>().ToList().ForEach(delegate(RecipeBookRightPageContent rightPageContent)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
((PageContent)rightPageContent).UpdatePage(((PageContent)rightPageContent).currentState, (IBookPageContent)(object)rightPageContent.pageContentPotion);
});
}
public static bool FixButtonInitializationException(Slot instance)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)instance.cursorAnchorSubObject == (Object)null)
{
((SectionEntity)instance).ShowSectionEntity();
}
instance.cursorAnchorLocalPos = Vector2.op_Implicit(((Component)instance.cursorAnchorSubObject).transform.localPosition);
return false;
}
public static void DeleteWaypoint(WaypointMapItem matchingWaypoint)
{
StaticStorage.Waypoints.Remove(matchingWaypoint);
Object.Destroy((Object)(object)((Component)matchingWaypoint).gameObject);
}
public static PotionBase GetCurrentPotionBase()
{
return Managers.RecipeMap?.currentMap?.potionBase;
}
public static void ModifyBrewPotionButtonForWaypointRecipes(RecipeBookBrewPotionButton instance, RecipeBookRightPageContent rightPageContent)
{
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)StaticStorage.TemporaryWaypoint != (Object)null)
{
Object.Destroy((Object)(object)((Component)StaticStorage.TemporaryWaypoint).gameObject);
}
StaticStorage.TemporaryWaypoint = null;
CreateRecipeBookWaypointToggleButton(rightPageContent);
if (RecipeService.IsWaypointRecipe(rightPageContent.pageContentPotion))
{
if (!StaticStorage.WaypointBrewPotionButton.ContainsKey(rightPageContent))
{
RecipeBookBrewPotionButton val = Object.Instantiate<RecipeBookBrewPotionButton>(instance, ((Component)instance).transform.parent);
StaticStorage.WaypointBrewPotionButton[rightPageContent] = val;
typeof(RecipeBookBrewPotionButton).GetField("rightPageContent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(val, rightPageContent);
TextMeshPro countText = default(TextMeshPro);
ref TextMeshPro reference = ref countText;
object? value = typeof(RecipeBookBrewPotionButton).GetField("potionsCountText", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(val);
reference = (TextMeshPro)((value is TextMeshPro) ? value : null);
TextMeshPro obj = ((SpriteChangingButton)val).texts.Where((TextMeshPro t) => (Object)(object)t != (Object)(object)countText).First();
((Renderer)((Component)countText).GetComponent<MeshRenderer>()).enabled = false;
((TMP_Text)obj).text = "View waypoint on map";
Sprite pressedSpriteIcon = (((SpriteChangingButton)val).spriteRendererIcon.sprite = GetWaypointSprite());
((SpriteChangingButton)val).hoveredSpriteIcon = (((SpriteChangingButton)val).normalSpriteIcon = (((SpriteChangingButton)val).pressedSpriteIcon = pressedSpriteIcon));
((SpriteChangingButton)val).spriteRendererIcon.color = GetWaypointSpriteColor();
Transform transform = ((Component)((SpriteChangingButton)val).spriteRendererIcon).transform;
transform.localScale *= 0.65f;
((InteractiveItem)val).GetTooltipContent();
}
((Component)StaticStorage.WaypointBrewPotionButton[rightPageContent]).gameObject.SetActive(true);
((Component)instance).gameObject.SetActive(false);
Potion pageContentPotion = rightPageContent.pageContentPotion;
object obj2;
if (pageContentPotion == null)
{
obj2 = null;
}
else
{
PotionBase potionBase = pageContentPotion.potionBase;
obj2 = ((potionBase != null) ? ((Object)potionBase).name : null);
}
bool flag = (string?)obj2 == ((Object)GetCurrentPotionBase()).name || !Managers.Potion.potionCraftPanel.IsPotionBrewingStarted();
((Button)StaticStorage.WaypointBrewPotionButton[rightPageContent]).Locked = !flag;
if (StaticStorage.BrewFromHereInstalled)
{
int currentPageIndex = ((Book)Managers.Potion.recipeBook).currentPageIndex;
StaticStorage.TemporaryWaypoint = AddWaypointToMap(new RecipeIndex
{
Index = currentPageIndex,
Recipe = rightPageContent.pageContentPotion
}, addToWaypointList: false);
}
}
else
{
if (StaticStorage.WaypointBrewPotionButton.ContainsKey(rightPageContent))
{
((Component)StaticStorage.WaypointBrewPotionButton[rightPageContent]).gameObject.SetActive(false);
}
((Component)instance).gameObject.SetActive(true);
}
}
public static void CreateWaypointToggleButton(FollowIndicatorButton instance)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Expected O, but got Unknown
if ((Object)(object)StaticStorage.WaypointToggleButton != (Object)null)
{
ShowHideWaypoints(show: false);
return;
}
BoxCollider2D component = ((Component)instance).GetComponent<BoxCollider2D>();
component.size = new Vector2(3f, component.size.y);
WaypointToggleButton waypointToggleButton = GetWaypointToggleButton(((Component)instance).transform.parent);
waypointToggleButton.followButton = instance;
GameObject gameObject = ((Component)waypointToggleButton).gameObject;
gameObject.transform.localPosition = new Vector3(((Component)instance).transform.localPosition.x + 1.8f, ((Component)instance).transform.localPosition.y, 0f);
SpriteRenderer val = ((Component)instance).GetComponentsInChildren<SpriteRenderer>().First();
((InteractiveItem)waypointToggleButton).sortingGroup = gameObject.AddComponent<SortingGroup>();
SortingGroup sortingGroup = ((InteractiveItem)waypointToggleButton).sortingGroup;
string sortingLayerName2 = (((Renderer)waypointToggleButton.iconRenderer).sortingLayerName = ((Renderer)val).sortingLayerName);
sortingGroup.sortingLayerName = sortingLayerName2;
SortingGroup sortingGroup2 = ((InteractiveItem)waypointToggleButton).sortingGroup;
int sortingLayerID2 = (((Renderer)waypointToggleButton.iconRenderer).sortingLayerID = ((Renderer)val).sortingLayerID);
sortingGroup2.sortingLayerID = sortingLayerID2;
SortingGroup sortingGroup3 = ((InteractiveItem)waypointToggleButton).sortingGroup;
sortingLayerID2 = (((Renderer)waypointToggleButton.iconRenderer).sortingOrder = ((Renderer)val).sortingOrder + 1);
sortingGroup3.sortingOrder = sortingLayerID2;
List<PositioningSettings> position = new List<PositioningSettings>
{
new PositioningSettings
{
bindingPoint = (BindingPoint)0,
tooltipCorner = (TooltipCorner)3,
position = new Vector2(4.5f, -0.4f)
}
};
AddTooltipProvider((InteractiveItem)(object)waypointToggleButton, gameObject, position);
StaticStorage.WaypointToggleButton = waypointToggleButton;
ShowHideWaypoints(show: false);
}
public static void CreateRecipeBookWaypointToggleButton(RecipeBookRightPageContent instance)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Expected O, but got Unknown
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
if (!StaticStorage.WaypointToggleButtonRecipeBook.ContainsKey(instance))
{
WaypointToggleButton waypointToggleButton = GetWaypointToggleButton(((Component)instance).transform);
GameObject gameObject = ((Component)waypointToggleButton).gameObject;
object? value = typeof(RecipeBookRightPageContent).GetField("brewPotionButton", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(instance);
RecipeBookBrewPotionButton val = (RecipeBookBrewPotionButton)((value is RecipeBookBrewPotionButton) ? value : null);
gameObject.transform.localPosition = new Vector3(2.7f, 4.55f, 0f);
((InteractiveItem)waypointToggleButton).raycastPriorityLevel = ((InteractiveItem)val).raycastPriorityLevel;
SpriteRenderer spriteRenderer = ((SpriteChangingButton)val).spriteRenderer;
((InteractiveItem)waypointToggleButton).sortingGroup = gameObject.AddComponent<SortingGroup>();
SortingGroup sortingGroup = ((InteractiveItem)waypointToggleButton).sortingGroup;
string sortingLayerName2 = (((Renderer)waypointToggleButton.iconRenderer).sortingLayerName = ((Renderer)spriteRenderer).sortingLayerName);
sortingGroup.sortingLayerName = sortingLayerName2;
SortingGroup sortingGroup2 = ((InteractiveItem)waypointToggleButton).sortingGroup;
int sortingLayerID2 = (((Renderer)waypointToggleButton.iconRenderer).sortingLayerID = ((Renderer)spriteRenderer).sortingLayerID);
sortingGroup2.sortingLayerID = sortingLayerID2;
SortingGroup sortingGroup3 = ((InteractiveItem)waypointToggleButton).sortingGroup;
sortingLayerID2 = (((Renderer)waypointToggleButton.iconRenderer).sortingOrder = ((Renderer)spriteRenderer).sortingOrder + 1);
sortingGroup3.sortingOrder = sortingLayerID2;
List<PositioningSettings> position = new List<PositioningSettings>
{
new PositioningSettings
{
bindingPoint = (BindingPoint)0,
tooltipCorner = (TooltipCorner)0,
position = new Vector2(0f, -1.5f)
}
};
AddTooltipProvider((InteractiveItem)(object)waypointToggleButton, gameObject, position);
StaticStorage.WaypointToggleButtonRecipeBook[instance] = waypointToggleButton;
}
WaypointToggleButton waypointToggleButton2 = StaticStorage.WaypointToggleButtonRecipeBook[instance];
bool flag = RecipeService.IsWaypointRecipe(instance.pageContentPotion, returnIgnored: true);
((Component)waypointToggleButton2).gameObject.SetActive(flag);
if (flag)
{
Color waypointSpriteColor = GetWaypointSpriteColor();
waypointToggleButton2.iconRenderer.color = (Color)(StaticStorage.IgnoredWaypoints.Contains(RecipeService.GetRecipeIndexObject(instance.pageContentPotion).Index) ? new Color(waypointSpriteColor.r, waypointSpriteColor.g, waypointSpriteColor.b, waypointToggleButton2.OffAlpha) : waypointSpriteColor);
}
}
public static void ShowHideWaypoints()
{
ShowHideWaypoints(!StaticStorage.WaypointsVisible);
}
public static Vector2 GetEffectMapLocation(PotionEffect potionEffect, PotionBase potionBase)
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
MapState val = ((IEnumerable<MapState>)MapStatesManager.MapStates).FirstOrDefault((Func<MapState, bool>)((MapState m) => ((Object)m.potionBase).name == ((Object)potionBase).name));
if (val == null)
{
Plugin.PluginLogger.LogError((object)("Error: failed to find map for potion base " + ((Object)potionBase).name));
return Vector2.zero;
}
return Vector2.op_Implicit(((RecipeMapItem)((IEnumerable<PotionEffectMapItem>)val.potionEffectsOnMap).FirstOrDefault((Func<PotionEffectMapItem, bool>)((PotionEffectMapItem e) => ((Object)e.Effect).name == ((Object)potionEffect).name))).thisTransform.localPosition);
}
public static float GetIndicatorDiameter()
{
return Managers.RecipeMap.indicator.circleCollider.radius * 2f;
}
private static Sprite GetWaypointSprite()
{
if ((Object)(object)StaticStorage.RecipeWaypointSprite == (Object)null)
{
StaticStorage.RecipeWaypointSprite = Settings<RecipeMapManagerTeleportationSettings>.Asset.spiralSprites.First().main;
}
return StaticStorage.RecipeWaypointSprite;
}
private static Color GetWaypointSpriteColor()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return Settings<RecipeMapManagerTeleportationSettings>.Asset.colorFixed;
}
private static Color GetWaypointMapItemColor()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
Color waypointSpriteColor = GetWaypointSpriteColor();
return new Color(waypointSpriteColor.r, waypointSpriteColor.g, waypointSpriteColor.b, 0.75f);
}
private static Color GetWaypointToggleButtonColor()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
Color waypointSpriteColor = GetWaypointSpriteColor();
if (StaticStorage.WaypointsVisible)
{
return waypointSpriteColor;
}
return new Color(waypointSpriteColor.r, waypointSpriteColor.g, waypointSpriteColor.b, StaticStorage.WaypointToggleButton.OffAlpha);
}
private static WaypointToggleButton GetWaypointToggleButton(Transform parent)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("WaypointToggleButton");
val.layer = LayerMask.NameToLayer("UI");
WaypointToggleButton waypointToggleButton = val.AddComponent<WaypointToggleButton>();
((Behaviour)waypointToggleButton).enabled = true;
waypointToggleButton.spriteSlot = new GameObject("SpriteSlot");
waypointToggleButton.spriteSlot.transform.parent = val.transform;
Transform transform = waypointToggleButton.spriteSlot.transform;
transform.localScale *= 0.5f;
SpriteRenderer val2 = (waypointToggleButton.iconRenderer = waypointToggleButton.spriteSlot.AddComponent<SpriteRenderer>());
BoxCollider2D val3 = (waypointToggleButton.collider = val.AddComponent<BoxCollider2D>());
((Behaviour)val3).enabled = true;
((Collider2D)val3).isTrigger = true;
val3.size = new Vector2(0.7f, val3.size.y);
val.transform.parent = parent;
val2.sprite = GetWaypointSprite();
val2.color = GetWaypointSpriteColor();
return waypointToggleButton;
}
private static void AddTooltipProvider(InteractiveItem obj, GameObject gameObject, List<PositioningSettings> position)
{
TooltipContentProvider val = gameObject.AddComponent<TooltipContentProvider>();
val.positioningSettings = position;
typeof(InteractiveItem).GetField("tooltipContentProvider", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(obj, val);
}
public static void ShowHideWaypoints(bool show)
{
if (StaticStorage.Waypoints != null)
{
StaticStorage.Waypoints.ForEach(delegate(WaypointMapItem w)
{
((Component)w).gameObject.SetActive(show);
});
StaticStorage.WaypointsVisible = show;
UpdateWaypointToggleButtonSprite();
if ((Object)(object)StaticStorage.TemporaryWaypoint != (Object)null)
{
((Component)StaticStorage.TemporaryWaypoint).gameObject.SetActive(show);
}
}
}
private static void UpdateWaypointToggleButtonSprite()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)StaticStorage.WaypointToggleButton == (Object)null))
{
StaticStorage.WaypointToggleButton.iconRenderer.color = GetWaypointToggleButtonColor();
}
}
}
}