Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of NewtsHalloween v3.2.10
plugins/viliger-TrickOrTreat/TrickOrTreat.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using On.RoR2; using R2API; using R2API.Networking; using R2API.Networking.Interfaces; using RoR2; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TrickOrTreat")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TrickOrTreat")] [assembly: AssemblyTitle("TrickOrTreat")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace RoR2_TrickOrTreat; public class CandyBucketInteractable { public class TrickOrTreatSoundMessage : INetMessage, ISerializableObject { private NetworkInstanceId netId; private string soundName; public TrickOrTreatSoundMessage() { } public TrickOrTreatSoundMessage(NetworkInstanceId netId, string soundName) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) this.netId = netId; this.soundName = soundName; } public void OnReceived() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { GameObject val = Util.FindNetworkObject(netId); if (Object.op_Implicit((Object)(object)val)) { Util.PlaySound(soundName, val); } } } public void Serialize(NetworkWriter writer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) writer.Write(netId); writer.Write(soundName); } public void Deserialize(NetworkReader reader) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) netId = reader.ReadNetworkId(); soundName = reader.ReadString(); } } public class CandyBucketInteractableManager : NetworkBehaviour { public GenericInteraction genericInteraction; private GameObject interactorObject; public void Start() { ((UnityEvent<Interactor>)(object)genericInteraction.onActivation).AddListener((UnityAction<Interactor>)OnActivation); } public void OnActivation(Interactor interactor) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if (NetworkServer.active) { interactorObject = ((Component)interactor).gameObject; CharacterBody val = default(CharacterBody); if (((Component)interactor).TryGetComponent<CharacterBody>(ref val)) { Chat.SendBroadcastChat((ChatMessageBase)new BodyChatMessage { bodyObject = ((Component)val).gameObject, token = "INTERACTABLE_CANDY_BUCKET_CHAT" }); } Util.PlaySound("viliger_TrickOrTreat", interactorObject); NetMessageExtensions.Send((INetMessage)(object)new TrickOrTreatSoundMessage(interactorObject.GetComponent<NetworkIdentity>().netId, "viliger_TrickOrTreat"), (NetworkDestination)1); ((MonoBehaviour)this).Invoke("TryYourLuck", 2f); genericInteraction.SetInteractabilityDisabled(); } } private void TryYourLuck() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: 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_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (Util.CheckRoll(60f, interactorObject.GetComponent<CharacterBody>().master)) { Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = "INTERACTABLE_CANDY_BUCKET_NEWT_TREAT" }); Util.PlaySound("viliger_Cheer", interactorObject); NetMessageExtensions.Send((INetMessage)(object)new TrickOrTreatSoundMessage(interactorObject.GetComponent<NetworkIdentity>().netId, "viliger_Cheer"), (NetworkDestination)1); DropItems(); return; } Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = "INTERACTABLE_CANDY_BUCKET_NEWT_TRICK" }); BlastAttack val = new BlastAttack { radius = 50f, procCoefficient = 0f, position = ((Component)this).gameObject.transform.position + 0.5f * ((Component)this).gameObject.transform.forward + Vector3.up * -0.25f, attacker = interactorObject, crit = false, baseDamage = 5000f, falloffModel = (FalloffModel)0, baseForce = 8000f }; val.teamIndex = TeamComponent.GetObjectTeam(val.attacker); val.damageType = DamageTypeCombo.op_Implicit((DamageType)2); val.attackerFiltering = (AttackerFiltering)0; val.Fire(); new BlastAttack { radius = 50f, procCoefficient = 0f, position = ((Component)this).gameObject.transform.position + 0.5f * ((Component)this).gameObject.transform.forward + Vector3.up * -0.25f, attacker = null, crit = false, baseDamage = 1f, falloffModel = (FalloffModel)2, baseForce = 8000f, teamIndex = (TeamIndex)0, damageType = DamageTypeCombo.op_Implicit((DamageType)2), attackerFiltering = (AttackerFiltering)0, canRejectForce = false }.Fire(); } private void DropItems() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) Xoroshiro128Plus rng = new Xoroshiro128Plus(Run.instance.treasureRng.nextUlong); int participatingPlayerCount = Run.instance.participatingPlayerCount; if (participatingPlayerCount != 0) { float num = 360f / (float)participatingPlayerCount; Vector3 val = Quaternion.AngleAxis((float)Random.Range(0, 360), Vector3.up) * (Vector3.up * 40f + Vector3.forward * 5f); Quaternion val2 = Quaternion.AngleAxis(num, Vector3.up); for (int i = 0; i < participatingPlayerCount; i++) { PickupDropletController.CreatePickupDroplet(GetPickupIndex(rng), new Vector3(-74.4528f, -24f, -27.9666f), val); val = val2 * val; } } } private PickupIndex GetPickupIndex(Xoroshiro128Plus rng) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) PickupIndex val = rng.NextElementUniform<PickupIndex>(Run.instance.availableTier1DropList); PickupIndex val2 = rng.NextElementUniform<PickupIndex>(Run.instance.availableTier2DropList); PickupIndex val3 = rng.NextElementUniform<PickupIndex>(Run.instance.availableTier3DropList); WeightedSelection<PickupIndex> obj = new WeightedSelection<PickupIndex>(8); obj.AddChoice(val, 60f); obj.AddChoice(val2, 35f); obj.AddChoice(val3, 5f); return obj.Evaluate(rng.nextNormalizedFloat); } } public static GameObject GetInteractable() { //IL_010c: Unknown result type (might be due to invalid IL or missing references) AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(TrickOrTreatPlugin.PInfo.Location), "Assets", "candybucket")); TrickOrTreatPlugin.ShaderConversion(obj); GameObject val = obj.LoadAsset<GameObject>("candybucket"); val.AddComponent<NetworkIdentity>(); GenericInteraction val2 = val.AddComponent<GenericInteraction>(); val2.contextToken = "INTERACTABLE_CANDY_BUCKET_CONTEXT"; val2.shouldShowOnScanner = false; val.AddComponent<GenericDisplayNameProvider>().displayToken = "INTERACTABLE_CANDY_BUCKET_NAME"; ModelLocator obj2 = val.AddComponent<ModelLocator>(); obj2.modelTransform = val.transform.Find("mdlCandyBucket"); obj2.modelBaseTransform = val.transform.Find("mdlCandyBucket"); obj2.dontDetatchFromParent = false; obj2.autoUpdateModelTransform = true; ((Component)val.GetComponentInChildren<MeshCollider>()).gameObject.AddComponent<EntityLocator>().entity = val; val.AddComponent<CandyBucketInteractableManager>().genericInteraction = val2; Highlight obj3 = val.AddComponent<Highlight>(); obj3.targetRenderer = (Renderer)(object)(from x in val.GetComponentsInChildren<MeshRenderer>() where ((Object)((Component)x).gameObject).name.Contains("mdlCandyBucket") select x).First(); obj3.strength = 1f; obj3.highlightColor = (HighlightColor)0; return val; } } public class TrickOrTreatLanguages { public const string LanguageFileName = "TrickOrTreat.language"; public const string LanguageFileFolder = "Languages"; public void Init(PluginInfo info) { LanguageAPI.AddPath(Path.Combine(Path.GetDirectoryName(info.Location), "Languages", "TrickOrTreat.language")); } } [BepInPlugin("com.Viliger.TrickOrTreat", "TrickOrTreat", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class TrickOrTreatPlugin : BaseUnityPlugin { public static PluginInfo PInfo; private GameObject candyBucketPrefab; public static ConfigEntry<bool> EnableAlways; public static Dictionary<string, string> ShaderLookup = new Dictionary<string, string> { { "Stubbed Hopoo Games/Deferred/Standard", "shaders/deferred/hgstandard" } }; private void Awake() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown EnableAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("Candy Bucket", "Always Enabled", false, "Enables Candy Bucket for entire year and not just October."); if (DateTime.Now.Month == 10 || EnableAlways.Value) { PInfo = ((BaseUnityPlugin)this).Info; LoadSoundBanks(); candyBucketPrefab = PrefabAPI.InstantiateClone(CandyBucketInteractable.GetInteractable(), "CandyBucketInteractable"); new TrickOrTreatLanguages().Init(PInfo); BazaarController.Awake += new hook_Awake(BazaarController_Awake); NetworkingAPI.RegisterMessageType<CandyBucketInteractable.TrickOrTreatSoundMessage>(); } } private void LoadSoundBanks() { using FileStream fileStream = new FileStream(Path.Combine(Path.GetDirectoryName(PInfo.Location), "Soundbanks", "TrickOrTreat.bnk"), FileMode.Open, FileAccess.Read); byte[] array = new byte[fileStream.Length]; fileStream.Read(array, 0, array.Length); SoundBanks.Add(array); } private void BazaarController_Awake(orig_Awake orig, BazaarController self) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active) { GameObject obj = Object.Instantiate<GameObject>(candyBucketPrefab, new Vector3(-74.4528f, -25f, -27.9666f), Quaternion.identity); obj.transform.eulerAngles = new Vector3(0f, 270f, 0f); NetworkServer.Spawn(obj); orig.Invoke(self); } } public static void ShaderConversion(AssetBundle assets) { foreach (Material item in from material in assets.LoadAllAssets<Material>() where ((Object)material.shader).name.StartsWith("Stubbed Hopoo Games") select material) { Shader val = LegacyResourcesAPI.Load<Shader>(ShaderLookup[((Object)item.shader).name]); if (Object.op_Implicit((Object)(object)val)) { item.shader = val; } } } }