using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BMH.MeleeChanges;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using MSC.API;
using MSC.CustomMeleeData;
using Microsoft.CodeAnalysis;
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("BetterMeleeHitbox")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1073ec3951e007c8116cd679ada832804e9ce4bd")]
[assembly: AssemblyProduct("BetterMeleeHitbox")]
[assembly: AssemblyTitle("BetterMeleeHitbox")]
[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 BMH
{
internal static class DinoLogger
{
private static readonly ManualLogSource logger = Logger.CreateLogSource("BetterMeleeHitbox");
public static void Log(string format, params object[] args)
{
Log(string.Format(format, args));
}
public static void Log(string str)
{
if (logger != null)
{
logger.Log((LogLevel)8, (object)str);
}
}
public static void Warning(string format, params object[] args)
{
Warning(string.Format(format, args));
}
public static void Warning(string str)
{
if (logger != null)
{
logger.Log((LogLevel)4, (object)str);
}
}
public static void Error(string format, params object[] args)
{
Error(string.Format(format, args));
}
public static void Error(string str)
{
if (logger != null)
{
logger.Log((LogLevel)2, (object)str);
}
}
public static void Debug(string format, params object[] args)
{
Debug(string.Format(format, args));
}
public static void Debug(string str)
{
if (logger != null)
{
logger.Log((LogLevel)32, (object)str);
}
}
}
[BepInPlugin("Dinorush.BetterMeleeHitbox", "BetterMeleeHitbox", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal sealed class EntryPoint : BasePlugin
{
public const string MODNAME = "BetterMeleeHitbox";
public override void Load()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("BetterMeleeHitbox").PatchAll();
foreach (var (text2, meleeChangeData2) in MeleeChangeData.ChangeDatas)
{
if (meleeChangeData2.TryGetHitboxData(out MeleeData hitboxData))
{
MeleeDataAPI.AddData(text2, hitboxData);
}
}
((BasePlugin)this).Log.LogMessage((object)"Loaded BetterMeleeHitbox");
}
}
}
namespace BMH.Patches
{
[HarmonyPatch(typeof(MeleeWeaponFirstPerson))]
internal static class MeleeSetupPatches
{
[HarmonyPatch("SetupMeleeAnimations")]
[HarmonyAfter(new string[] { "Dinorush.MeleeSwingCustomization" })]
[HarmonyWrapSafe]
[HarmonyPostfix]
private static void Post_MeleeSetup(MeleeWeaponFirstPerson __instance)
{
List<string> firstPersonPrefabs = ((Item)__instance).ItemDataBlock.FirstPersonPrefabs;
if (firstPersonPrefabs != null && firstPersonPrefabs.Count != 0)
{
MeleeChangeData.ChangeDatas[firstPersonPrefabs[0]].Apply(__instance);
}
}
}
}
namespace BMH.MeleeChanges
{
public sealed class MeleeAnimData
{
private readonly float _attackLength;
private readonly float _attackHitTime;
private readonly float _damageStartTime;
private readonly float _damageEndTime;
private readonly float _attackCamFwdHitTime;
private readonly float _comboEarlyTime;
public MeleeAnimData(float attackLength = -1f, float attackHitTime = -1f, float damageStartTime = -1f, float damageEndTime = -1f, float attackCamFwdHitTime = -1f, float comboEarlyTime = -1f)
{
_attackLength = attackLength;
_attackHitTime = attackHitTime;
_damageStartTime = damageStartTime;
_damageEndTime = damageEndTime;
_attackCamFwdHitTime = attackCamFwdHitTime;
_comboEarlyTime = comboEarlyTime;
}
public void Apply(MeleeAttackData data)
{
if (_attackLength >= 0f)
{
data.m_attackLength = _attackLength;
}
if (_attackHitTime >= 0f)
{
data.m_attackHitTime = _attackHitTime;
}
if (_damageStartTime >= 0f)
{
data.m_damageStartTime = _damageStartTime;
}
if (_damageEndTime >= 0f)
{
data.m_damageEndTime = _damageEndTime;
}
if (_attackCamFwdHitTime >= 0f)
{
data.m_attackCamFwdHitTime = _attackCamFwdHitTime;
}
if (_comboEarlyTime >= 0f)
{
data.m_comboEarlyTime = _comboEarlyTime;
}
}
private bool Approximately(float a, float b)
{
return Math.Abs(a - b) <= 0.01f;
}
public bool Equals(MeleeAttackData data)
{
if (_attackLength >= 0f && !Approximately(data.m_attackLength, _attackLength))
{
return false;
}
if (_attackHitTime >= 0f && !Approximately(data.m_attackHitTime, _attackHitTime))
{
return false;
}
if (_damageStartTime >= 0f && !Approximately(data.m_damageStartTime, _damageStartTime))
{
return false;
}
if (_damageEndTime >= 0f && !Approximately(data.m_damageEndTime, _damageEndTime))
{
return false;
}
if (_attackCamFwdHitTime >= 0f && !Approximately(data.m_attackCamFwdHitTime, _attackCamFwdHitTime))
{
return false;
}
if (_comboEarlyTime >= 0f && !Approximately(data.m_comboEarlyTime, _comboEarlyTime))
{
return false;
}
return true;
}
}
public sealed class MeleeAnimTarget
{
public readonly eMeleeWeaponState State;
public readonly MeleeAnimData Target;
public MeleeAnimTarget(eMeleeWeaponState state, MeleeAnimData target)
{
//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)
State = state;
Target = target;
}
}
public sealed class MeleeArchData
{
private readonly float _cameraDamageRayLength;
private readonly float _attackSphereRadius;
public MeleeArchData(float cameraDamageRayLength = -1f, float attackSphereRadius = -1f)
{
_cameraDamageRayLength = cameraDamageRayLength;
_attackSphereRadius = attackSphereRadius;
}
public void Apply(MeleeArchetypeDataBlock data)
{
if (_cameraDamageRayLength >= 0f)
{
data.CameraDamageRayLength = _cameraDamageRayLength;
}
if (_attackSphereRadius >= 0f)
{
data.AttackSphereRadius = _attackSphereRadius;
}
}
private bool Approximately(float a, float b)
{
return Math.Abs(a - b) <= 0.01f;
}
public bool Equals(MeleeArchetypeDataBlock data)
{
if (_cameraDamageRayLength >= 0f && !Approximately(data.CameraDamageRayLength, _cameraDamageRayLength))
{
return false;
}
if (_attackSphereRadius >= 0f && !Approximately(data.AttackSphereRadius, _attackSphereRadius))
{
return false;
}
return true;
}
}
public sealed class MeleeChangeData
{
private readonly List<(MeleeAnimTarget target, MeleeAnimData data)>? _animDatas;
private readonly (MeleeArchData target, MeleeArchData data)? _archData;
private readonly MeleeData? _hitboxData;
public static readonly Dictionary<string, MeleeChangeData> ChangeDatas;
public MeleeChangeData(List<(MeleeAnimTarget target, MeleeAnimData anim)>? animDatas = null, (MeleeArchData target, MeleeArchData arch)? archData = null, MeleeData? hitboxData = null)
{
_animDatas = animDatas;
_archData = archData;
_hitboxData = hitboxData;
}
public bool TryGetHitboxData([MaybeNullWhen(false)] out MeleeData hitboxData)
{
if (_hitboxData == null)
{
hitboxData = null;
return false;
}
hitboxData = _hitboxData;
return true;
}
public void Apply(MeleeWeaponFirstPerson melee)
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected I4, but got Unknown
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Expected I4, but got Unknown
MeleeArchetypeDataBlock meleeArchetypeData = ((ItemEquippable)melee).MeleeArchetypeData;
if (_archData.HasValue && _archData.Value.target.Equals(meleeArchetypeData))
{
_archData.Value.data.Apply(meleeArchetypeData);
}
if (_animDatas == null)
{
return;
}
Il2CppReferenceArray<MWS_Base> states = melee.m_states;
foreach (var animData in _animDatas)
{
MeleeAnimTarget item = animData.target;
MeleeAttackData data = ((Il2CppArrayBase<MWS_Base>)(object)states)[(int)item.State].m_data;
if (!item.Target.Equals(data))
{
return;
}
}
foreach (var animData2 in _animDatas)
{
MeleeAnimTarget item2 = animData2.target;
MeleeAnimData item3 = animData2.data;
MeleeAttackData data2 = ((Il2CppArrayBase<MWS_Base>)(object)states)[(int)item2.State].m_data;
item3.Apply(data2);
}
}
static MeleeChangeData()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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)
//IL_0085: 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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Expected O, but got Unknown
//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0406: Unknown result type (might be due to invalid IL or missing references)
//IL_040d: Unknown result type (might be due to invalid IL or missing references)
//IL_0418: Unknown result type (might be due to invalid IL or missing references)
//IL_0441: Expected O, but got Unknown
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_0451: Expected O, but got Unknown
//IL_045d: Unknown result type (might be due to invalid IL or missing references)
//IL_0462: Unknown result type (might be due to invalid IL or missing references)
//IL_0472: Unknown result type (might be due to invalid IL or missing references)
//IL_048b: Unknown result type (might be due to invalid IL or missing references)
//IL_049e: Unknown result type (might be due to invalid IL or missing references)
//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
//IL_04d0: Expected O, but got Unknown
//IL_04d1: Expected O, but got Unknown
//IL_082b: Unknown result type (might be due to invalid IL or missing references)
//IL_0830: Unknown result type (might be due to invalid IL or missing references)
//IL_0840: Unknown result type (might be due to invalid IL or missing references)
//IL_0859: Unknown result type (might be due to invalid IL or missing references)
//IL_0872: Unknown result type (might be due to invalid IL or missing references)
//IL_087c: Unknown result type (might be due to invalid IL or missing references)
//IL_0881: Unknown result type (might be due to invalid IL or missing references)
//IL_088c: Unknown result type (might be due to invalid IL or missing references)
//IL_0893: Unknown result type (might be due to invalid IL or missing references)
//IL_089e: Unknown result type (might be due to invalid IL or missing references)
//IL_08ae: Expected O, but got Unknown
//IL_08ae: Unknown result type (might be due to invalid IL or missing references)
//IL_08be: Expected O, but got Unknown
Dictionary<string, MeleeChangeData> obj = new Dictionary<string, MeleeChangeData>
{
{
"Assets/AssetPrefabs/Items/Melee/MeleeWeaponFirstPerson.prefab",
new MeleeChangeData(null, (new MeleeArchData(1.8f), new MeleeArchData(1.9f)), new MeleeData
{
AttackOffset = new OffsetData((Vector3?)new Vector3(0f, -0.12f, 0.55f), (Vector3?)new Vector3(0f, 0f, -0.3f), (Vector3?)null)
{
CapsuleSize = 0.05f,
CapsuleUseCamFwd = true,
CapsuleCamFwdAdd = -1.3f,
CapsuleDelay = 0.1f
},
LightAttackSpeed = 1.3f,
AttackSphereCenterMod = 1.5f
})
},
{
"Assets/AssetPrefabs/Items/Melee/MeleeWeaponFirstPersonKnife.prefab",
new MeleeChangeData(new List<(MeleeAnimTarget, MeleeAnimData)>
{
(new MeleeAnimTarget((eMeleeWeaponState)4, new MeleeAnimData(1f, 0.1667f, 0.1f, 0.2667f, 0.1667f, 0.5f)), new MeleeAnimData(-1f, -1f, 0.1167f, -1f, 0.1167f, 0.4667f)),
(new MeleeAnimTarget((eMeleeWeaponState)3, new MeleeAnimData(1f, 0.1667f, 0.1f, 0.2667f, 0.1667f, 0.5f)), new MeleeAnimData(-1f, -1f, 0.1167f, -1f, 0.1167f, 0.4667f)),
(new MeleeAnimTarget((eMeleeWeaponState)6, new MeleeAnimData(1f, 0.1667f, -1f, -1f, -1f, 0.3f)), new MeleeAnimData(-1f, 0.1167f, -1f, -1f, -1f, 0.3333f)),
(new MeleeAnimTarget((eMeleeWeaponState)5, new MeleeAnimData(1f, 0.1667f, -1f, -1f, -1f, 0.3f)), new MeleeAnimData(-1f, 0.1167f, -1f, -1f, -1f, 0.3333f)),
(new MeleeAnimTarget((eMeleeWeaponState)10, new MeleeAnimData(1f, 0.1667f, 0f, 0.3667f, 0.1667f, 0.3f)), new MeleeAnimData(-1f, 0.1f, 0.08f, -1f, 0.1f)),
(new MeleeAnimTarget((eMeleeWeaponState)8, new MeleeAnimData(1f, 0.1667f, 0f, 0.3667f, 0.1667f, 0.3f)), new MeleeAnimData(-1f, 0.1f, 0.0667f, -1f, 0.1f)),
(new MeleeAnimTarget((eMeleeWeaponState)12, new MeleeAnimData(1f, 0.1334f, -1f, -1f, -1f, 0.3f)), new MeleeAnimData(-1f, -1f, -1f, -1f, -1f, 0.3333f)),
(new MeleeAnimTarget((eMeleeWeaponState)11, new MeleeAnimData(1f, 0.1334f, -1f, -1f, -1f, 0.3f)), new MeleeAnimData(-1f, -1f, -1f, -1f, -1f, 0.3333f))
}, (new MeleeArchData(1.75f, 0.25f), new MeleeArchData(2f, 0.15f)), new MeleeData
{
AttackOffset = new OffsetData((Vector3?)new Vector3(0f, 0.35f, 0.076f), (Vector3?)new Vector3(0f, -0.4f, 0f), (Vector3?)null)
{
CapsuleSize = 0.05f,
CapsuleUseCamFwd = true,
CapsuleCamFwdAdd = -1.7f,
CapsuleStateDelay = new Dictionary<eMeleeWeaponState, float>
{
{
(eMeleeWeaponState)8,
0.05f
},
{
(eMeleeWeaponState)10,
0.05f
}
}
},
AttackSphereCenterMod = 1f
})
}
};
MeleeData hitboxData = new MeleeData
{
AttackOffset = new OffsetData((Vector3?)new Vector3(0f, 1.1f, -0.002f), (Vector3?)new Vector3(0f, -0.3f, 0f), (Vector3?)null)
{
CapsuleSize = 0.05f,
CapsuleUseCamFwd = true,
CapsuleCamFwdAdd = -2.2f,
CapsuleDelay = 0.1f
}
};
obj.Add("Assets/AssetPrefabs/Items/Melee/MeleeWeaponFirstPersonSpear.prefab", new MeleeChangeData(null, null, hitboxData));
obj.Add("Assets/AssetPrefabs/Items/Melee/MeleeWeaponFirstPersonBat.prefab", new MeleeChangeData(new List<(MeleeAnimTarget, MeleeAnimData)>
{
(new MeleeAnimTarget((eMeleeWeaponState)4, new MeleeAnimData(1.3334f, 0.2334f, 0.1334f, 0.667f, -1f, 0.5f)), new MeleeAnimData(0.6667f, -1f, 0.2f, 0.6f, -1f, 0.45f)),
(new MeleeAnimTarget((eMeleeWeaponState)3, new MeleeAnimData(1.3334f, 0.2334f, 0.1334f, 0.667f, -1f, 0.5f)), new MeleeAnimData(0.6667f, -1f, 0.2f, 0.6f, -1f, 0.45f)),
(new MeleeAnimTarget((eMeleeWeaponState)6, new MeleeAnimData(1.3334f, 0.2334f, -1f, -1f, -1f, 0.4f)), new MeleeAnimData(-1f, -1f, -1f, -1f, -1f, 0.33f)),
(new MeleeAnimTarget((eMeleeWeaponState)5, new MeleeAnimData(1.3334f, 0.2334f, -1f, -1f, -1f, 0.4f)), new MeleeAnimData(-1f, -1f, -1f, -1f, -1f, 0.33f)),
(new MeleeAnimTarget((eMeleeWeaponState)13, new MeleeAnimData(1.1667f, 0.2334f, 0.2f, 0.2667f, 0.2334f, 0.667f)), new MeleeAnimData(-1f, -1f, 0.1667f, -1f, 0.1667f, 0.467f)),
(new MeleeAnimTarget((eMeleeWeaponState)10, new MeleeAnimData(0.7f, 0.2334f, 0f, 0.3667f, 0.2334f, 0.3f)), new MeleeAnimData(-1f, -1f, -1f, -1f, -1f, 0.4f)),
(new MeleeAnimTarget((eMeleeWeaponState)8, new MeleeAnimData(0.7f, 0.2334f, 0f, 0.3667f, 0.2334f, 0.3f)), new MeleeAnimData(-1f, -1f, -1f, -1f, -1f, 0.4f)),
(new MeleeAnimTarget((eMeleeWeaponState)12, new MeleeAnimData(1.334f, 0.2334f, 0f, 0f, 0f, 0.4f)), new MeleeAnimData(-1f, -1f, -1f, -1f, -1f, 0.3333f)),
(new MeleeAnimTarget((eMeleeWeaponState)11, new MeleeAnimData(1.334f, 0.2334f, 0f, 0f, 0f, 0.4f)), new MeleeAnimData(-1f, -1f, -1f, -1f, -1f, 0.3333f))
}, (new MeleeArchData(1.75f), new MeleeArchData(1.85f)), new MeleeData
{
AttackOffset = new OffsetData((Vector3?)new Vector3(0f, 0.6f, 0f), (Vector3?)new Vector3(0f, -0.2f, -0.1f), (Vector3?)new Vector3(0f, 0.55f, -0.1f))
{
CapsuleSize = 0.05f,
CapsuleUseCamFwd = true,
CapsuleCamFwdAdd = -1.2f,
CapsuleDelay = 0.05f
},
AttackSphereCenterMod = 1f
}));
ChangeDatas = obj;
}
}
}
namespace BMH.Dependencies
{
internal static class MSCWrapper
{
public const string GUID = "Dinorush.MeleeSwingCustomization";
}
}