using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Photon.Pun;
using Photon.Realtime;
using PhotonCustomPropsUtils;
using TerrainRandomiser.TerrainGeneration;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.UIElements;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TerrainRandomiser")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: AssemblyInformationalVersion("1.0.1+c61c63c35f119bf6bd47dbf37d80a325bf8313bd")]
[assembly: AssemblyProduct("TerrainRandomiser")]
[assembly: AssemblyTitle("TerrainRandomiser")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
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;
}
}
}
namespace TerrainRandomiser
{
public static class BiomeDatabase
{
public static List<SectionData> GetAllSections()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
return new List<SectionData>
{
new SectionData
{
sectionName = "Biome_1",
biomes = new List<BiomeData>
{
new BiomeData
{
biomeName = "Shore",
biomeType = (BiomeType)0,
variants = new List<string> { "Default", "SnakeBeach", "RedBeach", "BlueBeach", "JellyHell", "BlackSand" },
variantSelectionType = VariantSelectionType.BiomeVariant
}
}
},
new SectionData
{
sectionName = "Biome_2",
biomes = new List<BiomeData>
{
new BiomeData
{
biomeName = "Tropics",
biomeType = (BiomeType)1,
variants = new List<string> { "Default", "Lava", "Pillars", "Thorny", "Bombs", "Ivy", "SkyJungle" },
variantSelectionType = VariantSelectionType.BiomeVariant
},
new BiomeData
{
biomeName = "Roots",
biomeType = (BiomeType)7,
variants = new List<string> { "Default", "Cave Mania", "Deep Water", "Bomb Beetle", "Deep Woods", "Clearcut" },
variantSelectionType = VariantSelectionType.VariantObject
}
}
},
new SectionData
{
sectionName = "Biome_3",
biomes = new List<BiomeData>
{
new BiomeData
{
biomeName = "Alpine",
biomeType = (BiomeType)2,
variants = new List<string> { "Default", "Lava", "Spiky", "GeyserHell" },
variantSelectionType = VariantSelectionType.BiomeVariant
},
new BiomeData
{
biomeName = "Mesa",
biomeType = (BiomeType)6,
variants = new List<string> { "NoVariant", "ScorpionsHell", "CacusHell", "CactusForest", "DynamiteHell", "TornadoHell", "TumblerHell" },
variantSelectionType = VariantSelectionType.VariantObject
}
}
}
};
}
public static List<SectionData> GetRuntimeValidSections()
{
HashSet<string> validBiomeNames = Enum.GetNames(typeof(BiomeType)).ToHashSet();
List<SectionData> allSections = GetAllSections();
return (from section in allSections
select new SectionData
{
sectionName = section.sectionName,
biomes = section.biomes.Where((BiomeData b) => validBiomeNames.Contains(b.biomeName)).ToList()
} into section
where section.biomes.Count > 0
select section).ToList();
}
}
public enum VariantSelectionType
{
BiomeVariant,
VariantObject
}
[Serializable]
public class MapSettings
{
public bool enableRandomiser;
public int seed;
public bool autoRandomSeed;
public bool fullyRandom;
public List<BiomeSettings> biomes = new List<BiomeSettings>();
public static MapSettings CreateDefaultMapSettings()
{
List<SectionData> runtimeValidSections = BiomeDatabase.GetRuntimeValidSections();
List<BiomeSettings> list = new List<BiomeSettings>();
foreach (SectionData item in runtimeValidSections)
{
if (item.biomes.Count != 0)
{
BiomeData biomeData = item.biomes[0];
string selectedVariant = ((biomeData.variants.Count > 0) ? biomeData.variants[0] : "");
list.Add(new BiomeSettings
{
overrideEnabled = true,
sectionName = item.sectionName,
selectedBiome = biomeData,
selectedVariant = selectedVariant
});
}
}
return new MapSettings
{
seed = 42,
autoRandomSeed = false,
fullyRandom = false,
biomes = list
};
}
}
[Serializable]
public class BiomeSettings
{
public bool overrideEnabled;
public string sectionName;
public BiomeData selectedBiome;
public string selectedVariant;
public bool randomBiome;
public bool randomVariant;
}
[Serializable]
public class SectionData
{
public string sectionName;
public List<BiomeData> biomes = new List<BiomeData>();
}
[Serializable]
public class BiomeData
{
public string biomeName;
public BiomeType biomeType;
public List<string> variants = new List<string>();
public VariantSelectionType variantSelectionType = VariantSelectionType.BiomeVariant;
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.snosz.terrainrandomiser", "TerrainRandomiser", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(BoardingPass), "Initialize")]
private static class BoardingPassInitializePatch
{
private static void Postfix(BoardingPass __instance)
{
Instance.CreateUI(__instance);
}
}
[HarmonyPatch(typeof(BoardingPass), "StartGame")]
private static class BoardingPassStartGamePatch
{
private static void Prefix(BoardingPass __instance)
{
if (PhotonNetwork.IsMasterClient && Instance.mapSettings.enableRandomiser)
{
MapSettings mapSettings = Instance.mapSettings;
if (mapSettings.fullyRandom || mapSettings.autoRandomSeed)
{
RandomiseSeed(mapSettings);
}
if (mapSettings.fullyRandom)
{
RandomiseAllSections(mapSettings);
}
else
{
RandomiseOverrides(mapSettings);
}
SyncWithClients(mapSettings);
}
}
}
[HarmonyPatch(typeof(MapHandler), "Start")]
private static class MapHandlerStartPatch
{
private static bool Prefix(MapHandler __instance)
{
if (!Instance.roomMapSettings.enableRandomiser)
{
return true;
}
MapSettings roomMapSettings = Instance.roomMapSettings;
viewIDsToSend = new List<int>();
viewsRequiringIDs = new List<PhotonView>();
Debug.LogError((object)$"[TerrainRandomiser] Starting generation with seed: {roomMapSettings.seed}");
Random.InitState(roomMapSettings.seed);
for (int i = 0; i < roomMapSettings.biomes.Count; i++)
{
ApplyBiomeToSegment(__instance, i, roomMapSettings.biomes[i]);
}
GameObject segmentCampfire = Singleton<MapHandler>.Instance.segments.First((MapSegment s) => ((Object)s.segmentCampfire).name == "Volcano_Campfire").segmentCampfire;
if ((Object)(object)segmentCampfire != (Object)null)
{
segmentCampfire.SetActive(false);
}
List<MapSegment> list = Singleton<MapHandler>.Instance.segments.ToList();
list.AddRange(Singleton<MapHandler>.Instance.variantSegments);
foreach (MapSegment item in list)
{
if ((Object)(object)item.segmentParent.GetComponent<PropGrouper>() == (Object)null)
{
item.segmentParent.gameObject.AddComponent<PropGrouper>();
}
}
MapHandlerHelpers.RunAllSegments(__instance.segments, __instance.variantSegments);
MapHandlerHelpers.RunGobal(__instance.globalParent);
if ((Object)(object)segmentCampfire != (Object)null)
{
segmentCampfire.SetActive(true);
}
if (PhotonNetwork.IsMasterClient)
{
List<int> andAssignAllUnassignedViews = MapHandlerHelpers.GetAndAssignAllUnassignedViews();
viewIDsToSend.AddRange(andAssignAllUnassignedViews);
Instance.SendViewIDsToClients(viewIDsToSend);
}
FakeItemManager.Instance.RefreshList();
return true;
}
private static void Postfix(MapHandler __instance)
{
if (Instance.roomMapSettings.enableRandomiser && !PhotonNetwork.IsMasterClient)
{
Debug.Log((object)string.Format("[TerrainRandomiser] Required viewIDs: {0} | Received viewIDs: {1}", viewsRequiringIDs?.Count ?? (-1), (receivedViewIDs == null) ? "null" : receivedViewIDs.Count.ToString()));
}
}
}
public static Plugin Instance;
private static Harmony _harmony;
public static List<int> viewIDsToSend;
public static List<PhotonView>? viewsRequiringIDs;
public static List<int> receivedViewIDs;
public AssetBundle seedPickerUIBundle;
public const int MAX_SEED_VALUE = 999999999;
public MapSettings mapSettings;
public MapSettings roomMapSettings;
private RandomiserUIManager uiManager;
private PhotonScopedManager photonManager;
private GameObject uidocObject;
private static readonly string SavePath = Path.Combine(Application.persistentDataPath, "TerrainRandomiser", "MapSettings.json");
public static int masterSeed => Instance.roomMapSettings.seed;
private void Awake()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
Instance = this;
_harmony = new Harmony("com.snosz.terrainrandomiser");
((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
byte[] terrainrandomiser = Resource1.terrainrandomiser;
seedPickerUIBundle = AssetBundle.LoadFromMemory(terrainrandomiser);
LoadMapSettings();
if (mapSettings == null)
{
mapSettings = MapSettings.CreateDefaultMapSettings();
}
AddPhotonManager();
_harmony.PatchAll();
}
private void OnDestroy()
{
_harmony.UnpatchSelf();
if ((Object)(object)seedPickerUIBundle != (Object)null)
{
if ((Object)(object)uidocObject != (Object)null)
{
uidocObject.GetComponent<UIDocument>().rootVisualElement.Clear();
Object.Destroy((Object)(object)uidocObject);
}
seedPickerUIBundle.Unload(true);
seedPickerUIBundle = null;
}
}
private void AddPhotonManager()
{
photonManager = PhotonCustomPropsUtilsPlugin.GetManager("com.snosz.terrainrandomiser");
photonManager.RegisterOnJoinedRoom((Action<Player>)delegate
{
if (PhotonNetwork.IsMasterClient)
{
string text = JsonConvert.SerializeObject((object)mapSettings, (Formatting)0);
photonManager.SetRoomProperty("roomMapSettings", (object)text);
}
});
photonManager.RegisterRoomProperty<string>("roomMapSettings", (RoomEventType)2, (Action<string>)delegate(string value)
{
roomMapSettings = JsonConvert.DeserializeObject<MapSettings>(value);
Debug.Log((object)value);
});
photonManager.RegisterRoomProperty<int[]>("propViews", (RoomEventType)2, (Action<int[]>)delegate(int[] val)
{
if (!PhotonNetwork.IsMasterClient)
{
if (receivedViewIDs == null)
{
receivedViewIDs = new List<int>();
}
else
{
receivedViewIDs.Clear();
}
receivedViewIDs = val.ToList();
Instance.UpdateRequiredViewIDs();
}
});
}
public void UpdateRequiredViewIDs()
{
if (!roomMapSettings.enableRandomiser || PhotonNetwork.IsMasterClient)
{
return;
}
if (viewsRequiringIDs == null || receivedViewIDs == null)
{
Debug.LogError((object)"[TerrainRandomiser] Required lists did not initialize or have already been resolved.");
return;
}
if (viewsRequiringIDs.Count > receivedViewIDs.Count)
{
Debug.LogError((object)"[TerrainRandomiser] ID Count mismatch! Map will be out of sync!");
return;
}
for (int i = 0; i < viewsRequiringIDs.Count; i++)
{
if ((Object)(object)viewsRequiringIDs[i] != (Object)null && (Object)(object)((Component)viewsRequiringIDs[i]).gameObject != (Object)null)
{
viewsRequiringIDs[i].ViewID = receivedViewIDs[i];
}
else
{
Debug.LogError((object)$"Null or destroyed PhotonView at index {i}");
}
}
List<PhotonView> allUnassignedViews = MapHandlerHelpers.GetAllUnassignedViews();
for (int j = 0; j < allUnassignedViews.Count; j++)
{
allUnassignedViews[j].ViewID = receivedViewIDs[viewsRequiringIDs.Count + j];
}
Debug.LogError((object)$"[TerrainCustomiser] Updated receivedViewIDs with {receivedViewIDs.Count} IDs");
viewsRequiringIDs.Clear();
viewsRequiringIDs = null;
}
private void CreateUI(BoardingPass bpInstance)
{
GameObject val = Instance.seedPickerUIBundle.LoadAsset<GameObject>("UIDocument");
Instance.uidocObject = Object.Instantiate<GameObject>(val, ((Component)bpInstance).transform);
uiManager = Instance.uidocObject.AddComponent<RandomiserUIManager>();
}
private static void RandomiseSeed(MapSettings settings)
{
settings.seed = Random.Range(0, 999999999);
}
private static void RandomiseAllSections(MapSettings settings)
{
List<SectionData> runtimeValidSections = BiomeDatabase.GetRuntimeValidSections();
for (int i = 0; i < runtimeValidSections.Count; i++)
{
ApplyRandomBiomeAndVariant(settings, i, runtimeValidSections[i]);
}
}
private static void RandomiseOverrides(MapSettings settings)
{
List<SectionData> runtimeValidSections = BiomeDatabase.GetRuntimeValidSections();
for (int i = 0; i < settings.biomes.Count; i++)
{
BiomeSettings biomeSettings = settings.biomes[i];
if (biomeSettings.overrideEnabled)
{
if (biomeSettings.randomBiome)
{
ApplyRandomBiomeAndVariant(settings, i, runtimeValidSections[i]);
}
else if (biomeSettings.randomVariant)
{
ApplyRandomVariant(settings, i);
}
}
}
}
private static void ApplyRandomBiomeAndVariant(MapSettings settings, int index, SectionData section)
{
int index2 = Random.Range(0, section.biomes.Count);
settings.biomes[index].selectedBiome = section.biomes[index2];
ApplyRandomVariant(settings, index);
}
private static void ApplyRandomVariant(MapSettings settings, int index)
{
BiomeData selectedBiome = settings.biomes[index].selectedBiome;
int index2 = Random.Range(0, selectedBiome.variants.Count);
settings.biomes[index].selectedVariant = selectedBiome.variants[index2];
}
private static void SyncWithClients(MapSettings settings)
{
Instance.roomMapSettings = settings;
SaveMapSettings();
string text = JsonConvert.SerializeObject((object)settings, (Formatting)0);
Instance.photonManager.SetRoomProperty("roomMapSettings", (object)text);
}
public void SendViewIDsToClients(List<int> viewIDs)
{
photonManager.SetRoomProperty("propViews", (object)viewIDs.ToArray());
}
private static void ApplyBiomeVariant(MapSegment seg, BiomeSettings biomeSettings)
{
BiomeSettings biomeSettings2 = biomeSettings;
BiomeVariant[] componentsInChildren = seg.segmentParent.GetComponentsInChildren<BiomeVariant>(true);
BiomeVariant val = ((IEnumerable<BiomeVariant>)componentsInChildren).FirstOrDefault((Func<BiomeVariant, bool>)((BiomeVariant v) => ((Component)v).gameObject.activeSelf));
BiomeVariant val2 = ((IEnumerable<BiomeVariant>)componentsInChildren).FirstOrDefault((Func<BiomeVariant, bool>)((BiomeVariant v) => ((Object)v).name == biomeSettings2.selectedVariant));
if ((Object)(object)val2 == (Object)null || (Object)(object)val == (Object)(object)val2)
{
return;
}
PropGrouper component = seg.segmentParent.gameObject.GetComponent<PropGrouper>();
if ((Object)(object)component == (Object)null)
{
seg.segmentParent.gameObject.AddComponent<PropGrouper>();
}
if ((Object)(object)val != (Object)null)
{
PropGrouper component2 = ((Component)val).GetComponent<PropGrouper>();
if (component2 != null)
{
component2.ClearAll();
}
((Component)val).gameObject.SetActive(false);
}
((Component)val2).gameObject.SetActive(true);
}
private static void ApplyBiomeToSegment(MapHandler handler, int index, BiomeSettings biomeSettings)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
MapSegment val = handler.segments[index];
if (val.biome == biomeSettings.selectedBiome.biomeType)
{
ApplyVariant(val, biomeSettings);
}
else
{
SwapBiome(val, handler, biomeSettings);
}
}
private static void ApplyVariant(MapSegment seg, BiomeSettings biomeSettings)
{
switch (biomeSettings.selectedBiome.variantSelectionType)
{
case VariantSelectionType.BiomeVariant:
ApplyBiomeVariant(seg, biomeSettings);
break;
case VariantSelectionType.VariantObject:
ApplyVariantObject(seg, biomeSettings);
break;
}
}
private static void ApplyVariantObject(MapSegment seg, BiomeSettings biomeSettings)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
BiomeSettings biomeSettings2 = biomeSettings;
VariantObject[] componentsInChildren = seg.segmentParent.GetComponentsInChildren<VariantObject>(true);
VariantObject val = ((IEnumerable<VariantObject>)componentsInChildren).FirstOrDefault((Func<VariantObject, bool>)((VariantObject v) => ((Object)v).name.Contains(biomeSettings2.selectedVariant)));
if (!((Object)(object)val == (Object)null))
{
VariantObject[] array = componentsInChildren;
foreach (VariantObject val2 in array)
{
bool active = (int)val2.group == 0 && ((Object)val2).name.Contains(biomeSettings2.selectedVariant);
((Component)val2).gameObject.SetActive(active);
}
}
}
private static void SwapBiome(MapSegment seg, MapHandler handler, BiomeSettings biomeSettings)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
MapSegment seg2 = seg;
PropGrouper component = seg2.segmentParent.GetComponent<PropGrouper>();
if (component != null)
{
component.ClearAll();
}
((Component)seg2.segmentParent.transform.parent).gameObject.SetActive(false);
int index = handler.biomes.FindIndex((BiomeType x) => x == seg2.biome);
handler.biomes[index] = biomeSettings.selectedBiome.biomeType;
((Component)seg2.segmentParent.transform.parent).gameObject.SetActive(true);
GameObject segmentCampfire = seg2.segmentCampfire;
PropGrouper val = segmentCampfire.GetComponent<PropGrouper>();
bool flag = false;
if ((Object)(object)val == (Object)null)
{
val = segmentCampfire.AddComponent<PropGrouper>();
flag = true;
}
val.RunAll(true);
ApplyVariant(seg2, biomeSettings);
}
public static void SaveMapSettings()
{
string contents = JsonConvert.SerializeObject((object)Instance.mapSettings, (Formatting)1);
File.WriteAllText(SavePath, contents);
}
public static void LoadMapSettings()
{
string directoryName = Path.GetDirectoryName(SavePath);
if (!Directory.Exists(directoryName))
{
Directory.CreateDirectory(directoryName);
}
if (File.Exists(SavePath))
{
string text = File.ReadAllText(SavePath);
MapSettings mapSettings = JsonConvert.DeserializeObject<MapSettings>(text);
if (mapSettings != null)
{
Instance.mapSettings = mapSettings;
}
}
}
}
public class RandomiserUIManager : MonoBehaviour
{
[SerializeField]
private UIDocument uiDocument;
private IntegerField seedInput;
private Button randomSeedButton;
private Toggle autoSeedToggle;
private Toggle fullyRandomToggle;
private Toggle enableRandomiserToggle;
private VisualElement randomiserMenu;
private VisualElement biomeTabContainer;
private List<Toggle> biomeOverrideToggles = new List<Toggle>();
private List<DropdownField> biomeDropdowns = new List<DropdownField>();
private List<DropdownField> variantDropdowns = new List<DropdownField>();
private List<SectionData> runtimeSections;
private MapSettings mapSettings;
private VisualElement _lockedPopup;
private bool _allowFocusChange;
public void OnEnable()
{
runtimeSections = BiomeDatabase.GetRuntimeValidSections();
mapSettings = Plugin.Instance.mapSettings;
biomeOverrideToggles.Clear();
biomeDropdowns.Clear();
variantDropdowns.Clear();
uiDocument = ((Component)this).GetComponent<UIDocument>();
VisualElement rootVisualElement = uiDocument.rootVisualElement;
seedInput = UQueryExtensions.Q<IntegerField>(rootVisualElement, "seedInput", (string)null);
randomSeedButton = UQueryExtensions.Q<Button>(rootVisualElement, "randomSeedButton", (string)null);
autoSeedToggle = UQueryExtensions.Q<Toggle>(rootVisualElement, "autoSeedToggle", (string)null);
fullyRandomToggle = UQueryExtensions.Q<Toggle>(rootVisualElement, "fullyRandomToggle", (string)null);
randomiserMenu = UQueryExtensions.Q<VisualElement>(rootVisualElement, "SeedPicker", (string)null);
enableRandomiserToggle = UQueryExtensions.Q<Toggle>(rootVisualElement, "enableRandomiserToggle", (string)null);
biomeTabContainer = (VisualElement)(object)UQueryExtensions.Q<TabView>(rootVisualElement, (string)null, (string)null);
for (int i = 0; i < mapSettings.biomes.Count; i++)
{
VisualElement val = UQueryExtensions.Q<VisualElement>(rootVisualElement, $"biome{i + 1}Tab", (string)null);
biomeOverrideToggles.Add(UQueryExtensions.Q<Toggle>(val, "overrideBiomeToggle", (string)null));
biomeDropdowns.Add(UQueryExtensions.Q<DropdownField>(val, "biomeDropdown", (string)null));
variantDropdowns.Add(UQueryExtensions.Q<DropdownField>(val, "variantDropdown", (string)null));
}
SetupBindings();
}
public void Awake()
{
}
private void SetupBindings()
{
//IL_0415: Unknown result type (might be due to invalid IL or missing references)
//IL_041a: Unknown result type (might be due to invalid IL or missing references)
((BaseField<bool>)(object)enableRandomiserToggle).value = Plugin.Instance.mapSettings.enableRandomiser;
INotifyValueChangedExtensions.RegisterValueChangedCallback<bool>((INotifyValueChanged<bool>)(object)enableRandomiserToggle, (EventCallback<ChangeEvent<bool>>)delegate(ChangeEvent<bool> evt)
{
OnEnableRandomiserChanged(evt.newValue);
});
OnEnableRandomiserChanged(Plugin.Instance.mapSettings.enableRandomiser);
randomSeedButton.clicked += OnRandomSeedPressed;
((BaseField<int>)(object)seedInput).value = mapSettings.seed;
INotifyValueChangedExtensions.RegisterValueChangedCallback<int>((INotifyValueChanged<int>)(object)seedInput, (EventCallback<ChangeEvent<int>>)delegate(ChangeEvent<int> evt)
{
mapSettings.seed = evt.newValue;
});
((BaseField<bool>)(object)autoSeedToggle).value = mapSettings.autoRandomSeed;
INotifyValueChangedExtensions.RegisterValueChangedCallback<bool>((INotifyValueChanged<bool>)(object)autoSeedToggle, (EventCallback<ChangeEvent<bool>>)delegate(ChangeEvent<bool> evt)
{
OnAutoSeedChanged(evt.newValue);
});
OnAutoSeedChanged(mapSettings.autoRandomSeed);
((BaseField<bool>)(object)fullyRandomToggle).value = mapSettings.fullyRandom;
INotifyValueChangedExtensions.RegisterValueChangedCallback<bool>((INotifyValueChanged<bool>)(object)fullyRandomToggle, (EventCallback<ChangeEvent<bool>>)delegate(ChangeEvent<bool> evt)
{
OnFullyRandomChanged(evt.newValue);
});
OnFullyRandomChanged(mapSettings.fullyRandom);
for (int i = 0; i < mapSettings.biomes.Count; i++)
{
int index = i;
BiomeSettings biome2 = mapSettings.biomes[i];
((BaseField<bool>)(object)biomeOverrideToggles[i]).value = biome2.overrideEnabled;
INotifyValueChangedExtensions.RegisterValueChangedCallback<bool>((INotifyValueChanged<bool>)(object)biomeOverrideToggles[i], (EventCallback<ChangeEvent<bool>>)delegate(ChangeEvent<bool> evt)
{
OnOverrideBiomeChanged(index, evt.newValue);
});
OnOverrideBiomeChanged(index, biome2.overrideEnabled);
if (runtimeSections[i].biomes.Count > 1)
{
((BasePopupField<string, string>)(object)biomeDropdowns[i]).choices.Add("Random");
}
((BasePopupField<string, string>)(object)biomeDropdowns[i]).choices.AddRange(runtimeSections[i].biomes.Select((BiomeData x) => x.biomeName));
((BaseField<string>)(object)biomeDropdowns[i]).value = biome2.selectedBiome.biomeName;
INotifyValueChangedExtensions.RegisterValueChangedCallback<string>((INotifyValueChanged<string>)(object)biomeDropdowns[i], (EventCallback<ChangeEvent<string>>)delegate(ChangeEvent<string> evt)
{
OnBiomeChanged(index, evt.newValue);
});
((CallbackEventHandler)biomeDropdowns[index]).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate
{
((VisualElement)biomeDropdowns[index]).schedule.Execute((Action)delegate
{
VisualElement val3 = UQueryExtensions.Q(((VisualElement)biomeDropdowns[index]).panel.visualTree, (string)null, "unity-scroll-view__content-container");
if (val3 != null)
{
InstallPopupFocusLock(val3);
}
});
}, (TrickleDown)0);
List<string> variants = runtimeSections[i].biomes.Find((BiomeData biome) => biome.biomeType == mapSettings.biomes[i].selectedBiome.biomeType).variants;
if (variants.Count > 1)
{
((BasePopupField<string, string>)(object)variantDropdowns[i]).choices.Add("Random");
}
((BasePopupField<string, string>)(object)variantDropdowns[i]).choices.AddRange(variants);
((BaseField<string>)(object)variantDropdowns[i]).value = biome2.selectedVariant;
INotifyValueChangedExtensions.RegisterValueChangedCallback<string>((INotifyValueChanged<string>)(object)variantDropdowns[i], (EventCallback<ChangeEvent<string>>)delegate(ChangeEvent<string> evt)
{
OnBiomeVariantChanged(index, biome2, evt.newValue);
});
((CallbackEventHandler)variantDropdowns[index]).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate
{
((VisualElement)variantDropdowns[index]).schedule.Execute((Action)delegate
{
VisualElement val2 = UQueryExtensions.Q(((VisualElement)variantDropdowns[index]).panel.visualTree, (string)null, "unity-scroll-view__content-container");
if (val2 != null)
{
InstallPopupFocusLock(val2);
}
});
}, (TrickleDown)0);
TabView val = UQueryExtensions.Q<TabView>(uiDocument.rootVisualElement, (string)null, (string)null);
List<Tab> list = UQueryExtensions.Query<Tab>((VisualElement)(object)val, (string)null, (string)null).ToList();
BiomeSettings biomeSettings = mapSettings.biomes[i];
list[i].label = biomeSettings.selectedBiome.biomeName.ToUpper();
}
}
private void InstallPopupFocusLock(VisualElement popup)
{
_lockedPopup = popup;
_allowFocusChange = false;
((CallbackEventHandler)popup).RegisterCallback<FocusOutEvent>((EventCallback<FocusOutEvent>)OnPopupFocusOut, (TrickleDown)1);
((CallbackEventHandler)popup).RegisterCallback<PointerMoveEvent>((EventCallback<PointerMoveEvent>)delegate(PointerMoveEvent evt)
{
((EventBase)evt).StopPropagation();
}, (TrickleDown)1);
}
private void OnPopupFocusOut(FocusOutEvent evt)
{
if (_allowFocusChange)
{
return;
}
VisualElement lockedPopup = _lockedPopup;
if (lockedPopup != null)
{
Focusable relatedTarget = ((FocusEventBase<FocusOutEvent>)(object)evt).relatedTarget;
VisualElement val = (VisualElement)(object)((relatedTarget is VisualElement) ? relatedTarget : null);
if ((val == null || !lockedPopup.Contains(val)) && val == null)
{
((EventBase)evt).PreventDefault();
((EventBase)evt).StopImmediatePropagation();
((EventBase)evt).StopPropagation();
((Focusable)lockedPopup).Focus();
}
}
}
private void OnBiomeChanged(int index, string value)
{
string value2 = value;
if (value2 == "Random")
{
mapSettings.biomes[index].randomBiome = true;
mapSettings.biomes[index].randomVariant = true;
((BasePopupField<string, string>)(object)variantDropdowns[index]).choices.Clear();
((BasePopupField<string, string>)(object)variantDropdowns[index]).choices.Add("Random");
((BaseField<string>)(object)variantDropdowns[index]).SetValueWithoutNotify("Random");
OnBiomeVariantChanged(index, mapSettings.biomes[index], "Random");
TabView val = UQueryExtensions.Q<TabView>(uiDocument.rootVisualElement, (string)null, (string)null);
val.activeTab.label = "RANDOM";
return;
}
mapSettings.biomes[index].randomBiome = false;
List<string> variants = runtimeSections[index].biomes.Find((BiomeData biome) => biome.biomeName == value2).variants;
((BasePopupField<string, string>)(object)variantDropdowns[index]).choices.Clear();
if (variants.Count > 1)
{
((BasePopupField<string, string>)(object)variantDropdowns[index]).choices.Add("Random");
}
((BasePopupField<string, string>)(object)variantDropdowns[index]).choices.AddRange(variants);
BiomeData biomeData = runtimeSections[index].biomes.Find((BiomeData biome) => biome.biomeName == value2);
mapSettings.biomes[index].selectedBiome = biomeData;
TabView val2 = UQueryExtensions.Q<TabView>(uiDocument.rootVisualElement, (string)null, (string)null);
val2.activeTab.label = biomeData.biomeName.ToUpper();
((BaseField<string>)(object)variantDropdowns[index]).SetValueWithoutNotify("Random");
OnBiomeVariantChanged(index, mapSettings.biomes[index], "Random");
}
private void OnBiomeVariantChanged(int index, BiomeSettings biome, string value)
{
if (value == "Random")
{
mapSettings.biomes[index].randomVariant = true;
}
else
{
mapSettings.biomes[index].randomVariant = false;
}
biome.selectedVariant = value;
}
private void OnOverrideBiomeChanged(int index, bool value)
{
mapSettings.biomes[index].overrideEnabled = value;
((VisualElement)biomeDropdowns[index]).SetEnabled(value);
((VisualElement)variantDropdowns[index]).SetEnabled(value);
}
private void OnRandomSeedPressed()
{
int value = Random.Range(0, 999999999);
((BaseField<int>)(object)seedInput).value = value;
}
private void OnAutoSeedChanged(bool value)
{
if (((BaseField<bool>)(object)fullyRandomToggle).value && !value)
{
((BaseField<bool>)(object)autoSeedToggle).SetValueWithoutNotify(true);
return;
}
mapSettings.autoRandomSeed = value;
((VisualElement)seedInput).SetEnabled(!value);
((VisualElement)randomSeedButton).SetEnabled(!value);
}
private void OnEnableRandomiserChanged(bool value)
{
randomiserMenu.visible = value;
mapSettings.enableRandomiser = value;
}
private void OnFullyRandomChanged(bool value)
{
if (value && !((BaseField<bool>)(object)autoSeedToggle).value)
{
((BaseField<bool>)(object)autoSeedToggle).value = true;
}
biomeTabContainer.SetEnabled(!value);
((VisualElement)autoSeedToggle).SetEnabled(!value);
mapSettings.fullyRandom = value;
}
}
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resource1
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
ResourceManager resourceManager = new ResourceManager("TerrainRandomiser.Resource1", typeof(Resource1).Assembly);
resourceMan = resourceManager;
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal static byte[] terrainrandomiser
{
get
{
object @object = ResourceManager.GetObject("terrainrandomiser", resourceCulture);
return (byte[])@object;
}
}
internal Resource1()
{
}
}
}
namespace TerrainRandomiser.TerrainGeneration
{
public static class GenerationPatches
{
[HarmonyPatch(typeof(SpawnConnectingBridge), "CheckCondition")]
private class SCBCheckConditionPatch
{
private static bool Prefix(SpawnConnectingBridge __instance, SpawnData data, ref bool __result)
{
SpawnConnectingBridge.parent = ((Component)__instance).transform.parent;
__instance.treePlatforms = ((Component)SpawnConnectingBridge.parent).GetComponentsInChildren<TreePlatform>();
Debug.LogError((object)("Checking: " + __instance.treePlatforms.Length));
return true;
}
}
[HarmonyPatch(typeof(JungleVine), "CheckCondition")]
private static class CheckConditionPatch
{
private static bool Prefix(JungleVine __instance, SpawnData data, ref bool __result)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: 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_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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_0047: 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_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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_00a6: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = data.normal;
val.y *= __instance.normalYMult;
val = ((Vector3)(ref val)).normalized;
RaycastHit val2 = HelperFunctions.LineCheck(((Component)__instance).transform.position + val * 0.02f, ((Component)__instance).transform.position + val * __instance.maxDist, (LayerType)1, 0f, (QueryTriggerInteraction)1);
if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).transform))
{
__result = false;
return false;
}
if (((RaycastHit)(ref val2)).distance < __instance.minDist)
{
__result = false;
return false;
}
if (Mathf.Abs(((RaycastHit)(ref val2)).point.y - ((Component)__instance).transform.position.y) > __instance.maxHeightDifference)
{
__result = false;
return false;
}
bool flag = __instance.ConfigVine(((RaycastHit)(ref val2)).point);
BreakableBridge val3 = default(BreakableBridge);
if (flag && ((Component)__instance).TryGetComponent<BreakableBridge>(ref val3))
{
val3.AddCollisionModifiers();
}
__result = flag;
if (!flag)
{
}
return false;
}
}
[HarmonyPatch(typeof(PSCP_Custom), "CheckConstraint")]
private static class CheckConstraintPatch
{
private static bool Prefix(PSCP_Custom __instance, GameObject spawned, SpawnData spawnData, ref bool __result)
{
CustomSpawnCondition[] components = spawned.GetComponents<CustomSpawnCondition>();
for (int i = 0; i < components.Length; i++)
{
if (!components[i].CheckCondition(spawnData))
{
__result = false;
return false;
}
}
__result = true;
return false;
}
}
[HarmonyPatch(typeof(PropSpawner), "SpawnNew")]
public static class PropSpawnerAddPatch
{
private static Ray[] rays = (Ray[])(object)new Ray[0];
private static bool Prefix(PropSpawner __instance)
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//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_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: 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_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: 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_012d: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.Instance.roomMapSettings.enableRandomiser)
{
return true;
}
if (__instance.chanceToUseSpawner < 0.999f && Random.value > __instance.chanceToUseSpawner)
{
return false;
}
if (!CanBatch(__instance))
{
return true;
}
int num = 25000;
int num2 = 0;
int nrOfSpawns = __instance.nrOfSpawns;
LayerMask mask = HelperFunctions.GetMask(__instance.layerType);
int num3 = 512;
if (rays.Length < num3)
{
rays = (Ray[])(object)new Ray[num3];
}
Vector3 val = ((Component)__instance).transform.forward + __instance.rayDirectionOffset;
Vector3 normalized = ((Vector3)(ref val)).normalized;
QueryParameters @default = QueryParameters.Default;
@default.layerMask = ((LayerMask)(ref mask)).value;
@default.hitTriggers = (QueryTriggerInteraction)1;
NativeArray<RaycastHit> results = default(NativeArray<RaycastHit>);
NativeArray<RaycastCommand> commands = default(NativeArray<RaycastCommand>);
while (num2 < nrOfSpawns && num > 0)
{
rays = PropSpawnerHelpers.BuildRays(__instance, rays, num3, normalized);
results..ctor(num3, (Allocator)3, (NativeArrayOptions)1);
commands..ctor(num3, (Allocator)3, (NativeArrayOptions)1);
ExecuteJob(commands, results, rays, @default, num3, __instance.rayLength);
num -= num3;
int num4 = ProcessResults(results, rays, __instance, num2, nrOfSpawns);
num2 += num4;
commands.Dispose();
results.Dispose();
}
Physics.SyncTransforms();
__instance.currentSpawns = ((Component)__instance).transform.childCount;
__instance.SpawnDecor();
return false;
}
}
[HarmonyPatch(typeof(PropGrouper), "RunAll")]
public static class PropGrouperPatch
{
private static readonly List<LevelGenStep> lateLevelGenSteps = new List<LevelGenStep>();
private static void Postfix(PropGrouper __instance)
{
PropGrouperHelpers.CollectLateLevelGenSteps(__instance, lateLevelGenSteps);
PropGrouperHelpers.RunLateLevelGenSteps(lateLevelGenSteps);
}
}
[HarmonyPatch]
public static class LevelGenStepSpawnPatch
{
[CompilerGenerated]
private sealed class <>c__DisplayClass0_0
{
public Type baseType;
public Func<Type, bool> <>9__0;
internal bool <TargetMethods>b__0(Type t)
{
return baseType.IsAssignableFrom(t) && !t.IsAbstract;
}
}
[CompilerGenerated]
private sealed class <TargetMethods>d__0 : IEnumerable<MethodBase>, IEnumerable, IEnumerator<MethodBase>, IEnumerator, IDisposable
{
private int <>1__state;
private MethodBase <>2__current;
private int <>l__initialThreadId;
private <>c__DisplayClass0_0 <>8__1;
private IEnumerator<Type> <>s__2;
private Type <type>5__3;
private MethodInfo <method>5__4;
MethodBase IEnumerator<MethodBase>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <TargetMethods>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>8__1 = null;
<>s__2 = null;
<type>5__3 = null;
<method>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
try
{
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -3;
goto IL_00ff;
}
<>1__state = -1;
<>8__1 = new <>c__DisplayClass0_0();
<>8__1.baseType = typeof(LevelGenStep);
<>s__2 = (from t in <>8__1.baseType.Assembly.GetTypes()
where <>8__1.baseType.IsAssignableFrom(t) && !t.IsAbstract
select t).GetEnumerator();
<>1__state = -3;
goto IL_010e;
IL_010e:
if (<>s__2.MoveNext())
{
<type>5__3 = <>s__2.Current;
<method>5__4 = <type>5__3.GetMethod("Spawn", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (<method>5__4 != null)
{
<>2__current = <method>5__4;
<>1__state = 1;
return true;
}
goto IL_00ff;
}
<>m__Finally1();
<>s__2 = null;
return false;
IL_00ff:
<method>5__4 = null;
<type>5__3 = null;
goto IL_010e;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__2 != null)
{
<>s__2.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<MethodBase> IEnumerable<MethodBase>.GetEnumerator()
{
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
return this;
}
return new <TargetMethods>d__0(0);
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<MethodBase>)this).GetEnumerator();
}
}
[IteratorStateMachine(typeof(<TargetMethods>d__0))]
private static IEnumerable<MethodBase> TargetMethods()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <TargetMethods>d__0(-2);
}
private static bool Prefix(LevelGenStep __instance, MethodBase __originalMethod, SpawnData spawnData, ref GameObject __result)
{
if (!Plugin.Instance.roomMapSettings.enableRandomiser)
{
return true;
}
Type type = ((object)__instance).GetType();
GameObject[] array = type.GetField("props", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(__instance) as GameObject[];
IList list = type.GetField("modifiers", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(__instance) as IList;
IList list2 = type.GetField("postConstraints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(__instance) as IList;
if (array == null)
{
return true;
}
List<PropSpawnerMod> modifiers = ((list != null) ? new List<PropSpawnerMod>(list.Cast<PropSpawnerMod>()) : new List<PropSpawnerMod>());
List<PropSpawnerConstraintPost> postConstraints = ((list2 != null) ? new List<PropSpawnerConstraintPost>(list2.Cast<PropSpawnerConstraintPost>()) : new List<PropSpawnerConstraintPost>());
bool flag = PropSpawnerHelpers.TrySpawn(spawnData, ref __result, array, modifiers, postConstraints, ((Component)__instance).transform, ((Component)__instance).gameObject, Plugin.viewIDsToSend, Plugin.viewsRequiringIDs);
if (!flag)
{
}
return flag;
}
}
public static bool CanBatch(PropSpawner spawner)
{
if (!spawner.raycastPosition)
{
return false;
}
if (!spawner.syncTransforms || PropSpawnerHelpers.SafeToBatchPropNames.Contains(((Object)((Component)spawner).gameObject).name))
{
return true;
}
return true;
}
public static bool PassedConstraints(PropSpawner spawner, SpawnData sd)
{
for (int i = 0; i < spawner.constraints.Count; i++)
{
if (!spawner.constraints[i].CheckConstraint(sd))
{
return false;
}
}
return true;
}
public static void ExecuteJob(NativeArray<RaycastCommand> commands, NativeArray<RaycastHit> results, Ray[] rays, QueryParameters queryParams, int batchCount, float rayLength)
{
//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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < batchCount; i++)
{
commands[i] = new RaycastCommand(((Ray)(ref rays[i])).origin, ((Ray)(ref rays[i])).direction, queryParams, rayLength);
}
JobHandle val = RaycastCommand.ScheduleBatch(commands, results, 128, default(JobHandle));
((JobHandle)(ref val)).Complete();
}
public static int ProcessResults(NativeArray<RaycastHit> results, Ray[] rays, PropSpawner spawner, int successes, int nrOfSpawns)
{
//IL_0010: 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_0031: 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)
int num = 0;
int num2 = 0;
for (int i = 0; i < results.Length; i++)
{
if (successes >= nrOfSpawns)
{
break;
}
RaycastHit hit = results[i];
if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null)
{
continue;
}
num++;
Ray val = rays[i];
SpawnData val2 = PropSpawnerHelpers.BuildSpawnData(spawner, rays[i], hit, hasHit: true, successes + num2);
if (PassedConstraints(spawner, val2))
{
object[] array = new object[1] { val2 };
if (Object.op_Implicit((Object)(object)spawner.Spawn(val2)))
{
successes++;
num2++;
}
}
}
return num2;
}
}
public class MapHandlerHelpers
{
public static void RunAllSegments(MapSegment[] segments, MapSegment[] variantSegments, bool forceBiome = false, string biomeName = "MESA")
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Invalid comparison between Unknown and I4
foreach (MapSegment val in segments)
{
GameObject segmentParent = val.segmentParent;
PropGrouper val2 = ((segmentParent != null) ? segmentParent.GetComponent<PropGrouper>() : null);
if (val2 != null)
{
val2.RunAll(true);
}
}
if (!forceBiome)
{
return;
}
foreach (MapSegment val3 in variantSegments)
{
if ((int)val3.biome == 6 && biomeName == "MESA")
{
GameObject segmentParent2 = val3.segmentParent;
PropGrouper val4 = ((segmentParent2 != null) ? segmentParent2.GetComponent<PropGrouper>() : null);
if (val4 != null)
{
val4.RunAll(true);
}
}
}
}
public static void RunGobal(Transform global)
{
PropGrouper component = ((Component)global).gameObject.GetComponent<PropGrouper>();
component.RunAll(true);
}
public static List<PhotonView> GetAllUnassignedViews()
{
PhotonView[] componentsInChildren = ((Component)Singleton<MapHandler>.Instance).gameObject.GetComponentsInChildren<PhotonView>();
List<PhotonView> list = new List<PhotonView>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
if (componentsInChildren[i].ViewID == 0)
{
list.Add(componentsInChildren[i]);
}
}
return list;
}
public static List<int> GetAndAssignAllUnassignedViews()
{
List<PhotonView> allUnassignedViews = GetAllUnassignedViews();
List<int> list = new List<int>();
for (int i = 0; i < allUnassignedViews.Count; i++)
{
int item = PropSpawnerHelpers.AssignMasterClientViewID(((Component)allUnassignedViews[i]).gameObject);
list.Add(item);
}
return list;
}
}
public static class PropGrouperHelpers
{
public static void CollectLateLevelGenSteps(PropGrouper grouper, List<LevelGenStep> results)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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>();
if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.timing == 1)
{
results.Add(val);
}
}
}
public static void RunLateLevelGenSteps(List<LevelGenStep> steps)
{
foreach (LevelGenStep step in steps)
{
step.Execute();
}
}
}
public static class PropSpawnerHelpers
{
public static readonly HashSet<string> SafeToBatchPropNames = new HashSet<string>
{
"LuggageSpawner", "Ivy", "Geysers", "Weed", "ExploShrooms", "PoisonShrooms", "Vines", "BeachGrass", "Driftwood", "Behive",
"ShittyPiton", "Monsteras", "FlashPlant", "Shrub", "Pine", "Bushes", "Trees", "DeadTree", "Ice_DeadTree", "Palms"
};
public static bool TrySpawn(SpawnData spawnData, ref GameObject __result, GameObject[] props, List<PropSpawnerMod> modifiers, List<PropSpawnerConstraintPost> postConstraints, Transform parent, GameObject fallback, List<int> viewIDsToSend, List<PhotonView> viewsRequiringIDs)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_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)
GameObject val = props[Random.Range(0, props.Length)];
PhotonView val2 = default(PhotonView);
if ((Object)(object)val != (Object)null && val.TryGetComponent<PhotonView>(ref val2))
{
Quaternion randomRotationWithUp = GetRandomRotationWithUp(Vector3.up);
GameObject val3 = Object.Instantiate<GameObject>(val, spawnData.pos, randomRotationWithUp, parent);
if ((Object)(object)val3 == (Object)null)
{
Debug.LogError((object)("Failed to instantiate prop " + ((Object)val).name));
__result = null;
return false;
}
RemoveSpineIfLuggage(val3);
ApplyModifiers(val3, spawnData, modifiers);
if (!CheckAndHandlePostConstraints(val3, spawnData, postConstraints))
{
__result = null;
return false;
}
if ((Object)(object)val3 == (Object)null)
{
__result = null;
return false;
}
HandleIfBridge(val3);
if (PhotonNetwork.IsMasterClient)
{
viewIDsToSend.Add(AssignMasterClientViewID(val3));
}
else
{
CollectViewRequiringID(val3, viewsRequiringIDs);
}
__result = val3;
return false;
}
return true;
}
public static Quaternion GetRandomRotationWithUp(Vector3 normal)
{
//IL_0001: 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_0013: 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_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: 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_0020: 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_0022: 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_0028: 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)
Vector3 onUnitSphere = Random.onUnitSphere;
onUnitSphere.y = 0f;
onUnitSphere = Vector3.Cross(normal, Vector3.Cross(normal, onUnitSphere));
return Quaternion.LookRotation(onUnitSphere, normal);
}
public static bool CheckAndHandlePostConstraints(GameObject go, SpawnData spawnData, List<PropSpawnerConstraintPost> postConstraints)
{
foreach (PropSpawnerConstraintPost postConstraint in postConstraints)
{
if (postConstraint.mute || postConstraint.CheckConstraint(go, spawnData))
{
continue;
}
Object.DestroyImmediate((Object)(object)go);
return false;
}
return true;
}
public static void ApplyModifiers(GameObject go, SpawnData spawnData, List<PropSpawnerMod> modifiers)
{
foreach (PropSpawnerMod modifier in modifiers)
{
if (!modifier.mute)
{
modifier.ModifyObject(go, spawnData);
}
}
}
public static void RemoveSpineIfLuggage(GameObject go)
{
Luggage val = default(Luggage);
if (go.TryGetComponent<Luggage>(ref val))
{
SpineCheck component = go.GetComponent<SpineCheck>();
if ((Object)(object)component != (Object)null)
{
Object.DestroyImmediate((Object)(object)component);
}
}
}
public static void HandleIfBridge(GameObject go)
{
BreakableBridge @object = default(BreakableBridge);
if (go.TryGetComponent<BreakableBridge>(ref @object))
{
CollisionModifier[] componentsInChildren = go.GetComponentsInChildren<CollisionModifier>();
CollisionModifier[] array = componentsInChildren;
foreach (CollisionModifier val in array)
{
val.applyEffects = false;
val.onCollide = (Action<Character, CollisionModifier, Collision, Bodypart>)Delegate.Combine(val.onCollide, new Action<Character, CollisionModifier, Collision, Bodypart>(@object.OnBridgeCollision));
}
}
}
public static bool CheckIfBridge(GameObject go)
{
BreakableBridge val = default(BreakableBridge);
if (go.TryGetComponent<BreakableBridge>(ref val))
{
return true;
}
return false;
}
public static int AssignMasterClientViewID(GameObject go)
{
int num = PhotonNetwork.AllocateViewID(false);
PhotonView component = go.GetComponent<PhotonView>();
component.ViewID = num;
return num;
}
public static void CollectViewRequiringID(GameObject go, List<PhotonView> viewsRequiringIDs)
{
PhotonView component = go.GetComponent<PhotonView>();
viewsRequiringIDs.Add(component);
}
public static Ray[] BuildRays(PropSpawner spawner, Ray[] outRays, int count, Vector3 rayDir)
{
//IL_0009: 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_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < count; i++)
{
outRays[i] = GetSpawnRay(spawner.area, ((Component)spawner).transform, rayDir);
}
return outRays;
}
public static Ray GetSpawnRay(Vector2 area, Transform t, Vector3 rayDir)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: 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_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: 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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: 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_0095: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(Random.value, Random.value);
Vector3 val2 = t.position + t.right * Mathf.Lerp((0f - area.x) * 0.5f, area.x * 0.5f, val.x) + t.up * Mathf.Lerp((0f - area.y) * 0.5f, area.y * 0.5f, val.y);
return new Ray(val2, rayDir);
}
public static SpawnData BuildSpawnData(PropSpawner spawner, Ray ray, RaycastHit hit, bool hasHit, int count)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0022: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Expected O, but got Unknown
Vector3 val = ((Ray)(ref ray)).origin - ((Component)spawner).transform.position;
Vector2 placement = default(Vector2);
((Vector2)(ref placement))..ctor(Vector3.Dot(val, ((Component)spawner).transform.right) / spawner.area.x + 0.5f, Vector3.Dot(val, ((Component)spawner).transform.up) / spawner.area.y + 0.5f);
return new SpawnData
{
pos = ((RaycastHit)(ref hit)).point,
normal = ((RaycastHit)(ref hit)).normal,
rayDir = ((Component)spawner).transform.forward,
hit = hit,
spawnerTransform = ((Component)spawner).transform,
placement = placement,
spawnCount = count
};
}
}
}