using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using com.github.zehsteam.Supercharger.Data;
using com.github.zehsteam.Supercharger.Dependencies;
using com.github.zehsteam.Supercharger.Helpers;
using com.github.zehsteam.Supercharger.MonoBehaviours;
using com.github.zehsteam.Supercharger.NetcodePatcher;
using com.github.zehsteam.Supercharger.Patches;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.zehsteam.Supercharger")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+504275a765f390fa9979735f9c7c8b30b301447b")]
[assembly: AssemblyProduct("Supercharger")]
[assembly: AssemblyTitle("com.github.zehsteam.Supercharger")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace com.github.zehsteam.Supercharger
{
public class ConfigManager
{
public ConfigEntry<bool> ExtendedLogging { get; private set; }
public SyncedConfigEntry<float> Supercharger_Chance { get; private set; }
public SyncedConfigEntry<int> Supercharger_ItemChargeAmount { get; private set; }
public ConfigEntry<bool> Supercharger_FlickerShipLights { get; private set; }
public SyncedConfigEntry<bool> Supercharger_OnlyWhenFullyCharged { get; private set; }
public SyncedConfigEntry<bool> Supercharger_EnableInOrbit { get; private set; }
public SyncedConfigEntry<float> Explosion_Chance { get; private set; }
public SyncedConfigEntry<float> Explosion_Range { get; private set; }
public SyncedConfigEntry<int> Explosion_Damage { get; private set; }
public SyncedConfigEntry<int> Explosion_EnemyDamage { get; private set; }
public SyncedConfigEntry<bool> Explosion_TurnsOffShipLights { get; private set; }
public ConfigManager()
{
BindConfigs();
ConfigHelper.ClearUnusedEntries();
}
private void BindConfigs()
{
ConfigHelper.SkipAutoGen();
ExtendedLogging = ConfigHelper.Bind("General", "ExtendedLogging", defaultValue: false, requiresRestart: false, "Enable extended logging.");
Supercharger_Chance = new SyncedConfigEntry<float>("Supercharger", "Chance", 45f, "The percent chance the ship's charging station will supercharge your item.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f));
Supercharger_ItemChargeAmount = new SyncedConfigEntry<int>("Supercharger", "ItemChargeAmount", 200, "The amount of charge an item will receive after being supercharged.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(100, 1000));
Supercharger_FlickerShipLights = ConfigHelper.Bind("Supercharger", "FlickerShipLights", defaultValue: true, requiresRestart: false, "If enabled, the ship's lights will flicker during a supercharge.");
Supercharger_OnlyWhenFullyCharged = new SyncedConfigEntry<bool>("Supercharger", "OnlyWhenFullyCharged", defaultValue: false, "If enabled, the ship's charging station will only be able to supercharge when the item has a battery charge of 100 or more.");
Supercharger_EnableInOrbit = new SyncedConfigEntry<bool>("Supercharger", "EnableInOrbit", defaultValue: false, "If enabled, the ship's charging station will be able to supercharge while in orbit.");
Explosion_Chance = new SyncedConfigEntry<float>("Explosion", "Chance", 30f, "The percent chance your item will explode from supercharging.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f));
Explosion_Range = new SyncedConfigEntry<float>("Explosion", "Range", 4f, "The range of the explosion in meters.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 8f));
Explosion_Damage = new SyncedConfigEntry<int>("Explosion", "Damage", 40, "The amount of damage you will receive from an explosion.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000));
Explosion_EnemyDamage = new SyncedConfigEntry<int>("Explosion", "EnemyDamage", 2, "The amount of damage enemies will receive from an explosion.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
Explosion_TurnsOffShipLights = new SyncedConfigEntry<bool>("Explosion", "TurnsOffShipLights", defaultValue: true, "If enabled, the ship's lights will turn off after an explosion.");
}
}
internal class Content
{
public static GameObject NetworkHandlerPrefab { get; private set; }
public static GameObject SuperchargeStationPrefab { get; private set; }
public static void Load()
{
LoadAssetsFromAssetBundle();
}
private static void LoadAssetsFromAssetBundle()
{
AssetBundle val = LoadAssetBundle("supercharger_assets");
if (!((Object)(object)val == (Object)null))
{
NetworkHandlerPrefab = LoadAssetFromAssetBundle<GameObject>("NetworkHandler", val);
NetworkHandlerPrefab.AddComponent<PluginNetworkBehaviour>();
SuperchargeStationPrefab = LoadAssetFromAssetBundle<GameObject>("SuperchargeStation", val);
Plugin.Logger.LogInfo((object)"Successfully loaded assets from AssetBundle!");
}
}
private static AssetBundle LoadAssetBundle(string fileName)
{
try
{
string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
string text = Path.Combine(directoryName, fileName);
return AssetBundle.LoadFromFile(text);
}
catch (Exception arg)
{
Plugin.Logger.LogError((object)$"Failed to load AssetBundle \"{fileName}\". {arg}");
}
return null;
}
private static T LoadAssetFromAssetBundle<T>(string name, AssetBundle assetBundle) where T : Object
{
if (string.IsNullOrWhiteSpace(name))
{
Plugin.Logger.LogError((object)("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace."));
return default(T);
}
if ((Object)(object)assetBundle == (Object)null)
{
Plugin.Logger.LogError((object)("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null."));
return default(T);
}
T val = assetBundle.LoadAsset<T>(name);
if ((Object)(object)val == (Object)null)
{
Plugin.Logger.LogError((object)("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name."));
return default(T);
}
return val;
}
}
internal static class NetworkUtils
{
public static bool IsConnected
{
get
{
if ((Object)(object)NetworkManager.Singleton == (Object)null)
{
return false;
}
return NetworkManager.Singleton.IsConnectedClient;
}
}
public static bool IsServer
{
get
{
if ((Object)(object)NetworkManager.Singleton == (Object)null)
{
return false;
}
return NetworkManager.Singleton.IsServer;
}
}
public static bool IsHost
{
get
{
if ((Object)(object)NetworkManager.Singleton == (Object)null)
{
return false;
}
return NetworkManager.Singleton.IsHost;
}
}
public static ulong GetLocalClientId()
{
return NetworkManager.Singleton.LocalClientId;
}
public static bool IsLocalClientId(ulong clientId)
{
return clientId == GetLocalClientId();
}
public static bool IsNetworkPrefab(GameObject prefab)
{
foreach (NetworkPrefab prefab2 in NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs)
{
if ((Object)(object)prefab2.Prefab == (Object)(object)prefab)
{
return true;
}
}
return false;
}
}
internal class PlayerUtils
{
public static PlayerControllerB GetLocalPlayerScript()
{
if ((Object)(object)GameNetworkManager.Instance == (Object)null)
{
return null;
}
return GameNetworkManager.Instance.localPlayerController;
}
public static bool IsLocalPlayer(PlayerControllerB playerScript)
{
return (Object)(object)playerScript == (Object)(object)GetLocalPlayerScript();
}
public static PlayerControllerB GetPlayerScriptByClientId(ulong clientId)
{
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
if (val.actualClientId == clientId)
{
return val;
}
}
return null;
}
}
[BepInPlugin("com.github.zehsteam.Supercharger", "Supercharger", "1.2.0")]
internal class Plugin : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("com.github.zehsteam.Supercharger");
internal static Plugin Instance;
internal static ManualLogSource Logger;
internal static ConfigManager ConfigManager;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
Logger = Logger.CreateLogSource("com.github.zehsteam.Supercharger");
Logger.LogInfo((object)"Supercharger has awoken!");
_harmony.PatchAll(typeof(GameNetworkManagerPatch));
_harmony.PatchAll(typeof(StartOfRoundPatch));
_harmony.PatchAll(typeof(InteractTriggerPatch));
_harmony.PatchAll(typeof(ItemChargerPatch));
ConfigManager = new ConfigManager();
Content.Load();
NetcodePatcherAwake();
}
private void NetcodePatcherAwake()
{
try
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
Type[] types = executingAssembly.GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
try
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
try
{
methodInfo.Invoke(null, null);
}
catch (TargetInvocationException ex)
{
Logger.LogWarning((object)("Failed to invoke method " + methodInfo.Name + ": " + ex.Message));
}
}
}
catch (Exception ex2)
{
Logger.LogWarning((object)("Error processing method " + methodInfo.Name + " in type " + type.Name + ": " + ex2.Message));
}
}
}
}
catch (Exception ex3)
{
Logger.LogError((object)("An error occurred in NetcodePatcherAwake: " + ex3.Message));
}
}
public void LogInfoExtended(object data)
{
LogExtended((LogLevel)16, data);
}
public void LogExtended(LogLevel level, object data)
{
//IL_0022: 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)
if (ConfigManager == null || ConfigManager.ExtendedLogging == null)
{
Logger.Log(level, data);
}
else if (ConfigManager.ExtendedLogging.Value)
{
Logger.Log(level, data);
}
}
}
internal class Utils
{
public static bool RandomPercent(float percent)
{
if (percent <= 0f)
{
return false;
}
if (percent >= 100f)
{
return true;
}
return Random.value * 100f <= percent;
}
public static void LogAnimatorParameters(Animator animator)
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Invalid comparison between Unknown and I4
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Expected I4, but got Unknown
StringBuilder stringBuilder = new StringBuilder();
int length = (from _ in animator.parameters
select _.name into _
orderby _.Length descending
select _).First().Length;
AnimatorControllerParameter[] parameters = animator.parameters;
foreach (AnimatorControllerParameter val in parameters)
{
if ((int)val.type != 9)
{
stringBuilder.AppendLine(("\"" + val.name + "\", ").PadRight(length + 3));
AnimatorControllerParameterType type = val.type;
AnimatorControllerParameterType val2 = type;
switch (val2 - 1)
{
case 0:
stringBuilder.AppendLine($"Float: {animator.GetFloat(val.name)}");
break;
case 2:
stringBuilder.AppendLine($"Int: {animator.GetInteger(val.name)}");
break;
case 3:
stringBuilder.AppendLine($"Bool: {animator.GetBool(val.name)}");
break;
}
}
}
Plugin.Instance.LogInfoExtended("\n\n" + stringBuilder.ToString() + "\n");
}
public static bool TryParseValue<T>(string value, out T result)
{
try
{
if (typeof(T) == typeof(int) && int.TryParse(value, out var result2))
{
result = (T)(object)result2;
return true;
}
if (typeof(T) == typeof(float) && float.TryParse(value, out var result3))
{
result = (T)(object)result3;
return true;
}
if (typeof(T) == typeof(double) && double.TryParse(value, out var result4))
{
result = (T)(object)result4;
return true;
}
if (typeof(T) == typeof(bool) && bool.TryParse(value, out var result5))
{
result = (T)(object)result5;
return true;
}
if (typeof(T) == typeof(string))
{
result = (T)(object)value;
return true;
}
}
catch
{
}
result = default(T);
return false;
}
public static void CreateExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, int damage = 20, float minDamageRange = 0f, float maxDamageRange = 1f, int enemyHitForce = 6, CauseOfDeath causeOfDeath = 3, PlayerControllerB attacker = null)
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: 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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: 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_0129: 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_03b2: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_031f: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
Transform val = null;
if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer.transform != (Object)null)
{
val = RoundManager.Instance.mapPropsContainer.transform;
}
if (spawnExplosionEffect)
{
Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, explosionPosition, Quaternion.Euler(-90f, 0f, 0f), val).SetActive(true);
}
float num = Vector3.Distance(((Component)PlayerUtils.GetLocalPlayerScript()).transform.position, explosionPosition);
if (num < 14f)
{
HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
}
else if (num < 25f)
{
HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
}
Collider[] array = Physics.OverlapSphere(explosionPosition, maxDamageRange, 2621448, (QueryTriggerInteraction)2);
PlayerControllerB val2 = null;
Rigidbody val4 = default(Rigidbody);
for (int i = 0; i < array.Length; i++)
{
float num2 = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
if (num2 > 4f && Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1))
{
continue;
}
Vector3 val3;
if (((Component)array[i]).gameObject.layer == 3)
{
val2 = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)val2 != (Object)null && ((NetworkBehaviour)val2).IsOwner)
{
float num3 = 1f - Mathf.Clamp01((num2 - minDamageRange) / (maxDamageRange - minDamageRange));
val3 = ((Component)val2).transform.position - explosionPosition;
Vector3 normalized = ((Vector3)(ref val3)).normalized;
if (((Component)val2).TryGetComponent<Rigidbody>(ref val4))
{
val4.AddForce(normalized * 500f);
}
Vector3 val5 = Vector3.Normalize((((Component)val2).transform.position + Vector3.up * 0.75f - explosionPosition) * 100f) * 30f;
val2.DamagePlayer((int)((float)damage * num3), true, true, causeOfDeath, 0, false, val5);
}
}
else if (((Component)array[i]).gameObject.layer == 21)
{
Landmine componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<Landmine>();
if ((Object)(object)componentInChildren != (Object)null && !componentInChildren.hasExploded && num2 < 6f)
{
Plugin.Instance.LogInfoExtended("Setting off other mine");
((MonoBehaviour)componentInChildren).StartCoroutine(componentInChildren.TriggerOtherMineDelayed(componentInChildren));
}
}
else if (((Component)array[i]).gameObject.layer == 19)
{
EnemyAICollisionDetect componentInChildren2 = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
if ((Object)(object)componentInChildren2 != (Object)null && ((NetworkBehaviour)componentInChildren2.mainScript).IsOwner && num2 < 4.5f)
{
EnemyAI mainScript = componentInChildren2.mainScript;
val3 = default(Vector3);
mainScript.HitEnemyOnLocalClient(enemyHitForce, val3, attacker, false, -1);
componentInChildren2.mainScript.HitFromExplosion(num2);
}
}
}
int num4 = ~LayerMask.GetMask(new string[1] { "Room" });
num4 = ~LayerMask.GetMask(new string[1] { "Colliders" });
array = Physics.OverlapSphere(explosionPosition, 10f, num4);
Rigidbody val6 = default(Rigidbody);
for (int j = 0; j < array.Length; j++)
{
if (((Component)array[j]).TryGetComponent<Rigidbody>(ref val6))
{
val6.AddExplosionForce(70f, explosionPosition, 10f);
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.github.zehsteam.Supercharger";
public const string PLUGIN_NAME = "Supercharger";
public const string PLUGIN_VERSION = "1.2.0";
}
}
namespace com.github.zehsteam.Supercharger.Patches
{
[HarmonyPatch(typeof(GameNetworkManager))]
internal static class GameNetworkManagerPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch()
{
AddNetworkPrefabs();
}
private static void AddNetworkPrefabs()
{
AddNetworkPrefab(Content.NetworkHandlerPrefab);
}
private static void AddNetworkPrefab(GameObject prefab)
{
if ((Object)(object)prefab == (Object)null)
{
Plugin.Logger.LogError((object)"Failed to register network prefab. GameObject is null.");
return;
}
NetworkManager.Singleton.AddNetworkPrefab(prefab);
Plugin.Logger.LogInfo((object)("Registered \"" + ((Object)prefab).name + "\" network prefab."));
}
}
[HarmonyPatch(typeof(InteractTrigger))]
internal static class InteractTriggerPatch
{
[HarmonyPatch("specialInteractAnimation")]
[HarmonyPostfix]
private static void specialInteractAnimationPatch(InteractTrigger __instance)
{
if (TryGetSuperchargeStationBehaviour(__instance, out var superchargeStationBehaviour) && ShipHelper.IsShipSupercharger(superchargeStationBehaviour))
{
superchargeStationBehaviour.TrySuperchargeNext();
}
}
private static bool TryGetSuperchargeStationBehaviour(InteractTrigger interactTrigger, out SuperchargeStationBehaviour superchargeStationBehaviour)
{
superchargeStationBehaviour = null;
ItemCharger val = default(ItemCharger);
if (!((Component)interactTrigger).TryGetComponent<ItemCharger>(ref val))
{
return false;
}
superchargeStationBehaviour = ((Component)val.chargeStationAnimator).GetComponentInChildren<SuperchargeStationBehaviour>();
return (Object)(object)superchargeStationBehaviour != (Object)null;
}
}
[HarmonyPatch(typeof(ItemCharger))]
internal static class ItemChargerPatch
{
[HarmonyPatch("__initializeVariables")]
[HarmonyPostfix]
private static void __initializeVariablesPatch(ItemCharger __instance)
{
//IL_0006: 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)
Object.Instantiate<GameObject>(Content.SuperchargeStationPrefab, Vector3.zero, Quaternion.identity, ((Component)__instance.chargeStationAnimator).transform);
}
[HarmonyPatch("ChargeItem")]
[HarmonyPrefix]
private static bool ChargeItemPatch(ref ItemCharger __instance, ref Coroutine ___chargeItemCoroutine)
{
SuperchargeStationBehaviour superchargeStationBehaviour = null;
try
{
superchargeStationBehaviour = ((Component)((Component)__instance).transform.parent.parent).GetComponentInChildren<SuperchargeStationBehaviour>();
}
catch
{
}
if ((Object)(object)superchargeStationBehaviour == (Object)null)
{
return true;
}
if (!ShipHelper.IsShipSupercharger(superchargeStationBehaviour))
{
return true;
}
if (!superchargeStationBehaviour.SuperchargeNext)
{
superchargeStationBehaviour.SetOriginalChargeStationValues();
return true;
}
PlayerControllerB localPlayerScript = PlayerUtils.GetLocalPlayerScript();
if ((Object)(object)localPlayerScript == (Object)null)
{
return true;
}
GrabbableObject currentlyHeldObjectServer = localPlayerScript.currentlyHeldObjectServer;
if ((Object)(object)currentlyHeldObjectServer == (Object)null)
{
return true;
}
if (!currentlyHeldObjectServer.itemProperties.requiresBattery)
{
return true;
}
if (___chargeItemCoroutine != null)
{
((MonoBehaviour)__instance).StopCoroutine(___chargeItemCoroutine);
}
superchargeStationBehaviour.SuperchargeItem(currentlyHeldObjectServer, localPlayerScript);
return false;
}
[HarmonyPatch("chargeItemDelayed")]
[HarmonyPrefix]
private static void chargeItemDelayedPatch(ref GrabbableObject itemToCharge)
{
if (!((Object)(object)itemToCharge == (Object)null) && itemToCharge.insertedBattery != null && !itemToCharge.insertedBattery.empty && itemToCharge.insertedBattery.charge > 1f)
{
itemToCharge = null;
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal static class StartOfRoundPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void AwakePatch()
{
SpawnNetworkHandler();
}
private static void SpawnNetworkHandler()
{
//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)
if (NetworkUtils.IsServer)
{
GameObject val = Object.Instantiate<GameObject>(Content.NetworkHandlerPrefab, Vector3.zero, Quaternion.identity);
val.GetComponent<NetworkObject>().Spawn(false);
}
}
[HarmonyPatch("OnClientConnect")]
[HarmonyPrefix]
private static void OnClientConnectPatch(ref ulong clientId)
{
SendConfigToNewConnectedPlayer(clientId);
}
private static void SendConfigToNewConnectedPlayer(ulong clientId)
{
if (NetworkUtils.IsServer)
{
SyncedConfigEntryBase.SendConfigsToClient(clientId);
}
}
[HarmonyPatch("PowerSurgeShip")]
[HarmonyPostfix]
private static void PowerSurgeShipPatch()
{
ShipHelper.PowerSurgedShip = true;
}
}
}
namespace com.github.zehsteam.Supercharger.MonoBehaviours
{
internal class PluginNetworkBehaviour : NetworkBehaviour
{
public static PluginNetworkBehaviour Instance { get; private set; }
private void Awake()
{
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
else
{
Instance = this;
}
}
public override void OnNetworkSpawn()
{
((NetworkBehaviour)this).OnNetworkSpawn();
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
if (((NetworkBehaviour)this).IsServer)
{
((NetworkBehaviour)this).NetworkObject.Despawn(true);
}
}
else
{
Instance = this;
}
}
[ClientRpc]
public void SetSyncedConfigValueClientRpc(string section, string key, string value, ClientRpcParams clientRpcParams = default(ClientRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: 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_0136: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1181108155u, clientRpcParams, (RpcDelivery)0);
bool flag = section != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val)).WriteValueSafe(section, false);
}
bool flag2 = key != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
if (flag2)
{
((FastBufferWriter)(ref val)).WriteValueSafe(key, false);
}
bool flag3 = value != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag3, default(ForPrimitives));
if (flag3)
{
((FastBufferWriter)(ref val)).WriteValueSafe(value, false);
}
((NetworkBehaviour)this).__endSendClientRpc(ref val, 1181108155u, clientRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !NetworkUtils.IsServer)
{
SyncedConfigEntryBase.SetValueFromServer(section, key, value);
}
}
[ServerRpc(RequireOwnership = false)]
public void SuperchargeItemServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2871894807u, serverRpcParams, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val, 2871894807u, serverRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
ulong senderClientId = serverRpcParams.Receive.SenderClientId;
if (((NetworkBehaviour)this).NetworkManager.ConnectedClients.ContainsKey(senderClientId))
{
SuperchargeItemClientRpc(senderClientId);
}
}
}
[ClientRpc]
public void SuperchargeItemClientRpc(ulong senderClientId)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(847089641u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, senderClientId);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 847089641u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !NetworkUtils.IsLocalClientId(senderClientId))
{
PlayerControllerB playerScriptByClientId = PlayerUtils.GetPlayerScriptByClientId(senderClientId);
if (ShipHelper.TryGetSuperchargeStationBehaviour(out var superchargeStationBehaviour))
{
superchargeStationBehaviour.SuperchargeItemForOtherClient(playerScriptByClientId);
}
}
}
[ServerRpc(RequireOwnership = false)]
public void SpawnExplosionServerRpc(Vector3 position, int damage, int enemyDamage, float range, ulong senderClientId)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: 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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1307054941u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
BytePacker.WriteValueBitPacked(val2, damage);
BytePacker.WriteValueBitPacked(val2, enemyDamage);
((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref range, default(ForPrimitives));
BytePacker.WriteValueBitPacked(val2, senderClientId);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1307054941u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
SpawnExplosionClientRpc(position, damage, enemyDamage, range, senderClientId);
}
}
}
[ClientRpc]
public void SpawnExplosionClientRpc(Vector3 position, int damage, int enemyDamage, float range, ulong senderClientId)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: 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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4060816794u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
BytePacker.WriteValueBitPacked(val2, damage);
BytePacker.WriteValueBitPacked(val2, enemyDamage);
((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref range, default(ForPrimitives));
BytePacker.WriteValueBitPacked(val2, senderClientId);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4060816794u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
PlayerControllerB playerScriptByClientId = PlayerUtils.GetPlayerScriptByClientId(senderClientId);
Utils.CreateExplosion(position, spawnExplosionEffect: true, damage, 0f, range, enemyDamage, (CauseOfDeath)3, playerScriptByClientId);
}
}
}
[ServerRpc(RequireOwnership = false)]
public void PowerSurgeShipServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1906784499u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1906784499u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
PowerSurgeShipClientRpc();
}
}
}
[ClientRpc]
public void PowerSurgeShipClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1633666871u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1633666871u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
StartOfRound.Instance.PowerSurgeShip();
}
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_PluginNetworkBehaviour()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(1181108155u, new RpcReceiveHandler(__rpc_handler_1181108155));
NetworkManager.__rpc_func_table.Add(2871894807u, new RpcReceiveHandler(__rpc_handler_2871894807));
NetworkManager.__rpc_func_table.Add(847089641u, new RpcReceiveHandler(__rpc_handler_847089641));
NetworkManager.__rpc_func_table.Add(1307054941u, new RpcReceiveHandler(__rpc_handler_1307054941));
NetworkManager.__rpc_func_table.Add(4060816794u, new RpcReceiveHandler(__rpc_handler_4060816794));
NetworkManager.__rpc_func_table.Add(1906784499u, new RpcReceiveHandler(__rpc_handler_1906784499));
NetworkManager.__rpc_func_table.Add(1633666871u, new RpcReceiveHandler(__rpc_handler_1633666871));
}
private static void __rpc_handler_1181108155(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: 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_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string section = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref section, false);
}
bool flag2 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
string key = null;
if (flag2)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref key, false);
}
bool flag3 = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag3, default(ForPrimitives));
string value = null;
if (flag3)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref value, false);
}
ClientRpcParams client = rpcParams.Client;
target.__rpc_exec_stage = (__RpcExecStage)2;
((PluginNetworkBehaviour)(object)target).SetSyncedConfigValueClientRpc(section, key, value, client);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2871894807(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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_003e: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ServerRpcParams server = rpcParams.Server;
target.__rpc_exec_stage = (__RpcExecStage)1;
((PluginNetworkBehaviour)(object)target).SuperchargeItemServerRpc(server);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_847089641(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong senderClientId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref senderClientId);
target.__rpc_exec_stage = (__RpcExecStage)2;
((PluginNetworkBehaviour)(object)target).SuperchargeItemClientRpc(senderClientId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1307054941(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0030: 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_0056: 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_0065: 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_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
Vector3 position = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
int damage = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref damage);
int enemyDamage = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref enemyDamage);
float range = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref range, default(ForPrimitives));
ulong senderClientId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref senderClientId);
target.__rpc_exec_stage = (__RpcExecStage)1;
((PluginNetworkBehaviour)(object)target).SpawnExplosionServerRpc(position, damage, enemyDamage, range, senderClientId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_4060816794(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0030: 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_0056: 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_0065: 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_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
Vector3 position = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
int damage = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref damage);
int enemyDamage = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref enemyDamage);
float range = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref range, default(ForPrimitives));
ulong senderClientId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref senderClientId);
target.__rpc_exec_stage = (__RpcExecStage)2;
((PluginNetworkBehaviour)(object)target).SpawnExplosionClientRpc(position, damage, enemyDamage, range, senderClientId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1906784499(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((PluginNetworkBehaviour)(object)target).PowerSurgeShipServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1633666871(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((PluginNetworkBehaviour)(object)target).PowerSurgeShipClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "PluginNetworkBehaviour";
}
}
public class SuperchargeStationBehaviour : MonoBehaviour
{
[Header("SuperchargeStation")]
[Space(5f)]
public AudioClip ChargeItemSFX;
public RuntimeAnimatorController ChargeStationAnimatorController;
[Header("Player")]
public AnimatorOverrideController PlayerAnimatorOverrideController;
private InteractTrigger _interactTrigger;
private AudioSource _chargeStationAudio;
private Animator _chargeStationAnimator;
private ParticleSystem _chargeStationParticleSystem;
private RuntimeAnimatorController _originalChargeStationAnimatorController;
private Dictionary<ulong, PlayerAnimatorStateHelper> _playerAnimatorStateHelpers = new Dictionary<ulong, PlayerAnimatorStateHelper>();
private Coroutine _superchargeItemAnimation;
public bool SuperchargeNext { get; private set; }
private void Start()
{
if ((Object)(object)((Component)this).transform.parent == (Object)null)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
_interactTrigger = ((Component)((Component)this).transform.parent).GetComponentInChildren<InteractTrigger>();
_chargeStationAudio = ((Component)((Component)this).transform.parent).GetComponentInChildren<AudioSource>();
_chargeStationAnimator = ((Component)((Component)this).transform.parent).GetComponent<Animator>();
_chargeStationParticleSystem = ((Component)((Component)this).transform.parent).GetComponentInChildren<ParticleSystem>(true);
_originalChargeStationAnimatorController = _chargeStationAnimator.runtimeAnimatorController;
}
public bool TrySuperchargeNext()
{
if (!AllowedToSupercharge())
{
return false;
}
SuperchargeNext = Utils.RandomPercent(Plugin.ConfigManager.Supercharger_Chance.Value);
if (SuperchargeNext)
{
SetCustomChargeStationValues();
}
return SuperchargeNext;
}
public bool AllowedToSupercharge()
{
PlayerControllerB localPlayerScript = PlayerUtils.GetLocalPlayerScript();
if ((Object)(object)localPlayerScript == (Object)null)
{
return false;
}
if ((Object)(object)localPlayerScript.currentlyHeldObjectServer == (Object)null)
{
return false;
}
if (localPlayerScript.currentlyHeldObjectServer.insertedBattery == null)
{
return false;
}
float charge = localPlayerScript.currentlyHeldObjectServer.insertedBattery.charge;
if (Plugin.ConfigManager.Supercharger_OnlyWhenFullyCharged.Value && charge < 1f)
{
return false;
}
if (!Plugin.ConfigManager.Supercharger_EnableInOrbit.Value && ShipHelper.IsInOrbit())
{
return false;
}
return true;
}
public void SuperchargeItem(GrabbableObject grabbableObject, PlayerControllerB playerScript)
{
//IL_0008: 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)
PluginNetworkBehaviour.Instance.SuperchargeItemServerRpc();
if (_superchargeItemAnimation != null)
{
((MonoBehaviour)this).StopCoroutine(_superchargeItemAnimation);
}
SuperchargeNext = false;
_superchargeItemAnimation = ((MonoBehaviour)this).StartCoroutine(SuperchargeItemAnimation(grabbableObject, playerScript));
}
public void SuperchargeItemForOtherClient(PlayerControllerB playerScript)
{
GrabbableObject currentlyHeldObjectServer = playerScript.currentlyHeldObjectServer;
if (_superchargeItemAnimation != null)
{
((MonoBehaviour)this).StopCoroutine(_superchargeItemAnimation);
}
SuperchargeNext = false;
_superchargeItemAnimation = ((MonoBehaviour)this).StartCoroutine(SuperchargeItemAnimation(currentlyHeldObjectServer, playerScript));
}
private IEnumerator SuperchargeItemAnimation(GrabbableObject grabbableObject, PlayerControllerB playerScript)
{
Plugin.Instance.LogInfoExtended("Player \"" + playerScript.playerUsername + "\" is supercharging \"" + grabbableObject.itemProperties.itemName + "\".");
bool isLocalPlayer = PlayerUtils.IsLocalPlayer(playerScript);
SetCustomChargeStationValues();
OverridePlayerAnimator(playerScript);
_chargeStationAudio.PlayOneShot(ChargeItemSFX);
yield return (object)new WaitForSeconds(0.65f);
_chargeStationAnimator.SetTrigger("zap");
if (Plugin.ConfigManager.Supercharger_FlickerShipLights.Value && ShipHelper.FlickerLightsOnLocalClient(3f, 0.15f, 0.4f))
{
ShipHelper.SetLightSwitchInteractable(value: false);
}
if (isLocalPlayer && (Object)(object)grabbableObject != (Object)null)
{
grabbableObject.insertedBattery = new Battery(false, (float)Plugin.ConfigManager.Supercharger_ItemChargeAmount.Value / 100f);
grabbableObject.SyncBatteryServerRpc(Plugin.ConfigManager.Supercharger_ItemChargeAmount.Value);
}
((Component)_chargeStationParticleSystem).gameObject.SetActive(true);
float duration = 2f;
float timePerIteration = 0.15f;
int iterations = Mathf.RoundToInt(duration / timePerIteration);
for (int i = 0; i < iterations; i++)
{
yield return (object)new WaitForSeconds(timePerIteration);
_chargeStationParticleSystem.Stop();
_chargeStationParticleSystem.Play();
}
if (isLocalPlayer && Utils.RandomPercent(Plugin.ConfigManager.Explosion_Chance.Value))
{
Vector3 position = ((Component)grabbableObject).transform.position;
int damage = Plugin.ConfigManager.Explosion_Damage.Value;
int enemyDamage = Plugin.ConfigManager.Explosion_EnemyDamage.Value;
float range = Plugin.ConfigManager.Explosion_Range.Value;
PluginNetworkBehaviour.Instance.SpawnExplosionServerRpc(position, damage, enemyDamage, range, NetworkUtils.GetLocalClientId());
if (Plugin.ConfigManager.Explosion_TurnsOffShipLights.Value)
{
PluginNetworkBehaviour.Instance.PowerSurgeShipServerRpc();
}
}
yield return (object)new WaitForSeconds(0.85f);
((Component)_chargeStationParticleSystem).gameObject.SetActive(false);
SetPlayerAnimatorHoldAnimation(playerScript, grabbableObject);
yield return (object)new WaitForSeconds(0.35f);
SetOriginalChargeStationValues();
ResetPlayerAnimator(playerScript, grabbableObject);
ShipHelper.SetLightSwitchInteractable(value: true);
Plugin.Instance.LogInfoExtended("Supercharge animation finished.");
}
public void SetCustomChargeStationValues()
{
_interactTrigger.animationWaitTime = 3.75f;
_chargeStationAnimator.runtimeAnimatorController = ChargeStationAnimatorController;
}
public void SetOriginalChargeStationValues()
{
_interactTrigger.animationWaitTime = 2f;
_chargeStationAnimator.runtimeAnimatorController = _originalChargeStationAnimatorController;
}
private void OverridePlayerAnimator(PlayerControllerB playerScript)
{
ulong actualClientId = playerScript.actualClientId;
if (!_playerAnimatorStateHelpers.ContainsKey(actualClientId))
{
_playerAnimatorStateHelpers[actualClientId] = new PlayerAnimatorStateHelper(playerScript.playerBodyAnimator);
}
PlayerAnimatorStateHelper playerAnimatorStateHelper = _playerAnimatorStateHelpers[actualClientId];
playerAnimatorStateHelper.SaveAnimatorStates();
playerAnimatorStateHelper.SetAnimatorOverrideController(PlayerAnimatorOverrideController);
Plugin.Instance.LogInfoExtended("Animator override set for player \"" + playerScript.playerUsername + "\".");
}
private void ResetPlayerAnimator(PlayerControllerB playerScript, GrabbableObject grabbableObject)
{
ulong actualClientId = playerScript.actualClientId;
if (_playerAnimatorStateHelpers.ContainsKey(actualClientId))
{
PlayerAnimatorStateHelper playerAnimatorStateHelper = _playerAnimatorStateHelpers[actualClientId];
playerAnimatorStateHelper.SaveAnimatorStates();
playerAnimatorStateHelper.RestoreOriginalAnimatorController();
SetPlayerAnimatorHoldAnimation(playerScript, grabbableObject);
Plugin.Instance.LogInfoExtended("Animator restored for player \"" + playerScript.playerUsername + "\".");
}
}
private void SetPlayerAnimatorHoldAnimation(PlayerControllerB playerScript, GrabbableObject grabbableObject)
{
Animator playerBodyAnimator = playerScript.playerBodyAnimator;
playerBodyAnimator.SetBool("Grab", true);
playerBodyAnimator.SetBool("GrabValidated", true);
string grabAnim = grabbableObject.itemProperties.grabAnim;
if (!string.IsNullOrEmpty(grabAnim))
{
playerBodyAnimator.SetBool(grabAnim, true);
}
if (grabbableObject.itemProperties.twoHandedAnimation)
{
playerBodyAnimator.ResetTrigger("SwitchHoldAnimationTwoHanded");
playerBodyAnimator.SetTrigger("SwitchHoldAnimationTwoHanded");
}
playerBodyAnimator.ResetTrigger("SwitchHoldAnimation");
playerBodyAnimator.SetTrigger("SwitchHoldAnimation");
playerBodyAnimator.Play("chooseHoldAnimation");
}
}
}
namespace com.github.zehsteam.Supercharger.Helpers
{
internal static class ConfigHelper
{
public static void SkipAutoGen()
{
if (LethalConfigProxy.Enabled)
{
LethalConfigProxy.SkipAutoGen();
}
}
public static void AddButton(string section, string name, string description, string buttonText, Action callback)
{
if (LethalConfigProxy.Enabled)
{
LethalConfigProxy.AddButton(section, name, description, buttonText, callback);
}
}
public static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, bool requiresRestart, string description, AcceptableValueBase acceptableValues = null, Action<T> settingChanged = null, ConfigFile configFile = null)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
if (configFile == null)
{
configFile = ((BaseUnityPlugin)Plugin.Instance).Config;
}
ConfigEntry<T> configEntry = ((acceptableValues == null) ? configFile.Bind<T>(section, key, defaultValue, description) : configFile.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty<object>())));
if (settingChanged != null)
{
configEntry.SettingChanged += delegate
{
settingChanged?.Invoke(configEntry.Value);
};
}
if (LethalConfigProxy.Enabled)
{
LethalConfigProxy.AddConfig<T>(configEntry, requiresRestart);
}
return configEntry;
}
public static Dictionary<ConfigDefinition, string> GetOrphanedConfigEntries(ConfigFile configFile = null)
{
if (configFile == null)
{
configFile = ((BaseUnityPlugin)Plugin.Instance).Config;
}
PropertyInfo property = ((object)configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
return (Dictionary<ConfigDefinition, string>)property.GetValue(configFile, null);
}
public static void SetConfigEntryValue<T>(ConfigEntry<T> configEntry, string value)
{
if (typeof(T) == typeof(int) && int.TryParse(value, out var result))
{
configEntry.Value = (T)(object)result;
return;
}
if (typeof(T) == typeof(float) && float.TryParse(value, out var result2))
{
configEntry.Value = (T)(object)result2;
return;
}
if (typeof(T) == typeof(double) && double.TryParse(value, out var result3))
{
configEntry.Value = (T)(object)result3;
return;
}
if (typeof(T) == typeof(bool) && bool.TryParse(value, out var result4))
{
configEntry.Value = (T)(object)result4;
return;
}
if (typeof(T) == typeof(string))
{
configEntry.Value = (T)(object)value;
return;
}
throw new InvalidOperationException($"Unsupported type: {typeof(T)}");
}
public static void ClearUnusedEntries(ConfigFile configFile = null)
{
if (configFile == null)
{
configFile = ((BaseUnityPlugin)Plugin.Instance).Config;
}
Dictionary<ConfigDefinition, string> orphanedConfigEntries = GetOrphanedConfigEntries(configFile);
if (orphanedConfigEntries != null)
{
orphanedConfigEntries.Clear();
configFile.Save();
}
}
}
public class PlayerAnimatorStateHelper
{
private Animator _animator;
private bool _isCrouching;
private bool _isJumping;
private bool _isWalking;
private bool _isSprinting;
private float _currentAnimationTime;
private AnimatorStateInfo _currentStateInfo;
private RuntimeAnimatorController _originalAnimatorController;
public PlayerAnimatorStateHelper(Animator animator)
{
if (!((Object)(object)animator == (Object)null))
{
_animator = animator;
_originalAnimatorController = animator.runtimeAnimatorController;
}
}
public void SaveAnimatorStates()
{
//IL_0074: 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 (!((Object)(object)_animator == (Object)null))
{
_isCrouching = _animator.GetBool("crouching");
_isJumping = _animator.GetBool("Jumping");
_isWalking = _animator.GetBool("Walking");
_isSprinting = _animator.GetBool("Sprinting");
_currentStateInfo = _animator.GetCurrentAnimatorStateInfo(0);
_currentAnimationTime = ((AnimatorStateInfo)(ref _currentStateInfo)).normalizedTime;
}
}
public void RestoreAnimatorStates()
{
if (!((Object)(object)_animator == (Object)null))
{
_animator.Play(((AnimatorStateInfo)(ref _currentStateInfo)).fullPathHash, 0, _currentAnimationTime);
_animator.SetBool("crouching", _isCrouching);
_animator.SetBool("Jumping", _isJumping);
_animator.SetBool("Walking", _isWalking);
_animator.SetBool("Sprinting", _isSprinting);
}
}
public void RestoreOriginalAnimatorController()
{
if (!((Object)(object)_animator == (Object)null))
{
_animator.runtimeAnimatorController = _originalAnimatorController;
RestoreAnimatorStates();
}
}
public void SetAnimatorOverrideController(AnimatorOverrideController overrideController)
{
if (!((Object)(object)_animator == (Object)null))
{
_animator.runtimeAnimatorController = (RuntimeAnimatorController)(object)overrideController;
RestoreAnimatorStates();
}
}
public RuntimeAnimatorController GetOriginalAnimatorController()
{
return _originalAnimatorController;
}
}
internal class ShipHelper
{
public static bool PowerSurgedShip;
private static Coroutine _flickerLightsOnLocalClientAnimation;
public static bool IsInOrbit()
{
if ((Object)(object)StartOfRound.Instance == (Object)null)
{
return false;
}
return StartOfRound.Instance.inShipPhase;
}
public static bool IsShipSupercharger(SuperchargeStationBehaviour superchargeStationBehaviour)
{
if (TryGetSuperchargeStationBehaviour(out var superchargeStationBehaviour2))
{
return (Object)(object)superchargeStationBehaviour == (Object)(object)superchargeStationBehaviour2;
}
return false;
}
public static bool TryGetSuperchargeStationBehaviour(out SuperchargeStationBehaviour superchargeStationBehaviour)
{
superchargeStationBehaviour = null;
if (TryGetChargeStationGameObject(out var gameObject))
{
superchargeStationBehaviour = gameObject.GetComponentInChildren<SuperchargeStationBehaviour>();
return (Object)(object)superchargeStationBehaviour != (Object)null;
}
return false;
}
private static bool TryGetChargeStationGameObject(out GameObject gameObject)
{
gameObject = null;
try
{
gameObject = GameObject.Find("/Environment/HangarShip/ShipModels2b/ChargeStation");
}
catch
{
return false;
}
return (Object)(object)gameObject != (Object)null;
}
public static void SetLightSwitchInteractable(bool value)
{
if (TryGetLightSwitchInteractTrigger(out var interactTrigger))
{
interactTrigger.interactable = value;
}
}
private static bool TryGetLightSwitchInteractTrigger(out InteractTrigger interactTrigger)
{
interactTrigger = null;
GameObject val;
try
{
val = GameObject.Find("/Environment/HangarShip/LightSwitchContainer");
}
catch
{
return false;
}
interactTrigger = val.GetComponentInChildren<InteractTrigger>();
return (Object)(object)interactTrigger != (Object)null;
}
public static bool FlickerLightsOnLocalClient(float duration, float minInterval, float maxInterval)
{
if (!StartOfRound.Instance.shipRoomLights.areLightsOn)
{
return false;
}
if (_flickerLightsOnLocalClientAnimation != null)
{
((MonoBehaviour)StartOfRound.Instance).StopCoroutine(_flickerLightsOnLocalClientAnimation);
}
_flickerLightsOnLocalClientAnimation = ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(FlickerLightsOnLocalClientAnimation(duration, minInterval, maxInterval));
return true;
}
private static IEnumerator FlickerLightsOnLocalClientAnimation(float duration, float minInterval, float maxInterval)
{
bool previouslyPowerSurged = PowerSurgedShip;
if (PowerSurgedShip)
{
PowerSurgedShip = false;
}
float timer = 0f;
float intervalTimer = 0f;
float interval = Random.Range(minInterval, maxInterval);
while (timer < duration)
{
if (PowerSurgedShip && !previouslyPowerSurged)
{
PowerSurgedShip = false;
StartOfRound.Instance.shipRoomLights.SetShipLightsOnLocalClientOnly(false);
yield break;
}
if (intervalTimer >= interval)
{
StartOfRound.Instance.shipRoomLights.ToggleShipLightsOnLocalClientOnly();
interval = Random.Range(minInterval, maxInterval);
intervalTimer = 0f;
}
yield return null;
timer += Time.deltaTime;
intervalTimer += Time.deltaTime;
}
if (PowerSurgedShip && !previouslyPowerSurged)
{
PowerSurgedShip = false;
StartOfRound.Instance.shipRoomLights.SetShipLightsOnLocalClientOnly(false);
}
else
{
StartOfRound.Instance.shipRoomLights.SetShipLightsOnLocalClientOnly(true);
}
}
}
}
namespace com.github.zehsteam.Supercharger.Dependencies
{
internal static class LethalConfigProxy
{
public const string PLUGIN_GUID = "ainavt.lc.lethalconfig";
public static bool Enabled => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void SkipAutoGen()
{
LethalConfigManager.SkipAutoGen();
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void AddConfig<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
{
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Expected O, but got Unknown
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Expected O, but got Unknown
AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues;
if (acceptableValues != null)
{
if (acceptableValues is AcceptableValueRange<float> || acceptableValues is AcceptableValueRange<int>)
{
AddConfigSlider<T>(configEntry, requiresRestart);
return;
}
if (acceptableValues is AcceptableValueList<string>)
{
AddConfigDropdown<T>(configEntry, requiresRestart);
return;
}
}
if (!(configEntry is ConfigEntry<string> val))
{
if (!(configEntry is ConfigEntry<bool> val2))
{
if (!(configEntry is ConfigEntry<float> val3))
{
if (!(configEntry is ConfigEntry<int> val4))
{
throw new NotSupportedException($"Unsupported type: {typeof(T)}");
}
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(val4, requiresRestart));
}
else
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(val3, requiresRestart));
}
}
else
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(val2, requiresRestart));
}
}
else
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val, requiresRestart));
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void AddConfigSlider<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
if (!(configEntry is ConfigEntry<float> val))
{
if (!(configEntry is ConfigEntry<int> val2))
{
throw new NotSupportedException($"Slider not supported for type: {typeof(T)}");
}
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(val2, requiresRestart));
}
else
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val, requiresRestart));
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void AddConfigDropdown<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
if (configEntry is ConfigEntry<string> val)
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new TextDropDownConfigItem(val, requiresRestart));
return;
}
throw new NotSupportedException($"Dropdown not supported for type: {typeof(T)}");
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void AddButton(string section, string name, string description, string buttonText, Action callback)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate
{
callback?.Invoke();
}));
}
}
}
namespace com.github.zehsteam.Supercharger.Data
{
public class SyncedConfigEntry<T> : SyncedConfigEntryBase
{
private ConfigEntry<T> _configEntry;
private T _serverValue;
public T Value
{
get
{
return GetValue();
}
set
{
SetValue(value);
}
}
public override string Section => ((ConfigEntryBase)_configEntry).Definition.Section;
public override string Key => ((ConfigEntryBase)_configEntry).Definition.Key;
public event Action<T> SettingChanged;
public SyncedConfigEntry(string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues = null, ConfigFile configFile = null)
{
SyncedConfigEntryBase.AddInstance(this);
_configEntry = ConfigHelper.Bind(section, key, defaultValue, requiresRestart: false, description, acceptableValues, null, configFile);
_configEntry.SettingChanged += SettingChangedInternal;
}
public T GetValue()
{
if (NetworkUtils.IsConnected && !NetworkUtils.IsServer)
{
return _serverValue;
}
return _configEntry.Value;
}
public void SetValue(T value)
{
if (!NetworkUtils.IsConnected || NetworkUtils.IsServer)
{
_configEntry.Value = value;
}
}
private void SettingChangedInternal(object sender, EventArgs e)
{
if (NetworkUtils.IsConnected && NetworkUtils.IsServer)
{
this.SettingChanged?.Invoke(Value);
SendConfigToClients();
}
}
private void SendConfigToClients()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (NetworkUtils.IsConnected && NetworkUtils.IsServer)
{
PluginNetworkBehaviour.Instance?.SetSyncedConfigValueClientRpc(Section, Key, Value.ToString());
}
}
public override void SendConfigToClient(ulong clientId)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: 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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
if (NetworkUtils.IsConnected && NetworkUtils.IsServer)
{
ClientRpcParams val = default(ClientRpcParams);
val.Send = new ClientRpcSendParams
{
TargetClientIds = new <>z__ReadOnlySingleElementList<ulong>(clientId)
};
ClientRpcParams clientRpcParams = val;
PluginNetworkBehaviour.Instance?.SetSyncedConfigValueClientRpc(Section, Key, Value.ToString(), clientRpcParams);
}
}
public override void SetValueFromServer(string value)
{
if (NetworkUtils.IsConnected && !NetworkUtils.IsServer)
{
if (!Utils.TryParseValue<T>(value, out var result))
{
throw new InvalidOperationException($"Failed to parse value: \"{value}\" for type {typeof(T)}");
}
_serverValue = result;
Plugin.Instance.LogInfoExtended("Set synced config entry value from server. (Section: \"" + Section + "\", Key: \"" + Key + "\", Value: \"" + value + "\")");
this.SettingChanged?.Invoke(result);
}
}
}
public abstract class SyncedConfigEntryBase
{
private static readonly object _instancesLock = new object();
public static List<SyncedConfigEntryBase> Instances { get; private set; } = new List<SyncedConfigEntryBase>();
public abstract string Section { get; }
public abstract string Key { get; }
public static void AddInstance(SyncedConfigEntryBase instance)
{
lock (_instancesLock)
{
Instances.Add(instance);
}
}
public static void RemoveInstance(SyncedConfigEntryBase instance)
{
lock (_instancesLock)
{
Instances.Remove(instance);
}
}
public abstract void SendConfigToClient(ulong clientId);
public abstract void SetValueFromServer(string value);
public static void SendConfigsToClient(ulong clientId)
{
if (!NetworkUtils.IsConnected || !NetworkUtils.IsServer || NetworkUtils.IsLocalClientId(clientId))
{
return;
}
foreach (SyncedConfigEntryBase instance in Instances)
{
instance.SendConfigToClient(clientId);
}
}
public static void SetValueFromServer(string section, string key, string value)
{
if (NetworkUtils.IsConnected && !NetworkUtils.IsServer)
{
SyncedConfigEntryBase syncedConfigEntryBase = Instances.Find((SyncedConfigEntryBase x) => x.Section == section && x.Key == key);
if (syncedConfigEntryBase == null)
{
Plugin.Logger.LogWarning((object)("No matching synced config entry found for section: \"" + section + "\", key: \"" + key + "\""));
}
else
{
syncedConfigEntryBase.SetValueFromServer(value);
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
{
object IEnumerator.Current => _item;
T IEnumerator<T>.Current => _item;
public Enumerator(T item)
{
_item = item;
}
bool IEnumerator.MoveNext()
{
return !_moveNextCalled && (_moveNextCalled = true);
}
void IEnumerator.Reset()
{
_moveNextCalled = false;
}
void IDisposable.Dispose()
{
}
}
int ICollection.Count => 1;
bool ICollection.IsSynchronized => false;
object ICollection.SyncRoot => this;
object IList.this[int index]
{
get
{
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
set
{
throw new NotSupportedException();
}
}
bool IList.IsFixedSize => true;
bool IList.IsReadOnly => true;
int IReadOnlyCollection<T>.Count => 1;
T IReadOnlyList<T>.this[int index]
{
get
{
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
}
int ICollection<T>.Count => 1;
bool ICollection<T>.IsReadOnly => true;
T IList<T>.this[int index]
{
get
{
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
set
{
throw new NotSupportedException();
}
}
public <>z__ReadOnlySingleElementList(T item)
{
_item = item;
}
IEnumerator IEnumerable.GetEnumerator()
{
return new Enumerator(_item);
}
void ICollection.CopyTo(Array array, int index)
{
array.SetValue(_item, index);
}
int IList.Add(object value)
{
throw new NotSupportedException();
}
void IList.Clear()
{
throw new NotSupportedException();
}
bool IList.Contains(object value)
{
return EqualityComparer<T>.Default.Equals(_item, (T)value);
}
int IList.IndexOf(object value)
{
return (!EqualityComparer<T>.Default.Equals(_item, (T)value)) ? (-1) : 0;
}
void IList.Insert(int index, object value)
{
throw new NotSupportedException();
}
void IList.Remove(object value)
{
throw new NotSupportedException();
}
void IList.RemoveAt(int index)
{
throw new NotSupportedException();
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return new Enumerator(_item);
}
void ICollection<T>.Add(T item)
{
throw new NotSupportedException();
}
void ICollection<T>.Clear()
{
throw new NotSupportedException();
}
bool ICollection<T>.Contains(T item)
{
return EqualityComparer<T>.Default.Equals(_item, item);
}
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
array[arrayIndex] = _item;
}
bool ICollection<T>.Remove(T item)
{
throw new NotSupportedException();
}
int IList<T>.IndexOf(T item)
{
return (!EqualityComparer<T>.Default.Equals(_item, item)) ? (-1) : 0;
}
void IList<T>.Insert(int index, T item)
{
throw new NotSupportedException();
}
void IList<T>.RemoveAt(int index)
{
throw new NotSupportedException();
}
}
namespace com.github.zehsteam.Supercharger.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}