using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BoplFixedMath;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Mathematics;
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(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("IUpdateable")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("IUpdateable")]
[assembly: AssemblyTitle("IUpdateable")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace IUpdateable
{
public static class OldUpdater
{
public class UpdatableComparer : IComparer<IUpdatable>
{
public int Compare(IUpdatable x, IUpdatable y)
{
if (x.GetHashCode() != y.GetHashCode())
{
_ = x.HierarchyNumber;
_ = y.HierarchyNumber;
}
return x.HierarchyNumber - y.HierarchyNumber;
}
}
public static Random random = new Random(37u);
public static List<IUpdatable> updatables = new List<IUpdatable>();
public static List<IUpdatable> toBeAddedUpdatables = new List<IUpdatable>();
public static UpdatableComparer updateComparer = new UpdatableComparer();
public static void RegisterUpdatable(IUpdatable objectToUpdate)
{
toBeAddedUpdatables.Add(objectToUpdate);
}
public static void InitSeed(uint seed)
{
((Random)(ref random)).InitState(seed);
}
public static void TickSimulation(Fix deltaTime)
{
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
//IL_040b: Unknown result type (might be due to invalid IL or missing references)
//IL_0410: Unknown result type (might be due to invalid IL or missing references)
//IL_0411: Unknown result type (might be due to invalid IL or missing references)
//IL_0416: Unknown result type (might be due to invalid IL or missing references)
//IL_041b: Unknown result type (might be due to invalid IL or missing references)
//IL_0420: Unknown result type (might be due to invalid IL or missing references)
//IL_0421: Unknown result type (might be due to invalid IL or missing references)
//IL_0426: Unknown result type (might be due to invalid IL or missing references)
bool loadedALevelThisUpdate = Updater.LoadedALevelThisUpdate;
bool gameHasStopped = Updater.gameHasStopped;
int simulationTicks = Updater.SimulationTicks;
List<Player> list = PlayerHandler.Get().PlayerList();
if (loadedALevelThisUpdate)
{
gameHasStopped = false;
}
for (int num = toBeAddedUpdatables.Count - 1; num >= 0; num--)
{
if (toBeAddedUpdatables[num] == null || toBeAddedUpdatables[num].IsDestroyed)
{
toBeAddedUpdatables.RemoveAt(num);
}
}
for (int i = 0; i < toBeAddedUpdatables.Count; i++)
{
IUpdatable value = toBeAddedUpdatables[i];
toBeAddedUpdatables[i] = value;
}
toBeAddedUpdatables.Sort(updateComparer);
for (int j = 0; j < toBeAddedUpdatables.Count; j++)
{
if (toBeAddedUpdatables[j] != null && !toBeAddedUpdatables[j].IsDestroyed)
{
toBeAddedUpdatables[j].Init();
}
}
for (int k = 0; k < toBeAddedUpdatables.Count; k++)
{
updatables.Add(toBeAddedUpdatables[k]);
}
toBeAddedUpdatables.Clear();
if (!GameTime.IsTimeStopped())
{
DetPhysics.Get().UpdateDuplicatedObjects();
}
for (int num2 = updatables.Count - 1; num2 >= 0; num2--)
{
if (updatables[num2] == null || updatables[num2].IsDestroyed)
{
updatables[num2]?.OnDestroyUpdatable();
updatables.RemoveAt(num2);
}
}
for (int l = 0; l < updatables.Count; l++)
{
if (updatables[l] != null && !updatables[l].IsDestroyed && updatables[l].IsEnabled())
{
updatables[l].UpdateSim(deltaTime);
}
}
if (Updater.LoadedALevelThisUpdate)
{
Updater.SimTimePassed += deltaTime;
Updater.SimTimeSinceLevelLoaded += deltaTime;
simulationTicks++;
Updater.LoadedALevelThisUpdate = false;
return;
}
DetPhysics.Get().Simulate(deltaTime);
for (int m = 0; m < updatables.Count; m++)
{
if (updatables[m] != null && !updatables[m].IsDestroyed && updatables[m].IsEnabled())
{
updatables[m].LateUpdateSim(deltaTime);
}
}
DetPhysics.Get().VeryLateRopeUpdate();
DetPhysics.Get().UpdateRopeMesh_parallell();
for (int num3 = updatables.Count - 1; num3 >= 0; num3--)
{
if (updatables[num3] == null || updatables[num3].IsDestroyed)
{
updatables[num3]?.OnDestroyUpdatable();
updatables.RemoveAt(num3);
}
}
while (Updater.destroyedObjects.Count > 0)
{
Object.DestroyImmediate((Object)(object)Updater.destroyedObjects.Dequeue(), false);
}
while (Updater.destroyedMonos.Count > 0)
{
Object.DestroyImmediate((Object)(object)Updater.destroyedMonos.Dequeue(), false);
}
Updater.SimTimePassed += deltaTime;
Updater.SimTimeSinceLevelLoaded += deltaTime;
simulationTicks++;
}
}
public interface IUpdatable
{
bool IsDestroyed { get; set; }
int HierarchyNumber { get; set; }
void Init();
void UpdateSim(Fix SimDeltaTime);
void LateUpdateSim(Fix SimDeltaTime);
void OnDestroyUpdatable();
bool IsEnabled();
}
[BepInPlugin("com.erwer.IUpdateable", "IUpdateable", "2.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.erwer.IUpdateable";
public const string PLUGIN_NAME = "IUpdateable";
public const string PLUGIN_VERSION = "2.0.0";
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.erwer.IUpdateable is loaded! Added IUpdateable to game..");
Harmony val = new Harmony("com.erwer.IUpdateable");
val.PatchAll(typeof(Patches));
}
}
public class Patches
{
[HarmonyPatch(typeof(Updater), "Update")]
[HarmonyPrefix]
public static bool Update(Updater __instance)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: 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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
if (__instance.autoUpdate && !GameLobby.isOnlineGame && !GameLobby.isPlayingAReplay)
{
__instance.autoUpdateAccum += Time.deltaTime;
while (__instance.autoUpdateAccum > 0f)
{
__instance.autoUpdateAccum -= (float)GameTime.FixedTimeStep;
if (Updater.hitStopFrames > 0)
{
Updater.hitStopFrames--;
Updater.SimTimePassed += GameTime.FixedTimeStep;
Updater.SimTimeSinceLevelLoaded += GameTime.FixedTimeStep;
Updater.SimulationTicks++;
}
else
{
Updater.TickSimulation(GameTime.FixedTimeStep);
OldUpdater.TickSimulation(GameTime.FixedTimeStep);
}
}
}
return false;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "IUpdateable";
public const string PLUGIN_NAME = "IUpdateable";
public const string PLUGIN_VERSION = "1.0.0";
}
}