using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Shapez2Mods.FastForwarder.UI;
using UnityEngine;
using UnityEngine.UI;
[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("FastForwarder")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c6f6bb419f5c821dad74be168a0a24ea54f17eb6")]
[assembly: AssemblyProduct("FastForwarder")]
[assembly: AssemblyTitle("FastForwarder")]
[assembly: AssemblyVersion("1.0.0.0")]
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 Shapez2Mods.FastForwarder
{
[BepInPlugin("yujis.shapez2mods.fastforwarder", "Fast Forwarder", "1.0.6")]
public class FastForwarderPlugin : BaseUnityPlugin
{
internal static FastForwarderPlugin Instance;
internal static GameSessionOrchestrator CurrentOrchestrator;
internal static SimulationSpeedManager SimManager;
internal static ManualLogSource Log;
private void Awake()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
try
{
Harmony val = new Harmony("yujis.shapez2mods.fastforwarder");
val.PatchAll();
Log.LogInfo((object)"Fast Forwarder: Harmony patches applied.");
}
catch (Exception arg)
{
Log.LogError((object)$"Fast Forwarder: Failed to apply Harmony patches: {arg}");
}
Log.LogInfo((object)"Fast Forwarder loaded.");
}
public static void TryInitialize(GameSessionOrchestrator orchestrator)
{
Log.LogInfo((object)"[FastForwarder] TryInitialize called.");
CurrentOrchestrator = orchestrator;
if (CurrentOrchestrator == null)
{
Log.LogWarning((object)"[FastForwarder] GameSessionOrchestrator is null.");
return;
}
Traverse val = Traverse.Create((object)orchestrator);
SimManager = val.Property("SimulationSpeed", (object[])null).GetValue<SimulationSpeedManager>();
if (SimManager == null)
{
SimManager = val.Field("SimulationSpeed").GetValue<SimulationSpeedManager>();
}
if (SimManager == null)
{
Log.LogWarning((object)"[FastForwarder] SimulationSpeedManager not found via Traverse.");
return;
}
try
{
Type type = AccessTools.TypeByName("Ticks");
Type type2 = AccessTools.TypeByName("SimulationConstants");
if (type != null && type2 != null)
{
object value = Traverse.Create(type).Method("FromSeconds", new object[1] { 5f }).GetValue();
Traverse.Create(type2).Field("MaxSimulatorIncrement").SetValue(value);
Log.LogInfo((object)"[FastForwarder] SimulationConstants.MaxSimulatorIncrement increased to 5s.");
}
}
catch (Exception ex)
{
Log.LogWarning((object)("[FastForwarder] Could not override SimulationConstants.MaxSimulatorIncrement: " + ex.Message));
}
Log.LogInfo((object)"[FastForwarder] SimulationSpeedManager successfully hooked.");
CreateUI();
SetSpeed(1f);
}
public static void SetSpeed(float speed)
{
if (SimManager != null)
{
if (speed == 0f)
{
SimManager.IsPaused = true;
}
else
{
SimManager.IsPaused = false;
}
SimManager.Speed = speed;
Log.LogInfo((object)$"[FastForwarder] Speed set to {speed}x");
}
}
private static void CreateUI()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
string text = "FastForwarder_UI_Root";
GameObject val = GameObject.Find(text);
if ((Object)(object)val == (Object)null)
{
GameObject val2 = new GameObject(text);
Object.DontDestroyOnLoad((Object)(object)val2);
val2.AddComponent<FastForwarderUI>();
Log.LogInfo((object)"[FastForwarder] FastForwarderUI created on new GameObject.");
}
}
}
}
namespace Shapez2Mods.FastForwarder.Patches
{
[HarmonyPatch]
public static class GameStartPatches
{
private static bool menuWasActive = true;
[HarmonyPostfix]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static void ContinueExisting_Postfix(GameStartOptionsContinueExisting __instance)
{
CheckMenuMode(__instance.MenuMode);
}
[HarmonyPostfix]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static void StartNew_Postfix(GameStartOptionsStartNew __instance)
{
CheckMenuMode(__instance.MenuMode);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameSessionOrchestrator), "Init")]
private static void GameSessionOrchestrator_Init_Postfix(GameSessionOrchestrator __instance)
{
if (menuWasActive)
{
FastForwarderPlugin.Log.LogInfo((object)"[FastForwarder] Skipping GameSessionOrchestrator.Init.");
return;
}
FastForwarderPlugin.Log.LogInfo((object)"[FastForwarder] GameSessionOrchestrator.Init() detected.");
FastForwarderPlugin.TryInitialize(__instance);
}
private static void CheckMenuMode(bool menuMode)
{
if (menuMode && !menuWasActive)
{
menuWasActive = true;
}
else if (!menuMode && menuWasActive)
{
menuWasActive = false;
FastForwarderPlugin.Log.LogInfo((object)"[FastForwarder] Menu closed.");
}
}
}
}
namespace Shapez2Mods.FastForwarder.UI
{
public class FastForwarderUI : MonoBehaviour
{
private readonly float[] speeds = new float[5] { 0f, 1f, 5f, 10f, 25f };
private readonly string[] labels = new string[5] { "II", ">", ">>", ">>>", ">|" };
private int selectedIndex = 1;
private GameObject raycastBlocker = null;
private void Start()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: 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_0102: 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)
raycastBlocker = new GameObject("FastForwarder_RaycastBlocker");
raycastBlocker.layer = LayerMask.NameToLayer("UI");
Canvas val = raycastBlocker.AddComponent<Canvas>();
val.renderMode = (RenderMode)0;
val.sortingOrder = 30000;
raycastBlocker.AddComponent<GraphicRaycaster>();
GameObject val2 = new GameObject("BlockerImage");
val2.transform.SetParent(raycastBlocker.transform, false);
val2.layer = LayerMask.NameToLayer("UI");
Image val3 = val2.AddComponent<Image>();
((Graphic)val3).color = new Color(0f, 0f, 0f, 0.001f);
RectTransform component = ((Component)val3).GetComponent<RectTransform>();
component.anchorMin = new Vector2(1f, 1f);
component.anchorMax = new Vector2(1f, 1f);
component.pivot = new Vector2(1f, 1f);
component.sizeDelta = new Vector2(200f, 40f);
component.anchoredPosition = new Vector2(-10f, -120f);
}
private void OnDestroy()
{
if ((Object)(object)raycastBlocker != (Object)null)
{
Object.Destroy((Object)(object)raycastBlocker);
}
}
private void OnGUI()
{
//IL_0034: 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_004b: Expected O, but got Unknown
//IL_0062: 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_0139: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: 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_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Invalid comparison between Unknown and I4
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Invalid comparison between Unknown and I4
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Invalid comparison between Unknown and I4
if (FastForwarderPlugin.SimManager == null)
{
return;
}
Rect val = default(Rect);
((Rect)(ref val))..ctor((float)(Screen.width - 210), 120f, 200f, 40f);
GUI.BeginGroup(val);
GUIStyle val2 = new GUIStyle(GUI.skin.button);
val2.fontSize = 14;
val2.fontStyle = (FontStyle)1;
val2.normal.textColor = Color.white;
val2.hover.textColor = Color.white;
for (int i = 0; i < speeds.Length; i++)
{
if (i == selectedIndex)
{
GUI.backgroundColor = new Color(1f, 0.55f, 0.1f);
}
else
{
GUI.backgroundColor = new Color(0.3f, 0.3f, 0.3f);
}
if (GUI.Button(new Rect((float)(i * 38), 0f, 35f, 30f), labels[i], val2))
{
selectedIndex = i;
FastForwarderPlugin.SetSpeed(speeds[i]);
}
}
GUI.EndGroup();
if (((Rect)(ref val)).Contains(Event.current.mousePosition))
{
Event current = Event.current;
if ((int)current.type == 0 || (int)current.type == 1 || (int)current.type == 6 || (int)current.type == 3)
{
current.Use();
}
}
GUI.backgroundColor = Color.white;
if (FastForwarderPlugin.CurrentOrchestrator == null)
{
LogOutput_OnDestroy();
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
private void LogOutput_OnDestroy()
{
FastForwarderPlugin.Log.LogInfo((object)"[FastForwarder] Destroying UI GameObject.");
}
}
}