using System;
using System.Collections;
using System.Collections.Generic;
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 LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("KuriiePlushMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adds a cute Kuriie plushie as scrap to Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("KuriiePlushMod")]
[assembly: AssemblyTitle("KuriiePlushMod")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace KuriiePlushMod
{
public class KuriiePlushBehaviour : PhysicsProp
{
[CompilerGenerated]
private sealed class <SqueezeAnimationCoroutine>d__12 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public KuriiePlushBehaviour <>4__this;
private float <squeezeDuration>5__2;
private float <returnDuration>5__3;
private Vector3 <squeezedScale>5__4;
private float <elapsed>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SqueezeAnimationCoroutine>d__12(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0073: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: 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_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
KuriiePlushBehaviour kuriiePlushBehaviour = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<squeezeDuration>5__2 = 0.15f;
<returnDuration>5__3 = 0.4f;
<squeezedScale>5__4 = new Vector3(kuriiePlushBehaviour.meshOriginalScale.x * 1.4f, kuriiePlushBehaviour.meshOriginalScale.y * 0.5f, kuriiePlushBehaviour.meshOriginalScale.z * 1.4f);
<elapsed>5__5 = 0f;
goto IL_00de;
case 1:
<>1__state = -1;
goto IL_00de;
case 2:
{
<>1__state = -1;
break;
}
IL_00de:
if (<elapsed>5__5 < <squeezeDuration>5__2)
{
<elapsed>5__5 += Time.deltaTime;
float num2 = <elapsed>5__5 / <squeezeDuration>5__2;
kuriiePlushBehaviour.meshTransform.localScale = Vector3.Lerp(kuriiePlushBehaviour.meshOriginalScale, <squeezedScale>5__4, num2);
<>2__current = null;
<>1__state = 1;
return true;
}
<elapsed>5__5 = 0f;
break;
}
if (<elapsed>5__5 < <returnDuration>5__3)
{
<elapsed>5__5 += Time.deltaTime;
float num3 = <elapsed>5__5 / <returnDuration>5__3;
float num4 = 1f - Mathf.Cos(num3 * MathF.PI * 2f) * Mathf.Pow(1f - num3, 2f);
kuriiePlushBehaviour.meshTransform.localScale = Vector3.Lerp(<squeezedScale>5__4, kuriiePlushBehaviour.meshOriginalScale, num4);
<>2__current = null;
<>1__state = 2;
return true;
}
kuriiePlushBehaviour.meshTransform.localScale = kuriiePlushBehaviour.meshOriginalScale;
kuriiePlushBehaviour.squeezeCoroutine = null;
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 AudioSource audioSource;
private float lastUseTime = -999f;
private const float COOLDOWN = 2f;
private Transform meshTransform;
private Vector3 meshOriginalScale;
private Coroutine squeezeCoroutine;
public static AudioClip confettiSound;
public override void Start()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
((GrabbableObject)this).Start();
audioSource = ((Component)this).GetComponent<AudioSource>();
meshTransform = ((Component)this).transform;
meshOriginalScale = meshTransform.localScale;
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
((GrabbableObject)this).ItemActivate(used, buttonDown);
if (buttonDown && Time.time >= lastUseTime + 2f)
{
lastUseTime = Time.time;
PlayEffectsServerRpc();
}
}
[ServerRpc(RequireOwnership = false)]
private void PlayEffectsServerRpc()
{
PlayEffectsClientRpc();
}
[ClientRpc]
private void PlayEffectsClientRpc()
{
PlayConfetti();
PlaySound();
PlaySqueezeAnimation();
}
private void PlaySqueezeAnimation()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)meshTransform == (Object)null))
{
if (squeezeCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(squeezeCoroutine);
meshTransform.localScale = meshOriginalScale;
}
squeezeCoroutine = ((MonoBehaviour)this).StartCoroutine(SqueezeAnimationCoroutine());
}
}
[IteratorStateMachine(typeof(<SqueezeAnimationCoroutine>d__12))]
private IEnumerator SqueezeAnimationCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SqueezeAnimationCoroutine>d__12(0)
{
<>4__this = this
};
}
private void PlaySound()
{
if (!((Object)(object)audioSource == (Object)null))
{
if ((Object)(object)confettiSound != (Object)null)
{
audioSource.PlayOneShot(confettiSound);
}
else if ((Object)(object)((GrabbableObject)this).itemProperties != (Object)null && (Object)(object)((GrabbableObject)this).itemProperties.grabSFX != (Object)null)
{
audioSource.PlayOneShot(((GrabbableObject)this).itemProperties.grabSFX);
}
}
}
private void PlayConfetti()
{
if (!TryUseGameConfetti())
{
CreateCustomConfetti();
}
}
private bool TryUseGameConfetti()
{
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Expected O, but got Unknown
try
{
StartOfRound instance = StartOfRound.Instance;
if ((Object)(object)instance == (Object)null)
{
return false;
}
FieldInfo[] fields = typeof(StartOfRound).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (FieldInfo fieldInfo in fields)
{
string text = fieldInfo.Name.ToLower();
if (text.Contains("confetti") || text.Contains("birthday"))
{
object value = fieldInfo.GetValue(instance);
ParticleSystem val = (ParticleSystem)((value is ParticleSystem) ? value : null);
if (val != null && (Object)(object)val != (Object)null)
{
SpawnConfettiFromPrefab(((Component)val).gameObject);
return true;
}
GameObject val2 = (GameObject)((value is GameObject) ? value : null);
if (val2 != null && (Object)(object)val2 != (Object)null && (Object)(object)val2.GetComponent<ParticleSystem>() != (Object)null)
{
SpawnConfettiFromPrefab(val2);
return true;
}
}
}
foreach (Transform item in ((Component)instance).transform)
{
Transform val3 = item;
if (((Object)val3).name.ToLower().Contains("confetti") && (Object)(object)((Component)val3).GetComponent<ParticleSystem>() != (Object)null)
{
SpawnConfettiFromPrefab(((Component)val3).gameObject);
return true;
}
}
}
catch (Exception)
{
}
return false;
}
private void SpawnConfettiFromPrefab(GameObject confettiPrefab)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_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)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: 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_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Component)this).transform.position;
Quaternion val = Quaternion.identity;
if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy.gameplayCamera != (Object)null)
{
val = ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.rotation;
}
GameObject val2 = Object.Instantiate<GameObject>(confettiPrefab, position, val);
val2.SetActive(true);
ParticleSystem component = val2.GetComponent<ParticleSystem>();
if ((Object)(object)component != (Object)null)
{
component.Play();
MainModule main = component.main;
float duration = ((MainModule)(ref main)).duration;
main = component.main;
MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime;
Object.Destroy((Object)(object)val2, duration + ((MinMaxCurve)(ref startLifetime)).constantMax + 1f);
}
else
{
Object.Destroy((Object)(object)val2, 3f);
}
}
private void CreateCustomConfetti()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0017: 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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: 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_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: 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_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: 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_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_035a: Unknown result type (might be due to invalid IL or missing references)
//IL_0361: Expected O, but got Unknown
//IL_036b: Unknown result type (might be due to invalid IL or missing references)
//IL_0375: Unknown result type (might be due to invalid IL or missing references)
//IL_037a: Unknown result type (might be due to invalid IL or missing references)
//IL_0381: Unknown result type (might be due to invalid IL or missing references)
//IL_038b: Unknown result type (might be due to invalid IL or missing references)
//IL_0390: Unknown result type (might be due to invalid IL or missing references)
//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
//IL_0340: Unknown result type (might be due to invalid IL or missing references)
//IL_034a: Expected O, but got Unknown
GameObject val = new GameObject("KuriieConfetti");
val.transform.position = ((Component)this).transform.position;
if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy.gameplayCamera != (Object)null)
{
val.transform.rotation = ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.rotation;
}
else
{
val.transform.rotation = ((Component)this).transform.rotation;
}
ParticleSystem val2 = val.AddComponent<ParticleSystem>();
val2.Stop(true, (ParticleSystemStopBehavior)0);
MainModule main = val2.main;
((MainModule)(ref main)).duration = 0.3f;
((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.5f, 2.5f);
((MainModule)(ref main)).startSpeed = new MinMaxCurve(4f, 7f);
((MainModule)(ref main)).startSize = new MinMaxCurve(0.03f, 0.08f);
((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, MathF.PI * 2f);
((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.4f);
((MainModule)(ref main)).maxParticles = 150;
((MainModule)(ref main)).loop = false;
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
((MainModule)(ref main)).startSize3D = true;
((MainModule)(ref main)).startSizeX = new MinMaxCurve(0.02f, 0.05f);
((MainModule)(ref main)).startSizeY = new MinMaxCurve(0.06f, 0.12f);
((MainModule)(ref main)).startSizeZ = new MinMaxCurve(0.01f, 0.02f);
Color[] array = (Color[])(object)new Color[8]
{
new Color(1f, 0.3f, 0.5f),
new Color(1f, 0.85f, 0.2f),
new Color(0.3f, 1f, 0.4f),
new Color(0.7f, 0.4f, 1f),
new Color(1f, 0.5f, 0.2f),
new Color(0.4f, 0.7f, 1f),
new Color(1f, 0.4f, 0.4f),
Color.white
};
((MainModule)(ref main)).startColor = new MinMaxGradient(array[Random.Range(0, array.Length)], array[Random.Range(0, array.Length)]);
EmissionModule emission = val2.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1]
{
new Burst(0f, (short)80)
});
ShapeModule shape = val2.shape;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
((ShapeModule)(ref shape)).angle = 35f;
((ShapeModule)(ref shape)).radius = 0.15f;
RotationOverLifetimeModule rotationOverLifetime = val2.rotationOverLifetime;
((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true;
((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = new MinMaxCurve(-MathF.PI, MathF.PI);
ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
component.renderMode = (ParticleSystemRenderMode)0;
Shader val3 = Shader.Find("Legacy Shaders/Particles/Alpha Blended Premultiply") ?? Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color");
if ((Object)(object)val3 != (Object)null)
{
((Renderer)component).material = new Material(val3);
}
ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
Gradient val4 = new Gradient();
val4.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
{
new GradientColorKey(Color.white, 0f),
new GradientColorKey(Color.white, 1f)
}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
{
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(0f, 1f)
});
((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val4);
val2.Play();
Object.Destroy((Object)(object)val, 3f);
}
}
[BepInPlugin("com.kuriie.plushmod", "Kuriie Plush", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string ModGUID = "com.kuriie.plushmod";
public const string ModName = "Kuriie Plush";
public const string ModVersion = "1.0.0";
private void Awake()
{
AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "kuriieplush"));
if ((Object)(object)val == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load asset bundle!");
return;
}
Item val2 = null;
string[] allAssetNames = val.GetAllAssetNames();
foreach (string text in allAssetNames)
{
if (text.EndsWith(".asset"))
{
Item val3 = val.LoadAsset<Item>(text);
if ((Object)(object)val3 != (Object)null)
{
val2 = val3;
break;
}
}
}
if ((Object)(object)val2 == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load KuriiePlushItem from asset bundle!");
return;
}
if ((Object)(object)val2.spawnPrefab == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Item's spawnPrefab is null!");
return;
}
GameObject spawnPrefab = val2.spawnPrefab;
GrabbableObject component = spawnPrefab.GetComponent<GrabbableObject>();
if ((Object)(object)component != (Object)null)
{
Object.DestroyImmediate((Object)(object)component);
}
KuriiePlushBehaviour kuriiePlushBehaviour = spawnPrefab.AddComponent<KuriiePlushBehaviour>();
((GrabbableObject)kuriiePlushBehaviour).grabbable = true;
((GrabbableObject)kuriiePlushBehaviour).grabbableToEnemies = true;
((GrabbableObject)kuriiePlushBehaviour).isInFactory = true;
((GrabbableObject)kuriiePlushBehaviour).itemProperties = val2;
val2.spawnPrefab = spawnPrefab;
allAssetNames = val.GetAllAssetNames();
foreach (string text2 in allAssetNames)
{
if (text2.ToLower().Contains("confetti") && (text2.EndsWith(".wav") || text2.EndsWith(".mp3") || text2.EndsWith(".ogg")))
{
AudioClip val4 = val.LoadAsset<AudioClip>(text2);
if ((Object)(object)val4 != (Object)null)
{
KuriiePlushBehaviour.confettiSound = val4;
break;
}
}
}
Utilities.FixMixerGroups(spawnPrefab);
NetworkPrefabs.RegisterNetworkPrefab(spawnPrefab);
Items.RegisterScrap(val2, 45, (LevelTypes)(-1));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Kuriie Plush mod loaded!");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "KuriiePlushMod";
public const string PLUGIN_NAME = "KuriiePlushMod";
public const string PLUGIN_VERSION = "1.0.0";
}
}