using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Decoy;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Serialization;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("NatanM")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Decoy")]
[assembly: AssemblyTitle("Decoy")]
[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.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;
}
}
[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;
}
}
}
public class ItemDecoyBehaviour : MonoBehaviour
{
public Color blinkColor;
private ItemToggle itemToggle;
private ItemAttributes itemAttributes;
internal bool isActive;
private float grenadeTimer;
private bool isPlayingSound;
private float soundPlayTime;
public float tickTime = 3f;
private PhotonView photonView;
private PhysGrabObjectImpactDetector physGrabObjectImpactDetector;
public Sound soundSplinter;
public Sound soundTick;
public Sound soundDecoy;
private float splinterAnimationProgress;
public AnimationCurve splinterAnimationCurve;
private Transform splinterTransform;
private Material grenadeEmissionMaterial;
private ItemEquippable itemEquippable;
private Vector3 grenadeStartPosition;
private Quaternion grenadeStartRotation;
private PhysGrabObject physGrabObject;
private Vector3 prevPosition;
private ParticleScriptExplosion particleScriptExplosion;
public Sound soundExplosion;
public Sound soundExplosionGlobal;
[FormerlySerializedAs("isThiefGrenade")]
[HideInInspector]
public bool isSpawnedGrenade;
public GameObject throwLine;
private Rigidbody rb;
private float throwLineTimer;
private TrailRenderer throwLineTrail;
private const float DEFAULT_SOUND_PLAY_TIME = 8f;
private bool cfgExp;
private float cfgExpRad;
private int cfgExpDam;
private int cfgExpDamEnemy;
private float cfgExpForce;
private float cfgTickTime;
private float cfgLureRad;
private float cfgDecoyLureTime;
private float cfgPitchStep;
private void Start()
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: 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)
itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
itemToggle = ((Component)this).GetComponent<ItemToggle>();
itemAttributes = ((Component)this).GetComponent<ItemAttributes>();
photonView = ((Component)this).GetComponent<PhotonView>();
physGrabObjectImpactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
splinterTransform = ((Component)this).transform.Find("Splinter");
GameObject gameObject = ((Component)((Component)this).transform.Find("Mesh")).gameObject;
grenadeEmissionMaterial = gameObject.GetComponent<Renderer>().material;
grenadeStartPosition = ((Component)this).transform.position;
grenadeStartRotation = ((Component)this).transform.rotation;
physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
rb = ((Component)this).GetComponent<Rigidbody>();
throwLineTrail = throwLine.GetComponent<TrailRenderer>();
SetupDecoy();
}
private void SetupDecoy()
{
if (SemiFunc.IsMasterClientOrSingleplayer())
{
DecoyPlugin instance = DecoyPlugin.Instance;
((BaseUnityPlugin)instance).Config.Reload();
if (!GameManager.Multiplayer())
{
LoadDecoyCfgRPC(instance.Explodes.Value, instance.ExplosionRadius.Value, instance.ExplosionDamage.Value, instance.ExplosionDamageEnemy.Value, instance.ForceMultiplier.Value, instance.TickTime.Value, instance.LureRange.Value, instance.DecoyLureTime.Value, instance.PitchStep.Value);
}
else
{
photonView.RPC("LoadDecoyCfgRPC", (RpcTarget)0, new object[9]
{
instance.Explodes.Value,
instance.ExplosionRadius.Value,
instance.ExplosionDamage.Value,
instance.ExplosionDamageEnemy.Value,
instance.ForceMultiplier.Value,
instance.TickTime.Value,
instance.LureRange.Value,
instance.DecoyLureTime.Value,
instance.PitchStep.Value
});
}
}
((MonoBehaviour)this).StartCoroutine(LoadClip());
}
[PunRPC]
private void LoadDecoyCfgRPC(bool explodes, float expRad, int expDam, int expDamEnemy, float expForce, float tickTime, float lureRad, float decoyLureTime, float pitchStep)
{
DecoyPlugin.Logger.LogDebug((object)("--- LOADED DECOY CFG ---\n" + $"Explodes: {explodes}\n" + $"Explosion Radius: {expRad}\n" + $"Explosion Damage: {expDam}\n" + $"Explosion Damage Enemy: {expDamEnemy}\n" + $"Explosion Force: {expForce}\n\n" + $"Tick Time: {tickTime}\n" + $"Lure Radius: {lureRad}\n" + $"Decoy Lure Time: {decoyLureTime}\n" + $"Pitch Step: {pitchStep}"));
cfgExp = explodes;
cfgExpRad = expRad;
cfgExpDam = expDam;
cfgExpDamEnemy = expDamEnemy;
cfgExpForce = expForce;
cfgTickTime = tickTime;
cfgLureRad = lureRad;
cfgDecoyLureTime = decoyLureTime;
cfgPitchStep = pitchStep;
}
private IEnumerator LoadClip()
{
string customSoundPath = Path.Combine(Application.streamingAssetsPath, "Decoy", "decoy_sound.mp3").Replace('\\', '/');
DecoyPlugin.Logger.LogInfo((object)("Trying to load clip from \"" + customSoundPath + "\"..."));
UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("file://" + customSoundPath, (AudioType)13);
try
{
yield return req.SendWebRequest();
if ((int)req.result == 1)
{
AudioClip clip = DownloadHandlerAudioClip.GetContent(req);
soundDecoy.Sounds = (AudioClip[])(object)new AudioClip[1] { clip };
DecoyPlugin.Logger.LogInfo((object)"Success!");
}
else
{
DecoyPlugin.Logger.LogInfo((object)("Could not load custom flip: " + req.error));
}
}
finally
{
((IDisposable)req)?.Dispose();
}
}
private void FixedUpdate()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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_0078: 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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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 (itemEquippable.isEquipped || itemEquippable.wasEquippedTimer > 0f)
{
prevPosition = rb.position;
return;
}
Vector3 val = (rb.position - prevPosition) / Time.fixedDeltaTime;
Vector3 val2 = rb.position - prevPosition;
_ = ((Vector3)(ref val2)).normalized;
prevPosition = rb.position;
if (!physGrabObject.grabbed && ((Vector3)(ref val)).magnitude > 2f)
{
throwLineTimer = 0.2f;
}
if (throwLineTimer > 0f)
{
throwLineTrail.emitting = true;
throwLineTimer -= Time.fixedDeltaTime;
}
else
{
throwLineTrail.emitting = false;
}
}
private void Update()
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
soundTick.PlayLoop(isActive && !isPlayingSound, 2f, 2f, 1f);
if (itemEquippable.isEquipped)
{
if (isActive)
{
isActive = false;
grenadeTimer = 0f;
splinterAnimationProgress = 0f;
itemToggle.ToggleItem(false, -1);
splinterTransform.localEulerAngles = new Vector3(0f, 0f, 0f);
grenadeEmissionMaterial.SetColor("_EmissionColor", Color.black);
}
return;
}
if (isActive && isPlayingSound)
{
if (splinterAnimationProgress < 1f)
{
splinterAnimationProgress += 5f * Time.deltaTime;
float num = splinterAnimationCurve.Evaluate(splinterAnimationProgress);
splinterTransform.localEulerAngles = new Vector3(num * 90f, 0f, 0f);
}
float num2 = Mathf.PingPong(Time.time * 8f, 1f);
Color val = blinkColor * Mathf.LinearToGammaSpace(num2);
grenadeEmissionMaterial.SetColor("_EmissionColor", val);
}
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
if (itemToggle.toggleState && !isActive)
{
isActive = true;
TickStart();
}
if (!isActive)
{
return;
}
if (!isPlayingSound)
{
grenadeTimer += Time.deltaTime;
if (grenadeTimer >= cfgTickTime)
{
grenadeTimer = 0f;
isPlayingSound = true;
TickEnd();
}
}
else
{
soundPlayTime += Time.deltaTime;
}
}
private void GrenadeReset()
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: 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_00af: Unknown result type (might be due to invalid IL or missing references)
isActive = false;
isPlayingSound = false;
soundPlayTime = 0f;
grenadeTimer = 0f;
soundDecoy.Pitch = 1f;
throwLine.SetActive(false);
splinterAnimationProgress = 0f;
itemToggle.ToggleItem(false, -1);
splinterTransform.localEulerAngles = new Vector3(0f, 0f, 0f);
grenadeEmissionMaterial.SetColor("_EmissionColor", Color.black);
if (SemiFunc.IsMasterClientOrSingleplayer())
{
Rigidbody component = ((Component)this).GetComponent<Rigidbody>();
component.velocity = Vector3.zero;
component.angularVelocity = Vector3.zero;
}
}
private void TickStart()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.IsMasterClient())
{
photonView.RPC("TickStartRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
TickStartRPC();
}
}
private void TickEnd()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.IsMasterClient())
{
photonView.RPC("TickEndRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
TickEndRPC();
}
}
[PunRPC]
private void TickStartRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.MasterOnlyRPC(_info))
{
soundSplinter.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
isActive = true;
}
}
[PunRPC]
private void TickEndRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.MasterOnlyRPC(_info) && !itemEquippable.isEquipped)
{
((MonoBehaviour)this).StartCoroutine(AwaitSoundFinished());
}
}
private IEnumerator AwaitSoundFinished()
{
soundPlayTime = 0f;
soundDecoy.SpatialBlend = 1f;
AudioSource src = soundDecoy.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
while (soundPlayTime < cfgDecoyLureTime)
{
if (!SemiFunc.RunIsShop())
{
EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, cfgLureRad, false);
}
if ((Object)(object)src == (Object)null || !src.isPlaying)
{
Sound obj = soundDecoy;
obj.Pitch += cfgPitchStep;
src = soundDecoy.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
}
else
{
((Component)src).transform.position = ((Component)this).transform.position;
}
yield return null;
}
if ((Object)(object)src != (Object)null)
{
src.Stop();
}
if (SemiFunc.IsMasterClient())
{
photonView.RPC("SoundFinishedRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
SoundFinishedRPC();
}
}
[PunRPC]
private void SoundFinishedRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
Explode();
if (SemiFunc.IsMasterClientOrSingleplayer())
{
if (!SemiFunc.RunIsShop() || isSpawnedGrenade)
{
if (!isSpawnedGrenade)
{
StatsManager.instance.ItemRemove(itemAttributes.instanceName);
}
physGrabObjectImpactDetector.DestroyObject(true);
}
else
{
physGrabObject.Teleport(grenadeStartPosition, grenadeStartRotation);
}
}
if (SemiFunc.RunIsShop() && !isSpawnedGrenade)
{
GrenadeReset();
}
}
private void Explode()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
if (cfgExp)
{
particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
particleScriptExplosion.Spawn(((Component)this).transform.position, cfgExpRad, cfgExpDam, cfgExpDamEnemy, cfgExpForce, false, true, 1f);
soundExplosion.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
soundExplosionGlobal.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
}
}
}
namespace Decoy
{
[BepInPlugin("NatanM.Decoy", "Decoy", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class DecoyPlugin : BaseUnityPlugin
{
private ConfigEntry<bool>? _explodes;
private ConfigEntry<float>? _expRadius;
private ConfigEntry<int>? _expDam;
private ConfigEntry<int>? _expDamEnemy;
private ConfigEntry<float>? _forceMulti;
private ConfigEntry<float>? _tickTime;
private ConfigEntry<float>? _lureRange;
private ConfigEntry<float>? _lureTime;
private ConfigEntry<float>? _pitchStep;
private static DecoyPlugin? _instance;
public ConfigEntry<bool> Explodes => _explodes;
public ConfigEntry<float> ExplosionRadius => _expRadius;
public ConfigEntry<int> ExplosionDamage => _expDam;
public ConfigEntry<int> ExplosionDamageEnemy => _expDamEnemy;
public ConfigEntry<float> ForceMultiplier => _forceMulti;
public ConfigEntry<float> TickTime => _tickTime;
public ConfigEntry<float> LureRange => _lureRange;
public ConfigEntry<float> DecoyLureTime => _lureTime;
public ConfigEntry<float> PitchStep => _pitchStep;
public static ManualLogSource Logger { get; } = Logger.CreateLogSource("Item Decoy Behaviour");
public static DecoyPlugin Instance => _instance;
private void Awake()
{
_instance = this;
_tickTime = ((BaseUnityPlugin)this).Config.Bind<float>("Decoy", "tick_time", 3f, (ConfigDescription)null);
_lureRange = ((BaseUnityPlugin)this).Config.Bind<float>("Decoy", "lure_range", 500f, (ConfigDescription)null);
_lureTime = ((BaseUnityPlugin)this).Config.Bind<float>("Decoy", "lure_time", 8f, (ConfigDescription)null);
_pitchStep = ((BaseUnityPlugin)this).Config.Bind<float>("Decoy", "pitch_step", 0.15f, (ConfigDescription)null);
_explodes = ((BaseUnityPlugin)this).Config.Bind<bool>("Explosion", "explode", true, (ConfigDescription)null);
_expRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Explosion", "radius", 2f, (ConfigDescription)null);
_expDam = ((BaseUnityPlugin)this).Config.Bind<int>("Explosion", "damage", 100, (ConfigDescription)null);
_expDamEnemy = ((BaseUnityPlugin)this).Config.Bind<int>("Explosion", "enemy_damage", 200, (ConfigDescription)null);
_forceMulti = ((BaseUnityPlugin)this).Config.Bind<float>("Explosion", "force_multiplier", 5f, (ConfigDescription)null);
}
}
}