protected CustomPlusSurvivor(SurvivorIndex index, string characterName, ConfigFile file)
        {
            Config        = file;
            SurvivorIndex = index;

            CharacterName = characterName;
        }
Пример #2
0
 public static void SpawnPlayerbots(CharacterMaster owner, SurvivorIndex characterType, int amount)
 {
     for (int i = 0; i < amount; i++)
     {
         SpawnPlayerbot(owner, characterType);
     }
 }
Пример #3
0
 public void NewSetup(SurvivorIndex survivorIndex = SurvivorIndex.None)
 {
     characterSelectController = gameObject.GetComponent <CharacterSelectController>();
     RepositionHUD();
     RepositionCharacterPads();
     UpdateTeamName(survivorIndex);
 }
Пример #4
0
        // Token: 0x060014ED RID: 5357 RVA: 0x00059610 File Offset: 0x00057810
        private void Build()
        {
            List <SurvivorIndex> list = new List <SurvivorIndex>();

            for (int i = 0; i < SurvivorCatalog.idealSurvivorOrder.Length; i++)
            {
                SurvivorIndex survivorIndex = SurvivorCatalog.idealSurvivorOrder[i];
                SurvivorDef   survivorDef   = SurvivorCatalog.GetSurvivorDef(survivorIndex);
                if (this.ShouldDisplaySurvivor(survivorDef))
                {
                    list.Add(survivorIndex);
                }
            }
            this.survivorIconControllers.AllocateElements(list.Count);
            ReadOnlyCollection <SurvivorIconController> elements = this.survivorIconControllers.elements;

            for (int j = 0; j < list.Count; j++)
            {
                elements[j].survivorIndex = list[j];
            }
            for (int k = list.Count; k < SurvivorCatalog.survivorMaxCount; k++)
            {
                UnityEngine.Object.Instantiate <GameObject>(this.WIPButtonPrefab, this.iconContainer).gameObject.SetActive(true);
            }
        }
Пример #5
0
        public static string SurvivorIndexToBodyString(SurvivorIndex index)
        {
            switch (index)
            {
            case SurvivorIndex.Commando:
                return("CommandoBody");

            case SurvivorIndex.Engineer:
                return("EngiBody");

            case SurvivorIndex.Huntress:
                return("HuntressBody");

            case SurvivorIndex.Mage:
                return("MageBody");

            case SurvivorIndex.Merc:
                return("MercBody");

            case SurvivorIndex.Toolbot:
                return("ToolbotBody");

            case SurvivorIndex.Treebot:
                return("TreebotBody");

            default:
                return("");
            }
        }
Пример #6
0
            private string GetTeamName2(SurvivorIndex firstSurvivorIndex = SurvivorIndex.None)
            {
                var networkUsers = characterSelectController.GetSortedNetworkUsersList();

                List <string>    bodyNames   = new List <string>();
                List <BodyIndex> bodyIndices = new List <BodyIndex>();

                if (!debug)
                {
                    if (networkUsers.Count <= 3)
                    {
                        return(string.Empty);
                    }
                    foreach (var networkUser in networkUsers)
                    {
                        bodyIndices.Add(networkUser.NetworkbodyIndexPreference);
                        bodyNames.Add(BodyCatalog.GetBodyName(networkUser.NetworkbodyIndexPreference));
                    }
                }
                else
                {
                    bodyNames = debug_characters.ToList();
                    foreach (var bodyName in debug_characters)
                    {
                        bodyIndices.Add(BodyCatalog.FindBodyIndex(bodyName));
                    }
                }
                if (firstSurvivorIndex != SurvivorIndex.None)
                {
                    bodyIndices[0] = SurvivorCatalog.GetBodyIndexFromSurvivorIndex(firstSurvivorIndex);
                    bodyNames[0]   = SurvivorCatalog.GetSurvivorDef(firstSurvivorIndex).bodyPrefab.name;
                }

                /*
                 * if (characterNames_to_teamName.TryGetValue(bodyNames.ToArray(), out string output))
                 * {
                 *  Debug.Log(output);
                 * }*/

                foreach (var name in bodyNames)
                {
                    Debug.Log(name);
                }

                foreach (var entry in characterNames_to_teamName)
                {
                    var key = entry.Key;
                    if (
                        key[0] == bodyNames[0] &&
                        key[1] == bodyNames[1] &&
                        key[2] == bodyNames[2] &&
                        key[3] == bodyNames[3]
                        )
                    {
                        return(entry.Value);
                    }
                }
                return(string.Empty);
            }
