using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModelReplacement;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("HL2")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HL2")]
[assembly: AssemblyTitle("HL2")]
[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 HL2.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
resourceMan = new ResourceManager("HL2.Properties.Resources", typeof(Resources).Assembly);
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal static byte[] hl2_player_models => (byte[])ResourceManager.GetObject("hl2_player_models", resourceCulture);
internal Resources()
{
}
}
}
namespace HL2PlayerModels
{
public static class Utils
{
public static PlayerControllerB? FindNearestPlayer(Vector3 vec, int radius)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
Collider[] array = Physics.OverlapSphere(vec, (float)radius);
for (int i = 0; i < array.Length; i++)
{
GameObject gameObject = ((Component)array[i]).gameObject;
if ((Object)(object)gameObject != (Object)null)
{
PlayerControllerB component = gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null)
{
return component;
}
}
}
return null;
}
public static Assets.RandomAudioClip? GetRandomClip_DeathReaction(BodyReplacementBase body)
{
GameObject replacementModel = body.replacementModel;
if ((Object)(object)replacementModel != (Object)null)
{
string name = ((Object)replacementModel).name;
if (name == null || name == "")
{
return null;
}
switch (name.ToLower())
{
case "alyx":
return Assets.Alyx_DeathReaction;
case "barney":
return Assets.Barney_DeathReaction;
case "breen":
return Assets.Breen_DeathReaction;
case "mossman":
return Assets.Mossman_DeathReaction;
case "eli":
return Assets.Eli_DeathReaction;
}
}
return null;
}
}
public class ChatteringBodyReplacement : BodyReplacementBase
{
private double m_nextchatter;
protected override GameObject LoadAssetsAndReturnModel()
{
throw new NotImplementedException();
}
protected override void LateUpdate()
{
((BodyReplacementBase)this).LateUpdate();
if (!((Object)(object)((BodyReplacementBase)this).controller != (Object)null))
{
return;
}
if (m_nextchatter <= 0.0)
{
int num = Random.Range(180, 360);
m_nextchatter = Time.time + (float)num;
}
if ((double)Time.time > m_nextchatter)
{
Assets.RandomAudioClip randomChatterClip = GetRandomChatterClip();
if (randomChatterClip != null)
{
AudioClip randomAudio = randomChatterClip.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
int num2 = Random.Range(180, 360);
m_nextchatter = Time.time + (float)num2;
}
}
}
protected virtual Assets.RandomAudioClip? GetRandomChatterClip()
{
return null;
}
}
public class MRALYX : ChatteringBodyReplacement
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.MainAssetBundle.LoadAsset<GameObject>("alyx");
}
protected override void OnDamageTaken(bool dead)
{
if (!dead)
{
AudioClip randomAudio = Assets.Alyx_OnHurt.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
}
((BodyReplacementBase)this).OnDamageTaken(dead);
}
protected override void OnDeath()
{
AudioClip randomAudio = Assets.Alyx_OnDeath.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
((BodyReplacementBase)this).OnDeath();
}
protected override Assets.RandomAudioClip? GetRandomChatterClip()
{
return Assets.Alyx_Chatter;
}
}
public class MRKLEINER : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.MainAssetBundle.LoadAsset<GameObject>("kleiner");
}
protected override void OnDamageTaken(bool dead)
{
((BodyReplacementBase)this).OnDamageTaken(dead);
}
protected override void OnDeath()
{
((BodyReplacementBase)this).OnDeath();
}
}
public class MRBARNEY : ChatteringBodyReplacement
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.MainAssetBundle.LoadAsset<GameObject>("barney");
}
protected override void OnDamageTaken(bool dead)
{
if (!dead)
{
AudioClip randomAudio = Assets.Barney_OnHurt.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
}
((BodyReplacementBase)this).OnDamageTaken(dead);
}
protected override void OnDeath()
{
AudioClip randomAudio = Assets.Barney_OnDeath.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
((BodyReplacementBase)this).OnDeath();
}
protected override Assets.RandomAudioClip? GetRandomChatterClip()
{
return Assets.Barney_Chatter;
}
}
public class MRBREEN : ChatteringBodyReplacement
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.MainAssetBundle.LoadAsset<GameObject>("breen");
}
protected override void OnDeath()
{
AudioClip randomAudio = Assets.Breen_OnDeath.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
((BodyReplacementBase)this).OnDeath();
}
protected override Assets.RandomAudioClip? GetRandomChatterClip()
{
return Assets.Breen_Chatter;
}
}
public class MRELI : ChatteringBodyReplacement
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.MainAssetBundle.LoadAsset<GameObject>("eli");
}
protected override void OnDeath()
{
AudioClip randomAudio = Assets.Eli_OnDeath.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
((BodyReplacementBase)this).OnDeath();
}
protected override Assets.RandomAudioClip? GetRandomChatterClip()
{
return Assets.Eli_Chatter;
}
}
public class MRMOSSMAN : ChatteringBodyReplacement
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.MainAssetBundle.LoadAsset<GameObject>("mossman");
}
protected override void OnDeath()
{
AudioClip randomAudio = Assets.Mossman_OnDeath.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
((BodyReplacementBase)this).OnDeath();
}
protected override Assets.RandomAudioClip? GetRandomChatterClip()
{
return Assets.Mossman_Chatter;
}
}
[BepInPlugin("com.Atomicskullz.HL2PlayerModels", "Half Life 2 Player Models", "0.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public static ConfigFile? config;
public static Plugin? Instance;
public static ConfigEntry<bool>? enableModelForAllSuits { get; private set; }
public static ConfigEntry<bool>? enableModelAsDefault { get; private set; }
public static ConfigEntry<string>? suitNamesToEnableModel { get; private set; }
private static void InitConfig()
{
}
private void Awake()
{
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
config = ((BaseUnityPlugin)this).Config;
Instance = this;
InitConfig();
Assets.PopulateAssets();
ModelReplacementAPI.RegisterSuitModelReplacement("Alyx", typeof(MRALYX));
ModelReplacementAPI.RegisterSuitModelReplacement("Kleiner", typeof(MRKLEINER));
ModelReplacementAPI.RegisterSuitModelReplacement("Barney", typeof(MRBARNEY));
ModelReplacementAPI.RegisterSuitModelReplacement("Breen", typeof(MRBREEN));
ModelReplacementAPI.RegisterSuitModelReplacement("Mossman", typeof(MRMOSSMAN));
ModelReplacementAPI.RegisterSuitModelReplacement("Eli", typeof(MRELI));
new Harmony("com.Atomicskullz.HL2PlayerModels").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.Atomicskullz.HL2PlayerModels is loaded!");
}
public void LogMessage(object message)
{
((BaseUnityPlugin)this).Logger.LogMessage(message);
}
}
public static class Assets
{
public class RandomAudioClip
{
private List<AudioClip> audioClipList = new List<AudioClip>();
public AudioClip GetRandomAudio(int seed)
{
int num = new Random().Next(audioClipList.Count);
Console.WriteLine($"Get audio N {audioClipList.Count} > {num}");
return audioClipList[num];
}
public void AddAudio(string name)
{
AudioClip audioClipFromName = GetAudioClipFromName(name);
if ((Object)(object)audioClipFromName != (Object)null)
{
audioClipList.Add(audioClipFromName);
}
else
{
Console.WriteLine("clip " + name + " null");
}
}
}
public static string mainAssetBundleName = "hl2_player_models";
public static AssetBundle? MainAssetBundle = null;
public static RandomAudioClip Alyx_DeathReaction = new RandomAudioClip();
public static RandomAudioClip Alyx_OnDeath = new RandomAudioClip();
public static RandomAudioClip Alyx_OnHurt = new RandomAudioClip();
public static RandomAudioClip Alyx_Chatter = new RandomAudioClip();
public static RandomAudioClip Barney_DeathReaction = new RandomAudioClip();
public static RandomAudioClip Barney_OnDeath = new RandomAudioClip();
public static RandomAudioClip Barney_OnHurt = new RandomAudioClip();
public static RandomAudioClip Barney_Chatter = new RandomAudioClip();
public static RandomAudioClip Breen_DeathReaction = new RandomAudioClip();
public static RandomAudioClip Breen_OnDeath = new RandomAudioClip();
public static RandomAudioClip Breen_Chatter = new RandomAudioClip();
public static RandomAudioClip Eli_DeathReaction = new RandomAudioClip();
public static RandomAudioClip Eli_OnDeath = new RandomAudioClip();
public static RandomAudioClip Eli_Chatter = new RandomAudioClip();
public static RandomAudioClip Mossman_DeathReaction = new RandomAudioClip();
public static RandomAudioClip Mossman_OnDeath = new RandomAudioClip();
public static RandomAudioClip Mossman_Chatter = new RandomAudioClip();
private static string GetAssemblyName()
{
return Assembly.GetExecutingAssembly().GetName().Name.Replace(" ", "_");
}
public static void PopulateAssets()
{
if ((Object)(object)MainAssetBundle == (Object)null)
{
Console.WriteLine(GetAssemblyName() + "." + mainAssetBundleName);
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + mainAssetBundleName);
MainAssetBundle = AssetBundle.LoadFromStream(stream);
}
Alyx_OnDeath.AddAudio("alyx_no01");
Alyx_OnDeath.AddAudio("alyx_no02");
Alyx_OnDeath.AddAudio("alyx_no03");
Alyx_OnHurt.AddAudio("alyx_hurt04");
Alyx_OnHurt.AddAudio("alyx_hurt05");
Alyx_OnHurt.AddAudio("alyx_hurt06");
Alyx_OnHurt.AddAudio("alyx_hurt08");
Alyx_DeathReaction.AddAudio("alyx_ohgod01");
Alyx_DeathReaction.AddAudio("alyx_brutal02");
Alyx_DeathReaction.AddAudio("alyx_ohno_startle01");
Alyx_DeathReaction.AddAudio("alyx_ohno_startle03");
Alyx_DeathReaction.AddAudio("alyx_dadgordonno_c");
Alyx_Chatter.AddAudio("al_buyyoudrink03");
Alyx_Chatter.AddAudio("al_comebackdad");
Alyx_Chatter.AddAudio("al_dad");
Alyx_Chatter.AddAudio("al_dadallright");
Alyx_Chatter.AddAudio("al_daddownhere01");
Alyx_Chatter.AddAudio("al_dadgordonno");
Alyx_Chatter.AddAudio("al_dadgordonno_b");
Alyx_Chatter.AddAudio("al_dadplease");
Alyx_Chatter.AddAudio("al_dad_ques01");
Alyx_Chatter.AddAudio("al_dad_scared01");
Alyx_Chatter.AddAudio("al_dad_scared02");
Alyx_Chatter.AddAudio("al_getyourball");
Alyx_Chatter.AddAudio("al_gooddoggie");
Alyx_Chatter.AddAudio("al_grabthrow");
Alyx_Chatter.AddAudio("al_gravdrop");
Alyx_Chatter.AddAudio("al_hmm");
Alyx_Chatter.AddAudio("al_ravenholm01");
Alyx_Chatter.AddAudio("al_readyforus");
Alyx_Chatter.AddAudio("al_theplug");
Alyx_Chatter.AddAudio("al_whatcat01");
Alyx_Chatter.AddAudio("al_whatsgoingon");
Alyx_Chatter.AddAudio("al_youcoming");
Alyx_Chatter.AddAudio("al_yououtdad");
Barney_OnDeath.AddAudio("ba_damnit");
Barney_OnDeath.AddAudio("ba_littlehelphere");
Barney_OnHurt.AddAudio("ba_pain01");
Barney_OnHurt.AddAudio("ba_pain02");
Barney_OnHurt.AddAudio("ba_pain03");
Barney_OnHurt.AddAudio("ba_pain04");
Barney_OnHurt.AddAudio("ba_pain05");
Barney_DeathReaction.AddAudio("ba_guh");
Barney_DeathReaction.AddAudio("ba_whoops");
Barney_DeathReaction.AddAudio("ba_cantlook");
Barney_Chatter.AddAudio("ba_dogwantsyou");
Barney_Chatter.AddAudio("ba_goodnews_d");
Barney_Chatter.AddAudio("ba_hearcat");
Barney_Chatter.AddAudio("ba_juicedup");
Barney_Chatter.AddAudio("ba_lookingforalyx");
Barney_Chatter.AddAudio("ba_myshift01");
Barney_Chatter.AddAudio("ba_ownsroof");
Barney_Chatter.AddAudio("ba_pissinmeoff");
Barney_Chatter.AddAudio("ba_rollgrenade");
Barney_Chatter.AddAudio("ba_sarcastic03");
Barney_Chatter.AddAudio("ba_tellbreen");
Barney_Chatter.AddAudio("ba_uhohdropships");
Barney_Chatter.AddAudio("ba_vista01");
Barney_Chatter.AddAudio("ba_yougotgravgun");
Breen_OnDeath.AddAudio("br_no");
Breen_OnDeath.AddAudio("br_ohshit");
Breen_OnDeath.AddAudio("br_youneedme");
Breen_OnDeath.AddAudio("br_youfool");
Breen_OnDeath.AddAudio("br_failing11");
Breen_DeathReaction.AddAudio("br_laugh01");
Breen_DeathReaction.AddAudio("br_guards");
Breen_DeathReaction.AddAudio("br_mock13");
Breen_Chatter.AddAudio("br_foundation");
Breen_Chatter.AddAudio("br_hostbody");
Breen_Chatter.AddAudio("br_instinct01");
Breen_Chatter.AddAudio("br_instinct02");
Breen_Chatter.AddAudio("br_instinct03");
Breen_Chatter.AddAudio("br_instinct13");
Breen_Chatter.AddAudio("br_stubborn");
Breen_Chatter.AddAudio("br_synapse02");
Eli_OnDeath.AddAudio("eli_iknow");
Eli_OnDeath.AddAudio("eli_alyxhoney");
Eli_OnDeath.AddAudio("eli_wherewillyougo01");
Eli_OnDeath.AddAudio("eli_handle_b");
Eli_DeathReaction.AddAudio("eli_lookgordon");
Eli_DeathReaction.AddAudio("eli_whatsgoingon");
Eli_Chatter.AddAudio("eli_finesci");
Eli_Chatter.AddAudio("eli_lookaround");
Eli_Chatter.AddAudio("eli_mit");
Eli_Chatter.AddAudio("eli_photo01");
Eli_Chatter.AddAudio("eli_photo02");
Eli_Chatter.AddAudio("eli_safety");
Eli_Chatter.AddAudio("eli_thisisportal");
Eli_Chatter.AddAudio("eli_vilebiz01");
Eli_Chatter.AddAudio("eli_welcometolab");
Mossman_OnDeath.AddAudio("mo_dont");
Mossman_DeathReaction.AddAudio("mo_drplease");
Mossman_DeathReaction.AddAudio("mo_illtakehim");
Mossman_DeathReaction.AddAudio("mo_onlyway");
Mossman_DeathReaction.AddAudio("mo_outoftime");
Mossman_DeathReaction.AddAudio("mo_sorrygordon");
Mossman_DeathReaction.AddAudio("mo_outoftime");
Mossman_DeathReaction.AddAudio("mo_worried");
Mossman_Chatter.AddAudio("mo_bargain");
Mossman_Chatter.AddAudio("mo_dontworry");
Mossman_Chatter.AddAudio("mo_fromplatform");
Mossman_Chatter.AddAudio("mo_hadtoprove02");
Mossman_Chatter.AddAudio("mo_howdyougetin");
Mossman_Chatter.AddAudio("mo_inacell");
Mossman_Chatter.AddAudio("mo_notimealyx");
Mossman_Chatter.AddAudio("mo_nouse");
Mossman_Chatter.AddAudio("mo_promised");
Mossman_Chatter.AddAudio("mo_protectfather01");
Mossman_Chatter.AddAudio("mo_pulsefoaming");
Mossman_Chatter.AddAudio("mo_talkingabout");
}
public static AudioClip? GetAudioClipFromName(string name)
{
Object obj = MainAssetBundle.LoadAsset(name);
return (AudioClip?)(object)((obj is AudioClip) ? obj : null);
}
}
public static class Patches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(DeadBodyInfo), "DetectIfSeenByLocalPlayer")]
private static void OnDetect()
{
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
if (!((Object)(object)localPlayerController != (Object)null))
{
return;
}
BodyReplacementBase component = ((Component)localPlayerController).GetComponent<BodyReplacementBase>();
if ((Object)(object)component != (Object)null)
{
Assets.RandomAudioClip randomClip_DeathReaction = Utils.GetRandomClip_DeathReaction(component);
if (randomClip_DeathReaction != null)
{
localPlayerController.movementAudio.PlayOneShot(randomClip_DeathReaction.GetRandomAudio(StartOfRound.Instance.randomMapSeed), 0.8f);
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}