using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PEAKLib.Core;
using PEAKLib.Items.UnityEditor;
using Peak.Afflictions;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("TRG")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TRG")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("13e7d2de-738f-41d2-a86c-6f105e8637a2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[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 TRG_Gun
{
public class Action_Ammo : ItemAction
{
public bool consumeOnFullyUsed;
[PunRPC]
public void ReduceUsesRPC()
{
OptionableIntItemData data = ((ItemActionBase)this).item.GetData<OptionableIntItemData>((DataEntryKey)2);
if (data.HasData && data.Value > 0)
{
data.Value--;
if (((ItemActionBase)this).item.totalUses > 0)
{
((ItemActionBase)this).item.SetUseRemainingPercentage((float)data.Value / (float)((ItemActionBase)this).item.totalUses);
}
if (data.Value == 0 && consumeOnFullyUsed && Object.op_Implicit((Object)(object)((ItemActionBase)this).character) && ((ItemActionBase)this).character.IsLocal && (Object)(object)((ItemActionBase)this).character.data.currentItem == (Object)(object)((ItemActionBase)this).item)
{
((MonoBehaviour)((ItemActionBase)this).item).StartCoroutine(((ItemActionBase)this).item.ConsumeDelayed(false));
}
}
}
}
public class Action_Gun : ItemAction
{
public GameObject shotSFXPrefab;
private static AudioSource cachedReferenceSfx;
public float maxDistance;
public float dartCollisionSize;
[SerializeReference]
public Affliction[] afflictionsOnHit;
public Transform spawnTransform;
public GameObject dartVFX;
public float fireRate = 0.15f;
public Action OnShoot;
private RaycastHit lineHit;
private RaycastHit[] sphereHits;
private RaycastHit[] itemSphereHits;
private float lastShootTime;
private Item lastHitItem;
private Vector3 originalDefaultPos;
private static ManualLogSource Log => Plugin.Log;
public override void RunAction()
{
if (!(Time.time <= lastShootTime + fireRate))
{
lastShootTime = Time.time;
FireGun();
}
}
private AudioSource FindReferenceSfx()
{
if ((Object)(object)cachedReferenceSfx != (Object)null)
{
return cachedReferenceSfx;
}
AudioSource[] array = Object.FindObjectsOfType<AudioSource>(true);
AudioSource[] array2 = array;
foreach (AudioSource val in array2)
{
if (!((Object)(object)val == (Object)null) && !((Object)(object)val.outputAudioMixerGroup == (Object)null))
{
string name = ((Object)val.outputAudioMixerGroup).name;
if (name == "SFX" || name == "Effects")
{
cachedReferenceSfx = val;
Log.LogInfo((object)("[TRG] Reference SFX source found: " + ((Object)val).name + " / group=" + name));
return cachedReferenceSfx;
}
}
}
AudioSource[] array3 = array;
foreach (AudioSource val2 in array3)
{
if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.outputAudioMixerGroup == (Object)null))
{
cachedReferenceSfx = val2;
Log.LogInfo((object)("[TRG] Fallback reference SFX source: " + ((Object)val2).name + " / group=" + ((Object)val2.outputAudioMixerGroup).name));
return cachedReferenceSfx;
}
}
Log.LogWarning((object)"[TRG] No reference AudioSource with mixer group found");
return null;
}
private void PlayTrgSfx()
{
//IL_005b: 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)
if ((Object)(object)shotSFXPrefab == (Object)null)
{
Log.LogWarning((object)"[TRG] shotSFXPrefab is null");
return;
}
if ((Object)(object)spawnTransform == (Object)null)
{
Log.LogWarning((object)"[TRG] spawnTransform is null");
return;
}
GameObject val = Object.Instantiate<GameObject>(shotSFXPrefab, spawnTransform.position, Quaternion.identity);
AudioSource component = val.GetComponent<AudioSource>();
if ((Object)(object)component == (Object)null)
{
Log.LogWarning((object)"[TRG] SFX_TRG has no AudioSource");
Object.Destroy((Object)(object)val, 2f);
return;
}
if ((Object)(object)component.clip == (Object)null)
{
Log.LogWarning((object)"[TRG] SFX_TRG AudioSource.clip is null");
Object.Destroy((Object)(object)val, 2f);
return;
}
AudioSource val2 = FindReferenceSfx();
if ((Object)(object)val2 != (Object)null)
{
component.outputAudioMixerGroup = val2.outputAudioMixerGroup;
Log.LogInfo((object)("[TRG] Copied mixer group: " + ((Object)val2.outputAudioMixerGroup).name));
}
else
{
Log.LogWarning((object)"[TRG] Could not copy mixer group");
}
component.playOnAwake = false;
component.mute = false;
component.volume = 1f;
component.pitch = 1f;
component.spatialBlend = 1f;
component.rolloffMode = (AudioRolloffMode)0;
component.minDistance = 2f;
component.maxDistance = 80f;
component.dopplerLevel = 0f;
component.priority = 128;
component.Play();
Object.Destroy((Object)(object)val, Mathf.Max(component.clip.length + 0.5f, 2f));
}
protected override void Start()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
((ItemActionBase)this).Start();
if ((Object)(object)((ItemActionBase)this).item != (Object)null)
{
originalDefaultPos = ((ItemActionBase)this).item.defaultPos;
}
}
private void OnDrawGizmosSelected()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)spawnTransform == (Object)null))
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(spawnTransform.position, dartCollisionSize);
}
}
private void FireGun()
{
//IL_00b3: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: 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_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: 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_0241: 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_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: 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_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)((ItemActionBase)this).item == (Object)null)
{
Log.LogWarning((object)"[TRG] FireGun aborted: item == null");
return;
}
if ((Object)(object)((MonoBehaviourPun)((ItemActionBase)this).item).photonView == (Object)null)
{
Log.LogWarning((object)"[TRG] FireGun aborted: item.photonView == null");
return;
}
if ((Object)(object)spawnTransform == (Object)null)
{
Log.LogWarning((object)"[TRG] FireGun aborted: spawnTransform == null");
return;
}
((MonoBehaviourPun)((ItemActionBase)this).item).photonView.RPC("ReduceUsesRPC", (RpcTarget)0, Array.Empty<object>());
OnShoot?.Invoke();
PlayTrgSfx();
Physics.Raycast(spawnTransform.position, ((Component)MainCamera.instance).transform.forward, ref lineHit, maxDistance, LayerMask.op_Implicit(HelperFunctions.terrainMapMask), (QueryTriggerInteraction)1);
if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref lineHit)).collider))
{
((RaycastHit)(ref lineHit)).distance = maxDistance;
((RaycastHit)(ref lineHit)).point = spawnTransform.position + ((Component)MainCamera.instance).transform.forward * maxDistance;
}
sphereHits = Physics.SphereCastAll(spawnTransform.position, dartCollisionSize, ((Component)MainCamera.instance).transform.forward, ((RaycastHit)(ref lineHit)).distance, LayerMask.GetMask(new string[1] { "Character" }), (QueryTriggerInteraction)1);
RaycastHit[] array = sphereHits;
for (int i = 0; i < array.Length; i++)
{
RaycastHit val = array[i];
if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null))
{
Character componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Character>();
if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent != (Object)(object)((ItemActionBase)this).character)
{
GunImpact(componentInParent, spawnTransform.position, ((RaycastHit)(ref val)).point);
return;
}
}
}
GunImpact(null, spawnTransform.position, ((RaycastHit)(ref lineHit)).point);
itemSphereHits = Physics.SphereCastAll(spawnTransform.position, dartCollisionSize, ((Component)MainCamera.instance).transform.forward, ((RaycastHit)(ref lineHit)).distance, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1);
RaycastHit[] array2 = itemSphereHits;
for (int j = 0; j < array2.Length; j++)
{
RaycastHit val2 = array2[j];
if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null))
{
Item componentInParent2 = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Item>();
if ((Object)(object)componentInParent2 != (Object)null && (Object)(object)componentInParent2 != (Object)(object)((Component)this).GetComponentInParent<Item>())
{
GunItemImpact(componentInParent2, spawnTransform.position, ((RaycastHit)(ref val2)).point);
break;
}
}
}
}
private void GunImpact(Character hitCharacter, Vector3 origin, Vector3 endpoint)
{
//IL_0022: 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)
//IL_005c: 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_0067: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)hitCharacter != (Object)null && hitCharacter.isZombie)
{
Vector3 forward = ((Component)MainCamera.instance).transform.forward;
((MonoBehaviourPun)hitCharacter).photonView.RPC("RPC_ShootSelfT", (RpcTarget)0, new object[3]
{
0.25f,
((MonoBehaviourPun)hitCharacter).photonView.ViewID,
-(forward * 2f)
});
}
else if ((Object)(object)hitCharacter != (Object)null)
{
((MonoBehaviourPun)this).photonView.RPC("RPC_GunImpact", (RpcTarget)0, new object[4]
{
((MonoBehaviourPun)hitCharacter).photonView.Owner,
origin,
endpoint,
((Component)MainCamera.instance).transform.forward
});
}
else
{
((MonoBehaviourPun)this).photonView.RPC("RPC_GunImpact", (RpcTarget)0, new object[4]
{
null,
origin,
endpoint,
((Component)MainCamera.instance).transform.forward
});
}
}
private void GunItemImpact(Item hitItem, Vector3 origin, Vector3 endpoint)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: 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)
lastHitItem = hitItem;
((MonoBehaviourPun)this).photonView.RPC("RPC_GunItemImpact", (RpcTarget)0, new object[3]
{
origin,
endpoint,
((Component)MainCamera.instance).transform.forward
});
}
[PunRPC]
private void RPC_GunImpact(Player hitPlayer, Vector3 origin, Vector3 endpoint, Vector3 direction)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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)
if (hitPlayer != null && PhotonNetwork.LocalPlayer != null && hitPlayer.ActorNumber == PhotonNetwork.LocalPlayer.ActorNumber)
{
((Component)Character.localCharacter).GetComponent<GunCharacterLaunch>().ShootSelfT(0.25f, Character.localCharacter, -(direction * 2f));
if (afflictionsOnHit != null)
{
Affliction[] array = afflictionsOnHit;
foreach (Affliction val in array)
{
Character.localCharacter.refs.afflictions.AddAffliction(val, false);
}
}
}
if ((Object)(object)GamefeelHandler.instance != (Object)null)
{
GamefeelHandler.instance.AddPerlinShakeProximity(endpoint, 5f, 0.2f, 15f, 10f);
}
}
[PunRPC]
private void RPC_GunItemImpact(Vector3 origin, Vector3 endpoint, Vector3 direction)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)lastHitItem != (Object)null)
{
((MonoBehaviourPun)lastHitItem).photonView.RPC("RPC_ShootSelfT", (RpcTarget)0, new object[2] { 0.1f, direction });
}
if ((Object)(object)GamefeelHandler.instance != (Object)null)
{
GamefeelHandler.instance.AddPerlinShakeProximity(endpoint, 5f, 0.2f, 15f, 10f);
}
}
}
public class TRGVFX : ItemVFX
{
public ParticleSystem trgParticles;
private ParticleSystem[] allParticles;
protected override void Start()
{
((ItemVFX)this).Start();
CacheParticles();
StopAllParticlesImmediate();
Subscribe();
}
private void OnEnable()
{
CacheParticles();
Subscribe();
}
private void OnDisable()
{
Unsubscribe();
}
private void CacheParticles()
{
if (allParticles == null || allParticles.Length == 0)
{
if ((Object)(object)trgParticles == (Object)null)
{
trgParticles = ((Component)this).GetComponentInChildren<ParticleSystem>(true);
}
allParticles = ((Component)this).GetComponentsInChildren<ParticleSystem>(true);
}
}
private void StopAllParticlesImmediate()
{
if (allParticles == null)
{
return;
}
ParticleSystem[] array = allParticles;
foreach (ParticleSystem val in array)
{
if (!((Object)(object)val == (Object)null))
{
val.Stop(true, (ParticleSystemStopBehavior)0);
}
}
}
private void Subscribe()
{
Action_Gun action_Gun = (((Object)(object)base.item != (Object)null) ? ((Component)base.item).GetComponent<Action_Gun>() : null);
if ((Object)(object)action_Gun != (Object)null)
{
action_Gun.OnShoot = (Action)Delegate.Remove(action_Gun.OnShoot, new Action(RunAction));
action_Gun.OnShoot = (Action)Delegate.Combine(action_Gun.OnShoot, new Action(RunAction));
}
}
private void Unsubscribe()
{
Action_Gun action_Gun = (((Object)(object)base.item != (Object)null) ? ((Component)base.item).GetComponent<Action_Gun>() : null);
if ((Object)(object)action_Gun != (Object)null)
{
action_Gun.OnShoot = (Action)Delegate.Remove(action_Gun.OnShoot, new Action(RunAction));
}
}
public void RunAction()
{
CacheParticles();
if (allParticles == null || allParticles.Length == 0)
{
return;
}
ParticleSystem[] array = allParticles;
foreach (ParticleSystem val in array)
{
if (!((Object)(object)val == (Object)null))
{
((Component)val).gameObject.SetActive(true);
val.Stop(true, (ParticleSystemStopBehavior)0);
val.Play(true);
}
}
}
}
public static class CharacterExtensions
{
public static void AddForce(this Character input, Vector3 move, float minRandomMultiplier, float maxRandomMultiplier, ForceMode forceMode = 5)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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_003d: Unknown result type (might be due to invalid IL or missing references)
foreach (Bodypart part in input.refs.ragdoll.partList)
{
Vector3 val = move;
if (minRandomMultiplier != maxRandomMultiplier)
{
val *= Random.Range(minRandomMultiplier, maxRandomMultiplier);
}
part.AddForce(val, forceMode);
}
}
}
public class GunCharacterLaunch : MonoBehaviour
{
public float shotTime;
private Character characterGettingShot;
private Vector3 shotDirection;
private void Start()
{
characterGettingShot = Character.localCharacter;
}
private void Update()
{
if (shotTime > 0f)
{
shotTime -= Time.deltaTime;
UpdateShotPhysicsT();
}
}
public void ShootSelfT(float howLongToFly, Character whoIsGettingShot, Vector3 whichDirectionShooting)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
shotTime = howLongToFly;
characterGettingShot = whoIsGettingShot;
shotDirection = whichDirectionShooting;
}
[PunRPC]
public void RPC_ShootSelfT(float howLongToFly, int characterViewID, Vector3 whichDirectionShooting)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
PhotonView val = PhotonView.Find(characterViewID);
if ((Object)(object)val != (Object)null)
{
Character component = ((Component)val).GetComponent<Character>();
characterGettingShot = (((Object)(object)component != (Object)null) ? component : Character.localCharacter);
}
else
{
characterGettingShot = Character.localCharacter;
}
shotTime = howLongToFly;
shotDirection = whichDirectionShooting;
}
public void UpdateShotPhysicsT()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)characterGettingShot == (Object)null))
{
Vector3 move = shotDirection * 25f * -1f;
characterGettingShot.AddForce(move, 1f, 1f, (ForceMode)5);
}
}
}
public class GunItemLaunch : MonoBehaviour
{
public float shotTime;
private Item itemGettingShot;
private Vector3 shotDirection;
private void Update()
{
if (shotTime > 0f)
{
shotTime -= Time.deltaTime;
PhotonView component = ((Component)this).GetComponent<PhotonView>();
if ((Object)(object)component != (Object)null)
{
component.RPC("UpdateShotPhysicsT", (RpcTarget)0, Array.Empty<object>());
}
}
}
public void ShootSelfT(float howLongToFly, Item whoIsGettingShot, Vector3 whichDirectionShooting)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
shotTime = howLongToFly;
itemGettingShot = whoIsGettingShot;
shotDirection = whichDirectionShooting;
}
[PunRPC]
public void RPC_ShootSelfT(float howLongToFly, Vector3 whichDirectionShooting)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
itemGettingShot = ((Component)this).GetComponent<Item>();
shotTime = howLongToFly;
shotDirection = whichDirectionShooting;
}
[PunRPC]
public void UpdateShotPhysicsT()
{
//IL_002c: 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)
if (!((Object)(object)itemGettingShot == (Object)null))
{
Rigidbody component = ((Component)itemGettingShot).GetComponent<Rigidbody>();
if ((Object)(object)component != (Object)null)
{
component.AddForce(shotDirection * 10f, (ForceMode)1);
}
}
}
}
[HarmonyPatch(typeof(Character), "Awake")]
internal static class GunPatch_Character
{
[HarmonyPostfix]
private static void AddGunCharacterLaunch(Character __instance)
{
if ((Object)(object)((Component)__instance).GetComponent<GunCharacterLaunch>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<GunCharacterLaunch>();
}
}
}
[HarmonyPatch(typeof(Item), "Awake")]
internal static class GunPatch_Item
{
[HarmonyPostfix]
private static void AddGunItemLaunch(Item __instance)
{
if ((Object)(object)((Component)__instance).GetComponent<GunItemLaunch>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<GunItemLaunch>();
}
}
}
[BepInDependency("com.github.PEAKModding.PEAKLib.Items", "1.0.0")]
[BepInDependency("com.github.PEAKModding.PEAKLib.Core", "1.0.0")]
[BepInPlugin("com.sol.trg_gun", "TRG Gun", "1.3.0")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <PatchAfterLoadFinished>d__10 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Plugin <>4__this;
private float <timeout>5__1;
private GameObject <bingBong>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PatchAfterLoadFinished>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<bingBong>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<timeout>5__1 = Time.time + 20f;
break;
case 1:
<>1__state = -1;
<bingBong>5__2 = null;
break;
}
if (Time.time < <timeout>5__1)
{
<bingBong>5__2 = GameObject.Find("BingBong_Spawner");
if ((Object)(object)TRG != (Object)null && (Object)(object)<bingBong>5__2 != (Object)null)
{
CreateItemSpawners();
return false;
}
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
}
Log.LogWarning((object)"[TRG] PatchAfterLoadFinished timeout.");
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public const string Id = "com.sol.trg_gun";
public const string Name = "TRG Gun";
public const string Version = "1.3.0";
internal static ManualLogSource Log;
private Harmony _harmony;
private Coroutine _levelLoadCompleteCoroutine;
private static GameObject TRG;
private void Awake()
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"[TRG] Patching sceneLoaded...");
SceneManager.sceneLoaded += OnSceneLoaded;
LocalizationFix();
BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "trg.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle)
{
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Expected O, but got Unknown
try
{
UnityItemContent val = peakBundle.LoadAsset<UnityItemContent>("IC_TRG");
GameObject val2 = peakBundle.LoadAsset<GameObject>("VFX_TRG");
GameObject val3 = peakBundle.LoadAsset<GameObject>("SFX_TRG");
Log.LogInfo((object)("[TRG] IC_TRG found = " + ((Object)(object)val != (Object)null)));
Log.LogInfo((object)("[TRG] SFX_TRG prefab found = " + ((Object)(object)val3 != (Object)null)));
Log.LogInfo((object)("[TRG] VFX_TRG found = " + ((Object)(object)val2 != (Object)null)));
if ((Object)(object)val == (Object)null)
{
Log.LogError((object)"[TRG] IC_TRG not found.");
}
else
{
TRG = val.ItemPrefab;
if ((Object)(object)TRG == (Object)null)
{
Log.LogError((object)"[TRG] ItemPrefab is null.");
}
else
{
Log.LogInfo((object)("[TRG] Prefab name = " + ((Object)TRG).name));
if ((Object)(object)TRG.GetComponent<Action_Ammo>() == (Object)null)
{
TRG.AddComponent<Action_Ammo>();
}
Action_Gun action_Gun = TRG.GetComponent<Action_Gun>();
if ((Object)(object)action_Gun == (Object)null)
{
action_Gun = TRG.AddComponent<Action_Gun>();
}
action_Gun.maxDistance = 500f;
action_Gun.dartCollisionSize = 0.3f;
action_Gun.fireRate = 0.8f;
((ItemAction)action_Gun).OnHeld = true;
action_Gun.spawnTransform = TRG.transform.Find("SpawnPos");
action_Gun.shotSFXPrefab = val3;
action_Gun.dartVFX = null;
action_Gun.afflictionsOnHit = (Affliction[])(object)new Affliction[1] { (Affliction)new Affliction_AdjustStatus((STATUSTYPE)0, 0.1f, 1f) };
if ((Object)(object)action_Gun.spawnTransform == (Object)null)
{
Log.LogWarning((object)"[TRG] SpawnPos not found.");
}
else
{
Log.LogInfo((object)"[TRG] SpawnPos linked.");
}
action_Gun.dartVFX = null;
Transform val4 = TRG.transform.Find("VFX_Gunshot(TRG)");
if ((Object)(object)val4 != (Object)null)
{
((Component)val4).gameObject.SetActive(true);
TRGVFX tRGVFX = TRG.GetComponent<TRGVFX>();
if ((Object)(object)tRGVFX == (Object)null)
{
tRGVFX = TRG.AddComponent<TRGVFX>();
}
ParticleSystem componentInChildren = ((Component)val4).GetComponentInChildren<ParticleSystem>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
tRGVFX.trgParticles = componentInChildren;
Log.LogInfo((object)("[TRG] MuzzleFlash ParticleSystem linked: " + ((Object)componentInChildren).name));
}
else
{
Log.LogWarning((object)"[TRG] No ParticleSystem found under VFX_Gunshot(TRG).");
}
}
else
{
Log.LogWarning((object)"[TRG] VFX_Gunshot(TRG) child not found.");
}
peakBundle.Mod.RegisterContent();
Log.LogInfo((object)"[TRG] RegisterContent complete.");
}
}
}
catch (Exception ex)
{
Log.LogError((object)("[TRG] bundle setup exception: " + ex));
}
});
_harmony = new Harmony("com.sol.trg_gun");
_harmony.PatchAll();
Log.LogInfo((object)"[TRG] Plugin TRG_Gun is loaded!");
}
private void OnDestroy()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
Log.LogInfo((object)("[TRG] Loaded scene: " + ((Scene)(ref scene)).path));
if (((Scene)(ref scene)).path.StartsWith("Assets/8_SCENES/Generated/"))
{
Log.LogInfo((object)"[TRG] started loading level scenes...");
if (_levelLoadCompleteCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(_levelLoadCompleteCoroutine);
_levelLoadCompleteCoroutine = null;
}
_levelLoadCompleteCoroutine = ((MonoBehaviour)this).StartCoroutine(PatchAfterLoadFinished());
}
}
[IteratorStateMachine(typeof(<PatchAfterLoadFinished>d__10))]
private IEnumerator PatchAfterLoadFinished()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PatchAfterLoadFinished>d__10(0)
{
<>4__this = this
};
}
private static void CreateItemSpawners()
{
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("BingBong_Spawner");
if ((Object)(object)val == (Object)null)
{
Log.LogWarning((object)"[TRG] BingBong_Spawner not found.");
return;
}
if ((Object)(object)TRG == (Object)null)
{
Log.LogError((object)"[TRG] TRG prefab is null.");
return;
}
if ((Object)(object)GameObject.Find("TRG_Spawner") != (Object)null)
{
Log.LogInfo((object)"[TRG] TRG_Spawner already exists.");
return;
}
GameObject val2 = Object.Instantiate<GameObject>(val, val.transform.parent);
val2.SetActive(false);
((Object)val2).name = "TRG_Spawner";
val2.transform.localPosition = new Vector3(-10.862f, 0.7437f, -4.13f);
Log.LogInfo((object)("[TRG] Spawning " + ((Object)val2).name));
try
{
SingleItemSpawner component = val2.GetComponent<SingleItemSpawner>();
if ((Object)(object)component == (Object)null)
{
Log.LogError((object)"[TRG] SingleItemSpawner missing on cloned BingBong.");
Object.Destroy((Object)(object)val2);
return;
}
component.prefab = TRG;
Log.LogInfo((object)("[TRG] Setting " + ((Object)val2).name + "'s prefab to " + ((Object)component.prefab).name));
val2.SetActive(true);
component.TrySpawnItems();
Log.LogInfo((object)"[TRG] TrySpawnItems success.");
}
catch (Exception ex)
{
Log.LogError((object)("[TRG] Failed to spawn TRG_Spawner: " + ex));
}
}
private static void LocalizationFix()
{
LocalizedText.mainTable["NAME_TRG"] = new List<string>(15)
{
"TRG", "TRG", "TRG", "TRG", "TRG", "TRG", "TRG", "TRG", "TRG", "TRG",
"TRG", "TRG", "TRG", "TRG", "TRG"
};
LocalizedText.mainTable["DESC_TRG"] = new List<string>(15)
{
"TRG sniper rifle", "TRG sniper rifle", "TRG sniper rifle", "TRG sniper rifle", "TRG sniper rifle", "TRG sniper rifle", "TRG sniper rifle", "TRG sniper rifle", "TRG sniper rifle", "TRG sniper rifle",
"TRG sniper rifle", "TRG sniper rifle", "TRG sniper rifle", "TRG sniper rifle", "TRG sniper rifle"
};
}
}
}