using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("REPOJP")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("REPOJP")]
[assembly: AssemblyTitle("REPOJP")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
[BepInPlugin("REPOJP.AntiInfiniteStamina", "AntiInfiniteStamina", "1.0.3")]
public class AntiInfiniteStaminaPlugin : BaseUnityPlugin
{
private sealed class SprintTracker
{
public int StableId;
public string PlayerName = string.Empty;
public string SteamId = string.Empty;
public float CurrentSprintSeconds;
public float NonSprintGraceSeconds;
public float MaxObservedSprintSeconds;
public float LastAllowedSprintSeconds;
public int LastStaminaUpgrade;
public int LastSpeedUpgrade;
public bool WarnedThisChain;
public int SuspiciousCount;
public float CurrentSpeedAnomalySeconds;
public float MaxObservedHorizontalSpeed;
public float LastSeenTime;
}
private sealed class OverlayMessage
{
public string Text = string.Empty;
public string TeleportHint = string.Empty;
public float CreatedAt;
public float ExpiresAt;
public int TargetStableId;
public string TargetPlayerName = string.Empty;
}
private sealed class PlayerOutlineShellMarker : MonoBehaviour
{
}
private sealed class PlayerOutlineShellController : MonoBehaviour
{
private Material outlineMaterial;
private PlayerAvatar targetPlayer;
private readonly List<GameObject> outlineShellObjects = new List<GameObject>();
private bool outlineVisible;
private Color outlineColor = new Color(1f, 0.84f, 0.06f, 1f);
private float lastBuildAttemptTime;
private const float OutlineScaleMultiplier = 1.06f;
private const float RebuildRetrySeconds = 1f;
public void Initialize(PlayerAvatar player)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
targetPlayer = player;
((Object)this).hideFlags = (HideFlags)61;
EnsureOutlineMaterial();
TryBuildOutlineShells();
SetOutlineVisible(visible: false, outlineColor);
}
public void SetOutlineVisible(bool visible, Color color)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
outlineVisible = visible;
outlineColor = color;
EnsureOutlineMaterial();
ApplyOutlineMaterialColor();
if (outlineVisible)
{
TryBuildOutlineShells();
}
ApplyOutlineVisibility();
}
private void Update()
{
if ((Object)(object)targetPlayer == (Object)null)
{
Object.Destroy((Object)(object)this);
}
else if (outlineVisible && (outlineShellObjects.Count == 0 || !HasAnyValidShell()) && Time.unscaledTime - lastBuildAttemptTime >= 1f)
{
TryBuildOutlineShells();
ApplyOutlineVisibility();
}
}
private void OnDestroy()
{
ClearOutlineShells();
if ((Object)(object)outlineMaterial != (Object)null)
{
Object.Destroy((Object)(object)outlineMaterial);
outlineMaterial = null;
}
}
private void EnsureOutlineMaterial()
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
if ((Object)(object)outlineMaterial != (Object)null)
{
return;
}
Shader val = Shader.Find("Standard");
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Legacy Shaders/Diffuse");
}
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Sprites/Default");
}
if (!((Object)(object)val == (Object)null))
{
outlineMaterial = new Material(val);
((Object)outlineMaterial).name = "AntiInfiniteStaminaDetectedOutline";
((Object)outlineMaterial).hideFlags = (HideFlags)61;
outlineMaterial.enableInstancing = true;
if (outlineMaterial.HasProperty("_Glossiness"))
{
outlineMaterial.SetFloat("_Glossiness", 0f);
}
if (outlineMaterial.HasProperty("_Metallic"))
{
outlineMaterial.SetFloat("_Metallic", 0f);
}
if (outlineMaterial.HasProperty("_Cull"))
{
outlineMaterial.SetInt("_Cull", 1);
}
if (outlineMaterial.HasProperty("_ZWrite"))
{
outlineMaterial.SetInt("_ZWrite", 1);
}
ApplyOutlineMaterialColor();
}
}
private void ApplyOutlineMaterialColor()
{
//IL_0035: 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_007d: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)outlineMaterial == (Object)null))
{
if (outlineMaterial.HasProperty("_Color"))
{
outlineMaterial.SetColor("_Color", outlineColor);
}
if (outlineMaterial.HasProperty("_EmissionColor"))
{
outlineMaterial.EnableKeyword("_EMISSION");
outlineMaterial.SetColor("_EmissionColor", outlineColor * 2.4f);
}
}
}
private void TryBuildOutlineShells()
{
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Expected O, but got Unknown
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: 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_01df: Unknown result type (might be due to invalid IL or missing references)
lastBuildAttemptTime = Time.unscaledTime;
if ((Object)(object)targetPlayer == (Object)null)
{
return;
}
if ((Object)(object)outlineMaterial == (Object)null)
{
EnsureOutlineMaterial();
if ((Object)(object)outlineMaterial == (Object)null)
{
return;
}
}
if (outlineShellObjects.Count > 0 && HasAnyValidShell())
{
return;
}
ClearOutlineShells();
GameObject val = null;
val = (((Object)(object)targetPlayer.playerAvatarVisuals != (Object)null && (Object)(object)targetPlayer.playerAvatarVisuals.meshParent != (Object)null) ? targetPlayer.playerAvatarVisuals.meshParent : ((!((Object)(object)targetPlayer.playerAvatarVisuals != (Object)null)) ? ((Component)targetPlayer).gameObject : ((Component)targetPlayer.playerAvatarVisuals).gameObject));
MeshRenderer[] componentsInChildren = val.GetComponentsInChildren<MeshRenderer>(true);
foreach (MeshRenderer val2 in componentsInChildren)
{
if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).GetComponent<PlayerOutlineShellMarker>() != (Object)null)
{
continue;
}
MeshFilter component = ((Component)val2).GetComponent<MeshFilter>();
if (!((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null))
{
GameObject val3 = new GameObject(((Object)val2).name + "_DetectedOutlineShell");
((Object)val3).hideFlags = (HideFlags)61;
val3.transform.SetParent(((Component)val2).transform, false);
val3.transform.localPosition = Vector3.zero;
val3.transform.localRotation = Quaternion.identity;
val3.transform.localScale = Vector3.one * 1.06f;
val3.layer = ((Component)val2).gameObject.layer;
val3.AddComponent<PlayerOutlineShellMarker>();
MeshFilter val4 = val3.AddComponent<MeshFilter>();
val4.sharedMesh = component.sharedMesh;
MeshRenderer val5 = val3.AddComponent<MeshRenderer>();
int num = Mathf.Max(1, (((Renderer)val2).sharedMaterials == null) ? 1 : ((Renderer)val2).sharedMaterials.Length);
Material[] array = (Material[])(object)new Material[num];
for (int j = 0; j < num; j++)
{
array[j] = outlineMaterial;
}
((Renderer)val5).sharedMaterials = array;
((Renderer)val5).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)val5).receiveShadows = false;
((Renderer)val5).motionVectorGenerationMode = (MotionVectorGenerationMode)2;
((Renderer)val5).lightProbeUsage = (LightProbeUsage)0;
((Renderer)val5).reflectionProbeUsage = (ReflectionProbeUsage)0;
((Renderer)val5).allowOcclusionWhenDynamic = false;
((Renderer)val5).enabled = outlineVisible;
outlineShellObjects.Add(val3);
}
}
}
private void ApplyOutlineVisibility()
{
for (int num = outlineShellObjects.Count - 1; num >= 0; num--)
{
GameObject val = outlineShellObjects[num];
if ((Object)(object)val == (Object)null)
{
outlineShellObjects.RemoveAt(num);
}
else
{
MeshRenderer component = val.GetComponent<MeshRenderer>();
if ((Object)(object)component != (Object)null)
{
((Renderer)component).enabled = outlineVisible;
}
}
}
}
private void ClearOutlineShells()
{
for (int num = outlineShellObjects.Count - 1; num >= 0; num--)
{
GameObject val = outlineShellObjects[num];
if ((Object)(object)val != (Object)null)
{
Object.Destroy((Object)(object)val);
}
}
outlineShellObjects.Clear();
}
private bool HasAnyValidShell()
{
for (int i = 0; i < outlineShellObjects.Count; i++)
{
if ((Object)(object)outlineShellObjects[i] != (Object)null)
{
return true;
}
}
return false;
}
}
[CompilerGenerated]
private sealed class <LoadWarningAudioCoroutine>d__80 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public string filePath;
public AntiInfiniteStaminaPlugin <>4__this;
private string <uri>5__1;
private UnityWebRequest <request>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadWarningAudioCoroutine>d__80(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();
}
}
<uri>5__1 = null;
<request>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Invalid comparison between Unknown and I4
bool result;
try
{
switch (<>1__state)
{
default:
result = false;
break;
case 0:
<>1__state = -1;
<uri>5__1 = new Uri(filePath).AbsoluteUri;
<request>5__2 = UnityWebRequestMultimedia.GetAudioClip(<uri>5__1, (AudioType)14);
<>1__state = -3;
<>2__current = <request>5__2.SendWebRequest();
<>1__state = 1;
result = true;
break;
case 1:
<>1__state = -3;
if ((int)<request>5__2.result != 1)
{
DebugLog("Warning audio load failed / 警告音読込失敗\n" + <request>5__2.error);
<>4__this.warningAudioClip = <>4__this.CreateFallbackWarningClip();
result = false;
<>m__Finally1();
break;
}
<>4__this.warningAudioClip = DownloadHandlerAudioClip.GetContent(<request>5__2);
if ((Object)(object)<>4__this.warningAudioClip == (Object)null)
{
<>4__this.warningAudioClip = <>4__this.CreateFallbackWarningClip();
}
<>m__Finally1();
<request>5__2 = null;
result = false;
break;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
return result;
}
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__2 != null)
{
((IDisposable)<request>5__2).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <TeleportStabilizeCoroutine>d__107 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlayerAvatar localPlayer;
public Vector3 destination;
public Quaternion rotation;
public AntiInfiniteStaminaPlugin <>4__this;
private int <i>5__1;
private PlayerController <playerController>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <TeleportStabilizeCoroutine>d__107(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<playerController>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0096: 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)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<i>5__1 = 0;
break;
case 1:
<>1__state = -1;
<playerController>5__2 = PlayerController.instance;
if ((Object)(object)localPlayer == (Object)null || (Object)(object)<playerController>5__2 == (Object)null)
{
<>4__this.teleportStabilizeCoroutine = null;
return false;
}
<>4__this.ApplyManualTeleportPose(localPlayer, <playerController>5__2, destination, rotation, <i>5__1 == 3);
<playerController>5__2 = null;
<i>5__1++;
break;
}
if (<i>5__1 < 4)
{
<>2__current = (object)new WaitForFixedUpdate();
<>1__state = 1;
return true;
}
<>4__this.teleportStabilizeCoroutine = null;
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();
}
}
internal static AntiInfiniteStaminaPlugin Instance;
internal static ManualLogSource LogSource;
internal static ConfigEntry<bool> EnableMod;
internal static ConfigEntry<bool> EnableDebugLog;
internal static ConfigEntry<float> AllowedExtraSprintSeconds;
internal static ConfigEntry<float> SprintBreakGraceSeconds;
internal static ConfigEntry<float> MinimumHorizontalSpeedToCountSprint;
internal static ConfigEntry<bool> WarnInConsole;
internal static ConfigEntry<bool> ShowWarningOverlay;
internal static ConfigEntry<int> WarningFontSize;
internal static ConfigEntry<float> WarningDisplaySeconds;
internal static ConfigEntry<float> DetectedPlayerOutlineSeconds;
internal static ConfigEntry<string> TeleportToWarningPlayerKey;
internal static ConfigEntry<bool> EnableSpeedAnomalyAssist;
internal static ConfigEntry<float> SpeedAnomalyMultiplier;
internal static ConfigEntry<float> SpeedAnomalyMinimumSeconds;
internal static ConfigEntry<bool> IgnoreLocalPlayer;
internal static ConfigEntry<string> LanguageSetting;
private Harmony harmony;
private static FieldInfo fiSteamId;
private static FieldInfo fiIsSprinting;
private static FieldInfo fiIsMoving;
private static FieldInfo fiIsTumbling;
private static FieldInfo fiIsCrawling;
private static FieldInfo fiRbVelocityRaw;
private static FieldInfo fiRbVelocity;
private static FieldInfo fiDeadSet;
private static FieldInfo fiPlayerName;
private static FieldInfo fiClientPosition;
private static FieldInfo fiClientPositionCurrent;
private static FieldInfo fiClientRotation;
private static FieldInfo fiClientRotationCurrent;
private static FieldInfo fiPcVelocityRelativeNew;
private static FieldInfo fiPcVelocityImpulse;
private static FieldInfo fiPcMoveForceDirection;
private static FieldInfo fiPcMoveForceAmount;
private static FieldInfo fiPcMoveForceTimer;
private static FieldInfo fiPcPositionPrevious;
private readonly Dictionary<int, SprintTracker> trackerMap = new Dictionary<int, SprintTracker>();
private readonly List<OverlayMessage> overlayMessages = new List<OverlayMessage>();
private readonly Dictionary<int, float> detectedOutlineExpireMap = new Dictionary<int, float>();
private readonly Dictionary<int, PlayerOutlineShellController> outlineControllerMap = new Dictionary<int, PlayerOutlineShellController>();
private bool previousRunIsLevel;
private bool autoTranslatorChecked;
private readonly float autoTranslatorCheckTime = 8f;
private AudioSource warningAudioSource;
private AudioClip warningAudioClip;
private bool warningAudioLoadStarted;
private Texture2D warningBarGradientTexture;
private Texture2D warningBarHighlightTexture;
private Coroutine teleportStabilizeCoroutine;
private const float TeleportInitialBackDistance = 1.35f;
private const float TeleportMaxBackDistance = 9.75f;
private const float TeleportBackDistanceStep = 0.35f;
private const float TeleportGroundProbeHeight = 3.5f;
private const float TeleportGroundProbeDistance = 8f;
private const float TeleportCandidateHeightOffset = 0.08f;
private const float TeleportCapsulePadding = 0.04f;
private const int TeleportDepenetrationPasses = 8;
private const int TeleportStabilizeFrames = 4;
private const float WarningFadeInSeconds = 0.25f;
private const float WarningFadeOutSeconds = 0.25f;
private const string WarningAudioDirectoryName = "AntiInfiniteStamina";
private const string WarningAudioFileName = "warning_detect.ogg";
private void Awake()
{
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Expected O, but got Unknown
//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0507: Expected O, but got Unknown
Instance = this;
LogSource = ((BaseUnityPlugin)this).Logger;
((Component)this).transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableMod", true, "Enable or disable this mod. このMOD全体の有効無効を切り替えます");
EnableDebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableDebugLog", false, "Enable detailed debug logs in the console. コンソールへ詳細なデバッグログを出力します");
AllowedExtraSprintSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Detection", "AllowedExtraSprintSeconds", 2.5f, "Additional safe seconds added on top of the theoretical maximum sprint duration. Higher values reduce false positives but also weaken detection. 理論上の最大連続ダッシュ秒数に加算する安全マージンです。大きいほど誤検知は減りますが検出は緩くなります");
SprintBreakGraceSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Detection", "SprintBreakGraceSeconds", 0.35f, "Grace time that still counts as one continuous sprint chain when sprinting briefly stops because of sync jitter or tiny interruptions. 同期ぶれや短い停止で一瞬ダッシュ判定が切れても、連続走行として扱う猶予秒数です");
MinimumHorizontalSpeedToCountSprint = ((BaseUnityPlugin)this).Config.Bind<float>("Detection", "MinimumHorizontalSpeedToCountSprint", 0.15f, "Minimum horizontal movement speed required before sprint time starts counting. 連続ダッシュ秒数の計測を始めるために必要な最低水平速度です");
WarnInConsole = ((BaseUnityPlugin)this).Config.Bind<bool>("Warning", "WarnInConsole", true, "Write warning messages to the BepInEx console and log output. BepInExのコンソールとログへ警告文を出力します");
ShowWarningOverlay = ((BaseUnityPlugin)this).Config.Bind<bool>("Warning", "ShowWarningOverlay", true, "Show warning messages as an animated on-screen overlay on your client. あなたのクライアント画面上にアニメーション付き警告オーバーレイを表示します");
WarningFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Warning", "WarningFontSize", 26, "Font size used by the warning popup text. 警告ポップアップの文字サイズです");
WarningDisplaySeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Warning", "WarningDisplaySeconds", 5f, "How long the warning popup stays visible before it starts fading out. 警告ポップアップを表示し続けてからフェードアウトを始めるまでの秒数です");
DetectedPlayerOutlineSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Warning", "DetectedPlayerOutlineSeconds", 5f, "How long the detected target keeps a yellow outline after each detection. Set 0 to disable the outline. 検知された対象者へ黄色アウトラインを表示し続ける秒数です。0 でアウトライン機能を無効化します");
TeleportToWarningPlayerKey = ((BaseUnityPlugin)this).Config.Bind<string>("Warning", "TeleportToWarningPlayerKey", "J", "Key used to instantly teleport to the currently displayed warning target while the popup is visible. ポップアップ表示中に現在表示中の警告対象へ即時TPするキーです");
EnableSpeedAnomalyAssist = ((BaseUnityPlugin)this).Config.Bind<bool>("Assist", "EnableSpeedAnomalyAssist", true, "Use suspicious movement speed as an additional helper signal. The main detection is still continuous sprint time. 不自然な移動速度を補助判定として使います。主判定は連続ダッシュ時間です");
SpeedAnomalyMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Assist", "SpeedAnomalyMultiplier", 1.15f, "Speed ratio used for the helper anomaly check. 1.15 means 15% faster than the expected sprint speed. This is a practical default, not a value mathematically guaranteed by the game source. 補助用の速度異常判定で使う倍率です。1.15 は想定ダッシュ速度より 15% 速い状態を意味します。これは実用上の初期値であり、ソースコードから一意に導いた絶対最適値ではありません");
SpeedAnomalyMinimumSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Assist", "SpeedAnomalyMinimumSeconds", 5f, "Minimum duration that the suspicious speed condition must continue before it is treated as a helper anomaly. 速度異常の補助判定として扱うために、異常速度が継続しなければならない最低秒数です");
IgnoreLocalPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("Filtering", "IgnoreLocalPlayer", true, "Legacy compatibility setting. In the current client detection design, your own player is always excluded from detection. 互換性維持用の設定です。現行のクライアント検知仕様では、自分自身は常に検知対象から除外されます");
LanguageSetting = ((BaseUnityPlugin)this).Config.Bind<string>("Localization", "LanguageSetting", "English", new ConfigDescription("Language used by the MOD UI and warning text. Supported values are English, Japanese, Korean, Chinese and Russian. MODのUIと警告文で使う言語です。English、Japanese、Korean、Chinese、Russian に対応しています", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[5] { "English", "Japanese", "Korean", "Chinese", "Russian" }), Array.Empty<object>()));
fiSteamId = AccessTools.Field(typeof(PlayerAvatar), "steamID");
fiIsSprinting = AccessTools.Field(typeof(PlayerAvatar), "isSprinting");
fiIsMoving = AccessTools.Field(typeof(PlayerAvatar), "isMoving");
fiIsTumbling = AccessTools.Field(typeof(PlayerAvatar), "isTumbling");
fiIsCrawling = AccessTools.Field(typeof(PlayerAvatar), "isCrawling");
fiRbVelocityRaw = AccessTools.Field(typeof(PlayerAvatar), "rbVelocityRaw");
fiRbVelocity = AccessTools.Field(typeof(PlayerAvatar), "rbVelocity");
fiDeadSet = AccessTools.Field(typeof(PlayerAvatar), "deadSet");
fiPlayerName = AccessTools.Field(typeof(PlayerAvatar), "playerName");
fiClientPosition = AccessTools.Field(typeof(PlayerAvatar), "clientPosition");
fiClientPositionCurrent = AccessTools.Field(typeof(PlayerAvatar), "clientPositionCurrent");
fiClientRotation = AccessTools.Field(typeof(PlayerAvatar), "clientRotation");
fiClientRotationCurrent = AccessTools.Field(typeof(PlayerAvatar), "clientRotationCurrent");
fiPcVelocityRelativeNew = AccessTools.Field(typeof(PlayerController), "VelocityRelativeNew");
fiPcVelocityImpulse = AccessTools.Field(typeof(PlayerController), "VelocityImpulse");
fiPcMoveForceDirection = AccessTools.Field(typeof(PlayerController), "MoveForceDirection");
fiPcMoveForceAmount = AccessTools.Field(typeof(PlayerController), "MoveForceAmount");
fiPcMoveForceTimer = AccessTools.Field(typeof(PlayerController), "MoveForceTimer");
fiPcPositionPrevious = AccessTools.Field(typeof(PlayerController), "positionPrevious");
warningAudioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
warningAudioSource.playOnAwake = false;
warningAudioSource.loop = false;
warningAudioSource.spatialBlend = 0f;
warningAudioSource.volume = 1f;
warningAudioSource.ignoreListenerPause = true;
warningAudioSource.priority = 0;
warningAudioClip = CreateFallbackWarningClip();
ForceTeleportKeyToJ();
CreateWarningBarTextures();
harmony = new Harmony("REPOJP.AntiInfiniteStamina");
harmony.PatchAll(typeof(AntiInfiniteStaminaPlugin));
LogInfo(GetLocalizedText("Loaded"));
}
private void ForceTeleportKeyToJ()
{
if (TeleportToWarningPlayerKey != null)
{
string a = (TeleportToWarningPlayerKey.Value ?? string.Empty).Trim();
if (!string.Equals(a, "J", StringComparison.OrdinalIgnoreCase))
{
TeleportToWarningPlayerKey.Value = "J";
((BaseUnityPlugin)this).Config.Save();
}
}
}
private void OnDestroy()
{
DisableAllDetectedPlayerOutlines();
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
EnsureWarningAudioLoaded();
TryApplyJapaneseFromAutoTranslator();
if (!EnableMod.Value)
{
ClearRunStateIfNeeded();
return;
}
if (!SemiFunc.RunIsLevel())
{
ClearRunStateIfNeeded();
return;
}
if (!previousRunIsLevel)
{
trackerMap.Clear();
overlayMessages.Clear();
}
previousRunIsLevel = true;
if ((Object)(object)GameDirector.instance == (Object)null || GameDirector.instance.PlayerList == null || (Object)(object)StatsManager.instance == (Object)null)
{
return;
}
float num = Mathf.Max(Time.deltaTime, 0f);
float time = Time.time;
HashSet<int> hashSet = new HashSet<int>();
foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
{
if ((Object)(object)player == (Object)null || IsLocalPlayer(player) || !IsAlivePlayer(player))
{
continue;
}
string steamId = GetSteamId(player);
if (string.IsNullOrEmpty(steamId))
{
continue;
}
int stablePlayerId = GetStablePlayerId(player);
hashSet.Add(stablePlayerId);
if (!trackerMap.TryGetValue(stablePlayerId, out SprintTracker value))
{
value = new SprintTracker();
value.StableId = stablePlayerId;
trackerMap[stablePlayerId] = value;
}
value.PlayerName = GetPlayerName(player);
value.SteamId = steamId;
value.LastSeenTime = time;
int upgradeValue = GetUpgradeValue(StatsManager.instance.playerUpgradeStamina, steamId);
int upgradeValue2 = GetUpgradeValue(StatsManager.instance.playerUpgradeSpeed, steamId);
value.LastStaminaUpgrade = upgradeValue;
value.LastSpeedUpgrade = upgradeValue2;
float num2 = (value.LastAllowedSprintSeconds = CalculateAllowedSprintSeconds(upgradeValue, upgradeValue2));
bool @bool = GetBool(fiIsSprinting, player);
bool bool2 = GetBool(fiIsMoving, player);
bool bool3 = GetBool(fiIsTumbling, player);
bool bool4 = GetBool(fiIsCrawling, player);
Vector3 velocity = GetVelocity(player);
Vector2 val = new Vector2(velocity.x, velocity.z);
float magnitude = ((Vector2)(ref val)).magnitude;
if (magnitude > value.MaxObservedHorizontalSpeed)
{
value.MaxObservedHorizontalSpeed = magnitude;
}
bool flag = @bool && bool2 && !bool3 && !bool4 && magnitude >= MinimumHorizontalSpeedToCountSprint.Value;
if (flag)
{
value.CurrentSprintSeconds += num;
value.NonSprintGraceSeconds = 0f;
if (value.CurrentSprintSeconds > value.MaxObservedSprintSeconds)
{
value.MaxObservedSprintSeconds = value.CurrentSprintSeconds;
}
}
else
{
value.NonSprintGraceSeconds += num;
if (value.NonSprintGraceSeconds > SprintBreakGraceSeconds.Value)
{
value.CurrentSprintSeconds = 0f;
value.NonSprintGraceSeconds = 0f;
value.WarnedThisChain = false;
value.CurrentSpeedAnomalySeconds = 0f;
}
}
if (EnableSpeedAnomalyAssist.Value && flag)
{
float num3 = 1.5f + (float)upgradeValue2;
float num4 = num3 * Mathf.Max(1f, SpeedAnomalyMultiplier.Value);
if (magnitude > num4)
{
value.CurrentSpeedAnomalySeconds += num;
}
else
{
value.CurrentSpeedAnomalySeconds = 0f;
}
}
else
{
value.CurrentSpeedAnomalySeconds = 0f;
}
bool flag2 = value.CurrentSprintSeconds > num2;
bool flag3 = EnableSpeedAnomalyAssist.Value && value.CurrentSpeedAnomalySeconds >= SpeedAnomalyMinimumSeconds.Value;
if (flag2 || flag3)
{
value.SuspiciousCount++;
EmitWarning(value);
ResetTrackerAfterWarning(value);
}
}
CleanupMissingTrackers(time, hashSet);
CleanupOverlayMessages(time);
UpdateDetectedPlayerOutlines(time, hashSet);
HandleTeleportToCurrentWarning();
}
private void OnGUI()
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Expected O, but got Unknown
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Unknown result type (might be due to invalid IL or missing references)
//IL_037e: Unknown result type (might be due to invalid IL or missing references)
//IL_0394: Unknown result type (might be due to invalid IL or missing references)
//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
if (!EnableMod.Value || !ShowWarningOverlay.Value || !SemiFunc.RunIsLevel())
{
return;
}
CleanupOverlayMessages(Time.time);
OverlayMessage currentOverlayMessage = GetCurrentOverlayMessage(Time.time);
if (currentOverlayMessage != null)
{
GUIStyle val = new GUIStyle(GUI.skin.box);
val.alignment = (TextAnchor)4;
val.fontSize = Mathf.Max(12, WarningFontSize.Value);
val.wordWrap = true;
GUIStyle val2 = new GUIStyle(GUI.skin.label);
val2.alignment = (TextAnchor)4;
val2.fontSize = Mathf.Max(12, WarningFontSize.Value);
val2.wordWrap = true;
val2.richText = false;
val2.normal.textColor = Color.white;
GUIStyle val3 = new GUIStyle(GUI.skin.label);
val3.alignment = (TextAnchor)4;
val3.fontSize = Mathf.Max(10, WarningFontSize.Value - 6);
val3.wordWrap = false;
val3.normal.textColor = new Color(1f, 1f, 1f, 0.95f);
float num = Mathf.Min(1100f, (float)Screen.width - 80f);
float num2 = Mathf.Max(96f, (float)WarningFontSize.Value + 60f);
float num3 = ((float)Screen.width - num) * 0.5f;
float num4 = (float)Screen.height * 0.7f;
float num5 = (float)Screen.height + num2 + 20f;
float num6 = Mathf.Max(0.5f, WarningDisplaySeconds.Value);
float num7 = 0.25f + num6 + 0.25f;
float num8 = Time.time - currentOverlayMessage.CreatedAt;
float num10;
float num11;
if (num8 < 0.25f)
{
float num9 = Mathf.Clamp01(num8 / 0.25f);
num10 = num9;
num11 = Mathf.Lerp(num5, num4, num9);
}
else if (num8 < 0.25f + num6)
{
num10 = 1f;
num11 = num4;
}
else
{
float num12 = Mathf.Clamp01((num8 - 0.25f - num6) / 0.25f);
num10 = 1f - num12;
num11 = Mathf.Lerp(num4, num5, num12);
}
float num13 = 1f - Mathf.Clamp01(num8 / num7);
float num14 = 10f;
float num15 = 18f;
float num16 = num - num15 * 2f;
float num17 = num11 + num2 - 18f;
Color color = GUI.color;
GUI.color = new Color(0f, 0f, 0f, 0.78f * num10);
GUI.Box(new Rect(num3, num11, num, num2), string.Empty, val);
GUI.color = new Color(1f, 1f, 1f, num10);
GUI.Label(new Rect(num3 + 16f, num11 + 8f, num - 32f, num2 - 46f), currentOverlayMessage.Text, val2);
GUI.Label(new Rect(num3 + 16f, num11 + num2 - 40f, num - 32f, 18f), currentOverlayMessage.TeleportHint, val3);
GUI.color = new Color(0f, 0f, 0f, 0.55f * num10);
GUI.Box(new Rect(num3 + num15, num17, num16, num14), string.Empty);
DrawYellowGradientBar(new Rect(num3 + num15, num17, num16 * num13, num14), num10);
GUI.color = color;
}
}
private void DrawYellowGradientBar(Rect rect, float alpha)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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_00e0: 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_012e: 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)
if (!(((Rect)(ref rect)).width <= 0f) && !(((Rect)(ref rect)).height <= 0f))
{
if ((Object)(object)warningBarGradientTexture == (Object)null || (Object)(object)warningBarHighlightTexture == (Object)null)
{
CreateWarningBarTextures();
}
Color color = GUI.color;
GUI.color = new Color(1f, 1f, 1f, 0.98f * alpha);
GUI.DrawTexture(rect, (Texture)(object)warningBarGradientTexture, (ScaleMode)0, false);
GUI.color = new Color(1f, 1f, 1f, 0.3f * alpha);
GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + 1f, ((Rect)(ref rect)).width, Mathf.Max(2f, ((Rect)(ref rect)).height * 0.45f)), (Texture)(object)warningBarHighlightTexture, (ScaleMode)0, true);
GUI.color = new Color(1f, 0.95f, 0.55f, 0.95f * alpha);
GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1f), (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0, false);
GUI.color = color;
}
}
private void CreateWarningBarTextures()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Expected O, but got Unknown
//IL_01b3: 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_00dc: 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_00f3: 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_0099: 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_00aa: 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)
if ((Object)(object)warningBarGradientTexture == (Object)null)
{
warningBarGradientTexture = new Texture2D(256, 1, (TextureFormat)4, false);
((Texture)warningBarGradientTexture).wrapMode = (TextureWrapMode)1;
((Object)warningBarGradientTexture).hideFlags = (HideFlags)61;
for (int i = 0; i < ((Texture)warningBarGradientTexture).width; i++)
{
float num = (float)i / (float)(((Texture)warningBarGradientTexture).width - 1);
Color val = ((!(num < 0.45f)) ? Color.Lerp(new Color(1f, 0.98f, 0.34f, 1f), new Color(1f, 0.76f, 0.08f, 1f), (num - 0.45f) / 0.55f) : Color.Lerp(new Color(1f, 0.88f, 0.12f, 1f), new Color(1f, 0.98f, 0.34f, 1f), num / 0.45f));
warningBarGradientTexture.SetPixel(i, 0, val);
}
warningBarGradientTexture.Apply(false, true);
}
if ((Object)(object)warningBarHighlightTexture == (Object)null)
{
warningBarHighlightTexture = new Texture2D(64, 1, (TextureFormat)4, false);
((Texture)warningBarHighlightTexture).wrapMode = (TextureWrapMode)1;
((Object)warningBarHighlightTexture).hideFlags = (HideFlags)61;
for (int j = 0; j < ((Texture)warningBarHighlightTexture).width; j++)
{
float num2 = (float)j / (float)(((Texture)warningBarHighlightTexture).width - 1);
float num3 = Mathf.Sin(num2 * MathF.PI);
warningBarHighlightTexture.SetPixel(j, 0, new Color(1f, 1f, 1f, num3));
}
warningBarHighlightTexture.Apply(false, true);
}
}
private float CalculateAllowedSprintSeconds(int staminaUpgrade, int speedUpgrade)
{
float num = 100f + (float)staminaUpgrade * 10f;
float num2 = 1f + (float)speedUpgrade;
if (num2 <= 0f)
{
num2 = 1f;
}
float num3 = num / num2;
return num3 + Mathf.Max(0f, AllowedExtraSprintSeconds.Value);
}
private void ResetTrackerAfterWarning(SprintTracker tracker)
{
if (tracker != null)
{
tracker.CurrentSprintSeconds = 0f;
tracker.NonSprintGraceSeconds = 0f;
tracker.CurrentSpeedAnomalySeconds = 0f;
tracker.WarnedThisChain = false;
}
}
private void EmitWarning(SprintTracker tracker)
{
string text = string.Format(GetLocalizedText("WarningFormat"), tracker.PlayerName, tracker.LastStaminaUpgrade, tracker.LastSpeedUpgrade, tracker.SuspiciousCount);
if (WarnInConsole.Value)
{
LogInfo(text);
}
MarkDetectedPlayerOutline(tracker.StableId);
if (ShowWarningOverlay.Value)
{
OverlayMessage overlayMessage = new OverlayMessage();
overlayMessage.Text = text;
overlayMessage.TeleportHint = string.Format(GetLocalizedText("TeleportHint"), GetDisplayTeleportKeyName());
overlayMessage.CreatedAt = Time.time;
overlayMessage.ExpiresAt = Time.time + 0.25f + Mathf.Max(0.5f, WarningDisplaySeconds.Value) + 0.25f;
overlayMessage.TargetStableId = tracker.StableId;
overlayMessage.TargetPlayerName = tracker.PlayerName;
overlayMessages.Add(overlayMessage);
PlayWarningSound();
}
}
private void PlayWarningSound()
{
EnsureWarningAudioLoaded();
if ((Object)(object)warningAudioSource == (Object)null)
{
warningAudioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
warningAudioSource.playOnAwake = false;
warningAudioSource.loop = false;
warningAudioSource.spatialBlend = 0f;
warningAudioSource.volume = 1f;
warningAudioSource.priority = 0;
warningAudioSource.ignoreListenerPause = true;
warningAudioSource.bypassReverbZones = true;
}
if ((Object)(object)warningAudioClip == (Object)null)
{
warningAudioClip = CreateFallbackWarningClip();
}
if (!((Object)(object)warningAudioSource == (Object)null) && !((Object)(object)warningAudioClip == (Object)null))
{
if ((Object)(object)warningAudioSource.outputAudioMixerGroup == (Object)null && (Object)(object)AudioManager.instance != (Object)null)
{
warningAudioSource.outputAudioMixerGroup = AudioManager.instance.SoundMasterGroup;
}
warningAudioSource.Stop();
warningAudioSource.PlayOneShot(warningAudioClip, 1f);
}
}
private void EnsureWarningAudioLoaded()
{
if ((Object)(object)warningAudioSource != (Object)null && (Object)(object)warningAudioSource.outputAudioMixerGroup == (Object)null && (Object)(object)AudioManager.instance != (Object)null)
{
warningAudioSource.outputAudioMixerGroup = AudioManager.instance.SoundMasterGroup;
}
if ((Object)(object)warningAudioClip == (Object)null)
{
warningAudioClip = CreateFallbackWarningClip();
}
if (!warningAudioLoadStarted)
{
string path = Path.Combine(Paths.ConfigPath, "AntiInfiniteStamina");
string text = Path.Combine(path, "warning_detect.ogg");
if (File.Exists(text))
{
warningAudioLoadStarted = true;
((MonoBehaviour)this).StartCoroutine(LoadWarningAudioCoroutine(text));
}
}
}
[IteratorStateMachine(typeof(<LoadWarningAudioCoroutine>d__80))]
private IEnumerator LoadWarningAudioCoroutine(string filePath)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadWarningAudioCoroutine>d__80(0)
{
<>4__this = this,
filePath = filePath
};
}
private AudioClip CreateFallbackWarningClip()
{
int num = Mathf.CeilToInt(18522f);
float[] array = new float[num];
for (int i = 0; i < num; i++)
{
float num2 = (float)i / 44100f;
float num3 = 1f;
if (num2 < 0.03f)
{
num3 = num2 / 0.03f;
}
else if (num2 > 0.33999997f)
{
num3 = Mathf.Clamp01((0.42f - num2) / 0.08f);
}
float num4 = ((num2 < 0.21f) ? 880f : 1320f);
float num5 = Mathf.Sin(num2 * num4 * MathF.PI * 2f);
float num6 = Mathf.Sin(num2 * (num4 * 0.5f) * MathF.PI * 2f) * 0.35f;
array[i] = (num5 * 0.65f + num6) * num3 * 0.28f;
}
AudioClip val = AudioClip.Create("AntiInfiniteStaminaWarningFallback", num, 1, 44100, false);
val.SetData(array, 0);
return val;
}
private void SetFieldValue(FieldInfo fieldInfo, object instance, object value)
{
if (fieldInfo == null || instance == null)
{
return;
}
try
{
fieldInfo.SetValue(instance, value);
}
catch
{
}
}
private void CleanupMissingTrackers(float now, HashSet<int> seenIds)
{
List<int> list = new List<int>();
foreach (KeyValuePair<int, SprintTracker> item in trackerMap)
{
if (!seenIds.Contains(item.Key) && now - item.Value.LastSeenTime > 2f)
{
list.Add(item.Key);
}
}
for (int i = 0; i < list.Count; i++)
{
trackerMap.Remove(list[i]);
}
}
private void CleanupOverlayMessages(float now)
{
for (int num = overlayMessages.Count - 1; num >= 0; num--)
{
if (overlayMessages[num].ExpiresAt <= now)
{
overlayMessages.RemoveAt(num);
}
}
}
private OverlayMessage GetCurrentOverlayMessage(float now)
{
OverlayMessage overlayMessage = null;
for (int i = 0; i < overlayMessages.Count; i++)
{
OverlayMessage overlayMessage2 = overlayMessages[i];
if (!(overlayMessage2.ExpiresAt <= now) && (overlayMessage == null || overlayMessage2.CreatedAt > overlayMessage.CreatedAt))
{
overlayMessage = overlayMessage2;
}
}
return overlayMessage;
}
private void HandleTeleportToCurrentWarning()
{
if (!ShowWarningOverlay.Value)
{
return;
}
OverlayMessage currentOverlayMessage = GetCurrentOverlayMessage(Time.time);
if (currentOverlayMessage != null && IsTeleportHotkeyPressed())
{
PlayerAvatar val = FindPlayerByStableId(currentOverlayMessage.TargetStableId);
if (!((Object)(object)val == (Object)null) && IsAlivePlayer(val))
{
TeleportLocalPlayerNearTarget(val);
}
}
}
private bool IsTeleportHotkeyPressed()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Invalid comparison between Unknown and I4
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown((KeyCode)106))
{
return true;
}
KeyCode val = ParseTeleportKey();
if ((int)val != 106 && Input.GetKeyDown(val))
{
return true;
}
return false;
}
private KeyCode ParseTeleportKey()
{
//IL_0057: 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)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
string text = ((TeleportToWarningPlayerKey != null) ? (TeleportToWarningPlayerKey.Value ?? string.Empty) : string.Empty);
if (string.IsNullOrWhiteSpace(text))
{
return (KeyCode)106;
}
try
{
return (KeyCode)Enum.Parse(typeof(KeyCode), text.Trim(), ignoreCase: true);
}
catch
{
return (KeyCode)106;
}
}
private string GetDisplayTeleportKeyName()
{
return "J";
}
private PlayerAvatar FindPlayerByStableId(int stableId)
{
if ((Object)(object)GameDirector.instance == (Object)null || GameDirector.instance.PlayerList == null)
{
return null;
}
foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
{
if ((Object)(object)player == (Object)null || GetStablePlayerId(player) != stableId)
{
continue;
}
return player;
}
return null;
}
private void TeleportLocalPlayerNearTarget(PlayerAvatar target)
{
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
PlayerController instance = PlayerController.instance;
PlayerAvatar val = null;
if ((Object)(object)instance != (Object)null)
{
val = instance.playerAvatarScript;
}
if ((Object)(object)val == (Object)null)
{
val = PlayerAvatar.instance;
}
if (!((Object)(object)val == (Object)null) && !((Object)(object)instance == (Object)null) && !((Object)(object)target == (Object)null))
{
ResolveTeleportPlacement(val, target, out var destination, out var rotation);
ManualLocalTeleport(val, destination, rotation);
}
}
private void ResolveTeleportPlacement(PlayerAvatar localPlayer, PlayerAvatar target, out Vector3 destination, out Quaternion rotation)
{
//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_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: 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_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: 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_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: 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_011f: 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_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_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//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_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
Vector3 teleportTargetPosition = GetTeleportTargetPosition(target);
Quaternion teleportTargetRotation = GetTeleportTargetRotation(target);
Vector3 val = Vector3.ProjectOnPlane(teleportTargetRotation * Vector3.forward, Vector3.up);
if (((Vector3)(ref val)).sqrMagnitude <= 0.0001f)
{
val = Vector3.ProjectOnPlane(((Component)target).transform.forward, Vector3.up);
}
if (((Vector3)(ref val)).sqrMagnitude <= 0.0001f && (Object)(object)localPlayer != (Object)null)
{
val = Vector3.ProjectOnPlane(((Component)localPlayer).transform.position - teleportTargetPosition, Vector3.up);
}
if (((Vector3)(ref val)).sqrMagnitude <= 0.0001f)
{
val = Vector3.forward;
}
((Vector3)(ref val)).Normalize();
Vector3 val2 = Vector3.Cross(Vector3.up, val);
if (((Vector3)(ref val2)).sqrMagnitude <= 0.0001f)
{
val2 = Vector3.right;
}
((Vector3)(ref val2)).Normalize();
rotation = Quaternion.LookRotation(val, Vector3.up);
destination = teleportTargetPosition - val * 1.35f + Vector3.up * 0.08f;
float[] array = new float[9] { 0f, 0.45f, -0.45f, 0.9f, -0.9f, 1.35f, -1.35f, 1.8f, -1.8f };
for (int i = 0; i < 2; i++)
{
bool ignorePlayerBodies = i == 1;
for (float num = 1.35f; num <= 9.751f; num += 0.35f)
{
float num2 = Mathf.Lerp(0.22f, 0.48f, Mathf.InverseLerp(1.35f, 9.75f, num));
for (int j = 0; j < array.Length; j++)
{
float num3 = array[j] * num2;
Vector3 candidateBase = teleportTargetPosition - val * num + val2 * num3;
if (TryResolveTeleportCandidate(localPlayer, target, teleportTargetPosition, candidateBase, rotation, ignorePlayerBodies, out var resolved))
{
destination = resolved;
DebugLog(string.Format("Teleport candidate accepted / TP候補採用 pass:{0} dist:{1:F2} lateral:{2:F2} pos:{3}", i + 1, num, num3, ((Vector3)(ref destination)).ToString("F2")));
return;
}
}
}
}
Vector3 candidateBase2 = teleportTargetPosition - val * Mathf.Min(9.75f, 4.5f);
if (TryResolveTeleportFallback(localPlayer, target, teleportTargetPosition, candidateBase2, rotation, out var resolved2))
{
destination = resolved2;
DebugLog("Teleport fallback accepted / TP最終フォールバック採用 " + ((Vector3)(ref destination)).ToString("F2"));
}
else
{
destination = teleportTargetPosition - val * 1.35f + Vector3.up * 0.08f;
DebugLog("Teleport hard fallback used / TP強制フォールバック使用 " + ((Vector3)(ref destination)).ToString("F2"));
}
}
private bool TryResolveTeleportCandidate(PlayerAvatar localPlayer, PlayerAvatar target, Vector3 targetPosition, Vector3 candidateBase, Quaternion rotation, bool ignorePlayerBodies, out Vector3 resolved)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: 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_00b3: 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)
resolved = candidateBase + Vector3.up * 0.08f;
if (!TryProjectTeleportCandidateToGround(targetPosition, candidateBase, out var grounded))
{
((Vector3)(ref grounded))..ctor(candidateBase.x, targetPosition.y, candidateBase.z);
}
grounded += Vector3.up * 0.08f;
if (IsTeleportPathBlocked(targetPosition, grounded, localPlayer, target, ignorePlayerBodies))
{
return false;
}
Vector3 position = grounded;
if (!TryDepenetrateTeleportPosition(localPlayer, target, ref position, rotation, ignorePlayerBodies))
{
return false;
}
if (IsTeleportSpotBlocked(localPlayer, target, position, rotation, ignorePlayerBodies))
{
return false;
}
resolved = position;
return true;
}
private bool TryResolveTeleportFallback(PlayerAvatar localPlayer, PlayerAvatar target, Vector3 targetPosition, Vector3 candidateBase, Quaternion rotation, out Vector3 resolved)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
resolved = candidateBase + Vector3.up * 0.08f;
if (!TryProjectTeleportCandidateToGround(targetPosition, candidateBase, out var grounded))
{
((Vector3)(ref grounded))..ctor(candidateBase.x, targetPosition.y, candidateBase.z);
}
grounded += Vector3.up * 0.08f;
Vector3 position = grounded;
if (!TryDepenetrateTeleportPosition(localPlayer, target, ref position, rotation, ignorePlayerBodies: true))
{
return false;
}
resolved = position;
return true;
}
private Vector3 GetTeleportTargetPosition(PlayerAvatar target)
{
//IL_000d: 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_00bd: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)target == (Object)null)
{
return Vector3.zero;
}
try
{
if (fiClientPositionCurrent != null && fiClientPositionCurrent.GetValue(target) is Vector3 val && val != Vector3.zero)
{
return val;
}
if (fiClientPosition != null)
{
object value = fiClientPosition.GetValue(target);
if (value is Vector3)
{
Vector3 val2 = (Vector3)value;
if (val2 != Vector3.zero)
{
return val2;
}
}
}
}
catch
{
}
return ((Component)target).transform.position;
}
private Quaternion GetTeleportTargetRotation(PlayerAvatar target)
{
//IL_000d: 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_00bb: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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_005d: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)target == (Object)null)
{
return Quaternion.identity;
}
try
{
if (fiClientRotationCurrent != null && fiClientRotationCurrent.GetValue(target) is Quaternion val && !IsInvalidQuaternion(val))
{
return val;
}
if (fiClientRotation != null)
{
object value = fiClientRotation.GetValue(target);
if (value is Quaternion)
{
Quaternion val2 = (Quaternion)value;
if (!IsInvalidQuaternion(val2))
{
return val2;
}
}
}
}
catch
{
}
return ((Component)target).transform.rotation;
}
private bool IsInvalidQuaternion(Quaternion rotation)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
return rotation.x == 0f && rotation.y == 0f && rotation.z == 0f && rotation.w == 0f;
}
private bool TryProjectTeleportCandidateToGround(Vector3 targetPosition, Vector3 candidateBase, out Vector3 grounded)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = candidateBase + Vector3.up * 3.5f;
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(val, Vector3.down, ref val2, 8f, -1, (QueryTriggerInteraction)1))
{
grounded = ((RaycastHit)(ref val2)).point;
return true;
}
grounded = new Vector3(candidateBase.x, targetPosition.y, candidateBase.z);
return false;
}
private bool IsTeleportPathBlocked(Vector3 targetPosition, Vector3 destination, PlayerAvatar localPlayer, PlayerAvatar target, bool ignorePlayerBodies)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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)
//IL_0054: 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_005c: 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)
Vector3 val = targetPosition + Vector3.up * 1f;
Vector3 val2 = destination + Vector3.up * 1f;
Vector3 val3 = val2 - val;
float magnitude = ((Vector3)(ref val3)).magnitude;
if (magnitude <= 0.01f)
{
return false;
}
val3 /= magnitude;
RaycastHit[] array = Physics.RaycastAll(val, val3, magnitude, -1, (QueryTriggerInteraction)1);
for (int i = 0; i < array.Length; i++)
{
Collider collider = ((RaycastHit)(ref array[i])).collider;
if (!IsIgnoredTeleportCollider(collider, localPlayer, target, ignorePlayerBodies))
{
return true;
}
}
return false;
}
private bool IsTeleportSpotBlocked(PlayerAvatar localPlayer, PlayerAvatar target, Vector3 position, Quaternion rotation, bool ignorePlayerBodies)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
Collider[] teleportOverlapHits = GetTeleportOverlapHits(localPlayer, position, rotation);
for (int i = 0; i < teleportOverlapHits.Length; i++)
{
if (!IsIgnoredTeleportCollider(teleportOverlapHits[i], localPlayer, target, ignorePlayerBodies))
{
return true;
}
}
return false;
}
private Collider[] GetTeleportOverlapHits(PlayerAvatar localPlayer, Vector3 position, Quaternion rotation)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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_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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
GetTeleportCapsule(localPlayer, out var center, out var height, out var radius);
Vector3 val = position + rotation * center;
float num = Mathf.Max(0f, height * 0.5f - radius);
Vector3 val2 = rotation * Vector3.up;
Vector3 val3 = val + val2 * num;
Vector3 val4 = val - val2 * num;
return Physics.OverlapCapsule(val3, val4, radius + 0.04f, -1, (QueryTriggerInteraction)1);
}
private void GetTeleportCapsule(PlayerAvatar localPlayer, out Vector3 center, out float height, out float radius)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
center = new Vector3(0f, 0.9f, 0f);
height = 1.8f;
radius = 0.32f;
CapsuleCollider val = null;
if ((Object)(object)PlayerCollisionStand.instance != (Object)null)
{
val = ((Component)PlayerCollisionStand.instance).GetComponent<CapsuleCollider>();
}
if ((Object)(object)val == (Object)null && (Object)(object)localPlayer != (Object)null)
{
val = ((Component)localPlayer).GetComponentInChildren<CapsuleCollider>();
}
if (!((Object)(object)val == (Object)null))
{
center = val.center;
height = Mathf.Max(val.height, val.radius * 2f + 0.1f);
radius = Mathf.Max(0.1f, val.radius);
}
}
private bool TryDepenetrateTeleportPosition(PlayerAvatar localPlayer, PlayerAvatar target, ref Vector3 position, Quaternion rotation, bool ignorePlayerBodies)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: 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_015d: 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_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
CapsuleCollider val = null;
if ((Object)(object)PlayerCollisionStand.instance != (Object)null)
{
val = ((Component)PlayerCollisionStand.instance).GetComponent<CapsuleCollider>();
}
if ((Object)(object)val == (Object)null && (Object)(object)localPlayer != (Object)null)
{
val = ((Component)localPlayer).GetComponentInChildren<CapsuleCollider>();
}
if ((Object)(object)val == (Object)null)
{
return !IsTeleportSpotBlocked(localPlayer, target, position, rotation, ignorePlayerBodies);
}
Vector3 val4 = default(Vector3);
float num = default(float);
for (int i = 0; i < 8; i++)
{
Collider[] teleportOverlapHits = GetTeleportOverlapHits(localPlayer, position, rotation);
bool flag = false;
Vector3 val2 = Vector3.zero;
foreach (Collider val3 in teleportOverlapHits)
{
if (!IsIgnoredTeleportCollider(val3, localPlayer, target, ignorePlayerBodies) && Physics.ComputePenetration((Collider)(object)val, position, rotation, val3, ((Component)val3).transform.position, ((Component)val3).transform.rotation, ref val4, ref num))
{
flag = true;
val2 += val4 * (num + 0.01f);
}
}
if (!flag)
{
return true;
}
if (((Vector3)(ref val2)).sqrMagnitude <= 1E-06f)
{
break;
}
position += val2;
if (TryProjectTeleportCandidateToGround(position, position, out var grounded))
{
position = grounded + Vector3.up * 0.08f;
}
}
return !IsTeleportSpotBlocked(localPlayer, target, position, rotation, ignorePlayerBodies);
}
private bool IsIgnoredTeleportCollider(Collider hit, PlayerAvatar localPlayer, PlayerAvatar target, bool ignorePlayerBodies)
{
if ((Object)(object)hit == (Object)null)
{
return true;
}
if (hit.isTrigger)
{
return true;
}
Transform transform = ((Component)hit).transform;
if ((Object)(object)localPlayer != (Object)null && transform.IsChildOf(((Component)localPlayer).transform))
{
return true;
}
if ((Object)(object)target != (Object)null && transform.IsChildOf(((Component)target).transform))
{
return true;
}
if (ignorePlayerBodies)
{
if ((Object)(object)((Component)hit).GetComponentInParent<PlayerAvatar>() != (Object)null)
{
return true;
}
if ((Object)(object)((Component)hit).GetComponentInParent<PlayerController>() != (Object)null)
{
return true;
}
if ((Object)(object)((Component)hit).GetComponentInParent<PlayerCollisionController>() != (Object)null)
{
return true;
}
if ((Object)(object)((Component)hit).GetComponentInParent<PlayerCollisionGrounded>() != (Object)null)
{
return true;
}
if ((Object)(object)((Component)hit).GetComponentInParent<PlayerCollisionStand>() != (Object)null)
{
return true;
}
}
return false;
}
private void ManualLocalTeleport(PlayerAvatar localPlayer, Vector3 destination, Quaternion rotation)
{
//IL_0060: 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_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: 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)
//IL_018c: 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_0175: Unknown result type (might be due to invalid IL or missing references)
PlayerController instance = PlayerController.instance;
if (!((Object)(object)instance == (Object)null) && !((Object)(object)localPlayer == (Object)null))
{
if (teleportStabilizeCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(teleportStabilizeCoroutine);
teleportStabilizeCoroutine = null;
}
instance.InputDisable(0.25f);
instance.Kinematic(0.25f);
instance.MoveForce(Vector3.zero, 0f, 0f);
instance.Velocity = Vector3.zero;
instance.VelocityRelative = Vector3.zero;
SetFieldValue(fiPcPositionPrevious, instance, destination);
SetFieldValue(fiPcVelocityRelativeNew, instance, Vector3.zero);
SetFieldValue(fiPcVelocityImpulse, instance, Vector3.zero);
SetFieldValue(fiPcMoveForceDirection, instance, Vector3.zero);
SetFieldValue(fiPcMoveForceAmount, instance, 0f);
SetFieldValue(fiPcMoveForceTimer, instance, 0f);
if ((Object)(object)instance.CollisionController != (Object)null)
{
instance.CollisionController.ResetFalling();
instance.CollisionController.GroundedDisableTimer = 0.15f;
}
if ((Object)(object)instance.CollisionGrounded != (Object)null)
{
instance.CollisionGrounded.physRiding = false;
instance.CollisionGrounded.physRidingID = 0;
instance.CollisionGrounded.physRidingPosition = Vector3.zero;
}
ApplyManualTeleportPose(localPlayer, instance, destination, rotation, refreshCamera: true);
teleportStabilizeCoroutine = ((MonoBehaviour)this).StartCoroutine(TeleportStabilizeCoroutine(localPlayer, destination, rotation));
LogInfo("Teleport executed / TP実行 " + ((Vector3)(ref destination)).ToString("F2"));
}
}
private void ApplyManualTeleportPose(PlayerAvatar localPlayer, PlayerController playerController, Vector3 destination, Quaternion rotation, bool refreshCamera)
{
//IL_009a: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: 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_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: 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_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: 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_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)localPlayer == (Object)null || (Object)(object)playerController == (Object)null)
{
return;
}
if ((Object)(object)playerController.rb != (Object)null)
{
playerController.rb.velocity = Vector3.zero;
playerController.rb.angularVelocity = Vector3.zero;
playerController.rb.position = destination;
playerController.rb.rotation = rotation;
playerController.rb.MovePosition(destination);
playerController.rb.MoveRotation(rotation);
playerController.rb.WakeUp();
}
((Component)playerController).transform.position = destination;
((Component)playerController).transform.rotation = rotation;
Rigidbody component = ((Component)localPlayer).GetComponent<Rigidbody>();
if ((Object)(object)component != (Object)null)
{
component.velocity = Vector3.zero;
component.angularVelocity = Vector3.zero;
component.position = destination;
component.rotation = rotation;
component.MovePosition(destination);
component.MoveRotation(rotation);
component.WakeUp();
}
((Component)localPlayer).transform.position = destination;
((Component)localPlayer).transform.rotation = rotation;
if ((Object)(object)localPlayer.playerTransform != (Object)null)
{
localPlayer.playerTransform.position = destination;
localPlayer.playerTransform.rotation = rotation;
}
SetFieldValue(fiClientPosition, localPlayer, destination);
SetFieldValue(fiClientPositionCurrent, localPlayer, destination);
SetFieldValue(fiClientRotation, localPlayer, rotation);
SetFieldValue(fiClientRotationCurrent, localPlayer, rotation);
if ((Object)(object)localPlayer.playerAvatarVisuals != (Object)null)
{
((Component)localPlayer.playerAvatarVisuals).transform.position = destination;
((Component)localPlayer.playerAvatarVisuals).transform.rotation = rotation;
localPlayer.playerAvatarVisuals.visualPosition = destination;
}
Physics.SyncTransforms();
if (refreshCamera)
{
if ((Object)(object)localPlayer.localCamera != (Object)null)
{
localPlayer.localCamera.Teleported();
}
if ((Object)(object)CameraAim.Instance != (Object)null)
{
CameraAim.Instance.SetPlayerAim(rotation, true);
CameraAim.Instance.OverrideNoSmooth(0.15f);
}
if ((Object)(object)CameraPosition.instance != (Object)null)
{
((Component)CameraPosition.instance).transform.position = destination;
((Component)CameraPosition.instance).transform.rotation = rotation;
}
if ((Object)(object)localPlayer.RoomVolumeCheck != (Object)null)
{
localPlayer.RoomVolumeCheck.CheckSet();
}
}
}
[IteratorStateMachine(typeof(<TeleportStabilizeCoroutine>d__107))]
private IEnumerator TeleportStabilizeCoroutine(PlayerAvatar localPlayer, Vector3 destination, Quaternion rotation)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <TeleportStabilizeCoroutine>d__107(0)
{
<>4__this = this,
localPlayer = localPlayer,
destination = destination,
rotation = rotation
};
}
private void MarkDetectedPlayerOutline(int stableId)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
float num = ((DetectedPlayerOutlineSeconds != null) ? Mathf.Max(0f, DetectedPlayerOutlineSeconds.Value) : 0f);
if (num <= 0f)
{
detectedOutlineExpireMap.Remove(stableId);
if (outlineControllerMap.TryGetValue(stableId, out PlayerOutlineShellController value) && (Object)(object)value != (Object)null)
{
value.SetOutlineVisible(visible: false, new Color(1f, 0.84f, 0.06f, 1f));
}
}
else
{
detectedOutlineExpireMap[stableId] = Time.time + num;
}
}
private void UpdateDetectedPlayerOutlines(float now, HashSet<int> seenIds)
{
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
List<int> list = new List<int>();
foreach (KeyValuePair<int, float> item in detectedOutlineExpireMap)
{
if (item.Value <= now)
{
list.Add(item.Key);
}
}
for (int i = 0; i < list.Count; i++)
{
detectedOutlineExpireMap.Remove(list[i]);
}
Color color = default(Color);
((Color)(ref color))..ctor(1f, 0.84f, 0.06f, 1f);
foreach (KeyValuePair<int, PlayerOutlineShellController> item2 in outlineControllerMap)
{
PlayerOutlineShellController value = item2.Value;
if (!((Object)(object)value == (Object)null))
{
float value2;
bool visible = detectedOutlineExpireMap.TryGetValue(item2.Key, out value2) && value2 > now && seenIds.Contains(item2.Key);
value.SetOutlineVisible(visible, color);
}
}
foreach (KeyValuePair<int, float> item3 in detectedOutlineExpireMap)
{
if (item3.Value <= now || !seenIds.Contains(item3.Key))
{
continue;
}
PlayerAvatar val = FindPlayerByStableId(item3.Key);
if (!((Object)(object)val == (Object)null) && IsAlivePlayer(val))
{
PlayerOutlineShellController orCreateOutlineController = GetOrCreateOutlineController(val, item3.Key);
if ((Object)(object)orCreateOutlineController != (Object)null)
{
orCreateOutlineController.SetOutlineVisible(visible: true, color);
}
}
}
List<int> list2 = new List<int>();
foreach (KeyValuePair<int, PlayerOutlineShellController> item4 in outlineControllerMap)
{
if ((Object)(object)item4.Value == (Object)null)
{
list2.Add(item4.Key);
}
}
for (int j = 0; j < list2.Count; j++)
{
outlineControllerMap.Remove(list2[j]);
}
}
private PlayerOutlineShellController GetOrCreateOutlineController(PlayerAvatar player, int stableId)
{
if ((Object)(object)player == (Object)null)
{
return null;
}
if (outlineControllerMap.TryGetValue(stableId, out PlayerOutlineShellController value) && (Object)(object)value != (Object)null)
{
return value;
}
PlayerOutlineShellController playerOutlineShellController = ((Component)player).GetComponent<PlayerOutlineShellController>();
if ((Object)(object)playerOutlineShellController == (Object)null)
{
playerOutlineShellController = ((Component)player).gameObject.AddComponent<PlayerOutlineShellController>();
}
playerOutlineShellController.Initialize(player);
outlineControllerMap[stableId] = playerOutlineShellController;
return playerOutlineShellController;
}
private void DisableAllDetectedPlayerOutlines()
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
foreach (KeyValuePair<int, PlayerOutlineShellController> item in outlineControllerMap)
{
if ((Object)(object)item.Value != (Object)null)
{
item.Value.SetOutlineVisible(visible: false, new Color(1f, 0.84f, 0.06f, 1f));
}
}
detectedOutlineExpireMap.Clear();
outlineControllerMap.Clear();
}
private void ClearRunStateIfNeeded()
{
if (previousRunIsLevel)
{
trackerMap.Clear();
overlayMessages.Clear();
DisableAllDetectedPlayerOutlines();
}
previousRunIsLevel = false;
}
private int GetStablePlayerId(PlayerAvatar player)
{
PhotonView component = ((Component)player).GetComponent<PhotonView>();
if ((Object)(object)component != (Object)null && component.ViewID != 0)
{
return component.ViewID;
}
return ((Object)player).GetInstanceID();
}
private string GetPlayerName(PlayerAvatar player)
{
try
{
if (fiPlayerName != null)
{
object value = fiPlayerName.GetValue(player);
if (value is string text && !string.IsNullOrEmpty(text))
{
return text;
}
}
}
catch
{
}
return ((Object)player).name;
}
private string GetSteamId(PlayerAvatar player)
{
if (fiSteamId == null || (Object)(object)player == (Object)null)
{
return string.Empty;
}
object value = fiSteamId.GetValue(player);
return (value as string) ?? string.Empty;
}
private bool IsLocalPlayer(PlayerAvatar player)
{
if ((Object)(object)player == (Object)null)
{
return false;
}
if ((Object)(object)PlayerAvatar.instance != (Object)null && (Object)(object)player == (Object)(object)PlayerAvatar.instance)
{
return true;
}
PhotonView component = ((Component)player).GetComponent<PhotonView>();
return (Object)(object)component != (Object)null && component.IsMine;
}
private bool IsAlivePlayer(PlayerAvatar player)
{
if ((Object)(object)player == (Object)null)
{
return false;
}
if (fiDeadSet == null)
{
return true;
}
object value = fiDeadSet.GetValue(player);
bool flag = default(bool);
int num;
if (value is bool)
{
flag = (bool)value;
num = 1;
}
else
{
num = 0;
}
return ((uint)num & (flag ? 1u : 0u)) == 0;
}
private bool GetBool(FieldInfo fieldInfo, object instance)
{
if (fieldInfo == null || instance == null)
{
return false;
}
object value = fieldInfo.GetValue(instance);
bool flag = default(bool);
int num;
if (value is bool)
{
flag = (bool)value;
num = 1;
}
else
{
num = 0;
}
return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
}
private Vector3 GetVelocity(PlayerAvatar player)
{
//IL_007e: 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_0026: 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_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
if (fiRbVelocityRaw != null && fiRbVelocityRaw.GetValue(player) is Vector3 result)
{
return result;
}
if (fiRbVelocity != null && fiRbVelocity.GetValue(player) is Vector3 result2)
{
return result2;
}
return Vector3.zero;
}
private int GetUpgradeValue(Dictionary<string, int> dictionary, string steamId)
{
if (dictionary == null || string.IsNullOrEmpty(steamId))
{
return 0;
}
if (dictionary.TryGetValue(steamId, out var value))
{
return value;
}
return 0;
}
private void TryApplyJapaneseFromAutoTranslator()
{
if (autoTranslatorChecked || Time.realtimeSinceStartup < autoTranslatorCheckTime)
{
return;
}
autoTranslatorChecked = true;
try
{
string path = Path.Combine(Paths.ConfigPath, "AutoTranslatorConfig.ini");
if (!File.Exists(path))
{
return;
}
string[] array = File.ReadAllLines(path);
foreach (string text in array)
{
if (string.IsNullOrWhiteSpace(text))
{
continue;
}
string text2 = text.Trim();
if (text2.StartsWith("Language=", StringComparison.OrdinalIgnoreCase))
{
string a = text2.Substring("Language=".Length).Trim();
if (string.Equals(a, "ja", StringComparison.OrdinalIgnoreCase) && !string.Equals(LanguageSetting.Value, "Japanese", StringComparison.OrdinalIgnoreCase))
{
LanguageSetting.Value = "Japanese";
((BaseUnityPlugin)this).Config.Save();
LogInfo(GetLocalizedText("AutoTranslatorJapaneseApplied"));
}
break;
}
}
}
catch (Exception ex)
{
DebugLog("AutoTranslator language check failed / AutoTranslator の言語確認に失敗\n" + ex);
}
}
private static string GetNormalizedLanguage()
{
string text = ((LanguageSetting != null) ? (LanguageSetting.Value ?? string.Empty) : string.Empty);
if (text.Equals("Japanese", StringComparison.OrdinalIgnoreCase))
{
return "ja";
}
if (text.Equals("Korean", StringComparison.OrdinalIgnoreCase))
{
return "ko";
}
if (text.Equals("Chinese", StringComparison.OrdinalIgnoreCase))
{
return "zh";
}
if (text.Equals("Russian", StringComparison.OrdinalIgnoreCase))
{
return "ru";
}
return "en";
}
private static string GetLocalizedText(string key)
{
string normalizedLanguage = GetNormalizedLanguage();
return key switch
{
"Loaded" => normalizedLanguage switch
{
"ja" => "読み込み完了",
"ko" => "로드 완료",
"zh" => "加载完成",
"ru" => "Загрузка завершена",
_ => "Loaded",
},
"AutoTranslatorJapaneseApplied" => normalizedLanguage switch
{
"ja" => "AutoTranslatorConfig.ini を検出したため、MOD言語設定を日本語へ自動変更しました",
"ko" => "AutoTranslatorConfig.ini가 감지되어 MOD 언어 설정이 일본어로 자동 변경되었습니다",
"zh" => "检测到 AutoTranslatorConfig.ini,MOD 语言已自动切换为日语",
"ru" => "Обнаружен AutoTranslatorConfig.ini, язык мода автоматически переключен на японский",
_ => "AutoTranslatorConfig.ini detected. MOD language setting was automatically changed to Japanese",
},
"WarningFormat" => normalizedLanguage switch
{
"ja" => "[チート検出] 無限スタミナ {0} STA {1} SPD {2} 回数 {3}",
"ko" => "[치트 감지] 무한 스태미나 {0} STA {1} SPD {2} 횟수 {3}",
"zh" => "[作弊检测] 无限体力 {0} STA {1} SPD {2} 次数 {3}",
"ru" => "[Обнаружение чита] Бесконечная выносливость {0} STA {1} SPD {2} Кол-во {3}",
_ => "[Cheat Detected] Infinite Stamina {0} STA {1} SPD {2} Count {3}",
},
"TeleportHint" => normalizedLanguage switch
{
"ja" => "{0}キーでTP",
"ko" => "{0} 키로 TP",
"zh" => "按 {0} 键传送",
"ru" => "TP на {0}",
_ => "{0} to TP",
},
_ => key,
};
}
internal static void LogInfo(string message)
{
if (LogSource != null)
{
LogSource.LogInfo((object)message);
}
}
internal static void DebugLog(string message)
{
if (EnableDebugLog != null && EnableDebugLog.Value && LogSource != null)
{
LogSource.LogInfo((object)message);
}
}
}