using System;
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 BaronDrakula.MoreCounterplay.NetcodePatcher;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CSync.Extensions;
using CSync.Lib;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using MoreCounterplay.Behaviours;
using MoreCounterplay.Config;
using MoreCounterplay.Items;
using MoreCounterplay.Patches;
using MoreCounterplay.Util;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Events;
[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("BaronDrakula.MoreCounterplay")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyInformationalVersion("1.5.0+becd5ffea927c2d13a79c75d4bd1546b07b45447")]
[assembly: AssemblyProduct("MoreCounterplay")]
[assembly: AssemblyTitle("BaronDrakula.MoreCounterplay")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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 MoreCounterplay
{
[BepInPlugin("BaronDrakula.MoreCounterplay", "MoreCounterplay", "1.5.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency("com.sigurd.csync", "5.0.1")]
public class MoreCounterplay : BaseUnityPlugin
{
public static AssetBundle? Bundle;
public static MoreCounterplay Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony Harmony { get; set; }
internal static ConfigSettings Settings { get; set; }
private void Awake()
{
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
Settings = new ConfigSettings(((BaseUnityPlugin)this).Config);
NetcodePatcher();
LoadAssets();
Patch();
Logger.LogInfo((object)"BaronDrakula.MoreCounterplay v1.5.0 has loaded!");
}
private void LoadAssets()
{
Log("Loading Assets...");
Bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "morecounterplayassets"));
GameObject val = Bundle.LoadAsset<GameObject>("JesterSurface.prefab");
val.AddComponent<JesterSurface>();
JesterSurface.JesterSurfacePrefab = val;
NetworkPrefabs.RegisterNetworkPrefab(val);
CoilExplosion.RadioactiveFirePrefab = Bundle.LoadAsset<GameObject>("RadioactiveFire.prefab");
Item val2 = Bundle.LoadAsset<Item>("CoillessCoilhead.asset");
((GrabbableObject)val2.spawnPrefab.AddComponent<HeadItem>()).itemProperties = val2;
HeadItem.Prefab = val2.spawnPrefab;
Items.RegisterItem(val2);
NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
GameObject val3 = Bundle.LoadAsset<GameObject>("FeioparAdditionalData.prefab");
val3.AddComponent<FeioparPatch.FeioparAdditionalData>();
FeioparPatch.FeioparAdditionalData.FeioparAdditionalDataPrefab = val3;
NetworkPrefabs.RegisterNetworkPrefab(val3);
}
internal static void Patch()
{
//IL_000c: 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_0017: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("BaronDrakula.MoreCounterplay");
}
Harmony.PatchAll();
}
private static void NetcodePatcher()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
foreach (Type type in types)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
}
public static void Log(string message)
{
Logger.LogInfo((object)message);
}
public static void LogDebug(string message)
{
Logger.LogDebug((object)message);
}
public static void LogError(string message)
{
Logger.LogError((object)message);
}
public static void LogWarning(string message)
{
Logger.LogWarning((object)message);
}
public static bool IsModLoaded(string guid)
{
return Chainloader.PluginInfos.ContainsKey(guid);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "BaronDrakula.MoreCounterplay";
public const string PLUGIN_NAME = "MoreCounterplay";
public const string PLUGIN_VERSION = "1.5.0";
}
}
namespace MoreCounterplay.Util
{
internal class VanillaPrefabUtils
{
internal static bool GetInsideEnemyPrefab(string enemyName, out GameObject? enemyPrefab)
{
string enemyName2 = enemyName;
enemyPrefab = null;
for (int i = 0; i < StartOfRound.Instance.levels.Length; i++)
{
EnemyType val = StartOfRound.Instance.levels[i]?.Enemies?.Find((SpawnableEnemyWithRarity enemy) => string.CompareOrdinal(enemy.enemyType.enemyName, enemyName2) == 0)?.enemyType;
if ((Object)(object)val != (Object)null)
{
enemyPrefab = val.enemyPrefab;
return true;
}
}
MoreCounterplay.LogWarning("Could not find enemy '" + enemyName2 + "' in any moon's list of spawns.");
return false;
}
internal static bool GetOutsideEnemyPrefab(string enemyName, out GameObject? enemyPrefab)
{
string enemyName2 = enemyName;
enemyPrefab = null;
for (int i = 0; i < StartOfRound.Instance.levels.Length; i++)
{
EnemyType val = StartOfRound.Instance.levels[i]?.OutsideEnemies?.Find((SpawnableEnemyWithRarity enemy) => string.CompareOrdinal(enemy.enemyType.enemyName, enemyName2) == 0)?.enemyType;
if ((Object)(object)val != (Object)null)
{
enemyPrefab = val.enemyPrefab;
return true;
}
}
MoreCounterplay.LogWarning("Could not find enemy '" + enemyName2 + "' in any moon's list of spawns.");
return false;
}
}
}
namespace MoreCounterplay.Patches
{
[HarmonyPatch]
internal class CoilheadPatch
{
private const int SHOVEL_HIT_ID = 1;
private const int KNIFE_HIT_ID = 5;
[HarmonyPatch(typeof(EnemyAI), "HitEnemy")]
[HarmonyPostfix]
private static void HitCoilhead(EnemyAI __instance, int hitID = -1)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
if (!SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableCoilheadCounterplay) || __instance.isEnemyDead || ((object)__instance).GetType() != typeof(SpringManAI))
{
return;
}
SpringManAI val = (SpringManAI)__instance;
if (val.inCooldownAnimation)
{
MoreCounterplay.Log("Coilhead hit negated.");
return;
}
int num = SyncedEntry<int>.op_Implicit((SyncedEntry<int>)(hitID switch
{
5 => MoreCounterplay.Settings.CoilheadKnifeDamage,
1 => MoreCounterplay.Settings.CoilheadShovelDamage,
_ => MoreCounterplay.Settings.CoilheadDefaultDamage,
}));
MoreCounterplay.Log($"Coilhead hit for {num} damage on server.");
((EnemyAI)val).enemyHP = ((EnemyAI)val).enemyHP - num;
if (((EnemyAI)val).enemyHP <= 0)
{
MoreCounterplay.Log("Coilhead killed!");
((EnemyAI)val).KillEnemyOnOwnerClient(false);
}
}
[HarmonyPatch(typeof(EnemyAI), "KillEnemy")]
[HarmonyPostfix]
private static void KillCoilhead(EnemyAI __instance)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
if (SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableCoilheadCounterplay) && !(((object)__instance).GetType() != typeof(SpringManAI)))
{
SpringManAI val = (SpringManAI)__instance;
ResetCoilhead(val);
val.DoSpringAnimation(true);
IgniteCoilhead(val, SpawnHead(val));
}
}
private static void ResetCoilhead(SpringManAI coilhead)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
coilhead.hasStopped = true;
((EnemyAI)coilhead).creatureAnimator.SetFloat("walkSpeed", 0f);
coilhead.currentAnimSpeed = 0f;
coilhead.mainCollider.isTrigger = false;
if (((NetworkBehaviour)coilhead).IsOwner)
{
((EnemyAI)coilhead).agent.speed = 0f;
((EnemyAI)coilhead).movingTowardsTargetPlayer = false;
((EnemyAI)coilhead).SetDestinationToPosition(((Component)coilhead).transform.position, false);
}
}
private static GameObject? SpawnHead(SpringManAI coilhead)
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
if ((!((NetworkBehaviour)coilhead).IsServer && !((NetworkBehaviour)coilhead).IsHost) || !SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.DropHeadAsScrap))
{
return null;
}
if ((Object)(object)HeadItem.Prefab == (Object)null)
{
MoreCounterplay.LogWarning("'Coilless Coilhead' prefab did not load correctly or is missing; it will not be spawned.");
return null;
}
GameObject gameObject = ((Component)((EnemyAI)coilhead).meshRenderers.First((MeshRenderer mesh) => ((Object)mesh).name == "Head")).gameObject;
GameObject val = Object.Instantiate<GameObject>(HeadItem.Prefab, gameObject.transform.position, gameObject.transform.rotation);
NetworkObject val2 = default(NetworkObject);
HeadItem headItem = default(HeadItem);
if (!val.TryGetComponent<NetworkObject>(ref val2) || !val.TryGetComponent<HeadItem>(ref headItem))
{
MoreCounterplay.LogWarning("'Coilless Coilhead' instance has missing components; it will not be spawned.");
Object.Destroy((Object)(object)val);
return null;
}
val2.Spawn(false);
((GrabbableObject)headItem).SetScrapValue(HeadItem.Random.Next(SyncedEntry<int>.op_Implicit(MoreCounterplay.Settings.MinHeadValue), SyncedEntry<int>.op_Implicit(MoreCounterplay.Settings.MaxHeadValue) + 1));
headItem.AttachItemClientRpc(NetworkObjectReference.op_Implicit(((EnemyAI)coilhead).thisNetworkObject));
RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val2) }, new int[1] { ((GrabbableObject)headItem).scrapValue });
return val;
}
private static void IgniteCoilhead(SpringManAI coilhead, GameObject? scrapHead)
{
if (!SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.LoreAccurateCoilheads))
{
return;
}
Transform obj = ((Component)coilhead).transform.Find("SpringManModel/RadioactiveFire");
if (obj != null)
{
GameObject gameObject = ((Component)obj).gameObject;
if (gameObject != null)
{
gameObject.SetActive(true);
}
}
if (((NetworkBehaviour)coilhead).IsServer || ((NetworkBehaviour)coilhead).IsHost)
{
CoilExplosion coilExplosion = default(CoilExplosion);
if (!((Component)coilhead).TryGetComponent<CoilExplosion>(ref coilExplosion))
{
MoreCounterplay.LogWarning("Coilhead CoilExplosion script did not load correctly or is missing; explosion will not happen.");
return;
}
coilExplosion.HeadContainer = scrapHead;
coilExplosion.UpdateScanNodeClientRpc(ignited: true);
coilExplosion.TimeLeft = Mathf.Clamp(coilExplosion.TimeSinceLastStop, SyncedEntry<float>.op_Implicit(MoreCounterplay.Settings.MinExplosionTimer), SyncedEntry<float>.op_Implicit(MoreCounterplay.Settings.MaxExplosionTimer));
coilExplosion.Ticking = true;
((Behaviour)coilExplosion).enabled = true;
}
}
[HarmonyPatch(typeof(SpringManAI), "SetAnimationGoServerRpc")]
[HarmonyPostfix]
private static void OnStartedMoving(SpringManAI __instance)
{
CoilExplosion coilExplosion = default(CoilExplosion);
if ((((NetworkBehaviour)__instance).IsServer || ((NetworkBehaviour)__instance).IsHost) && SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.LoreAccurateCoilheads) && ((Component)__instance).TryGetComponent<CoilExplosion>(ref coilExplosion))
{
coilExplosion.TimeSinceLastStop = 0f;
((Behaviour)coilExplosion).enabled = true;
}
}
[HarmonyPatch(typeof(SpringManAI), "SetAnimationStopServerRpc")]
[HarmonyPostfix]
private static void OnStoppedMoving(SpringManAI __instance)
{
CoilExplosion coilExplosion = default(CoilExplosion);
if ((((NetworkBehaviour)__instance).IsServer || ((NetworkBehaviour)__instance).IsHost) && SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.LoreAccurateCoilheads) && ((Component)__instance).TryGetComponent<CoilExplosion>(ref coilExplosion))
{
((Behaviour)coilExplosion).enabled = false;
}
}
}
[HarmonyPatch]
public class FeioparPatch
{
public class FeioparAdditionalData : NetworkBehaviour
{
public bool ActiveLaserPointerInRange;
public bool WaitForTreeDrop;
public float ClosestLaserDistance;
public Vector3 LastLaserPosition;
public int PumaAttackAnimationHash;
public static GameObject? FeioparAdditionalDataPrefab { get; internal set; }
public PumaAI? Puma { get; internal set; }
public override void OnNetworkSpawn()
{
((NetworkBehaviour)this).OnNetworkSpawn();
Transform transform = ((Component)this).transform;
GameObject? feioparAdditionalDataPrefab = FeioparAdditionalDataPrefab;
((Object)transform).name = ((feioparAdditionalDataPrefab != null) ? ((Object)feioparAdditionalDataPrefab).name : null);
}
public void Start()
{
//IL_0059: 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)
PumaAI puma = default(PumaAI);
if (((Component)((Component)this).transform.GetParent()).TryGetComponent<PumaAI>(ref puma))
{
Puma = puma;
}
if ((Object)(object)Puma == (Object)null)
{
MoreCounterplay.LogError("Feiopar additional data instance could not find its PumaAI component in its parent object; its counterplay will not work.");
return;
}
ActiveLaserPointerInRange = false;
WaitForTreeDrop = false;
ClosestLaserDistance = float.MaxValue;
LastLaserPosition = ((Component)Puma).transform.position;
PumaAttackAnimationHash = Animator.StringToHash("Base Layer.PumaAttack1");
AddBehaviourState(Puma);
AllowHittingEnemies(Puma);
}
private void AddBehaviourState(PumaAI pumaAI)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
((EnemyAI)pumaAI).enemyBehaviourStates = CollectionExtensions.AddToArray<EnemyBehaviourState>(((EnemyAI)pumaAI).enemyBehaviourStates, new EnemyBehaviourState
{
name = "AttackLaserPointer"
});
}
private void AllowHittingEnemies(PumaAI pumaAI)
{
EnemyAICollisionDetect componentInChildren = ((Component)pumaAI).GetComponentInChildren<EnemyAICollisionDetect>();
if (!componentInChildren.canCollideWithEnemies)
{
componentInChildren.canCollideWithEnemies = SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.CanDamageEnemiesWhileAttackingLaser);
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
((NetworkBehaviour)this).__initializeRpcs();
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string? __getTypeName()
{
return "FeioparAdditionalData";
}
}
[HarmonyPatch(typeof(PumaAI), "Start")]
[HarmonyPostfix]
public static void OnSpawn(PumaAI __instance)
{
if ((!((NetworkBehaviour)__instance).IsServer && !((NetworkBehaviour)__instance).IsHost) || !SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableFeioparCounterplay))
{
return;
}
if ((Object)(object)FeioparAdditionalData.FeioparAdditionalDataPrefab == (Object)null)
{
MoreCounterplay.LogError("Feiopar additional data prefab did not load correctly or is missing; its counterplay will not work.");
return;
}
GameObject val = Object.Instantiate<GameObject>(FeioparAdditionalData.FeioparAdditionalDataPrefab);
((Object)val).name = ((Object)FeioparAdditionalData.FeioparAdditionalDataPrefab).name;
NetworkObject val2 = default(NetworkObject);
if (val.TryGetComponent<NetworkObject>(ref val2))
{
val2.Spawn(false);
val.transform.SetParent(((Component)__instance).transform, false);
}
}
[HarmonyPatch(typeof(PumaAI), "DoAIInterval")]
[HarmonyPostfix]
private static void CheckNearbyPlayersForLasers(PumaAI __instance)
{
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
FeioparAdditionalData feioparAdditionalData = default(FeioparAdditionalData);
if (!SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableFeioparCounterplay) || StartOfRound.Instance.livingPlayers == 0 || ((EnemyAI)__instance).isEnemyDead || !((Component)((Component)__instance).transform.Find("FeioparAdditionalData")).TryGetComponent<FeioparAdditionalData>(ref feioparAdditionalData))
{
return;
}
feioparAdditionalData.ActiveLaserPointerInRange = false;
feioparAdditionalData.ClosestLaserDistance = float.MaxValue;
foreach (PlayerControllerB nearPlayer in __instance.nearPlayers)
{
GrabbableObject currentlyHeldObjectServer = nearPlayer.currentlyHeldObjectServer;
if ((Object)(object)currentlyHeldObjectServer == (Object)null || !currentlyHeldObjectServer.itemProperties.itemName.ToLower().Contains("laser") || !currentlyHeldObjectServer.itemProperties.itemName.ToLower().Contains("pointer") || !currentlyHeldObjectServer.isBeingUsed)
{
continue;
}
Vector3 position = ((Component)((FlashlightItem)currentlyHeldObjectServer).flashlightBulb).transform.position;
if (!DoRaycast(position, ((Component)currentlyHeldObjectServer).transform.forward, out var hit))
{
continue;
}
float num = Vector3.Distance(((Component)__instance).transform.position, ((RaycastHit)(ref hit)).point);
if (!(num > SyncedEntry<float>.op_Implicit(MoreCounterplay.Settings.FeioparLaserPointerEffectiveRange)))
{
if (feioparAdditionalData.ClosestLaserDistance < num)
{
break;
}
feioparAdditionalData.ActiveLaserPointerInRange = true;
feioparAdditionalData.ClosestLaserDistance = num;
feioparAdditionalData.LastLaserPosition = ((RaycastHit)(ref hit)).point;
if (__instance.clingingToTree && !feioparAdditionalData.WaitForTreeDrop)
{
feioparAdditionalData.WaitForTreeDrop = true;
ForceTreeDrop(__instance);
break;
}
if (feioparAdditionalData.WaitForTreeDrop)
{
break;
}
if (((EnemyAI)__instance).currentBehaviourStateIndex != 3)
{
((EnemyAI)__instance).SwitchToBehaviourState(3);
}
}
}
}
private static bool DoRaycast(Vector3 origin, Vector3 direction, out RaycastHit hit)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
hit = default(RaycastHit);
RaycastHit[] array = Physics.RaycastAll(origin, direction);
if (array.Length == 0)
{
return false;
}
IOrderedEnumerable<RaycastHit> orderedEnumerable = array.OrderBy((RaycastHit x) => ((RaycastHit)(ref x)).distance);
foreach (RaycastHit item in orderedEnumerable)
{
RaycastHit current = item;
if (!((Object)(object)((Component)((RaycastHit)(ref current)).transform).GetComponentInParent<PumaAI>() != (Object)null))
{
hit = current;
break;
}
}
return true;
}
private static void ForceTreeDrop(PumaAI __instance)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsServer || ((NetworkBehaviour)__instance).IsHost)
{
MoreCounterplay.Log("Feiopar: Force tree drop");
if (__instance.StartTreeDropOnLocalClient(false))
{
__instance.StartTreeDropRpc(__instance.clingIdlePosition, __instance.leapFromPosition, __instance.treeClingRotation, false);
}
}
}
[HarmonyPatch(typeof(PumaAI), "EndDroppingDownAnimationOnLocalClient")]
[HarmonyPrefix]
private static bool InterceptTreeDropComplete(PumaAI __instance)
{
//IL_0063: 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_007d: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)__instance).IsServer && !((NetworkBehaviour)__instance).IsHost)
{
return false;
}
if (!SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableFeioparCounterplay))
{
return true;
}
FeioparAdditionalData feioparAdditionalData = default(FeioparAdditionalData);
if (!((Component)((Component)__instance).transform.Find("FeioparAdditionalData")).TryGetComponent<FeioparAdditionalData>(ref feioparAdditionalData))
{
return true;
}
if (feioparAdditionalData.WaitForTreeDrop)
{
MoreCounterplay.Log("Feiopar: Completed tree drop - switching to laser attack");
((EnemyAI)__instance).inSpecialAnimation = false;
((EnemyAI)__instance).serverPosition = ((Component)__instance).transform.position;
__instance.clingingToTree = false;
__instance.relocatingToNewTree = false;
__instance.treeState = (TreeState)1;
((EnemyAI)__instance).creatureAnimator.SetBool("TreeMode", false);
((EnemyAI)__instance).creatureAnimator.SetBool("Dropping", false);
((EnemyAI)__instance).creatureAnimator.SetBool("Climbing", false);
__instance.timeAtLastDrop = Time.realtimeSinceStartup;
if (!((Behaviour)((EnemyAI)__instance).agent).enabled)
{
((Behaviour)((EnemyAI)__instance).agent).enabled = true;
}
((EnemyAI)__instance).SwitchToBehaviourStateOnLocalClient(3);
feioparAdditionalData.WaitForTreeDrop = false;
return false;
}
return true;
}
[HarmonyPatch(typeof(PumaAI), "Update")]
[HarmonyPostfix]
private static void FeioparUpdate(PumaAI __instance)
{
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_031a: Unknown result type (might be due to invalid IL or missing references)
//IL_0335: Unknown result type (might be due to invalid IL or missing references)
//IL_0344: Unknown result type (might be due to invalid IL or missing references)
if (!SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableFeioparCounterplay))
{
return;
}
if (((NetworkBehaviour)__instance).IsOwner && !((NetworkBehaviour)__instance).IsHost)
{
((EnemyAI)__instance).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
}
else
{
FeioparAdditionalData feioparAdditionalData = default(FeioparAdditionalData);
if (!((Component)((Component)__instance).transform.Find("FeioparAdditionalData")).TryGetComponent<FeioparAdditionalData>(ref feioparAdditionalData))
{
return;
}
int currentBehaviourStateIndex = ((EnemyAI)__instance).currentBehaviourStateIndex;
if (currentBehaviourStateIndex != 3)
{
return;
}
if (__instance.previousState != ((EnemyAI)__instance).currentBehaviourStateIndex)
{
MoreCounterplay.Log("Feiopar: Initialize laser attack state");
__instance.TargetTree = null;
__instance.clingingToTree = false;
__instance.stalkingFrozen = false;
__instance.stalkingFrozenAnim = false;
__instance.hidingQuickly = false;
((EnemyAI)__instance).inSpecialAnimation = false;
__instance.wasOwnerLastFrame = false;
__instance.stopStalkingTimer = 0f;
__instance.leapAttempts = 0;
((EnemyAI)__instance).creatureAnimator.SetBool("Attacking", true);
((EnemyAI)__instance).creatureAnimator.SetBool("Running", false);
((EnemyAI)__instance).creatureAnimator.SetBool("TreeMode", false);
((EnemyAI)__instance).creatureAnimator.SetBool("Climbing", false);
((EnemyAI)__instance).creatureAnimator.SetBool("Startled", false);
((EnemyAI)__instance).creatureAnimator.Play(feioparAdditionalData.PumaAttackAnimationHash);
__instance.attackSFX.clip = __instance.attackScream;
__instance.attackSFX.pitch = Random.Range(0.94f, 1.1f);
__instance.growlSource.Stop();
((EnemyAI)__instance).creatureSFX.clip = __instance.pumaRunSFX;
((EnemyAI)__instance).creatureSFX.Play();
__instance.previousState = ((EnemyAI)__instance).currentBehaviourStateIndex;
}
if (!feioparAdditionalData.ActiveLaserPointerInRange)
{
((EnemyAI)__instance).SwitchToBehaviourState(0);
return;
}
Vector3 lastLaserPosition = feioparAdditionalData.LastLaserPosition;
if (((NetworkBehaviour)__instance).IsOwner && ((Behaviour)((EnemyAI)__instance).agent).enabled)
{
((EnemyAI)__instance).SetDestinationToPosition(lastLaserPosition, false);
((EnemyAI)__instance).movingTowardsTargetPlayer = false;
((EnemyAI)__instance).moveTowardsDestination = true;
}
((EnemyAI)__instance).agent.stoppingDistance = 2.6f;
((EnemyAI)__instance).agent.speed = __instance.attackRunSpeed;
((EnemyAI)__instance).agent.acceleration = __instance.attackAcceleration;
float num = Vector3.Distance(((Component)__instance).transform.position, lastLaserPosition);
__instance.scratching = num < 6f;
((EnemyAI)__instance).creatureAnimator.SetBool("Scratching", __instance.scratching);
if (num < 6f)
{
if (!__instance.startedScreamingInAttack)
{
__instance.startedScreamingInAttack = true;
__instance.attackSFX.Play();
__instance.attackSFXFaraway.Play();
}
__instance.attackSFX.volume = Mathf.Lerp(__instance.attackSFX.volume, 1f, 10f * Time.deltaTime);
__instance.attackSFXFaraway.volume = Mathf.Lerp(__instance.attackSFXFaraway.volume, 1f, 10f * Time.deltaTime);
}
if (((NetworkBehaviour)__instance).IsOwner)
{
__instance.turnCompass.LookAt(lastLaserPosition);
__instance.turnCompass.eulerAngles = new Vector3(0f, __instance.turnCompass.eulerAngles.y, 0f);
((Component)__instance).transform.rotation = Quaternion.Lerp(((Component)__instance).transform.rotation, __instance.turnCompass.rotation, 10f * Time.deltaTime);
((Component)__instance).transform.localEulerAngles = new Vector3(0f, ((Component)__instance).transform.localEulerAngles.y, 0f);
}
if (((NetworkBehaviour)__instance).IsOwner && ((Behaviour)((EnemyAI)__instance).agent).enabled)
{
__instance.CalculateAnimationDirection(1f);
}
}
}
[HarmonyPatch(typeof(PumaAI), "AnimationEventC")]
[HarmonyPostfix]
private static void ScratchAnimationEvent(PumaAI __instance)
{
FeioparAdditionalData feioparAdditionalData = default(FeioparAdditionalData);
if (SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableFeioparCounterplay) && ((EnemyAI)__instance).currentBehaviourStateIndex == 3 && ((Component)((Component)__instance).transform.Find("FeioparAdditionalData")).TryGetComponent<FeioparAdditionalData>(ref feioparAdditionalData))
{
RoundManager.PlayRandomClip(((EnemyAI)__instance).creatureSFX, __instance.scratchSFX, true, Random.Range(0.6f, 1f), 0, 1000);
}
}
[HarmonyPatch(typeof(PumaAI), "OnCollideWithPlayer")]
[HarmonyPrefix]
private static void OnCollideWithPlayer(PumaAI __instance, Collider other)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
if (SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableFeioparCounterplay) && SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.CanDamagePlayerWhileAttackingLaser) && !((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).currentBehaviourStateIndex == 3)
{
PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false);
if (!((Object)(object)val == (Object)null))
{
Vector3 val2 = Vector3.Normalize(((Component)val.playerEye).transform.position - __instance.pushPoint.position) * __instance.scratchPushForce + Random.onUnitSphere * Random.Range(0f, 10f);
val.externalForceAutoFade += val2;
MoreCounterplay.Log("Feiopar: Deal damage to player " + ((Object)val).name);
val.DamagePlayer(7, true, true, (CauseOfDeath)18, 10, false, val2 * 1.25f);
val.AddBloodToBody();
__instance.PumaDamagePlayerRpc((int)val.playerClientId);
HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
}
}
}
[HarmonyPatch(typeof(EnemyAI), "OnCollideWithEnemy")]
[HarmonyPostfix]
private static void OnCollideWithEnemy(EnemyAI __instance, Collider other, EnemyAI collidedEnemy)
{
if ((((NetworkBehaviour)__instance).IsServer || ((NetworkBehaviour)__instance).IsHost) && SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableFeioparCounterplay) && SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.CanDamageEnemiesWhileAttackingLaser) && !__instance.isEnemyDead && !(((object)__instance).GetType() != typeof(PumaAI)) && __instance.currentBehaviourStateIndex == 3 && !((Object)(object)collidedEnemy == (Object)null) && !((Object)(object)collidedEnemy.enemyType == (Object)(object)__instance.enemyType) && collidedEnemy.enemyType.canDie)
{
MoreCounterplay.Log("Feiopar: Deal damage to enemy " + ((Object)collidedEnemy).name);
collidedEnemy.HitEnemy(SyncedEntry<int>.op_Implicit(MoreCounterplay.Settings.FeioparEnemyHitForce), (PlayerControllerB)null, true, -1);
}
}
}
[HarmonyPatch]
internal class JesterPatch
{
[HarmonyPatch(typeof(JesterAI), "Start")]
[HarmonyPostfix]
public static void OnSpawn(JesterAI __instance)
{
if ((!((NetworkBehaviour)__instance).IsServer && !((NetworkBehaviour)__instance).IsHost) || !SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableJesterCounterplay))
{
return;
}
if ((Object)(object)JesterSurface.JesterSurfacePrefab == (Object)null)
{
MoreCounterplay.LogWarning("Jester surface prefab did not load correctly or is missing; its counterplay will not work.");
return;
}
GameObject val = Object.Instantiate<GameObject>(JesterSurface.JesterSurfacePrefab);
((Object)val).name = ((Object)JesterSurface.JesterSurfacePrefab).name;
NetworkObject val2 = default(NetworkObject);
if (val.TryGetComponent<NetworkObject>(ref val2))
{
val2.Spawn(false);
val.transform.SetParent(((Component)__instance).transform, false);
}
}
[HarmonyPatch(typeof(EnemyAI), "SwitchToBehaviourState")]
[HarmonyPrefix]
public static void CheckJesterHead(EnemyAI __instance, ref int stateIndex)
{
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
if ((!((NetworkBehaviour)__instance).IsServer && !((NetworkBehaviour)__instance).IsHost) || !SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableJesterCounterplay) || ((object)__instance).GetType() != typeof(JesterAI))
{
return;
}
Transform obj = ((Component)__instance).transform.Find("JesterSurface");
JesterSurface jesterSurface = default(JesterSurface);
if (obj == null || !((Component)obj).TryGetComponent<JesterSurface>(ref jesterSurface))
{
return;
}
switch (stateIndex)
{
case 0:
case 1:
if (SyncedEntry<float>.op_Implicit(MoreCounterplay.Settings.JesterPanicThreshold) > 0f && jesterSurface.TotalWeight >= SyncedEntry<float>.op_Implicit(MoreCounterplay.Settings.JesterPanicThreshold))
{
MoreCounterplay.Log("Uh oh...");
stateIndex = 2;
jesterSurface.SwitchAnimationClientRpc(panic: true);
}
break;
case 2:
if (SyncedEntry<float>.op_Implicit(MoreCounterplay.Settings.JesterPreventThreshold) > 0f && jesterSurface.TotalWeight >= SyncedEntry<float>.op_Implicit(MoreCounterplay.Settings.JesterPreventThreshold))
{
MoreCounterplay.Log("Preventing Jester from popping...");
stateIndex = 0;
jesterSurface.SwitchAnimationClientRpc();
}
else
{
jesterSurface.DropAllItemsOnClient();
jesterSurface.DropAllItemsServerRpc(NetworkObjectReference.op_Implicit(((Component)GameNetworkManager.Instance.localPlayerController).GetComponent<NetworkObject>()));
}
break;
}
}
[HarmonyPatch(typeof(GrabbableObject), "GrabItem")]
[HarmonyPrefix]
public static void GrabItem(GrabbableObject __instance)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsOwner && SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableJesterCounterplay))
{
Transform parent = ((Component)__instance).transform.GetParent();
JesterSurface jesterSurface = default(JesterSurface);
if (parent != null && ((Component)parent).TryGetComponent<JesterSurface>(ref jesterSurface))
{
jesterSurface.RemoveItemOnClient(__instance);
jesterSurface.RemoveItemServerRpc(NetworkObjectReference.op_Implicit(((Component)GameNetworkManager.Instance.localPlayerController).GetComponent<NetworkObject>()), NetworkObjectReference.op_Implicit(((Component)__instance).GetComponent<NetworkObject>()));
}
}
}
[HarmonyPatch(typeof(EnemyAI), "HitEnemy")]
[HarmonyPrefix]
private static void HitJester(EnemyAI __instance, PlayerControllerB playerWhoHit, int hitID = -1)
{
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)playerWhoHit == (Object)null) && ((NetworkBehaviour)playerWhoHit).IsOwner && SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableJesterCounterplay) && !__instance.isEnemyDead && !(((object)__instance).GetType() != typeof(JesterAI)) && __instance.currentBehaviourStateIndex != 2 && hitID == 1 && SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.DropItemsOnHit))
{
Transform obj = ((Component)__instance).transform.Find("JesterSurface");
JesterSurface jesterSurface = default(JesterSurface);
if (obj != null && ((Component)obj).TryGetComponent<JesterSurface>(ref jesterSurface))
{
jesterSurface.DropAllItemsOnClient(hit: true);
jesterSurface.DropAllItemsServerRpc(NetworkObjectReference.op_Implicit(((Component)playerWhoHit).GetComponent<NetworkObject>()), hit: true);
}
}
}
[HarmonyPatch(typeof(EnemyAI), "KillEnemy")]
[HarmonyPrefix]
private static void KillJester(EnemyAI __instance)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsOwner && SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableJesterCounterplay) && !__instance.isEnemyDead && !(((object)__instance).GetType() != typeof(JesterAI)))
{
Transform obj = ((Component)__instance).transform.Find("JesterSurface");
JesterSurface jesterSurface = default(JesterSurface);
if (obj != null && ((Component)obj).TryGetComponent<JesterSurface>(ref jesterSurface))
{
jesterSurface.DropAllItemsOnClient(hit: true);
jesterSurface.DropAllItemsServerRpc(NetworkObjectReference.op_Implicit(((Component)GameNetworkManager.Instance.localPlayerController).GetComponent<NetworkObject>()), hit: true);
}
}
}
}
[HarmonyPatch]
internal class LoadPatches
{
[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
[HarmonyPostfix]
private static void OnDisconnect()
{
GameObject? radioactiveFirePrefab = CoilExplosion.RadioactiveFirePrefab;
if (radioactiveFirePrefab != null)
{
radioactiveFirePrefab.transform.SetParent((Transform)null, false);
}
GameObject? coilheadPrefab = CoilExplosion.CoilheadPrefab;
Object.Destroy((Object)(object)((coilheadPrefab != null) ? coilheadPrefab.GetComponent<CoilExplosion>() : null));
GameObject? coilheadPrefab2 = CoilExplosion.CoilheadPrefab;
SpringManAI val = default(SpringManAI);
if (coilheadPrefab2 != null && coilheadPrefab2.TryGetComponent<SpringManAI>(ref val))
{
((EnemyAI)val).enemyHP = 3;
((EnemyAI)val).enemyType.canDie = false;
}
}
internal static void FindAndModifyPrefabs()
{
if (!SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableCoilheadCounterplay))
{
return;
}
MoreCounterplay.Log("Loading prefab textures...");
if (VanillaPrefabUtils.GetInsideEnemyPrefab("Spring", out GameObject enemyPrefab))
{
CoilExplosion.CoilheadPrefab = enemyPrefab;
if ((Object)(object)HeadItem.Prefab != (Object)null && (Object)(object)enemyPrefab != (Object)null)
{
SpringManAI component = enemyPrefab.GetComponent<SpringManAI>();
((EnemyAI)component).enemyHP = SyncedEntry<int>.op_Implicit(MoreCounterplay.Settings.SpringDurability);
((EnemyAI)component).enemyType.canDie = true;
if (SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.LoreAccurateCoilheads))
{
((Behaviour)enemyPrefab.AddComponent<CoilExplosion>()).enabled = false;
if ((Object)(object)CoilExplosion.RadioactiveFirePrefab != (Object)null && (MoreCounterplay.Settings.ExplosionFire.Value || MoreCounterplay.Settings.ExplosionParticles.Value))
{
CoilExplosion.RadioactiveFirePrefab.transform.SetParent(enemyPrefab.transform.Find("SpringManModel"), false);
CoilExplosion.RadioactiveFirePrefab.SetActive(false);
((Behaviour)((Component)CoilExplosion.RadioactiveFirePrefab.transform.Find("FireLight")).GetComponent<Light>()).enabled = MoreCounterplay.Settings.ExplosionFire.Value;
((Renderer)((Component)CoilExplosion.RadioactiveFirePrefab.transform.Find("GreenFlame")).GetComponent<ParticleSystemRenderer>()).enabled = MoreCounterplay.Settings.ExplosionFire.Value;
((Renderer)((Component)CoilExplosion.RadioactiveFirePrefab.transform.Find("RadioactiveParticles")).GetComponent<ParticleSystemRenderer>()).enabled = MoreCounterplay.Settings.ExplosionParticles.Value;
}
}
if (SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.DropHeadAsScrap))
{
Transform val = enemyPrefab.transform.Find("SpringManModel/Head");
Mesh sharedMesh = ((Component)val).GetComponent<MeshFilter>().sharedMesh;
HeadItem.Prefab.GetComponent<MeshFilter>().sharedMesh = sharedMesh;
Material sharedMaterial = ((Renderer)((Component)val).GetComponent<MeshRenderer>()).sharedMaterial;
((Renderer)HeadItem.Prefab.GetComponent<MeshRenderer>()).sharedMaterial = sharedMaterial;
}
}
else
{
MoreCounterplay.LogWarning("Either the 'Coilless Coilhead' prefab did not load or the Coilhead enemy prefab could not be found. Some stuff might not load or work properly.");
}
}
if (SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.LoreAccurateCoilheads) && MoreCounterplay.Settings.ExplosionFire.Value && VanillaPrefabUtils.GetOutsideEnemyPrefab("ForestGiant", out GameObject enemyPrefab2))
{
ParticleSystemRenderer val2 = default(ParticleSystemRenderer);
if ((Object)(object)CoilExplosion.RadioactiveFirePrefab != (Object)null && (Object)(object)enemyPrefab2 != (Object)null && ((Component)enemyPrefab2.transform.Find("FireParticlesContainer/LingeringFire")).TryGetComponent<ParticleSystemRenderer>(ref val2))
{
Texture mainTexture = ((Renderer)val2).sharedMaterial.mainTexture;
Transform val3 = CoilExplosion.RadioactiveFirePrefab.transform.Find("GreenFlame");
ParticleSystemRenderer val4 = default(ParticleSystemRenderer);
if ((Object)(object)val3 != (Object)null && ((Component)val3).TryGetComponent<ParticleSystemRenderer>(ref val4))
{
((Renderer)val4).sharedMaterial.mainTexture = mainTexture;
}
}
else
{
MoreCounterplay.LogWarning("Either the 'RadioactiveFire' prefab did not load or the Forest Giant enemy prefab could not be found. Some stuff might not load or work properly.");
}
}
MoreCounterplay.Log("Finished loading textures!");
}
}
[HarmonyPatch]
internal class TurretPatch
{
private const int KNIFE_HIT_ID = 5;
[HarmonyPatch(typeof(Turret), "IHittable.Hit")]
[HarmonyPostfix]
public static void CheckHitID(Turret __instance, int hitID = -1)
{
if (SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableTurretCounterplay) && hitID == 5)
{
MoreCounterplay.Log("Turret hit using knife");
TurretCounterplay turretCounterplay = ((Component)__instance).gameObject.AddComponent<TurretCounterplay>();
turretCounterplay.TurretDisabled = true;
}
}
[HarmonyPatch(typeof(Turret), "Update")]
[HarmonyPrefix]
public static bool CheckIfTurretGotDisabled(Turret __instance)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (!SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.EnableTurretCounterplay))
{
return true;
}
if ((int)__instance.turretMode != 0)
{
return true;
}
TurretCounterplay component = ((Component)__instance).gameObject.GetComponent<TurretCounterplay>();
if ((Object)(object)component != (Object)null && component.TurretDisabled)
{
if (__instance.turretActive)
{
__instance.ToggleTurretEnabled(false);
__instance.mainAudio.Stop();
__instance.farAudio.Stop();
__instance.berserkAudio.Stop();
__instance.bulletCollisionAudio.Stop();
__instance.bulletParticles.Stop();
__instance.mainAudio.PlayOneShot(__instance.turretDeactivate);
}
return false;
}
return true;
}
}
internal class TurretCounterplay : MonoBehaviour
{
public bool TurretDisabled;
}
}
namespace MoreCounterplay.Items
{
public class AttachedItem : PhysicsProp
{
public bool IsAttached { get; private set; }
public Action? OnGrab { get; set; }
public Action? OnEquip { get; set; }
public override void Start()
{
((GrabbableObject)this).Start();
((GrabbableObject)this).grabbable = true;
((GrabbableObject)this).grabbableToEnemies = true;
OnGrab = delegate
{
if (IsAttached && ((NetworkBehaviour)this).IsOwner)
{
DetachItemServerRpc();
}
};
}
public override void LateUpdate()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)((GrabbableObject)this).radarIcon != (Object)null)
{
((GrabbableObject)this).radarIcon.position = ((Component)this).transform.position;
}
if (!((Object)(object)((GrabbableObject)this).parentObject == (Object)null) && !IsAttached)
{
((Component)this).transform.position = ((GrabbableObject)this).parentObject.position;
((Component)this).transform.rotation = ((GrabbableObject)this).parentObject.rotation;
ApplyOffsets();
}
}
public override void GrabItem()
{
((GrabbableObject)this).GrabItem();
OnGrab?.Invoke();
}
public override void EquipItem()
{
((PhysicsProp)this).EquipItem();
OnEquip?.Invoke();
}
public virtual void ApplyOffsets()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: 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_0027: 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)
Transform transform = ((Component)this).transform;
transform.position += ((GrabbableObject)this).parentObject.rotation * ((GrabbableObject)this).itemProperties.positionOffset;
((Component)this).transform.Rotate(((GrabbableObject)this).itemProperties.rotationOffset);
}
public void AttachTo(GameObject parent)
{
//IL_0018: 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)
if (!IsAttached)
{
ParentConstraint component = ((Component)this).gameObject.GetComponent<ParentConstraint>();
ConstraintSource val = default(ConstraintSource);
((ConstraintSource)(ref val)).weight = 1f;
((ConstraintSource)(ref val)).sourceTransform = parent.transform;
component.AddSource(val);
component.constraintActive = true;
((GrabbableObject)this).parentObject = parent.transform;
IsAttached = true;
}
}
[ClientRpc]
public virtual void AttachItemClientRpc(NetworkObjectReference parent)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: 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)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1876029344u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref parent, default(ForNetworkSerializable));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1876029344u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
NetworkObject val3 = default(NetworkObject);
if (((NetworkObjectReference)(ref parent)).TryGet(ref val3, (NetworkManager)null))
{
AttachTo(((Component)val3).gameObject);
}
}
}
[ClientRpc]
public void DetachItemClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(318505161u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 318505161u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
ParentConstraint component = ((Component)this).gameObject.GetComponent<ParentConstraint>();
component.RemoveSource(0);
component.constraintActive = false;
IsAttached = false;
}
}
}
[ServerRpc(RequireOwnership = false)]
public void DetachItemServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4149983584u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4149983584u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
DetachItemClientRpc();
}
}
}
public override string __getTypeName()
{
return "AttachedItem";
}
protected override void __initializeVariables()
{
((PhysicsProp)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(1876029344u, new RpcReceiveHandler(__rpc_handler_1876029344), "AttachItemClientRpc");
((NetworkBehaviour)this).__registerRpc(318505161u, new RpcReceiveHandler(__rpc_handler_318505161), "DetachItemClientRpc");
((NetworkBehaviour)this).__registerRpc(4149983584u, new RpcReceiveHandler(__rpc_handler_4149983584), "DetachItemServerRpc");
((PhysicsProp)this).__initializeRpcs();
}
private static void __rpc_handler_1876029344(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_0044: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference parent = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref parent, default(ForNetworkSerializable));
target.__rpc_exec_stage = (__RpcExecStage)1;
((AttachedItem)(object)target).AttachItemClientRpc(parent);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_318505161(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;
((AttachedItem)(object)target).DetachItemClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_4149983584(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;
((AttachedItem)(object)target).DetachItemServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string? __getTypeName()
{
return "AttachedItem";
}
}
public class HeadItem : RotatingItem
{
private static Random? _random;
public static GameObject? Prefab { get; internal set; }
public static Random Random
{
get
{
return _random ?? (_random = new Random());
}
private set
{
_random = value;
}
}
public override void Start()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
base.Start();
((Component)this).transform.Rotate(new Vector3(0f, -90f, -35f));
((Component)this).transform.Translate(new Vector3(-0.05f, -0.05f, 0f));
((Object)this).hideFlags = (HideFlags)0;
base.OnEquip = delegate
{
if (((NetworkBehaviour)this).IsOwner)
{
int num = Random.Next(0, 360);
if (num <= 75)
{
OnEquipHeadServerRpc(1f / (float)Random.Next(1, 5), num);
}
else
{
SetRotationTarget(35f, 35f);
}
}
};
}
[ClientRpc]
public override void AttachItemClientRpc(NetworkObjectReference coilheadReference)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: 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)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4210478846u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref coilheadReference, default(ForNetworkSerializable));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4210478846u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
NetworkObject val3 = default(NetworkObject);
if (((NetworkObjectReference)(ref coilheadReference)).TryGet(ref val3, (NetworkManager)null))
{
GameObject gameObject = ((Component)((Component)val3).transform.Find("SpringManModel/Head")).gameObject;
Material material = ((Renderer)gameObject.GetComponent<MeshRenderer>()).material;
((Renderer)((Component)this).GetComponent<MeshRenderer>()).material = material;
AttachTo(gameObject);
gameObject.GetComponent<Renderer>().enabled = false;
}
}
}
[ClientRpc]
public void OnEquipHeadClientRpc(float rotationSpeed, int startingAngle)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(156822866u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref rotationSpeed, default(ForPrimitives));
BytePacker.WriteValueBitPacked(val2, startingAngle);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 156822866u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
SetRotationSpeed(rotationSpeed);
SetRotationTarget(startingAngle, 35f);
}
}
}
[ServerRpc(RequireOwnership = false)]
public void OnEquipHeadServerRpc(float rotationSpeed, int startingAngle)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1697168690u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref rotationSpeed, default(ForPrimitives));
BytePacker.WriteValueBitPacked(val2, startingAngle);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1697168690u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
OnEquipHeadClientRpc(rotationSpeed, startingAngle);
}
}
}
protected override void __initializeVariables()
{
base.__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(4210478846u, new RpcReceiveHandler(__rpc_handler_4210478846), "AttachItemClientRpc");
((NetworkBehaviour)this).__registerRpc(156822866u, new RpcReceiveHandler(__rpc_handler_156822866), "OnEquipHeadClientRpc");
((NetworkBehaviour)this).__registerRpc(1697168690u, new RpcReceiveHandler(__rpc_handler_1697168690), "OnEquipHeadServerRpc");
base.__initializeRpcs();
}
private static void __rpc_handler_4210478846(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_0044: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference coilheadReference = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref coilheadReference, default(ForNetworkSerializable));
target.__rpc_exec_stage = (__RpcExecStage)1;
((HeadItem)(object)target).AttachItemClientRpc(coilheadReference);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_156822866(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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
float rotationSpeed = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref rotationSpeed, default(ForPrimitives));
int startingAngle = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref startingAngle);
target.__rpc_exec_stage = (__RpcExecStage)1;
((HeadItem)(object)target).OnEquipHeadClientRpc(rotationSpeed, startingAngle);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1697168690(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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
float rotationSpeed = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref rotationSpeed, default(ForPrimitives));
int startingAngle = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref startingAngle);
target.__rpc_exec_stage = (__RpcExecStage)1;
((HeadItem)(object)target).OnEquipHeadServerRpc(rotationSpeed, startingAngle);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string? __getTypeName()
{
return "HeadItem";
}
}
public class RotatingItem : AttachedItem
{
public float CurrentAngle { get; private set; } = 90f;
public float RotationSpeed { get; private set; } = 0.5f;
public float StartingAngle { get; private set; } = 90f;
public float TargetAngle { get; private set; } = 35f;
public bool ReachedTarget { get; private set; }
public override void Start()
{
base.Start();
base.OnEquip = ResetRotation;
}
public override void ApplyOffsets()
{
//IL_0034: 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_004a: 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_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(((GrabbableObject)this).itemProperties.rotationOffset.x, ((GrabbableObject)this).itemProperties.rotationOffset.y, CurrentAngle);
Transform transform = ((Component)this).transform;
transform.position += ((GrabbableObject)this).parentObject.rotation * ((GrabbableObject)this).itemProperties.positionOffset;
((Component)this).transform.Rotate(val);
if (!ReachedTarget)
{
if (CurrentAngle > TargetAngle + RotationSpeed * 2f)
{
CurrentAngle -= RotationSpeed;
}
else if (CurrentAngle < TargetAngle - RotationSpeed * 2f)
{
CurrentAngle += RotationSpeed;
}
else
{
ReachedTarget = true;
}
}
}
public void ResetRotation()
{
SetRotation(StartingAngle);
}
public void SetRotation(float angle)
{
CurrentAngle = angle;
ReachedTarget = false;
}
public void SetRotationTarget(float startingAngle, float targetAngle)
{
StartingAngle = Math.Abs(startingAngle % 360f);
TargetAngle = Math.Abs(targetAngle % 360f);
ResetRotation();
}
public void SetRotationSpeed(float rotationSpeed)
{
RotationSpeed = rotationSpeed;
}
public override string __getTypeName()
{
return "RotatingItem";
}
protected override void __initializeVariables()
{
base.__initializeVariables();
}
protected override void __initializeRpcs()
{
base.__initializeRpcs();
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "RotatingItem";
}
}
}
namespace MoreCounterplay.Config
{
public class ConfigSettings : SyncedConfig2<ConfigSettings>
{
[field: SyncedEntryField]
public SyncedEntry<bool> EnableJesterCounterplay { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<float> JesterPreventThreshold { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<float> JesterEncumberThreshold { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<float> JesterPanicThreshold { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<float> MinPanicTimer { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<float> MaxPanicTimer { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<bool> ItemsStayOnLid { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<bool> DropItemsOnHit { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<bool> ShowWeightOnScan { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<bool> EnableTurretCounterplay { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<bool> EnableCoilheadCounterplay { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<int> SpringDurability { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<int> CoilheadDefaultDamage { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<int> CoilheadKnifeDamage { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<int> CoilheadShovelDamage { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<bool> DropHeadAsScrap { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<int> MinHeadValue { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<int> MaxHeadValue { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<bool> LoreAccurateCoilheads { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<int> ExplosionDamage { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<float> ExplosionDamageRadius { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<float> ExplosionKillRadius { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<float> MinExplosionTimer { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<float> MaxExplosionTimer { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<bool> ExplosionDestroysHead { get; private set; }
public ConfigEntry<bool> ExplosionFire { get; private set; }
public ConfigEntry<bool> ExplosionParticles { get; private set; }
public ConfigEntry<float> ExplosionWarnVolume { get; private set; }
public ConfigEntry<bool> EnableCoilheadScanNode { get; private set; }
public ConfigEntry<bool> ModifyCoilheadScanNode { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<bool> EnableFeioparCounterplay { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<float> FeioparLaserPointerEffectiveRange { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<bool> CanDamagePlayerWhileAttackingLaser { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<bool> CanDamageEnemiesWhileAttackingLaser { get; private set; }
[field: SyncedEntryField]
public SyncedEntry<int> FeioparEnemyHitForce { get; private set; }
public ConfigSettings(ConfigFile config)
: base("BaronDrakula.MoreCounterplay")
{
//IL_0357: Unknown result type (might be due to invalid IL or missing references)
//IL_0361: Expected O, but got Unknown
config.SaveOnConfigSet = false;
EnableJesterCounterplay = SyncedBindingExtensions.BindSyncedEntry<bool>(config, "Jester", "EnableJesterCounterplay", true, "Add counterplay for Jesters. Required for all Jester settings under this.");
JesterPreventThreshold = SyncedBindingExtensions.BindSyncedEntry<float>(config, "Jester", "JesterPreventThreshold", 60f, "Minimum weight of items needed to prevent the Jester from popping. Set to 0 to disable.");
JesterEncumberThreshold = SyncedBindingExtensions.BindSyncedEntry<float>(config, "Jester", "JesterEncumberThreshold", 120f, "Minimum weight of items needed to prevent the Jester from walking at all. Set to 0 to disable. Can be smaller than the setting above.");
JesterPanicThreshold = SyncedBindingExtensions.BindSyncedEntry<float>(config, "Jester", "JesterPanicThreshold", 200f, "Minimum weight of items needed for the Jester to start panicking. Set to 0 to disable. Functionally disables counterplay if lower than the 'prevent' threshold.");
MinPanicTimer = SyncedBindingExtensions.BindSyncedEntry<float>(config, "Jester", "MinPanicTimer", 0.5f, "Shortest amount of time the Jester can panic for before popping.");
MaxPanicTimer = SyncedBindingExtensions.BindSyncedEntry<float>(config, "Jester", "MaxPanicTimer", 5f, "Largest amount of time the Jester can panic for before popping");
ItemsStayOnLid = SyncedBindingExtensions.BindSyncedEntry<bool>(config, "Jester", "ItemsStayOnLid", false, "Allow items to stay on top of the Jester after preventing it from popping.");
DropItemsOnHit = SyncedBindingExtensions.BindSyncedEntry<bool>(config, "Jester", "DropItemsOnHit", true, "Drop all items on top of the Jester when hitting it with a shovel.");
ShowWeightOnScan = SyncedBindingExtensions.BindSyncedEntry<bool>(config, "Jester", "ShowWeightOnScan", true, "Shows the total weight on top of the Jester as the subtext of its scan node.");
EnableTurretCounterplay = SyncedBindingExtensions.BindSyncedEntry<bool>(config, "Turret", "EnableTurretCounterplay", true, "Add counterplay for Turret.");
EnableCoilheadCounterplay = SyncedBindingExtensions.BindSyncedEntry<bool>(config, "Coilhead", "EnableCoilheadCounterplay", true, "Add counterplay for Coilheads. Required for all Coilhead settings under this.");
SpringDurability = SyncedBindingExtensions.BindSyncedEntry<int>(config, "Coilhead", "SpringDurability", 3, "Set Coilhead health points.");
CoilheadDefaultDamage = SyncedBindingExtensions.BindSyncedEntry<int>(config, "Coilhead", "CoilheadDefaultDamage", 0, "Amount of damage that Coilheads take from any source not specified below.");
CoilheadKnifeDamage = SyncedBindingExtensions.BindSyncedEntry<int>(config, "Coilhead", "CoilheadKnifeDamage", 1, "Amount of damage that Coilheads take from Knife.");
CoilheadShovelDamage = SyncedBindingExtensions.BindSyncedEntry<int>(config, "Coilhead", "CoilheadShovelDamage", 0, "Amount of damage that Coilheads take from Shovel.");
DropHeadAsScrap = SyncedBindingExtensions.BindSyncedEntry<bool>(config, "Coilhead", "DropHeadAsScrap", true, "Enable the Coilhead head scrap item spawning on death.");
MinHeadValue = SyncedBindingExtensions.BindSyncedEntry<int>(config, "Coilhead", "MinHeadValue", 30, "Minimum value of the Coilhead head item.");
MaxHeadValue = SyncedBindingExtensions.BindSyncedEntry<int>(config, "Coilhead", "MaxHeadValue", 70, "Maximum value of the Coilhead head item.");
LoreAccurateCoilheads = SyncedBindingExtensions.BindSyncedEntry<bool>(config, "Coilhead", "LoreAccurateCoilheads", true, "Enable lore accurate (volatile) Coilhead counterplay (requires restart). Required for all Coilhead settings under this.");
ExplosionDamage = SyncedBindingExtensions.BindSyncedEntry<int>(config, "Coilhead", "ExplosionDamage", 50, "Amount of damage the Coilhead explosion deals.");
ExplosionDamageRadius = SyncedBindingExtensions.BindSyncedEntry<float>(config, "Coilhead", "ExplosionDamageRadius", 4f, "Radius of the Coilhead explosion damage zone.");
ExplosionKillRadius = SyncedBindingExtensions.BindSyncedEntry<float>(config, "Coilhead", "ExplosionKillRadius", 2f, "Radius of the Coilhead explosion kill zone.");
MinExplosionTimer = SyncedBindingExtensions.BindSyncedEntry<float>(config, "Coilhead", "MinExplosionTimer", 0.5f, "Minimum time until Coilhead explosion.");
MaxExplosionTimer = SyncedBindingExtensions.BindSyncedEntry<float>(config, "Coilhead", "MaxExplosionTimer", 5f, "Maximum time until Coilhead explosion.");
ExplosionDestroysHead = SyncedBindingExtensions.BindSyncedEntry<bool>(config, "Coilhead", "ExplosionDestroysHead", true, "Destroy Coilhead scrap head if still attached during explosion.");
ExplosionFire = config.Bind<bool>("Coilhead", "ExplosionFire", true, "(Client-side) Enable green fire effect for Coilheads that are about to explode.");
ExplosionParticles = config.Bind<bool>("Coilhead", "ExplosionParticles", true, "(Client-side) Enable radioactive particles effect for Coilheads that are about to explode.");
ExplosionWarnVolume = config.Bind<float>("Coilhead", "ExplosionWarnVolume", 1f, new ConfigDescription("(Client-side) Adjust volume of the sound effect played right before exploding (NOT the actual explosion).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
EnableCoilheadScanNode = config.Bind<bool>("Coilhead", "EnableCoilheadScanNode", true, "(Client-side) Enable scanning Coilheads that have been killed.");
ModifyCoilheadScanNode = config.Bind<bool>("Coilhead", "ModifyCoilheadScanNode", true, "(Client-side) Add extra text/subtext to a killed Coilhead's scan node.");
EnableFeioparCounterplay = SyncedBindingExtensions.BindSyncedEntry<bool>(config, "Feiopar", "EnableFeioparCounterplay", true, "Add counterplay for Feiopars. Required for all Feiopar settings under this.");
FeioparLaserPointerEffectiveRange = SyncedBindingExtensions.BindSyncedEntry<float>(config, "Feiopar", "FeioparLaserPointerEffectiveRange", 40f, "Maximum effective range of the laser pointer on the behavior of Feiopar.");
CanDamagePlayerWhileAttackingLaser = SyncedBindingExtensions.BindSyncedEntry<bool>(config, "Feiopar", "CanDamagePlayerWhileAttackingLaser", true, "Allow Feiopars to damage the player while they are attacking laser pointer.");
CanDamageEnemiesWhileAttackingLaser = SyncedBindingExtensions.BindSyncedEntry<bool>(config, "Feiopar", "CanDamageEnemiesWhileAttackingLaser", true, "Allow Feiopars to damage enemies while they are attacking laser pointer.");
FeioparEnemyHitForce = SyncedBindingExtensions.BindSyncedEntry<int>(config, "Feiopar", "FeioparEnemyHitForce", 1, "Hit force of feiopar attacks applied to enemies.\nFor feference shovel hit force is 1.");
base.InitialSyncCompleted += delegate
{
LoadPatches.FindAndModifyPrefabs();
};
ClearOrphanedEntries(config);
config.SaveOnConfigSet = true;
config.Save();
ConfigManager.Register<ConfigSettings>((SyncedConfig2<ConfigSettings>)(object)this);
}
private void ClearOrphanedEntries(ConfigFile config)
{
PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
((Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(config))?.Clear();
}
}
}
namespace MoreCounterplay.Behaviours
{
public class CoilExplosion : NetworkBehaviour
{
public static GameObject? CoilheadPrefab { get; internal set; }
public static GameObject? RadioactiveFirePrefab { get; internal set; }
public bool Ticking { get; internal set; }
public float TimeLeft { get; internal set; }
public float TimeSinceLastStop { get; internal set; }
public bool PlayedSfx { get; internal set; }
public GameObject? HeadContainer { get; internal set; }
public GameObject? FireContainer { get; private set; }
public SpringManAI? Coilhead { get; private set; }
public override void OnNetworkSpawn()
{
((NetworkBehaviour)this).OnNetworkSpawn();
SpringManAI coilhead = default(SpringManAI);
if (((Component)this).TryGetComponent<SpringManAI>(ref coilhead))
{
Coilhead = coilhead;
}
Transform obj = ((Component)this).transform.Find("SpringManModel/RadioactiveFire");
FireContainer = ((obj != null) ? ((Component)obj).gameObject : null);
}
public void LateUpdate()
{
if (!Ticking)
{
TimeSinceLastStop += Time.deltaTime;
}
else if (TimeLeft <= 0f)
{
GameObject? headContainer = HeadContainer;
AttachedItem attachedItem = default(AttachedItem);
if (headContainer != null && headContainer.TryGetComponent<AttachedItem>(ref attachedItem) && attachedItem.IsAttached && !((GrabbableObject)attachedItem).heldByPlayerOnServer && SyncedEntry<bool>.op_Implicit(MoreCounterplay.Settings.ExplosionDestroysHead))
{
GameObject? headContainer2 = HeadContainer;
if (headContainer2 != null)
{
headContainer2.GetComponent<NetworkObject>().Despawn(true);
}
}
SpawnExplosionClientRpc();
UpdateScanNodeClientRpc(ignited: false);
((Behaviour)this).enabled = false;
}
else
{
if (!PlayedSfx && TimeLeft <= 1f)
{
PlaySfxClientRpc();
PlayedSfx = true;
}
TimeLeft -= Time.deltaTime;
}
}
[ClientRpc]
private void SpawnExplosionClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(854298167u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 854298167u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
base.__rpc_exec_stage = (__RpcExecStage)0;
Landmine.SpawnExplosion(((Component)this).transform.position, true, SyncedEntry<float>.op_Implicit(MoreCounterplay.Settings.ExplosionKillRadius), SyncedEntry<float>.op_Implicit(MoreCounterplay.Settings.ExplosionDamageRadius), SyncedEntry<int>.op_Implicit(MoreCounterplay.Settings.ExplosionDamage), 0f, (GameObject)null, false);
SpringManAI? coilhead = Coilhead;
if (coilhead != null)
{
coilhead.DoSpringAnimation(true);
}
GameObject? fireContainer = FireContainer;
if (fireContainer != null)
{
fireContainer.SetActive(false);
}
}
}
[ClientRpc]
private void PlaySfxClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: 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.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1574743326u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1574743326u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
base.__rpc_exec_stage = (__RpcExecStage)0;
SpringManAI? coilhead = Coilhead;
if (coilhead != null)
{
AudioSource creatureVoice = ((EnemyAI)coilhead).creatureVoice;
GameObject? prefab = HeadItem.Prefab;
HeadItem headItem = default(HeadItem);
creatureVoice.PlayOneShot((prefab != null && prefab.TryGetComponent<HeadItem>(ref headItem)) ? ((GrabbableObject)headItem).itemProperties.throwSFX : Coilhead?.enterCooldownSFX, MoreCounterplay.Settings.ExplosionWarnVolume.Value);
}
}
}
[ClientRpc]
internal void UpdateScanNodeClientRpc(bool ignited)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: 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.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(548278882u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref ignited, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 548278882u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
base.__rpc_exec_stage = (__RpcExecStage)0;
if (!MoreCounterplay.Settings.ModifyCoilheadScanNode.Value)
{
return;
}
Transform obj = ((Component)this).transform.Find("SpringManModel/ScanNode");
ScanNodeProperties val3 = default(ScanNodeProperties);
if (obj != null && ((Component)obj).TryGetComponent<ScanNodeProperties>(ref val3))
{
Collider val4 = default(Collider);
if (((Component)val3).TryGetComponent<Collider>(ref val4))
{
val4.enabled = true;
}
if (MoreCounterplay.Settings.ModifyCoilheadScanNode.Value)
{
val3.headerText = (ignited ? "Fissile" : "Decayed") + " Coil-Head";
val3.subText = (ignited ? "Run." : "Don't get too close...");
val3.nodeType = (ignited ? 1 : 0);
}
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(854298167u, new RpcReceiveHandler(__rpc_handler_854298167), "SpawnExplosionClientRpc");
((NetworkBehaviour)this).__registerRpc(1574743326u, new RpcReceiveHandler(__rpc_handler_1574743326), "PlaySfxClientRpc");
((NetworkBehaviour)this).__registerRpc(548278882u, new RpcReceiveHandler(__rpc_handler_548278882), "UpdateScanNodeClientRpc");
((NetworkBehaviour)this).__initializeRpcs();
}
private static void __rpc_handler_854298167(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;
((CoilExplosion)(object)target).SpawnExplosionClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1574743326(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;
((CoilExplosion)(object)target).PlaySfxClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_548278882(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_0044: 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 ignited = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref ignited, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)1;
((CoilExplosion)(object)target).UpdateScanNodeClientRpc(ignited);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string? __getTypeName()
{
return "CoilExplosion";
}
}
public class JesterSurface : PlaceableObjectsSurface
{
public static GameObject? JesterSurfacePrefab { get; internal set; }
public float TotalWeight { get; internal set; }
public JesterAI? Jester { get; private set; }
public override void OnNetworkSpawn()
{
((NetworkBehaviour)this).OnNetworkSpawn();
Transform transform = ((Component)this).transform;
GameObject? jesterSurfacePrefab = JesterSurfacePrefab;
((Object)transform).name = ((jesterSurfacePrefab != null) ? ((Object)jesterSurfacePrefab).name : null);
base.parentTo = ((Component)this).GetComponent<NetworkObject>();
base.placeableBounds = ((Component)((Component)this).transform.Find("bounds")).GetComponent<Collider>();
base.triggerScript = ((Component)this).GetComponent<InteractTrigger>();
((UnityEvent<PlayerControllerB>)(object)base.triggerScript.onInteract).AddListener((UnityAction<PlayerControllerB>)PlaceObject);
}
public void Start()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
Transform parent = ((Component)this).transform.GetParent();
JesterAI jester = default(JesterAI);
if (parent != null && ((Component)parent).TryGetComponent<JesterAI>(ref jester))
{
Jester = jester;
}
((Component)this).gameObject.layer = LayerMask.NameToLayer("InteractableObject");
ParentConstraint val = ((Component)this).gameObject.AddComponent<ParentConstraint>();
ConstraintSource val2 = default(ConstraintSource);
((ConstraintSource)(ref val2)).weight = 1f;
((ConstraintSource)(ref val2)).sourceTransform = ((Component)this).transform.GetParent().Find("MeshContainer/AnimContainer/metarig/BoxContainer");
val.AddSource(val2);
val.constraintActive = true;
}
public void Update()
{
if ((Object)(object)base.triggerScript != (Object)null)
{
InteractTrigger triggerScript = base.triggerScript;
int interactable;
if (GameNetworkManager.Instance.localPlayerController.isHoldingObject)
{
JesterAI? jester = Jester;
interactable = ((jester == null || ((EnemyAI)jester).currentBehaviourStateIndex != 2) ? 1 : 0);
}
else
{
interactable = 0;
}
triggerScript.interactable = (byte)interactable != 0;
}
}
public void PlaceObject(PlayerControllerB playerWhoTriggered)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)playerWhoTriggered).IsOwner && playerWhoTriggered.isHoldingObject && !playerWhoTriggered.isGrabbingObjectAnimation && !((Object)(object)playerWhoTriggered.currentlyHeldObjectServer == (Object)null))
{
GrabbableObject currentlyHeldObjectServer = playerWhoTriggered.currentlyHeldObjectServer;
Vector3 val = ((Component)base.parentTo).transform.InverseTransformPoint(itemPlacementPosition(((Component)playerWhoTriggered.gameplayCamera).transform, currentlyHeldObjectServer));
playerWhoTriggered.DiscardHeldObject(true, base.parentTo, val, false);
PlaceItemOnClient(currentlyHeldObjectServer);
PlaceItemServerRpc(NetworkObjectReference.op_Implicit(((Component)playerWhoTriggered).GetComponent<NetworkObject>()), NetworkObjectReference.op_Implicit(((Component)currentlyHeldObjectServer).GetComponent<NetworkObject>()));
}
}
public Vector3 itemPlacementPosition(Transform camera, GrabbableObject heldItem)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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)
int num = 1074277120;
RaycastHit val = default(RaycastHit);
if (Physics.Raycast(camera.position, camera.forward, ref val, 7f, num, (QueryTriggerInteraction)1))
{
return base.placeableBounds.ClosestPoint(((RaycastHit)(ref val)).point) + ((Component)base.placeableBounds).transform.up * heldItem.itemProperties.verticalOffset;
}
return ((Component)base.placeableBounds).transform.position;
}
public void ResetJester()
{
if (!((Object)(object)Jester == (Object)null))
{
if (SyncedEntry<float>.op_Implicit(MoreCounterplay.Settings.JesterEncumberThreshold) != 0f && TotalWeight < SyncedEntry<float>.op_Implicit(MoreCounterplay.Settings.JesterEncumberThreshold) && ((EnemyAI)Jester).stunNormalizedTimer > 0f)
{
Jester.beginCrankingTimer = ((EnemyAI)Jester).stunNormalizedTimer * ((EnemyAI)Jester).enemyType.stunTimeMultiplier;
((EnemyAI)Jester).stunNormalizedTimer = 0f;
}
if (SyncedEntry<float>.op_Implicit(MoreCounterplay.Settings.JesterPanicThreshold) != 0f && TotalWeight < SyncedEntry<float>.op_Implicit(MoreCounterplay.Settings.JesterPanicThreshold) && ((EnemyAI)Jester).creatureAnimator.GetBool("turningCrank") && ((EnemyAI)Jester).currentBehaviourStateIndex == 0)
{
((EnemyAI)Jester).creatureVoice.Stop();
((EnemyAI)Jester).creatureAnimator.SetBool("turningCrank", false);
((EnemyAI)Jester).creatureAnimator.SetFloat("CrankSpeedMultiplier", 1f);
((EnemyAI)Jester).creatureAnimator.CrossFade("IdleDocile", 0.1f);
}
}
}
public void PlaceItemOnClient(GrabbableObject item)
{
if ((Object)(object)base.parentTo == (Object)null || (Object)(object)base.placeableBounds == (Object)null || (Object)(object)base.triggerScript == (Object)null || (Object)(object)Jester == (Object)null || ((EnemyAI)Jester).currentBehaviourStateIndex == 2)
{
return;
}
Transform child = ((Component)item).transform.GetChild(0);
ScanNodeProperties val = default(ScanNodeProperties);
Rigidbody val2 = default(Rigidbody);
if (child != null && ((Component)child).TryGetComponent<ScanNodeProperties>(ref val) && !((Component)val).TryGetComponent<Rigidbody>(ref val2))
{
((Component)val).gameObject.AddComponent<Rigidbody>().isKinematic = true;
}
TotalWeight += (item.itemProperties.weight - 1f) * 105f;
MoreCounterplay.Log($"Current weight: {TotalWeight}");
if (SyncedEntry<bool>.op_Implicit(MoreCounterplay.Sett