using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On;
using UnityEngine;
[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: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("Glacc.TrapSpawnTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+3ad5a9e451277e75e082287c81684ca03ebd4673")]
[assembly: AssemblyProduct("TrapSpawnTweaks")]
[assembly: AssemblyTitle("Glacc.TrapSpawnTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.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 TrapSpawnTweaks
{
[BepInPlugin("Glacc.TrapSpawnTweaks", "TrapSpawnTweaks", "0.1.0")]
public class TrapSpawnTweaks : BaseUnityPlugin
{
private struct LevelConfig
{
public ConfigEntry<float> landmineSpawnMultiplier;
public ConfigEntry<float> turretSpawnMultiplier;
public ConfigEntry<float> spikeTrapSpawnMultiplier;
}
[CompilerGenerated]
private static class <>O
{
public static hook_SpawnMapObjects <0>__Hook_RoundManager_SpawnMapObjects;
}
private static ConfigFile configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "TrapSpawnTweaks.cfg"), false);
private static float landmineSpawnMultiplier = 1f;
private static float turretSpawnMultiplier = 1f;
private static float spikeTrapSpawnMultiplier = 1f;
private static bool limitNumberToSpawn = false;
private static float maxNumberToSpawn = 100f;
private const string landmineHazerdName = "Landmine";
private const string turretHazardName = "TurretContainer";
private const string spikeHazardName = "SpikeRoofTrapHazard";
private static int clampResolution = 100;
private static bool mapDataSaved = false;
public static TrapSpawnTweaks Instance { get; private set; } = null;
internal static ManualLogSource Logger { get; private set; } = null;
private static void LoadGlobalConfig()
{
LevelConfig levelConfig = default(LevelConfig);
levelConfig.landmineSpawnMultiplier = configFile.Bind<float>("- Global -", "Landmine Spawn Multiplier", 1f, (ConfigDescription)null);
levelConfig.turretSpawnMultiplier = configFile.Bind<float>("- Global -", "Turret Spawn Multiplier", 1f, (ConfigDescription)null);
levelConfig.spikeTrapSpawnMultiplier = configFile.Bind<float>("- Global -", "Spike Trap Spawn Multiplier", 1f, (ConfigDescription)null);
ConfigEntry<bool> val = configFile.Bind<bool>("- Global -", "Limit Number To Spawn", false, "(Experimental) Limits max spawns of each type of trap.");
ConfigEntry<float> val2 = configFile.Bind<float>("- Global -", "Max Number To Spawn", 100f, (ConfigDescription)null);
limitNumberToSpawn = val.Value;
maxNumberToSpawn = val2.Value;
landmineSpawnMultiplier = levelConfig.landmineSpawnMultiplier.Value;
turretSpawnMultiplier = levelConfig.turretSpawnMultiplier.Value;
spikeTrapSpawnMultiplier = levelConfig.spikeTrapSpawnMultiplier.Value;
configFile.Save();
}
private static Keyframe[] ClampValues(AnimationCurve animationCurve, float multiplier)
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
List<Keyframe> list = new List<Keyframe>();
float num = 0f;
float num2 = 1f;
Keyframe item = default(Keyframe);
for (int i = 0; i < clampResolution; i++)
{
float num3 = num + (num2 - num) * ((float)i / (float)clampResolution);
float num4 = animationCurve.Evaluate(num3) * multiplier;
if (num4 > maxNumberToSpawn)
{
num4 = maxNumberToSpawn;
}
((Keyframe)(ref item))..ctor(num3, num4);
((Keyframe)(ref item)).tangentModeInternal = 2;
list.Add(item);
}
return list.ToArray();
}
private static void CopyFrame(Keyframe src, ref Keyframe dest)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
((Keyframe)(ref dest)).time = ((Keyframe)(ref src)).time;
((Keyframe)(ref dest)).value = ((Keyframe)(ref src)).value;
((Keyframe)(ref dest)).inTangent = ((Keyframe)(ref src)).inTangent;
((Keyframe)(ref dest)).outTangent = ((Keyframe)(ref src)).outTangent;
((Keyframe)(ref dest)).inWeight = ((Keyframe)(ref src)).inWeight;
((Keyframe)(ref dest)).outWeight = ((Keyframe)(ref src)).outWeight;
((Keyframe)(ref dest)).weightedMode = ((Keyframe)(ref src)).weightedMode;
}
private static void TweakValues()
{
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: 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_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
if (!mapDataSaved)
{
StartOfRound instance = StartOfRound.Instance;
for (int i = 0; i < instance.levels.Length; i++)
{
SelectableLevel val = instance.levels[i];
Logger.LogInfo((object)("Level Name: " + ((Object)val).name));
LevelConfig levelConfig = default(LevelConfig);
levelConfig.landmineSpawnMultiplier = configFile.Bind<float>(((Object)val).name, "Landmine Spawn Multiplier", 1f, (ConfigDescription)null);
levelConfig.turretSpawnMultiplier = configFile.Bind<float>(((Object)val).name, "Turret Spawn Multiplier", 1f, (ConfigDescription)null);
levelConfig.spikeTrapSpawnMultiplier = configFile.Bind<float>(((Object)val).name, "Spike Trap Spawn Multiplier", 1f, (ConfigDescription)null);
Logger.LogInfo((object)" - Original Values:");
for (int j = 0; j < val.spawnableMapObjects.Length; j++)
{
SpawnableMapObject val2 = val.spawnableMapObjects[j];
Logger.LogInfo((object)(" - " + ((Object)val2.prefabToSpawn).name));
Keyframe[] keys = val2.numberToSpawn.keys;
for (int k = 0; k < keys.Length; k++)
{
Logger.LogInfo((object)(" - [" + k + "]:" + ((Keyframe)(ref keys[k])).value));
}
float num = 1f;
switch (((Object)val2.prefabToSpawn).name)
{
case "Landmine":
num = levelConfig.landmineSpawnMultiplier.Value * landmineSpawnMultiplier;
break;
case "TurretContainer":
num = levelConfig.turretSpawnMultiplier.Value * turretSpawnMultiplier;
break;
case "SpikeRoofTrapHazard":
num = levelConfig.spikeTrapSpawnMultiplier.Value * spikeTrapSpawnMultiplier;
break;
}
bool flag = true;
if (!limitNumberToSpawn)
{
Keyframe[] array = (Keyframe[])(object)new Keyframe[keys.Length];
for (int k = 0; k < keys.Length; k++)
{
Keyframe src = keys[k];
Keyframe dest = default(Keyframe);
CopyFrame(src, ref dest);
((Keyframe)(ref dest)).value = ((Keyframe)(ref src)).value * num;
((Keyframe)(ref dest)).time = ((Keyframe)(ref src)).time;
((Keyframe)(ref dest)).inTangent = ((Keyframe)(ref src)).inTangent * num;
((Keyframe)(ref dest)).outTangent = ((Keyframe)(ref src)).outTangent * num;
array[k] = dest;
}
val2.numberToSpawn.keys = array;
}
else
{
val2.numberToSpawn.keys = ClampValues(val2.numberToSpawn, num);
}
}
Logger.LogInfo((object)" - New Values:");
bool flag2 = false;
for (int j = 0; j < val.spawnableMapObjects.Length; j++)
{
SpawnableMapObject val3 = val.spawnableMapObjects[j];
Logger.LogInfo((object)(" - " + ((Object)val3.prefabToSpawn).name));
for (int l = 0; l < val3.numberToSpawn.keys.Length; l++)
{
float value = ((Keyframe)(ref val3.numberToSpawn.keys[l])).value;
if (value < maxNumberToSpawn)
{
flag2 = false;
}
if (!flag2)
{
Logger.LogInfo((object)(" - [" + l + "]:" + value));
}
if (value >= maxNumberToSpawn)
{
flag2 = true;
}
}
}
}
mapDataSaved = true;
configFile.Save();
Logger.LogInfo((object)"Map object spawning info has been updated.");
}
else
{
Logger.LogInfo((object)"Map object spawning info was updated, no need to update again.");
}
}
private static void Hook_StartOfRound_Awake(orig_Awake orig, StartOfRound self)
{
orig.Invoke(self);
TweakValues();
}
private static void Hook_RoundManager_SpawnMapObjects(orig_SpawnMapObjects orig, RoundManager self)
{
TweakValues();
SelectableLevel currentLevel = self.currentLevel;
if ((Object)(object)currentLevel != (Object)null)
{
Logger.LogInfo((object)("Level Name: " + ((Object)currentLevel).name));
Logger.LogInfo((object)" - Current Values:");
SpawnableMapObject[] spawnableMapObjects = currentLevel.spawnableMapObjects;
foreach (SpawnableMapObject val in spawnableMapObjects)
{
Logger.LogInfo((object)(" - " + ((Object)val.prefabToSpawn).name));
bool flag = true;
bool flag2 = false;
for (int j = 0; j < val.numberToSpawn.keys.Length; j++)
{
float value = ((Keyframe)(ref val.numberToSpawn.keys[j])).value;
if (value < maxNumberToSpawn)
{
flag2 = false;
}
if (!flag2)
{
Logger.LogInfo((object)(" - [" + j + "]:" + value));
}
if (value >= maxNumberToSpawn)
{
flag2 = true;
}
}
}
}
orig.Invoke(self);
}
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
LoadGlobalConfig();
Hook();
Logger.LogInfo((object)"Glacc.TrapSpawnTweaks v0.1.0 has loaded!");
}
internal static void Hook()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
Logger.LogDebug((object)"Hooking...");
object obj = <>O.<0>__Hook_RoundManager_SpawnMapObjects;
if (obj == null)
{
hook_SpawnMapObjects val = Hook_RoundManager_SpawnMapObjects;
<>O.<0>__Hook_RoundManager_SpawnMapObjects = val;
obj = (object)val;
}
RoundManager.SpawnMapObjects += (hook_SpawnMapObjects)obj;
Logger.LogDebug((object)"Finished Hooking!");
}
internal static void Unhook()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
Logger.LogDebug((object)"Unhooking...");
object obj = <>O.<0>__Hook_RoundManager_SpawnMapObjects;
if (obj == null)
{
hook_SpawnMapObjects val = Hook_RoundManager_SpawnMapObjects;
<>O.<0>__Hook_RoundManager_SpawnMapObjects = val;
obj = (object)val;
}
RoundManager.SpawnMapObjects -= (hook_SpawnMapObjects)obj;
Logger.LogDebug((object)"Finished Unhooking!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Glacc.TrapSpawnTweaks";
public const string PLUGIN_NAME = "TrapSpawnTweaks";
public const string PLUGIN_VERSION = "0.1.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}