Пример #7
0
 public static SurvivorDef GetSurvivorDef(SurvivorIndex survivorIndex)
 {
     if ((int)survivorIndex < 0 || (int)survivorIndex > SurvivorCatalog.survivorDefs.Length)
     {
         return(null);
     }
     return(SurvivorCatalog.survivorDefs[(int)survivorIndex]);
 }
Пример #8
0
 private void ScrollableLobbyUISelectCharacter(SurvivorIndex survivorIndex)
 {
     if (!(scrollableLobbyUIController is ScrollableLobbyUI.CharacterSelectBarControllerReplacement barReplacement))
     {
         return;
     }
     barReplacement.OpenPageWithCharacter(survivorIndex);
 }
Пример #9
0
 public static SurvivorDef GetSurvivorDef(SurvivorIndex survivorIndex)
 {
     if (survivorIndex < 0 || survivorIndex > (SurvivorIndex)SurvivorCatalog.survivorDefs.Count())
     {
         return(null);
     }
     return(SurvivorCatalog.survivorDefs[(int)survivorIndex]);
 }
 // Token: 0x06001B4C RID: 6988 RVA: 0x0007F8C4 File Offset: 0x0007DAC4
 public static SurvivorDef GetSurvivorDef(SurvivorIndex survivorIndex)
 {
     if (survivorIndex < SurvivorIndex.Commando || survivorIndex > SurvivorIndex.Count)
     {
         return(null);
     }
     return(SurvivorCatalog.survivorDefs[(int)survivorIndex]);
 }
Пример #11
0
        // Token: 0x06001B2F RID: 6959 RVA: 0x00073EB0 File Offset: 0x000720B0
        private static int GuessUnlockableSortScore(UnlockableDef unlockableDef)
        {
            int num    = 0;
            int num2   = num + 200;
            int num3   = num2 + 200;
            int num4   = num3 + 200;
            int result = num4 + 200;

            if (unlockableDef == null)
            {
                return(10000);
            }
            string name = unlockableDef.name;
            int    i    = 0;

            while (i < SurvivorCatalog.idealSurvivorOrder.Length)
            {
                SurvivorIndex survivorIndex = SurvivorCatalog.idealSurvivorOrder[i];
                if (name.Contains(survivorIndex.ToString()))
                {
                    if (SurvivorCatalog.GetSurvivorDef(survivorIndex).unlockableName == name)
                    {
                        return(num3 + i * 10);
                    }
                    int num5 = num4 + i * 10;
                    if (name.Contains("Skin"))
                    {
                        num5++;
                    }
                    return(num5);
                }
                else
                {
                    i++;
                }
            }
            ItemDef itemDef = ItemCatalog.allItems.Select(new Func <ItemIndex, ItemDef>(ItemCatalog.GetItemDef)).FirstOrDefault((ItemDef v) => v.unlockableName == unlockableDef.name);

            if (itemDef != null)
            {
                return((int)(num + itemDef.tier));
            }
            EquipmentDef equipmentDef = EquipmentCatalog.allEquipment.Select(new Func <EquipmentIndex, EquipmentDef>(EquipmentCatalog.GetEquipmentDef)).FirstOrDefault((EquipmentDef v) => v.unlockableName == unlockableDef.name);

            if (equipmentDef == null)
            {
                return(result);
            }
            if (equipmentDef.isBoss)
            {
                return(num2 + 1);
            }
            if (equipmentDef.isLunar)
            {
                return(num2 - 1);
            }
            return(num2);
        }
Пример #12
0
 // Token: 0x06001ADA RID: 6874 RVA: 0x00071C73 File Offset: 0x0006FE73
 private static void RegisterSurvivor(SurvivorIndex survivorIndex, SurvivorDef survivorDef)
 {
     if (survivorIndex < SurvivorIndex.Count)
     {
         survivorDef.name = survivorIndex.ToString();
     }
     survivorDef.survivorIndex = survivorIndex;
     SurvivorCatalog.survivorDefs[(int)survivorIndex] = survivorDef;
 }
