using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GlobalEnums;
using InControl;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.Networking;
[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("Teleport")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2+40ddc1699d0a548fe17b3f0014eba18cd992b311")]
[assembly: AssemblyProduct("Teleport")]
[assembly: AssemblyTitle("Teleport Mod")]
[assembly: AssemblyVersion("1.1.2.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;
}
}
}
[BepInPlugin("Mhz.TeleportMod", "Teleport Mod", "1.1.2")]
public class TeleportMod : BaseUnityPlugin
{
public struct SaveSlot
{
public Vector3 position;
public string scene;
public bool hasData;
public SaveSlot(Vector3 pos, string sceneName)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
position = pos;
scene = sceneName;
hasData = true;
}
}
[Serializable]
public class PersistentData
{
public Dictionary<int, SerializableSaveSlot> saveSlots = new Dictionary<int, SerializableSaveSlot>();
}
[Serializable]
public class SerializableSaveSlot
{
public float x;
public float y;
public float z;
public string scene = "";
public bool hasData = false;
public SerializableSaveSlot()
{
}
public SerializableSaveSlot(SaveSlot slot)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
x = slot.position.x;
y = slot.position.y;
z = slot.position.z;
scene = slot.scene ?? "";
hasData = slot.hasData;
}
public SaveSlot ToSaveSlot()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
return new SaveSlot(new Vector3(x, y, z), scene);
}
}
[CompilerGenerated]
private sealed class <CheckTeleportSafety>d__82 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Vector3 originalPosition;
public TeleportMod <>4__this;
private Collider2D <heroCollider>5__1;
private int <groundLayerMask>5__2;
private Collider2D <overlapping>5__3;
private Vector3 <safePosition>5__4;
private Exception <ex>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CheckTeleportSafety>d__82(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<heroCollider>5__1 = null;
<overlapping>5__3 = null;
<ex>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
try
{
if ((Object)(object)HeroController.instance == (Object)null)
{
return false;
}
<heroCollider>5__1 = ((Component)HeroController.instance).GetComponent<Collider2D>();
if ((Object)(object)<heroCollider>5__1 == (Object)null)
{
return false;
}
<groundLayerMask>5__2 = LayerMask.GetMask(new string[1] { "Terrain" });
Bounds bounds = <heroCollider>5__1.bounds;
Vector2 val = Vector2.op_Implicit(((Bounds)(ref bounds)).center);
bounds = <heroCollider>5__1.bounds;
<overlapping>5__3 = Physics2D.OverlapBox(val, Vector2.op_Implicit(((Bounds)(ref bounds)).size), 0f, <groundLayerMask>5__2);
if ((Object)(object)<overlapping>5__3 != (Object)null)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"检测到传送后卡在地形中,尝试修复位置");
}
<safePosition>5__4 = <>4__this.FindSafePositionNearby(originalPosition);
if (<safePosition>5__4 != Vector3.zero)
{
<>4__this.PerformTeleport(<safePosition>5__4);
LogInfo($"已修复到安全位置: {<safePosition>5__4}");
}
else
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogWarning((object)"无法找到安全位置,建议使用Alt+6重新进入场景");
}
}
}
<heroCollider>5__1 = null;
<overlapping>5__3 = null;
}
catch (Exception ex)
{
<ex>5__5 = ex;
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)("检查传送安全性时发生错误: " + <ex>5__5.Message));
}
}
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <PreloadAudioClip>d__75 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public TeleportMod <>4__this;
private string <fileName>5__1;
private Assembly <assembly>5__2;
private string <dllDirectory>5__3;
private string <audioFilePath>5__4;
private string <tempPath>5__5;
private byte[] <audioData>5__6;
private Exception <ex>5__7;
private UnityWebRequest <request>5__8;
private Exception <ex>5__9;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PreloadAudioClip>d__75(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<fileName>5__1 = null;
<assembly>5__2 = null;
<dllDirectory>5__3 = null;
<audioFilePath>5__4 = null;
<tempPath>5__5 = null;
<audioData>5__6 = null;
<ex>5__7 = null;
<request>5__8 = null;
<ex>5__9 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Invalid comparison between Unknown and I4
try
{
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
LogInfo("开始预加载音频文件...");
ConfigEntry<bool>? enableEasterEggAudio = TeleportMod.enableEasterEggAudio;
<fileName>5__1 = ((enableEasterEggAudio != null && enableEasterEggAudio.Value) ? "manbo.wav" : "Gamesave.wav");
<assembly>5__2 = Assembly.GetExecutingAssembly();
<dllDirectory>5__3 = Path.GetDirectoryName(<assembly>5__2.Location);
<audioFilePath>5__4 = Path.Combine(<dllDirectory>5__3, <fileName>5__1);
LogInfo($"选择音频文件: {<fileName>5__1} (彩蛋音效: {TeleportMod.enableEasterEggAudio?.Value})");
LogInfo("音频文件路径: " + <audioFilePath>5__4);
<tempPath>5__5 = "";
try
{
if (!File.Exists(<audioFilePath>5__4))
{
ManualLogSource? logger4 = Logger;
if (logger4 != null)
{
logger4.LogWarning((object)("未找到音频文件: " + <audioFilePath>5__4));
}
return false;
}
<audioData>5__6 = File.ReadAllBytes(<audioFilePath>5__4);
LogInfo($"成功读取音频文件,大小: {<audioData>5__6.Length} 字节");
<tempPath>5__5 = Path.GetTempFileName() + ".wav";
File.WriteAllBytes(<tempPath>5__5, <audioData>5__6);
<audioData>5__6 = null;
}
catch (Exception ex)
{
<ex>5__7 = ex;
ManualLogSource? logger5 = Logger;
if (logger5 != null)
{
logger5.LogError((object)("读取音频文件时发生错误: " + <ex>5__7.Message));
}
return false;
}
<request>5__8 = UnityWebRequestMultimedia.GetAudioClip("file://" + <tempPath>5__5, (AudioType)20);
<>1__state = -3;
<>2__current = <request>5__8.SendWebRequest();
<>1__state = 1;
return true;
}
case 1:
<>1__state = -3;
if ((int)<request>5__8.result == 1)
{
cachedSaveAudioClip = DownloadHandlerAudioClip.GetContent(<request>5__8);
if ((Object)(object)cachedSaveAudioClip != (Object)null)
{
Object.DontDestroyOnLoad((Object)(object)cachedSaveAudioClip);
LogInfo($"音频预加载成功 - 长度: {cachedSaveAudioClip.length}秒, 频率: {cachedSaveAudioClip.frequency}, 声道: {cachedSaveAudioClip.channels}");
}
else
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"无法获取AudioClip");
}
}
}
else
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogError((object)("预加载音频失败: " + <request>5__8.error));
}
}
<>m__Finally1();
<request>5__8 = null;
try
{
if (!string.IsNullOrEmpty(<tempPath>5__5) && File.Exists(<tempPath>5__5))
{
File.Delete(<tempPath>5__5);
LogInfo("已清理预加载临时文件");
}
}
catch (Exception ex)
{
<ex>5__9 = ex;
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)("删除预加载临时文件失败: " + <ex>5__9.Message));
}
}
return false;
}
}
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 (<request>5__8 != null)
{
((IDisposable)<request>5__8).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <TeleportWithSceneChange>d__78 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public string targetScene;
public Vector3 targetPosition;
public TeleportMod <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <TeleportWithSceneChange>d__78(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.TeleportWithSceneChange(targetScene, targetPosition, null));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <TeleportWithSceneChange>d__79 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public string targetScene;
public Vector3 targetPosition;
public string entryPointName;
public TeleportMod <>4__this;
private string <useEntryPoint>5__1;
private Exception <ex>5__2;
private Vector3 <finalPosition>5__3;
private (Vector3 position, string scene) <benchInfo>5__4;
private Exception <ex>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <TeleportWithSceneChange>d__79(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<useEntryPoint>5__1 = null;
<ex>5__2 = null;
<benchInfo>5__4 = default((Vector3, string));
<ex>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Expected O, but got Unknown
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: 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_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Expected O, but got Unknown
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
LogInfo("开始场景切换到: " + targetScene);
<useEntryPoint>5__1 = entryPointName;
if (string.IsNullOrEmpty(<useEntryPoint>5__1))
{
<useEntryPoint>5__1 = <>4__this.GetBestEntryPointForScene(targetScene);
}
LogInfo("使用入口点: " + <useEntryPoint>5__1);
try
{
GameManager.instance.BeginSceneTransition(new SceneLoadInfo
{
SceneName = targetScene,
EntryGateName = <useEntryPoint>5__1,
HeroLeaveDirection = (GatePosition)5,
EntryDelay = 0f,
Visualization = (SceneLoadVisualizations)0,
AlwaysUnloadUnusedAssets = true
});
}
catch (Exception ex)
{
<ex>5__2 = ex;
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)("开始场景切换时发生错误: " + <ex>5__2.Message));
}
return false;
}
<>2__current = (object)new WaitWhile((Func<bool>)delegate
{
GameManager instance2 = GameManager.instance;
HeroController instance3 = HeroController.instance;
return (Object)(object)instance2 == (Object)null || (Object)(object)instance3 == (Object)null || instance2.IsInSceneTransition || !instance3.isHeroInPosition || instance3.cState.transitioning;
});
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>2__current = (object)new WaitUntil((Func<bool>)delegate
{
HeroController instance = HeroController.instance;
return (Object)(object)instance != (Object)null && instance.CanInput();
});
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
try
{
<finalPosition>5__3 = targetPosition;
if (targetPosition == Vector3.one)
{
LogInfo("获取椅子在新场景中的真实坐标");
<benchInfo>5__4 = <>4__this.GetBenchPositionAndScene();
if (!(<benchInfo>5__4.position != Vector3.zero) || !(<benchInfo>5__4.position != Vector3.one))
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)"场景切换后仍无法找到椅子坐标,使用入口点位置");
}
return false;
}
<finalPosition>5__3 = <benchInfo>5__4.position;
LogInfo($"找到椅子坐标: {<finalPosition>5__3}");
<benchInfo>5__4 = default((Vector3, string));
}
if (targetPosition != Vector3.zero)
{
LogInfo($"场景切换完成,传送到位置: {<finalPosition>5__3}");
<>4__this.PerformSafeTeleport(<finalPosition>5__3);
}
else
{
LogInfo("场景切换完成,已在安全入口点位置");
}
}
catch (Exception ex)
{
<ex>5__5 = ex;
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogError((object)("传送到目标位置时发生错误: " + <ex>5__5.Message));
}
}
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static ManualLogSource? Logger;
private static ConfigEntry<bool>? enableDetailedLogging;
private static ConfigEntry<bool>? enableGamepadSupport;
private static ConfigEntry<bool>? enableEasterEggAudio;
private static ConfigEntry<string>? saveModifierKey;
private static ConfigEntry<string>? teleportModifierKey;
private static ConfigEntry<string>? resetModifierKey;
private static ConfigEntry<string>? gamepadSlot1Key;
private static ConfigEntry<string>? gamepadSlot2Key;
private static ConfigEntry<string>? gamepadSlot3Key;
private static ConfigEntry<string>? gamepadSlot4Key;
private static ConfigEntry<string>? gamepadSlot5Key;
private static ConfigEntry<string>? gamepadTeleportModifier1;
private static ConfigEntry<string>? gamepadTeleportModifier2;
private static ConfigEntry<string>? gamepadSaveModifier;
private static ConfigEntry<string>? gamepadSaveTrigger;
private static ConfigEntry<string>? gamepadSafeRespawnKey;
private static ConfigEntry<string>? gamepadHardcodedTeleportKey;
private static ConfigEntry<string>? gamepadBenchTeleportKey;
private static ConfigEntry<string>? gamepadClearAllModifier1;
private static ConfigEntry<string>? gamepadClearAllModifier2;
private static ConfigEntry<string>? gamepadClearAllTrigger;
private static ConfigEntry<string>? slot1Key;
private static ConfigEntry<string>? slot2Key;
private static ConfigEntry<string>? slot3Key;
private static ConfigEntry<string>? slot4Key;
private static ConfigEntry<string>? slot5Key;
private static ConfigEntry<string>? safeRespawnKey;
private static ConfigEntry<string>? resetAllKey;
private static ConfigEntry<string>? hardcodedTeleportKey;
private static ConfigEntry<string>? benchTeleportKey;
private static ConfigEntry<float>? audioVolume;
private static Dictionary<int, SaveSlot> saveSlots = new Dictionary<int, SaveSlot>();
private static int currentEntryPointIndex = 0;
private static string lastUsedScene = "";
private static bool wasVerticalPressed = false;
private static bool wasHorizontalPressed = false;
private static GameObject? audioPlayerObject = null;
private static AudioSource? audioPlayerSource = null;
private static AudioClip? cachedSaveAudioClip = null;
private static float lastSaveAudioTime = 0f;
private const float AUDIO_COOLDOWN = 0.1f;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
enableDetailedLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("日志设置 | Logging", "启用详细日志 | Enable Detailed Logging", false, "是否启用详细的传送日志输出 | Enable detailed teleport logging output");
enableGamepadSupport = ((BaseUnityPlugin)this).Config.Bind<bool>("控制设置 | Controls", "启用手柄支持 | Enable Gamepad Support", true, "是否启用手柄控制传送功能。操作方法:传送=LB+RB+方向键/A,保存=LB+Start+方向键/A,安全重生=LB+RB+Y,硬编码传送=LB+RB+X,重置所有坐标=LB+Select+Start | Enable gamepad control for teleport functions. Controls: Teleport=LB+RB+Directional/A, Save=LB+Start+Directional/A, Safe respawn=LB+RB+Y, Hardcoded teleport=LB+RB+X, Reset all coordinates=LB+Select+Start");
enableEasterEggAudio = ((BaseUnityPlugin)this).Config.Bind<bool>("音效设置 | Audio Settings", "启用彩蛋音效 | Enable Easter Egg Audio", false, "是否启用彩蛋音效。开启后存档时播放特殊音效,关闭时播放默认音效。需要重启游戏生效 | Enable easter egg audio effect. When enabled, plays special sound effect when saving, otherwise plays default sound effect. Requires game restart to take effect");
audioVolume = ((BaseUnityPlugin)this).Config.Bind<float>("音效设置 | Audio Settings", "音效音量 | Audio Volume", 0.5f, "存档音效的音量大小。范围0.0-1.0,设置为0关闭音效 | Volume level for save sound effect. Range 0.0-1.0, set to 0 to disable audio");
saveModifierKey = ((BaseUnityPlugin)this).Config.Bind<string>("按键设置 | Key Settings", "保存修饰键 | Save Modifier Key", "LeftControl", "保存坐标时使用的修饰键。可选值:LeftControl, RightControl, LeftAlt, RightAlt, LeftShift, RightShift | Modifier key for saving coordinates. Options: LeftControl, RightControl, LeftAlt, RightAlt, LeftShift, RightShift");
teleportModifierKey = ((BaseUnityPlugin)this).Config.Bind<string>("按键设置 | Key Settings", "传送修饰键 | Teleport Modifier Key", "LeftAlt", "传送坐标时使用的修饰键。可选值:LeftControl, RightControl, LeftAlt, RightAlt, LeftShift, RightShift | Modifier key for teleporting coordinates. Options: LeftControl, RightControl, LeftAlt, RightAlt, LeftShift, RightShift");
resetModifierKey = ((BaseUnityPlugin)this).Config.Bind<string>("按键设置 | Key Settings", "重置修饰键 | Reset Modifier Key", "LeftAlt", "重置坐标和安全重生时使用的修饰键。可选值:LeftControl, RightControl, LeftAlt, RightAlt, LeftShift, RightShift | Modifier key for reset and safe respawn functions. Options: LeftControl, RightControl, LeftAlt, RightAlt, LeftShift, RightShift");
gamepadSlot1Key = ((BaseUnityPlugin)this).Config.Bind<string>("手柄存档槽按键 | Gamepad Slot Keys", "手柄存档槽1 | Gamepad Slot 1", "DPadUp", "手柄存档槽1按键 | Gamepad key for slot 1 (默认: DPadUp=方向键上 | Default: DPadUp=D-Pad Up). \ud83d\udcd6 完整按键对照表请查看 README.md | For complete key reference, see README.md");
gamepadSlot2Key = ((BaseUnityPlugin)this).Config.Bind<string>("手柄存档槽按键 | Gamepad Slot Keys", "手柄存档槽2 | Gamepad Slot 2", "DPadDown", "手柄存档槽2按键 | Gamepad key for slot 2 (默认: DPadDown=方向键下 | Default: DPadDown=D-Pad Down)");
gamepadSlot3Key = ((BaseUnityPlugin)this).Config.Bind<string>("手柄存档槽按键 | Gamepad Slot Keys", "手柄存档槽3 | Gamepad Slot 3", "DPadLeft", "手柄存档槽3按键 | Gamepad key for slot 3 (默认: DPadLeft=方向键左 | Default: DPadLeft=D-Pad Left)");
gamepadSlot4Key = ((BaseUnityPlugin)this).Config.Bind<string>("手柄存档槽按键 | Gamepad Slot Keys", "手柄存档槽4 | Gamepad Slot 4", "DPadRight", "手柄存档槽4按键 | Gamepad key for slot 4 (默认: DPadRight=方向键右 | Default: DPadRight=D-Pad Right)");
gamepadSlot5Key = ((BaseUnityPlugin)this).Config.Bind<string>("手柄存档槽按键 | Gamepad Slot Keys", "手柄存档槽5 | Gamepad Slot 5", "JoystickButton0", "手柄存档槽5按键 | Gamepad key for slot 5 (默认: JoystickButton0=A按钮 | Default: JoystickButton0=A Button)");
gamepadTeleportModifier1 = ((BaseUnityPlugin)this).Config.Bind<string>("手柄修饰键 | Gamepad Modifiers", "传送修饰键1 | Teleport Modifier 1", "LeftBumper", "传送修饰键1 (默认: LeftBumper=LB) | Teleport modifier 1 (Default: LeftBumper=LB). 组合: 修饰键1 + 修饰键2 + 存档槽 = 传送 | Combo: Modifier1 + Modifier2 + Slot = Teleport");
gamepadTeleportModifier2 = ((BaseUnityPlugin)this).Config.Bind<string>("手柄修饰键 | Gamepad Modifiers", "传送修饰键2 | Teleport Modifier 2", "RightBumper", "传送修饰键2 (默认: RightBumper=RB) | Teleport modifier 2 (Default: RightBumper=RB). 默认组合: LB + RB | Default combo: LB + RB");
gamepadSaveModifier = ((BaseUnityPlugin)this).Config.Bind<string>("手柄修饰键 | Gamepad Modifiers", "保存修饰键 | Save Modifier", "LeftBumper", "保存修饰键 (默认: LeftBumper=LB) | Save modifier (Default: LeftBumper=LB). 组合: 保存修饰键 + 保存触发键 + 存档槽 = 保存 | Combo: Save Modifier + Save Trigger + Slot = Save");
gamepadSaveTrigger = ((BaseUnityPlugin)this).Config.Bind<string>("手柄修饰键 | Gamepad Modifiers", "保存触发键 | Save Trigger", "JoystickButton7", "保存触发键 (默认: JoystickButton7=Start) | Save trigger (Default: JoystickButton7=Start). 默认组合: LB + Start | Default combo: LB + Start");
gamepadSafeRespawnKey = ((BaseUnityPlugin)this).Config.Bind<string>("手柄特殊功能 | Gamepad Special", "安全重生按键 | Safe Respawn", "JoystickButton3", "安全重生按键 (默认: JoystickButton3=Y按钮) | Safe respawn key (Default: JoystickButton3=Y Button). 传送模式下使用 | Use in teleport mode");
gamepadHardcodedTeleportKey = ((BaseUnityPlugin)this).Config.Bind<string>("手柄特殊功能 | Gamepad Special", "硬编码传送按键 | Hardcoded Teleport", "JoystickButton2", "硬编码传送按键 (默认: JoystickButton2=X按钮) | Hardcoded teleport key (Default: JoystickButton2=X Button). 传送模式下使用 | Use in teleport mode");
gamepadBenchTeleportKey = ((BaseUnityPlugin)this).Config.Bind<string>("手柄特殊功能 | Gamepad Special", "椅子传送按键 | Bench Teleport", "JoystickButton1", "椅子传送按键 (默认: JoystickButton1=B按钮) | Bench teleport key (Default: JoystickButton1=B Button). 传送模式下使用 | Use in teleport mode");
gamepadClearAllModifier1 = ((BaseUnityPlugin)this).Config.Bind<string>("手柄重置组合 | Gamepad Reset Combo", "重置修饰键1 | Reset Modifier 1", "LeftBumper", "重置修饰键1 (默认: LeftBumper=LB) | Reset modifier 1 (Default: LeftBumper=LB). 三键组合清空所有存档 | Triple key combo to clear all saves");
gamepadClearAllModifier2 = ((BaseUnityPlugin)this).Config.Bind<string>("手柄重置组合 | Gamepad Reset Combo", "重置修饰键2 | Reset Modifier 2", "JoystickButton6", "重置修饰键2 (默认: JoystickButton6=Select) | Reset modifier 2 (Default: JoystickButton6=Select). 默认组合: LB + Select + Start | Default combo: LB + Select + Start");
gamepadClearAllTrigger = ((BaseUnityPlugin)this).Config.Bind<string>("手柄重置组合 | Gamepad Reset Combo", "重置触发键 | Reset Trigger", "JoystickButton7", "重置触发键 (默认: JoystickButton7=Start) | Reset trigger (Default: JoystickButton7=Start). ⚠\ufe0f警告: 此操作不可撤销 | ⚠\ufe0fWarning: This action is irreversible");
slot1Key = ((BaseUnityPlugin)this).Config.Bind<string>("键盘存档槽按键 | Keyboard Slot Keys", "键盘存档槽1 | Keyboard Slot 1", "Alpha1", "键盘存档槽1按键。可用:Alpha0-9, F1-F12, Q, W, E, R, T, Y, U, I, O, P等 | Keyboard key for slot 1. Available: Alpha0-9, F1-F12, Q, W, E, R, T, Y, U, I, O, P, etc.");
slot2Key = ((BaseUnityPlugin)this).Config.Bind<string>("键盘存档槽按键 | Keyboard Slot Keys", "键盘存档槽2 | Keyboard Slot 2", "Alpha2", "键盘存档槽2按键 | Keyboard key for slot 2");
slot3Key = ((BaseUnityPlugin)this).Config.Bind<string>("键盘存档槽按键 | Keyboard Slot Keys", "键盘存档槽3 | Keyboard Slot 3", "Alpha3", "键盘存档槽3按键 | Keyboard key for slot 3");
slot4Key = ((BaseUnityPlugin)this).Config.Bind<string>("键盘存档槽按键 | Keyboard Slot Keys", "键盘存档槽4 | Keyboard Slot 4", "Alpha4", "键盘存档槽4按键 | Keyboard key for slot 4");
slot5Key = ((BaseUnityPlugin)this).Config.Bind<string>("键盘存档槽按键 | Keyboard Slot Keys", "键盘存档槽5 | Keyboard Slot 5", "Alpha5", "键盘存档槽5按键 | Keyboard key for slot 5");
safeRespawnKey = ((BaseUnityPlugin)this).Config.Bind<string>("键盘特殊功能 | Keyboard Special", "键盘安全重生 | Keyboard Safe Respawn", "Alpha6", "键盘安全重生功能按键 | Keyboard safe respawn function key");
resetAllKey = ((BaseUnityPlugin)this).Config.Bind<string>("键盘特殊功能 | Keyboard Special", "键盘重置所有 | Keyboard Reset All", "Alpha0", "键盘重置所有坐标功能按键 | Keyboard reset all coordinates function key");
hardcodedTeleportKey = ((BaseUnityPlugin)this).Config.Bind<string>("键盘特殊功能 | Keyboard Special", "键盘硬编码传送 | Keyboard Hardcoded Teleport", "Minus", "键盘传送到预设坐标的按键。默认是减号键(-) | Keyboard key for teleporting to preset coordinates. Default is minus key (-)");
benchTeleportKey = ((BaseUnityPlugin)this).Config.Bind<string>("键盘特殊功能 | Keyboard Special", "键盘椅子传送 | Keyboard Bench Teleport", "Alpha7", "键盘传送到椅子(最后重生点)的按键 | Keyboard key for teleporting to bench (last respawn point)");
Logger.LogInfo((object)"Teleport Mod 已加载!");
ConfigEntry<bool>? obj = enableDetailedLogging;
if (obj != null && obj.Value)
{
Logger.LogInfo((object)"详细日志已启用 | Detailed logging enabled");
}
else
{
Logger.LogInfo((object)"详细日志已禁用,只显示重要信息 | Detailed logging disabled, showing important messages only");
}
ConfigEntry<bool>? obj2 = enableGamepadSupport;
if (obj2 != null && obj2.Value)
{
Logger.LogInfo((object)"手柄支持已启用 | Gamepad support enabled");
}
else
{
Logger.LogInfo((object)"手柄支持已禁用 | Gamepad support disabled");
}
LoadPersistentData();
((MonoBehaviour)this).StartCoroutine(PreloadAudioClip());
}
private void LoadPersistentData()
{
try
{
string saveFilePath = GetSaveFilePath();
if (File.Exists(saveFilePath))
{
string text = File.ReadAllText(saveFilePath);
PersistentData persistentData = JsonConvert.DeserializeObject<PersistentData>(text);
if (persistentData == null || persistentData.saveSlots == null)
{
return;
}
saveSlots.Clear();
foreach (KeyValuePair<int, SerializableSaveSlot> saveSlot in persistentData.saveSlots)
{
if (saveSlot.Value != null && saveSlot.Value.hasData)
{
saveSlots[saveSlot.Key] = saveSlot.Value.ToSaveSlot();
}
}
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogInfo((object)$"已加载持久化数据:{persistentData.saveSlots.Count} 个存档槽 | Loaded persistent data: {persistentData.saveSlots.Count} save slots");
}
}
else
{
LogInfo("未找到存档文件,使用默认设置 | No save file found, using defaults");
}
}
catch (Exception ex)
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogError((object)("加载持久化数据时发生错误 | Error loading persistent data: " + ex.Message));
}
}
}
private void SavePersistentData()
{
try
{
PersistentData persistentData = new PersistentData();
foreach (KeyValuePair<int, SaveSlot> saveSlot in saveSlots)
{
if (saveSlot.Value.hasData)
{
persistentData.saveSlots[saveSlot.Key] = new SerializableSaveSlot(saveSlot.Value);
}
}
string contents = JsonConvert.SerializeObject((object)persistentData, (Formatting)1);
string saveFilePath = GetSaveFilePath();
string directoryName = Path.GetDirectoryName(saveFilePath);
if (!Directory.Exists(directoryName))
{
Directory.CreateDirectory(directoryName);
}
File.WriteAllText(saveFilePath, contents);
LogInfo($"已保存持久化数据:{persistentData.saveSlots.Count} 个存档槽 | Saved persistent data: {persistentData.saveSlots.Count} save slots");
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("保存持久化数据时发生错误 | Error saving persistent data: " + ex.Message));
}
}
}
private string GetSaveFilePath()
{
try
{
string persistentDataPath = Application.persistentDataPath;
string path = Path.Combine(persistentDataPath, "TeleportMod");
string text = Path.Combine(path, "savedata.json");
LogInfo("存档文件路径 | Save file path: " + text);
return text;
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("获取存档文件路径时发生错误 | Error getting save file path: " + ex.Message));
}
return Path.Combine("TeleportMod", "savedata.json");
}
}
private static void LogInfo(string message)
{
ConfigEntry<bool>? obj = enableDetailedLogging;
if (obj != null && obj.Value)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogInfo((object)message);
}
}
}
private static bool CanPerformTeleportOperations()
{
try
{
if (PlayerData.instance != null && PlayerData.instance.health <= 0)
{
LogInfo("角色血量为0,禁止保存和传送 | Hero health is 0, blocking save and teleport");
return false;
}
if (PlayerData.instance != null && PlayerData.instance.atBench)
{
LogInfo("角色在椅子上,禁止保存和传送 | Hero is at bench, blocking save and teleport");
return false;
}
if ((Object)(object)GameManager.instance != (Object)null && GameManager.instance.RespawningHero)
{
LogInfo("角色正在重生,禁止保存和传送 | Hero is respawning, blocking save and teleport");
return false;
}
return true;
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("检查传送操作权限时发生错误: " + ex.Message));
}
return false;
}
}
private static bool IsGamepadKeyPressed(string keyConfig)
{
if (string.IsNullOrEmpty(keyConfig))
{
return false;
}
InputDevice activeDevice = InputManager.ActiveDevice;
if (activeDevice == null || !activeDevice.IsAttached)
{
return false;
}
if (1 == 0)
{
}
bool result = keyConfig switch
{
"DPadUp" => ((OneAxisInputControl)activeDevice.DPadUp).WasPressed,
"DPadDown" => ((OneAxisInputControl)activeDevice.DPadDown).WasPressed,
"DPadLeft" => ((OneAxisInputControl)activeDevice.DPadLeft).WasPressed,
"DPadRight" => ((OneAxisInputControl)activeDevice.DPadRight).WasPressed,
"LeftBumper" => ((OneAxisInputControl)activeDevice.LeftBumper).WasPressed,
"RightBumper" => ((OneAxisInputControl)activeDevice.RightBumper).WasPressed,
"LeftTrigger" => ((OneAxisInputControl)activeDevice.LeftTrigger).WasPressed,
"RightTrigger" => ((OneAxisInputControl)activeDevice.RightTrigger).WasPressed,
"LeftStickButton" => ((OneAxisInputControl)activeDevice.LeftStickButton).WasPressed,
"RightStickButton" => ((OneAxisInputControl)activeDevice.RightStickButton).WasPressed,
"LeftStickUp" => ((OneAxisInputControl)activeDevice.LeftStickUp).WasPressed,
"LeftStickDown" => ((OneAxisInputControl)activeDevice.LeftStickDown).WasPressed,
"LeftStickLeft" => ((OneAxisInputControl)activeDevice.LeftStickLeft).WasPressed,
"LeftStickRight" => ((OneAxisInputControl)activeDevice.LeftStickRight).WasPressed,
"RightStickUp" => ((OneAxisInputControl)activeDevice.RightStickUp).WasPressed,
"RightStickDown" => ((OneAxisInputControl)activeDevice.RightStickDown).WasPressed,
"RightStickLeft" => ((OneAxisInputControl)activeDevice.RightStickLeft).WasPressed,
"RightStickRight" => ((OneAxisInputControl)activeDevice.RightStickRight).WasPressed,
_ => keyConfig.StartsWith("JoystickButton") && ParseJoystickButton(keyConfig),
};
if (1 == 0)
{
}
return result;
}
private static bool IsGamepadKeyHeld(string keyConfig)
{
if (string.IsNullOrEmpty(keyConfig))
{
return false;
}
InputDevice activeDevice = InputManager.ActiveDevice;
if (activeDevice == null || !activeDevice.IsAttached)
{
return false;
}
if (1 == 0)
{
}
bool result = keyConfig switch
{
"DPadUp" => ((OneAxisInputControl)activeDevice.DPadUp).IsPressed,
"DPadDown" => ((OneAxisInputControl)activeDevice.DPadDown).IsPressed,
"DPadLeft" => ((OneAxisInputControl)activeDevice.DPadLeft).IsPressed,
"DPadRight" => ((OneAxisInputControl)activeDevice.DPadRight).IsPressed,
"LeftBumper" => ((OneAxisInputControl)activeDevice.LeftBumper).IsPressed,
"RightBumper" => ((OneAxisInputControl)activeDevice.RightBumper).IsPressed,
"LeftTrigger" => ((OneAxisInputControl)activeDevice.LeftTrigger).IsPressed,
"RightTrigger" => ((OneAxisInputControl)activeDevice.RightTrigger).IsPressed,
"LeftStickButton" => ((OneAxisInputControl)activeDevice.LeftStickButton).IsPressed,
"RightStickButton" => ((OneAxisInputControl)activeDevice.RightStickButton).IsPressed,
"LeftStickUp" => ((OneAxisInputControl)activeDevice.LeftStickUp).IsPressed,
"LeftStickDown" => ((OneAxisInputControl)activeDevice.LeftStickDown).IsPressed,
"LeftStickLeft" => ((OneAxisInputControl)activeDevice.LeftStickLeft).IsPressed,
"LeftStickRight" => ((OneAxisInputControl)activeDevice.LeftStickRight).IsPressed,
"RightStickUp" => ((OneAxisInputControl)activeDevice.RightStickUp).IsPressed,
"RightStickDown" => ((OneAxisInputControl)activeDevice.RightStickDown).IsPressed,
"RightStickLeft" => ((OneAxisInputControl)activeDevice.RightStickLeft).IsPressed,
"RightStickRight" => ((OneAxisInputControl)activeDevice.RightStickRight).IsPressed,
_ => keyConfig.StartsWith("JoystickButton") && ParseJoystickButtonHeld(keyConfig),
};
if (1 == 0)
{
}
return result;
}
private static bool ParseJoystickButton(string keyConfig)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
try
{
if (keyConfig.StartsWith("JoystickButton") && keyConfig.Length > 14)
{
string s = keyConfig.Substring(14);
if (int.TryParse(s, out var result) && result >= 0 && result <= 19)
{
KeyCode val = (KeyCode)Enum.Parse(typeof(KeyCode), keyConfig);
return Input.GetKeyDown(val);
}
}
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("解析JoystickButton时发生错误: " + keyConfig + ", " + ex.Message));
}
}
return false;
}
private static bool ParseJoystickButtonHeld(string keyConfig)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
try
{
if (keyConfig.StartsWith("JoystickButton") && keyConfig.Length > 14)
{
string s = keyConfig.Substring(14);
if (int.TryParse(s, out var result) && result >= 0 && result <= 19)
{
KeyCode val = (KeyCode)Enum.Parse(typeof(KeyCode), keyConfig);
return Input.GetKey(val);
}
}
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("解析JoystickButton时发生错误: " + keyConfig + ", " + ex.Message));
}
}
return false;
}
private void Update()
{
if (!((Object)(object)GameManager.UnsafeInstance == (Object)null))
{
ConfigEntry<bool>? obj = enableGamepadSupport;
if (obj != null && obj.Value)
{
HandleGamepadInput();
}
HandleKeyboardInput();
}
}
private void HandleKeyboardInput()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
HandleEmergencyRestartInput();
GameManager unsafeInstance = GameManager.UnsafeInstance;
if ((Object)(object)unsafeInstance == (Object)null || unsafeInstance.isPaused || (int)unsafeInstance.GameState != 4 || !CanPerformTeleportOperations())
{
return;
}
if (IsModifierKeyPressed(saveModifierKey?.Value ?? "LeftControl"))
{
for (int i = 1; i <= 5; i++)
{
KeyCode slotKey = GetSlotKey(i);
if ((int)slotKey != 0 && Input.GetKeyDown(slotKey))
{
SaveToSlot(i);
break;
}
}
}
else if (IsModifierKeyPressed(teleportModifierKey?.Value ?? "LeftAlt"))
{
for (int j = 1; j <= 5; j++)
{
KeyCode slotKey2 = GetSlotKey(j);
if ((int)slotKey2 != 0 && Input.GetKeyDown(slotKey2))
{
LoadFromSlot(j);
break;
}
}
}
if (IsModifierKeyPressed(resetModifierKey?.Value ?? "LeftAlt"))
{
KeyCode val = ParseKeyCode(safeRespawnKey?.Value ?? "Alpha6");
if ((int)val != 0 && Input.GetKeyDown(val))
{
RespawnToSafeEntryPoint();
return;
}
KeyCode val2 = ParseKeyCode(resetAllKey?.Value ?? "Alpha0");
if ((int)val2 != 0 && Input.GetKeyDown(val2))
{
ClearAllSaveSlots();
return;
}
KeyCode val3 = ParseKeyCode(hardcodedTeleportKey?.Value ?? "Minus");
if ((int)val3 != 0 && Input.GetKeyDown(val3))
{
TeleportToHardcodedPosition();
return;
}
}
if (IsModifierKeyPressed(teleportModifierKey?.Value ?? "LeftAlt"))
{
KeyCode val4 = ParseKeyCode(benchTeleportKey?.Value ?? "Alpha7");
if ((int)val4 != 0 && Input.GetKeyDown(val4))
{
TeleportToBench();
}
}
}
private void HandleGamepadInput()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Invalid comparison between Unknown and I4
try
{
GameManager unsafeInstance = GameManager.UnsafeInstance;
if ((Object)(object)unsafeInstance == (Object)null || unsafeInstance.isPaused || (int)unsafeInstance.GameState != 4 || !CanPerformTeleportOperations())
{
return;
}
bool flag = IsGamepadKeyHeld(gamepadTeleportModifier1?.Value ?? "LeftBumper") && IsGamepadKeyHeld(gamepadTeleportModifier2?.Value ?? "RightBumper");
bool flag2 = IsGamepadKeyHeld(gamepadSaveModifier?.Value ?? "LeftBumper") && IsGamepadKeyHeld(gamepadSaveTrigger?.Value ?? "JoystickButton7");
if (!flag && !flag2)
{
return;
}
if (flag && IsGamepadKeyPressed(gamepadSafeRespawnKey?.Value ?? "JoystickButton3"))
{
RespawnToSafeEntryPoint();
return;
}
if (flag && IsGamepadKeyPressed(gamepadHardcodedTeleportKey?.Value ?? "JoystickButton2"))
{
TeleportToHardcodedPosition();
return;
}
if (flag && IsGamepadKeyPressed(gamepadBenchTeleportKey?.Value ?? "JoystickButton1"))
{
TeleportToBench();
return;
}
if (IsGamepadKeyHeld(gamepadClearAllModifier1?.Value ?? "LeftBumper") && IsGamepadKeyHeld(gamepadClearAllModifier2?.Value ?? "JoystickButton6") && IsGamepadKeyPressed(gamepadClearAllTrigger?.Value ?? "JoystickButton7"))
{
ClearAllSaveSlots();
return;
}
int num = 0;
if (!wasVerticalPressed || !wasHorizontalPressed)
{
if (!wasVerticalPressed && IsGamepadKeyPressed(gamepadSlot1Key?.Value ?? "DPadUp"))
{
num = 1;
wasVerticalPressed = true;
LogInfo("检测到存档槽1按键: " + gamepadSlot1Key?.Value);
}
else if (!wasVerticalPressed && IsGamepadKeyPressed(gamepadSlot2Key?.Value ?? "DPadDown"))
{
num = 2;
wasVerticalPressed = true;
LogInfo("检测到存档槽2按键: " + gamepadSlot2Key?.Value);
}
else if (!wasHorizontalPressed && IsGamepadKeyPressed(gamepadSlot3Key?.Value ?? "DPadLeft"))
{
num = 3;
wasHorizontalPressed = true;
LogInfo("检测到存档槽3按键: " + gamepadSlot3Key?.Value);
}
else if (!wasHorizontalPressed && IsGamepadKeyPressed(gamepadSlot4Key?.Value ?? "DPadRight"))
{
num = 4;
wasHorizontalPressed = true;
LogInfo("检测到存档槽4按键: " + gamepadSlot4Key?.Value);
}
else if (IsGamepadKeyPressed(gamepadSlot5Key?.Value ?? "JoystickButton0"))
{
num = 5;
LogInfo("检测到存档槽5按键: " + gamepadSlot5Key?.Value);
}
}
string keyConfig = gamepadSlot1Key?.Value ?? "DPadUp";
string keyConfig2 = gamepadSlot2Key?.Value ?? "DPadDown";
string keyConfig3 = gamepadSlot3Key?.Value ?? "DPadLeft";
string keyConfig4 = gamepadSlot4Key?.Value ?? "DPadRight";
if (wasVerticalPressed && !IsGamepadKeyHeld(keyConfig) && !IsGamepadKeyHeld(keyConfig2))
{
wasVerticalPressed = false;
}
if (wasHorizontalPressed && !IsGamepadKeyHeld(keyConfig3) && !IsGamepadKeyHeld(keyConfig4))
{
wasHorizontalPressed = false;
}
if (num > 0)
{
if (flag2)
{
SaveToSlot(num);
}
else if (flag)
{
LoadFromSlot(num);
}
}
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("处理手柄输入时发生错误 | Error handling gamepad input: " + ex.Message));
}
}
}
private void ClearAllSaveSlots()
{
try
{
saveSlots.Clear();
SavePersistentData();
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"已清空所有存档坐标!| All save slots cleared!");
}
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogInfo((object)"所有传送位置已重置,可以重新保存坐标 | All teleport positions reset, you can save new coordinates");
}
}
catch (Exception ex)
{
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)("清空存档坐标时发生错误 | Error clearing save slots: " + ex.Message));
}
}
}
private void HandleEmergencyRestartInput()
{
try
{
if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)290))
{
EmergencyReturnToMainMenu();
}
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("处理紧急重启输入时发生错误 | Error handling emergency restart input: " + ex.Message));
}
}
}
private void EmergencyReturnToMainMenu()
{
try
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"=== 紧急返回主菜单 | EMERGENCY RETURN TO MAIN MENU ===");
}
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogWarning((object)"正在强制返回主菜单,不保存当前进度!| Force returning to main menu without saving current progress!");
}
if ((Object)(object)GameManager.instance == (Object)null)
{
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)"GameManager实例未找到,无法返回主菜单 | GameManager instance not found, cannot return to main menu");
}
return;
}
GameManager.instance.ReturnToMainMenuNoSave();
ManualLogSource? logger4 = Logger;
if (logger4 != null)
{
logger4.LogInfo((object)"已触发返回主菜单 | Return to main menu triggered");
}
}
catch (Exception ex)
{
ManualLogSource? logger5 = Logger;
if (logger5 != null)
{
logger5.LogError((object)("紧急返回主菜单时发生错误 | Error during emergency return to main menu: " + ex.Message));
}
}
}
private void TeleportToBench()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)HeroController.instance == (Object)null || (Object)(object)GameManager.instance == (Object)null)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"HeroController 或 GameManager 未找到,无法传送到椅子");
}
return;
}
LogInfo("=== 传送到椅子 | TELEPORT TO BENCH ===");
(Vector3, string) benchPositionAndScene = GetBenchPositionAndScene();
if (benchPositionAndScene.Item1 == Vector3.zero || string.IsNullOrEmpty(benchPositionAndScene.Item2))
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogWarning((object)"未找到有效的椅子位置或场景信息 | No valid bench position or scene found");
}
return;
}
string sceneName = GameManager.instance.sceneName;
LogInfo($"准备传送到椅子: {benchPositionAndScene.Item1} 在场景: {benchPositionAndScene.Item2}");
if (!string.IsNullOrEmpty(benchPositionAndScene.Item2) && sceneName != benchPositionAndScene.Item2)
{
LogInfo("需要切换场景传送到椅子: " + sceneName + " -> " + benchPositionAndScene.Item2);
((MonoBehaviour)this).StartCoroutine(TeleportWithSceneChange(benchPositionAndScene.Item2, benchPositionAndScene.Item1));
}
else
{
LogInfo("在当前场景传送到椅子");
PerformTeleport(benchPositionAndScene.Item1);
}
}
catch (Exception ex)
{
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)("传送到椅子时发生错误 | Error during teleport to bench: " + ex.Message));
}
}
}
private KeyCode ParseKeyCode(string keyString)
{
//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_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
try
{
return (KeyCode)Enum.Parse(typeof(KeyCode), keyString, ignoreCase: true);
}
catch
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)("无法解析按键设置: " + keyString + ",使用默认值 | Cannot parse key setting: " + keyString + ", using default"));
}
return (KeyCode)0;
}
}
private bool IsModifierKeyPressed(string modifierKeyString)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
KeyCode val = ParseKeyCode(modifierKeyString);
if ((int)val == 0)
{
return false;
}
return Input.GetKey(val);
}
private KeyCode GetSlotKey(int slotNumber)
{
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
if (1 == 0)
{
}
string text = slotNumber switch
{
1 => slot1Key?.Value ?? "Alpha1",
2 => slot2Key?.Value ?? "Alpha2",
3 => slot3Key?.Value ?? "Alpha3",
4 => slot4Key?.Value ?? "Alpha4",
5 => slot5Key?.Value ?? "Alpha5",
_ => "None",
};
if (1 == 0)
{
}
string keyString = text;
return ParseKeyCode(keyString);
}
private void RespawnToSafeEntryPoint()
{
//IL_016a: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)HeroController.instance == (Object)null || (Object)(object)GameManager.instance == (Object)null)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"HeroController 或 GameManager 未找到,无法执行安全重生");
}
return;
}
string sceneName = GameManager.instance.sceneName;
if (lastUsedScene != sceneName)
{
currentEntryPointIndex = 0;
lastUsedScene = sceneName;
LogInfo("检测到新场景,重置入口点索引: " + sceneName);
}
else
{
LogInfo($"同一场景,继续轮换: {sceneName},当前索引: {currentEntryPointIndex}");
}
LogInfo("正在重新进入当前场景的安全入口点: " + sceneName);
string nextSafeEntryPointForCurrentScene = GetNextSafeEntryPointForCurrentScene();
if (string.IsNullOrEmpty(nextSafeEntryPointForCurrentScene))
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogWarning((object)"未找到当前场景的安全入口点,使用椅子位置");
}
(Vector3, string) benchPositionAndScene = GetBenchPositionAndScene();
if (benchPositionAndScene.Item1 != Vector3.zero && !string.IsNullOrEmpty(benchPositionAndScene.Item2))
{
if (benchPositionAndScene.Item2 == sceneName)
{
PerformTeleport(benchPositionAndScene.Item1);
}
else
{
((MonoBehaviour)this).StartCoroutine(TeleportWithSceneChange(benchPositionAndScene.Item2, benchPositionAndScene.Item1));
}
}
}
else
{
LogInfo($"使用安全入口点 {currentEntryPointIndex}: {nextSafeEntryPointForCurrentScene}");
((MonoBehaviour)this).StartCoroutine(TeleportWithSceneChange(sceneName, Vector3.zero, nextSafeEntryPointForCurrentScene));
}
}
catch (Exception ex)
{
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)("执行安全重生时发生错误: " + ex.Message));
}
}
}
private void TeleportToHardcodedPosition()
{
//IL_005e: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)HeroController.instance == (Object)null || (Object)(object)GameManager.instance == (Object)null)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"HeroController 或 GameManager 未找到,无法执行硬编码传送");
}
return;
}
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(71.42231f, 9.597684f, 0.004f);
string text = "Bellway_01";
LogInfo($"执行硬编码传送到: {val} 在场景: {text}");
string sceneName = GameManager.instance.sceneName;
if (!string.IsNullOrEmpty(text) && sceneName != text)
{
LogInfo("需要切换场景进行硬编码传送: " + sceneName + " -> " + text);
((MonoBehaviour)this).StartCoroutine(TeleportWithSceneChange(text, val));
}
else
{
LogInfo("在当前场景执行硬编码传送");
PerformTeleport(val);
}
}
catch (Exception ex)
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogError((object)("执行硬编码传送时发生错误: " + ex.Message));
}
}
}
private Vector3 CheckAndFixPositionInCurrentScene(Vector3 targetPosition, int slotNumber)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)HeroController.instance == (Object)null)
{
return targetPosition;
}
if (IsPositionSafe(targetPosition))
{
LogInfo($"档位 {slotNumber} 位置安全: {targetPosition}");
return targetPosition;
}
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)$"档位 {slotNumber} 位置不安全,正在查找安全位置: {targetPosition}");
}
Vector3 val = FindSafePositionNearby(targetPosition);
if (val != Vector3.zero)
{
string sceneName = GameManager.instance.sceneName;
saveSlots[slotNumber] = new SaveSlot(val, sceneName);
LogInfo($"档位 {slotNumber} 已修正为安全位置: {targetPosition} -> {val}");
return val;
}
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogWarning((object)$"档位 {slotNumber} 无法找到安全位置,将在传送后尝试修复");
}
return targetPosition;
}
catch (Exception ex)
{
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)("检查位置安全性时发生错误: " + ex.Message));
}
return targetPosition;
}
}
private bool IsPositionSafe(Vector3 position)
{
//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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
try
{
HeroController instance = HeroController.instance;
Collider2D val = ((instance != null) ? ((Component)instance).GetComponent<Collider2D>() : null);
if ((Object)(object)val == (Object)null)
{
return true;
}
int mask = LayerMask.GetMask(new string[1] { "Terrain" });
Vector2 val2 = Vector2.op_Implicit(position);
Bounds bounds = val.bounds;
Collider2D val3 = Physics2D.OverlapBox(val2, Vector2.op_Implicit(((Bounds)(ref bounds)).size), 0f, mask);
bool flag = (Object)(object)val3 == (Object)null;
LogInfo(string.Format("位置安全检查: {0} -> {1}", position, flag ? "安全" : "不安全"));
return flag;
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("检查位置安全性时发生错误: " + ex.Message));
}
return true;
}
}
private string? GetNextSafeEntryPointForCurrentScene()
{
try
{
List<string> allSafeEntryPointsForCurrentScene = GetAllSafeEntryPointsForCurrentScene();
if (allSafeEntryPointsForCurrentScene == null || allSafeEntryPointsForCurrentScene.Count == 0)
{
LogInfo("当前场景没有可用的安全入口点");
return null;
}
if (currentEntryPointIndex >= allSafeEntryPointsForCurrentScene.Count)
{
currentEntryPointIndex = 0;
}
string text = allSafeEntryPointsForCurrentScene[currentEntryPointIndex];
LogInfo($"选择安全入口点 {currentEntryPointIndex + 1}/{allSafeEntryPointsForCurrentScene.Count}: {text}");
currentEntryPointIndex++;
return text;
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("获取下一个安全入口点时发生错误: " + ex.Message));
}
return null;
}
}
private List<string>? GetAllSafeEntryPointsForCurrentScene()
{
try
{
List<TransitionPoint> transitionPoints = TransitionPoint.TransitionPoints;
if (transitionPoints == null || transitionPoints.Count == 0)
{
LogInfo("当前场景没有TransitionPoint");
return null;
}
List<string> list = new List<string>();
List<TransitionPoint> list2 = transitionPoints.Where((TransitionPoint tp) => (Object)(object)tp != (Object)null && ((Object)tp).name.Contains("door") && !tp.isInactive).ToList();
foreach (TransitionPoint item in list2)
{
list.Add(((Object)item).name);
LogInfo("找到门入口点: " + ((Object)item).name);
}
List<TransitionPoint> list3 = transitionPoints.Where((TransitionPoint tp) => (Object)(object)tp != (Object)null && !tp.isInactive && !((Object)tp).name.Contains("door") && (((Object)tp).name.Contains("left") || ((Object)tp).name.Contains("right") || ((Object)tp).name.Contains("top") || ((Object)tp).name.Contains("bot"))).ToList();
foreach (TransitionPoint item2 in list3)
{
list.Add(((Object)item2).name);
LogInfo("找到其他入口点: " + ((Object)item2).name);
}
if (list.Count == 0)
{
List<TransitionPoint> list4 = transitionPoints.Where((TransitionPoint tp) => (Object)(object)tp != (Object)null && !tp.isInactive).ToList();
foreach (TransitionPoint item3 in list4)
{
list.Add(((Object)item3).name);
LogInfo("找到可用入口点: " + ((Object)item3).name);
}
}
LogInfo($"总共找到 {list.Count} 个安全入口点");
return (list.Count > 0) ? list : null;
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("获取所有安全入口点时发生错误: " + ex.Message));
}
return null;
}
}
private string? GetSafeEntryPointForCurrentScene()
{
try
{
List<TransitionPoint> transitionPoints = TransitionPoint.TransitionPoints;
if (transitionPoints == null || transitionPoints.Count == 0)
{
LogInfo("当前场景没有TransitionPoint");
return null;
}
List<TransitionPoint> list = transitionPoints.Where((TransitionPoint tp) => (Object)(object)tp != (Object)null && ((Object)tp).name.Contains("door") && !tp.isInactive).ToList();
if (list.Count > 0)
{
LogInfo("找到门入口点: " + ((Object)list[0]).name);
return ((Object)list[0]).name;
}
List<TransitionPoint> list2 = transitionPoints.Where((TransitionPoint tp) => (Object)(object)tp != (Object)null && !tp.isInactive && (((Object)tp).name.Contains("left") || ((Object)tp).name.Contains("right") || ((Object)tp).name.Contains("top") || ((Object)tp).name.Contains("bot"))).ToList();
if (list2.Count > 0)
{
LogInfo("找到其他入口点: " + ((Object)list2[0]).name);
return ((Object)list2[0]).name;
}
TransitionPoint val = ((IEnumerable<TransitionPoint>)transitionPoints).FirstOrDefault((Func<TransitionPoint, bool>)((TransitionPoint tp) => (Object)(object)tp != (Object)null && !tp.isInactive));
if ((Object)(object)val != (Object)null)
{
LogInfo("使用第一个可用入口点: " + ((Object)val).name);
return ((Object)val).name;
}
return null;
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("获取安全入口点时发生错误: " + ex.Message));
}
return null;
}
}
private void SaveToSlot(int slotNumber)
{
//IL_002c: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)HeroController.instance != (Object)null && (Object)(object)GameManager.instance != (Object)null)
{
Vector3 position = ((Component)HeroController.instance).transform.position;
string sceneName = GameManager.instance.sceneName;
saveSlots[slotNumber] = new SaveSlot(position, sceneName);
LogInfo($"档位 {slotNumber} 已保存: {position} 在场景: {sceneName}");
PlaySaveSound();
SavePersistentData();
}
else
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"HeroController 或 GameManager 未找到,无法保存位置");
}
}
}
catch (Exception ex)
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogError((object)$"保存档位 {slotNumber} 时发生错误: {ex.Message}");
}
}
}
private void PlaySaveSound()
{
try
{
ConfigEntry<float>? obj = audioVolume;
if (obj != null && obj.Value <= 0f)
{
LogInfo("音效音量设置为0,跳过音效播放");
return;
}
float time = Time.time;
if (time - lastSaveAudioTime < 0.1f)
{
LogInfo("音频播放在冷却中,跳过此次播放");
return;
}
lastSaveAudioTime = time;
EnsureAudioPlayer();
if ((Object)(object)cachedSaveAudioClip != (Object)null && (Object)(object)audioPlayerSource != (Object)null)
{
audioPlayerSource.PlayOneShot(cachedSaveAudioClip, audioVolume?.Value ?? 0.5f);
LogInfo($"使用缓存音频播放存档音效,音量: {audioVolume?.Value ?? 0.5f}");
}
else
{
LogInfo("音频未预加载完成,跳过播放");
}
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("播放存档音效时发生错误: " + ex.Message));
}
}
}
private void EnsureAudioPlayer()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
if ((Object)(object)audioPlayerObject == (Object)null || (Object)(object)audioPlayerSource == (Object)null)
{
audioPlayerObject = new GameObject("TeleportAudioPlayer");
audioPlayerSource = audioPlayerObject.AddComponent<AudioSource>();
audioPlayerSource.volume = audioVolume?.Value ?? 0.5f;
audioPlayerSource.spatialBlend = 0f;
audioPlayerSource.playOnAwake = false;
audioPlayerSource.loop = false;
Object.DontDestroyOnLoad((Object)(object)audioPlayerObject);
LogInfo("创建并复用音频播放器对象");
}
}
[IteratorStateMachine(typeof(<PreloadAudioClip>d__75))]
private IEnumerator PreloadAudioClip()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PreloadAudioClip>d__75(0)
{
<>4__this = this
};
}
private void LoadFromSlot(int slotNumber)
{
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)HeroController.instance == (Object)null || (Object)(object)GameManager.instance == (Object)null)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"HeroController 或 GameManager 未找到,无法传送");
}
return;
}
Vector3 val;
string text;
if (saveSlots.ContainsKey(slotNumber) && saveSlots[slotNumber].hasData)
{
SaveSlot saveSlot = saveSlots[slotNumber];
val = saveSlot.position;
text = saveSlot.scene;
LogInfo($"准备传送到档位 {slotNumber}: {val} 在场景: {text}");
}
else
{
LogInfo($"档位 {slotNumber} 没有存档数据,传送到椅子位置");
(val, text) = GetBenchPositionAndScene();
if (val == Vector3.zero || string.IsNullOrEmpty(text))
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogWarning((object)"未找到有效的椅子位置或场景信息");
}
return;
}
LogInfo($"准备传送到椅子位置: {val} 在场景: {text}");
}
string sceneName = GameManager.instance.sceneName;
if (!string.IsNullOrEmpty(text) && sceneName != text)
{
LogInfo("需要切换场景: " + sceneName + " -> " + text);
((MonoBehaviour)this).StartCoroutine(TeleportWithSceneChange(text, val));
}
else
{
Vector3 targetPosition = CheckAndFixPositionInCurrentScene(val, slotNumber);
PerformTeleport(targetPosition);
}
}
catch (Exception ex)
{
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogError((object)$"从档位 {slotNumber} 传送时发生错误: {ex.Message}");
}
}
}
private (Vector3 position, string scene) GetBenchPositionAndScene()
{
//IL_01e9: 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)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
try
{
if (PlayerData.instance == null)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"PlayerData 未找到");
}
return (Vector3.zero, "");
}
string respawnMarkerName = PlayerData.instance.respawnMarkerName;
string respawnScene = PlayerData.instance.respawnScene;
if (string.IsNullOrEmpty(respawnMarkerName) || string.IsNullOrEmpty(respawnScene))
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogWarning((object)"未找到椅子标记名称或场景信息");
}
return (Vector3.zero, "");
}
LogInfo("查找椅子: " + respawnMarkerName + " 在场景: " + respawnScene);
string text = GameManager.instance?.sceneName ?? "";
if (text == respawnScene)
{
if (RespawnMarker.Markers != null)
{
RespawnMarker val = ((IEnumerable<RespawnMarker>)RespawnMarker.Markers).FirstOrDefault((Func<RespawnMarker, bool>)((RespawnMarker marker) => (Object)(object)marker != (Object)null && ((Object)((Component)marker).gameObject).name == respawnMarkerName));
if ((Object)(object)val != (Object)null)
{
LogInfo($"在当前场景找到椅子: {((Object)((Component)val).gameObject).name} 位置: {((Component)val).transform.position}");
return (((Component)val).transform.position, respawnScene);
}
}
ManualLogSource? logger3 = Logger;
if (logger3 != null)
{
logger3.LogWarning((object)("在当前场景中未找到椅子标记: " + respawnMarkerName));
}
return (Vector3.zero, "");
}
LogInfo("椅子在其他场景: " + respawnScene + ",需要切换场景后获取坐标");
return (Vector3.one, respawnScene);
}
catch (Exception ex)
{
ManualLogSource? logger4 = Logger;
if (logger4 != null)
{
logger4.LogError((object)("获取椅子位置时发生错误: " + ex.Message));
}
return (Vector3.zero, "");
}
}
[IteratorStateMachine(typeof(<TeleportWithSceneChange>d__78))]
private IEnumerator TeleportWithSceneChange(string targetScene, Vector3 targetPosition)
{
//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)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <TeleportWithSceneChange>d__78(0)
{
<>4__this = this,
targetScene = targetScene,
targetPosition = targetPosition
};
}
[IteratorStateMachine(typeof(<TeleportWithSceneChange>d__79))]
private IEnumerator TeleportWithSceneChange(string targetScene, Vector3 targetPosition, string? entryPointName)
{
//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)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <TeleportWithSceneChange>d__79(0)
{
<>4__this = this,
targetScene = targetScene,
targetPosition = targetPosition,
entryPointName = entryPointName
};
}
private string GetBestEntryPointForScene(string sceneName)
{
try
{
string[] array = new string[7] { "door1", "door_entrance", "entrance", "left1", "right1", "top1", "bot1" };
string[] array2 = array;
int num = 0;
if (num < array2.Length)
{
string text = array2[num];
LogInfo("尝试使用入口点: " + text);
return text;
}
return "door1";
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("选择最佳入口点时发生错误: " + ex.Message));
}
return "door1";
}
}
private void PerformSafeTeleport(Vector3 targetPosition)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)HeroController.instance == (Object)null)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"HeroController 未找到,无法执行传送");
}
}
else
{
PerformTeleport(targetPosition);
((MonoBehaviour)this).StartCoroutine(CheckTeleportSafety(targetPosition));
}
}
catch (Exception ex)
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogError((object)("执行安全传送时发生错误: " + ex.Message));
}
}
}
[IteratorStateMachine(typeof(<CheckTeleportSafety>d__82))]
private IEnumerator CheckTeleportSafety(Vector3 originalPosition)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CheckTeleportSafety>d__82(0)
{
<>4__this = this,
originalPosition = originalPosition
};
}
private Vector3 FindSafePositionNearby(Vector3 originalPosition)
{
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_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_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: 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_0114: 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_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
try
{
HeroController instance = HeroController.instance;
Collider2D val = ((instance != null) ? ((Component)instance).GetComponent<Collider2D>() : null);
if ((Object)(object)val == (Object)null)
{
return Vector3.zero;
}
int mask = LayerMask.GetMask(new string[1] { "Terrain" });
Vector3[] array = (Vector3[])(object)new Vector3[6]
{
new Vector3(0f, 2f, 0f),
new Vector3(0f, 4f, 0f),
new Vector3(-1f, 2f, 0f),
new Vector3(1f, 2f, 0f),
new Vector3(-2f, 0f, 0f),
new Vector3(2f, 0f, 0f)
};
Vector3[] array2 = array;
foreach (Vector3 val2 in array2)
{
Vector3 val3 = originalPosition + val2;
Vector2 val4 = Vector2.op_Implicit(val3);
Bounds bounds = val.bounds;
Collider2D val5 = Physics2D.OverlapBox(val4, Vector2.op_Implicit(((Bounds)(ref bounds)).size), 0f, mask);
if ((Object)(object)val5 == (Object)null)
{
LogInfo($"找到安全位置偏移: {val2}");
return val3;
}
}
return Vector3.zero;
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogError((object)("查找安全位置时发生错误: " + ex.Message));
}
return Vector3.zero;
}
}
private void PerformTeleport(Vector3 targetPosition)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)HeroController.instance == (Object)null)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)"HeroController 未找到,无法执行传送");
}
return;
}
((Component)HeroController.instance).transform.position = targetPosition;
Rigidbody2D component = ((Component)HeroController.instance).GetComponent<Rigidbody2D>();
if ((Object)(object)component != (Object)null)
{
component.linearVelocity = Vector2.zero;
}
if (HeroController.instance.cState != null)
{
HeroController.instance.cState.recoiling = false;
HeroController.instance.cState.transitioning = false;
}
LogInfo($"传送完成: {targetPosition}");
}
catch (Exception ex)
{
ManualLogSource? logger2 = Logger;
if (logger2 != null)
{
logger2.LogError((object)("执行传送时发生错误: " + ex.Message));
}
}
}
}