using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using EntityStates; using EntityStates.Drone; using HarmonyLib; using JetBrains.Annotations; using RoR2; using RoR2.ContentManagement; using RoR2.Modding; using RoR2.Networking; using RoR2.Skills; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] namespace DrifterUES; public sealed class DeferredFabricatorSkillDef : DrifterSkillDef { public override bool IsReady([NotNull] GenericSkill skillSlot) { return FabricationService.HasAvailableFabricationRecipe() && ((DrifterSkillDef)this).IsReady(skillSlot); } public override bool CanExecute([NotNull] GenericSkill skillSlot) { return FabricationService.HasAvailableFabricationRecipe() && ((DrifterSkillDef)this).CanExecute(skillSlot); } public override void OnExecute([NotNull] GenericSkill skillSlot) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) skillSlot.stateMachine.SetInterruptState(((SkillDef)this).InstantiateNextState(skillSlot), ((SkillDef)this).interruptPriority); if (((SkillDef)this).cancelSprintingOnActivation) { skillSlot.characterBody.isSprinting = false; } if (((SkillDef)this).resetCooldownTimerOnUse) { skillSlot.rechargeStopwatch = 0f; } CharacterBody characterBody = skillSlot.characterBody; if (characterBody != null) { characterBody.OnSkillActivated(skillSlot); } } } internal static class FabricationMenu { internal enum Mode { Fabricator, Nanobot } private static GameObject activeMenuRoot; private static bool menuOpening; internal static bool IsOpen => Object.op_Implicit((Object)(object)activeMenuRoot); internal static void Open(Mode mode, CharacterBody owner) { if (!((Object)(object)owner == (Object)null) && owner.hasEffectiveAuthority && !menuOpening && !Object.op_Implicit((Object)(object)activeMenuRoot)) { menuOpening = true; ((MonoBehaviour)Plugin.Instance).StartCoroutine(OpenWhenUiReady(mode, owner)); } } private static IEnumerator OpenWhenUiReady(Mode mode, CharacterBody owner) { LocalUser user = null; HUD hud = null; for (int frame = 0; frame < 30; frame++) { if ((Object)(object)owner == (Object)null || !owner.hasEffectiveAuthority) { menuOpening = false; yield break; } user = ((IEnumerable)LocalUserManager.readOnlyLocalUsersList).FirstOrDefault((Func)((LocalUser candidate) => (Object)(object)candidate.cachedBody == (Object)(object)owner)); hud = ((IEnumerable)HUD.readOnlyInstanceList).FirstOrDefault((Func)((HUD candidate) => candidate.localUserViewer == user)); if (user != null && (Object)(object)user.eventSystem != (Object)null && (Object)(object)hud != (Object)null) { break; } yield return null; } menuOpening = false; if (user != null && !((Object)(object)user.eventSystem == (Object)null) && !((Object)(object)hud == (Object)null) && !Object.op_Implicit((Object)(object)activeMenuRoot)) { GameObject root = (activeMenuRoot = CreateMenuRoot(user, hud, (mode == Mode.Fabricator) ? "UES FABRICATOR" : "NANOBOT UPGRADES")); PauseManager.ClosePauseScreen(true); if (mode == Mode.Fabricator) { ConfigureFabricator(root, owner); } else { ConfigureNanobots(root, owner); } AddResourceSummary(root, owner); } } private static GameObject CreateMenuRoot(LocalUser user, HUD hud, string title) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_00a2: 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_0108: 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_0126: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Expected O, but got Unknown //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Expected O, but got Unknown //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Expected O, but got Unknown GameObject val = new GameObject("UESDrifterSelectionMenu", new Type[7] { typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler), typeof(GraphicRaycaster), typeof(MPEventSystemProvider), typeof(MPEventSystemLocator), typeof(CursorOpener) }); Canvas component = val.GetComponent(); component.renderMode = (RenderMode)0; component.sortingOrder = 100; val.GetComponent().uiScaleMode = (ScaleMode)1; val.GetComponent().referenceResolution = new Vector2(1920f, 1080f); val.GetComponent().eventSystem = user.eventSystem; val.GetComponent().forceCursorForGamePad = true; Image val2 = val.AddComponent(); ((Graphic)val2).color = new Color(0f, 0.02f, 0.05f, 0.88f); Transform val3 = CreateChild(val.transform, "Panel", new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(860f, 760f)); Image val4 = ((Component)val3).gameObject.AddComponent(); ((Graphic)val4).color = new Color(0.06f, 0.11f, 0.16f, 0.98f); CreateText(val3, "Title", title, 32f, (TextAlignmentOptions)514, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -38f), new Vector2(-40f, 52f), hud); CreateText(val3, "Hint", "Select a target. Costs are charged only after server confirmation.", 17f, (TextAlignmentOptions)514, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -76f), new Vector2(-40f, 28f), hud); CreateCloseButton(val3, hud, val); Transform val5 = CreateChild(val3, "SelectionScroll", new Vector2(0f, 0f), new Vector2(1f, 1f), new Vector2(0.5f, 0.5f), new Vector2(0f, -70f), new Vector2(-44f, -166f)); ScrollRect val6 = ((Component)val5).gameObject.AddComponent(); Transform val7 = CreateChild(val5, "Viewport", Vector2.zero, Vector2.one, new Vector2(0.5f, 0.5f), Vector2.zero, Vector2.zero); ((Graphic)((Component)val7).gameObject.AddComponent()).color = new Color(0f, 0f, 0f, 0.18f); ((Component)val7).gameObject.AddComponent().showMaskGraphic = true; Transform val8 = CreateChild(val7, "Content", new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0.5f, 1f), Vector2.zero, new Vector2(0f, 0f)); VerticalLayoutGroup val9 = ((Component)val8).gameObject.AddComponent(); ((LayoutGroup)val9).padding = new RectOffset(14, 14, 14, 14); ((HorizontalOrVerticalLayoutGroup)val9).spacing = 8f; ((HorizontalOrVerticalLayoutGroup)val9).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val9).childForceExpandHeight = false; ((Component)val8).gameObject.AddComponent().verticalFit = (FitMode)2; val6.viewport = (RectTransform)val7; val6.content = (RectTransform)val8; val6.horizontal = false; val6.vertical = true; val6.scrollSensitivity = 30f; return val; } private static void ConfigureFabricator(GameObject root, CharacterBody owner) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00ca: Unknown result type (might be due to invalid IL or missing references) Transform parent = root.transform.Find("Panel/SelectionScroll/Viewport/Content"); JunkController component = ((Component)owner).GetComponent(); int num = FabricationService.CountActiveFabricatedDrones(owner.master); bool flag = num >= 8; CreateText(root.transform.Find("Panel"), "FabricatedDroneCount", "Fabricated Drones: " + num + " / " + 8, 17f, (TextAlignmentOptions)514, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -128f), new Vector2(-40f, 28f), null); foreach (DroneRecipe recipe in UesRecipes.Fabrication) { DroneDef val = recipe.drone(); if (!((Object)(object)val == (Object)null)) { bool enabled = !flag && FabricationService.CanPay(owner.inventory, component, recipe.cost); string label = recipe.displayName + " • Tier " + recipe.fabricationTier + "\n" + CostText(recipe.cost) + (flag ? " (8 drone limit reached)" : string.Empty); CreateSelectionButton(parent, val.iconSprite, label, enabled, delegate { UesNetwork.SendFabrication(recipe.id); Close(root); }); } } } private static void ConfigureNanobots(GameObject root, CharacterBody owner) { //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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) Transform parent = root.transform.Find("Panel/SelectionScroll/Viewport/Content"); CharacterMaster master = owner.master; JunkController component = ((Component)owner).GetComponent(); bool flag = NanobotUpgradeService.CountActiveNanobotUpgrades(master) >= 2; bool flag2 = false; foreach (CharacterMaster drone in GetEligibleDrones(master)) { flag2 = true; bool flag3 = NanobotUpgradeService.IsNanobotActive(drone); int num = 1 + drone.inventory.GetItemCountPermanent(Items.DroneUpgradeHidden) - (flag3 ? 1 : 0); ResourceCost cost = NanobotUpgradeService.CostForPermanentTier(num); bool enabled = !flag3 && !flag && FabricationService.CanPay(owner.inventory, component, cost); CharacterBody body = drone.GetBody(); DroneDef droneDef = DroneCatalog.GetDroneDef(DroneCatalog.GetDroneIndexFromBodyIndex(body.bodyIndex)); string text = (((Object)(object)droneDef != (Object)null && !Language.IsTokenInvalid(droneDef.nameToken)) ? Language.GetString(droneDef.nameToken) : body.GetDisplayName()); string label = text + " • Tier " + num + " → " + (num + 1) + "\n" + CostText(cost) + (flag3 ? " (already upgraded)" : (flag ? " (2 upgrade limit reached)" : string.Empty)); CreateSelectionButton(parent, ((Object)(object)droneDef != (Object)null) ? droneDef.iconSprite : null, label, enabled, delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) UesNetwork.SendNanobot(((NetworkBehaviour)drone).netId); Close(root); }); } if (!flag2) { CreateText(parent, "Empty", "No eligible allied drones are currently owned by this player.", 20f, (TextAlignmentOptions)514, Vector2.zero, Vector2.one, new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(0f, 90f), null); } } private static IEnumerable GetEligibleDrones(CharacterMaster owner) { MinionGroup group = (((Object)(object)owner != (Object)null) ? MinionGroup.FindGroup(((NetworkBehaviour)owner).netId) : null); if (group == null) { yield break; } MinionOwnership[] members = group.members; foreach (MinionOwnership member in members) { CharacterMaster master = (Object.op_Implicit((Object)(object)member) ? ((Component)member).GetComponent() : null); if ((Object)(object)master != (Object)null && (NanobotUpgradeService.IsEligible(owner, master) || NanobotUpgradeService.IsNanobotActive(master))) { yield return master; } } } private static void CreateSelectionButton(Transform parent, Sprite icon, string label, bool enabled, Action onClick) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00de: Expected O, but got Unknown //IL_00f4: 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_0112: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("DroneOption", new Type[4] { typeof(RectTransform), typeof(Image), typeof(Button), typeof(LayoutElement) }); val.transform.SetParent(parent, false); val.GetComponent().preferredHeight = 82f; Image component = val.GetComponent(); ((Graphic)component).color = (enabled ? new Color(0.12f, 0.24f, 0.31f, 1f) : new Color(0.09f, 0.09f, 0.09f, 1f)); Button component2 = val.GetComponent