Пример #13
0
        public static AiSkillHelper GetSkillHelperByIndex(SurvivorIndex index)
        {
            AiSkillHelper helper;

            if (!SkillHelperDict.TryGetValue(index, out helper))
            {
                helper = DefaultSkillHelper;
            }
            return(helper);
        }
        public void OpenPageWithCharacter(SurvivorIndex survivorIndex)
        {
            var index = survivorIndexList.FindIndex(el => el == survivorIndex);

            if (index == -1)
            {
                return;
            }
            currentPageIndex = index / survivorsPerPage;
            RebuildPage();
        }
Пример #15
0
 public static SurvivorIndex[] BuildIdealOrder(SurvivorIndex[] og_order)
 {
     VanillaCount = og_order.Length;
     SurvivorIndex[] Order = new SurvivorIndex[og_order.Length + SurvivorMods.Count];
     for (int index = 0; index < Order.Length; index++)
     {
         Order[index] = (SurvivorIndex)index;
     }
     SurvivorCount = Order.Length;
     return(Order.Length >= 24 ? Order.Take(24).ToArray() : Order.ToArray());
 }
Пример #16
0
 public static void SpawnPlayerbot(CharacterMaster owner, SurvivorIndex survivorIndex)
 {
     if (PlayerMode.Value)
     {
         SpawnPlayerbotAsPlayer(owner, survivorIndex);
     }
     else
     {
         SpawnPlayerbotAsSummon(owner, survivorIndex);
     }
 }
Пример #17
0
 /*
  * private static void BAD_GenericCharacterMain_FixedUpdate(On.EntityStates.GenericCharacterMain.orig_FixedUpdate orig, GenericCharacterMain self)
  * {
  *  // Check for jump input first, since the base function resets input
  *  CharacterBody characterBody = ReflectionUtil.GetPropertyValue<CharacterBody>(self, "characterBody");
  *  string baseNameToken = ReflectionUtil.GetFieldValue<string>(characterBody, "baseNameToken");
  *  SurvivorIndex survivorIndex = SurvivorIndex.None;
  *  bool doJump = false;
  *  Debug.Log("Searching for name token == " + baseNameToken);
  *
  *  bool isAuthority = ReflectionUtil.GetPropertyValue<bool>(self, "isAuthority");
  *  if (isAuthority)
  *  {
  *
  *      if (characterBody && JumpOverrides.ContainsKey(survivorIndex))
  *      {
  *          Debug.Log("Jump override for: " + survivorIndex);
  *
  *          ReflectionUtil.InvokeMethod(self, "GatherInputs");
  *          CharacterMotor characterMotor = ReflectionUtil.GetPropertyValue<CharacterMotor>(self, "characterMotor");
  *          bool jumpInputRecieved = ReflectionUtil.GetFieldValue<bool>(self, "jumpInputReceived");
  *          int jumpCount = ReflectionUtil.GetFieldValue<int>(characterMotor, "jumpCount");
  *          int maxJumpCount = ReflectionUtil.GetPropertyValue<int>(characterBody, "maxJumpCount");
  *          if (jumpInputRecieved && jumpCount < maxJumpCount)
  *          {
  *              doJump = true;
  *          }
  *      }
  *  }
  *  // Now call orig and override, if needed
  *  orig.Invoke(self);
  *  if(doJump)
  *  {
  *      Debug.Log($"Entering jump override state {survivorIndex} for {characterBody.name}");
  *      self.outer.SetNextState(JumpOverrides[survivorIndex]);
  *  }
  * }
  */
 public static void AddSkillOverride(ExpandedSkillSlot skillSlot, SurvivorIndex survivor, EntityState activationState)
 {
     if (skillSlot != ExpandedSkillSlot.Jump)
     {
         SkillSlot baseSlot = skillSlot.ToBaseSkillSlot();
     }
     else
     {
         JumpOverrides[survivor] = activationState;
     }
 }
