using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using PunishingBirdScrap.Behaviours;
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: AssemblyCompany("PunishingBirdScrap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PunishingBirdScrap")]
[assembly: AssemblyTitle("PunishingBirdScrap")]
[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 PunishingBirdScrap
{
[BepInPlugin("cyber.punishingBirdScrap", "Punishing Bird Scrap", "0.0.1")]
public class Plugin : BaseUnityPlugin
{
private const string GUID = "cyber.punishingBirdScrap";
private const string NAME = "Punishing Bird Scrap";
private const string VERSION = "0.0.1";
public static Plugin instance;
private void Awake()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
instance = this;
LevelTypes val = (LevelTypes)7376;
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "punishingbird");
AssetBundle val2 = AssetBundle.LoadFromFile(text);
Item val3 = val2.LoadAsset<Item>("Assets/PunishingBird/PunishingBirdItem.asset");
DamagePlayerItem damagePlayerItem = val3.spawnPrefab.AddComponent<DamagePlayerItem>();
((GrabbableObject)damagePlayerItem).grabbable = true;
((GrabbableObject)damagePlayerItem).grabbableToEnemies = true;
((GrabbableObject)damagePlayerItem).itemProperties = val3;
NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
Utilities.FixMixerGroups(val3.spawnPrefab);
Items.RegisterScrap(val3, 25, val);
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "cyber.punishingBirdScrap");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Punishing Bird has breached Containment!");
}
}
}
namespace PunishingBirdScrap.Behaviours
{
internal class DamagePlayerItem : PhysicsProp
{
private Random rnd = new Random();
private Coroutine customCoroutine;
private bool coroutineRunning = false;
private float timeToWaitFloat;
private int timeToWait;
private AudioSource birdAttackSource;
public void Awake()
{
GameObject gameObject = ((Component)((Component)this).transform.Find("PunishingBirdModel")).gameObject;
birdAttackSource = gameObject.GetComponent<AudioSource>();
}
public override void DiscardItem()
{
((GrabbableObject)this).DiscardItem();
if (coroutineRunning)
{
((MonoBehaviour)this).StopCoroutine(customCoroutine);
}
}
public override async void GrabItem()
{
<>n__0();
timeToWaitFloat = 3f;
if (((GrabbableObject)this).isHeld)
{
await Task.Delay(TimeSpan.FromSeconds(timeToWaitFloat));
if (((GrabbableObject)this).isHeld)
{
((GrabbableObject)this).playerHeldBy.DamagePlayer(5, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
birdAttackSource.PlayOneShot(birdAttackSource.clip);
customCoroutine = ((MonoBehaviour)this).StartCoroutine(PunishingBirdAttack());
}
}
}
private IEnumerator PunishingBirdAttack()
{
coroutineRunning = true;
timeToWait = rnd.Next(10, 20);
timeToWaitFloat = timeToWait;
while (((GrabbableObject)this).isHeld)
{
yield return (object)new WaitForSeconds(timeToWaitFloat);
if (!((GrabbableObject)this).isHeld)
{
yield break;
}
((GrabbableObject)this).playerHeldBy.DamagePlayer(5, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
birdAttackSource.PlayOneShot(birdAttackSource.clip);
}
coroutineRunning = false;
}
[CompilerGenerated]
[DebuggerHidden]
private void <>n__0()
{
((GrabbableObject)this).GrabItem();
}
}
}