using System;
using System.Diagnostics;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.boxofbiscuits97.PushMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fee319ff8627565cee088500bdeae3bd131f42ce")]
[assembly: AssemblyProduct("com.github.boxofbiscuits97.PushMod")]
[assembly: AssemblyTitle("PushMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace PushMod
{
public class ConfigurationHandler
{
private ConfigEntry<KeyCode> _configPushKey;
private ConfigEntry<KeyCode> _configSelfPushKey;
private ConfigEntry<bool> _configcanCharge;
public KeyCode SelfPushKey => _configSelfPushKey.Value;
public KeyCode PushKey => _configPushKey.Value;
public bool CanCharge => _configcanCharge.Value;
public ConfigurationHandler(Plugin instance)
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
Plugin.Log.LogInfo((object)"PushMod ConfigurationHandler initialising");
_configPushKey = ((BaseUnityPlugin)instance).Config.Bind<KeyCode>("Push Settings", "PushKey", (KeyCode)102, "The keyboard key used to push. Example: F, E, G, etc.");
_configSelfPushKey = ((BaseUnityPlugin)instance).Config.Bind<KeyCode>("Push Settings", "SelfPushKey", (KeyCode)103, "The keyboard key used to push yourself. Example: F, E, G, etc.");
_configcanCharge = ((BaseUnityPlugin)instance).Config.Bind<bool>("Push Settings", "CanCharge", true, "The setting includes charging force when pushed");
Plugin.Log.LogInfo((object)"PushMod Configuration loaded:");
Plugin.Log.LogInfo((object)$" PushKey: {PushKey}");
Plugin.Log.LogInfo((object)$" CanCharge: {CanCharge}");
Plugin.Log.LogInfo((object)"PushMod ConfigurationHandler initialised");
}
}
[BepInPlugin("com.github.boxofbiscuits97.PushMod", "PushMod", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string Id = "com.github.boxofbiscuits97.PushMod";
internal static ManualLogSource Log { get; private set; }
internal static ConfigurationHandler PConfig { get; private set; }
public static string Name => "PushMod";
public static string Version => "1.0.0";
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
PConfig = new ConfigurationHandler(this);
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
Harmony.CreateAndPatchAll(typeof(PushPatch), (string)null);
}
}
public static class PushPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(Character), "Awake")]
public static void AwakePatch(Character __instance)
{
((Component)__instance).gameObject.AddComponent<PushManager>();
Plugin.Log.LogInfo((object)("Added PushManager component to character: " + __instance.characterName));
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GUIManager), "UpdateReticle")]
public static bool ReticlePatch(GUIManager __instance)
{
PushManager pushManager = (PushManager)(object)((Component)Character.localCharacter).GetComponent(typeof(PushManager));
if (pushManager == null)
{
return true;
}
if (pushManager.animationCoolDown > 0f)
{
__instance.SetReticle(__instance.reticleReach);
return false;
}
if (pushManager.isCharging && !pushManager.isPushingSelf && (Object)(object)pushManager.hitCharacter != (Object)null && (Object)(object)pushManager.hitCharacter != (Object)(object)Character.localCharacter)
{
__instance.SetReticle(__instance.reticleShoot);
return false;
}
return true;
}
}
public class PushManager : MonoBehaviour
{
private const float PUSH_RANGE = 2.5f;
private const float PUSH_COOLDOWN = 1f;
private const float PUSH_FORCE_BASE = 500f;
private const float BINGBONG_MULTIPLIER = 10f;
private const float STAMINA_COST = 0.1f;
private const float MAX_CHARGE = 1f;
private const float CHARGE_FORCE_MULTIPLIER = 1.5f;
private const float ANIMATION_TIME = 0.25f;
private const float MAX_STAMINA_COST_MULTIPLIER = 3f;
private Color chargeBarMinColor = new Color(0.3483f, 0.7843f, 0f);
private Color chargeBarMaxColor = new Color(0.749f, 0.9255f, 0.1098f);
private Character localCharacter;
private Character? pushedCharacter;
public Character? hitCharacter;
private float coolDownLeft;
public float animationCoolDown;
private bool bingBong;
public bool isCharging;
public bool isPushingSelf;
public float currentCharge;
private GameObject? chargeBarObject;
private Image? chargeBar;
private Character cachedCharacter;
private Camera mainCamera;
private void Awake()
{
cachedCharacter = ((Component)this).GetComponent<Character>();
if (cachedCharacter == null)
{
Debug.LogError((object)"[PushManager] Character component not found on GameObject!", (Object)(object)((Component)this).gameObject);
((Behaviour)this).enabled = false;
}
else if (cachedCharacter.IsLocal)
{
localCharacter = cachedCharacter;
mainCamera = Camera.main;
if (mainCamera == null)
{
Debug.LogError((object)"[PushManager] Main camera not found!");
((Behaviour)this).enabled = false;
}
}
}
private void Update()
{
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Invalid comparison between Unknown and I4
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
if (coolDownLeft > 0f)
{
coolDownLeft -= Time.deltaTime;
}
if (animationCoolDown > 0f)
{
animationCoolDown -= Time.deltaTime;
}
if (animationCoolDown > 0f && cachedCharacter != null)
{
PlayPushAnimation(cachedCharacter);
}
if (coolDownLeft > 0f || localCharacter == null || !localCharacter.view.IsMine)
{
return;
}
if (!localCharacter.data.fullyConscious || localCharacter.data.isCarried || localCharacter.data.isClimbingAnything)
{
if (Object.op_Implicit((Object)(object)chargeBarObject))
{
chargeBarObject.SetActive(false);
}
return;
}
Item currentItem = localCharacter.data.currentItem;
bingBong = currentItem != null && (int)currentItem.itemTags == 16;
HandleChargeInput();
if (chargeBar == null || chargeBarObject == null)
{
GameObject val = GameObject.Find("GAME/GUIManager/Canvas_HUD/Throw/");
chargeBarObject = Object.Instantiate<GameObject>(val);
((Object)chargeBarObject).name = "PushCharge";
chargeBarObject.transform.parent = val.transform.parent;
chargeBarObject.transform.localPosition = Vector3.zero;
chargeBarObject.transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, 180f));
GameObject gameObject = ((Component)chargeBarObject.transform.Find("BarMask/BarFill/")).gameObject;
gameObject.transform.localScale = new Vector3(1f, -1f, 1f);
chargeBar = gameObject.GetComponent<Image>();
}
chargeBarObject.SetActive(isCharging);
if (isCharging)
{
currentCharge += Time.deltaTime;
currentCharge = Mathf.Clamp(currentCharge, 0f, 1f);
float fillAmount = Mathf.Lerp(0.672f, 0.808f, currentCharge);
Color color = Color.Lerp(chargeBarMinColor, chargeBarMaxColor, currentCharge);
chargeBar.fillAmount = fillAmount;
((Graphic)chargeBar).color = color;
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(((Component)mainCamera).transform.position, ((Component)mainCamera).transform.forward, ref val2, 2.5f, LayerMask.GetMask(new string[1] { "Character" })))
{
hitCharacter = GetCharacter(((Component)((RaycastHit)(ref val2)).transform).gameObject);
}
else
{
hitCharacter = null;
}
}
}
private void HandleChargeInput()
{
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: 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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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)
if (Plugin.PConfig.CanCharge)
{
if ((Input.GetKey(Plugin.PConfig.PushKey) || Input.GetKey(Plugin.PConfig.SelfPushKey)) && !isCharging && coolDownLeft <= 0f)
{
isCharging = true;
currentCharge = 0f;
Plugin.Log.LogInfo((object)"Started charging push...");
}
if (Input.GetKeyUp(Plugin.PConfig.PushKey) && !Input.GetKey(Plugin.PConfig.SelfPushKey) && isCharging)
{
isCharging = false;
isPushingSelf = false;
TryPushTarget(self: false);
}
if (Input.GetKeyUp(Plugin.PConfig.SelfPushKey) && !Input.GetKey(Plugin.PConfig.PushKey) && isCharging)
{
isCharging = false;
isPushingSelf = true;
TryPushTarget(self: true);
}
}
else
{
if (Input.GetKeyDown(Plugin.PConfig.PushKey) && coolDownLeft <= 0f)
{
TryPushTarget(self: false);
}
if (Input.GetKeyDown(Plugin.PConfig.SelfPushKey) && coolDownLeft <= 0f)
{
TryPushTarget(self: true);
}
}
}
private void TryPushTarget(bool self)
{
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: 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_0147: Unknown result type (might be due to invalid IL or missing references)
if (mainCamera == null)
{
return;
}
if (self)
{
pushedCharacter = localCharacter;
}
else
{
pushedCharacter = hitCharacter;
if ((Object)(object)pushedCharacter == (Object)null || (Object)(object)pushedCharacter == (Object)(object)localCharacter)
{
return;
}
}
float num = 1f + currentCharge / 1f * 1.5f;
float num2 = (bingBong ? 10f : 1f);
float num3 = num2 * num;
Vector3 val = ((Component)mainCamera).transform.forward * 500f * num3;
Plugin.Log.LogInfo((object)$"Push force direction: {val}");
if (!self)
{
PlayPushSFX(pushedCharacter);
}
coolDownLeft = 1f;
float num4 = (bingBong ? 1f : (0.1f * (currentCharge / 1f * 3f)));
localCharacter.UseStamina(num4, true);
Plugin.Log.LogInfo((object)"Sending Push RPC Event");
localCharacter.view.RPC("PushPlayer_Rpc", (RpcTarget)0, new object[3]
{
pushedCharacter.view.ViewID,
val,
localCharacter.view.ViewID
});
}
private Character? GetCharacter(GameObject? obj)
{
if (obj == null)
{
return null;
}
Character result = default(Character);
if (obj.TryGetComponent<Character>(ref result))
{
return result;
}
Transform parent = obj.transform.parent;
if (parent != null)
{
return GetCharacter(((Component)parent).gameObject);
}
return null;
}
private void PlayPushAnimation(Character? character)
{
if (character != null)
{
character.refs.animator.Play("A_Scout_Reach_Straight");
}
}
private void PlayPushSFX(Character character)
{
Transform val = ((Component)character).gameObject.transform.Find("Scout").Find("SFX").Find("Movement")
.Find("SFX Jump");
if (val == null)
{
Plugin.Log.LogError((object)"Could not find sound effect for pushed character.");
}
else
{
((Component)val).gameObject.SetActive(true);
}
}
[PunRPC]
private void PushPlayer_Rpc(int viewID, Vector3 force, int senderID)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
Plugin.Log.LogInfo((object)$"Received Push RPC Event for ID: {viewID}, Force: {force}, from SenderID: {senderID}");
Character val = default(Character);
if (Character.GetCharacterWithPhotonID(senderID, ref val))
{
PushManager pushManager = default(PushManager);
if (((Component)val).TryGetComponent<PushManager>(ref pushManager))
{
pushManager.animationCoolDown = 0.25f;
}
}
else
{
Plugin.Log.LogWarning((object)$"Could not find character with photon ID: {senderID}");
}
if (localCharacter == null)
{
localCharacter = Character.AllCharacters.First((Character c) => c.IsLocal);
if (localCharacter == null)
{
Plugin.Log.LogError((object)"Failed to find local character in PushPlayer_Rpc.");
return;
}
}
int viewID2 = localCharacter.view.ViewID;
if (viewID != viewID2)
{
Plugin.Log.LogInfo((object)$"Local Player ID: {viewID2} is not the pushed ID: {viewID}");
return;
}
PlayPushSFX(localCharacter);
localCharacter.AddForce(force, 1f, 1f);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}