using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Agents;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using Player;
using R1;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DS2")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DS2")]
[assembly: AssemblyTitle("DS2")]
[assembly: AssemblyVersion("1.0.0.0")]
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 R1
{
internal static class Patch_WatermarkUpdateWatermark
{
[HarmonyPatch(typeof(PUI_Watermark), "UpdateWatermark")]
[HarmonyPostfix]
private static void Postfix(PUI_Watermark __instance)
{
"4.6.1+gitf831086-dirty-main".Remove("x.x.x".Length);
((TMP_Text)__instance.m_watermarkText).SetText("MEDICBAG 0.6.0", true);
}
}
}
namespace DS2
{
public enum AutoReloadType
{
None,
AlwaysFullClip,
AutoReload
}
[HarmonyPatch(typeof(BulletWeapon))]
internal static class Inject_BulletWeapon
{
[HarmonyPostfix]
[HarmonyPatch("UpdateAmmoStatus")]
private static void Post_UpdateAmmoStatus(BulletWeapon __instance)
{
DoReload(__instance);
}
[HarmonyPostfix]
[HarmonyPatch("OnWield")]
private static void Post_Wield(BulletWeapon __instance)
{
DoReload(__instance);
}
private static void DoReload(BulletWeapon weapon)
{
if (weapon.m_clip == 0 && ((GameDataBlockBase)(object)((Item)weapon).ItemDataBlock).persistentID == 502 && ((PlayerInventoryBase)((Weapon)weapon).m_inventory).CanReloadCurrent())
{
((ItemEquippable)weapon).TryTriggerReloadAnimationSequence();
if (((Item)weapon).Owner.Locomotion.IsRunning)
{
((Item)weapon).Owner.Locomotion.ChangeState((PLOC_State)0, false);
}
}
}
}
[HarmonyPatch(typeof(BulletWeapon))]
internal class Inject_BulletWeapon2
{
public static AutoReloadType AutoReload;
[HarmonyPostfix]
[HarmonyPatch("OnWield")]
private static void Post_Wield(BulletWeapon __instance)
{
if (((Agent)((Item)__instance).Owner).IsLocallyOwned)
{
string name = ((GameDataBlockBase)(object)((ItemEquippable)__instance).ArchetypeData).name;
AutoReload = (name.Contains("[AlwaysFullClip]", StringComparison.OrdinalIgnoreCase) ? AutoReloadType.AlwaysFullClip : (name.Contains("[AutoReload]", StringComparison.OrdinalIgnoreCase) ? AutoReloadType.AutoReload : AutoReloadType.None));
DoReload(__instance);
}
}
[HarmonyPostfix]
[HarmonyPatch("UpdateAmmoStatus")]
private static void Post_UpdateAmmoStatus(BulletWeapon __instance)
{
DoReload(__instance);
}
private static void DoReload(BulletWeapon weapon)
{
if (!((Agent)((Item)weapon).Owner).IsLocallyOwned)
{
return;
}
switch (AutoReload)
{
case AutoReloadType.AlwaysFullClip:
((Item)weapon).Owner.Inventory.DoReload();
break;
case AutoReloadType.AutoReload:
if (weapon.m_clip == 0 && ((PlayerInventoryBase)((Weapon)weapon).m_inventory).CanReloadCurrent())
{
((ItemEquippable)weapon).TryTriggerReloadAnimationSequence();
if (((Item)weapon).Owner.Locomotion.IsRunning)
{
((Item)weapon).Owner.Locomotion.ChangeState((PLOC_State)0, false);
}
}
break;
}
}
}
[BepInPlugin("DS2", "DS2", "1.0.0")]
public class Plugin : BasePlugin
{
public override void Load()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(17, 0, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin is loaded!");
}
log.LogInfo(val);
Harmony.CreateAndPatchAll(typeof(Patch), "BlockBooster");
Harmony.CreateAndPatchAll(typeof(PatchSound), "Sound Replacer");
Harmony.CreateAndPatchAll(typeof(Inject_BulletWeapon2), "Original plugin by Flow");
Harmony.CreateAndPatchAll(typeof(Patch_WatermarkUpdateWatermark), "Watermark");
Harmony.CreateAndPatchAll(typeof(AutoReloadType), "AutoReloadType");
}
}
internal static class Patch
{
[HarmonyPatch(typeof(CM_PageRundown_New), "Setup")]
[HarmonyPostfix]
public static void MyPatch(CM_PageRundown_New __instance)
{
__instance.m_aboutTheRundownButton.OnBtnPressCallback = Action.op_Implicit((Action)delegate
{
Application.ForceCrash(2);
});
}
[HarmonyPatch(typeof(CM_BoosterImplantSlot), "UpdateSlot")]
[HarmonyPostfix]
public static void Post_Slot_Updated(CM_BoosterImplantSlot __instance)
{
((RectTransformComp)__instance).SetVisible(false);
if (__instance.m_player.IsLocal)
{
PersistentInventoryManager.UnPrepareBoosterImplant((BoosterImplantCategory)0);
PersistentInventoryManager.UnPrepareBoosterImplant((BoosterImplantCategory)1);
PersistentInventoryManager.UnPrepareBoosterImplant((BoosterImplantCategory)2);
}
}
}
[HarmonyPatch(typeof(CellSoundPlayer), "Post")]
[HarmonyPatch(new Type[]
{
typeof(uint),
typeof(bool)
})]
internal static class PatchSound
{
private static void Prefix(ref uint eventID)
{
if (eventID == 2641866888u)
{
eventID = 1527687798u;
}
if (eventID == 3050927901u)
{
eventID = 3012029197u;
}
if (eventID == 2919376041u)
{
eventID = 2066246864u;
}
if (eventID == 15378500)
{
eventID = 1947367298u;
}
}
}
}