using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
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 PushCompany.Assets.Scripts;
using PushCompany.Properties;
using Unity.Netcode;
using UnityEngine;
[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("PushCompany")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Push your fellow crewmates with the interaction key! (E by default)")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyProduct("PushCompany")]
[assembly: AssemblyTitle("PushCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
static <Module>()
{
NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
}
}
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 PushCompany
{
[BepInPlugin("PushCompany", "PushCompany", "1.2.0")]
public class PushCompanyBase : BaseUnityPlugin
{
public static readonly Lazy<PushCompanyBase> Instance = new Lazy<PushCompanyBase>(() => new PushCompanyBase());
public static GameObject pushPrefab;
public ManualLogSource mls;
private readonly Harmony harmony = new Harmony("PushCompany");
public static ConfigEntry<float> config_PushCooldown;
public static ConfigEntry<float> config_PushForce;
public static ConfigEntry<float> config_PushRange;
public static ConfigEntry<float> config_PushCost;
private void Awake()
{
mls = Logger.CreateLogSource("PushCompany");
ConfigSetup();
LoadBundle();
harmony.PatchAll(typeof(PushCompanyBase));
harmony.PatchAll(typeof(PlayerControllerB_Patches));
harmony.PatchAll(typeof(NetworkHandler));
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);
}
}
}
mls.LogInfo((object)"PushCompany has initialized!");
}
private void ConfigSetup()
{
config_PushCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Push Cooldown", "Value", 0.025f, "How long until the player can push again");
config_PushForce = ((BaseUnityPlugin)this).Config.Bind<float>("Push Force", "Value", 12.5f, "How strong the player pushes.");
config_PushRange = ((BaseUnityPlugin)this).Config.Bind<float>("Push Range", "Value", 3f, "The distance the player is able to push.");
config_PushCost = ((BaseUnityPlugin)this).Config.Bind<float>("Push Cost", "Value", 0.08f, "The energy cost of each push.");
}
private void LoadBundle()
{
AssetBundle val = AssetBundle.LoadFromMemory(Resources.pushcompany);
if ((Object)(object)val == (Object)null)
{
throw new Exception("Failed to load Push Bundle!");
}
pushPrefab = val.LoadAsset<GameObject>("Assets/Push.prefab");
if ((Object)(object)pushPrefab == (Object)null)
{
throw new Exception("Failed to load Push Prefab!");
}
pushPrefab.AddComponent<PushComponent>();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "PushCompany";
public const string PLUGIN_NAME = "PushCompany";
public const string PLUGIN_VERSION = "1.2.0";
}
}
namespace PushCompany.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
ResourceManager resourceManager = new ResourceManager("PushCompany.Properties.Resources", typeof(Resources).Assembly);
resourceMan = resourceManager;
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal static byte[] AssetBundles
{
get
{
object @object = ResourceManager.GetObject("AssetBundles", resourceCulture);
return (byte[])@object;
}
}
internal static byte[] AssetBundles_manifest
{
get
{
object @object = ResourceManager.GetObject("AssetBundles.manifest", resourceCulture);
return (byte[])@object;
}
}
internal static byte[] AssetBundles1
{
get
{
object @object = ResourceManager.GetObject("AssetBundles1", resourceCulture);
return (byte[])@object;
}
}
internal static byte[] AssetBundles2
{
get
{
object @object = ResourceManager.GetObject("AssetBundles2", resourceCulture);
return (byte[])@object;
}
}
internal static byte[] pushcompany
{
get
{
object @object = ResourceManager.GetObject("pushcompany", resourceCulture);
return (byte[])@object;
}
}
internal static byte[] pushcompany_push
{
get
{
object @object = ResourceManager.GetObject("pushcompany.push", resourceCulture);
return (byte[])@object;
}
}
internal static byte[] pushcompany_push_manifest
{
get
{
object @object = ResourceManager.GetObject("pushcompany.push.manifest", resourceCulture);
return (byte[])@object;
}
}
internal static byte[] pushcompany_push1
{
get
{
object @object = ResourceManager.GetObject("pushcompany.push1", resourceCulture);
return (byte[])@object;
}
}
internal Resources()
{
}
}
}
namespace PushCompany.Assets.Scripts
{
[HarmonyPatch]
public class NetworkHandler
{
private static GameObject pushObject;
[HarmonyPrefix]
[HarmonyPatch(typeof(GameNetworkManager), "Start")]
private static void Init()
{
NetworkManager.Singleton.AddNetworkPrefab(PushCompanyBase.pushPrefab);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "Awake")]
private static void SpawnNetworkPrefab()
{
try
{
if (NetworkManager.Singleton.IsServer)
{
pushObject = Object.Instantiate<GameObject>(PushCompanyBase.pushPrefab);
pushObject.GetComponent<NetworkObject>().Spawn(true);
}
}
catch
{
PushCompanyBase.Instance.Value.mls.LogError((object)"Failed to instantiate network prefab!");
}
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
public static class PlayerControllerB_Patches
{
private static PushComponent pushComponent;
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerControllerB), "Update")]
private static void Update(PlayerControllerB __instance)
{
//IL_0016: 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)
if (!((NetworkBehaviour)__instance).IsOwner)
{
return;
}
MovementActions movement = __instance.playerActions.Movement;
if (((MovementActions)(ref movement)).Interact.WasPressedThisFrame())
{
if ((Object)(object)pushComponent == (Object)null)
{
pushComponent = Object.FindObjectOfType<PushComponent>();
}
if ((Object)(object)pushComponent != (Object)null)
{
pushComponent.PushServerRpc(((NetworkBehaviour)__instance).NetworkObjectId);
}
}
}
}
public class PushComponent : NetworkBehaviour
{
private Dictionary<ulong, float> lastPushTimes = new Dictionary<ulong, float>();
private NetworkVariable<float> PushCooldown = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
private NetworkVariable<float> PushRange = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
private NetworkVariable<float> PushForce = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
private NetworkVariable<float> PushCost = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
public override void OnNetworkSpawn()
{
if (((NetworkBehaviour)this).IsServer)
{
PushCooldown.Value = PushCompanyBase.config_PushCooldown.Value;
PushRange.Value = PushCompanyBase.config_PushRange.Value;
PushForce.Value = PushCompanyBase.config_PushForce.Value;
PushCost.Value = PushCompanyBase.config_PushCost.Value;
}
}
[ServerRpc(RequireOwnership = false)]
public void PushServerRpc(ulong playerId)
{
//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)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: 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))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2433198804u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, playerId);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2433198804u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
if (lastPushTimes.TryGetValue(playerId, out var value))
{
if (Time.time - value < PushCooldown.Value)
{
return;
}
}
else
{
lastPushTimes.Add(playerId, 0f);
}
GameObject playerById = GetPlayerById(playerId);
PlayerControllerB component = playerById.GetComponent<PlayerControllerB>();
Camera gameplayCamera = component.gameplayCamera;
if (!CanPushPlayer(component))
{
return;
}
int num = 1 << playerById.layer;
Vector3 forward = ((Component)gameplayCamera).transform.forward;
Vector3 normalized = ((Vector3)(ref forward)).normalized;
RaycastHit[] array = Physics.RaycastAll(((Component)gameplayCamera).transform.position, normalized, PushRange.Value, num);
RaycastHit[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
RaycastHit val3 = array2[i];
if ((Object)(object)((Component)((RaycastHit)(ref val3)).transform).gameObject != (Object)(object)playerById)
{
PlayerControllerB component2 = ((Component)((RaycastHit)(ref val3)).transform).GetComponent<PlayerControllerB>();
if (!component2.inSpecialInteractAnimation)
{
PushClientRpc(((NetworkBehaviour)component).NetworkObjectId, ((NetworkBehaviour)component2).NetworkObjectId, normalized * PushForce.Value * Time.fixedDeltaTime);
lastPushTimes[playerId] = Time.time;
}
break;
}
}
}
[ClientRpc]
private void PushClientRpc(ulong pusherId, ulong playerId, Vector3 push)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: 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(3498116674u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, pusherId);
BytePacker.WriteValueBitPacked(val2, playerId);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref push);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3498116674u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
GameObject playerById = GetPlayerById(playerId);
PlayerControllerB component = playerById.GetComponent<PlayerControllerB>();
((MonoBehaviour)this).StartCoroutine(SmoothMove(component.thisController, push));
component.movementAudio.PlayOneShot(StartOfRound.Instance.playerJumpSFX);
GameObject playerById2 = GetPlayerById(pusherId);
PlayerControllerB component2 = playerById2.GetComponent<PlayerControllerB>();
component2.sprintMeter = Mathf.Clamp(component2.sprintMeter - PushCost.Value, 0f, 1f);
}
}
}
public IEnumerator SmoothMove(CharacterController controller, Vector3 push)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
float force = PushForce.Value / 12.5f;
float smoothTime = ((Vector3)(ref push)).magnitude / force;
Vector3 targetPosition = ((Component)controller).transform.position + push;
Vector3 val = targetPosition - ((Component)controller).transform.position;
Vector3 direction = ((Vector3)(ref val)).normalized;
float distance = Vector3.Distance(((Component)controller).transform.position, targetPosition);
for (float currentTime = 0f; currentTime < smoothTime; currentTime += Time.fixedDeltaTime)
{
float currentDistance = distance * Mathf.Min(currentTime, smoothTime) / smoothTime;
controller.Move(direction * currentDistance);
yield return null;
}
}
private bool CanPushPlayer(PlayerControllerB player)
{
return !player.quickMenuManager.isMenuOpen && !player.inSpecialInteractAnimation && !player.isTypingChat && !player.isExhausted;
}
private static GameObject GetPlayerById(ulong playerId)
{
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(playerId, out var value))
{
return ((Component)value).gameObject;
}
return null;
}
protected override void __initializeVariables()
{
if (PushCooldown == null)
{
throw new Exception("PushComponent.PushCooldown cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)PushCooldown).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)PushCooldown, "PushCooldown");
base.NetworkVariableFields.Add((NetworkVariableBase)(object)PushCooldown);
if (PushRange == null)
{
throw new Exception("PushComponent.PushRange cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)PushRange).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)PushRange, "PushRange");
base.NetworkVariableFields.Add((NetworkVariableBase)(object)PushRange);
if (PushForce == null)
{
throw new Exception("PushComponent.PushForce cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)PushForce).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)PushForce, "PushForce");
base.NetworkVariableFields.Add((NetworkVariableBase)(object)PushForce);
if (PushCost == null)
{
throw new Exception("PushComponent.PushCost cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)PushCost).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)PushCost, "PushCost");
base.NetworkVariableFields.Add((NetworkVariableBase)(object)PushCost);
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_PushComponent()
{
//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
NetworkManager.__rpc_func_table.Add(2433198804u, new RpcReceiveHandler(__rpc_handler_2433198804));
NetworkManager.__rpc_func_table.Add(3498116674u, new RpcReceiveHandler(__rpc_handler_3498116674));
}
private static void __rpc_handler_2433198804(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 playerId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
target.__rpc_exec_stage = (__RpcExecStage)1;
((PushComponent)(object)target).PushServerRpc(playerId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3498116674(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong pusherId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref pusherId);
ulong playerId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
Vector3 push = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref push);
target.__rpc_exec_stage = (__RpcExecStage)2;
((PushComponent)(object)target).PushClientRpc(pusherId, playerId, push);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "PushComponent";
}
}
}