using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Agents;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Enemies;
using Gear;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TheArchive;
using TheArchive.Core;
using TheArchive.Core.Attributes.Feature.Members;
using TheArchive.Core.Attributes.Feature.Settings;
using TheArchive.Core.FeaturesAPI;
using TheArchive.Core.FeaturesAPI.Components;
using TheArchive.Core.FeaturesAPI.Settings;
using TheArchive.Core.Localization;
using TheArchive.Interfaces;
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("TF2_Hitsounds")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TF2_Hitsounds")]
[assembly: AssemblyTitle("TF2_Hitsounds")]
[assembly: TargetPlatform("Windows7.0")]
[assembly: SupportedOSPlatform("Windows7.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TeamFortress
{
[BepInPlugin("HatsuneFucker.Hitsounds.TF2", "Hitsounds.TF2", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class EntryPoint : BasePlugin, IArchiveModule
{
private Harmony _Harmony;
public ILocalizationService LocalizationService { get; set; }
public IArchiveLogger Logger { get; set; }
public override void Load()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
_Harmony = new Harmony("TF2.Hitsounds");
_Harmony.PatchAll(typeof(TeamFortressTheSecond));
ArchiveMod.RegisterArchiveModule(typeof(EntryPoint));
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(271, 0, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SoldierTF2: 'If fighting is sure to result in victory, then you must fight!' Sun Tzu said that, and I'd say he knows a little more about fighting than you do, pal, because he invented it, and then he perfected it so that no living man could best him in the ring of honor.");
}
log.LogMessage(val);
}
public void Init()
{
}
}
public static class TF2_Hitsounds
{
public static uint Critical = 1982540530u;
public static uint MiniCrit = 2058778615u;
public static uint TF2_SFX = 2194843653u;
public static Dictionary<string, Dictionary<string, uint>> HitsoundDB = new Dictionary<string, Dictionary<string, uint>>
{
{
"Default",
new Dictionary<string, uint>
{
{ "HitSound", 2475295733u },
{ "KillSound", 3106042834u }
}
},
{
"Electro",
new Dictionary<string, uint>
{
{ "HitSound", 2114375515u },
{ "KillSound", 2386285472u }
}
},
{
"Notes",
new Dictionary<string, uint>
{
{ "HitSound", 849560917u },
{ "KillSound", 3613081112u }
}
},
{
"Percussion",
new Dictionary<string, uint>
{
{ "HitSound", 3850444438u },
{ "KillSound", 4040373391u }
}
},
{
"Retro",
new Dictionary<string, uint>
{
{ "HitSound", 3496907731u },
{ "KillSound", 1879459860u }
}
},
{
"Space",
new Dictionary<string, uint>
{
{ "HitSound", 4164838345u },
{ "KillSound", 454180086u }
}
},
{
"Beepo",
new Dictionary<string, uint>
{
{ "HitSound", 165559140u },
{ "KillSound", 3588240407u }
}
},
{
"Vortex",
new Dictionary<string, uint>
{
{ "HitSound", 1511565765u },
{ "KillSound", 3749318248u }
}
},
{
"Squasher",
new Dictionary<string, uint>
{
{ "HitSound", 250713227u },
{ "KillSound", 1936766546u }
}
}
};
}
public class TeamFortressTheSecond : Feature
{
public class Hitsounds
{
public enum Sounds
{
Default,
Electro,
Notes,
Percussion,
Retro,
Space,
Beepo,
Vortex,
Squasher
}
public enum Toggle
{
BaseSound,
HitSound,
Disabled
}
[FSHeader("Toggles", true)]
[FSDisplayName("Hit Sound Toggle")]
public bool Hits { get; set; } = true;
[FSDisplayName("Kill Sound Toggle")]
public bool Kills { get; set; } = true;
[FSDisplayName("Precision Sound Toggle")]
public Toggle Crits { get; set; }
[FSDisplayName("Back Damage Sound Toggle")]
public Toggle MiniCrits { get; set; }
[FSHeader("Sound Settings", true)]
[FSDisplayName("Hit Sound")]
public Sounds HitType { get; set; }
[FSDisplayName("Kill Sound")]
public Sounds KillType { get; set; }
[FSSeparator]
[FSDisplayName("Play Hits")]
public FButton HitSound { get; set; } = new FButton("Play Hit Sound", (string)null, (Action)null, false);
[FSDisplayName("Play Kills")]
public FButton KillSound { get; set; } = new FButton("Play Kill Sound", (string)null, (Action)null, false);
}
public override string Name => "Team Fortress 2";
public override FeatureGroup Group => FeatureGroups.GetOrCreateModuleGroup("HatsuneFucker39", (GroupLocalization)null);
[FeatureConfig]
public static Hitsounds Settings { get; set; }
public override void OnButtonPressed(ButtonSetting setting)
{
if (setting.ButtonID.Contains("HitSound"))
{
CellSound.Post(TF2_Hitsounds.HitsoundDB[Settings.HitType.ToString()]["HitSound"]);
}
if (setting.ButtonID.Contains("KillSound"))
{
CellSound.Post(TF2_Hitsounds.HitsoundDB[Settings.KillType.ToString()]["KillSound"]);
}
}
[HarmonyPatch(typeof(Dam_EnemyDamageLimb), "BulletDamage")]
[HarmonyPostfix]
internal static void GunHits(Dam_EnemyDamageLimb __instance, ref float dam, Agent sourceAgent, Vector3 position, Vector3 direction, bool allowDirectionalBonus = false, float staggerMulti = 1f, float precisionMulti = 1f)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected I4, but got Unknown
if (!((Agent)__instance.m_base.Owner).Alive || !((Object)(object)sourceAgent != (Object)null))
{
return;
}
bool flag = BackstabTest(dam, position, direction, __instance.m_base);
eLimbDamageType type = __instance.m_type;
switch ((int)type)
{
case 0:
if (flag && allowDirectionalBonus)
{
switch (Settings.MiniCrits)
{
case Hitsounds.Toggle.BaseSound:
CellSound.Post(TF2_Hitsounds.MiniCrit);
break;
case Hitsounds.Toggle.HitSound:
CellSound.Post(TF2_Hitsounds.HitsoundDB[Settings.HitType.ToString()]["HitSound"]);
break;
case Hitsounds.Toggle.Disabled:
break;
}
}
else if (Settings.Hits)
{
CellSound.Post(TF2_Hitsounds.HitsoundDB[Settings.HitType.ToString()]["HitSound"]);
}
break;
case 1:
switch (Settings.Crits)
{
case Hitsounds.Toggle.BaseSound:
CellSound.Post(TF2_Hitsounds.Critical);
break;
case Hitsounds.Toggle.HitSound:
CellSound.Post(TF2_Hitsounds.HitsoundDB[Settings.HitType.ToString()]["HitSound"]);
break;
case Hitsounds.Toggle.Disabled:
break;
}
break;
case 2:
break;
}
}
[HarmonyPatch(typeof(Dam_EnemyDamageLimb), "MeleeDamage")]
[HarmonyPostfix]
internal static void MeleeHits(Dam_EnemyDamageLimb __instance, ref float dam, Agent sourceAgent, Vector3 position, Vector3 direction, float backstabberMulti = 1f)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected I4, but got Unknown
if (!((Agent)__instance.m_base.Owner).Alive)
{
return;
}
bool allowDamgeBonusFromBehind = __instance.m_base.Owner.EnemyBalancingData.AllowDamgeBonusFromBehind;
if (!((Object)(object)sourceAgent != (Object)null))
{
return;
}
bool flag = BackstabTest(dam, position, direction, __instance.m_base);
eLimbDamageType type = __instance.m_type;
switch ((int)type)
{
case 0:
if (flag && allowDamgeBonusFromBehind)
{
switch (Settings.MiniCrits)
{
case Hitsounds.Toggle.BaseSound:
CellSound.Post(TF2_Hitsounds.MiniCrit);
break;
case Hitsounds.Toggle.HitSound:
CellSound.Post(TF2_Hitsounds.HitsoundDB[Settings.HitType.ToString()]["HitSound"]);
break;
case Hitsounds.Toggle.Disabled:
break;
}
}
else if (Settings.Hits)
{
CellSound.Post(TF2_Hitsounds.HitsoundDB[Settings.HitType.ToString()]["HitSound"]);
}
break;
case 1:
switch (Settings.Crits)
{
case Hitsounds.Toggle.BaseSound:
CellSound.Post(TF2_Hitsounds.Critical);
break;
case Hitsounds.Toggle.HitSound:
CellSound.Post(TF2_Hitsounds.HitsoundDB[Settings.HitType.ToString()]["HitSound"]);
break;
case Hitsounds.Toggle.Disabled:
break;
}
break;
case 2:
break;
}
}
[HarmonyPatch(typeof(Dam_EnemyDamageLimb), "ShowHitIndicator")]
[HarmonyPostfix]
internal static void Kills(Dam_EnemyDamageLimb __instance, bool willDie)
{
if (willDie && Settings.Kills)
{
CellSound.Post(TF2_Hitsounds.HitsoundDB[Settings.KillType.ToString()]["KillSound"]);
}
}
[HarmonyPatch(typeof(BulletWeapon), "OnWield")]
[HarmonyPostfix]
internal static void FuckShotguns(BulletWeapon __instance)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
int shotgunBulletCount = ((ItemEquippable)__instance).ArchetypeData.ShotgunBulletCount;
if (shotgunBulletCount > 0)
{
float num = 1f / (float)shotgunBulletCount * 100f;
CellSound.SetGlobalRTPCValue(TF2_Hitsounds.TF2_SFX, num);
}
else
{
CellSound.SetGlobalRTPCValue(TF2_Hitsounds.TF2_SFX, 100f);
}
}
[HarmonyPatch(typeof(MeleeWeaponFirstPerson), "OnWield")]
[HarmonyPostfix]
internal static void Melee()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
CellSound.SetGlobalRTPCValue(TF2_Hitsounds.TF2_SFX, 100f);
}
internal static bool BackstabTest(float Damage, Vector3 position, Vector3 direction, Dam_EnemyDamageBase Enemy, float BackShotMulti = 1f)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: 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_0099: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
float num = Damage;
bool flag = false;
float num2 = Mathf.Clamp01(Vector3.Dot(((Agent)Enemy.Owner).Forward, direction) + 0.25f) + 1f;
Damage *= num2;
flag = Damage > num;
if (BackShotMulti > 1f)
{
Vector3 val = ((Component)Enemy).transform.forward;
EnemyAgent owner = Enemy.Owner;
Object val2;
if ((Object)(object)owner == (Object)null)
{
val2 = null;
}
else
{
EnemyModelRefs modelRef = owner.ModelRef;
val2 = (Object)(object)(((Object)(object)modelRef != (Object)null) ? modelRef.m_chestBone : null);
}
if (val2 != (Object)null)
{
val = Enemy.Owner.ModelRef.m_chestBone.up * -1f;
}
if (Vector3.Dot(direction, val) > 0.55f)
{
Damage *= BackShotMulti;
flag = Damage > num;
}
}
return flag;
}
}
internal static class Logger
{
private static readonly ManualLogSource _Logger;
static Logger()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
_Logger = new ManualLogSource("Team Fortress 2");
Logger.Sources.Add((ILogSource)(object)_Logger);
}
private static string Format(object msg)
{
return msg.ToString();
}
public static void Info(BepInExInfoLogInterpolatedStringHandler handler)
{
_Logger.LogInfo(handler);
}
public static void Info(string str)
{
_Logger.LogMessage((object)str);
}
public static void Info(object data)
{
_Logger.LogMessage((object)Format(data));
}
public static void Debug(BepInExDebugLogInterpolatedStringHandler handler)
{
_Logger.LogDebug(handler);
}
public static void Debug(string str)
{
_Logger.LogDebug((object)str);
}
public static void Debug(object data)
{
_Logger.LogDebug((object)Format(data));
}
public static void Error(BepInExErrorLogInterpolatedStringHandler handler)
{
_Logger.LogError(handler);
}
public static void Error(string str)
{
_Logger.LogError((object)str);
}
public static void Error(object data)
{
_Logger.LogError((object)Format(data));
}
public static void Fatal(BepInExFatalLogInterpolatedStringHandler handler)
{
_Logger.LogFatal(handler);
}
public static void Fatal(string str)
{
_Logger.LogFatal((object)str);
}
public static void Fatal(object data)
{
_Logger.LogFatal((object)Format(data));
}
public static void Warn(BepInExWarningLogInterpolatedStringHandler handler)
{
_Logger.LogWarning(handler);
}
public static void Warn(string str)
{
_Logger.LogWarning((object)str);
}
public static void Warn(object data)
{
_Logger.LogWarning((object)Format(data));
}
[Conditional("DEBUG")]
public static void DebugOnly(object data)
{
}
}
}