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 serek items v2.0.3
serek.dll
Decompiled 2 months agousing 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 BepInEx.Logging; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Netcode; 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("serek")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("serek")] [assembly: AssemblyTitle("serek")] [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 serekRafek { [BepInPlugin("serekRafek.plugin", "serekRafek", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private struct ItemDefinition { public string ItemScriptName; public string PrefabName; public string DisplayName; public int Rarity; } private const string PLUGIN_GUID = "serekRafek.plugin"; private const string PLUGIN_NAME = "serekRafek"; private const string PLUGIN_VERSION = "1.0.0"; private const string ASSET_BUNDLE_FILENAME = "serekScrap"; public static Plugin instance; internal static ManualLogSource mls = Logger.CreateLogSource("serekRafek.plugin"); private readonly ItemDefinition[] itemDefinitions = new ItemDefinition[19] { new ItemDefinition { ItemScriptName = "assets/serek/SerekItem.asset", PrefabName = "assets/serek/serekscrap.prefab", DisplayName = "Sereček Ráfeček", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/MalboroItem.asset", PrefabName = "assets/serek/Malboro.prefab", DisplayName = "Cíčka", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/ZangetsuItem.asset", PrefabName = "assets/serek/Zangetsu.prefab", DisplayName = "Zangetsu", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/BongItem.asset", PrefabName = "assets/serek/Bong.prefab", DisplayName = "BONG", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/MoneyItem.asset", PrefabName = "assets/serek/Money.prefab", DisplayName = "Židovské peníz", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/JointItem.asset", PrefabName = "assets/serek/Joint.prefab", DisplayName = "Tučný brko", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/MerakItem.asset", PrefabName = "assets/serek/Merak.prefab", DisplayName = "Měřák", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/TwingoItem.asset", PrefabName = "assets/serek/Twingo.prefab", DisplayName = "Twingo", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/TGVItem.asset", PrefabName = "assets/serek/TGV.prefab", DisplayName = "TGV", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/SpagetyItem.asset", PrefabName = "assets/serek/Spagety.prefab", DisplayName = "Adam Špageťák", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/PhaetonItem.asset", PrefabName = "assets/serek/phaeton.prefab", DisplayName = "Phaeton", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/MeowlItem.asset", PrefabName = "assets/serek/meowl.prefab", DisplayName = "Meowl", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/PeugeotItem.asset", PrefabName = "assets/serek/Peugeot.prefab", DisplayName = "Pžot", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/T3.asset", PrefabName = "assets/serek/T3.prefab", DisplayName = "T3", Rarity = 90 }, new ItemDefinition { ItemScriptName = "assets/serek/SkodaItem.asset", PrefabName = "assets/serek/Skoda.prefab", DisplayName = "Škoda WRC", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/KafickoItem.asset", PrefabName = "assets/serek/kaficko.prefab", DisplayName = "Kafíčko", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/MrdnaItem.asset", PrefabName = "assets/serek/mrdna.prefab", DisplayName = "Mrdna S.R.O.", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/YarisItem.asset", PrefabName = "assets/serek/yaris.prefab", DisplayName = "Yaris", Rarity = 80 }, new ItemDefinition { ItemScriptName = "assets/serek/JobItem.asset", PrefabName = "assets/serek/Job.prefab", DisplayName = "Žádost o práci", Rarity = 80 } }; private void Awake() { instance = this; string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "serekScrap"); AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { mls.LogError((object)("[ERROR] Failed to load AssetBundle from path: " + text + ". Check that the file exists next to your DLL.")); return; } mls.LogInfo((object)"AssetBundle loaded successfully."); ItemDefinition[] array = itemDefinitions; foreach (ItemDefinition definition in array) { RegisterCustomScrap(val, definition); } Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "serekRafek.plugin"); mls.LogInfo((object)"!!!!!!ALL CUSTOM SCRAP LOADED AND REGISTERED!!!!!!!"); } private void RegisterCustomScrap(AssetBundle bundle, ItemDefinition definition) { Item val = bundle.LoadAsset<Item>(definition.ItemScriptName); if ((Object)(object)val == (Object)null) { mls.LogError((object)("[ERROR] Failed to load Item ScriptableObject: " + definition.ItemScriptName + ". Skipping registration for this item.")); return; } GameObject val2 = bundle.LoadAsset<GameObject>(definition.PrefabName); if ((Object)(object)val2 == (Object)null) { mls.LogError((object)("[ERROR] Failed to load GameObject Prefab: " + definition.PrefabName + ". Skipping registration for this item.")); return; } val.spawnPrefab = val2; val.itemName = definition.DisplayName; val.isScrap = true; if ((Object)(object)val.spawnPrefab.GetComponent<GrabbableObject>() == (Object)null) { mls.LogError((object)("[ERROR] Prefab for '" + definition.DisplayName + "' is missing a GrabbableObject component. REQUIRED for scrap.")); return; } Utilities.FixMixerGroups(val.spawnPrefab); Items.RegisterScrap(val, definition.Rarity, (LevelTypes)(-1)); NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); mls.LogInfo((object)$"[SUCCESS] Registered item: {val.itemName} (Worth: {val.minValue} - {val.maxValue}, Rarity: {definition.Rarity})"); } } public class SmokeableJoint : GrabbableObject { [CompilerGenerated] private sealed class <SmokeRoutine>d__16 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SmokeableJoint <>4__this; private float <timer>5__1; private Vector3 <spawnPosition>5__2; private GameObject <smoke>5__3; private float <currentDrunk>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SmokeRoutine>d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <smoke>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0273: 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_0282: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this.currentCooldown = <>4__this.cooldownTime; if ((Object)(object)((GrabbableObject)<>4__this).playerHeldBy != (Object)null) { ((GrabbableObject)<>4__this).playerHeldBy.activatingItem = true; ((GrabbableObject)<>4__this).playerHeldBy.playerBodyAnimator.SetBool("HoldMask", true); } if ((Object)(object)<>4__this.inhaleSFX != (Object)null && (Object)(object)<>4__this.audioSource != (Object)null) { <>4__this.audioSource.PlayOneShot(<>4__this.inhaleSFX); } <timer>5__1 = 0f; break; case 1: <>1__state = -1; break; } if (<timer>5__1 < 1.2f) { <timer>5__1 += Time.deltaTime; if (((GrabbableObject)<>4__this).isPocketed || !((GrabbableObject)<>4__this).isHeld || (Object)(object)((GrabbableObject)<>4__this).playerHeldBy == (Object)null) { <>4__this.StopSmoking(); return false; } <>2__current = null; <>1__state = 1; return true; } if ((Object)(object)((GrabbableObject)<>4__this).playerHeldBy != (Object)null) { ((GrabbableObject)<>4__this).playerHeldBy.playerBodyAnimator.SetBool("HoldMask", false); ((GrabbableObject)<>4__this).playerHeldBy.activatingItem = false; } if ((Object)(object)<>4__this.exhaleSFX != (Object)null && (Object)(object)<>4__this.audioSource != (Object)null) { <>4__this.audioSource.PlayOneShot(<>4__this.exhaleSFX); } if ((Object)(object)<>4__this.smokeParticlePrefab != (Object)null) { if ((Object)(object)((GrabbableObject)<>4__this).playerHeldBy != (Object)null && ((NetworkBehaviour)((GrabbableObject)<>4__this).playerHeldBy).IsOwner && (Object)(object)((GrabbableObject)<>4__this).playerHeldBy.gameplayCamera != (Object)null) { <spawnPosition>5__2 = ((Component)((GrabbableObject)<>4__this).playerHeldBy.gameplayCamera).transform.position + ((Component)((GrabbableObject)<>4__this).playerHeldBy.gameplayCamera).transform.forward * 0.5f + ((Component)((GrabbableObject)<>4__this).playerHeldBy.gameplayCamera).transform.up * -0.2f; } else { <spawnPosition>5__2 = ((Component)<>4__this).transform.position + ((Component)<>4__this).transform.up * 0.15f; } <smoke>5__3 = Object.Instantiate<GameObject>(<>4__this.smokeParticlePrefab, <spawnPosition>5__2, Quaternion.identity); Object.Destroy((Object)(object)<smoke>5__3, 5f); <smoke>5__3 = null; } if ((Object)(object)((GrabbableObject)<>4__this).playerHeldBy != (Object)null && ((NetworkBehaviour)((GrabbableObject)<>4__this).playerHeldBy).IsOwner) { <currentDrunk>5__4 = ((GrabbableObject)<>4__this).playerHeldBy.drunkness; ((GrabbableObject)<>4__this).playerHeldBy.drunkness = Mathf.Clamp(<currentDrunk>5__4 + 0.2f, 0f, 5f); if (((GrabbableObject)<>4__this).playerHeldBy.insanityLevel > 0f) { ((GrabbableObject)<>4__this).playerHeldBy.insanityLevel = Mathf.Max(((GrabbableObject)<>4__this).playerHeldBy.insanityLevel - 15f, 0f); } <>4__this.puffsRemaining--; } 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(); } } [Header("Joint Settings")] public int puffsRemaining = 1000; public float cooldownTime = 2.5f; [Header("Effects")] public GameObject smokeParticlePrefab; public AudioClip inhaleSFX; public AudioClip exhaleSFX; private float currentCooldown = 0f; private AudioSource audioSource; private Coroutine smokeCoroutine; public override void Start() { ((GrabbableObject)this).Start(); audioSource = ((Component)this).GetComponent<AudioSource>(); if ((Object)(object)audioSource == (Object)null) { Debug.LogError((object)"SmokeableJoint: No AudioSource found on this object!"); } puffsRemaining = Random.Range(3, 6); } public override void Update() { ((GrabbableObject)this).Update(); if (currentCooldown > 0f) { currentCooldown -= Time.deltaTime; } if (base.isPocketed && (Object)(object)base.playerHeldBy != (Object)null) { if (base.playerHeldBy.activatingItem) { base.playerHeldBy.activatingItem = false; } base.playerHeldBy.playerBodyAnimator.SetBool("HoldMask", false); } } public override void ItemActivate(bool used, bool buttonDown = true) { ((GrabbableObject)this).ItemActivate(used, buttonDown); if (buttonDown && !(currentCooldown > 0f) && puffsRemaining > 0 && !((Object)(object)base.playerHeldBy == (Object)null) && !base.isPocketed) { if (smokeCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(smokeCoroutine); } smokeCoroutine = ((MonoBehaviour)this).StartCoroutine(SmokeRoutine()); SmokeServerRpc(); } } public override void PocketItem() { StopSmoking(); ((GrabbableObject)this).PocketItem(); } public override void DiscardItem() { StopSmoking(); ((GrabbableObject)this).DiscardItem(); } private void StopSmoking() { if (smokeCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(smokeCoroutine); smokeCoroutine = null; } if ((Object)(object)base.playerHeldBy != (Object)null) { base.playerHeldBy.playerBodyAnimator.SetBool("HoldMask", false); base.playerHeldBy.activatingItem = false; } } [ServerRpc(RequireOwnership = false)] public void SmokeServerRpc() { SmokeClientRpc(); } [ClientRpc] public void SmokeClientRpc() { if ((Object)(object)base.playerHeldBy != (Object)null && !((NetworkBehaviour)base.playerHeldBy).IsOwner) { if (smokeCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(smokeCoroutine); } smokeCoroutine = ((MonoBehaviour)this).StartCoroutine(SmokeRoutine()); } } [IteratorStateMachine(typeof(<SmokeRoutine>d__16))] private IEnumerator SmokeRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SmokeRoutine>d__16(0) { <>4__this = this }; } } }