Пример #18
0
        protected CustomSurvivor(SurvivorIndex index, string characterName, string primarySkillName,
                                 string secondarySkillName,
                                 string utilitySkillName, string specialSkillName)
        {
            SurvivorIndex = index;

            CharacterName      = characterName;
            PrimarySkillName   = primarySkillName;
            SecondarySkillName = secondarySkillName;
            UtilitySkillName   = utilitySkillName;
            SpecialSkillName   = specialSkillName;
        }
        private void SummonBotsHook(On.RoR2.CharacterMaster.orig_OnInventoryChanged orig, CharacterMaster self)
        {
            orig(self);

            SurvivorIndex index = SurvivorIndex.Captain;

            if ((self.playerCharacterMasterController != null) && (GetCount(self) > 0) && (GetCount(self) > botCapCount))
            {
                PlayerBotManager.SpawnPlayerbots(self, index, NumC4PTNBotsSpawned);
                botCapCount = GetCount(self);
            }
        }
        private void SummonBotsHook(On.RoR2.CharacterMaster.orig_OnInventoryChanged orig, CharacterMaster self)
        {
            orig(self);

            SurvivorIndex index = SurvivorIndex.Toolbot;

            if ((self.playerCharacterMasterController != null) && (self.inventory.GetItemCount(Index) > 0) && (self.inventory.GetItemCount(Index) > botToolCount))
            {
                PlayerBotManager.SpawnPlayerbots(self, index, NumT00LBotsSpawned);
                botToolCount = GetCount(self);
            }
        }
        protected CustomSurvivor(SurvivorIndex index, string characterName, string survivorNameToken,
                                 bool updateVanillaValues, ConfigFile configFile, ManualLogSource logger)
        {
            _updateVanillaValues = updateVanillaValues;
            SurvivorIndex        = index;
            Config = configFile;
            Logger = logger;

            CharacterName  = characterName;
            BodyDefinition = new CustomBodyDefinition(this, characterName, survivorNameToken);
            BodyDefinition.OnFieldChanged += OnBodyChangedPlaceholder;
        }
 // Token: 0x06002217 RID: 8727 RVA: 0x0009363C File Offset: 0x0009183C
 private SurvivorIndex GetSelectedSurvivorIndexFromBodyPreference()
 {
     if (this.networkUser)
     {
         SurvivorIndex survivorIndexFromBodyIndex = SurvivorCatalog.GetSurvivorIndexFromBodyIndex(this.networkUser.bodyIndexPreference);
         Debug.Log(survivorIndexFromBodyIndex);
         if (survivorIndexFromBodyIndex != SurvivorIndex.None)
         {
             return(survivorIndexFromBodyIndex);
         }
     }
     return(SurvivorIndex.Commando);
 }
        // Token: 0x06001B4E RID: 6990 RVA: 0x0007F918 File Offset: 0x0007DB18
        public static Texture GetSurvivorPortrait(SurvivorIndex survivorIndex)
        {
            SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(survivorIndex);

            if (survivorDef.bodyPrefab != null)
            {
                CharacterBody component = survivorDef.bodyPrefab.GetComponent <CharacterBody>();
                if (component)
                {
                    return(component.portraitIcon);
                }
            }
            return(null);
        }
Пример #24
0
        public void UpdateHook(On.RoR2.UI.SkillIcon.orig_Update orig, SkillIcon self)
        {
            orig.Invoke(self);

            if (self.targetSkill && self.targetSkillSlot == SkillSlot.Primary)
            {
                SurvivorIndex survivorIndex =
                    SurvivorCatalog.GetSurvivorIndexFromBodyIndex(self.targetSkill.characterBody.bodyIndex);

                if (survivorIndex == SurvivorIndex.Captain)
                {
                    self.stockText.gameObject.SetActive(true);
                    self.stockText.fontSize = 12f;
                    self.stockText.SetText(fireMode.ToString());
                }
            }
        }
