using System;
using System.Collections;
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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using SammyCadian.PillsScripts;
using UnityEngine;
[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("SammyCadian")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PillsScripts")]
[assembly: AssemblyTitle("PillsScripts")]
[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;
}
}
}
namespace SammyCadian.PillsScripts
{
public class PillsBottle : MonoBehaviour
{
public GameObject itemEffectPrefab;
public int pillType;
public int healAmount;
private ItemToggle itemToggle;
private ItemEquippable itemEquippable;
private ItemAttributes itemAttributes;
private PhotonView photonView;
private PhysGrabObject physGrabObject;
[Space]
public ParticleSystem[] particles;
public ParticleSystem[] rejectParticles;
[Space]
public PropLight propLight;
public AnimationCurve lightIntensityCurve;
private float lightIntensityLerp;
public MeshRenderer mesh;
private Material material;
private Color materialEmissionOriginal;
private int materialPropertyEmission = Shader.PropertyToID("_EmissionColor");
[Space]
public Sound soundUse;
public Sound soundReject;
private bool used;
private void Start()
{
//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)
itemToggle = ((Component)this).GetComponent<ItemToggle>();
itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
itemAttributes = ((Component)this).GetComponent<ItemAttributes>();
photonView = ((Component)this).GetComponent<PhotonView>();
physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
material = ((Renderer)mesh).material;
materialEmissionOriginal = material.GetColor(materialPropertyEmission);
}
private void Update()
{
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: 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_0133: 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_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)itemToggle == (Object)null || (Object)(object)itemEquippable == (Object)null || (Object)(object)itemAttributes == (Object)null || (Object)(object)physGrabObject == (Object)null || (Object)(object)photonView == (Object)null || SemiFunc.RunIsShop())
{
return;
}
LightLogic();
if (!SemiFunc.IsMasterClientOrSingleplayer() || !itemToggle.toggleState || used)
{
return;
}
PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(itemToggle.playerTogglePhotonID);
if (!Object.op_Implicit((Object)(object)val))
{
return;
}
if (val.playerHealth.health > val.playerHealth.maxHealth)
{
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("RejectRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
RejectRPC();
}
itemToggle.ToggleItem(false, -1);
physGrabObject.rb.AddForce(Vector3.up * 2f, (ForceMode)1);
physGrabObject.rb.AddTorque(-((Component)physGrabObject).transform.right * 0.05f, (ForceMode)1);
return;
}
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("InstantiateEffectRPC", (RpcTarget)0, new object[2]
{
itemToggle.playerTogglePhotonID,
((Component)this).transform.position
});
}
else
{
GameObject val2 = Object.Instantiate<GameObject>(itemEffectPrefab, ((Component)this).transform.position, Quaternion.identity);
val2.GetComponent<PillsEffect>().Initialize(itemToggle.playerTogglePhotonID, pillType);
}
StatsManager.instance.ItemRemove(itemAttributes.instanceName);
physGrabObject.impactDetector.indestructibleBreakEffects = true;
if (SemiFunc.IsMultiplayer())
{
photonView.RPC("UsedRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
UsedRPC();
}
}
private void LightLogic()
{
//IL_0082: 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)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
if (used && lightIntensityLerp < 1f)
{
lightIntensityLerp += 1f * Time.deltaTime;
propLight.lightComponent.intensity = lightIntensityCurve.Evaluate(lightIntensityLerp);
propLight.originalIntensity = propLight.lightComponent.intensity;
material.SetColor(materialPropertyEmission, Color.Lerp(Color.black, materialEmissionOriginal, lightIntensityCurve.Evaluate(lightIntensityLerp)));
}
}
[PunRPC]
private void InstantiateEffectRPC(int _photonID, Vector3 _position, PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: 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)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.MasterOnlyRPC(_info))
{
GameObject val = PhotonNetwork.Instantiate("Items/Drugs", _position, Quaternion.identity, (byte)0, (object[])null);
val.GetComponent<PillsEffect>().Initialize(_photonID, pillType);
}
}
[PunRPC]
private void UsedRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.MasterOnlyRPC(_info))
{
GameDirector.instance.CameraImpact.ShakeDistance(5f, 1f, 6f, ((Component)this).transform.position, 0.2f);
itemToggle.ToggleDisable(true);
itemAttributes.DisableUI(true);
Object.Destroy((Object)(object)itemEquippable);
ParticleSystem[] array = particles;
for (int i = 0; i < array.Length; i++)
{
array[i].Play();
}
soundUse.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
used = true;
}
}
[PunRPC]
private void RejectRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
{
//IL_0001: 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)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.MasterOnlyRPC(_info))
{
PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(itemToggle.playerTogglePhotonID);
if (val.isLocal)
{
val.physGrabber.ReleaseObjectRPC(false, 1f);
}
ParticleSystem[] array = rejectParticles;
for (int i = 0; i < array.Length; i++)
{
array[i].Play();
}
GameDirector.instance.CameraImpact.ShakeDistance(5f, 1f, 6f, ((Component)this).transform.position, 0.2f);
soundReject.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
}
}
public void OnDestroy()
{
//IL_003a: 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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
ParticleSystem[] array = particles;
ParticleSystem[] array2 = array;
foreach (ParticleSystem val in array2)
{
if (Object.op_Implicit((Object)(object)val) && val.isPlaying)
{
((Component)val).transform.SetParent((Transform)null);
MainModule main = val.main;
((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)2;
}
}
array = rejectParticles;
ParticleSystem[] array3 = array;
foreach (ParticleSystem val2 in array3)
{
if (Object.op_Implicit((Object)(object)val2) && val2.isPlaying)
{
((Component)val2).transform.SetParent((Transform)null);
MainModule main2 = val2.main;
((MainModule)(ref main2)).stopAction = (ParticleSystemStopAction)2;
}
}
}
}
public class PillsEffect : MonoBehaviour
{
public GameObject explosivePrefab;
public float pillADuration = 20f;
public float pillBDuration = 20f;
public float pillBInvincibleDuration = 10f;
public float boostedSpeed = 3f;
public float strengthBonus = 1f;
private int targetPhotonViewIDyay;
private int pillType;
private float baseStrength;
private float pillTimer;
private void Start()
{
}
public void Initialize(int targetPhotonViewID, int typeParameter)
{
pillType = typeParameter;
pillTimer = 20f;
targetPhotonViewIDyay = targetPhotonViewID;
switch (pillType)
{
case 0:
pillTimer = pillADuration;
break;
case 1:
pillTimer = pillBDuration;
if (targetPhotonViewIDyay == SemiFunc.PhotonViewIDPlayerAvatarLocal())
{
baseStrength = SemiFunc.PlayerAvatarLocal().physGrabber.grabStrength;
SemiFunc.PlayerAvatarGetFromPhotonID(targetPhotonViewIDyay).playerHealth.InvincibleSet(pillBDuration);
}
break;
case 2:
pillTimer = 1f;
break;
}
}
private void Update()
{
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
if (targetPhotonViewIDyay != SemiFunc.PhotonViewIDPlayerAvatarLocal())
{
return;
}
switch (pillType)
{
case 0:
CameraZoom.Instance.OverrideZoomSet(130f, 0.1f, 0.5f, 1f, ((Component)this).gameObject, 2);
PlayerController.instance.OverrideSpeed(boostedSpeed, 0.1f);
PlayerController.instance.EnergyCurrent = PlayerController.instance.EnergyStart;
break;
case 1:
CameraZoom.Instance.OverrideZoomSet(110f, 0.1f, 0.5f, 1f, ((Component)this).gameObject, 2);
SemiFunc.PlayerAvatarLocal().physGrabber.grabStrength = baseStrength + strengthBonus;
break;
case 2:
CameraZoom.Instance.OverrideZoomSet(110f, 0.1f, 0.5f, 1f, ((Component)this).gameObject, 2);
break;
}
if (pillTimer < 0f)
{
if (pillType == 1)
{
SemiFunc.PlayerAvatarLocal().physGrabber.grabStrength = baseStrength;
}
else if (pillType == 2)
{
if (SemiFunc.IsMultiplayer())
{
GameObject val = PhotonNetwork.Instantiate("Items/SuicideBomb", ((Component)SemiFunc.PlayerAvatarGetFromPhotonID(targetPhotonViewIDyay)).transform.position, Quaternion.identity, (byte)0, (object[])null);
val.GetComponent<SuicidersGrenade>().Initialize();
val.GetComponent<SuicidersGrenade>().Spawn();
}
else
{
SuicidersGrenade component = Object.Instantiate<GameObject>(explosivePrefab, ((Component)SemiFunc.PlayerAvatarGetFromPhotonID(targetPhotonViewIDyay)).transform.position, Quaternion.identity).GetComponent<SuicidersGrenade>();
component.Initialize();
component.Spawn();
}
}
Object.Destroy((Object)(object)this);
}
pillTimer -= Time.deltaTime;
}
}
public class SuicidersGrenade : MonoBehaviour
{
[CompilerGenerated]
private sealed class <LateSpawn>d__11 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public SuicidersGrenade <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LateSpawn>d__11(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (!<>4__this.physGrabObject.spawned || <>4__this.rb.isKinematic)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<>4__this.itemToggle.ToggleItem(true, -1);
<>4__this.itemGrenade.tickTime = Random.Range(0.1f, 0.3f);
<>4__this.itemGrenade.isSpawnedGrenade = true;
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();
}
}
private ParticleScriptExplosion particleScriptExplosion;
private ItemToggle itemToggle;
private ItemGrenade itemGrenade;
private PhotonView photonView;
private PhysGrabObject physGrabObject;
private Rigidbody rb;
public Sound soundExplosion;
public Sound soundExplosionGlobal;
private void Start()
{
Initialize();
}
public void Initialize()
{
particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
itemToggle = ((Component)this).GetComponent<ItemToggle>();
itemGrenade = ((Component)this).GetComponent<ItemGrenade>();
photonView = ((Component)this).GetComponent<PhotonView>();
physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
rb = ((Component)this).GetComponent<Rigidbody>();
}
public void Spawn()
{
((MonoBehaviour)this).StartCoroutine(LateSpawn());
itemGrenade.isSpawnedGrenade = true;
}
[IteratorStateMachine(typeof(<LateSpawn>d__11))]
private IEnumerator LateSpawn()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LateSpawn>d__11(0)
{
<>4__this = this
};
}
public void Explosion()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"Grenade explosion");
particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
particleScriptExplosion.Spawn(((Component)this).transform.position, 1.5f, 1000, 1000, 2f, false, true, 1f);
soundExplosion.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
soundExplosionGlobal.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
}
}
}
namespace PillsScripts
{
[HarmonyPatch(typeof(PlayerController))]
internal static class ExamplePlayerControllerPatch
{
[HarmonyPrefix]
[HarmonyPatch("Start")]
private static void Start_Prefix(PlayerController __instance)
{
PillsScripts.Logger.LogDebug((object)$"{__instance} Start Prefix");
}
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(PlayerController __instance)
{
PillsScripts.Logger.LogDebug((object)$"{__instance} Start Postfix");
}
}
[BepInPlugin("SammyCadian.PillsScripts", "PillsScripts", "1.0")]
public class PillsScripts : BaseUnityPlugin
{
internal static PillsScripts Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
internal PillsBottle? pillsBottleInstance { get; private set; }
internal PillsEffect? pillsEffectInstance { get; private set; }
internal SuicidersGrenade? suicidersGrenadeInstance { get; private set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
pillsBottleInstance = ((Component)this).gameObject.AddComponent<PillsBottle>();
pillsEffectInstance = ((Component)this).gameObject.AddComponent<PillsEffect>();
suicidersGrenadeInstance = ((Component)this).gameObject.AddComponent<SuicidersGrenade>();
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
}
}
}