using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AIGraph;
using API;
using Agents;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using ButterFingers.BepInEx;
using FluffyUnderware.DevTools.Extensions;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using LevelGeneration;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using UnityEngine;
using UnityEngine.Analytics;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ButterFingers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7987d4a727733cc57f85c790c66a1533e1f81abf")]
[assembly: AssemblyProduct("ButterFingers")]
[assembly: AssemblyTitle("ButterFingers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
}
}
}
namespace ButterFingers
{
internal class Cooldown
{
public static float timer;
}
[HarmonyPatch]
internal class CarryItem : MonoBehaviour
{
[HarmonyPatch]
private static class Patches
{
private static bool patch = true;
private static IEnumerator DelayedEndSession()
{
yield return (object)new WaitForSeconds(1f);
patch = false;
RundownManager.Current.EndGameSession();
patch = true;
}
[HarmonyPatch(typeof(RundownManager), "EndGameSession")]
[HarmonyPrefix]
private static bool EndGameSession()
{
if (!patch)
{
return true;
}
APILogger.Debug("CarryItem Level ended!");
foreach (CarryItem value in instances.Values)
{
value.ForceStop();
}
foreach (ResourcePack value2 in ResourcePack.instances.Values)
{
value2.ForceStop();
ObjectExt.Destroy((Object)(object)((Component)value2).gameObject);
}
foreach (Consumable value3 in Consumable.instances.Values)
{
value3.ForceStop();
ObjectExt.Destroy((Object)(object)((Component)value3).gameObject);
}
ResourcePack.instances.Clear();
Consumable.instances.Clear();
instances.Clear();
((MonoBehaviour)PlayerManager.GetLocalPlayerAgent()).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DelayedEndSession()));
return false;
}
[HarmonyPatch(typeof(CarryItemPickup_Core), "Setup")]
[HarmonyPostfix]
private static void Setup(CarryItemPickup_Core __instance)
{
((Component)__instance).gameObject.AddComponent<CarryItem>();
}
[HarmonyPatch(typeof(CarryItemPickup_Core), "OnSyncStateChange")]
[HarmonyPrefix]
private static void Prefix_StatusChange(CarryItemPickup_Core __instance, ePickupItemStatus status, pPickupPlacement placement, PlayerAgent player, bool isRecall)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
int instanceID = ((Object)__instance).GetInstanceID();
if (instances.ContainsKey(instanceID))
{
instances[instanceID].Prefix_OnStatusChange(status, placement, player, isRecall);
}
}
[HarmonyPatch(typeof(CarryItemPickup_Core), "OnSyncStateChange")]
[HarmonyPostfix]
[HarmonyPriority(600)]
private static void Postfix_StatusChange(CarryItemPickup_Core __instance, ePickupItemStatus status, pPickupPlacement placement, PlayerAgent player, bool isRecall)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
int instanceID = ((Object)__instance).GetInstanceID();
if (instances.ContainsKey(instanceID))
{
instances[instanceID].Postfix_OnStatusChange(status, placement, player, isRecall);
}
}
[HarmonyPatch(typeof(PlayerAgent), "Update")]
[HarmonyPrefix]
private static void Update(PlayerAgent __instance)
{
if (!__instance.Owner.IsLocal || __instance.Owner.IsBot || Clock.Time < Cooldown.timer)
{
return;
}
foreach (CarryItem value in instances.Values)
{
value.Footstep();
}
}
[HarmonyPatch(typeof(SNet_SessionHub), "LeaveHub")]
[HarmonyPrefix]
private static void LeaveHub()
{
foreach (CarryItem value in instances.Values)
{
value.ForceStop();
}
}
[HarmonyPatch(typeof(PLOC_Downed), "CommonEnter")]
[HarmonyPrefix]
private static void Prefix_CommonEnter(PLOC_Downed __instance)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
BackpackItem val = default(BackpackItem);
if (!((PLOC_Base)__instance).m_owner.Owner.IsLocal || ((PLOC_Base)__instance).m_owner.Owner.IsBot || !PlayerBackpackManager.TryGetItem(PlayerManager.GetLocalPlayerAgent().Owner, (InventorySlot)8, ref val) || (Object)(object)val.Instance == (Object)null)
{
return;
}
ItemEquippable val2 = ((Il2CppObjectBase)val.Instance).Cast<ItemEquippable>();
if ((Object)(object)val2 == (Object)null)
{
return;
}
ItemInLevel levelItemFromItemData = GetLevelItemFromItemData(((Item)val2).Get_pItemData());
if (!((Object)(object)levelItemFromItemData == (Object)null))
{
int instanceID = ((Object)levelItemFromItemData).GetInstanceID();
if (instances.ContainsKey(instanceID))
{
instances[instanceID].Footstep(force: true);
}
if (GuiManager.MainMenuLayer != null && (Object)(object)GuiManager.MainMenuLayer.PageMap != (Object)null)
{
GuiManager.MainMenuLayer.PageMap.UpdatePlayerData();
}
}
}
}
private int instance;
private CarryItemPickup_Core? core;
private LG_PickupItem_Sync? sync;
private Rigidbody? rb;
private CapsuleCollider? collider;
private static Dictionary<int, CarryItem> instances = new Dictionary<int, CarryItem>();
private Vector3 physicsPosition;
private Quaternion physicsRotation;
private bool prevKinematic = true;
private PlayerAgent? carrier;
private bool startTracking;
private Vector3 prevPosition = Vector3.zero;
private float distanceSqrd;
private bool performSlip;
private NM_NoiseData? noise;
private float noiseDelay;
private byte oldValue;
private float prevTime;
private float stillTimer;
private float blink;
private static bool allowQuitting = false;
private static ItemInLevel? GetLevelItemFromItemData(pItemData itemData)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
Item val = default(Item);
if (!PlayerBackpackManager.TryGetItemInLevelFromItemData(itemData, ref val))
{
return null;
}
if ((Object)(object)((Il2CppObjectBase)val).TryCast<ItemInLevel>() == (Object)null)
{
return null;
}
return ((Il2CppObjectBase)val).TryCast<ItemInLevel>();
}
private void Start()
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Expected O, but got Unknown
core = ((Component)this).GetComponent<CarryItemPickup_Core>();
sync = ((Component)this).GetComponent<LG_PickupItem_Sync>();
if (!((Object)(object)sync == (Object)null) && !((Object)(object)core == (Object)null))
{
instance = ((Object)core).GetInstanceID();
instances.Add(instance, this);
((Component)core).gameObject.layer = LayerManager.LAYER_DEBRIS;
rb = ((Component)this).gameObject.AddComponent<Rigidbody>();
collider = ((Component)this).gameObject.AddComponent<CapsuleCollider>();
rb.drag = 0.01f;
rb.isKinematic = true;
rb.collisionDetectionMode = (CollisionDetectionMode)2;
PhysicMaterial val = new PhysicMaterial();
val.bounciness = 0.4f;
val.bounceCombine = (PhysicMaterialCombine)3;
((Collider)collider).material = val;
}
}
private void Prefix_OnStatusChange(ePickupItemStatus status, pPickupPlacement placement, PlayerAgent player, bool isRecall)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_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_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)rb == (Object)null)
{
return;
}
if (!placement.droppedOnFloor && !placement.linkedToMachine)
{
carrier = player;
}
else
{
carrier = null;
}
bool flag = !prevKinematic && rb.isKinematic;
if (isRecall || (int)status != 0)
{
rb.isKinematic = true;
return;
}
if (rb.isKinematic)
{
if (!flag && ((Agent)player).GlobalID != ((Agent)PlayerManager.GetLocalPlayerAgent()).GlobalID)
{
rb.isKinematic = true;
return;
}
if (performSlip)
{
performSlip = false;
Slip(player, placement.position + Vector3.up * 1.5f, placement.rotation, player.m_courseNode);
}
}
if (!rb.isKinematic)
{
physicsPosition = ((Component)this).transform.position;
physicsRotation = ((Component)this).transform.rotation;
}
}
private void Postfix_OnStatusChange(ePickupItemStatus status, pPickupPlacement placement, PlayerAgent player, bool isRecall)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)rb == (Object)null) && !((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null))
{
if (!rb.isKinematic)
{
((Component)this).transform.position = physicsPosition;
((Component)this).transform.rotation = physicsRotation;
}
prevKinematic = rb.isKinematic;
}
}
private AIG_CourseNode? GetNode(Vector3 position)
{
//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_000c: Unknown result type (might be due to invalid IL or missing references)
AIG_INode val = default(AIG_INode);
AIG_NodeCluster val2 = default(AIG_NodeCluster);
if (AIG_GeomorphNodeVolume.TryGetNode(0, Dimension.GetDimensionFromPos(position).DimensionIndex, position, ref val, false) && AIG_NodeCluster.TryGetNodeCluster(val.ClusterID, ref val2))
{
if (val2.CourseNode == null)
{
return null;
}
return val2.CourseNode;
}
return null;
}
private void Footstep(bool force = false)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Invalid comparison between Unknown and I4
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)sync == (Object)null || (Object)(object)carrier == (Object)null || (Object)(object)rb == (Object)null || !rb.isKinematic || sync.m_stateReplicator.State.placement.droppedOnFloor)
{
return;
}
PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
if (((Agent)carrier).GlobalID != ((Agent)localPlayerAgent).GlobalID || !((Object)(object)localPlayerAgent.Inventory != (Object)null) || (int)localPlayerAgent.Inventory.WieldedSlot != 8)
{
return;
}
if (!startTracking)
{
startTracking = true;
prevPosition = ((Agent)localPlayerAgent).Position;
}
float num = distanceSqrd;
Vector3 val = ((Agent)localPlayerAgent).Position - prevPosition;
distanceSqrd = num + ((Vector3)(ref val)).sqrMagnitude;
prevPosition = ((Agent)localPlayerAgent).Position;
if (distanceSqrd > ConfigManager.DistancePerRoll * ConfigManager.DistancePerRoll || force)
{
distanceSqrd = 0f;
if (Random.Range(0f, 1f) < ConfigManager.HeavyItemProbability || force)
{
performSlip = true;
PlayerBackpackManager.WantToDropItem_Local(((Item)localPlayerAgent.Inventory.WieldedItem).Get_pItemData(), ((Agent)localPlayerAgent).Position, ((Agent)localPlayerAgent).Rotation, true);
}
}
}
private void Slip(PlayerAgent player, Vector3 position, Quaternion rotation, AIG_CourseNode node)
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null))
{
((Component)this).gameObject.SetActive(true);
rb.isKinematic = false;
Cooldown.timer = Clock.Time + ConfigManager.Cooldown;
prevTime = Clock.Time;
stillTimer = 0f;
startTracking = false;
carrier = null;
Vector3 insideUnitSphere = Random.insideUnitSphere;
rb.velocity = Vector3.zero;
rb.AddForce(insideUnitSphere * ConfigManager.Force);
SetTransform(position, rotation, node);
}
}
private void SetTransform(Vector3 position, Quaternion rotation, AIG_CourseNode node)
{
//IL_0040: 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_0084: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null))
{
((Component)this).transform.position = position;
((Component)this).transform.rotation = rotation;
((Component)this).gameObject.transform.SetParent(node.gameObject.transform);
core.m_itemCuller.MoveToNode(node.m_cullNode, ((Component)this).transform.position);
}
}
private void OnCollisionStay()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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)
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null) && rb.velocity.y > -0.3f && rb.velocity.y < 0.3f)
{
Rigidbody? obj = rb;
obj.velocity *= 0.92f;
Rigidbody? obj2 = rb;
obj2.angularVelocity *= 0.92f;
}
}
private void OnCollisionEnter()
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Expected O, but got Unknown
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null) && ConfigManager.MakeNoise && !rb.isKinematic && ((ItemInLevel)core).m_courseNode != null && Clock.Time > noiseDelay)
{
noiseDelay = Clock.Time + 1.5f;
noise = new NM_NoiseData
{
noiseMaker = null,
position = ((Component)this).transform.position,
radiusMin = 4f,
radiusMax = 10f,
yScale = 1f,
node = ((ItemInLevel)core).m_courseNode,
type = (NM_NoiseType)1,
includeToNeightbourAreas = true,
raycastFirstNode = false
};
NoiseManager.MakeNoise(noise);
}
}
private void FixedUpdate()
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: 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)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: 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_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)core == (Object)null || (Object)(object)sync == (Object)null || (Object)(object)rb == (Object)null || (Object)(object)collider == (Object)null)
{
return;
}
if (rb.isKinematic)
{
oldValue = sync.m_stateReplicator.State.custom.byteState;
return;
}
AIG_CourseNode node = GetNode(((Component)this).transform.position);
bool flag = Physics.Raycast(((Component)this).transform.position, Vector3.down, 1f);
Vector3 val = rb.velocity;
if (((Vector3)(ref val)).sqrMagnitude < 1f && flag)
{
stillTimer += Clock.Time - prevTime;
}
else
{
stillTimer = 0f;
}
if (node != null)
{
((Component)this).gameObject.transform.SetParent(node.gameObject.transform);
core.m_itemCuller.MoveToNode(node.m_cullNode, ((Component)this).transform.position);
}
pItemData_Custom val2 = default(pItemData_Custom);
val2.ammo = sync.m_stateReplicator.State.custom.ammo;
val2.byteId = sync.m_stateReplicator.State.custom.byteId;
val2.byteState = 1;
if (stillTimer > 1f || ((Component)this).transform.position.y < -2500f)
{
rb.velocity = Vector3.zero;
rb.isKinematic = true;
val2.byteState = oldValue;
}
if (Clock.Time > blink - 0.5f)
{
val2.byteState = oldValue;
LG_PickupItem_Sync? obj = sync;
SNet_Player owner = PlayerManager.GetLocalPlayerAgent().Owner;
val = ((Component)this).transform.position;
Quaternion rotation = ((Component)this).transform.rotation;
AIG_CourseNode val3 = node;
obj.AttemptPickupInteraction((ePickupItemInteractionType)1, owner, val2, val, rotation, val3, true, true);
}
else
{
LG_PickupItem_Sync? obj2 = sync;
SNet_Player owner2 = PlayerManager.GetLocalPlayerAgent().Owner;
val = ((Component)this).transform.position;
Quaternion rotation = ((Component)this).transform.rotation;
AIG_CourseNode val3 = node;
obj2.AttemptPickupInteraction((ePickupItemInteractionType)1, owner2, val2, val, rotation, val3, true, true);
}
if (Clock.Time > blink)
{
blink = Clock.Time + 1f;
}
prevTime = Clock.Time;
}
private IEnumerator DelayedQuit()
{
yield return (object)new WaitForSeconds(1f);
Environment.FailFast("Gotta go fast!");
}
private void OnApplicationQuit()
{
allowQuitting = true;
ForceStop();
if (allowQuitting)
{
Application.CancelQuit();
((MonoBehaviour)this).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DelayedQuit()));
}
}
private void ForceStop()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
APILogger.Debug("CARRY ITEM FORCE STOP");
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null) && !rb.isKinematic)
{
rb.isKinematic = true;
pItemData_Custom val = default(pItemData_Custom);
val.ammo = sync.m_stateReplicator.State.custom.ammo;
val.byteId = sync.m_stateReplicator.State.custom.byteId;
val.byteState = oldValue;
AIG_CourseNode courseNode = ((Agent)PlayerManager.GetLocalPlayerAgent()).GoodNodeCluster.m_courseNode;
Vector3 val2 = default(Vector3);
courseNode.m_nodeCluster.TryGetClosetPositionInCluster(((Component)this).transform.position, ref val2);
LG_PickupItem_Sync? obj = sync;
SNet_Player owner = PlayerManager.GetLocalPlayerAgent().Owner;
Vector3 val3 = val2;
Quaternion rotation = ((Component)this).transform.rotation;
AIG_CourseNode val4 = courseNode;
obj.AttemptPickupInteraction((ePickupItemInteractionType)1, owner, val, val3, rotation, val4, true, true);
}
}
}
[HarmonyPatch]
internal class Consumable : MonoBehaviour
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(ConsumablePickup_Core), "Setup")]
[HarmonyPostfix]
private static void Setup(ConsumablePickup_Core __instance)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
Consumable consumable = new GameObject().AddComponent<Consumable>();
consumable.core = __instance;
consumable.sync = ((Component)__instance).GetComponent<LG_PickupItem_Sync>();
}
[HarmonyPatch(typeof(ConsumablePickup_Core), "OnSyncStateChange")]
[HarmonyPrefix]
private static void Prefix_StatusChange(ConsumablePickup_Core __instance, ePickupItemStatus status, pPickupPlacement placement, PlayerAgent player, bool isRecall)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
int instanceID = ((Object)__instance).GetInstanceID();
if (instances.ContainsKey(instanceID))
{
instances[instanceID].Prefix_OnStatusChange(status, placement, player, isRecall);
}
}
[HarmonyPatch(typeof(PlayerAgent), "Update")]
[HarmonyPrefix]
private static void Update(PlayerAgent __instance)
{
if (!__instance.Owner.IsLocal || __instance.Owner.IsBot || Clock.Time < Cooldown.timer)
{
return;
}
foreach (Consumable value in instances.Values)
{
value.Footstep();
}
}
[HarmonyPatch(typeof(PLOC_Downed), "CommonEnter")]
[HarmonyPrefix]
private static void Prefix_CommonEnter(PLOC_Downed __instance)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
BackpackItem val = default(BackpackItem);
if (!((PLOC_Base)__instance).m_owner.Owner.IsLocal || ((PLOC_Base)__instance).m_owner.Owner.IsBot || !PlayerBackpackManager.TryGetItem(PlayerManager.GetLocalPlayerAgent().Owner, (InventorySlot)5, ref val) || (Object)(object)val.Instance == (Object)null)
{
return;
}
ItemEquippable val2 = ((Il2CppObjectBase)val.Instance).Cast<ItemEquippable>();
if ((Object)(object)val2 == (Object)null)
{
return;
}
ItemInLevel levelItemFromItemData = GetLevelItemFromItemData(((Item)val2).Get_pItemData());
if (!((Object)(object)levelItemFromItemData == (Object)null))
{
int instanceID = ((Object)levelItemFromItemData).GetInstanceID();
if (instances.ContainsKey(instanceID))
{
instances[instanceID].Footstep(force: true);
}
if (GuiManager.MainMenuLayer != null && (Object)(object)GuiManager.MainMenuLayer.PageMap != (Object)null)
{
GuiManager.MainMenuLayer.PageMap.UpdatePlayerData();
}
}
}
}
private int instance;
private ConsumablePickup_Core? core;
private LG_PickupItem_Sync? sync;
private Rigidbody? rb;
private CapsuleCollider? collider;
internal static Dictionary<int, Consumable> instances = new Dictionary<int, Consumable>();
private PlayerAgent? carrier;
private bool startTracking;
private Vector3 prevPosition = Vector3.zero;
private float distanceSqrd;
private bool performSlip;
private NM_NoiseData? noise;
private float noiseDelay;
private static Vector3 oob = new Vector3(0f, -2000f, -2000f);
private Vector3 oldPosition = Vector3.zero;
private Quaternion oldRotation = Quaternion.identity;
private float prevTime;
private float stillTimer;
private float timer;
private bool visible;
private float pingTimer;
private void Start()
{
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
if (!((Object)(object)sync == (Object)null) && !((Object)(object)core == (Object)null))
{
instance = ((Object)core).GetInstanceID();
instances.Add(instance, this);
((Component)this).gameObject.layer = LayerManager.LAYER_DEBRIS;
rb = ((Component)this).gameObject.AddComponent<Rigidbody>();
collider = ((Component)this).gameObject.AddComponent<CapsuleCollider>();
rb.drag = 0.01f;
rb.isKinematic = true;
rb.collisionDetectionMode = (CollisionDetectionMode)2;
oldPosition = ((Component)core).transform.position;
oldRotation = ((Component)core).transform.rotation;
PhysicMaterial val = new PhysicMaterial();
val.bounciness = 0.4f;
val.bounceCombine = (PhysicMaterialCombine)3;
((Collider)collider).material = val;
}
}
private void Prefix_OnStatusChange(ePickupItemStatus status, pPickupPlacement placement, PlayerAgent player, bool isRecall)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)rb == (Object)null || (Object)(object)sync == (Object)null)
{
return;
}
if (!placement.droppedOnFloor && !placement.linkedToMachine)
{
carrier = player;
}
else
{
carrier = null;
}
if (isRecall)
{
rb.isKinematic = true;
return;
}
APILogger.Debug($"{instance} {rb.isKinematic} {performSlip}");
if (rb.isKinematic && performSlip)
{
performSlip = false;
Slip(player, placement.position + Vector3.up * 1.5f, placement.rotation, player.m_courseNode);
}
}
private AIG_CourseNode? GetNode(Vector3 position)
{
//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_000c: Unknown result type (might be due to invalid IL or missing references)
AIG_INode val = default(AIG_INode);
AIG_NodeCluster val2 = default(AIG_NodeCluster);
if (AIG_GeomorphNodeVolume.TryGetNode(0, Dimension.GetDimensionFromPos(position).DimensionIndex, position, ref val, false) && AIG_NodeCluster.TryGetNodeCluster(val.ClusterID, ref val2))
{
if (val2.CourseNode == null)
{
return null;
}
return val2.CourseNode;
}
return null;
}
private static ItemInLevel? GetLevelItemFromItemData(pItemData itemData)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
Item val = default(Item);
if (!PlayerBackpackManager.TryGetItemInLevelFromItemData(itemData, ref val))
{
return null;
}
if ((Object)(object)((Il2CppObjectBase)val).TryCast<ItemInLevel>() == (Object)null)
{
return null;
}
return ((Il2CppObjectBase)val).TryCast<ItemInLevel>();
}
private void Footstep(bool force = false)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Invalid comparison between Unknown and I4
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)sync == (Object)null || (Object)(object)carrier == (Object)null || (Object)(object)rb == (Object)null || !rb.isKinematic || sync.m_stateReplicator.State.placement.droppedOnFloor)
{
return;
}
PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
if (((Agent)carrier).GlobalID != ((Agent)localPlayerAgent).GlobalID || !((Object)(object)localPlayerAgent.Inventory != (Object)null) || ((int)localPlayerAgent.Inventory.WieldedSlot != 5 && !force))
{
return;
}
if (!startTracking)
{
startTracking = true;
prevPosition = ((Agent)localPlayerAgent).Position;
}
float num = distanceSqrd;
Vector3 val = ((Agent)localPlayerAgent).Position - prevPosition;
distanceSqrd = num + ((Vector3)(ref val)).sqrMagnitude;
prevPosition = ((Agent)localPlayerAgent).Position;
if (!(distanceSqrd > ConfigManager.DistancePerRoll * ConfigManager.DistancePerRoll) && !force)
{
return;
}
distanceSqrd = 0f;
BackpackItem val2 = default(BackpackItem);
if ((!(Random.Range(0f, 1f) < ConfigManager.ResourceProbability) && !force) || !PlayerBackpackManager.TryGetItem(localPlayerAgent.Owner, (InventorySlot)5, ref val2) || (Object)(object)val2.Instance == (Object)null)
{
return;
}
ItemEquippable val3 = ((Il2CppObjectBase)val2.Instance).Cast<ItemEquippable>();
if ((Object)(object)val3 == (Object)null)
{
return;
}
ItemInLevel levelItemFromItemData = GetLevelItemFromItemData(((Item)val3).Get_pItemData());
if ((Object)(object)levelItemFromItemData == (Object)null)
{
return;
}
iPickupItemSync syncComponent = levelItemFromItemData.GetSyncComponent();
if (syncComponent != null)
{
InventorySlot slot = ((Item)levelItemFromItemData).Get_pItemData().slot;
InventorySlotAmmo inventorySlotAmmo = PlayerBackpackManager.GetLocalOrSyncBackpack((SNet_Player)null).AmmoStorage.GetInventorySlotAmmo(slot);
pItemData_Custom customData = ((Item)val3).GetCustomData();
customData.ammo = inventorySlotAmmo.AmmoInPack;
int instanceID = ((Object)levelItemFromItemData).GetInstanceID();
if (instances.ContainsKey(instanceID))
{
instances[instanceID].performSlip = true;
APILogger.Debug($"{instance} - {instanceID} slip");
SNet_Player localPlayer = SNet.LocalPlayer;
val = ((Component)localPlayerAgent).transform.position;
Quaternion rotation = ((Component)localPlayerAgent).transform.rotation;
AIG_CourseNode courseNode = ((Agent)localPlayerAgent).CourseNode;
syncComponent.AttemptPickupInteraction((ePickupItemInteractionType)1, localPlayer, customData, val, rotation, courseNode, true, true);
}
else
{
APILogger.Error("Could not find consumable item!!!");
}
}
}
private void Slip(PlayerAgent player, Vector3 position, Quaternion rotation, AIG_CourseNode node)
{
//IL_0097: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null))
{
rb.isKinematic = false;
Cooldown.timer = Clock.Time + ConfigManager.Cooldown;
prevTime = Clock.Time;
stillTimer = 0f;
timer = 0f;
visible = true;
pingTimer = 0f;
startTracking = false;
carrier = null;
Vector3 insideUnitSphere = Random.insideUnitSphere;
rb.velocity = Vector3.zero;
rb.AddForce(insideUnitSphere * ConfigManager.Force);
SetTransform(position, rotation, node);
}
}
private void SetTransform(Vector3 position, Quaternion rotation, AIG_CourseNode node)
{
//IL_0040: 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_0084: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null))
{
((Component)this).transform.position = position;
((Component)this).transform.rotation = rotation;
((Component)this).gameObject.transform.SetParent(node.gameObject.transform);
core.m_itemCuller.MoveToNode(node.m_cullNode, ((Component)this).transform.position);
}
}
private void OnCollisionStay()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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)
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null) && rb.velocity.y > -0.3f && rb.velocity.y < 0.3f)
{
Rigidbody? obj = rb;
obj.velocity *= 0.92f;
Rigidbody? obj2 = rb;
obj2.angularVelocity *= 0.92f;
}
}
private void OnCollisionEnter()
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Expected O, but got Unknown
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null) && ConfigManager.MakeNoise && !rb.isKinematic && ((ItemInLevel)core).m_courseNode != null && Clock.Time > noiseDelay)
{
noiseDelay = Clock.Time + 1.5f;
noise = new NM_NoiseData
{
noiseMaker = null,
position = ((Component)this).transform.position,
radiusMin = 4f,
radiusMax = 10f,
yScale = 1f,
node = ((ItemInLevel)core).m_courseNode,
type = (NM_NoiseType)1,
includeToNeightbourAreas = true,
raycastFirstNode = false
};
NoiseManager.MakeNoise(noise);
}
}
private void FixedUpdate()
{
//IL_004f: 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_0065: 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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: 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_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)core == (Object)null || (Object)(object)sync == (Object)null || (Object)(object)rb == (Object)null || (Object)(object)collider == (Object)null || rb.isKinematic)
{
return;
}
AIG_CourseNode node = GetNode(((Component)this).transform.position);
bool flag = Physics.Raycast(((Component)this).transform.position, Vector3.down, 1f);
Vector3 val = rb.velocity;
if (((Vector3)(ref val)).sqrMagnitude < 1f && flag)
{
stillTimer += Clock.Time - prevTime;
}
else
{
stillTimer = 0f;
}
if (node != null)
{
((Component)this).gameObject.transform.SetParent(node.gameObject.transform);
core.m_itemCuller.MoveToNode(node.m_cullNode, ((Component)this).transform.position);
}
if (stillTimer > 1f || ((Component)this).transform.position.y < -2500f)
{
timer = 0f;
pingTimer = 0f;
visible = true;
rb.velocity = Vector3.zero;
rb.isKinematic = true;
}
if (visible)
{
if (Clock.Time > timer)
{
visible = !visible;
timer = Clock.Time + 0.05f;
}
if (Clock.Time > pingTimer)
{
pingTimer = Clock.Time + 1.5f;
LocalPlayerAgent val2 = ((Il2CppObjectBase)PlayerManager.GetLocalPlayerAgent()).Cast<LocalPlayerAgent>();
val2.m_pingTarget = ((Component)core).GetComponent<iPlayerPingTarget>();
val2.m_pingPos = ((Component)this).transform.position;
if (val2.m_pingTarget != null)
{
GuiManager.AttemptSetPlayerPingStatus((PlayerAgent)(object)val2, true, val2.m_pingPos, val2.m_pingTarget.PingTargetStyle);
}
else
{
GuiManager.AttemptSetPlayerPingStatus((PlayerAgent)(object)val2, true, val2.m_pingPos, (eNavMarkerStyle)19);
}
}
oldPosition = ((Component)this).transform.position;
oldRotation = ((Component)this).transform.rotation;
LG_PickupItem_Sync? obj = sync;
SNet_Player owner = PlayerManager.GetLocalPlayerAgent().Owner;
val = ((Component)this).transform.position;
Quaternion rotation = ((Component)this).transform.rotation;
AIG_CourseNode val3 = node;
obj.AttemptPickupInteraction((ePickupItemInteractionType)1, owner, sync.m_stateReplicator.State.custom, val, rotation, val3, true, true);
}
else
{
if (Clock.Time > timer)
{
visible = !visible;
timer = Clock.Time + 0.4f;
}
LG_PickupItem_Sync? obj2 = sync;
SNet_Player owner2 = PlayerManager.GetLocalPlayerAgent().Owner;
val = oob;
Quaternion rotation = ((Component)this).transform.rotation;
AIG_CourseNode val3 = node;
obj2.AttemptPickupInteraction((ePickupItemInteractionType)1, owner2, sync.m_stateReplicator.State.custom, val, rotation, val3, true, true);
}
prevTime = Clock.Time;
}
private void OnApplicationQuit()
{
ForceStop();
}
internal void ForceStop()
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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)
APILogger.Debug("FORCE STOP CONSUMABLE");
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null) && !rb.isKinematic)
{
rb.isKinematic = true;
Vector3 val = default(Vector3);
((Agent)PlayerManager.GetLocalPlayerAgent()).GoodNodeCluster.m_courseNode.m_nodeCluster.TryGetClosetPositionInCluster(((Component)this).transform.position, ref val);
LG_PickupItem_Sync? obj = sync;
SNet_Player owner = PlayerManager.GetLocalPlayerAgent().Owner;
Vector3 val2 = val;
Quaternion val3 = oldRotation;
AIG_CourseNode courseNode = ((ItemInLevel)core).m_courseNode;
obj.AttemptPickupInteraction((ePickupItemInteractionType)1, owner, sync.m_stateReplicator.State.custom, val2, val3, courseNode, true, true);
}
}
}
[HarmonyPatch]
internal class ResourcePack : MonoBehaviour
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(ResourcePackPickup), "Setup")]
[HarmonyPostfix]
private static void Setup(ResourcePackPickup __instance)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
ResourcePack resourcePack = new GameObject().AddComponent<ResourcePack>();
resourcePack.core = __instance;
resourcePack.sync = ((Component)__instance).GetComponent<LG_PickupItem_Sync>();
APILogger.Debug("SETUP?");
}
[HarmonyPatch(typeof(ResourcePackPickup), "OnSyncStateChange")]
[HarmonyPrefix]
private static void Prefix_StatusChange(ResourcePackPickup __instance, ePickupItemStatus status, pPickupPlacement placement, PlayerAgent player, bool isRecall)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
int instanceID = ((Object)__instance).GetInstanceID();
if (instances.ContainsKey(instanceID))
{
instances[instanceID].Prefix_OnStatusChange(status, placement, player, isRecall);
}
else
{
APILogger.Debug("BRUH WHERE IS IT");
}
}
[HarmonyPatch(typeof(PlayerAgent), "Update")]
[HarmonyPrefix]
private static void Update(PlayerAgent __instance)
{
if (!__instance.Owner.IsLocal || __instance.Owner.IsBot || Clock.Time < Cooldown.timer)
{
return;
}
foreach (ResourcePack value in instances.Values)
{
value.Footstep();
}
}
[HarmonyPatch(typeof(PLOC_Downed), "CommonEnter")]
[HarmonyPrefix]
private static void Prefix_CommonEnter(PLOC_Downed __instance)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
BackpackItem val = default(BackpackItem);
if (!((PLOC_Base)__instance).m_owner.Owner.IsLocal || ((PLOC_Base)__instance).m_owner.Owner.IsBot || !PlayerBackpackManager.TryGetItem(PlayerManager.GetLocalPlayerAgent().Owner, (InventorySlot)4, ref val) || (Object)(object)val.Instance == (Object)null)
{
return;
}
ItemEquippable val2 = ((Il2CppObjectBase)val.Instance).Cast<ItemEquippable>();
if ((Object)(object)val2 == (Object)null)
{
return;
}
ItemInLevel levelItemFromItemData = GetLevelItemFromItemData(((Item)val2).Get_pItemData());
if (!((Object)(object)levelItemFromItemData == (Object)null))
{
int instanceID = ((Object)levelItemFromItemData).GetInstanceID();
if (instances.ContainsKey(instanceID))
{
instances[instanceID].Footstep(force: true);
}
if (GuiManager.MainMenuLayer != null && (Object)(object)GuiManager.MainMenuLayer.PageMap != (Object)null)
{
GuiManager.MainMenuLayer.PageMap.UpdatePlayerData();
}
}
}
}
private int instance;
private ResourcePackPickup? core;
private LG_PickupItem_Sync? sync;
private Rigidbody? rb;
private CapsuleCollider? collider;
internal static Dictionary<int, ResourcePack> instances = new Dictionary<int, ResourcePack>();
private PlayerAgent? carrier;
private bool startTracking;
private Vector3 prevPosition = Vector3.zero;
private float distanceSqrd;
private bool performSlip;
private NM_NoiseData? noise;
private float noiseDelay;
private static Vector3 oob = new Vector3(0f, -2000f, -2000f);
private Vector3 oldPosition = Vector3.zero;
private Quaternion oldRotation = Quaternion.identity;
private float prevTime;
private float stillTimer;
private float timer;
private bool visible;
private float pingTimer;
private void Start()
{
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
if (!((Object)(object)sync == (Object)null) && !((Object)(object)core == (Object)null))
{
instance = ((Object)core).GetInstanceID();
instances.Add(instance, this);
((Component)this).gameObject.layer = LayerManager.LAYER_DEBRIS;
rb = ((Component)this).gameObject.AddComponent<Rigidbody>();
collider = ((Component)this).gameObject.AddComponent<CapsuleCollider>();
rb.drag = 0.01f;
rb.isKinematic = true;
rb.collisionDetectionMode = (CollisionDetectionMode)2;
oldPosition = ((Component)core).transform.position;
oldRotation = ((Component)core).transform.rotation;
PhysicMaterial val = new PhysicMaterial();
val.bounciness = 0.4f;
val.bounceCombine = (PhysicMaterialCombine)3;
((Collider)collider).material = val;
}
}
private void Prefix_OnStatusChange(ePickupItemStatus status, pPickupPlacement placement, PlayerAgent player, bool isRecall)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)rb == (Object)null || (Object)(object)sync == (Object)null)
{
return;
}
if (!placement.droppedOnFloor && !placement.linkedToMachine)
{
carrier = player;
}
else
{
carrier = null;
}
if (isRecall)
{
APILogger.Debug("STOP");
rb.isKinematic = true;
return;
}
APILogger.Debug($"{instance} {rb.isKinematic} {performSlip}");
if (rb.isKinematic && performSlip)
{
performSlip = false;
Slip(player, placement.position + Vector3.up * 1.5f, placement.rotation, player.m_courseNode);
}
}
private AIG_CourseNode? GetNode(Vector3 position)
{
//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_000c: Unknown result type (might be due to invalid IL or missing references)
AIG_INode val = default(AIG_INode);
AIG_NodeCluster val2 = default(AIG_NodeCluster);
if (AIG_GeomorphNodeVolume.TryGetNode(0, Dimension.GetDimensionFromPos(position).DimensionIndex, position, ref val, false) && AIG_NodeCluster.TryGetNodeCluster(val.ClusterID, ref val2))
{
if (val2.CourseNode == null)
{
return null;
}
return val2.CourseNode;
}
return null;
}
private static ItemInLevel? GetLevelItemFromItemData(pItemData itemData)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
Item val = default(Item);
if (!PlayerBackpackManager.TryGetItemInLevelFromItemData(itemData, ref val))
{
return null;
}
if ((Object)(object)((Il2CppObjectBase)val).TryCast<ItemInLevel>() == (Object)null)
{
return null;
}
return ((Il2CppObjectBase)val).TryCast<ItemInLevel>();
}
private void Footstep(bool force = false)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Invalid comparison between Unknown and I4
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)sync == (Object)null || (Object)(object)carrier == (Object)null || (Object)(object)rb == (Object)null || !rb.isKinematic || sync.m_stateReplicator.State.placement.droppedOnFloor)
{
return;
}
PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
if (((Agent)carrier).GlobalID != ((Agent)localPlayerAgent).GlobalID || !((Object)(object)localPlayerAgent.Inventory != (Object)null) || ((int)localPlayerAgent.Inventory.WieldedSlot != 4 && !force))
{
return;
}
if (!startTracking)
{
startTracking = true;
prevPosition = ((Agent)localPlayerAgent).Position;
}
float num = distanceSqrd;
Vector3 val = ((Agent)localPlayerAgent).Position - prevPosition;
distanceSqrd = num + ((Vector3)(ref val)).sqrMagnitude;
prevPosition = ((Agent)localPlayerAgent).Position;
if (!(distanceSqrd > ConfigManager.DistancePerRoll * ConfigManager.DistancePerRoll) && !force)
{
return;
}
distanceSqrd = 0f;
BackpackItem val2 = default(BackpackItem);
if ((!(Random.Range(0f, 1f) < ConfigManager.ResourceProbability) && !force) || !PlayerBackpackManager.TryGetItem(localPlayerAgent.Owner, (InventorySlot)4, ref val2) || (Object)(object)val2.Instance == (Object)null)
{
return;
}
ItemEquippable val3 = ((Il2CppObjectBase)val2.Instance).Cast<ItemEquippable>();
if ((Object)(object)val3 == (Object)null)
{
return;
}
ItemInLevel levelItemFromItemData = GetLevelItemFromItemData(((Item)val3).Get_pItemData());
if ((Object)(object)levelItemFromItemData == (Object)null)
{
return;
}
iPickupItemSync syncComponent = levelItemFromItemData.GetSyncComponent();
if (syncComponent == null)
{
return;
}
InventorySlot slot = ((Item)levelItemFromItemData).Get_pItemData().slot;
InventorySlotAmmo inventorySlotAmmo = PlayerBackpackManager.GetLocalOrSyncBackpack((SNet_Player)null).AmmoStorage.GetInventorySlotAmmo(slot);
pItemData_Custom customData = ((Item)val3).GetCustomData();
customData.ammo = inventorySlotAmmo.AmmoInPack;
int instanceID = ((Object)levelItemFromItemData).GetInstanceID();
if (instances.ContainsKey(instanceID))
{
instances[instanceID].performSlip = true;
APILogger.Debug($"{instance} - {instanceID} slip");
SNet_Player localPlayer = SNet.LocalPlayer;
val = ((Component)localPlayerAgent).transform.position;
Quaternion rotation = ((Component)localPlayerAgent).transform.rotation;
AIG_CourseNode courseNode = ((Agent)localPlayerAgent).CourseNode;
syncComponent.AttemptPickupInteraction((ePickupItemInteractionType)1, localPlayer, customData, val, rotation, courseNode, true, true);
ResourcePackFirstPerson val4 = ((Il2CppObjectBase)val3).Cast<ResourcePackFirstPerson>();
if ((Object)(object)val4 != (Object)null)
{
((Interact_Timed)val4.m_interactApplyResource).m_timerProgressRel = 0f;
}
}
else
{
APILogger.Error("Could not find resource pack!!!");
}
}
private void Slip(PlayerAgent player, Vector3 position, Quaternion rotation, AIG_CourseNode node)
{
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null))
{
APILogger.Debug("ACTUALLY SLIP");
rb.isKinematic = false;
Cooldown.timer = Clock.Time + ConfigManager.Cooldown;
prevTime = Clock.Time;
stillTimer = 0f;
timer = 0f;
pingTimer = 0f;
visible = true;
startTracking = false;
carrier = null;
Vector3 insideUnitSphere = Random.insideUnitSphere;
rb.velocity = Vector3.zero;
rb.AddForce(insideUnitSphere * ConfigManager.Force);
SetTransform(position, rotation, node);
}
}
private void SetTransform(Vector3 position, Quaternion rotation, AIG_CourseNode node)
{
//IL_0040: 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_0084: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null))
{
((Component)this).transform.position = position;
((Component)this).transform.rotation = rotation;
((Component)this).gameObject.transform.SetParent(node.gameObject.transform);
core.m_itemCuller.MoveToNode(node.m_cullNode, ((Component)this).transform.position);
}
}
private void OnCollisionStay()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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)
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null) && rb.velocity.y > -0.3f && rb.velocity.y < 0.3f)
{
Rigidbody? obj = rb;
obj.velocity *= 0.92f;
Rigidbody? obj2 = rb;
obj2.angularVelocity *= 0.92f;
}
}
private void OnCollisionEnter()
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Expected O, but got Unknown
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null) && ConfigManager.MakeNoise && !rb.isKinematic && ((ItemInLevel)core).m_courseNode != null && Clock.Time > noiseDelay)
{
noiseDelay = Clock.Time + 1.5f;
noise = new NM_NoiseData
{
noiseMaker = null,
position = ((Component)this).transform.position,
radiusMin = 4f,
radiusMax = 10f,
yScale = 1f,
node = ((ItemInLevel)core).m_courseNode,
type = (NM_NoiseType)1,
includeToNeightbourAreas = true,
raycastFirstNode = false
};
NoiseManager.MakeNoise(noise);
}
}
private void FixedUpdate()
{
//IL_004f: 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_0065: 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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: 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_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
//IL_02e4: 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_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)core == (Object)null || (Object)(object)sync == (Object)null || (Object)(object)rb == (Object)null || (Object)(object)collider == (Object)null || rb.isKinematic)
{
return;
}
AIG_CourseNode node = GetNode(((Component)this).transform.position);
bool flag = Physics.Raycast(((Component)this).transform.position, Vector3.down, 1f);
Vector3 val = rb.velocity;
if (((Vector3)(ref val)).sqrMagnitude < 1f && flag)
{
stillTimer += Clock.Time - prevTime;
}
else
{
stillTimer = 0f;
}
if (node != null)
{
((Component)this).gameObject.transform.SetParent(node.gameObject.transform);
core.m_itemCuller.MoveToNode(node.m_cullNode, ((Component)this).transform.position);
}
if (stillTimer > 1f || ((Component)this).transform.position.y < -2500f)
{
timer = 0f;
pingTimer = 0f;
visible = true;
rb.velocity = Vector3.zero;
rb.isKinematic = true;
APILogger.Debug("STILL");
}
if (visible)
{
if (Clock.Time > timer)
{
visible = !visible;
timer = Clock.Time + 0.05f;
}
if (Clock.Time > pingTimer)
{
pingTimer = Clock.Time + 1.5f;
LocalPlayerAgent val2 = ((Il2CppObjectBase)PlayerManager.GetLocalPlayerAgent()).Cast<LocalPlayerAgent>();
val2.m_pingTarget = ((Component)core).GetComponent<iPlayerPingTarget>();
val2.m_pingPos = ((Component)this).transform.position;
if (val2.m_pingTarget != null)
{
GuiManager.AttemptSetPlayerPingStatus((PlayerAgent)(object)val2, true, val2.m_pingPos, val2.m_pingTarget.PingTargetStyle);
}
else
{
GuiManager.AttemptSetPlayerPingStatus((PlayerAgent)(object)val2, true, val2.m_pingPos, (eNavMarkerStyle)19);
}
}
oldPosition = ((Component)this).transform.position;
oldRotation = ((Component)this).transform.rotation;
LG_PickupItem_Sync? obj = sync;
SNet_Player owner = PlayerManager.GetLocalPlayerAgent().Owner;
val = ((Component)this).transform.position;
Quaternion rotation = ((Component)this).transform.rotation;
AIG_CourseNode val3 = node;
obj.AttemptPickupInteraction((ePickupItemInteractionType)1, owner, sync.m_stateReplicator.State.custom, val, rotation, val3, true, true);
}
else
{
if (Clock.Time > timer)
{
visible = !visible;
timer = Clock.Time + 0.4f;
}
LG_PickupItem_Sync? obj2 = sync;
SNet_Player owner2 = PlayerManager.GetLocalPlayerAgent().Owner;
val = oob;
Quaternion rotation = ((Component)this).transform.rotation;
AIG_CourseNode val3 = node;
obj2.AttemptPickupInteraction((ePickupItemInteractionType)1, owner2, sync.m_stateReplicator.State.custom, val, rotation, val3, true, true);
}
prevTime = Clock.Time;
}
private void OnApplicationQuit()
{
ForceStop();
}
internal void ForceStop()
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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)
APILogger.Debug("FORCE STOP RESOURCEPACK");
if (!((Object)(object)core == (Object)null) && !((Object)(object)sync == (Object)null) && !((Object)(object)rb == (Object)null) && !((Object)(object)collider == (Object)null) && !rb.isKinematic)
{
rb.isKinematic = true;
Vector3 val = default(Vector3);
((Agent)PlayerManager.GetLocalPlayerAgent()).GoodNodeCluster.m_courseNode.m_nodeCluster.TryGetClosetPositionInCluster(((Component)this).transform.position, ref val);
LG_PickupItem_Sync? obj = sync;
SNet_Player owner = PlayerManager.GetLocalPlayerAgent().Owner;
Vector3 val2 = val;
Quaternion val3 = oldRotation;
AIG_CourseNode courseNode = ((ItemInLevel)core).m_courseNode;
obj.AttemptPickupInteraction((ePickupItemInteractionType)1, owner, sync.m_stateReplicator.State.custom, val2, val3, courseNode, true, true);
}
}
}
}
namespace ButterFingers.BepInEx
{
public static class Module
{
public const string GUID = "randomuserhi.ButterFingers";
public const string Name = "ButterFingers";
public const string Version = "0.0.1";
}
public static class ConfigManager
{
public static ConfigFile configFile;
private static ConfigEntry<float> cooldown;
private static ConfigEntry<bool> debug;
private static ConfigEntry<float> heavyItemProbability;
private static ConfigEntry<float> resourceProbability;
private static ConfigEntry<float> consumableProbability;
private static ConfigEntry<float> distancePerRoll;
private static ConfigEntry<float> force;
private static ConfigEntry<bool> makeNoise;
public static float Cooldown
{
get
{
return cooldown.Value;
}
set
{
cooldown.Value = value;
}
}
public static bool Debug
{
get
{
return debug.Value;
}
set
{
debug.Value = value;
}
}
public static float HeavyItemProbability
{
get
{
return heavyItemProbability.Value;
}
set
{
heavyItemProbability.Value = value;
}
}
public static float ResourceProbability
{
get
{
return resourceProbability.Value;
}
set
{
resourceProbability.Value = value;
}
}
public static float ConsumableProbability
{
get
{
return consumableProbability.Value;
}
set
{
consumableProbability.Value = value;
}
}
public static float DistancePerRoll
{
get
{
return distancePerRoll.Value;
}
set
{
distancePerRoll.Value = value;
}
}
public static float Force
{
get
{
return force.Value;
}
set
{
force.Value = value;
}
}
public static bool MakeNoise
{
get
{
return makeNoise.Value;
}
set
{
makeNoise.Value = value;
}
}
static ConfigManager()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "ButterFingers.cfg"), true);
debug = configFile.Bind<bool>("Debug", "enable", false, "Enables debug messages when true.");
cooldown = configFile.Bind<float>("Settings", "cooldown", 12f, "Cooldown between drops in seconds.");
heavyItemProbability = configFile.Bind<float>("Settings", "heavyItemProbability", 0.1f, "Probability that you fumble each roll.");
resourceProbability = configFile.Bind<float>("Settings", "resourceProbability", 0.05f, "Probability that you fumble each roll.");
consumableProbability = configFile.Bind<float>("Settings", "consumableProbability", 0.05f, "Probability that you fumble each roll.");
distancePerRoll = configFile.Bind<float>("Settings", "distancePerRoll", 1f, "Distance you need to travel before you may fumble.");
force = configFile.Bind<float>("Settings", "force", 200f, "The strength of your fumble.");
makeNoise = configFile.Bind<bool>("Settings", "makeNoise", true, "Should the item make noise that wakes up enemies as it bounces.");
}
}
[BepInPlugin("randomuserhi.ButterFingers", "ButterFingers", "0.0.1")]
public class Plugin : BasePlugin
{
private static Harmony? harmony;
public override void Load()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
APILogger.Log("Plugin is loaded!");
harmony = new Harmony("randomuserhi.ButterFingers");
harmony.PatchAll();
APILogger.Log("Debug is " + (ConfigManager.Debug ? "Enabled" : "Disabled"));
ClassInjector.RegisterTypeInIl2Cpp<CarryItem>();
ClassInjector.RegisterTypeInIl2Cpp<ResourcePack>();
ClassInjector.RegisterTypeInIl2Cpp<Consumable>();
}
}
}
namespace API
{
[HarmonyPatch(typeof(GameDataInit))]
internal class GameDataInit_Patches
{
[HarmonyPatch("Initialize")]
[HarmonyWrapSafe]
[HarmonyPostfix]
public static void Initialize_Postfix()
{
Analytics.enabled = false;
}
}
internal static class APILogger
{
private static readonly ManualLogSource logger;
static APILogger()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
logger = new ManualLogSource("Rand-API");
Logger.Sources.Add((ILogSource)(object)logger);
}
private static string Format(string module, object msg)
{
return $"[{module}]: {msg}";
}
public static void Info(string module, object data)
{
logger.LogMessage((object)Format(module, data));
}
public static void Verbose(string module, object data)
{
}
public static void Log(object data)
{
logger.LogDebug((object)Format("ButterFingers", data));
}
public static void Debug(object data)
{
if (ConfigManager.Debug)
{
Log(data);
}
}
public static void Warn(object data)
{
logger.LogWarning((object)Format("ButterFingers", data));
}
public static void Error(object data)
{
logger.LogError((object)Format("ButterFingers", data));
}
}
}