Пример #25
0
        // Token: 0x0600237D RID: 9085 RVA: 0x0009B160 File Offset: 0x00099360
        private static LeaderboardController.LeaderboardInfo LeaderboardInfoFromSteamLeaderboardEntry(Leaderboard.Entry entry)
        {
            SurvivorIndex survivorIndex = SurvivorIndex.None;
            int           num           = (entry.SubScores != null && entry.SubScores.Length >= 1) ? entry.SubScores[1] : 0;

            if (num >= 0 && num < SurvivorCatalog.survivorCount)
            {
                survivorIndex = (SurvivorIndex)num;
            }
            return(new LeaderboardController.LeaderboardInfo
            {
                timeInSeconds = (float)entry.Score * 0.001f,
                survivorIndex = survivorIndex,
                userSteamID = entry.SteamId,
                rank = entry.GlobalRank
            });
        }
Пример #26
0
        public static void RegisterSkillHelper(AiSkillHelper skillHelper)
        {
            SurvivorIndex index = SurvivorIndex.None;

            SkillHelperSurvivor[] survivorAttributes = skillHelper.GetType().GetCustomAttributes(typeof(SkillHelperSurvivor), false) as SkillHelperSurvivor[];

            if (survivorAttributes.Length > 0)
            {
                SkillHelperSurvivor skillHelperSurvivor = survivorAttributes[0];
                if (skillHelperSurvivor.Index != SurvivorIndex.None)
                {
                    index = skillHelperSurvivor.Index;
                }
                else if (skillHelperSurvivor.BodyPrefabName != null)
                {
                    if (PlayerBotUtils.TryGetSurvivorIndexByBodyPrefabName(skillHelperSurvivor.BodyPrefabName, out index))
                    {
                        string name = BodyCatalog.FindBodyPrefab(skillHelperSurvivor.BodyPrefabName).GetComponent <CharacterBody>().GetDisplayName().ToLower();
                        if (!PlayerBotManager.SurvivorDict.ContainsKey(name))
                        {
                            PlayerBotManager.SurvivorDict.Add(name, index);
                        }
                        if (skillHelperSurvivor.AllowRandom)
                        {
                            PlayerBotManager.RandomSurvivorsList.Add(index);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                return;
            }

            SkillHelperDict.Add(index, skillHelper);
        }
Пример #27
0
        private static void InjectSkillDrivers(GameObject gameObject, BaseAI ai, SurvivorIndex survivorIndex)
        {
            AISkillDriver[] skillDrivers = gameObject.GetComponents <AISkillDriver>();
            if (skillDrivers != null)
            {
                // Strip skills
                StripSkills(skillDrivers);
            }

            // Add skill drivers based on class
            AiSkillHelper skillHelper = AiSkillHelperCatalog.GetSkillHelperByIndex(survivorIndex);

            skillHelper.InjectSkills(gameObject, ai);

            // Set skill drivers
            PropertyInfo property = typeof(BaseAI).GetProperty("skillDrivers");

            property.DeclaringType.GetProperty("skillDrivers");
            property.SetValue(ai, gameObject.GetComponents <AISkillDriver>(), BindingFlags.NonPublic | BindingFlags.Instance, null, null, null);
            //ai.SetFieldValue2("skillDrivers", gameObject.GetComponents<AISkillDriver>());

            // Combat update timer fix
            gameObject.AddComponent <PlayerBotCombatFix>();
        }
Пример #28
0
        // Zoom //
        private void ZoomOnSelected(On.RoR2.UI.CharacterSelectController.orig_SelectSurvivor orig, RoR2.UI.CharacterSelectController self, SurvivorIndex survivor)
        {
            orig(self, survivor);
            var cameraRig = GameObject.Find("Main Camera").gameObject.GetComponent <CameraRigController>();

            if (characterCameraSettings.TryGetValue(survivor, out float[] cameraParams))
Пример #29
0
 public static SurvivorDef GetSurvivorDef(SurvivorIndex survivorIndex) =>
 SurvivorDefinitions.FirstOrDefault(x => x.survivorIndex == survivorIndex);
Пример #30
0
        private static void ReconstructSurvivors()
        {
            SurvivorDefinitions.GroupBy(x => x.survivorIndex).Where(x => x.Count() > 1).ToList().ForEach(x => {
                R2API.Logger.LogError($"{CenterText("!ERROR!")}");
                R2API.Logger.LogError($"{CenterText($"One of your mods assigns a duplicate SurvivorIndex for \"{x.Key}\"")}");
                R2API.Logger.LogError($"{CenterText("Please ask the author to fix their mod.")}");
            });

            SurvivorCatalog.survivorMaxCount =
                Math.Max((int)SurvivorDefinitions.Select(x => x.survivorIndex).Max() + 1, 10);
            SurvivorCatalog.idealSurvivorOrder = SurvivorDefinitions.Select(x => x.survivorIndex).ToArray();

            // Only contains not null survivors
            typeof(SurvivorCatalog).SetFieldValue("_allSurvivorDefs",
                                                  SurvivorDefinitions
                                                  .OrderBy(x => x.survivorIndex)
                                                  .ToArray()
                                                  );

            // Contains null for index with no survivor
            typeof(SurvivorCatalog).SetFieldValue("survivorDefs",
                                                  Enumerable.Range(0, SurvivorCatalog.survivorMaxCount)
                                                  .Select(i => SurvivorDefinitions.FirstOrDefault(x => x.survivorIndex == (SurvivorIndex)i)
                                                          ?? new SurvivorDef {
                survivorIndex = (SurvivorIndex)i
            })
                                                  .OrderBy(x => x.survivorIndex)
                                                  .Select(x => x.bodyPrefab == null ? null : x)
                                                  .ToArray()
                                                  );

            var bodyIndexToSurvivorIndex = new SurvivorIndex[BodyCatalog.bodyCount];
            var survivorIndexToBodyIndex = new int[SurvivorCatalog.survivorMaxCount];

            foreach (var survivorDef in SurvivorDefinitions)
            {
                int bodyIndex = survivorDef.bodyPrefab.GetComponent <CharacterBody>().bodyIndex;
                bodyIndexToSurvivorIndex[bodyIndex] = survivorDef.survivorIndex;
                survivorIndexToBodyIndex[(int)survivorDef.survivorIndex] = bodyIndex;
            }

            typeof(SurvivorCatalog).SetFieldValue("bodyIndexToSurvivorIndex", bodyIndexToSurvivorIndex);
            typeof(SurvivorCatalog).SetFieldValue("survivorIndexToBodyIndex", survivorIndexToBodyIndex);

            var parent = ViewablesCatalog.FindNode("/Survivors/")
                         ?? new ViewablesCatalog.Node("Survivors", true);

            if (parent.parent == null)
            {
                ViewablesCatalog.AddNodeToRoot(parent);
            }

            foreach (var survivor in SurvivorDefinitions)
            {
                var name = survivor.survivorIndex.ToString();

                var child =
                    ViewablesCatalog.FindNode(parent.fullName + name)
                    ?? new ViewablesCatalog.Node(name, false, parent);

                child.shouldShowUnviewed = userProfile =>
                                           !string.IsNullOrEmpty(survivor.unlockableName) &&
                                           survivor.survivorIndex < SurvivorIndex.Count &&
                                           userProfile.HasSurvivorUnlocked(survivor.survivorIndex) &&
                                           !userProfile.HasViewedViewable(child.fullName)
                ;
            }

            Debug.Log("Re-setting all survivor nodes, duplicates may occur. This is no problem.");
            ViewablesCatalog.AddNodeToRoot(parent);
            Debug.Log("Re-setting survivor nodes complete.");

            // Survivors over the builtin limit will be returned as null from SurvivorCatalog.GetSurvivorDef
            // This is a quick check if the MonoMod component is installed correctly.
            var overLimit = SurvivorDefinitions.FirstOrDefault(x => x.survivorIndex >= SurvivorIndex.Count);

            if (overLimit == null || SurvivorCatalog.GetSurvivorDef(overLimit.survivorIndex) != null)
            {
                return;
            }

            R2API.Logger.LogError($"{CenterText("!ERROR!")}");
            R2API.Logger.LogError($"{CenterText("MonoMod component of R2API is not installed correctly!")}");
            R2API.Logger.LogError($"{CenterText("Please copy Assembly-CSharp.R2API.mm.dll to BepInEx/monomod.")}");
        }