Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SnowGlobe v1.0.0
plugins/SnowGlobe/SnowGlobe.dll
Decompiled 14 hours agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using LethalLib.Modules; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 SnowGlobe { [BepInPlugin("CoddingCat.SnowGlobe", "Snow Globe", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class SnowGlobePlugin : BaseUnityPlugin { public const string Guid = "CoddingCat.SnowGlobe"; public const string Name = "Snow Globe"; public const string Version = "1.0.0"; private void Awake() { //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_027d: 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_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "snowglobe")); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Could not load the snowglobe asset bundle, the snow globe will not be added."); return; } Item val2 = val.LoadAsset<Item>("Assets/SnowGlobe/Items/SnowGlobe.asset"); SnowGlobeItem component = val2.spawnPrefab.GetComponent<SnowGlobeItem>(); ((GrabbableObject)component).useCooldown = Bind("Shaking", "CooldownSeconds", ((GrabbableObject)component).useCooldown, "Seconds you must wait between shakes. 0 for no cooldown.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 300f)); component.driftSeconds = Bind("Shaking", "DriftSeconds", component.driftSeconds, "How long, in seconds, the snow drifts toward the nearest scrap after a shake.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f)); component.shakeVolume = Bind("Chime", "Volume", component.shakeVolume, "Volume of the shake chime (1 = full).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f)); component.monsterHearingRange = Bind("Chime", "MonsterHearingRange", component.monsterHearingRange, "How far away (in meters) monsters can hear the chime. 0 makes it silent to monsters.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f)); component.monsterHearingLoudness = Bind("Chime", "MonsterHearingLoudness", component.monsterHearingLoudness, "How loud monsters perceive the chime (0 - 1). Higher values also get through the closed ship doors.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f)); component.melodyVolume = Bind("Chime", "MusicBoxVolume", component.melodyVolume, "Volume of the music box melody that plays after a shake. 0 disables it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f)); component.melodyAttractsMonsters = Bind("Chime", "MusicBoxAttractsMonsters", component.melodyAttractsMonsters, "While the melody plays, monsters in MonsterHearingRange keep hearing it (a pulse every few seconds)."); val2.minValue = Bind("Spawning", "MinValue", val2.minValue, "Lowest scrap value, before the game's scrap value multiplier (the scanner shows about 0.4 times this).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5000)); val2.maxValue = Mathf.Max(val2.minValue + 1, Bind("Spawning", "MaxValue", val2.maxValue, "Highest scrap value, before the game's scrap value multiplier (the scanner shows about 0.4 times this).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5000))); int num = Bind("Spawning", "Rarity", 12, "How common the snow globe is as scrap (relative spawn weight, like other scrap). 0 disables spawning. Needs a game restart.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200)); LevelTypes val3 = (LevelTypes)1; if (Bind("Spawning", "SpawnOnVanillaMoons", fallback: true, "Spawn as scrap on the vanilla moons. Needs a game restart.")) { val3 = (LevelTypes)(val3 | 0x3BFC); } if (Bind("Spawning", "SpawnOnModdedMoons", fallback: true, "Spawn as scrap on modded moons. Needs a game restart.")) { val3 = (LevelTypes)(val3 | 0x400); } NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab); Utilities.FixMixerGroups(val2.spawnPrefab); Items.RegisterScrap(val2, num, val3); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded (rarity {2}).", "Snow Globe", "1.0.0", num)); } private T Bind<T>(string section, string key, T fallback, string description, AcceptableValueBase range = null) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown return ((BaseUnityPlugin)this).Config.Bind<T>(section, key, fallback, new ConfigDescription(description, range, Array.Empty<object>())).Value; } } public class SnowGlobeItem : GrabbableObject { public ParticleSystem snow; public AudioSource shakeAudio; public int flakesPerShake = 300; public float driftSeconds = 5f; public float shakeVolume = 1f; public float monsterHearingRange = 30f; public AudioSource melodyAudio; public float melodyVolume = 0.15f; public bool melodyAttractsMonsters = true; public float driftForce = 0.1f; public float monsterHearingLoudness = 0.8f; public Transform visual; private float rattle; public override void EquipItem() { ((GrabbableObject)this).EquipItem(); snow.Emit(flakesPerShake / 5); } public override void OnHitGround() { ((GrabbableObject)this).OnHitGround(); snow.Emit(flakesPerShake / 4); } public override void EnableItemMeshes(bool enable) { ((GrabbableObject)this).EnableItemMeshes(enable); ((Renderer)((Component)snow).GetComponent<ParticleSystemRenderer>()).enabled = enable; } public override void LateUpdate() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) ((GrabbableObject)this).LateUpdate(); if (!(rattle <= 0f)) { rattle -= Time.deltaTime; float num = Mathf.Max(rattle, 0f) / 0.75f; visual.localRotation = Quaternion.Euler(Mathf.Sin(Time.time * 43f) * 16f * num, 0f, Mathf.Sin(Time.time * 37f) * 18f * num); } } public override void ItemActivate(bool used, bool buttonDown = true) { //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) ((GrabbableObject)this).ItemActivate(used, buttonDown); if (!buttonDown) { return; } shakeAudio.pitch = Random.Range(0.97f, 1.03f); shakeAudio.PlayOneShot(shakeAudio.clip, shakeVolume); WalkieTalkie.TransmitOneShotAudio(shakeAudio, shakeAudio.clip, shakeVolume); MakeNoise(monsterHearingLoudness); if (melodyVolume > 0f) { melodyAudio.Stop(); ((MonoBehaviour)this).CancelInvoke("PlayMelody"); ((MonoBehaviour)this).Invoke("PlayMelody", 1.25f); } snow.Emit(flakesPerShake); GrabbableObject val = null; float num = float.MaxValue; GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>(); Vector3 val3; foreach (GrabbableObject val2 in array) { if (!((Object)(object)val2 == (Object)(object)this) && !((Object)(object)val2.itemProperties == (Object)null) && val2.itemProperties.isScrap && !val2.isInShipRoom && !val2.isInElevator && !(val2 is RagdollGrabbableObject)) { val3 = ((Component)val2).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val = val2; } } } if ((Object)(object)val != (Object)null) { val3 = ((Component)val).transform.position - ((Component)this).transform.position; Vector3 val4 = ((Vector3)(ref val3)).normalized * driftForce; ForceOverLifetimeModule forceOverLifetime = snow.forceOverLifetime; ((ForceOverLifetimeModule)(ref forceOverLifetime)).x = MinMaxCurve.op_Implicit(val4.x); ((ForceOverLifetimeModule)(ref forceOverLifetime)).y = MinMaxCurve.op_Implicit(val4.y); ((ForceOverLifetimeModule)(ref forceOverLifetime)).z = MinMaxCurve.op_Implicit(val4.z); ((MonoBehaviour)this).CancelInvoke("StopDrift"); ((MonoBehaviour)this).Invoke("StopDrift", driftSeconds); } rattle = 0.75f; } private void StopDrift() { //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_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) //IL_0035: Unknown result type (might be due to invalid IL or missing references) ForceOverLifetimeModule forceOverLifetime = snow.forceOverLifetime; ((ForceOverLifetimeModule)(ref forceOverLifetime)).x = MinMaxCurve.op_Implicit(0f); ((ForceOverLifetimeModule)(ref forceOverLifetime)).y = MinMaxCurve.op_Implicit(0f); ((ForceOverLifetimeModule)(ref forceOverLifetime)).z = MinMaxCurve.op_Implicit(0f); } private void MakeNoise(float loudness) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!(monsterHearingRange <= 0f)) { bool flag = base.isInElevator && StartOfRound.Instance.hangarDoorsClosed; RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, monsterHearingRange, loudness, 0, flag, 0); } } private void PlayMelody() { melodyAudio.volume = melodyVolume; melodyAudio.Play(); WalkieTalkie.TransmitOneShotAudio(shakeAudio, melodyAudio.clip, melodyVolume); if (melodyAttractsMonsters) { ((MonoBehaviour)this).InvokeRepeating("MelodyNoise", 0f, 3f); } } private void MelodyNoise() { if (!melodyAudio.isPlaying) { ((MonoBehaviour)this).CancelInvoke("MelodyNoise"); } else { MakeNoise(monsterHearingLoudness * 0.75f); } } } }