using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using NetworkingLibrary;
using NetworkingLibrary.Modules;
using NetworkingLibrary.Services;
using PEAKChoice.Features;
using PEAKChoice.Modules;
using PEAKChoice.Services;
using Photon.Pun;
using UnityEngine;
using Zorro.Core;
using pworld.Scripts.Extensions;
[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("off_grid.PEAKChoice")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyInformationalVersion("1.3.1")]
[assembly: AssemblyProduct("PEAKChoice")]
[assembly: AssemblyTitle("off_grid.PEAKChoice")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 PEAKChoice
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("off_grid.PEAKChoice", "PEAKChoice", "1.3.1")]
public class PEAKChoice : BaseUnityPlugin
{
internal static Harmony Harmony = new Harmony("off_grid.PEAKChoice");
internal static string ForceMap = "Any";
internal static int AnyWeight = 50;
internal static string ForceMap2 = "Any";
internal static int AnyWeight2 = 50;
internal static bool BothMaps = false;
internal static string LayoutOrder = "";
internal static bool ForceLayoutOrder = false;
internal static string PeakZone = "";
internal static string StartingZone = "";
internal static bool AwaitRPC = true;
internal static bool NoWind = false;
internal static bool NoTornado = false;
internal static bool NoBlizard = false;
internal static bool NoRain = false;
internal static bool AlwaysDay = false;
internal static bool AlwaysNight = false;
internal static string[] Forced = new string[0];
internal static bool GenerateMissingTerrain = true;
internal static int Seed = 0;
internal static bool UseTerrainRandomizerCompat = true;
internal static string GenerateSegmentsList = "1-2";
internal static bool TerrainRandomizerPresent = Chainloader.PluginInfos.ContainsKey("com.snosz.terrainrandomiser");
public ConfigFile config;
internal static MethodInfo? WarpPlayer;
internal static INetworkingService Service = Net.Service;
internal static readonly uint MOD_ID = ModId.FromGuid("off_grid.PEAKChoice");
private IDisposable? registrationToken;
public static PEAKChoice Instance { get; private set; } = null;
internal static ManualLogSource Logger { get; private set; } = null;
private void Setup()
{
Seed = Additions.GetMasterSeed();
if (BothMaps && !ForceLayoutOrder)
{
LayoutOrder = "Beach > Tropics > Roots > Alpine > Mesa > Caldera > Volcano > Peak";
}
Forced = Additions.GetTargetBiome();
string text = ((Forced != null && Forced.Length != 0) ? string.Join(", ", Forced) : "None");
Logger.LogWarning((object)("< " + ((BothMaps && !ForceLayoutOrder) ? "Forced every segment >" : (ForceLayoutOrder ? "Forced LayoutOrder, ignoring all other values >" : ("Forced biome set to: " + text + " >")))));
WarpPlayer = typeof(Character).GetMethod("WarpPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
if (GenerateMissingTerrain)
{
Logger.LogWarning((object)$"< Generation Seed = {Seed} | TerrainRandomizerPresent? = {TerrainRandomizerPresent} >");
}
Logger.LogInfo((object)"< Setup Finished >");
}
private void NetworkSetup()
{
registrationToken = Service.RegisterNetworkObject((object)this, MOD_ID, 0);
Service.LobbyEntered += Networking.OnLobbyEntered;
if (Service.InLobby)
{
Networking.OnLobbyEntered();
}
Logger.LogInfo((object)"< Network Finished >");
}
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
FileManager.InitializeConfig();
Setup();
NetworkSetup();
Harmony.PatchAll();
Logger.LogInfo((object)"off_grid.PEAKChoice v1.3.1 has fully loaded!");
}
private void OnDestroy()
{
Service.LobbyEntered -= Networking.OnLobbyEntered;
registrationToken?.Dispose();
Logger.LogInfo((object)"PEAKChoice destroyed");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "off_grid.PEAKChoice";
public const string PLUGIN_NAME = "PEAKChoice";
public const string PLUGIN_VERSION = "1.3.1";
}
}
namespace PEAKChoice.Services
{
internal class Networking
{
internal static void OnLobbyEntered()
{
if (PEAKChoice.Service.IsHost)
{
PEAKChoice.Service.RPC(PEAKChoice.MOD_ID, "HandleConfigRPC", (ReliableType)1, new object[1] { BuildConfigPayload() });
}
else
{
PEAKChoice.Service.RPCToHost(PEAKChoice.MOD_ID, "RequestConfigRPC", (ReliableType)1, Array.Empty<object>());
}
}
internal static string BuildConfigPayload()
{
string text = "";
try
{
if (PEAKChoice.Forced != null && PEAKChoice.Forced.Length != 0)
{
text = string.Join(",", (from s in PEAKChoice.Forced
select (s ?? "").Replace("|", "/").Trim() into s
where s.Length > 0
select s).ToArray());
}
}
catch
{
text = "";
}
return string.Join("|", PEAKChoice.ForceMap, PEAKChoice.AnyWeight.ToString(), PEAKChoice.ForceMap2, PEAKChoice.AnyWeight2.ToString(), PEAKChoice.BothMaps.ToString(), PEAKChoice.LayoutOrder, PEAKChoice.ForceLayoutOrder.ToString(), PEAKChoice.PeakZone, PEAKChoice.StartingZone, PEAKChoice.GenerateMissingTerrain.ToString(), PEAKChoice.Seed.ToString(), text);
}
[CustomRPC]
internal static void RequestConfigRPC()
{
if (PEAKChoice.Service.IsHost)
{
PEAKChoice.Service.RPC(PEAKChoice.MOD_ID, "HandleConfigRPC", (ReliableType)1, new object[1] { BuildConfigPayload() });
}
}
[CustomRPC]
internal static void HandleConfigRPC(string joined)
{
try
{
string[] array = joined.Split('|');
int num = 0;
PEAKChoice.ForceMap = array[num++];
PEAKChoice.AnyWeight = int.Parse(array[num++]);
PEAKChoice.ForceMap2 = array[num++];
PEAKChoice.AnyWeight2 = int.Parse(array[num++]);
PEAKChoice.BothMaps = bool.Parse(array[num++]);
PEAKChoice.LayoutOrder = array[num++];
PEAKChoice.ForceLayoutOrder = bool.Parse(array[num++]);
PEAKChoice.PeakZone = array[num++];
PEAKChoice.StartingZone = array[num++];
PEAKChoice.GenerateMissingTerrain = bool.Parse(array[num++]);
PEAKChoice.Seed = int.Parse(array[num++]);
string text = "";
if (array.Length > num)
{
text = array[num++];
}
if (!string.IsNullOrEmpty(text))
{
try
{
PEAKChoice.Forced = (from s in text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)
select s.Trim() into s
where !string.IsNullOrEmpty(s)
select s).ToArray();
return;
}
catch
{
PEAKChoice.Logger.LogError((object)"Forced was not able to be synced, so built it with synced values...");
PEAKChoice.Forced = Additions.GetTargetBiome();
return;
}
}
PEAKChoice.Logger.LogError((object)"Forced was not able to be synced, so built it with synced values...");
PEAKChoice.Forced = Additions.GetTargetBiome();
}
catch (Exception arg)
{
PEAKChoice.Logger.LogError((object)$"HandleConfigRPC exception: {arg}");
}
}
[CustomRPC]
internal static void HandleAssignedViewIDs_RPC(int[] ids)
{
try
{
if (PEAKChoice.Service.IsHost)
{
return;
}
PhotonView[] source = (from v in ((Component)Singleton<MapHandler>.Instance).gameObject.GetComponentsInChildren<PhotonView>(true)
where v.ViewID == 0
select v).ToArray();
PhotonView[] array = source.OrderBy(delegate(PhotonView v)
{
GameObject gameObject = ((Component)v).gameObject;
List<string> list = new List<string>();
Transform val = gameObject.transform;
while ((Object)(object)val != (Object)null)
{
list.Add(((Object)val).name);
val = val.parent;
}
list.Reverse();
return string.Join("/", list);
}).ToArray();
if (array.Length != ids.Length)
{
PEAKChoice.Logger.LogWarning((object)$"[Gen] Assigned view count mismatch (local={array.Length}, remote={ids.Length}).");
}
int num = Math.Min(array.Length, ids.Length);
for (int i = 0; i < num; i++)
{
try
{
array[i].ViewID = ids[i];
}
catch (Exception arg)
{
PEAKChoice.Logger.LogError((object)$"[Gen] Failed to assign view id on client: {arg}");
}
}
}
catch (Exception arg2)
{
PEAKChoice.Logger.LogError((object)$"[Gen] HandleAssignedViewIDs_RPC exception: {arg2}");
}
}
}
}
namespace PEAKChoice.Patches
{
[HarmonyPatch(typeof(Character))]
internal class CharacterPatch
{
}
[HarmonyPatch(typeof(DayNightManager))]
internal class DayNightManagerPatch
{
private static readonly FieldInfo fi_passedMidnight = typeof(DayNightManager).GetField("passedMidnight", BindingFlags.Instance | BindingFlags.NonPublic);
[HarmonyPostfix]
[HarmonyPatch("Update")]
public static void Patch_DayNight_Update_Postfix(DayNightManager __instance)
{
if (!PhotonNetwork.IsMasterClient)
{
return;
}
float num = ForcedTime();
if (!float.IsNaN(num))
{
__instance.timeOfDay = num;
if (fi_passedMidnight != null)
{
fi_passedMidnight.SetValue(__instance, false);
}
__instance.UpdateCycle();
}
}
internal static float ForcedTime()
{
if (PEAKChoice.AlwaysDay)
{
return 12f;
}
if (PEAKChoice.AlwaysNight)
{
return 0f;
}
return float.NaN;
}
}
[HarmonyPatch(typeof(MapHandler))]
public static class MapHandlerPatches
{
[CompilerGenerated]
private sealed class <Start_Postfix>d__3 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator __result;
public MapHandler __instance;
private List<int> <assignedViewIds>5__2;
private MapSegment[] <segments>5__3;
private int <i>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Start_Postfix>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<assignedViewIds>5__2 = null;
<segments>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if (__result != null)
{
goto IL_004d;
}
goto IL_005a;
case 1:
<>1__state = -1;
goto IL_004d;
case 2:
{
<>1__state = -1;
goto IL_0642;
}
IL_004d:
if (__result.MoveNext())
{
<>2__current = __result.Current;
<>1__state = 1;
return true;
}
goto IL_005a;
IL_0642:
<i>5__4++;
goto IL_0654;
IL_005a:
if (!PEAKChoice.GenerateMissingTerrain || !PhotonNetwork.IsMasterClient)
{
return false;
}
PEAKChoice.Logger.LogInfo((object)$"[Gen] Host starting generation (Seed={PEAKChoice.Seed})");
<assignedViewIds>5__2 = new List<int>();
<segments>5__3 = __instance.segments;
if (<segments>5__3 == null)
{
PEAKChoice.Logger.LogWarning((object)"[Gen] Segments is null, nothing to generate.");
return false;
}
<i>5__4 = 0;
goto IL_0654;
IL_0654:
if (<i>5__4 < <segments>5__3.Length)
{
MapSegment val = <segments>5__3[<i>5__4];
if (val == null)
{
PEAKChoice.Logger.LogInfo((object)$"[Gen] Segment {<i>5__4} is null.");
}
else
{
GameObject segmentParent = val.segmentParent;
Transform val2 = ((segmentParent != null) ? segmentParent.transform : null);
if ((Object)(object)val2 == (Object)null)
{
PEAKChoice.Logger.LogInfo((object)$"[Gen] Segment {<i>5__4} has no segmentParent.");
}
else
{
if (MapHelper.ShouldGenerateSegment(<i>5__4, val))
{
try
{
if (!((Component)val2).gameObject.activeSelf)
{
((Component)val2).gameObject.SetActive(true);
}
bool flag = false;
bool flag2 = true;
bool flag3 = PEAKChoice.TerrainRandomizerPresent && PEAKChoice.UseTerrainRandomizerCompat;
if (flag && !flag2)
{
PEAKChoice.Logger.LogInfo((object)$"[Gen] Segment {<i>5__4} appears to have terrain and a campfire.");
}
else
{
int num = Additions.HashSeed(PEAKChoice.Seed, <i>5__4);
Random.InitState(num);
PEAKChoice.Logger.LogInfo((object)$"[Gen] Segment {<i>5__4} requires generation (hasTerrain={MapHelper.SegmentHasTerrain(val2, val)}, needCampfire={MapHelper.CampfireNeedsGeneration(val, val2)}, forceCampfireOnly={flag3}, Seed={num}).");
PropGrouper val3 = ((Component)val2).GetComponent<PropGrouper>() ?? ((Component)val2).gameObject.AddComponent<PropGrouper>();
if (!flag3)
{
try
{
val3.RunAll(true);
PEAKChoice.Logger.LogInfo((object)$"[Gen] PropGrouper.RunAll executed for segment {<i>5__4}.");
}
catch (Exception arg)
{
PEAKChoice.Logger.LogError((object)$"[Gen] PropGrouper.RunAll failed for segment {<i>5__4}: {arg}");
}
try
{
List<LevelGenStep> list = new List<LevelGenStep>();
MapHelper.CollectLateLevelGenSteps(val3, list);
MapHelper.RunLateLevelGenSteps(list);
}
catch (Exception arg2)
{
PEAKChoice.Logger.LogWarning((object)$"[Gen] Late level gen steps for segment {<i>5__4} failed: {arg2}");
}
}
else
{
PEAKChoice.Logger.LogInfo((object)$"[Gen] Skipping to campfire generation for segment {<i>5__4}.");
}
try
{
GameObject val4 = val.segmentCampfire;
if ((Object)(object)val4 == (Object)null)
{
Transform val5 = Additions.FindChildByNameContains(val2, "Campfire");
if ((Object)(object)val5 != (Object)null)
{
val4 = ((Component)val5).gameObject;
try
{
FieldInfo field = typeof(MapSegment).GetField("segmentCampfire", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(val, val4);
}
}
catch
{
}
}
}
if ((Object)(object)val4 != (Object)null)
{
if (!val4.activeInHierarchy)
{
val4.SetActive(true);
}
if (flag2 || flag3)
{
try
{
PropGrouper val6 = val4.GetComponent<PropGrouper>() ?? val4.AddComponent<PropGrouper>();
val6.RunAll(true);
PEAKChoice.Logger.LogInfo((object)$"[Gen] Campfire PropGrouper.RunAll executed for segment {<i>5__4}.");
}
catch (Exception arg3)
{
PEAKChoice.Logger.LogWarning((object)$"[Gen] Campfire PropGrouper failed for segment {<i>5__4}: {arg3}");
}
try
{
List<LevelGenStep> list2 = new List<LevelGenStep>();
PropGrouper grouper = val4.GetComponent<PropGrouper>() ?? val4.AddComponent<PropGrouper>();
MapHelper.CollectLateLevelGenSteps(grouper, list2);
MapHelper.RunLateLevelGenSteps(list2);
}
catch (Exception arg4)
{
PEAKChoice.Logger.LogWarning((object)$"[Gen] Campfire late LevelGenSteps failed for segment {<i>5__4}: {arg4}");
}
}
}
}
catch (Exception arg5)
{
PEAKChoice.Logger.LogWarning((object)$"[Gen] Campfire generation unexpected failure for segment {<i>5__4}: {arg5}");
}
try
{
List<PhotonView> list3 = new List<PhotonView>();
list3.AddRange(from v in ((Component)val2).GetComponentsInChildren<PhotonView>(true)
where v.ViewID == 0
select v);
GameObject val7 = val.segmentCampfire;
if ((Object)(object)val7 == (Object)null)
{
Transform val8 = Additions.FindChildByNameContains(val2, "Campfire");
if ((Object)(object)val8 != (Object)null)
{
val7 = ((Component)val8).gameObject;
}
}
if ((Object)(object)val7 != (Object)null)
{
list3.AddRange(from v in val7.GetComponentsInChildren<PhotonView>(true)
where v.ViewID == 0
select v);
}
PhotonView[] array = (from v in list3
where (Object)(object)v != (Object)null
orderby MapHelper.GetHierarchyPath(((Component)v).gameObject)
select v).ToArray();
PhotonView[] array2 = array;
foreach (PhotonView val9 in array2)
{
try
{
<assignedViewIds>5__2.Add(Helper.AssignMasterClientViewID(((Component)val9).gameObject));
}
catch (Exception arg6)
{
PEAKChoice.Logger.LogError((object)$"[Gen] Assign view ID failed segment {<i>5__4}: {arg6}");
}
}
}
catch (Exception arg7)
{
PEAKChoice.Logger.LogWarning((object)$"[Gen] Collecting/assigning views failed for segment {<i>5__4}: {arg7}");
}
finally
{
try
{
Random.state = Random.state;
}
catch
{
}
}
}
}
catch (Exception arg8)
{
PEAKChoice.Logger.LogError((object)$"[Gen] Exception while processing segment {<i>5__4}: {arg8}");
}
<>2__current = null;
<>1__state = 2;
return true;
}
PEAKChoice.Logger.LogInfo((object)$"[Gen] Segment {<i>5__4} has been disabled from generation.");
}
}
goto IL_0642;
}
if (<assignedViewIds>5__2.Count > 0)
{
try
{
PEAKChoice.Service.RPC(PEAKChoice.MOD_ID, "HandleAssignedViewIDs_RPC", (ReliableType)1, new object[1] { <assignedViewIds>5__2.ToArray() });
PEAKChoice.Logger.LogInfo((object)$"[Gen] Sent {<assignedViewIds>5__2.Count} assigned view IDs to clients.");
}
catch (Exception arg9)
{
PEAKChoice.Logger.LogError((object)$"[Gen] Failed to broadcast assigned view IDs: {arg9}");
}
}
PEAKChoice.Logger.LogInfo((object)"[Gen] Host finished generation for all segments.");
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
internal static Vector3 DesiredPosition;
[HarmonyPrefix]
[HarmonyPatch("DetectBiomes")]
private static bool DetectBiomes_Prefix(MapHandler __instance)
{
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0990: Unknown result type (might be due to invalid IL or missing references)
//IL_0997: Expected O, but got Unknown
//IL_0a2a: Unknown result type (might be due to invalid IL or missing references)
//IL_0a31: Expected O, but got Unknown
//IL_0abc: Unknown result type (might be due to invalid IL or missing references)
//IL_0ac3: Expected O, but got Unknown
//IL_0b56: Unknown result type (might be due to invalid IL or missing references)
//IL_0b5d: Expected O, but got Unknown
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Expected O, but got Unknown
//IL_0bed: Unknown result type (might be due to invalid IL or missing references)
//IL_0bf3: Invalid comparison between Unknown and I4
//IL_0c23: Unknown result type (might be due to invalid IL or missing references)
//IL_0c29: Invalid comparison between Unknown and I4
//IL_0c59: Unknown result type (might be due to invalid IL or missing references)
//IL_0c5f: Invalid comparison between Unknown and I4
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Expected O, but got Unknown
//IL_0cb9: Unknown result type (might be due to invalid IL or missing references)
//IL_0c8c: Unknown result type (might be due to invalid IL or missing references)
//IL_0c92: Invalid comparison between Unknown and I4
//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
//IL_061d: Unknown result type (might be due to invalid IL or missing references)
//IL_0622: Unknown result type (might be due to invalid IL or missing references)
//IL_0625: Unknown result type (might be due to invalid IL or missing references)
//IL_062a: Unknown result type (might be due to invalid IL or missing references)
//IL_0634: Unknown result type (might be due to invalid IL or missing references)
//IL_0639: Unknown result type (might be due to invalid IL or missing references)
//IL_0642: Unknown result type (might be due to invalid IL or missing references)
//IL_064d: Unknown result type (might be due to invalid IL or missing references)
//IL_0652: Unknown result type (might be due to invalid IL or missing references)
//IL_0654: Unknown result type (might be due to invalid IL or missing references)
//IL_065b: Unknown result type (might be due to invalid IL or missing references)
//IL_0665: Unknown result type (might be due to invalid IL or missing references)
//IL_066c: Unknown result type (might be due to invalid IL or missing references)
//IL_067d: Unknown result type (might be due to invalid IL or missing references)
//IL_0682: Unknown result type (might be due to invalid IL or missing references)
//IL_0ccd: Unknown result type (might be due to invalid IL or missing references)
//IL_0834: Unknown result type (might be due to invalid IL or missing references)
//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
//IL_08df: Unknown result type (might be due to invalid IL or missing references)
//IL_0859: Unknown result type (might be due to invalid IL or missing references)
//IL_085e: Unknown result type (might be due to invalid IL or missing references)
//IL_0863: Unknown result type (might be due to invalid IL or missing references)
//IL_069a: Unknown result type (might be due to invalid IL or missing references)
//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
//IL_089a: Unknown result type (might be due to invalid IL or missing references)
//IL_071d: Unknown result type (might be due to invalid IL or missing references)
//IL_0722: Unknown result type (might be due to invalid IL or missing references)
//IL_0726: Unknown result type (might be due to invalid IL or missing references)
//IL_0821: Unknown result type (might be due to invalid IL or missing references)
//IL_07cf: Unknown result type (might be due to invalid IL or missing references)
//IL_07de: Unknown result type (might be due to invalid IL or missing references)
//IL_0768: Unknown result type (might be due to invalid IL or missing references)
//IL_076d: Unknown result type (might be due to invalid IL or missing references)
//IL_0771: Unknown result type (might be due to invalid IL or missing references)
if (PEAKChoice.TerrainRandomizerPresent)
{
PEAKChoice.Logger.LogError((object)"< Skipping biome selection logic due to TerrainRandomizer being present. >");
return true;
}
__instance.biomes.Clear();
if (PEAKChoice.ForceLayoutOrder || PEAKChoice.BothMaps)
{
if (!PhotonNetwork.IsMasterClient && PEAKChoice.AwaitRPC)
{
PEAKChoice.Logger.LogWarning((object)"< Using AwaitRPC, instead of calculating. >");
return true;
}
PEAKChoice.Logger.LogInfo((object)"< BEGINNING STEP 1/3 - Layout Order >");
Object.Destroy((Object)(object)GameObject.Find("FogSphereSystem"));
PEAKChoice.Logger.LogInfo((object)"< Deleted FogSphereSystem >");
string[] source = PEAKChoice.LayoutOrder.Split('>');
List<string> list = (from s in source
select s.Trim() into s
where !string.IsNullOrEmpty(s)
select s).ToList();
Transform transform = ((Component)__instance).transform;
foreach (string item5 in list)
{
string name = item5.Trim();
BiomeType val = Additions.ParseBiomeName(name);
__instance.biomes.Add(val);
PEAKChoice.Logger.LogInfo((object)$"Added {val} to biomes list (USING - Layout Order)");
}
PEAKChoice.Logger.LogInfo((object)"< BEGINNING STEP 2/3 - Layout Order >");
Dictionary<string, (Transform, Transform, Transform)> dictionary = new Dictionary<string, (Transform, Transform, Transform)>(StringComparer.OrdinalIgnoreCase);
foreach (Transform item6 in ((Component)__instance).transform)
{
Transform val2 = item6;
if (!((Object)val2).name.StartsWith("Biome_"))
{
continue;
}
foreach (Transform item7 in val2)
{
Transform val3 = item7;
string name2 = ((Object)val3).name;
switch (name2)
{
case "Volcano":
dictionary["Volcano"] = (val3.Find(name2 + "_Segment") ?? val3.Find(name2 + " Segment"), val3.Find(name2 + "_Campfire") ?? val3.Find(name2 + " Campfire"), val2.Find("VolcanoModel"));
PEAKChoice.Logger.LogInfo((object)" --- > GOT TARGET: Volcano");
dictionary["Caldera"] = (val3.Find("Caldera_Segment") ?? val3.Find("Caldera_Segment"), val3.Find("Caldera_Segment/Enterance/LavaTemple/Ruin") ?? val3.Find("Caldera Segment/Enterance/LavaTemple/Ruin"), null);
PEAKChoice.Logger.LogInfo((object)" --- > GOT TARGET: Caldera");
dictionary["Peak"] = (val3.Find("Peak"), val3.Find("Peak/Flag_planted_seagull"), null);
PEAKChoice.Logger.LogInfo((object)" --- > GOT TARGET: Peak");
break;
case "Alpine":
dictionary["Alpine"] = (val3.Find("Snow_Segment"), val3.Find("Snow_Campfire"), val3.Find("SnowStorm"));
PEAKChoice.Logger.LogInfo((object)" --- > GOT TARGET: Alpine");
break;
case "Mesa":
dictionary["Mesa"] = (val3.Find("Desert_Segment"), val3.Find("Desert_Campfire"), null);
PEAKChoice.Logger.LogInfo((object)" --- > GOT TARGET: Mesa");
break;
case "Tropics":
dictionary["Tropics"] = (val3.Find("Jungle_Segment"), val3.Find("Jungle_Campfire"), val3.Find("RainStorm"));
PEAKChoice.Logger.LogInfo((object)" --- > GOT TARGET: Tropics");
break;
case "Roots":
dictionary["Roots"] = (val3.Find("Roots Segment"), val3.Find("Roots_Campfire"), val3.Find("WindStorm"));
PEAKChoice.Logger.LogInfo((object)" --- > GOT TARGET: Roots");
break;
default:
{
Transform val4 = val3.Find(name2 + "_Segment") ?? val3.Find(name2 + " Segment");
Transform val5 = val3.Find(name2 + "_Campfire") ?? val3.Find(name2 + " Campfire");
if ((Object)(object)val4 != (Object)null && (Object)(object)val5 != (Object)null)
{
dictionary[name2] = (val4, val5, val3);
PEAKChoice.Logger.LogInfo((object)(" --- > GOT TARGET: " + name2));
}
break;
}
}
}
}
PEAKChoice.Logger.LogInfo((object)"< BEGINNING STEP 3/3 - Layout Order >");
float num = 0f;
float num2 = 0f;
Transform val6 = null;
Vector3? val7 = null;
float thickness = 0.05f;
float num3 = 0f;
float num4 = 0f;
Transform val8 = null;
for (int i = 0; i < list.Count; i++)
{
string text = list[i];
if (!dictionary.TryGetValue(text, out var value))
{
PEAKChoice.Logger.LogError((object)(" --- > FAILURE ON TARGET - No Biome: " + text));
continue;
}
if ((Object)(object)value.Item1 == (Object)null)
{
PEAKChoice.Logger.LogError((object)(" --- > FAILURE ON TARGET - No Segment: " + text));
continue;
}
Transform parent = value.Item1.parent;
((Component)value.Item1).gameObject.SetActive(true);
value.Item1.SetParent(((Component)__instance).transform, true);
value.Item1.localRotation = Quaternion.identity;
value.Item1.localScale = Vector3.one;
(Vector3 minLocal, Vector3 maxLocal, bool __found, Vector3 Highest) localMeshBounds = Additions.GetLocalMeshBounds(value.Item1, value.Item2, 220f);
Vector3 item = localMeshBounds.minLocal;
Vector3 item2 = localMeshBounds.maxLocal;
bool item3 = localMeshBounds.__found;
Vector3 item4 = localMeshBounds.Highest;
Vector3 val9 = Additions.SampleEdgeWorldPoint(value.Item1, item.z, thickness, wantMax: false);
float num5 = item2.z - item.z;
float num6 = item2.y - item.y;
Vector3 position = value.Item1.position;
if (i > 0 && val7.HasValue)
{
float num7 = val7.Value.z + num2;
float num8 = num7 - val9.z;
float num9 = Mathf.Max(num4, num5) * 2f;
num8 = Mathf.Clamp(num8, 0f - num9, num9);
position.z += num8;
Transform val10 = Additions.FindChildByNameContains(value.Item1, "Ground");
bool flag = false;
float num10 = float.NaN;
Bounds bounds;
if ((Object)(object)val10 != (Object)null)
{
Renderer componentInChildren = ((Component)val10).GetComponentInChildren<Renderer>();
if ((Object)(object)componentInChildren != (Object)null)
{
bounds = componentInChildren.bounds;
num10 = ((Bounds)(ref bounds)).min.y;
flag = true;
}
}
float num11 = float.NaN;
bool flag2 = false;
if ((Object)(object)val8 != (Object)null && (Object)(object)val6 != (Object)null)
{
Renderer componentInChildren2 = ((Component)val8).GetComponentInChildren<Renderer>();
if ((Object)(object)componentInChildren2 != (Object)null)
{
bounds = componentInChildren2.bounds;
num11 = ((Bounds)(ref bounds)).max.y;
flag2 = true;
}
}
if (flag && flag2)
{
float num12 = num11 + num;
float num13 = num12 - num10;
float num14 = Mathf.Max(num3, num6) * 4f;
num13 = Mathf.Clamp(num13, 0f - num14, num14);
position.y += num13;
}
else if ((Object)(object)val6 != (Object)null)
{
float num15 = val7.Value.y + num;
float y = val9.y;
float num16 = num15 - y;
float num17 = Mathf.Max(num3, num6) * 4f;
num16 = Mathf.Clamp(num16, 0f - num17, num17);
position.y += num16;
}
value.Item1.position = position;
}
else
{
value.Item1.position = position;
if (i == 0)
{
DesiredPosition = value.Item1.TransformPoint(new Vector3(0f, 30f, (0f - num5) / 2f));
if (text == "Beach")
{
GameObject val11 = GameObject.Find("Misc/Water");
if ((Object)(object)val11 != (Object)null)
{
val11.transform.position = value.Item1.position;
PEAKChoice.Logger.LogInfo((object)(" --- > Modified water to match " + text));
}
}
}
}
val6 = value.Item1;
num3 = num6;
num4 = num5;
val7 = Additions.SampleEdgeWorldPoint(value.Item1, item2.z, thickness);
val8 = Additions.FindChildByNameContains(value.Item1, "Ground");
}
PEAKChoice.Logger.LogWarning((object)"< Layout Order finished >");
}
else
{
GameObject val12 = GameObject.Find("Map/Biome_3/Alpine");
GameObject val13 = GameObject.Find("Map/Biome_3/Mesa");
GameObject val14 = GameObject.Find("Map/Biome_2/Tropics");
GameObject val15 = GameObject.Find("Map/Biome_2/Roots");
if (Additions.ForcedContains("Mesa"))
{
if ((Object)(object)val12 != (Object)null)
{
val12.gameObject.SetActive(false);
foreach (Transform item8 in val12.transform)
{
Transform val16 = item8;
if ((Object)(object)val16 != (Object)null)
{
((Component)val16).gameObject.SetActive(false);
}
}
}
if ((Object)(object)val13 != (Object)null)
{
val13.gameObject.SetActive(true);
}
}
else if (Additions.ForcedContains("Alpine"))
{
if ((Object)(object)val13 != (Object)null)
{
val13.gameObject.SetActive(false);
foreach (Transform item9 in val13.transform)
{
Transform val17 = item9;
if ((Object)(object)val17 != (Object)null)
{
((Component)val17).gameObject.SetActive(false);
}
}
}
if ((Object)(object)val12 != (Object)null)
{
val12.gameObject.SetActive(true);
}
}
if (Additions.ForcedContains("Roots"))
{
if ((Object)(object)val14 != (Object)null)
{
val14.gameObject.SetActive(false);
foreach (Transform item10 in val14.transform)
{
Transform val18 = item10;
if ((Object)(object)val18 != (Object)null)
{
((Component)val18).gameObject.SetActive(false);
}
}
}
if ((Object)(object)val15 != (Object)null)
{
val15.gameObject.SetActive(true);
}
}
else if (Additions.ForcedContains("Tropics"))
{
if ((Object)(object)val15 != (Object)null)
{
val15.gameObject.SetActive(false);
foreach (Transform item11 in val15.transform)
{
Transform val19 = item11;
if ((Object)(object)val19 != (Object)null)
{
((Component)val19).gameObject.SetActive(false);
}
}
}
if ((Object)(object)val14 != (Object)null)
{
val14.gameObject.SetActive(true);
}
}
Biome val20 = default(Biome);
for (int j = 0; j < ((Component)__instance).transform.childCount; j++)
{
Transform child = ((Component)__instance).transform.GetChild(j);
for (int k = 0; k < child.childCount; k++)
{
if (((Component)child.GetChild(k)).TryGetComponent<Biome>(ref val20))
{
if (Additions.ForcedContains("Mesa") && (int)val20.biomeType == 2)
{
__instance.biomes.Add((BiomeType)6);
PEAKChoice.Logger.LogInfo((object)"Forced Mesa");
}
else if (Additions.ForcedContains("Alpine") && (int)val20.biomeType == 6)
{
__instance.biomes.Add((BiomeType)2);
PEAKChoice.Logger.LogInfo((object)"Forced Alpine");
}
else if (Additions.ForcedContains("Roots") && (int)val20.biomeType == 1)
{
__instance.biomes.Add((BiomeType)7);
PEAKChoice.Logger.LogInfo((object)"Forced Roots");
}
else if (Additions.ForcedContains("Tropics") && (int)val20.biomeType == 7)
{
__instance.biomes.Add((BiomeType)1);
PEAKChoice.Logger.LogInfo((object)"Forced Tropics");
}
else if (!__instance.biomes.Contains(val20.biomeType))
{
__instance.biomes.Add(val20.biomeType);
PEAKChoice.Logger.LogInfo((object)("Added: " + ((Object)val20).name));
}
}
}
}
}
PEAKChoice.Logger.LogWarning((object)"< Patched - DetectBiomes [MapHandlerPatch] >");
return false;
}
[HarmonyPostfix]
[HarmonyPatch("Awake")]
private static void Awake_Postfix(MapHandler __instance)
{
typeof(MapHandler).GetMethod("DetectBiomes", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(__instance, null);
PEAKChoice.Logger.LogWarning((object)"< Patched - Awake [MapHandlerPatch] >");
}
[IteratorStateMachine(typeof(<Start_Postfix>d__3))]
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static IEnumerator Start_Postfix(IEnumerator __result, MapHandler __instance)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Start_Postfix>d__3(0)
{
__result = __result,
__instance = __instance
};
}
}
[HarmonyPatch(typeof(PointPinger))]
internal class PointPingerPatch
{
[HarmonyPatch("ReceivePoint_Rpc")]
[HarmonyPostfix]
public static void Postfix_PingWarp_ReceivePoint_Rpc(PointPinger __instance)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: 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_0040: Unknown result type (might be due to invalid IL or missing references)
RaycastHit val = default(RaycastHit);
if (PExt.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), ref val, HelperExtensions.ToLayerMask((LayerType)1), -1f))
{
PEAKChoice.Logger.LogMessage((object)$"{((Object)((Component)((RaycastHit)(ref val)).collider).gameObject).name} --- > {((RaycastHit)(ref val)).point}");
}
}
}
[HarmonyPatch(typeof(RunManager))]
internal class RunManagerPatch
{
[HarmonyPatch("StartRun")]
[HarmonyPrefix]
public static bool Prefix_PeakToBeach_StartRun(RunManager __instance)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
if (PEAKChoice.ForceLayoutOrder || PEAKChoice.BothMaps)
{
((MonoBehaviour)__instance).StartCoroutine(Additions.Teleport(MapHandlerPatches.DesiredPosition));
PEAKChoice.Logger.LogWarning((object)"< Patched - StartRun [RunManagerPatch] >");
return true;
}
return true;
}
}
[HarmonyPatch(typeof(TornadoSpawner))]
internal class TornadoSpawnerPatch
{
private static readonly FieldInfo fi_untilNext = typeof(TornadoSpawner).GetField("untilNext", BindingFlags.Instance | BindingFlags.NonPublic);
[HarmonyPatch("Update")]
[HarmonyPrefix]
public static bool Patch_TornadoSpawner_Update_Prefix(TornadoSpawner __instance)
{
if (PEAKChoice.NoTornado && PhotonNetwork.IsMasterClient)
{
if (fi_untilNext != null)
{
fi_untilNext.SetValue(__instance, float.MaxValue);
}
return false;
}
return true;
}
}
[HarmonyPatch(typeof(WindChillZone))]
internal class WindChillZonePatch
{
private static readonly FieldInfo fi_untilSwitch = typeof(WindChillZone).GetField("untilSwitch", BindingFlags.Instance | BindingFlags.NonPublic);
private static readonly FieldInfo fi_timeUntilNextWind = typeof(WindChillZone).GetField("timeUntilNextWind", BindingFlags.Instance | BindingFlags.NonPublic);
private static readonly FieldInfo fi_windActive = typeof(WindChillZone).GetField("windActive", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo fi_windMovesItems = typeof(WindChillZone).GetField("windMovesItems", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo fi_currentWindDirection = typeof(WindChillZone).GetField("currentWindDirection", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
public static void ForceDisableZone(WindChillZone zone)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)zone == (Object)null))
{
fi_windActive?.SetValue(zone, false);
fi_windMovesItems?.SetValue(zone, false);
fi_currentWindDirection?.SetValue(zone, Vector3.zero);
fi_timeUntilNextWind?.SetValue(zone, float.MaxValue);
fi_untilSwitch?.SetValue(zone, float.MaxValue);
}
}
public static string FullPath(Transform t)
{
if ((Object)(object)t == (Object)null)
{
return "";
}
List<string> list = new List<string>();
while ((Object)(object)t != (Object)null)
{
list.Add(((Object)t).name);
t = t.parent;
}
list.Reverse();
return string.Join("/", list);
}
public static bool IsSnowStorm(WindChillZone z)
{
return FullPath(((Component)z).transform).IndexOf("SnowStorm", StringComparison.OrdinalIgnoreCase) >= 0;
}
public static bool IsWindStorm(WindChillZone z)
{
return FullPath(((Component)z).transform).IndexOf("WindStorm", StringComparison.OrdinalIgnoreCase) >= 0;
}
public static bool IsRainStorm(WindChillZone z)
{
return FullPath(((Component)z).transform).IndexOf("RainStorm", StringComparison.OrdinalIgnoreCase) >= 0;
}
[HarmonyPrefix]
[HarmonyPatch("HandleTime")]
private static bool HandleTime_Prefix(WindChillZone __instance)
{
if (!PhotonNetwork.IsMasterClient)
{
return true;
}
if ((PEAKChoice.NoBlizard && IsSnowStorm(__instance)) || (PEAKChoice.NoWind && IsWindStorm(__instance)) || (PEAKChoice.NoRain && IsRainStorm(__instance)))
{
ForceDisableZone(__instance);
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch("RPCA_ToggleWind")]
private static bool RPCA_ToggleWind_Prefix(WindChillZone __instance, bool set, Vector3 windDir, float untilSwitch)
{
if ((PEAKChoice.NoBlizard && IsSnowStorm(__instance)) || (PEAKChoice.NoWind && IsWindStorm(__instance)) || (PEAKChoice.NoRain && IsRainStorm(__instance)))
{
ForceDisableZone(__instance);
return false;
}
return true;
}
[HarmonyPostfix]
[HarmonyPatch("FixedUpdate")]
private static void FixedUpdate_Postfix(WindChillZone __instance)
{
if ((PEAKChoice.NoBlizard && IsSnowStorm(__instance)) || (PEAKChoice.NoWind && IsWindStorm(__instance)) || (PEAKChoice.NoRain && IsRainStorm(__instance)))
{
ForceDisableZone(__instance);
}
}
}
}
namespace PEAKChoice.Modules
{
public static class Helper
{
[CompilerGenerated]
private sealed class <GetComponentsInChildrenByTypeName>d__1 : IEnumerable<Component>, IEnumerable, IEnumerator<Component>, IEnumerator, IDisposable
{
private int <>1__state;
private Component <>2__current;
private int <>l__initialThreadId;
private Transform root;
public Transform <>3__root;
private bool includeInactive;
public bool <>3__includeInactive;
private string typeName;
public string <>3__typeName;
private Component[] <comps>5__2;
private int <i>5__3;
Component IEnumerator<Component>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <GetComponentsInChildrenByTypeName>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<comps>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
goto IL_00a7;
}
<>1__state = -1;
if ((Object)(object)root == (Object)null)
{
return false;
}
<comps>5__2 = ((Component)root).GetComponentsInChildren<Component>(includeInactive);
<i>5__3 = 0;
goto IL_00b7;
IL_00a7:
<i>5__3++;
goto IL_00b7;
IL_00b7:
if (<i>5__3 < <comps>5__2.Length)
{
Component val = <comps>5__2[<i>5__3];
if (!((Object)(object)val == (Object)null))
{
Type type = ((object)val).GetType();
if (string.Equals(type.Name, typeName, StringComparison.Ordinal) || string.Equals(type.FullName, typeName, StringComparison.Ordinal))
{
<>2__current = val;
<>1__state = 1;
return true;
}
}
goto IL_00a7;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<Component> IEnumerable<Component>.GetEnumerator()
{
<GetComponentsInChildrenByTypeName>d__1 <GetComponentsInChildrenByTypeName>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<GetComponentsInChildrenByTypeName>d__ = this;
}
else
{
<GetComponentsInChildrenByTypeName>d__ = new <GetComponentsInChildrenByTypeName>d__1(0);
}
<GetComponentsInChildrenByTypeName>d__.root = <>3__root;
<GetComponentsInChildrenByTypeName>d__.typeName = <>3__typeName;
<GetComponentsInChildrenByTypeName>d__.includeInactive = <>3__includeInactive;
return <GetComponentsInChildrenByTypeName>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<Component>)this).GetEnumerator();
}
}
internal static Component GetComponentInChildrenByTypeName(Transform root, string typeName, bool includeInactive = true)
{
if ((Object)(object)root == (Object)null)
{
return null;
}
Component[] componentsInChildren = ((Component)root).GetComponentsInChildren<Component>(includeInactive);
foreach (Component val in componentsInChildren)
{
if (!((Object)(object)val == (Object)null))
{
Type type = ((object)val).GetType();
if (string.Equals(type.Name, typeName, StringComparison.Ordinal) || string.Equals(type.FullName, typeName, StringComparison.Ordinal))
{
return val;
}
}
}
return null;
}
[IteratorStateMachine(typeof(<GetComponentsInChildrenByTypeName>d__1))]
internal static IEnumerable<Component> GetComponentsInChildrenByTypeName(Transform root, string typeName, bool includeInactive = true)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GetComponentsInChildrenByTypeName>d__1(-2)
{
<>3__root = root,
<>3__typeName = typeName,
<>3__includeInactive = includeInactive
};
}
internal static bool TryInvokeMethod(Component target, string methodName, object[] args = null)
{
if ((Object)(object)target == (Object)null)
{
return false;
}
try
{
MethodInfo method = ((object)target).GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (method == null)
{
PEAKChoice.Logger.LogDebug((object)("TryInvokeMethod: method '" + methodName + "' not found on '" + ((object)target).GetType().FullName + "'"));
return false;
}
ParameterInfo[] parameters = method.GetParameters();
object[] array;
if (args == null)
{
array = new object[parameters.Length];
for (int i = 0; i < parameters.Length; i++)
{
Type parameterType = parameters[i].ParameterType;
array[i] = (parameterType.IsValueType ? Activator.CreateInstance(parameterType) : null);
}
}
else if (args.Length == parameters.Length)
{
array = args;
}
else
{
array = new object[parameters.Length];
int num = Math.Min(args.Length, parameters.Length);
for (int j = 0; j < num; j++)
{
array[j] = args[j];
}
for (int k = num; k < parameters.Length; k++)
{
Type parameterType2 = parameters[k].ParameterType;
array[k] = (parameterType2.IsValueType ? Activator.CreateInstance(parameterType2) : null);
}
}
method.Invoke(target, array);
return true;
}
catch (Exception arg)
{
PEAKChoice.Logger.LogError((object)$"TryInvokeMethod: failed invoking {methodName} on {((object)target).GetType().Name}: {arg}");
return false;
}
}
internal static int AssignMasterClientViewID(GameObject go)
{
int num = PhotonNetwork.AllocateViewID(false);
PhotonView component = go.GetComponent<PhotonView>();
component.ViewID = num;
return num;
}
}
public class MapHelper
{
internal static bool SegmentHasTerrain(Transform segParent, MapSegment seg)
{
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
try
{
if (Additions.GetLocalMeshBounds(segParent, ((Object)(object)seg.segmentCampfire != (Object)null) ? seg.segmentCampfire.transform : null).__found)
{
return true;
}
}
catch
{
}
Renderer[] componentsInChildren = ((Component)segParent).GetComponentsInChildren<Renderer>(true);
int num = 0;
Renderer[] array = componentsInChildren;
Vector3 size;
foreach (Renderer val in array)
{
if ((Object)(object)val == (Object)null || !val.enabled || !((Component)val).gameObject.activeInHierarchy)
{
continue;
}
string text = ((Object)((Component)val).gameObject).name.ToLowerInvariant();
if (!text.Contains("cloud") && !text.Contains("vfx") && !text.Contains("smoke") && !text.Contains("plane") && !text.Contains("lod"))
{
Bounds bounds = val.bounds;
size = ((Bounds)(ref bounds)).size;
if (!(((Vector3)(ref size)).sqrMagnitude < 0.0001f) && !(((Bounds)(ref bounds)).size.x * ((Bounds)(ref bounds)).size.y * ((Bounds)(ref bounds)).size.z > 5000000f))
{
num++;
}
}
}
if (num >= 1)
{
return true;
}
MeshFilter[] componentsInChildren2 = ((Component)segParent).GetComponentsInChildren<MeshFilter>(true);
MeshFilter[] array2 = componentsInChildren2;
foreach (MeshFilter val2 in array2)
{
if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.sharedMesh == (Object)null) && val2.sharedMesh.vertexCount > 20)
{
return true;
}
}
Collider[] componentsInChildren3 = ((Component)segParent).GetComponentsInChildren<Collider>(true);
Collider[] array3 = componentsInChildren3;
foreach (Collider val3 in array3)
{
if (!((Object)(object)val3 == (Object)null))
{
Bounds bounds2 = val3.bounds;
size = ((Bounds)(ref bounds2)).size;
if (((Vector3)(ref size)).sqrMagnitude > 0.01f)
{
return true;
}
}
}
return false;
}
internal static string GetHierarchyPath(GameObject go)
{
List<string> list = new List<string>();
Transform val = go.transform;
while ((Object)(object)val != (Object)null)
{
list.Add(((Object)val).name);
val = val.parent;
}
list.Reverse();
return string.Join("/", list);
}
internal static bool CampfireNeedsGeneration(MapSegment seg, Transform segParent)
{
try
{
GameObject campGO = seg.segmentCampfire;
if ((Object)(object)campGO == (Object)null)
{
Transform val = Additions.FindChildByNameContains(segParent, "Campfire");
if ((Object)(object)val != (Object)null)
{
try
{
FieldInfo field = typeof(MapSegment).GetField("segmentCampfire", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(seg, ((Component)val).gameObject);
}
}
catch
{
}
campGO = ((Component)val).gameObject;
}
}
if ((Object)(object)campGO == (Object)null)
{
return false;
}
if (campGO.GetComponentsInChildren<Renderer>(true).Any(delegate(Renderer r)
{
//IL_0017: 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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)r != (Object)null && ((Component)r).gameObject.activeInHierarchy)
{
Bounds bounds = r.bounds;
Vector3 size = ((Bounds)(ref bounds)).size;
return ((Vector3)(ref size)).sqrMagnitude > 0.0001f;
}
return false;
}))
{
return false;
}
if (campGO.transform.childCount > 0)
{
if (!campGO.GetComponentsInChildren<Transform>(true).Any((Transform t) => (Object)(object)t != (Object)(object)campGO.transform && (((Component)t).gameObject.activeInHierarchy || (Object)(object)((Component)t).GetComponent<Renderer>() != (Object)null || (Object)(object)((Component)t).GetComponent<MeshFilter>() != (Object)null)))
{
return true;
}
return false;
}
int num = campGO.GetComponentsInChildren<PhotonView>(true).Length;
return true;
}
catch
{
return true;
}
}
internal static void CollectLateLevelGenSteps(PropGrouper grouper, List<LevelGenStep> results)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Invalid comparison between Unknown and I4
results.Clear();
LevelGenStep[] componentsInChildren = ((Component)grouper).GetComponentsInChildren<LevelGenStep>(true);
LevelGenStep[] array = componentsInChildren;
foreach (LevelGenStep val in array)
{
PropGrouper componentInParent = ((Component)val).GetComponentInParent<PropGrouper>();
try
{
if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.timing == 1)
{
results.Add(val);
}
}
catch
{
if ((Object)(object)componentInParent == (Object)(object)grouper)
{
results.Add(val);
}
}
}
}
internal static void RunLateLevelGenSteps(List<LevelGenStep> steps)
{
foreach (LevelGenStep step in steps)
{
try
{
step.Execute();
}
catch (Exception arg)
{
PEAKChoice.Logger.LogWarning((object)$"[Gen] Late LevelGenStep Execute threw: {arg}");
}
}
}
internal static (HashSet<int> indices, HashSet<string> names) ParseGenerateSegmentsList(string raw)
{
HashSet<int> hashSet = new HashSet<int>();
HashSet<string> hashSet2 = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
if (string.IsNullOrWhiteSpace(raw))
{
return (hashSet, hashSet2);
}
IEnumerable<string> enumerable = from s in raw.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)
select s.Trim();
foreach (string item in enumerable)
{
Match match = Regex.Match(item, "^(\\d+)\\s*-\\s*(\\d+)$");
int result3;
if (match.Success && int.TryParse(match.Groups[1].Value, out var result) && int.TryParse(match.Groups[2].Value, out var result2))
{
if (result > result2)
{
int num = result;
result = result2;
result2 = num;
}
for (int i = result; i <= result2; i++)
{
hashSet.Add(i);
}
}
else if (int.TryParse(item, out result3))
{
hashSet.Add(result3);
}
else
{
hashSet2.Add(item);
}
}
return (hashSet, hashSet2);
}
internal static bool ShouldGenerateSegment(int segIndex, MapSegment seg)
{
string generateSegmentsList = PEAKChoice.GenerateSegmentsList;
if (string.IsNullOrWhiteSpace(generateSegmentsList))
{
return true;
}
var (hashSet, hashSet2) = ParseGenerateSegmentsList(generateSegmentsList);
if (hashSet.Contains(segIndex))
{
return true;
}
if (seg != null && (Object)(object)seg.segmentParent != (Object)null)
{
string text = ((Object)seg.segmentParent).name ?? "";
foreach (string item in hashSet2)
{
if (text.IndexOf(item, StringComparison.OrdinalIgnoreCase) >= 0)
{
return true;
}
}
}
return false;
}
}
}
namespace PEAKChoice.Features
{
public static class Additions
{
[CompilerGenerated]
private sealed class <Teleport>d__9 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Vector3 Position;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Teleport>d__9(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if ((Object)(object)Character.localCharacter != (Object)null)
{
PEAKChoice.WarpPlayer?.Invoke(Character.localCharacter, new object[2] { Position, true });
PEAKChoice.Logger.LogInfo((object)$" < Teleported you to: {Position} >");
}
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static Random rng = new Random();
internal static readonly Dictionary<string, (Transform seg, Transform fire, Vector3 segPos, Vector3 firePos)> TargetPositions = new Dictionary<string, (Transform, Transform, Vector3, Vector3)>(StringComparer.OrdinalIgnoreCase);
internal static int GetMasterSeed()
{
if (PEAKChoice.Seed > 0)
{
return PEAKChoice.Seed;
}
PEAKChoice.Seed = Random.Range(1, int.MaxValue);
return PEAKChoice.Seed;
}
internal static int HashSeed(int master, int index)
{
ulong num = (uint)master;
num = (ulong)((long)num * -7046029254386353131L + ((long)(uint)index + 1L));
num ^= num >> 33;
num *= 18397679294719823053uL;
num ^= num >> 33;
return (int)(num & 0x7FFFFFFF);
}
internal static bool ForcedContains(string value)
{
string value2 = value;
if (PEAKChoice.Forced == null || value2 == null)
{
return false;
}
return PEAKChoice.Forced.Any((string f) => string.Equals(f?.Trim(), value2.Trim(), StringComparison.OrdinalIgnoreCase));
}
internal static string[] GetTargetBiome()
{
string raw = (PEAKChoice.ForceMap ?? "Any").Trim();
string raw2 = (PEAKChoice.ForceMap2 ?? "Any").Trim();
string text = ResolveMesaAlpine(raw);
string text2 = ResolveJungleRoots(raw2);
List<string> list = new List<string>();
if (!string.IsNullOrEmpty(text))
{
list.Add(text);
}
if (!string.IsNullOrEmpty(text2))
{
list.Add(text2);
}
return list.ToArray();
}
private static string ResolveMesaAlpine(string raw)
{
if (string.IsNullOrWhiteSpace(raw))
{
raw = "Any";
}
if (raw.IndexOfAny(new char[3] { ',', ';', '|' }) >= 0)
{
raw = (from s in raw.Split(new char[3] { ',', ';', '|' }, StringSplitOptions.RemoveEmptyEntries)
select s.Trim()).FirstOrDefault() ?? "Any";
}
if (string.Equals(raw, "Mesa", StringComparison.OrdinalIgnoreCase))
{
return "Mesa";
}
if (string.Equals(raw, "Alpine", StringComparison.OrdinalIgnoreCase))
{
return "Alpine";
}
if (string.Equals(raw, "Any", StringComparison.OrdinalIgnoreCase))
{
int num = rng.Next(0, 100);
if (num < PEAKChoice.AnyWeight)
{
return "Alpine";
}
return "Mesa";
}
return NormalizeA(raw);
}
private static string ResolveJungleRoots(string raw)
{
if (string.IsNullOrWhiteSpace(raw))
{
raw = "Any";
}
if (raw.IndexOfAny(new char[3] { ',', ';', '|' }) >= 0)
{
raw = (from s in raw.Split(new char[3] { ',', ';', '|' }, StringSplitOptions.RemoveEmptyEntries)
select s.Trim()).FirstOrDefault() ?? "Any";
}
if (string.Equals(raw, "Tropics", StringComparison.OrdinalIgnoreCase))
{
return "Tropics";
}
if (string.Equals(raw, "Roots", StringComparison.OrdinalIgnoreCase))
{
return "Roots";
}
if (string.Equals(raw, "Any", StringComparison.OrdinalIgnoreCase))
{
int num = rng.Next(0, 100);
if (num < PEAKChoice.AnyWeight2)
{
return "Tropics";
}
return "Roots";
}
return NormalizeB(raw);
}
private static string NormalizeA(string token)
{
if (string.IsNullOrWhiteSpace(token))
{
return "Mesa";
}
token = token.Trim();
if (string.Equals(token, "mesa", StringComparison.OrdinalIgnoreCase))
{
return "Mesa";
}
if (string.Equals(token, "alpine", StringComparison.OrdinalIgnoreCase))
{
return "Alpine";
}
return char.ToUpperInvariant(token[0]) + ((token.Length > 1) ? token.Substring(1) : "");
}
private static string NormalizeB(string token)
{
if (string.IsNullOrWhiteSpace(token))
{
return "Tropics";
}
token = token.Trim();
if (string.Equals(token, "tropics", StringComparison.OrdinalIgnoreCase))
{
return "Tropics";
}
if (string.Equals(token, "roots", StringComparison.OrdinalIgnoreCase))
{
return "Roots";
}
return char.ToUpperInvariant(token[0]) + ((token.Length > 1) ? token.Substring(1) : "");
}
[IteratorStateMachine(typeof(<Teleport>d__9))]
internal static IEnumerator Teleport(Vector3 Position)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Teleport>d__9(0)
{
Position = Position
};
}
internal static BiomeType ParseBiomeName(string name)
{
//IL_0117: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: 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_010b: 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_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
return (BiomeType)(name.ToLower() switch
{
"alpine" => 2,
"mesa" => 6,
"beach" => 0,
"tropics" => 1,
"roots" => 7,
"caldera" => 3,
"volcano" => 3,
"peak" => 5,
_ => 0,
});
}
internal static Transform FindChildByNameContains(Transform root, string keyword)
{
Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
foreach (Transform val in componentsInChildren)
{
if (((Object)((Component)val).gameObject).name.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0)
{
return val;
}
}
return null;
}
internal static (Vector3 minLocal, Vector3 maxLocal, bool __found, Vector3 Highest) GetLocalMeshBounds(Transform root, Transform? anchor = null, float anchorRadius = 200f)
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0359: Unknown result type (might be due to invalid IL or missing references)
//IL_035e: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
//IL_03da: Unknown result type (might be due to invalid IL or missing references)
//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
//IL_040c: Unknown result type (might be due to invalid IL or missing references)
//IL_0418: Unknown result type (might be due to invalid IL or missing references)
//IL_042b: Unknown result type (might be due to invalid IL or missing references)
//IL_0437: Unknown result type (might be due to invalid IL or missing references)
//IL_0443: Unknown result type (might be due to invalid IL or missing references)
//IL_0454: Unknown result type (might be due to invalid IL or missing references)
//IL_0459: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_0494: Unknown result type (might be due to invalid IL or missing references)
//IL_0496: Unknown result type (might be due to invalid IL or missing references)
//IL_0499: Unknown result type (might be due to invalid IL or missing references)
//IL_0481: Unknown result type (might be due to invalid IL or missing references)
//IL_0486: Unknown result type (might be due to invalid IL or missing references)
//IL_048c: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
Transform val = FindChildByNameContains(root, "Ground");
float num = float.MinValue;
if ((Object)(object)val != (Object)null)
{
Renderer componentInChildren = ((Component)val).GetComponentInChildren<Renderer>();
if ((Object)(object)componentInChildren != (Object)null)
{
Bounds val2 = root.InverseTransformBounds(componentInChildren.bounds);
num = ((Bounds)(ref val2)).max.y;
}
}
Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true);
if (componentsInChildren == null || componentsInChildren.Length == 0)
{
return (Vector3.zero, Vector3.zero, false, Vector3.zero);
}
string[] array = new string[7] { "cloud", "sphere", "vfx", "smoke", "lod", "ring", "plane" };
List<(Renderer, Bounds, float, string)> list = new List<(Renderer, Bounds, float, string)>();
Renderer[] array2 = componentsInChildren;
foreach (Renderer val3 in array2)
{
try
{
if (!((Component)val3).gameObject.activeInHierarchy || !val3.enabled)
{
continue;
}
Bounds item = root.InverseTransformBounds(val3.bounds);
string text = ((Object)((Component)val3).gameObject).name.ToLowerInvariant();
bool flag = false;
string[] array3 = array;
foreach (string value in array3)
{
if (text.Contains(value))
{
flag = true;
break;
}
}
if (!flag && (!((Object)(object)val != (Object)null) || !(((Bounds)(ref item)).max.y < num - 5f)) && !float.IsNaN(((Bounds)(ref item)).size.x) && !float.IsInfinity(((Bounds)(ref item)).size.x) && !float.IsNaN(((Bounds)(ref item)).size.y) && !float.IsInfinity(((Bounds)(ref item)).size.y) && !float.IsNaN(((Bounds)(ref item)).size.z) && !float.IsInfinity(((Bounds)(ref item)).size.z))
{
float item2 = ((Bounds)(ref item)).size.x * ((Bounds)(ref item)).size.y * ((Bounds)(ref item)).size.z;
list.Add((val3, item, item2, ((Object)((Component)val3).gameObject).name));
}
}
catch
{
}
}
if (list.Count == 0)
{
return (Vector3.zero, Vector3.zero, false, Vector3.zero);
}
float[] array4 = (from c in list
select Math.Max(0f, c.vol) into v
orderby v
select v).ToArray();
float num2 = array4[array4.Length / 2];
float val4 = 5000000f;
float val5 = num2 * 100f;
float allowedCap = Math.Max(val4, val5);
List<(Renderer, Bounds, float, string)> list2 = list.Where<(Renderer, Bounds, float, string)>(((Renderer r, Bounds localB, float vol, string name) c) => c.vol > 0f && c.vol <= allowedCap).ToList();
if (list2.Count == 0 && list.Count > 1)
{
List<(Renderer, Bounds, float, string)> list3 = list.OrderBy<(Renderer, Bounds, float, string), float>(((Renderer r, Bounds localB, float vol, string name) c) => c.vol).ToList();
list2 = list3.Take(list3.Count - 1).ToList();
}
if (list2.Count == 0)
{
return (Vector3.zero, Vector3.zero, false, Vector3.zero);
}
Vector3 val6 = default(Vector3);
((Vector3)(ref val6))..ctor(float.MaxValue, float.MaxValue, float.MaxValue);
Vector3 val7 = default(Vector3);
((Vector3)(ref val7))..ctor(float.MinValue, float.MinValue, float.MinValue);
float num3 = float.MinValue;
Vector3 item3 = Vector3.zero;
int num4 = 0;
foreach (var item5 in list2)
{
Bounds item4 = item5.Item2;
val6 = Vector3.Min(val6, ((Bounds)(ref item4)).min);
val7 = Vector3.Max(val7, ((Bounds)(ref item4)).max);
if (((Bounds)(ref item4)).max.y > num3)
{
num3 = ((Bounds)(ref item4)).max.y;
item3 = new Vector3((((Bounds)(ref item4)).min.x + ((Bounds)(ref item4)).max.x) * 0.5f, ((Bounds)(ref item4)).max.y, (((Bounds)(ref item4)).min.z + ((Bounds)(ref item4)).max.z) * 0.5f);
}
num4++;
}
if (num4 == 0)
{
return (Vector3.zero, Vector3.zero, false, item3);
}
return (val6, val7, true, item3);
}
internal static Bounds InverseTransformBounds(this Transform root, Bounds b)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: 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_0062: 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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: 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_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
Vector3[] array = (Vector3[])(object)new Vector3[8]
{
new Vector3(((Bounds)(ref b)).min.x, ((Bounds)(ref b)).min.y, ((Bounds)(ref b)).min.z),
new Vector3(((Bounds)(ref b)).max.x, ((Bounds)(ref b)).min.y, ((Bounds)(ref b)).min.z),
new Vector3(((Bounds)(ref b)).min.x, ((Bounds)(ref b)).max.y, ((Bounds)(ref b)).min.z),
new Vector3(((Bounds)(ref b)).min.x, ((Bounds)(ref b)).min.y, ((Bounds)(ref b)).max.z),
new Vector3(((Bounds)(ref b)).max.x, ((Bounds)(ref b)).max.y, ((Bounds)(ref b)).min.z),
new Vector3(((Bounds)(ref b)).min.x, ((Bounds)(ref b)).max.y, ((Bounds)(ref b)).max.z),
new Vector3(((Bounds)(ref b)).max.x, ((Bounds)(ref b)).min.y, ((Bounds)(ref b)).max.z),
new Vector3(((Bounds)(ref b)).max.x, ((Bounds)(ref b)).max.y, ((Bounds)(ref b)).max.z)
};
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(float.MaxValue, float.MaxValue, float.MaxValue);
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(float.MinValue, float.MinValue, float.MinValue);
Vector3[] array2 = array;
foreach (Vector3 val3 in array2)
{
Vector3 val4 = root.InverseTransformPoint(val3);
val = Vector3.Min(val, val4);
val2 = Vector3.Max(val2, val4);
}
return new Bounds((val + val2) * 0.5f, val2 - val);
}
internal static Vector3 SampleEdgeWorldPoint(Transform root, float sampleLocalZ, float thickness = 0.05f, bool wantMax = true, bool wantYMiddle = false)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: 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)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
Transform val = FindChildByNameContains(root, "Ground");
float num = float.MinValue;
if ((Object)(object)val != (Object)null)
{
Renderer componentInChildren = ((Component)val).GetComponentInChildren<Renderer>();
if ((Object)(object)componentInChildren != (Object)null)
{
Bounds val2 = root.InverseTransformBounds(componentInChildren.bounds);
num = ((Bounds)(ref val2)).max.y;
}
}
Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true);
List<Vector3> list = new List<Vector3>();
List<float> list2 = new List<float>();
string[] array = new string[7] { "cloud", "sphere", "vfx", "smoke", "lod", "ring", "plane" };
Renderer[] array2 = componentsInChildren;
Vector3 val5 = default(Vector3);
foreach (Renderer val3 in array2)
{
if (!((Component)val3).gameObject.activeInHierarchy || !val3.enabled)
{
continue;
}
Bounds val4 = root.InverseTransformBounds(val3.bounds);
string text = ((Object)((Component)val3).gameObject).name.ToLowerInvariant();
bool flag = false;
string[] array3 = array;
foreach (string value in array3)
{
if (text.Contains(value))
{
flag = true;
break;
}
}
if (!flag && (!((Object)(object)val != (Object)null) || !(((Bounds)(ref val4)).max.y < num - 5f)) && !(sampleLocalZ + thickness < ((Bounds)(ref val4)).min.z) && !(sampleLocalZ - thickness > ((Bounds)(ref val4)).max.z))
{
((Vector3)(ref val5))..ctor((((Bounds)(ref val4)).min.x + ((Bounds)(ref val4)).max.x) * 0.5f, wantMax ? ((Bounds)(ref val4)).max.y : ((Bounds)(ref val4)).min.y, Mathf.Clamp(sampleLocalZ, ((Bounds)(ref val4)).min.z, ((Bounds)(ref val4)).max.z));
list.Add(val5);
list2.Add(val5.y);
}
}
if (list.Count == 0)
{
(Vector3 minLocal, Vector3 maxLocal, bool __found, Vector3 Highest) localMeshBounds = GetLocalMeshBounds(root);
Vector3 item = localMeshBounds.minLocal;
Vector3 item2 = localMeshBounds.maxLocal;
bool item3 = localMeshBounds.__found;
Vector3 item4 = localMeshBounds.Highest;
float num2 = (wantMax ? item2.y : item.y);
return root.TransformPoint(new Vector3(0f, num2, sampleLocalZ));
}
list2.Sort();
float num3 = list2[list2.Count / 2];
Vector3 val6 = list[0];
float num4 = Mathf.Abs(list[0].y - num3);
for (int k = 1; k < list.Count; k++)
{
float num5 = Mathf.Abs(list[k].y - num3);
if (num5 < num4)
{
num4 = num5;
val6 = list[k];
}
}
return root.TransformPoint(val6);
}
}
public static class FileManager
{
internal static ConfigEntry<T> BindConfig<T>(string Header, string Features, T Value, string? Info = "")
{
return PEAKChoice.Instance.config.Bind<T>(Header, Features, Value, Info);
}
internal static void InitializeConfig()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
string text = Path.Combine(Paths.ConfigPath, "DAa Mods/PEAKChoice");
if (!Directory.Exists(text))
{
Directory.CreateDirectory(text);
}
PEAKChoice.Instance.config = new ConfigFile(Path.Combine(text, "config.cfg"), true);
if (BindConfig("Version", "Current Version", "").Value != "1.3.1")
{
PEAKChoice.Instance.config.Clear();
}
DefineConfig();
PEAKChoice.Logger.LogWarning((object)"< Config initialized >");
}
internal static void DefineConfig()
{
BindConfig("Version", "Current Version", "1.3.1", "Autoupdates the config / lets the mod know what version of config it is.");
PEAKChoice.ForceMap = BindConfig("MAP", "ForceMap Biome3", "Any", "Biome_3: Alpine | Mesa | Any\n(HOST ONLY)").Value;
PEAKChoice.AnyWeight = BindConfig("MAP", "AnyWeight Biome3", 50, "Less = Alpine | More = Mesa.\n(HOST ONLY)").Value;
PEAKChoice.ForceMap2 = BindConfig("MAP", "ForceMap Biome2", "Any", "Biome_2: Tropics | Roots | Any\n(HOST ONLY)").Value;
PEAKChoice.AnyWeight2 = BindConfig("MAP", "AnyWeight Biome2", 50, "Less = Tropics | More = Roots.\n(HOST ONLY)").Value;
PEAKChoice.BothMaps = BindConfig("MAP", "AllSegments", Value: false, "[DOES NOT FUNCTION] Spawn in all map segments.\n(ALL CLIENTS)").Value;
PEAKChoice.LayoutOrder = BindConfig("MAP", "LayoutOrder", "Beach > Tropics > Roots > Alpine > Mesa > Caldera > Volcano > Peak", "Layout order").Value;
PEAKChoice.ForceLayoutOrder = BindConfig("MAP", "ForceLayoutOrder", Value: false, "[DOES NOT FUNCTION] Maps will be placed in the layout order instead. You can also remove any maps if you remove them from the layout.\nAdditionally, you might want to use a flight mod too!\n(HOST ONLY)").Value;
PEAKChoice.PeakZone = BindConfig("MAP", "PeakZone", "Peak", "[DOES NOT FUNCTION] Choose any map segment to be the peak.\n(HOST ONLY)").Value;
PEAKChoice.StartingZone = BindConfig("MAP", "StartingZone", "Beach", "[DOES NOT FUNCTION] Starting zone, will be ignored with ForceLayoutOrder.\n(HOST ONLY)").Value;
PEAKChoice.UseTerrainRandomizerCompat = BindConfig("METHODS", "TerrainRandomizerCompatibility", Value: true, "When true: if a TerrainRandomizer is present, PEAKChoice will avoid doing full segment terrain generation and only manage campfires. \n(HOST ONLY)").Value;
PEAKChoice.GenerateSegmentsList = BindConfig("METHODS", "GenerateSegmentsList", "1-2", "Comma-separated segment indices or names or ranges to force generation when TerrainRandomizer is present. \nEmpty => generate all. Examples: \"1,3,5\" or \"Roots,Caldera\" or \"1-3,Roots\"\n(HOST ONLY)").Value;
PEAKChoice.GenerateMissingTerrain = BindConfig("METHODS", "GenerateMissingTerrain", Value: true, "Allow generation of missing segments. \n(HOST ONLY)").Value;
PEAKChoice.Seed = BindConfig("METHODS", "Seed", 0, "Int Value, 0 = random").Value;
PEAKChoice.AwaitRPC = BindConfig("METHODS", "AwaitRPC", Value: false, "[DOES NOT FUNCTION] Wait for host to send you calculated locations instead of doing it yourself.\n(CLIENT ONLY)").Value;
PEAKChoice.NoWind = BindConfig("MAP EFFECTS", "No Wind", Value: false, "Removes the wind in Roots.\n(HOST ONLY?)").Value;
PEAKChoice.NoTornado = BindConfig("MAP EFFECTS", "No Tornado", Value: false, "Removes the tornados in Mesa.\n(HOST ONLY)").Value;
PEAKChoice.NoBlizard = BindConfig("MAP EFFECTS", "No Blizard", Value: false, "Removes the blizard in Alpine.\n(HOST ONLY?)").Value;
PEAKChoice.NoRain = BindConfig("MAP EFFECTS", "No Rain", Value: false, "Removes the rain in Tropics.\n(HOST ONLY?)").Value;
PEAKChoice.AlwaysDay = BindConfig("MAP EFFECTS", "Always Day", Value: false, "Makes it always day.\n(HOST ONLY)").Value;
PEAKChoice.AlwaysNight = BindConfig("MAP EFFECTS", "Always Night", Value: false, "Makes it always night.\n(HOST ONLY)").Value;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}