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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
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.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+69f4ff5cd8d4b22103efa233e9313047f150cdc4")]
[assembly: AssemblyProduct("Supercharger")]
[assembly: AssemblyTitle("com.github.zehsteam.Supercharger")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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
{
internal class Content
{
public static GameObject NetworkHandlerPrefab;
public static GameObject SuperchargeStationPrefab;
public static void Load()
{
LoadAssetsFromAssetBundle();
}
private static void LoadAssetsFromAssetBundle()
{
try
{
string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
string text = Path.Combine(directoryName, "supercharger_assets");
AssetBundle val = AssetBundle.LoadFromFile(text);
NetworkHandlerPrefab = val.LoadAsset<GameObject>("NetworkHandler");
NetworkHandlerPrefab.AddComponent<PluginNetworkBehaviour>();
SuperchargeStationPrefab = val.LoadAsset<GameObject>("SuperchargeStation");
Plugin.logger.LogInfo((object)"Successfully loaded assets from AssetBundle!");
}
catch (Exception arg)
{
Plugin.logger.LogError((object)$"Error: failed to load assets from AssetBundle.\n\n{arg}");
}
}
}
public class PlayerAnimatorStateHelper
{
private Animator animator;
private AnimatorStateInfo currentStateInfo;
private float currentAnimationTime;
private bool isCrouching;
private bool isJumping;
private bool isWalking;
private bool isSprinting;
private RuntimeAnimatorController originalAnimatorController;
public PlayerAnimatorStateHelper(Animator animator)
{
this.animator = animator;
originalAnimatorController = animator.runtimeAnimatorController;
}
public void SaveAnimatorStates()
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
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 PlayerUtils
{
public static bool IsLocalPlayer(int playerId)
{
return IsLocalPlayer(GetPlayerScript(playerId));
}
public static bool IsLocalPlayer(PlayerControllerB playerScript)
{
return (Object)(object)playerScript == (Object)(object)GetLocalPlayerScript();
}
public static int GetPlayerId(PlayerControllerB playerScript)
{
return (int)playerScript.playerClientId;
}
public static int GetLocalPlayerId()
{
return (int)GetLocalPlayerScript().playerClientId;
}
public static PlayerControllerB GetPlayerScript(int playerId)
{
try
{
return StartOfRound.Instance.allPlayerScripts[playerId];
}
catch
{
return null;
}
}
public static PlayerControllerB GetLocalPlayerScript()
{
return GameNetworkManager.Instance.localPlayerController;
}
}
[BepInPlugin("com.github.zehsteam.Supercharger", "Supercharger", "1.1.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 SyncedConfigManager ConfigManager;
public static bool IsHostOrServer => NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer;
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 SyncedConfigManager();
Content.Load();
NetcodePatcherAwake();
}
private void NetcodePatcherAwake()
{
Type[] types = Assembly.GetExecutingAssembly().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)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
}
public void OnLocalDisconnect()
{
logger.LogInfo((object)"Local player disconnected. Removing host config data.");
ConfigManager.SetHostConfigData(null);
}
public void LogInfoExtended(object data)
{
if (ConfigManager.ExtendedLogging)
{
logger.LogInfo(data);
}
}
}
internal class ShipHelper
{
public static bool PowerSurgedShip;
private static Coroutine _flickerLightsOnLocalClientAnimation;
public static bool IsInOrbit()
{
if (StartOfRound.Instance.inShipPhase)
{
return true;
}
return false;
}
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);
}
}
}
[Serializable]
public class SyncedConfigData : INetworkSerializable
{
public bool EnableSuperchargerInOrbit;
public float SuperchargeChance;
public int ItemChargeAmount;
public float ExplodeChance;
public int ExplodeDamage;
public bool ExplosionTurnsOffShipLights;
public SyncedConfigData()
{
}
public SyncedConfigData(SyncedConfigManager configManager)
{
EnableSuperchargerInOrbit = configManager.EnableSuperchargerInOrbit;
SuperchargeChance = configManager.SuperchargeChance;
ItemChargeAmount = configManager.ItemChargeAmount;
ExplodeChance = configManager.ExplodeChance;
ExplodeDamage = configManager.ExplodeDamage;
ExplosionTurnsOffShipLights = configManager.ExplosionTurnsOffShipLights;
}
public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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_0050: 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_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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref EnableSuperchargerInOrbit, default(ForPrimitives));
((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref SuperchargeChance, default(ForPrimitives));
((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref ItemChargeAmount, default(ForPrimitives));
((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref ExplodeChance, default(ForPrimitives));
((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref ExplodeDamage, default(ForPrimitives));
((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref ExplosionTurnsOffShipLights, default(ForPrimitives));
}
}
public class SyncedConfigManager
{
private SyncedConfigData _hostConfigData;
private ConfigEntry<bool> ExtendedLoggingCfg;
private ConfigEntry<bool> EnableSuperchargerInOrbitCfg;
private ConfigEntry<float> SuperchargeChanceCfg;
private ConfigEntry<int> ItemChargeAmountCfg;
private ConfigEntry<bool> FlickerShipLightsCfg;
private ConfigEntry<float> ExplodeChanceCfg;
private ConfigEntry<int> ExplodeDamageCfg;
private ConfigEntry<bool> ExplosionTurnsOffShipLightsCfg;
public bool ExtendedLogging
{
get
{
return ExtendedLoggingCfg.Value;
}
set
{
ExtendedLoggingCfg.Value = value;
}
}
public bool EnableSuperchargerInOrbit
{
get
{
return (_hostConfigData == null) ? EnableSuperchargerInOrbitCfg.Value : _hostConfigData.EnableSuperchargerInOrbit;
}
set
{
EnableSuperchargerInOrbitCfg.Value = value;
SyncedConfigsChanged();
}
}
public float SuperchargeChance
{
get
{
return (_hostConfigData == null) ? SuperchargeChanceCfg.Value : _hostConfigData.SuperchargeChance;
}
set
{
SuperchargeChanceCfg.Value = value;
SyncedConfigsChanged();
}
}
public int ItemChargeAmount
{
get
{
return (_hostConfigData == null) ? ItemChargeAmountCfg.Value : _hostConfigData.ItemChargeAmount;
}
set
{
ItemChargeAmountCfg.Value = value;
SyncedConfigsChanged();
}
}
public bool FlickerShipLights
{
get
{
return FlickerShipLightsCfg.Value;
}
set
{
FlickerShipLightsCfg.Value = value;
}
}
public float ExplodeChance
{
get
{
return (_hostConfigData == null) ? ExplodeChanceCfg.Value : _hostConfigData.ExplodeChance;
}
set
{
ExplodeChanceCfg.Value = value;
SyncedConfigsChanged();
}
}
public int ExplodeDamage
{
get
{
return (_hostConfigData == null) ? ExplodeDamageCfg.Value : _hostConfigData.ExplodeDamage;
}
set
{
ExplodeDamageCfg.Value = value;
SyncedConfigsChanged();
}
}
public bool ExplosionTurnsOffShipLights
{
get
{
return (_hostConfigData == null) ? ExplosionTurnsOffShipLightsCfg.Value : _hostConfigData.ExplosionTurnsOffShipLights;
}
set
{
ExplosionTurnsOffShipLightsCfg.Value = value;
SyncedConfigsChanged();
}
}
public SyncedConfigManager()
{
BindConfigs();
ClearUnusedEntries();
}
private void BindConfigs()
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Expected O, but got Unknown
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Expected O, but got Unknown
ConfigFile config = ((BaseUnityPlugin)Plugin.Instance).Config;
ExtendedLoggingCfg = config.Bind<bool>("General Settings", "ExtendedLogging", false, "Enable extended logging.");
EnableSuperchargerInOrbitCfg = config.Bind<bool>("General Settings", "EnableSuperchargerInOrbit", false, "If enabled, the ship's charging station will be able to supercharge while in orbit.");
SuperchargeChanceCfg = config.Bind<float>("General Settings", "SuperchargeChance", 45f, new ConfigDescription("The percent chance the ship's charging station will supercharge your item.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
ItemChargeAmountCfg = config.Bind<int>("General Settings", "ItemChargeAmount", 200, new ConfigDescription("The amount of charge an item will receive after being supercharged.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(100, 1000), Array.Empty<object>()));
FlickerShipLightsCfg = config.Bind<bool>("General Settings", "FlickerShipLights", true, "If enabled, the ship's lights will flicker during a supercharge.");
ExplodeChanceCfg = config.Bind<float>("General Settings", "ExplodeChance", 25f, new ConfigDescription("The percent chance your item will explode from supercharging.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
ExplodeDamageCfg = config.Bind<int>("General Settings", "ExplodeDamage", 40, new ConfigDescription("The amount of damage you will receive from an explosion.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
ExplosionTurnsOffShipLightsCfg = config.Bind<bool>("General Settings", "ExplosionTurnsOffShipLights", true, "If enabled, the ship's lights will turn off after an explosion.");
EnableSuperchargerInOrbitCfg.SettingChanged += SyncedConfigsChanged;
SuperchargeChanceCfg.SettingChanged += SyncedConfigsChanged;
ItemChargeAmountCfg.SettingChanged += SyncedConfigsChanged;
ExplodeChanceCfg.SettingChanged += SyncedConfigsChanged;
ExplodeDamageCfg.SettingChanged += SyncedConfigsChanged;
ExplosionTurnsOffShipLightsCfg.SettingChanged += SyncedConfigsChanged;
}
private void ClearUnusedEntries()
{
ConfigFile config = ((BaseUnityPlugin)Plugin.Instance).Config;
PropertyInfo property = ((object)config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(config, null);
dictionary.Clear();
config.Save();
}
internal void SetHostConfigData(SyncedConfigData syncedConfigData)
{
_hostConfigData = syncedConfigData;
}
private void SyncedConfigsChanged()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.IsHostOrServer)
{
PluginNetworkBehaviour.Instance.SendConfigToPlayerClientRpc(new SyncedConfigData(this));
}
}
private void SyncedConfigsChanged(object sender, EventArgs e)
{
SyncedConfigsChanged();
}
}
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
string text = "";
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)
{
text += ("\"" + val.name + "\", ").PadRight(length + 3);
AnimatorControllerParameterType type = val.type;
AnimatorControllerParameterType val2 = type;
switch (val2 - 1)
{
case 0:
text += $"Float: {animator.GetFloat(val.name)}";
break;
case 2:
text += $"Int: {animator.GetInteger(val.name)}";
break;
case 3:
text += $"Bool: {animator.GetBool(val.name)}";
break;
}
text += "\n";
}
}
Plugin.Instance.LogInfoExtended("\n\n" + text.Trim() + "\n");
}
}
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.1.0";
}
}
namespace com.github.zehsteam.Supercharger.Patches
{
[HarmonyPatch(typeof(GameNetworkManager))]
internal 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))
{
NetworkManager.Singleton.AddNetworkPrefab(prefab);
Plugin.logger.LogInfo((object)("Registered \"" + ((Object)prefab).name + "\" network prefab."));
}
}
}
[HarmonyPatch(typeof(InteractTrigger))]
internal 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 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 componentInChildren = ((Component)((Component)__instance).transform.parent.parent).GetComponentInChildren<SuperchargeStationBehaviour>();
if ((Object)(object)componentInChildren == (Object)null)
{
return true;
}
if (!ShipHelper.IsShipSupercharger(componentInChildren))
{
return true;
}
if (!componentInChildren.SuperchargeNext)
{
componentInChildren.SetOriginalChargeStationValues();
return true;
}
PlayerControllerB localPlayerScript = PlayerUtils.GetLocalPlayerScript();
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);
}
componentInChildren.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 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 (Plugin.IsHostOrServer)
{
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)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.IsHostOrServer)
{
ClientRpcParams val = default(ClientRpcParams);
val.Send = new ClientRpcSendParams
{
TargetClientIds = new <>z__ReadOnlyArray<ulong>(new ulong[1] { clientId })
};
ClientRpcParams clientRpcParams = val;
Plugin.logger.LogInfo((object)$"Sending config to client: {clientId}");
PluginNetworkBehaviour.Instance.SendConfigToPlayerClientRpc(new SyncedConfigData(Plugin.ConfigManager), clientRpcParams);
}
}
[HarmonyPatch("OnLocalDisconnect")]
[HarmonyPrefix]
private static void OnLocalDisconnectPatch()
{
Plugin.Instance.OnLocalDisconnect();
}
[HarmonyPatch("PowerSurgeShip")]
[HarmonyPostfix]
private static void PowerSurgeShipPatch()
{
ShipHelper.PowerSurgedShip = true;
}
}
}
namespace com.github.zehsteam.Supercharger.MonoBehaviours
{
public class PluginNetworkBehaviour : NetworkBehaviour
{
public static PluginNetworkBehaviour Instance;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
}
[ClientRpc]
public void SendConfigToPlayerClientRpc(SyncedConfigData syncedConfigData, 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_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: 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(764670070u, clientRpcParams, (RpcDelivery)0);
bool flag = syncedConfigData != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val)).WriteValueSafe<SyncedConfigData>(ref syncedConfigData, default(ForNetworkSerializable));
}
((NetworkBehaviour)this).__endSendClientRpc(ref val, 764670070u, clientRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !Plugin.IsHostOrServer)
{
Plugin.logger.LogInfo((object)"Syncing config with host.");
Plugin.ConfigManager.SetHostConfigData(syncedConfigData);
}
}
[ServerRpc(RequireOwnership = false)]
public void SuperchargeItemServerRpc(int fromPlayerId)
{
//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)
{
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(995664264u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, fromPlayerId);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 995664264u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
SuperchargeItemClientRpc(fromPlayerId);
}
}
}
[ClientRpc]
public void SuperchargeItemClientRpc(int fromPlayerId)
{
//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(2707355818u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, fromPlayerId);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2707355818u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
PlayerControllerB playerScript = PlayerUtils.GetPlayerScript(fromPlayerId);
if (!PlayerUtils.IsLocalPlayer(playerScript) && ShipHelper.TryGetSuperchargeStationBehaviour(out var superchargeStationBehaviour))
{
superchargeStationBehaviour.SuperchargeItemForOtherClient(playerScript);
}
}
}
[ServerRpc(RequireOwnership = false)]
public void SpawnExplosionServerRpc(Vector3 position, int damage, float range)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: 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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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)
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(49790004u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
BytePacker.WriteValueBitPacked(val2, damage);
((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref range, default(ForPrimitives));
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 49790004u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
SpawnExplosionClientRpc(position, damage, range);
}
}
}
[ClientRpc]
public void SpawnExplosionClientRpc(Vector3 position, int damage, float range)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: 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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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)
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(3181596674u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
BytePacker.WriteValueBitPacked(val2, damage);
((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref range, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3181596674u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
Landmine.SpawnExplosion(position, true, 0f, range, damage, 0f, (GameObject)null, false);
}
}
}
[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(764670070u, new RpcReceiveHandler(__rpc_handler_764670070));
NetworkManager.__rpc_func_table.Add(995664264u, new RpcReceiveHandler(__rpc_handler_995664264));
NetworkManager.__rpc_func_table.Add(2707355818u, new RpcReceiveHandler(__rpc_handler_2707355818));
NetworkManager.__rpc_func_table.Add(49790004u, new RpcReceiveHandler(__rpc_handler_49790004));
NetworkManager.__rpc_func_table.Add(3181596674u, new RpcReceiveHandler(__rpc_handler_3181596674));
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_764670070(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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: 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_0087: 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_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
SyncedConfigData syncedConfigData = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe<SyncedConfigData>(ref syncedConfigData, default(ForNetworkSerializable));
}
ClientRpcParams client = rpcParams.Client;
target.__rpc_exec_stage = (__RpcExecStage)2;
((PluginNetworkBehaviour)(object)target).SendConfigToPlayerClientRpc(syncedConfigData, client);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_995664264(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)
{
int fromPlayerId = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref fromPlayerId);
target.__rpc_exec_stage = (__RpcExecStage)1;
((PluginNetworkBehaviour)(object)target).SuperchargeItemServerRpc(fromPlayerId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2707355818(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)
{
int fromPlayerId = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref fromPlayerId);
target.__rpc_exec_stage = (__RpcExecStage)2;
((PluginNetworkBehaviour)(object)target).SuperchargeItemClientRpc(fromPlayerId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_49790004(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
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);
float range = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref range, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)1;
((PluginNetworkBehaviour)(object)target).SpawnExplosionServerRpc(position, damage, range);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3181596674(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
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);
float range = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref range, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)2;
((PluginNetworkBehaviour)(object)target).SpawnExplosionClientRpc(position, damage, range);
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 = null;
public RuntimeAnimatorController ChargeStationAnimatorController = null;
[Header("Player")]
public AnimatorOverrideController PlayerAnimatorOverrideController = null;
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()
{
_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 (!Plugin.ConfigManager.EnableSuperchargerInOrbit && ShipHelper.IsInOrbit())
{
return false;
}
SuperchargeNext = Utils.RandomPercent(Plugin.ConfigManager.SuperchargeChance);
if (SuperchargeNext)
{
SetCustomChargeStationValues();
}
return SuperchargeNext;
}
public void SuperchargeItem(GrabbableObject grabbableObject, PlayerControllerB playerScript)
{
PluginNetworkBehaviour.Instance.SuperchargeItemServerRpc(PlayerUtils.GetLocalPlayerId());
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.FlickerShipLights && 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.ItemChargeAmount / 100f);
grabbableObject.SyncBatteryServerRpc(Plugin.ConfigManager.ItemChargeAmount);
}
((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.ExplodeChance))
{
PluginNetworkBehaviour.Instance.SpawnExplosionServerRpc(((Component)grabbableObject).transform.position, Plugin.ConfigManager.ExplodeDamage, 5f);
if (Plugin.ConfigManager.ExplosionTurnsOffShipLights)
{
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 System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
int ICollection.Count => _items.Length;
bool ICollection.IsSynchronized => false;
object ICollection.SyncRoot => this;
object IList.this[int index]
{
get
{
return _items[index];
}
set
{
throw new NotSupportedException();
}
}
bool IList.IsFixedSize => true;
bool IList.IsReadOnly => true;
int IReadOnlyCollection<T>.Count => _items.Length;
T IReadOnlyList<T>.this[int index] => _items[index];
int ICollection<T>.Count => _items.Length;
bool ICollection<T>.IsReadOnly => true;
T IList<T>.this[int index]
{
get
{
return _items[index];
}
set
{
throw new NotSupportedException();
}
}
public <>z__ReadOnlyArray(T[] items)
{
_items = items;
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)_items).GetEnumerator();
}
void ICollection.CopyTo(Array array, int index)
{
((ICollection)_items).CopyTo(array, index);
}
int IList.Add(object value)
{
throw new NotSupportedException();
}
void IList.Clear()
{
throw new NotSupportedException();
}
bool IList.Contains(object value)
{
return ((IList)_items).Contains(value);
}
int IList.IndexOf(object value)
{
return ((IList)_items).IndexOf(value);
}
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 ((IEnumerable<T>)_items).GetEnumerator();
}
void ICollection<T>.Add(T item)
{
throw new NotSupportedException();
}
void ICollection<T>.Clear()
{
throw new NotSupportedException();
}
bool ICollection<T>.Contains(T item)
{
return ((ICollection<T>)_items).Contains(item);
}
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
((ICollection<T>)_items).CopyTo(array, arrayIndex);
}
bool ICollection<T>.Remove(T item)
{
throw new NotSupportedException();
}
int IList<T>.IndexOf(T item)
{
return ((IList<T>)_items).IndexOf(item);
}
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
{
}
}