using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.SceneManagement;
[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("zabu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("zabumod")]
[assembly: AssemblyTitle("zabumod")]
[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;
}
}
}
namespace REPOJP.DefaultUpgrade
{
[BepInPlugin("REPOJP.DefaultUpgrade", "DefaultUpgrade", "1.0.0")]
public sealed class DefaultUpgradePlugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <CoNewJoinSync>d__37 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlayerAvatar playerAvatar;
private float <timeout>5__1;
private float <elapsed>5__2;
private string <sceneSignature>5__3;
private string <processKey>5__4;
private string <playerName>5__5;
private bool <changed>5__6;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CoNewJoinSync>d__37(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<sceneSignature>5__3 = null;
<processKey>5__4 = null;
<playerName>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
WriteInfo("New Join Sync 待機開始");
<timeout>5__1 = 10f;
<elapsed>5__2 = 0f;
break;
case 1:
<>1__state = -1;
break;
}
if (<elapsed>5__2 < <timeout>5__1)
{
if ((Object)(object)playerAvatar == (Object)null)
{
WriteWarning("New Join Sync 中断: PlayerAvatar null");
return false;
}
if (string.IsNullOrEmpty(playerAvatar.steamID))
{
<elapsed>5__2 += 0.1f;
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 1;
return true;
}
}
if ((Object)(object)playerAvatar == (Object)null)
{
WriteWarning("New Join Sync 中断: PlayerAvatar null");
return false;
}
if (string.IsNullOrEmpty(playerAvatar.steamID))
{
WriteWarning("New Join Sync 中断: steamID 未取得 timeout");
return false;
}
<sceneSignature>5__3 = GetCurrentLevelSignature();
<processKey>5__4 = <sceneSignature>5__3 + "|" + playerAvatar.steamID;
if (processedJoinSyncKeys.Contains(<processKey>5__4))
{
WriteInfo("New Join Sync 重複スキップ: " + <processKey>5__4);
return false;
}
processedJoinSyncKeys.Add(<processKey>5__4);
<playerName>5__5 = (string.IsNullOrEmpty(playerAvatar.playerName) ? ((Object)playerAvatar).name : playerAvatar.playerName);
<changed>5__6 = ApplyMissingUpgradesToPlayer(playerAvatar.steamID, <playerName>5__5, "NewJoinSync");
if (<changed>5__6)
{
SemiFunc.StatSyncAll();
WriteInfo("New Join Sync 完了: " + <playerName>5__5 + " / 同期実行");
}
else
{
WriteInfo("New Join Sync 完了: " + <playerName>5__5 + " / 変更なし");
}
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();
}
}
public const string PluginGuid = "REPOJP.DefaultUpgrade";
public const string PluginName = "DefaultUpgrade";
public const string PluginVersion = "1.0.0";
internal static DefaultUpgradePlugin Instance;
internal static ManualLogSource Log;
private Harmony harmony;
internal static ConfigEntry<bool> CfgEnableMod;
internal static ConfigEntry<bool> CfgNewJoinSync;
internal static ConfigEntry<int> CfgHealth;
internal static ConfigEntry<int> CfgStamina;
internal static ConfigEntry<int> CfgExtraJump;
internal static ConfigEntry<int> CfgLaunch;
internal static ConfigEntry<int> CfgTumbleClimb;
internal static ConfigEntry<int> CfgMapPlayerCount;
internal static ConfigEntry<int> CfgDeathHeadBattery;
internal static ConfigEntry<int> CfgSpeed;
internal static ConfigEntry<int> CfgStrength;
internal static ConfigEntry<int> CfgThrow;
internal static ConfigEntry<int> CfgRange;
internal static ConfigEntry<int> CfgCrouchRest;
internal static ConfigEntry<int> CfgTumbleWings;
internal static ConfigEntry<bool> CfgEnableLog;
private static string lastAppliedLevelSignature = string.Empty;
private static readonly HashSet<string> processedJoinSyncKeys = new HashSet<string>();
private void Awake()
{
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Expected O, but got Unknown
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Expected O, but got Unknown
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Expected O, but got Unknown
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Expected O, but got Unknown
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Expected O, but got Unknown
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Expected O, but got Unknown
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Expected O, but got Unknown
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Expected O, but got Unknown
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Expected O, but got Unknown
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Expected O, but got Unknown
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Expected O, but got Unknown
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Expected O, but got Unknown
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
((Component)this).transform.parent = null;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
CfgEnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("A General", "EnableMod", true, "このMODの有効無効");
CfgNewJoinSync = ((BaseUnityPlugin)this).Config.Bind<bool>("A General", "NewJoinSync", true, "途中参加者に不足分だけ同期付与");
CfgHealth = ((BaseUnityPlugin)this).Config.Bind<int>("B Upgrades", "Health", 1, new ConfigDescription("ヘルスアップグレード初期値", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>()));
CfgStamina = ((BaseUnityPlugin)this).Config.Bind<int>("B Upgrades", "Stamina", 1, new ConfigDescription("スタミナアップグレード初期値", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>()));
CfgExtraJump = ((BaseUnityPlugin)this).Config.Bind<int>("B Upgrades", "ExtraJump", 1, new ConfigDescription("ジャンプアップグレード初期値", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>()));
CfgLaunch = ((BaseUnityPlugin)this).Config.Bind<int>("B Upgrades", "Launch", 1, new ConfigDescription("打ち上げアップグレード初期値", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>()));
CfgTumbleClimb = ((BaseUnityPlugin)this).Config.Bind<int>("B Upgrades", "TumbleClimb", 1, new ConfigDescription("よじ登りアップグレード初期値", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>()));
CfgMapPlayerCount = ((BaseUnityPlugin)this).Config.Bind<int>("B Upgrades", "MapPlayerCount", 1, new ConfigDescription("プレイヤーカウントアップグレード初期値", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>()));
CfgDeathHeadBattery = ((BaseUnityPlugin)this).Config.Bind<int>("B Upgrades", "DeathHeadBattery", 1, new ConfigDescription("デスヘッドバッテリーアップグレード初期値", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>()));
CfgSpeed = ((BaseUnityPlugin)this).Config.Bind<int>("B Upgrades", "Speed", 1, new ConfigDescription("スピードアップグレード初期値", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>()));
CfgStrength = ((BaseUnityPlugin)this).Config.Bind<int>("B Upgrades", "Strength", 1, new ConfigDescription("筋力アップグレード初期値", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>()));
CfgThrow = ((BaseUnityPlugin)this).Config.Bind<int>("B Upgrades", "Throw", 1, new ConfigDescription("投擲力アップグレード初期値", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>()));
CfgRange = ((BaseUnityPlugin)this).Config.Bind<int>("B Upgrades", "Range", 1, new ConfigDescription("掴み範囲アップグレード初期値", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>()));
CfgCrouchRest = ((BaseUnityPlugin)this).Config.Bind<int>("B Upgrades", "CrouchRest", 1, new ConfigDescription("しゃがみ回復アップグレード初期値", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>()));
CfgTumbleWings = ((BaseUnityPlugin)this).Config.Bind<int>("B Upgrades", "TumbleWings", 1, new ConfigDescription("羽アップグレード初期値", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>()));
CfgEnableLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Z Debug", "EnableLog", true, "ログ出力有効無効");
harmony = new Harmony("REPOJP.DefaultUpgrade");
harmony.PatchAll();
WriteInfo("Loaded DefaultUpgrade v1.0.0");
}
private void OnDestroy()
{
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
internal static void WriteInfo(string message)
{
if (Log != null && (CfgEnableLog == null || CfgEnableLog.Value))
{
Log.LogInfo((object)message);
}
}
internal static void WriteWarning(string message)
{
if (Log != null && (CfgEnableLog == null || CfgEnableLog.Value))
{
Log.LogWarning((object)message);
}
}
internal static void WriteError(string message)
{
if (Log != null && (CfgEnableLog == null || CfgEnableLog.Value))
{
Log.LogError((object)message);
}
}
internal static void WriteException(string title, Exception ex)
{
if (Log != null && (CfgEnableLog == null || CfgEnableLog.Value))
{
Log.LogError((object)(title + "\n" + ex));
}
}
internal static bool IsModEnabled()
{
return CfgEnableMod != null && CfgEnableMod.Value;
}
internal static bool IsHostOrSingle()
{
return SemiFunc.IsMasterClientOrSingleplayer();
}
internal static bool IsTargetGameplayScene()
{
return SemiFunc.RunIsLevel() || SemiFunc.RunIsArena() || SemiFunc.RunIsTutorial();
}
internal static string GetCurrentLevelSignature()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
string name = ((Scene)(ref activeScene)).name;
return name + "|" + (Object.op_Implicit((Object)(object)RunManager.instance) ? RunManager.instance.levelsCompleted : (-1));
}
internal static List<UpgradeEntry> GetUpgradeEntries()
{
StatsManager statsManager = StatsManager.instance;
return new List<UpgradeEntry>
{
new UpgradeEntry("Health", CfgHealth, () => statsManager.playerUpgradeHealth),
new UpgradeEntry("Stamina", CfgStamina, () => statsManager.playerUpgradeStamina),
new UpgradeEntry("ExtraJump", CfgExtraJump, () => statsManager.playerUpgradeExtraJump),
new UpgradeEntry("Launch", CfgLaunch, () => statsManager.playerUpgradeLaunch),
new UpgradeEntry("TumbleClimb", CfgTumbleClimb, () => statsManager.playerUpgradeTumbleClimb),
new UpgradeEntry("MapPlayerCount", CfgMapPlayerCount, () => statsManager.playerUpgradeMapPlayerCount),
new UpgradeEntry("DeathHeadBattery", CfgDeathHeadBattery, () => statsManager.playerUpgradeDeathHeadBattery),
new UpgradeEntry("Speed", CfgSpeed, () => statsManager.playerUpgradeSpeed),
new UpgradeEntry("Strength", CfgStrength, () => statsManager.playerUpgradeStrength),
new UpgradeEntry("Throw", CfgThrow, () => statsManager.playerUpgradeThrow),
new UpgradeEntry("Range", CfgRange, () => statsManager.playerUpgradeRange),
new UpgradeEntry("CrouchRest", CfgCrouchRest, () => statsManager.playerUpgradeCrouchRest),
new UpgradeEntry("TumbleWings", CfgTumbleWings, () => statsManager.playerUpgradeTumbleWings)
};
}
internal static void ApplyStartingUpgradesForCurrentLevel()
{
if (!IsModEnabled() || !IsHostOrSingle() || !IsTargetGameplayScene())
{
return;
}
if ((Object)(object)StatsManager.instance == (Object)null)
{
WriteWarning("StatsManager.instance が null のため開始時付与を中止");
return;
}
string currentLevelSignature = GetCurrentLevelSignature();
if (lastAppliedLevelSignature == currentLevelSignature)
{
WriteInfo("同一レベルへの二重適用をスキップ: " + currentLevelSignature);
return;
}
List<PlayerAvatar> list = SemiFunc.PlayerGetList();
if (list == null || list.Count == 0)
{
WriteWarning("プレイヤー一覧が空のため開始時付与を中止");
return;
}
WriteInfo("開始時アップグレード付与開始: " + currentLevelSignature + " / playerCount=" + list.Count);
bool flag = false;
int num = 0;
foreach (PlayerAvatar item in list)
{
if (!((Object)(object)item == (Object)null))
{
string steamID = item.steamID;
string text = (string.IsNullOrEmpty(item.playerName) ? ((Object)item).name : item.playerName);
if (string.IsNullOrEmpty(steamID))
{
WriteWarning("steamID 未取得プレイヤーをスキップ: " + text);
}
else if (ApplyMissingUpgradesToPlayer(steamID, text, "LevelStart"))
{
flag = true;
num++;
}
}
}
if (flag)
{
SemiFunc.StatSyncAll();
WriteInfo("開始時アップグレード付与完了 / changedPlayers=" + num + " / 同期実行");
}
else
{
WriteInfo("開始時アップグレード付与完了 / 変更なし");
}
lastAppliedLevelSignature = currentLevelSignature;
processedJoinSyncKeys.Clear();
}
internal static void StartNewJoinSync(PlayerAvatar playerAvatar)
{
if (IsModEnabled() && CfgNewJoinSync.Value && IsHostOrSingle() && IsTargetGameplayScene() && !((Object)(object)LevelGenerator.Instance == (Object)null) && LevelGenerator.Instance.Generated && !((Object)(object)Instance == (Object)null) && !((Object)(object)playerAvatar == (Object)null))
{
((MonoBehaviour)Instance).StartCoroutine(CoNewJoinSync(playerAvatar));
}
}
[IteratorStateMachine(typeof(<CoNewJoinSync>d__37))]
private static IEnumerator CoNewJoinSync(PlayerAvatar playerAvatar)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CoNewJoinSync>d__37(0)
{
playerAvatar = playerAvatar
};
}
internal static bool ApplyMissingUpgradesToPlayer(string steamId, string playerName, string reason)
{
if (string.IsNullOrEmpty(steamId))
{
return false;
}
StatsManager instance = StatsManager.instance;
if ((Object)(object)instance == (Object)null)
{
return false;
}
List<UpgradeEntry> upgradeEntries = GetUpgradeEntries();
bool result = false;
WriteInfo("アップグレード確認開始: " + reason + " / player=" + playerName + " / steamId=" + steamId);
foreach (UpgradeEntry item in upgradeEntries)
{
int num = Mathf.Clamp(item.Target.Value, 0, 50);
Dictionary<string, int> dictionary = item.DictionaryGetter();
if (!dictionary.ContainsKey(steamId))
{
dictionary[steamId] = 0;
}
int num2 = dictionary[steamId];
int num3 = num - num2;
if (num3 > 0)
{
dictionary[steamId] = num2 + num3;
result = true;
WriteInfo("適用: player=" + playerName + " / upgrade=" + item.Name + " / current=" + num2 + " / target=" + num + " / add=" + num3 + " / result=" + dictionary[steamId]);
}
else
{
WriteInfo("スキップ: player=" + playerName + " / upgrade=" + item.Name + " / current=" + num2 + " / target=" + num);
}
}
return result;
}
}
internal sealed class UpgradeEntry
{
public string Name;
public ConfigEntry<int> Target;
public Func<Dictionary<string, int>> DictionaryGetter;
public UpgradeEntry(string name, ConfigEntry<int> target, Func<Dictionary<string, int>> dictionaryGetter)
{
Name = name;
Target = target;
DictionaryGetter = dictionaryGetter;
}
}
[HarmonyPatch(typeof(LevelGenerator), "GenerateDone")]
internal static class LevelGenerator_GenerateDone_Patch
{
private static void Postfix()
{
try
{
DefaultUpgradePlugin.ApplyStartingUpgradesForCurrentLevel();
}
catch (Exception ex)
{
DefaultUpgradePlugin.WriteException("GenerateDone Postfix 失敗", ex);
}
}
}
[HarmonyPatch(typeof(PlayerAvatar), "Awake")]
internal static class PlayerAvatar_Awake_Patch
{
private static void Postfix(PlayerAvatar __instance)
{
try
{
DefaultUpgradePlugin.StartNewJoinSync(__instance);
}
catch (Exception ex)
{
DefaultUpgradePlugin.WriteException("PlayerAvatar Awake Postfix 失敗", ex);
}
}
}
[HarmonyPatch(typeof(NetworkManager), "OnPlayerEnteredRoom")]
internal static class NetworkManager_OnPlayerEnteredRoom_Patch
{
private static void Postfix(Player newPlayer)
{
try
{
if (newPlayer != null)
{
DefaultUpgradePlugin.WriteInfo("プレイヤー参加検知: actor=" + newPlayer.ActorNumber + " / name=" + newPlayer.NickName + " / NewJoinSync=" + DefaultUpgradePlugin.CfgNewJoinSync.Value);
}
}
catch (Exception ex)
{
DefaultUpgradePlugin.WriteException("OnPlayerEnteredRoom Postfix 失敗", ex);
}
}
}
}