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 RandomEvents v2.0.0
RandomEvents.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.Barrel; using EntityStates.Captain.Weapon; using EntityStates.CaptainSupplyDrop; using EntityStates.Drone; using EntityStates.FalseSonBoss; using EntityStates.GoldGat; using EntityStates.InfiniteTowerSafeWard; using EntityStates.JellyfishMonster; using EntityStates.Mimic.Chest; using EntityStates.Missions.Arena.NullWard; using EntityStates.Poltergeist; using EntityStates.Providence; using EntityStates.QuestVolatileBattery; using EntityStates.SolusMine; using EntityStates.SprintDamage; using EntityStates.Turret1; using HG; using HG.Reflection; using IL.RoR2; using IL.RoR2.CharacterAI; using InLobbyConfig; using InLobbyConfig.Fields; using ItemStringParser; using KinematicCharacterController; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; using MonoMod.Cil; using On.EntityStates; using On.EntityStates.Drone; using On.EntityStates.GoldGat; using On.EntityStates.InfiniteTowerSafeWard; using On.EntityStates.JellyfishMonster; using On.EntityStates.Mimic.Chest; using On.EntityStates.Poltergeist; using On.EntityStates.Providence; using On.EntityStates.QuestVolatileBattery; using On.EntityStates.Turret1; using On.RoR2; using On.RoR2.Artifacts; using On.RoR2.CharacterAI; using On.RoR2.Items; using On.RoR2.Orbs; using On.RoR2.Projectile; using PerClientSync; using R2API.Utils; using RoR2; using RoR2.Artifacts; using RoR2.AsyncManagement; using RoR2.Audio; using RoR2.CharacterAI; using RoR2.ExpansionManagement; using RoR2.Items; using RoR2.Navigation; using RoR2.Networking; using RoR2.Orbs; using RoR2.Projectile; using RoR2.Skills; using ShareSuite; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RandomEvents")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9632537e139290d773852d6304457ac5a434e76c")] [assembly: AssemblyProduct("RandomEvents")] [assembly: AssemblyTitle("RandomEvents")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 RandomEvents { [Flags] public enum EventTags { None = 0, OnlyAffectsMonsters = 1, ChangesMonsterSpawns = 2, PicksOwnMonsterKinds = 4, SpawnsExtraMonsters = 8, ChangesMonsterSize = 0x10, ChangesMonsterAttackSpeed = 0x20, ChangesMonsterDamageTaken = 0x40, ChangesMonsterHealth = 0x80, ReliesOnGivenItems = 0x100, ReplacesEquipment = 0x200, SwapsEquipmentOnUse = 0x400, DrainsPlayerHealth = 0x800, SwapsOrSharesItems = 0x1000, ChangesPlayerBody = 0x2000, ChangesPlayerSkills = 0x4000, MarksPlayers = 0x8000, RevivesPlayers = 0x10000, ChangesPlayerDamage = 0x20000, HidesPlayers = 0x40000, AffectsPlayerMovement = 0x80000, ChangesMonsterTargets = 0x100000, PicksEquipment = 0x200000, PlayerVersusPlayer = 0x400000, SwapsMonsterProjectiles = 0x800000, MonstersExplode = 0x1000000, MakesMonstersElite = 0x2000000 } public abstract class AbstractEvent { public ConfigEntry<bool> Enabled; public ConfigEntry<float> Weight; public int Id; public virtual bool SuppressesHereticTransformation => false; public virtual bool KeepsOwnTime => false; public virtual EventTags Tags => EventTags.None; public virtual EventTags ExcludedTags => EventTags.None; protected virtual float DefaultWeight => 1f; public bool IsCompatibleWith(AbstractEvent other) { return (ExcludedTags & other.Tags) == 0; } public abstract string GetEventConfigName(); public abstract string GetAnnouncement(); public void SetupConfig(ConfigFile config, List<AbstractEvent> allEvents) { string text = ""; string fullConditionDescription = GetFullConditionDescription(allEvents); if (!Utility.IsNullOrWhiteSpace(fullConditionDescription)) { text = text + "\nCondition: " + fullConditionDescription; } Enabled = config.Bind<bool>(GetEventConfigName(), "SectionEnabled", true, "Enable " + GetEventConfigName() + ": " + GetDescription() + text); Weight = config.Bind<float>(GetEventConfigName(), "Weight", DefaultWeight, "Weight for the event."); AddConfig(config); } protected abstract void AddConfig(ConfigFile config); public float GetWeight() { return Weight.Value; } public bool IsEnabled() { return Enabled.Value; } public bool IsActive() { return RandomEvents.instance.m_activeEvents.Contains(this); } public virtual bool LoadCondition() { return true; } public abstract bool Condition(List<AbstractEvent> activeOtherEvents); public abstract void Preload(); public abstract void Prepare(); public abstract void Start(List<AbstractEvent> activeOtherEvents); public abstract void Stop(); public abstract void Hook(); public abstract string GetDescription(); public virtual string GetPopupDescription() { return GetDescription(); } public abstract string GetConditionDescription(); public List<string> GetConditions() { string conditionDescription = GetConditionDescription(); if (Utility.IsNullOrWhiteSpace(conditionDescription)) { return new List<string>(); } return (from condition in conditionDescription.Split(new string[1] { ". " }, StringSplitOptions.RemoveEmptyEntries) select condition.TrimEnd('.') + ".").ToList(); } public string GetFullConditionDescription(List<AbstractEvent> allEvents) { List<string> conditions = GetConditions(); bool noMonsterEvents = (ExcludedTags & EventTags.OnlyAffectsMonsters) != 0; if (noMonsterEvents) { conditions.Add("No event about monsters alone."); } List<string> list = (from other in allEvents where other != this && (!IsCompatibleWith(other) || !other.IsCompatibleWith(this)) where !noMonsterEvents || (other.Tags & EventTags.OnlyAffectsMonsters) == 0 select "\"" + other.GetEventConfigName() + "\"").ToList(); if (list.Count > 0) { conditions.Add(((list.Count == 1) ? "Event " : "Events ") + JoinWithAnd(list) + " inactive."); } return string.Join(" ", conditions); } private static string JoinWithAnd(List<string> words) { if (words.Count != 1) { return string.Join(", ", words.Take(words.Count - 1)) + " and " + words.Last(); } return words[0]; } } public class BuffTracker { private readonly List<(CharacterBody body, BuffDef buff)> added = new List<(CharacterBody, BuffDef)>(); public void Add(CharacterBody body, BuffDef buff) { body.AddBuff(buff); added.Add((body, buff)); } public bool Has(CharacterBody body, BuffDef buff) { return added.Contains((body, buff)); } public void Remove(CharacterBody body, BuffDef buff) { if (added.Remove((body, buff)) && Object.op_Implicit((Object)(object)body)) { body.RemoveBuff(buff); } } public void Remove(CharacterBody body) { foreach (var item2 in added.Where(((CharacterBody body, BuffDef buff) entry) => (Object)(object)entry.body == (Object)(object)body).ToList()) { BuffDef item = item2.buff; Remove(body, item); } } public void RemoveAll() { foreach (var (val, val2) in added) { if (Object.op_Implicit((Object)(object)val)) { val.RemoveBuff(val2); } } added.Clear(); } } internal class ChatHelper { private static Random rand = new Random(); private const string GrayColor = "7e91af"; private const string RedColor = "ed4c40"; private const string LunarColor = "5cb1ed"; private const short ChatMessageType = 59; private static int popupCount; private static string GetPlayerColor(PlayerCharacterMasterController pc) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_005f: Unknown result type (might be due to invalid IL or missing references) pc.GetDisplayName(); SurvivorDef val = SurvivorCatalog.FindSurvivorDefFromBody(pc.master?.bodyPrefab); if ((Object)(object)val != (Object)null) { _ = val.primaryColor; return ColorUtility.ToHtmlStringRGB(val.primaryColor); } CharacterMaster master = pc.master; CharacterBody val2 = ((master != null) ? master.GetBody() : null); if ((Object)(object)val2 != (Object)null) { _ = val2.bodyColor; return ColorUtility.ToHtmlStringRGB(val2.bodyColor); } return "f27b0c"; } private static string GetColoredPlayerName(PlayerCharacterMasterController playerCharacterMasterController) { string playerColor = GetPlayerColor(playerCharacterMasterController); CharacterBody body = playerCharacterMasterController.master.GetBody(); return "<color=#" + playerColor + ">" + body.GetUserName() + "</color>"; } public static string GetColoredPlayerName(CharacterBody body) { PlayerCharacterMasterController val = (((Object)(object)body.master != (Object)null) ? body.master.playerCharacterMasterController : null); if ((Object)(object)val == (Object)null) { return body.GetDisplayName(); } return "<color=#" + GetPlayerColor(val) + ">" + body.GetUserName() + "</color>"; } public static void SendEventMessage(string token, params object[] args) { Send("<style=cEvent>" + Language.GetStringFormatted(token, args) + "</style>"); } public static void LunarShopTerminalUsesLeft(PlayerCharacterMasterController playerCharacterMasterController, int usesLeft) { string coloredPlayerName = GetColoredPlayerName(playerCharacterMasterController); if (usesLeft > 1) { Send(string.Format("{0} <color=#{1}>can use a shop terminal</color> <color=#{2}>{3}</color> <color=#{4}>more times.</color>", coloredPlayerName, "7e91af", "ed4c40", usesLeft, "7e91af")); } else if (usesLeft == 1) { Send(string.Format("{0} <color=#{1}>can use a shop terminal</color> <color=#{2}>{3}</color> <color=#{4}>more time.</color>", coloredPlayerName, "7e91af", "ed4c40", usesLeft, "7e91af")); } else { Send(coloredPlayerName + " <color=#7e91af>can no longer use shop terminals.</color>"); } } public static void LunarRecyclerUsesLeft(int usesLeft) { if (usesLeft > 1) { Send(string.Format("The <color=#{0}>Lunar Recycler</color> <color=#{1}>can be used</color> <color=#{2}>{3}</color> <color=#{4}>more times.</color>", "5cb1ed", "7e91af", "ed4c40", usesLeft, "7e91af")); } else if (usesLeft == 1) { Send(string.Format("The <color=#{0}>Lunar Recycler</color> <color=#{1}>can be used</color> <color=#{2}>{3}</color> <color=#{4}>more time.</color>", "5cb1ed", "7e91af", "ed4c40", usesLeft, "7e91af")); } else { Send("The <color=#5cb1ed>Lunar Recycler</color> <color=#7e91af>can no longer be used.</color>"); } } public static string GetItemNames(PickupIndex[] pickupIndexes) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Invalid comparison between Unknown and I4 //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Invalid comparison between Unknown and I4 //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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) Dictionary<PickupIndex, int> dictionary = (from x in pickupIndexes group x by x).ToDictionary((IGrouping<PickupIndex, PickupIndex> g) => g.Key, (IGrouping<PickupIndex, PickupIndex> g) => g.Count()); List<string> list = new List<string>(); foreach (KeyValuePair<PickupIndex, int> item in dictionary) { PickupIndex key = item.Key; int value = item.Value; PickupDef pickupDef = PickupCatalog.GetPickupDef(key); string text = pickupDef.internalName; ColorIndex val = (ColorIndex)14; if ((int)pickupDef.itemIndex != -1) { ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); text = Language.GetString(itemDef.nameToken); val = ItemTierCatalog.GetItemTierDef(itemDef.tier).colorIndex; } else if ((int)pickupDef.equipmentIndex != -1) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex); text = Language.GetString(equipmentDef.nameToken); val = equipmentDef.colorIndex; } string colorHexString = ColorCatalog.GetColorHexString(val); if (value > 1) { list.Add($"<color=#{colorHexString}>{text}</color> x {value}"); continue; } list.Add("<color=#" + colorHexString + ">" + text + "</color>"); } return string.Join(", ", list); } public static void AnnounceEvent(string sound) { int maxValue = 10; int num = rand.Next(maxValue); string stringFormatted = Language.GetStringFormatted($"ANNOUNCE_EVENT_{num}", Array.Empty<object>()); SendWithSound("<size=18px><style=cEvent>" + stringFormatted + "</style></size>", sound); } public static void AnnounceDoubleEvent(string sound) { int maxValue = 5; int num = rand.Next(maxValue); string stringFormatted = Language.GetStringFormatted($"ANNOUNCE_DOUBLE_EVENT_{num}", Array.Empty<object>()); SendWithSound("<size=22px><style=cEvent>" + stringFormatted + "</style></size>", sound); } public static void AnnounceTripleEvent(string sound) { int maxValue = 3; int num = rand.Next(maxValue); string stringFormatted = Language.GetStringFormatted($"ANNOUNCE_TRIPLE_EVENT_{num}", Array.Empty<object>()); SendWithSound("<size=26px><style=cEvent>" + stringFormatted + "</style></size>", sound); } public static void AnnounceEventConclusion() { int maxValue = 12; int num = rand.Next(maxValue); string stringFormatted = Language.GetStringFormatted($"ANNOUNCE_EVENT_CONCLUDE_{num}", Array.Empty<object>()); Send("<size=18px><style=cEvent>" + stringFormatted + "</style></size>"); } public static void SendToken(string token) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = Language.GetStringFormatted(token, Array.Empty<object>()) }); } public static void Send(string message) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = message }); } public static void SendWithSound(string message, string sound) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown List<CharacterBody> livingPlayerBodies = Helper.GetLivingPlayerBodies(); foreach (NetworkConnection connection in NetworkServer.connections) { if (connection != null) { NetworkUser val = ((IEnumerable<NetworkUser>)NetworkUser.readOnlyInstancesList).FirstOrDefault((Func<NetworkUser, bool>)((NetworkUser networkUser) => ((NetworkBehaviour)networkUser).connectionToClient == connection)); CharacterBody val2 = (((Object)(object)val != (Object)null && (Object)(object)val.master != (Object)null) ? val.master.GetBody() : null); if (((Object)(object)val2 == (Object)null || !val2.healthComponent.alive) && livingPlayerBodies.Count > 0) { val2 = livingPlayerBodies[0]; } NpcChatMessage val3 = new NpcChatMessage { sender = (((Object)(object)val2 != (Object)null) ? ((Component)val2).gameObject : null), baseToken = message, formatStringToken = "{0}", sound = sound }; NetworkWriter val4 = new NetworkWriter(); val4.StartMessage((short)59); val4.Write(((ChatMessageBase)val3).GetTypeIndex()); val4.Write((MessageBase)(object)val3); val4.FinishMessage(); connection.SendWriter(val4, QosChannelIndex.chat.intVal); } } } public static void SendPopup(string title, string description) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) EquipmentDef val = ((popupCount++ % 2 == 0) ? Equipment.EliteGoldEquipment : Equipment.EliteYellowEquipment); if ((Object)(object)val == (Object)null || (int)val.equipmentIndex == -1) { return; } CustomOverrideInfo val2 = new CustomOverrideInfo { titleText = title, descriptionText = description, iconColor = new Color(1f, 1f, 0f) }; foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if ((Object)(object)instance.master != (Object)null) { CharacterMasterNotificationQueue.SendCustomNotification(instance.master, val.equipmentIndex, val2); } } } } internal static class DebugToolkitAutoComplete { private const string Guid = "iHarbHD.DebugToolkit"; internal static void Register(IEnumerable<AbstractEvent> events) { if (!Chainloader.PluginInfos.TryGetValue("iHarbHD.DebugToolkit", out var value) || (Object)(object)value.Instance == (Object)null) { return; } try { Assembly assembly = ((object)value.Instance).GetType().Assembly; Type type = assembly.GetType("DebugToolkit.AutoCompleteParser", throwOnError: true); Type attributeType = assembly.GetType("DebugToolkit.AutoCompleteAttribute", throwOnError: true); Type type2 = assembly.GetType("DebugToolkit.AutoCompleteManager", throwOnError: true); object parser = Activator.CreateInstance(type); type.GetMethod("RegisterStaticVariable", new Type[3] { typeof(string), typeof(IEnumerable<string>), typeof(int) }).Invoke(parser, new object[3] { "random_event", events.Select((AbstractEvent ev) => $"{ev.Id}|{ev.GetEventConfigName()}").ToList(), 1 }); MethodInfo parse = attributeType.GetMethod("Parse", BindingFlags.Instance | BindingFlags.NonPublic); MethodInfo registerCommand = type2.GetMethod("RegisterCommand", BindingFlags.Static | BindingFlags.NonPublic); RegisterCommand("start_event", "Requires 1 argument: {random_event}"); RegisterCommand("queue_event", "Requires 1 argument: {random_event}"); RegisterCommand("stop_event", "Requires 1 argument: {(random_event|'all')}"); void RegisterCommand(string command, string signature) { object obj = parse.Invoke(Activator.CreateInstance(attributeType, signature), new object[1] { parser }); registerCommand.Invoke(null, new object[2] { command, obj }); } } catch (Exception arg) { Log.LogWarning($"Could not add the event commands to DebugToolkit's autocompletion: {arg}"); } } } public class EventBlightedCorpses : AbstractEvent { private class Corpse { public CharacterBody body; public Vector3 position; public float radius; public float damage; public GameObject pool; } private const float TickInterval = 1f; private const float BlightDuration = 5f; private const float MinCorpseShare = 1f / 3f; private const float Radius = 6f; private const int MaxStacksPerSecond = 3; private const int MaxCorpses = 40; private const float DamageMultiplier = 0.2f; private AsyncOperationHandle<GameObject> AcidPool; private readonly List<Corpse> corpses = new List<Corpse>(); private readonly HashSet<CharacterBody> released = new HashSet<CharacterBody>(); private float tickTimer; public override EventTags Tags => EventTags.OnlyAffectsMonsters | EventTags.ChangesMonsterSpawns; public override EventTags ExcludedTags => EventTags.ChangesMonsterSpawns; public override bool LoadCondition() { return true; } public override bool Condition(List<AbstractEvent> activeOtherEvents) { return MonsterTraits.WeightShare(MonsterPool.GetChoices(), MonsterTraits.LeavesCorpse) >= 1f / 3f; } public override string GetEventConfigName() { return "BlightedCorpses"; } public override string GetAnnouncement() { return Language.GetStringFormatted("ANNOUNCE_EVENT_BLIGHTED_CORPSES", Array.Empty<object>()); } public override string GetDescription() { return "Only monsters that leave a corpse spawn. Their corpses lie in pools of acid, and being near them blights players."; } public override string GetPopupDescription() { return "Monster corpses lie in pools of acid. Keep away from them!"; } public override string GetConditionDescription() { return "At least a third of the stage's monsters leave a corpse."; } protected override void AddConfig(ConfigFile config) { } public override void Preload() { //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) AcidPool = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/BeetleQueen/BeetleQueenAcid.prefab"); } public override void Hook() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown GlobalEventManager.onCharacterDeathGlobal += GlobalEventManager_onCharacterDeathGlobal; GenericCharacterDeath.DestroyBodyAsapServer += new hook_DestroyBodyAsapServer(GenericCharacterDeath_DestroyBodyAsapServer); RoR2Application.onFixedUpdate += RoR2Application_onFixedUpdate; } private void GlobalEventManager_onCharacterDeathGlobal(DamageReport report) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 //IL_005f: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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) CharacterBody body = report.victimBody; RaycastHit hit = default(RaycastHit); if (ModConfig.Enabled.Value && NetworkServer.active && IsActive() && !((Object)(object)body == (Object)null) && (int)body.teamComponent.teamIndex != 1 && (int)body.teamComponent.teamIndex != 0 && !corpses.Any((Corpse corpse) => (Object)(object)corpse.body == (Object)(object)body) && Physics.Raycast(body.corePosition, Vector3.down, ref hit, 20f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1)) { corpses.Add(new Corpse { body = body, position = ((RaycastHit)(ref hit)).point, radius = body.radius, damage = body.damage, pool = SpawnPool(hit, body.teamComponent.teamIndex) }); while (corpses.Count > Mathf.Max(0, 40)) { Remove(corpses[0]); corpses.RemoveAt(0); } } } private GameObject SpawnPool(RaycastHit hit, TeamIndex teamIndex) { //IL_0000: 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) //IL_000c: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Util.QuaternionSafeLookRotation(Vector3.ProjectOnPlane(Vector3.forward, ((RaycastHit)(ref hit)).normal), ((RaycastHit)(ref hit)).normal); GameObject obj = Object.Instantiate<GameObject>(AcidPool.WaitForCompletion(), ((RaycastHit)(ref hit)).point, val); ProjectileDotZone val2 = default(ProjectileDotZone); if (obj.TryGetComponent<ProjectileDotZone>(ref val2)) { ((Behaviour)val2).enabled = false; } ProjectileDamage val3 = default(ProjectileDamage); if (obj.TryGetComponent<ProjectileDamage>(ref val3)) { val3.damage = 0f; } TeamFilter val4 = default(TeamFilter); if (obj.TryGetComponent<TeamFilter>(ref val4)) { val4.teamIndex = teamIndex; } NetworkServer.Spawn(obj); return obj; } private void Remove(Corpse corpse) { if ((Object)(object)corpse.body != (Object)null) { released.Add(corpse.body); } if ((Object)(object)corpse.pool != (Object)null) { Object.Destroy((Object)(object)corpse.pool); } } private void GenericCharacterDeath_DestroyBodyAsapServer(orig_DestroyBodyAsapServer orig, GenericCharacterDeath self) { CharacterBody body = ((EntityState)self).characterBody; if (!ModConfig.Enabled.Value || !NetworkServer.active || !IsActive() || (Object)(object)body == (Object)null || self.isPlayerDeath || self.isVoidDeath || self.destroyModelOnDeath || (Object)(object)self.cachedModelTransform == (Object)null || self.fallingStopwatch >= GenericCharacterDeath.maxFallDuration || released.Contains(body) || !corpses.Any((Corpse corpse) => (Object)(object)corpse.body == (Object)(object)body)) { orig.Invoke(self); } } private void RoR2Application_onFixedUpdate() { if (!ModConfig.Enabled.Value || !NetworkServer.active || !IsActive()) { return; } tickTimer -= Time.fixedDeltaTime; if (tickTimer > 0f) { return; } tickTimer = 1f; released.RemoveWhere((CharacterBody body) => (Object)(object)body == (Object)null); float radius = Mathf.Max(0f, 6f); foreach (CharacterBody player in Helper.GetLivingPlayerBodies()) { foreach (Corpse item in corpses.Where(delegate(Corpse corpse) { //IL_0001: 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_0016: Unknown result type (might be due to invalid IL or missing references) Vector3 val = corpse.position - player.footPosition; return ((Vector3)(ref val)).sqrMagnitude <= (radius + corpse.radius) * (radius + corpse.radius); }).Take(Mathf.Max(0, 3)).ToList()) { Blight(player, item); } } } private void Blight(CharacterBody player, Corpse corpse) { float num = Mathf.Max(0f, 0.2f); GameObject val = (((Object)(object)corpse.body != (Object)null) ? ((Component)corpse.body).gameObject : ((Component)player).gameObject); if ((Object)(object)corpse.body == (Object)null) { num *= corpse.damage / Mathf.Max(1f, player.damage); } DotController.InflictDot(((Component)player).gameObject, val, (DotIndex)5, 5f, num, (uint?)null); } public override void Prepare() { } public override void Start(List<AbstractEvent> activeOtherEvents) { corpses.Clear(); released.Clear(); tickTimer = 1f; MonsterPool.Filter(this, (ChoiceInfo<DirectorCard> choice) => MonsterTraits.LeavesCorpse(choice.value)); } public override void Stop() { MonsterPool.Restore(this); foreach (Corpse corpse in corpses) { if ((Object)(object)corpse.pool != (Object)null) { Object.Destroy((Object)(object)corpse.pool); } } corpses.Clear(); released.Clear(); } } public class EventBorrowedArsenal : AbstractEvent { private const float MaxPerSecond = 2f; private Dictionary<BodyIndex, List<GameObject>> arsenals = new Dictionary<BodyIndex, List<GameObject>>(); private readonly Dictionary<BodyIndex, List<GameObject>> borrowed = new Dictionary<BodyIndex, List<GameObject>>(); private readonly Dictionary<(BodyIndex, GameObject), GameObject> swaps = new Dictionary<(BodyIndex, GameObject), GameObject>(); private readonly ProjectileRateLimit rateLimit = new ProjectileRateLimit(); public override EventTags Tags => EventTags.OnlyAffectsMonsters | EventTags.SwapsMonsterProjectiles; public override EventTags ExcludedTags => EventTags.SwapsMonsterProjectiles; public override bool LoadCondition() { return true; } public override bool Condition(List<AbstractEvent> activeOtherEvents) { return true; } public override string GetEventConfigName() { return "BorrowedArsenal"; } public override string GetAnnouncement() { return Language.GetStringFormatted("ANNOUNCE_EVENT_BORROWED_ARSENAL", Array.Empty<object>()); } public override string GetDescription() { return "Each kind of monster fires the projectiles of another kind, picked from all monsters of the enabled expansions. A flying projectile turns into one of theirs that flies the same way if they have one, at the same speed. The damage stays that of the attack, and each kind of projectile spawns at most twice per second. The shots beyond that spawn nothing."; } public override string GetPopupDescription() { return "Every monster fights with another monster's projectiles!"; } public override string GetConditionDescription() { return ""; } protected override void AddConfig(ConfigFile config) { } public override void Preload() { } public override void Hook() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown ProjectileManager.FireProjectileServer += new hook_FireProjectileServer(ProjectileManager_FireProjectileServer); } private void ProjectileManager_FireProjectileServer(orig_FireProjectileServer orig, ProjectileManager self, FireProjectileInfo fireProjectileInfo, NetworkConnection clientAuthorityOwner, ushort predictionId, double fastForwardTime) { //IL_00a7: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0061: 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_0073: Unknown result type (might be due to invalid IL or missing references) CharacterBody val = default(CharacterBody); if (ModConfig.Enabled.Value && NetworkServer.active && IsActive() && (Object)(object)fireProjectileInfo.projectilePrefab != (Object)null && MonsterProjectiles.IsMonster(fireProjectileInfo.owner) && fireProjectileInfo.owner.TryGetComponent<CharacterBody>(ref val) && MonsterProjectiles.IsSuitable(fireProjectileInfo.projectilePrefab)) { MonsterProjectiles.ReportIfUnknown(fireProjectileInfo.projectilePrefab, fireProjectileInfo.owner); GameObject swap = GetSwap(val.bodyIndex, fireProjectileInfo.projectilePrefab); if ((Object)(object)swap != (Object)null) { if (!rateLimit.CanSpawn(swap, 2f)) { return; } MonsterProjectiles.Swap(ref fireProjectileInfo, swap); } } orig.Invoke(self, fireProjectileInfo, clientAuthorityOwner, predictionId, fastForwardTime); } private GameObject GetSwap(BodyIndex bodyIndex, GameObject projectile) { //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) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if (swaps.TryGetValue((bodyIndex, projectile), out var value)) { return value; } if (!borrowed.TryGetValue(bodyIndex, out var value2)) { List<List<GameObject>> list = (from pair in arsenals where pair.Key != bodyIndex select pair.Value).ToList(); value2 = ((list.Count > 0) ? list[RoR2Application.rng.RangeInt(0, list.Count)] : null); borrowed[bodyIndex] = value2; } if (value2 != null && value2.Count > 0) { ProjectileMotion motion = MonsterProjectiles.GetMotion(projectile); List<GameObject> list2 = value2.Where((GameObject other) => MonsterProjectiles.GetMotion(other) == motion).ToList(); List<GameObject> list3 = ((list2.Count > 0) ? list2 : value2); value = list3[RoR2Application.rng.RangeInt(0, list3.Count)]; } swaps[(bodyIndex, projectile)] = value; return value; } public override void Prepare() { MonsterProjectiles.StartLoading(); } public override void Start(List<AbstractEvent> activeOtherEvents) { //IL_006d: 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) borrowed.Clear(); swaps.Clear(); rateLimit.Clear(); arsenals = MonsterProjectiles.GetArsenals(); List<BodyIndex> list = arsenals.Keys.OrderBy((BodyIndex _) => RoR2Application.rng.nextNormalizedFloat).ToList(); for (int num = 0; num < list.Count; num++) { if (list.Count <= 1) { break; } borrowed[list[num]] = arsenals[list[(num + 1) % list.Count]]; } } public override void Stop() { borrowed.Clear(); swaps.Clear(); rateLimit.Clear(); } } public class EventBouncy : AbstractEvent { private const int VesselCount = 3; private const int MonsterFeathers = 3; private const float MinHopInterval = 0.5f; private const float MaxHopInterval = 3f; private const float LeashLength = 10f; private const float BounceStrength = 0.6f; private const float MinBounceSpeed = 5f; private readonly HashSet<CharacterBody> bouncing = new HashSet<CharacterBody>(); private const float LeashSpring = 15f; private readonly Dictionary<CharacterMotor, Vector3> anchors = new Dictionary<CharacterMotor, Vector3>(); private readonly Dictionary<CharacterBody, float> nextHops = new Dictionary<CharacterBody, float>(); public override EventTags Tags => EventTags.ChangesMonsterSpawns | EventTags.ReliesOnGivenItems | EventTags.AffectsPlayerMovement; public override bool LoadCondition() { return true; } public override bool Condition(List<AbstractEvent> activeOtherEvents) { if (!Helper.IsBossFight() && (VesselsAvailable() || FinsAvailable())) { return MonsterPool.GetChoices().Any(IsWalker); } return false; } public override string GetEventConfigName() { return "Bouncy"; } public override string GetAnnouncement() { return Language.GetStringFormatted("ANNOUNCE_EVENT_BOUNCY", Array.Empty<object>()); } public override string GetDescription() { return "All players get 3 Earthbound Vessels and a Breaching Fin without a cooldown. Only walking monsters spawn, and they jump around at random. Everyone who lands bounces off the ground once more."; } public override string GetPopupDescription() { return "Boing! You and the monsters bounce around."; } public override string GetConditionDescription() { return "Hallowed Concepts or Seekers of the Storm is enabled. Not during a boss fight. The stage has walking monsters."; } protected override void AddConfig(ConfigFile config) { } public override void Preload() { } public override void Hook() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown CharacterBody.onBodyStartGlobal += CharacterBody_onBodyStartGlobal; BaseAI.UpdateBodyInputs += new hook_UpdateBodyInputs(BaseAI_UpdateBodyInputs); RoR2Application.onFixedUpdate += RoR2Application_onFixedUpdate; GlobalEventManager.OnCharacterHitGroundServer += new hook_OnCharacterHitGroundServer(GlobalEventManager_OnCharacterHitGroundServer); } private void GlobalEventManager_OnCharacterHitGroundServer(orig_OnCharacterHitGroundServer orig, GlobalEventManager self, CharacterBody body, HitGroundInfo hitGroundInfo) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Invalid comparison between Unknown and I4 //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Invalid comparison between Unknown and I4 //IL_0145: Expected O, but got Unknown orig.Invoke(self, body, hitGroundInfo); if (NetworkServer.active && IsActive() && !((Object)(object)body == (Object)null) && !((Object)(object)body.healthComponent == (Object)null) && body.healthComponent.alive && !((Object)(object)body.characterMotor == (Object)null) && !body.characterMotor.isFlying && !bouncing.Remove(body) && (body.bodyFlags & 0x14000) == 0) { float num = (0f - hitGroundInfo.velocity.y) * Mathf.Max(0f, 0.6f); if (!(0f - hitGroundInfo.velocity.y < 5f) && !(num <= 0f)) { PhysForceInfo val = PhysForceInfo.Create(); val.force = Vector3.up * num; ((PhysForceInfo)(ref val)).massIsOne = true; ((PhysForceInfo)(ref val)).ignoreGroundStick = true; ((PhysForceInfo)(ref val)).respectKnockupImmune = true; body.healthComponent.TakeDamageForce(val); bouncing.Add(body); EffectManager.SpawnEffect(CommonAssets.knockbackFinEffect, new EffectData { origin = body.transform.position, scale = (((int)body.hullClassification == 2) ? KnockbackFinUtil.queenLaunchEffectScale : (((int)body.hullClassification == 1) ? KnockbackFinUtil.golemLaunchEffectScale : KnockbackFinUtil.humanLaunchEffectScale)) }, true); } } } private static bool VesselsAvailable() { if ((Object)(object)DLC4Content.DLC4 != (Object)null && (Object)(object)Run.instance != (Object)null) { return Run.instance.IsExpansionEnabled(DLC4Content.DLC4); } return false; } private static bool FinsAvailable() { ItemDef knockBackHitEnemies = Items.KnockBackHitEnemies; if ((Object)(object)knockBackHitEnemies != (Object)null && (Object)(object)Run.instance != (Object)null) { if (!((Object)(object)knockBackHitEnemies.requiredExpansion == (Object)null)) { return Run.instance.IsExpansionEnabled(knockBackHitEnemies.requiredExpansion); } return true; } return false; } private void RoR2Application_onFixedUpdate() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_010c: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !IsActive()) { return; } foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList) { CharacterMotor val = (((Object)(object)readOnlyInstances != (Object)null) ? readOnlyInstances.characterMotor : null); if ((Object)(object)val == (Object)null || Helper.IsPlayersSide(readOnlyInstances) || !val.hasEffectiveAuthority || !readOnlyInstances.healthComponent.alive) { continue; } Vector3 position = readOnlyInstances.transform.position; if (val.isGrounded || !anchors.TryGetValue(val, out var value)) { anchors[val] = position; continue; } Vector3 val2 = position - value; float magnitude = ((Vector3)(ref val2)).magnitude; float num = Mathf.Max(0f, 10f); if (!(magnitude <= num) && !(magnitude <= 0f)) { Vector3 val3 = val2 / magnitude; Vector3 val4 = val.velocity; float num2 = Vector3.Dot(val4, val3); if (num2 > 0f) { val4 -= val3 * num2; } val4 -= val3 * 15f * (magnitude - num) * Time.fixedDeltaTime; val.velocity = val4; } } } private static bool IsWalker(ChoiceInfo<DirectorCard> choice) { //IL_0000: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Invalid comparison between Unknown and I4 SpawnCard val = ((choice.value != null) ? choice.value.spawnCard : null); CharacterMaster val2 = (((Object)(object)val != (Object)null && (Object)(object)val.prefab != (Object)null) ? val.prefab.GetComponent<CharacterMaster>() : null); CharacterBody val3 = (((Object)(object)val2 != (Object)null && (Object)(object)val2.bodyPrefab != (Object)null) ? val2.bodyPrefab.GetComponent<CharacterBody>() : null); if (choice.weight > 0f && (Object)(object)val3 != (Object)null && val3.baseMoveSpeed > 0f) { return (int)val.nodeGraphType == 0; } return false; } private void CharacterBody_onBodyStartGlobal(CharacterBody body) { if (NetworkServer.active && IsActive()) { GiveVessels(body); GiveFin(body); GiveFeathers(body); } } private void GiveFin(CharacterBody body) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_007a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)body == (Object)null) && body.isPlayerControlled && !((Object)(object)body.inventory == (Object)null) && FinsAvailable()) { TemporaryInventory inventory = EventLoot.GetInventory(this, body); if (!inventory.temporaryItems.ContainsKey(Items.KnockBackHitEnemies.itemIndex)) { inventory.GiveTemporaryItem(Items.KnockBackHitEnemies.itemIndex); inventory.GiveTemporaryItem(Items.KnockBackHitEnemiesNoCooldown.itemIndex); ItemOrb.Fly(body.corePosition, ((Component)body).gameObject, Items.KnockBackHitEnemies.itemIndex); } } } private void GiveVessels(CharacterBody body) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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) if (!((Object)(object)body == (Object)null) && body.isPlayerControlled && !((Object)(object)body.inventory == (Object)null) && VesselsAvailable()) { TemporaryInventory inventory = EventLoot.GetInventory(this, body); if (!inventory.temporaryItems.ContainsKey(Items.RechargeableJump.itemIndex)) { inventory.GiveTemporaryItem(Items.RechargeableJump.itemIndex, 3); ItemOrb.Fly(body.corePosition + Vector3.up * 4f, ((Component)body).gameObject, Items.RechargeableJump.itemIndex); } } } private void GiveFeathers(CharacterBody body) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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) if (!((Object)(object)body == (Object)null) && !((Object)(object)body.inventory == (Object)null) && !((Object)(object)body.characterMotor == (Object)null) && !Helper.IsPlayersSide(body) && (int)body.teamComponent.teamIndex != 0) { TemporaryInventory inventory = EventLoot.GetInventory(this, body); if (!inventory.temporaryItems.ContainsKey(Items.Feather.itemIndex)) { inventory.GiveTemporaryItem(Items.Feather.itemIndex, 3); } } } private void BaseAI_UpdateBodyInputs(orig_UpdateBodyInputs orig, BaseAI self) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); CharacterBody body = self.body; if (NetworkServer.active && IsActive() && !((Object)(object)Run.instance == (Object)null) && !((Object)(object)body == (Object)null) && !((Object)(object)self.bodyInputBank == (Object)null) && !((Object)(object)body.characterMotor == (Object)null) && !Helper.IsPlayersSide(body) && (int)body.teamComponent.teamIndex != 0) { float fixedTime = Run.instance.fixedTime; if (!nextHops.TryGetValue(body, out var value)) { nextHops[body] = fixedTime + NextInterval(); } else if (!(fixedTime < value)) { nextHops[body] = fixedTime + NextInterval(); self.bodyInputBank.jump.down = true; } } } private float NextInterval() { float num = Mathf.Max(0.1f, 0.5f); return RoR2Application.rng.RangeFloat(num, Mathf.Max(num, 3f)); } public override void Prepare() { } public override void Start(List<AbstractEvent> activeOtherEvents) { nextHops.Clear(); bouncing.Clear(); MonsterPool.Filter(this, IsWalker); foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList) { GiveVessels(readOnlyInstances); GiveFin(readOnlyInstances); GiveFeathers(readOnlyInstances); } } public override void Stop() { MonsterPool.Restore(this); EventLoot.Clear(this); nextHops.Clear(); anchors.Clear(); bouncing.Clear(); } } public class EventBulletHell : AbstractEvent { public class BulletHellComponent : MonoBehaviour { private TemporaryInventory inventory; private void OnEnable() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00d0: Unknown result type (might be due to invalid IL or missing references) CharacterBody component = ((Component)this).GetComponent<CharacterBody>(); if ((Object)(object)component != (Object)null && (Object)(object)component.inventory != (Object)null) { if ((Object)(object)inventory == (Object)null) { inventory = ((Component)this).gameObject.AddComponent<TemporaryInventory>(); } float num = 1.9f; float num2 = 0.1f; int count = Mathf.RoundToInt(0f - Mathf.Log(4f, 0.75f)); inventory.GiveTemporaryItem(Items.ReduceDamage.itemIndex, Mathf.RoundToInt((1f - num2) * 100f)); inventory.GiveTemporaryItem(Items.BoostAttackSpeed.itemIndex, Mathf.RoundToInt((num - 1f) * 10f)); if (component.bodyIndex != BodyCatalog.FindBodyIndex("VoidJailerBody")) { inventory.GiveTemporaryItem(Items.AlienHead.itemIndex, count); } } } private void OnDisable() { Object.Destroy((Object)(object)inventory); } } private const float MinProjectileShare = 1f / 3f; public override EventTags Tags => EventTags.OnlyAffectsMonsters | EventTags.ChangesMonsterSpawns | EventTags.ChangesMonsterAttackSpeed; public override EventTags ExcludedTags => EventTags.ChangesMonsterSpawns | EventTags.SpawnsExtraMonsters | EventTags.ChangesMonsterAttackSpeed; public override bool LoadCondition() { return true; } public override bool Condition(List<AbstractEvent> activeOtherEvents) { return MonsterTraits.WeightShare(MonsterPool.GetChoices(), MonsterTraits.FiresProjectiles) >= 1f / 3f; } public override string GetEventConfigName() { return "BulletHell"; } public override string GetAnnouncement() { return Language.GetString("ANNOUNCE_EVENT_BULLET_HELL"); } public override string GetDescription() { return "Only monsters whose primary or secondary attack fires projectiles spawn. They fire much faster but deal less damage."; } public override string GetPopupDescription() { return "Monsters fire much faster, but each shot hurts less."; } public override string GetConditionDescription() { return "At least a third of the stage's monsters fire projectiles with their primary or secondary attack."; } protected override void AddConfig(ConfigFile config) { } public override void Preload() { } public override void Hook() { CharacterBody.onBodyStartGlobal += CharacterBody_onBodyStartGlobal; } private void CharacterBody_onBodyStartGlobal(CharacterBody body) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 if (ModConfig.Enabled.Value && NetworkServer.active && IsActive() && (int)body.teamComponent.teamIndex != 1) { UnityObjectExtensions.EnsureComponent<BulletHellComponent>(((Component)body).gameObject); } } public override void Prepare() { } public override void Start(List<AbstractEvent> activeOtherEvents) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 MonsterPool.Filter(this, (ChoiceInfo<DirectorCard> choice) => MonsterTraits.FiresProjectiles(choice.value)); foreach (CharacterBody instances in CharacterBody.instancesList) { if ((Object)(object)instances != (Object)null && (int)instances.teamComponent.teamIndex != 1) { UnityObjectExtensions.EnsureComponent<BulletHellComponent>(((Component)instances).gameObject); } } } public override void Stop() { MonsterPool.Restore(this); BulletHellComponent bulletHellComponent = default(BulletHellComponent); foreach (CharacterBody instances in CharacterBody.instancesList) { if ((Object)(object)instances != (Object)null && ((Component)instances).TryGetComponent<BulletHellComponent>(ref bulletHellComponent)) { Object.Destroy((Object)(object)bulletHellComponent); } } } } public class EventCasinoItem : AbstractEvent { public class CasinoItemComponent : MonoBehaviour { private const float changeInterval = 10f; private TemporaryInventory inventory; private float timer = 10f; private int index = -1; private List<ItemIndex> itemCandidates; private void FixedUpdate() { //IL_00b2: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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) timer += Time.fixedDeltaTime; if (!(timer >= 10f)) { return; } CharacterBody component = ((Component)this).GetComponent<CharacterBody>(); if ((Object)(object)component != (Object)null && (Object)(object)component.inventory != (Object)null) { if ((Object)(object)inventory == (Object)null) { inventory = ((Component)this).gameObject.AddComponent<TemporaryInventory>(); } if (index >= 0) { inventory.RemoveTemporaryItem(itemCandidates[index], 10); } index = (index + 1) % itemCandidates.Count; ItemIndex itemIndex = itemCandidates[index]; inventory.GiveTemporaryItem(itemIndex, 10); ItemOrb.Fly(component.transform.position, ((Component)component).gameObject, itemIndex); } timer = 0f; } private void OnEnable() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Invalid comparison between Unknown and I4 //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) List<PickupIndex> list = new List<PickupIndex>(); list.AddRange(Run.instance.availableTier1DropList); list.AddRange(Run.instance.availableTier2DropList); list.AddRange(Run.instance.availableTier3DropList); list.AddRange(Run.instance.availableBossDropList); list.AddRange(Run.instance.availableLunarItemDropList); list.AddRange(Run.instance.availableFoodTierDropList); list.AddRange(Run.instance.availableCursedTierDropList); List<ItemIndex> list2 = new List<ItemIndex>(); foreach (PickupIndex item in list) { PickupDef pickupDef = PickupCatalog.GetPickupDef(item); if (pickupDef != null) { ItemIndex itemIndex = pickupDef.itemIndex; if ((int)ContagiousItemManager.GetTransformedItemIndex(itemIndex) == -1) { list2.Add(itemIndex); } } } list2.Remove(Items.ExtraStatsOnLevelUp.itemIndex); list2.Remove(Items.ExtraLife.itemIndex); list2.Remove(Items.FragileDamageBonus.itemIndex); list2.Remove(Items.HealingPotion.itemIndex); list2.Remove(Items.RegeneratingScrap.itemIndex); list2.Remove(Items.TeleportOnLowHealth.itemIndex); list2.Remove(Items.LowerPricedChests.itemIndex); list2.Remove(Items.BarrageOnBoss.itemIndex); list2.Remove(Items.OnLevelUpFreeUnlock.itemIndex); list2.Remove(Items.ItemDropChanceOnKill.itemIndex); list2.Remove(Items.RoboBallBuddy.itemIndex); list2.Remove(Items.BeetleGland.itemIndex); list2.Remove(Items.Clover.itemIndex); list2.Remove(Items.TransferDebuffOnHit.itemIndex); itemCandidates = list2.OrderBy((ItemIndex x) => Random.Range(0f, 1f)).ToList(); } private void OnDisable() { Object.Destroy((Object)(object)inventory); } } public override EventTags Tags => EventTags.ReliesOnGivenItems; public override bool LoadCondition() { return true; } public override bool Condition(List<AbstractEvent> activeOtherEvents) { return true; } public override string GetEventConfigName() { return "CasinoItem"; } public override string GetAnnouncement() { return Language.GetStringFormatted("ANNOUNCE_EVENT_CASINO_ITEM", Array.Empty<object>()); } public override string GetDescription() { return "All players get 10 of a random item, which changes every 10 seconds."; } public override string GetConditionDescription() { return ""; } protected override void AddConfig(ConfigFile config) { } public override void Preload() { } public override void Hook() { CharacterBody.onBodyStartGlobal += CharacterBody_onBodyStartGlobal; } private void CharacterBody_onBodyStartGlobal(CharacterBody body) { if (ModConfig.Enabled.Value && NetworkServer.active && IsActive() && body.isPlayerControlled) { UnityObjectExtensions.EnsureComponent<CasinoItemComponent>(((Component)body).gameObject); } } public override void Prepare() { } public override void Start(List<AbstractEvent> activeOtherEvents) { foreach (TeamComponent item in (from body in CharacterBody.readOnlyInstancesList where (Object)(object)body != (Object)null && body.isPlayerControlled select body.teamComponent).ToList()) { if ((Object)(object)item.body != (Object)null && item.body.isPlayerControlled) { UnityObjectExtensions.EnsureComponent<CasinoItemComponent>(((Component)item.body).gameObject); } } } public override void Stop() { CasinoItemComponent casinoItemComponent = default(CasinoItemComponent); foreach (CharacterBody instances in CharacterBody.instancesList) { if ((Object)(object)instances != (Object)null && ((Component)instances).TryGetComponent<CasinoItemComponent>(ref casinoItemComponent)) { Object.Destroy((Object)(object)casinoItemComponent); } } } } public class EventChestMimics : AbstractEvent { private const float MimicShare = 0.25f; private CharacterSpawnCard spawnCard; public override EventTags Tags => EventTags.OnlyAffectsMonsters | EventTags.ChangesMonsterSpawns; public override bool LoadCondition() { return true; } public override bool Condition(List<AbstractEvent> activeOtherEvents) { if (!Helper.IsBossFight() && (Object)(object)DLC4Content.DLC4 != (Object)null && (Object)(object)Run.instance != (Object)null && Run.instance.IsExpansionEnabled(DLC4Content.DLC4) && MonsterPool.GetChoices().Count > 0) { return (Object)(object)GetSpawnCard() != (Object)null; } return false; } public override string GetEventConfigName() { return "ChestMimics"; } public override string GetAnnouncement() { return Language.GetStringFormatted("ANNOUNCE_EVENT_CHEST_MIMICS", Array.Empty<object>()); } public override string GetDescription() { return "Mimics join the monsters, about a quarter of them, and hunt the players right away."; } public override string GetPopupDescription() { return "Mimics are on the hunt! Don't let them swallow you."; } public override string GetConditionDescription() { return "Hallowed Concepts is enabled. Not during a boss fight."; } protected override void AddConfig(ConfigFile config) { } public override void Preload() { } public override void Hook() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Idle.OnEnter += new hook_OnEnter(Idle_OnEnter); } private CharacterSpawnCard GetSpawnCard() { //IL_005e: 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_0076: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)spawnCard == (Object)null) { GameObject val = MasterCatalog.FindMasterPrefab("MimicMaster"); if ((Object)(object)val == (Object)null) { return null; } spawnCard = ScriptableObject.CreateInstance<CharacterSpawnCard>(); ((Object)spawnCard).name = "cscMimic"; ((SpawnCard)spawnCard).prefab = val; ((SpawnCard)spawnCard).sendOverNetwork = true; ((SpawnCard)spawnCard).hullSize = (HullClassification)1; ((SpawnCard)spawnCard).nodeGraphType = (GraphType)0; ((SpawnCard)spawnCard).forbiddenFlags = (NodeFlags)4; ((SpawnCard)spawnCard).directorCreditCost = 60; } return spawnCard; } private void Idle_OnEnter(orig_OnEnter orig, Idle self) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 orig.Invoke(self); MimicController val = default(MimicController); if (NetworkServer.active && IsActive() && (Object)(object)((EntityState)self).characterBody != (Object)null && (int)((EntityState)self).characterBody.teamComponent.teamIndex != 1 && ((Component)((EntityState)self).characterBody).TryGetComponent<MimicController>(ref val)) { val.ForceUndisguiseStateServer(); } } public override void Prepare() { } public override void Start(List<AbstractEvent> activeOtherEvents) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown if ((Object)(object)RunArtifactManager.instance != (Object)null && RunArtifactManager.instance.IsArtifactEnabled(Artifacts.SingleMonsterType)) { return; } List<ChoiceInfo<DirectorCard>> choices = MonsterPool.GetChoices(); float num = Mathf.Clamp(0.25f, 0f, 0.95f); float num2 = choices.Sum((ChoiceInfo<DirectorCard> choice) => choice.weight); if (num2 <= 0f || num <= 0f || (Object)(object)GetSpawnCard() == (Object)null) { return; } WeightedSelection<DirectorCard> val = new WeightedSelection<DirectorCard>(8); foreach (ChoiceInfo<DirectorCard> item in choices) { val.AddChoice(item); } val.AddChoice(new DirectorCard { spawnCard = (SpawnCard)(object)GetSpawnCard(), selectionWeight = 1, spawnDistance = (MonsterSpawnDistance)0 }, num2 * num / (1f - num)); MonsterPool.Replace(this, val); } public override void Stop() { MonsterPool.Restore(this); } } public class EventCursedSpoils : AbstractEvent { private const float HexDamage = 0.25f; private readonly Dictionary<CharacterBody, float> damageTaken = new Dictionary<CharacterBody, float>(); public override EventTags Tags => EventTags.OnlyAffectsMonsters; public override EventTags ExcludedTags => EventTags.ReliesOnGivenItems; public override bool LoadCondition() { return true; } public override bool Condition(List<AbstractEvent> activeOtherEvents) { if ((Object)(object)DLC4Content.DLC4 != (Object)null && (Object)(object)Run.instance != (Object)null) { return Run.instance.IsExpansionEnabled(DLC4Content.DLC4); } return false; } public override string GetEventConfigName() { return "CursedSpoils"; } public override string GetAnnouncement() { return Language.GetStringFormatted("ANNOUNCE_EVENT_CURSED_SPOILS", Array.Empty<object>()); } public override string GetDescription() { return "Every kill gives each player a temporary item, but taking damage from monsters brings hexes that disable items."; } public override string GetPopupDescription() { return "Kills give temporary items, but monster hits bring hexes."; } public override string GetConditionDescription() { return "Hallowed Concepts is enabled."; } protected override void AddConfig(ConfigFile config) { } public override void Preload() { } public override void Hook() { GlobalEventManager.onCharacterDeathServer += GlobalEventManager_onCharacterDeathServer; GlobalEventManager.onServerDamageDealt += GlobalEventManager_onServerDamageDealt; } private void GlobalEventManager_onCharacterDeathServer(DamageReport damageReport) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_0027: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 //IL_0064: 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_007c: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !IsActive() || (Object)(object)damageReport.victimBody == (Object)null || (int)damageReport.victimTeamIndex == 1 || (int)damageReport.victimTeamIndex == 0 || (Object)(object)Run.instance == (Object)null) { return; } foreach (CharacterBody livingPlayerBody in Helper.GetLivingPlayerBodies()) { ItemIndex val = RollItem(); if ((int)val == -1) { break; } EventLoot.GetInventory(this, livingPlayerBody).GiveTemporaryItem(val); ItemOrb.FlySilently(damageReport.victimBody.corePosition, ((Component)livingPlayerBody).gameObject, val); } } private static ItemIndex RollItem() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) WeightedSelection<List<PickupIndex>> smallChestDropTierSelector = Run.instance.smallChestDropTierSelector; if (smallChestDropTierSelector.Count == 0) { return (ItemIndex)(-1); } List<PickupIndex> list = smallChestDropTierSelector.Evaluate(RoR2Application.rng.nextNormalizedFloat); if (list == null || list.Count == 0) { return (ItemIndex)(-1); } return (ItemIndex)(((??)PickupCatalog.GetPickupDef(list[RoR2Application.rng.RangeInt(0, list.Count)])?.itemIndex) ?? (-1)); } private void GlobalEventManager_onServerDamageDealt(DamageReport damageReport) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_00b9: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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) CharacterBody victimBody = damageReport.victimBody; if (!NetworkServer.active || !IsActive() || (Object)(object)victimBody == (Object)null || !victimBody.isPlayerControlled || damageReport.damageDealt <= 0f || (int)damageReport.attackerTeamIndex == 1 || (int)damageReport.attackerTeamIndex == -1) { return; } float num = victimBody.baseMaxHealth + victimBody.levelMaxHealth * (victimBody.level - 1f); float num2 = Mathf.Max(1f, num * 0.25f); float num3 = damageTaken.GetValueOrDefault(victimBody) + damageReport.damageDealt; int num4 = 0; while (num3 >= num2) { num3 -= num2; num4++; } damageTaken[victimBody] = num3; if (num4 > 0) { EventLoot.GetInventory(this, victimBody).GiveTemporaryItem(Items.RoamingItemDisable.itemIndex, num4); Vector3 origin = (((Object)(object)damageReport.attackerBody != (Object)null) ? damageReport.attackerBody.corePosition : (victimBody.corePosition + Vector3.up * 4f)); for (int i = 0; i < num4; i++) { ItemOrb.FlySilently(origin, ((Component)victimBody).gameObject, Items.RoamingItemDisable.itemIndex); } } } public override void Prepare() { } public override void Start(List<AbstractEvent> activeOtherEvents) { damageTaken.Clear(); } public override void Stop() { EventLoot.Clear(this); damageTaken.Clear(); } } public class EventDeathmatch : AbstractEvent { private class LostDrone { public CharacterMaster owner; public GameObject masterPrefab; public Dictionary<ItemIndex, int> items = new Dictionary<ItemIndex, int>(); public EquipmentIndex equipment; public Vector3 position; } private const float LeftoverTime = 10f; private float leftoverEnd = float.NegativeInfinity; private const float KillCreditTime = 5f; private const float ImmobilizeSlowDuration = 2f; private const float HealthLossLimit = 0.2f; private const float HealthLossBurstLimit = 0.5f; private const float ItemHealthLossLimit = 0.1f; private const float ItemHealthLossBurstLimit = 0.25f; private const float HealingLimit = 0.2f; private const float BarrierLimit = 0.2f; private const float ItemDamageMultiplier = 0.3f; private const float BigHitDamagePercentage = 4000f; private const float BigHitBurstLimit = 1f; private const float ItemHealthShare = 0.5f; private readonly Dictionary<CharacterMaster, int> scores = new Dictionary<CharacterMaster, int>(); private readonly Dictionary<CharacterMaster, (CharacterMaster attacker, float time)> lastHits = new Dictionary<CharacterMaster, (CharacterMaster, float)>(); private readonly Dictionary<CharacterBody, (float time, float lost)> healthLost = new Dictionary<CharacterBody, (float, float)>(); private readonly Dictionary<CharacterBody, (float time, float lost)> itemHealthLost = new Dictionary<CharacterBody, (float, float)>(); private readonly Dictionary<HealthComponent, (float time, float healed)> healthHealed = new Dictionary<HealthComponent, (float, float)>(); private readonly Dictionary<HealthComponent, (float time, float gained)> barrierGained = new Dictionary<HealthComponent, (float, float)>(); private readonly Dictionary<HealthComponent, (float lost, float itemLost, bool isItemDamage, float burst)> hits = new Dictionary<HealthComponent, (float, float, bool, float)>(); private readonly List<(Inventory inventory, ItemIndex item, int count, ItemIndex broken, int brokenCount)> brokenItems = new List<(Inventory, ItemIndex, int, ItemIndex, int)>(); private readonly List<LostDrone> lostDrones = new List<LostDrone>(); private readonly HashSet<CharacterBody> lostDroneBodies = new HashSet<CharacterBody>(); private readonly Dictionary<TeamFilter, CharacterMaster> bannerOwners = new Dictionary<TeamFilter, CharacterMaster>(); private float timeLeft; private static readonly TeamIndex[] Teams; private const int MaxPlayersAlone = 3; private bool teamMode; private bool modeChosen; private readonly Dictionary<CharacterMaster, TeamIndex> playerTeams = new Dictionary<CharacterMaster, TeamIndex>(); private readonly Dictionary<CharacterMaster, TeamIndex> originalTeams = new Dictionary<CharacterMaster, TeamIndex>(); private readonly Dictionary<TeamIndex, uint> originalTeamLevels = new Dictionary<TeamIndex, uint>(); public override EventTags Tags => EventTags.MarksPlayers | EventTags.RevivesPlayers | EventTags.PlayerVersusPlayer; public override EventTags ExcludedTags => EventTags.OnlyAffectsMonsters | EventTags.MarksPlayers | EventTags.RevivesPlayers | EventTags.ChangesPlayerDamage | EventTags.HidesPlayers; public override bool KeepsOwnTime => true; private bool Pausing { get { if (ModConfig.Enabled.Value && NetworkServer.active) { return IsActive(); } return false; } } public override bool LoadCondition() { return true; } public override bool Condition(List<AbstractEvent> activeOtherEvents) { return PlayerMatch.CanStart(); } public override string GetEventConfigName() { return "Deathmatch"; } public override string GetAnnouncement() { if (!modeChosen) { ChooseMode(); } return Language.GetStringFormatted(teamMode ? "ANNOUNCE_EVENT_TEAM_DEATHMATCH" : "ANNOUNCE_EVENT_DEATHMATCH", Array.Empty<object>()); } public override string GetDescription() { return "The monsters leave and the players fight each other: alone with up to 3 players, otherwise in two teams. Players revive when they die and score a point for each kill. Afterwards broken items and destroyed drones come back, and the winners get a green item."; } public override string GetPopupDescription() { return "Fight the other players! The most kills wins an item."; } public override string GetConditionDescription() { return "At least two players are alive. Not during the teleporter event, a Void Fields cell or a boss fight."; } protected override void AddConfig(ConfigFile config) { } public override void Preload() { } public override void Hook() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_TakeDamage); HealthComponent.TakeDamageProcess += new Manipulator(HealthComponent_TakeDamageProcess); HealthComponent.TakeDamageProcess += new Manipulator(HealthComponent_TakeDamageProcess_GoldOnHurt); HealthComponent.Heal += new hook_Heal(HealthComponent_Heal); HealthComponent.AddBarrier += new hook_AddBarrier(HealthComponent_AddBarrier); GlobalEventManager.onCharacterDeathServer += GlobalEventManager_onCharacterDeathServer; CharacterBody.onBodyStartGlobal += CharacterBody_onBodyStartGlobal; RoR2Application.onFixedUpdate += RoR2Application_onFixedUpdate; SetStateOnHurt.SetStun += new hook_SetStun(SetStateOnHurt_SetStun); SetStateOnHurt.OverrideStun += new hook_OverrideStun(SetStateOnHurt_OverrideStun); SetStateOnHurt.SetFrozen += new hook_SetFrozen(SetStateOnHurt_SetFrozen); SetStateOnHurt.SetShock += new hook_SetShock(SetStateOnHurt_SetShock); SetStateOnHurt.SetImmobilize += new hook_SetImmobilize(SetStateOnHurt_SetImmobilize); CharacterBody.AddTimedBuff_BuffDef_float += new hook_AddTimedBuff_BuffDef_float(CharacterBody_AddTimedBuff_BuffDef_float); CharacterBody.AddTimedBuff_BuffDef_float_int += new hook_AddTimedBuff_BuffDef_float_int(CharacterBody_AddTimedBuff_BuffDef_float_int); ItemTransformation.TryTransform += new hook_TryTransform(ItemTransformation_TryTransform); SacrificeArtifactManager.OnServerCharacterDeath += new hook_OnServerCharacterDeath(SacrificeArtifactManager_OnServerCharacterDeath); DeathState.OnEnter += new hook_OnEnter(DeathState_OnEnter); DeathState.OnEnter += new hook_OnEnter(TurretDeathState_OnEnter); SetStateOnHurt.OnTakeDamageServer += new hook_OnTakeDamageServer(SetStateOnHurt_OnTakeDamageServer); WardOnLevelManager.OnCharacterLevelUp += new hook_OnCharacterLevelUp(WardOnLevelManager_OnCharacterLevelUp); GenericPickupController.AttemptGrant += new hook_AttemptGrant(GenericPickupController_AttemptGrant); } private void GenericPickupController_AttemptGrant(orig_AttemptGrant orig, GenericPickupController self, CharacterBody body) { //IL_0077: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) TeamComponent val = (((Object)(object)body != (Object)null) ? body.teamComponent : null); if (!NetworkServer.active || !IsActive() || (Object)(object)val == (Object)null || (int)val._teamIndex == 1 || (Object)(object)body.master == (Object)null || (Object)(object)body.master.playerCharacterMasterController == (Object)null) { orig.Invoke(self, body); return; } TeamIndex teamIndex = val._teamIndex; val._teamIndex = (TeamIndex)1; try { orig.Invoke(self, body); } finally { val._teamIndex = teamIndex; } } private void SetStateOnHurt_OnTakeDamageServer(orig_OnTakeDamageServer orig, SetStateOnHurt self, DamageReport damageReport) { //IL_0040: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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) orig.Invoke(self, damageReport); DamageInfo damageInfo = damageReport.damageInfo; CharacterBody val = default(CharacterBody); if (Pausing && !self.canBeStunned && !(damageInfo.procCoefficient < Mathf.Epsilon) && ((Component)self).TryGetComponent<CharacterBody>(ref val) && val.isPlayerControlled) { if (DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)16777216)) != 0L) { val.AddTimedBuff(Buffs.Slow80, 5f * damageInfo.procCoefficient); } else if (DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)32)) != 0L) { val.AddTimedBuff(Buffs.Slow80, damageInfo.procCoefficient); } } } private void WardOnLevelManager_OnCharacterLevelUp(orig_OnCharacterLevelUp orig, CharacterBody characterBody) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(characterBody); if (!NetworkServer.active || (Object)(object)characterBody == (Object)null || (Object)(object)characterBody.master == (Object)null) { return; } BuffWard[] array = Object.FindObjectsOfType<BuffWard>(); TeamFilter key = default(TeamFilter); foreach (BuffWard val in array) { if ((Object)(object)val.buffDef == (Object)(object)Buffs.Warbanner && ((Component)val).transform.position == characterBody.transform.position && ((Component)val).TryGetComponent<TeamFilter>(ref key) && !bannerOwners.ContainsKey(key)) { bannerOwners[key] = characterBody.master; } } } private void UpdateOwnedTeams() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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) foreach (TeamFilter item in bannerOwners.Keys.Where((TeamFilter val6) => !Object.op_Implicit((Object)(object)val6)).ToList()) { bannerOwners.Remove(item); } TeamFilter[] array = Object.FindObjectsOfType<TeamFilter>(); TeamComponent val2 = default(TeamComponent); CharacterBody val3 = default(CharacterBody); EntityStateMachine val4 = default(EntityStateMachine); TeamFilter teamFilter = default(TeamFilter); foreach (TeamFilter val in array) { CharacterMaster ownerMaster = GetOwnerMaster(val); if ((Object)(object)ownerMaster == (Object)null || (Object)(object)GetPlayer(ownerMaster) == (Object)null) { continue; } SetTeam(val, ownerMaster.teamIndex); if (((Component)val).TryGetComponent<TeamComponent>(ref val2) && (!((Component)val).TryGetComponent<CharacterBody>(ref val3) || (Object)(object)val3.master == (Object)null) && val2.teamIndex != ownerMaster.teamIndex) { val2.teamIndex = ownerMaster.teamIndex; } if (((Component)val).TryGetComponent<EntityStateMachine>(ref val4)) { EntityState state = val4.state; HealZoneMainState val5 = (HealZoneMainState)(object)((state is HealZoneMainState) ? state : null); if (val5 != null && Object.op_Implicit((Object)(object)val5.healZoneInstance) && val5.healZoneInstance.TryGetComponent<TeamFilter>(ref teamFilter)) { SetTeam(teamFilter, ownerMaster.teamIndex); } } } } private static void SetTeam(TeamFilter teamFilter, TeamIndex team) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (teamFilter.teamIndex != team) { teamFilter.teamIndex = team; } } private CharacterMaster GetOwnerMaster(TeamFilter teamFilter) { GameObject gameObject = ((Component)teamFilter).gameObject; Deployable val = default(Deployable); if (gameObject.TryGetComponent<Deployable>(ref val) && (Object)(object)val.ownerMaster != (Object)null) { return val.ownerMaster; } if (bannerOwners.TryGetValue(teamFilter, out var value)) { return value; } NetworkedBodyAttachment val2 = default(NetworkedBodyAttachment); if (gameObject.TryGetComponent<NetworkedBodyAttachment>(ref val2) && (Object)(object)val2.attachedBody != (Object)null) { return val2.attachedBody.master; } GenericOwnership val4 = default(GenericOwnership); ProjectileController val5 = default(ProjectileController); GameObject val3 = (gameObject.TryGetComponent<GenericOwnership>(ref val4) ? val4.ownerObject : (gameObject.TryGetComponent<ProjectileController>(ref val5) ? val5.owner : null)); CharacterBody val6 = (((Object)(object)val3 != (Object)null) ? val3.GetComponent<CharacterBody>() : gameObject.GetComponentInParent<CharacterBody>()); if (!((Object)(object)val6 != (Object)null)) { return null; } return val6.master; } private void SacrificeArtifactManager_OnServerCharacterDeath(orig_OnServerCharacterDeath orig, DamageReport damageReport) { if (!Pausing || !((Object)(object)damageReport.victimMaster != (Object)null) || !((Object)(object)GetPlayer(damageReport.victimMaster) != (Object)null)) { orig.Invoke(damageReport); } } private static List<CharacterMaster> ConnectedPlayers() { return (from pc in PlayerCharacterMasterController.instances where pc.isConnected && (Object)(object)pc.master != (Object)null select pc.master).ToList(); } private void ChooseMode() { int count = ConnectedPlayers().Count; teamMode = count > 3; modeChosen = true; } private void AssignTeams() { //IL_00b5: 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_00c2: 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_00da: Unknown result type (might be due to invalid IL or missing references) List<CharacterMaster> list = (from player in ConnectedPlayers() orderby RoR2Application.rng.nextNormalizedFloat select player).ToList(); for (int num = 0; num < list.Count; num++) { playerTeams[list[num]] = Teams[num % (teamMode ? 2 : Teams.Length)]; } uint teamLevel = TeamManager.instance.GetTeamLevel((TeamIndex)1); foreach (TeamIndex item in from team in playerTeams.Values.Distinct() where (int)team != 1 select team) { originalTeamLevels[item] = TeamManager.instance.GetTeamLevel(item); TeamManager.instance.SetTeamLevel(item, teamLevel); } foreach (CharacterMaster item2 in CharacterMaster.readOnlyInstancesList.ToList()) { AssignTeam(item2); } } private void AssignTeam(CharacterMaster master) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0040: 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) CharacterMaster player = GetPlayer(master); if ((Object)(object)player == (Object)null || !playerTeams.TryGetValue(player, out var value)) { return; } if (master.teamIndex != value) { if (!originalTeams.ContainsKey(master)) { originalTeams[master] = master.teamIndex; } master.teamIndex = value; } CharacterBody body = master.GetBody(); if ((Object)(object)body != (Object)null && body.teamComponent.teamIndex != value) { body.teamComponent.teamIndex = value; } } private void RestoreTeams() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_013c: 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_01e5: Unknown result type (might be due to invalid IL or missing references) TeamIndex key2; foreach (KeyValuePair<CharacterMaster, TeamIndex> originalTeam in originalTeams) { originalTeam.Deconstruct(out var key, out key2); CharacterMaster val = key; TeamIndex teamIndex = key2; if (!((Object)(object)val == (Object)null)) { val.teamIndex = teamIndex; CharacterBody body = val.GetBody(); if ((Object)(object)body != (Object)null) { body.teamComponent.teamIndex = teamIndex; } } } foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList) { CharacterMaster player = GetPlayer(readOnlyInstances); if (!((Object)(object)player == (Object)null) && !((Object)(object)player == (Object)(object)readOnlyInstances) && readOnlyInstances.teamIndex != player.teamIndex) { readOnlyInstances.teamIndex = player.teamIndex; CharacterBody body2 = readOnlyInstances.GetBody(); if ((Object)(object)body2 != (Object)null) { body2.teamComponent.teamIndex = player.teamIndex; } } } if ((Object)(object)TeamManager.instance != (Object)null) { foreach (KeyValuePair<TeamIndex, uint> originalTeamLevel in originalTeamLevels) { originalTeamLevel.Deconstruct(out key2, out var value); TeamIndex val2 = key2; uint num = value; TeamManager.instance.SetTeamLevel(val2, num); } } originalTeams.Clear(); originalTeamLevels.Clear(); playerTeams.Clear(); foreach (CharacterMaster readOnlyInstances2 in CharacterMaster.readOnlyInstancesList) { BaseAI[] array = (BaseAI[])(((object)readOnlyInstances2.AiComponents) ?? ((object)new BaseAI[0])); foreach (BaseAI val3 in array) { Target currentEnemy = val3.currentEnemy; CharacterBody val4 = ((currentEnemy != null) ? currentEnemy.characterBody : null); if ((Object)(object)val4 != (Object)null && val4.teamComponent.teamIndex == readOnlyInstances2.teamIndex) { val3.currentEnemy.Reset(); val3.enemyAttention = 0f; } } } } private bool ItemTransformation_TryTransform(orig_TryTransform orig, ref ItemTransformation self, Inventory inventory, out TryTransformResult result) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_00bc: Unknown result type (might be due to invalid IL or missing references) bool num = orig.Invoke(ref self, inventory, ref result); CharacterMaster val = default(CharacterMaster); if (num && Pausing && (Object)(object)inventory != (Object)null && ((Component)inventory).TryGetComponent<CharacterMaster>(ref val) && (Object)(object)val.playerCharacterMasterController != (Object)null && result.takenItem.stackValues.permanentStacks > 0 && result.takenItem.itemIndex != Items.RegeneratingScrap.itemIndex) { ItemDef itemDef = ItemCatalog.GetItemDef(result.givenItem.itemIndex); if ((Object)(object)itemDef != (Object)null && itemDef.isConsumed) { brokenItems.Add((inventory, result.takenItem.itemIndex, result.takenItem.stackValues.permanentStacks, itemDef.itemIndex, result.givenItem.stackValues.permanentStacks)); } } return num; } private void RestoreBrokenItems() { //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) //IL_0059: Unknown result type (might be due to invalid IL or missing references) foreach (var (val, val2, num, val3, num2) in brokenItems) { if (!((Object)(object)val == (Object)null)) { int num3 = Mathf.Min(num2, val.GetItemCountPermanent(val3)); if (num3 > 0) { val.RemoveItemPermanent(val3, num3); } val.GiveItemPermanent(val2, num); } } if (brokenItems.Count > 0) { ChatHelper.SendEventMessage("EVENT_DEATHMATCH_ITEMS_RESTORED"); } brokenItems.Clear(); } private bool SlowsInstead(SetStateOnHurt setStateOnHurt, float duration) { CharacterBody val = default(CharacterBody); if (Pausing && ((Component)setStateOnHurt).TryGetComponent<CharacterBody>(ref val) && val.isPlayerControlled) { val.AddTimedBuff(Buffs.Slow80, duration); return true; } return false; } private void SetStateOnHurt_SetStun(orig_SetStun orig, SetStateOnHurt self, float duration) { if (!SlowsInstead(self, duration)) { orig.Invoke(self, duration); } } private void SetStateOnHurt_OverrideStun(orig_OverrideStun orig, SetStateOnHurt self, float duration) { if (!SlowsInstead(self, duration)) { orig.Invoke(self, duration); } } private void SetStateOnHurt_SetFrozen(orig_SetFrozen orig, SetStateOnHurt self, float duration) { if (!SlowsInstead(self, duration)) { orig.Invoke(self, duration); } } private void SetStateOnHurt_SetShock(orig_SetShock orig, SetStateOnHurt self, float duration) { if (!SlowsInstead(self, duration)) { orig.Invoke(self, duration); } } private void SetStateOnHurt_SetImmobilize(orig_Se