// Token: 0x060020EC RID: 8428 RVA: 0x0009A958 File Offset: 0x00098B58 private void RebuildLocal() { SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(this.selectedSurvivorIndex); this.survivorName.text = survivorDef.displayNameToken; if (survivorDef.descriptionToken != null) { this.survivorDescription.text = Language.GetString(survivorDef.descriptionToken); } SkillLocator component = survivorDef.bodyPrefab.GetComponent <SkillLocator>(); if (component) { this.RebuildStrip(this.primarySkillStrip, component.primary); this.RebuildStrip(this.secondarySkillStrip, component.secondary); this.RebuildStrip(this.utilitySkillStrip, component.utility); this.RebuildStrip(this.specialSkillStrip, component.special); this.RebuildStrip(this.passiveSkillStrip, component.passiveSkill); } Image[] array = this.primaryColorImages; for (int i = 0; i < array.Length; i++) { array[i].color = survivorDef.primaryColor; } TextMeshProUGUI[] array2 = this.primaryColorTexts; for (int i = 0; i < array2.Length; i++) { array2[i].color = survivorDef.primaryColor; } }
// Token: 0x060023FB RID: 9211 RVA: 0x000A8FCC File Offset: 0x000A71CC private void Rebuild() { SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(this.survivorIndex); if (survivorDef != null) { GameObject bodyPrefab = survivorDef.bodyPrefab; if (bodyPrefab) { CharacterBody component = bodyPrefab.GetComponent <CharacterBody>(); if (component) { if (this.survivorIcon) { this.survivorIcon.texture = component.portraitIcon; } string viewableName = string.Format(CultureInfo.InvariantCulture, "/Survivors/{0}", this.survivorIndex.ToString()); if (this.viewableTag) { this.viewableTag.viewableName = viewableName; this.viewableTag.Refresh(); } if (this.viewableTrigger) { this.viewableTrigger.viewableName = viewableName; } } } } }
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); }
private void CharacterSelectController_SelectSurvivor(On.RoR2.UI.CharacterSelectController.orig_SelectSurvivor orig, RoR2.UI.CharacterSelectController self, SurvivorIndex survivor) { orig(self, survivor); var skillPreview = UnityEngine.Object.FindObjectOfType <SkillPreview>(); skillPreview.UpdateInstance(SurvivorCatalog.GetSurvivorDef(survivor)); }
public static void SpawnRandomPlayerbots(CharacterMaster owner, int amount) { int lastCharacterType = -1; for (int i = 0; i < amount; i++) { int randomSurvivorIndex = -1; do { randomSurvivorIndex = random.Next(0, RandomSurvivorsList.Count); }while ((randomSurvivorIndex == lastCharacterType || !SurvivorCatalog.GetSurvivorDef((SurvivorIndex)RandomSurvivorsList[randomSurvivorIndex]).CheckRequiredExpansionEnabled()) && RandomSurvivorsList.Count > 1); SpawnPlayerbot(owner, RandomSurvivorsList[randomSurvivorIndex]); lastCharacterType = randomSurvivorIndex; } }
// Token: 0x0600259A RID: 9626 RVA: 0x000A39F4 File Offset: 0x000A1BF4 private void Rebuild() { SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(this.survivorIndex); if (survivorDef != null) { GameObject bodyPrefab = survivorDef.bodyPrefab; if (bodyPrefab) { CharacterBody component = bodyPrefab.GetComponent <CharacterBody>(); if (component) { if (this.survivorIcon) { this.survivorIcon.texture = component.portraitIcon; } string viewableName = string.Format(CultureInfo.InvariantCulture, "/Survivors/{0}", this.survivorIndex.ToString()); if (this.viewableTag) { this.viewableTag.viewableName = viewableName; this.viewableTag.Refresh(); } if (this.loadoutViewableTag) { this.loadoutViewableTag.viewableName = string.Format(CultureInfo.InvariantCulture, "/Loadout/Bodies/{0}/", BodyCatalog.GetBodyName(SurvivorCatalog.GetBodyIndexFromSurvivorIndex(this.survivorIndex))); this.loadoutViewableTag.Refresh(); } if (this.viewableTrigger) { this.viewableTrigger.viewableName = viewableName; } if (this.tooltipProvider) { UnlockableDef unlockableDef = UnlockableCatalog.GetUnlockableDef(survivorDef.unlockableName); if (unlockableDef != null) { this.tooltipProvider.titleToken = "UNIDENTIFIED"; this.tooltipProvider.titleColor = Color.gray; this.tooltipProvider.overrideBodyText = unlockableDef.getHowToUnlockString(); } } } } } }
private static void ShowEndgameText(ConCommandArgs args) { if (args.GetArgString(0).ToLower() == "custom") { flavorText = args.GetArgString(1); } else { var bodyIndex = BodyCatalog.FindBodyIndexCaseInsensitive(args.GetArgString(0)); if (bodyIndex < 0) { Debug.Log("Couldn't find body index!"); return; } var survivorIndex = SurvivorCatalog.GetSurvivorIndexFromBodyIndex(bodyIndex); if (survivorIndex < 0) { Debug.Log("Couldn't find survivor index!"); return; } SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(survivorIndex); if (!survivorDef) { Debug.Log("SurvivorDef not found!"); return; } bool isWinQuote = true; if (args.Count == 2) { if (args.GetArgString(1).ToLower() == "fail") { isWinQuote = false; } } flavorText = GetOutroText(survivorDef, isWinQuote); } Debug.Log("Outro Text: " + flavorText); Debug.Log(Language.GetString(flavorText)); RoR2.Console.instance.SubmitCmd(null, "set_scene outro", false); }
public void Awake() { if (!characterBody) { characterBody = gameObject.GetComponent <CharacterBody>(); } isNetwork = NetworkServer.active; this.localUser = LocalUserManager.readOnlyLocalUsersList[0]; foreach (var entityStateMachine in gameObject.GetComponents <EntityStateMachine>()) { if (entityStateMachine.customName == "Body") { outer = entityStateMachine; break; } } survivorDef = SurvivorCatalog.GetSurvivorDef(SurvivorCatalog.GetSurvivorIndexFromBodyIndex(characterBody.bodyIndex)); }
public void RandomizeCharacter() { if ((!PreGameController.instance || !PreGameController.instance.IsCharacterSwitchingCurrentlyAllowed() || !characterSelectController) && !eclipseRunScreenController) { return; } var localUser = ((MPEventSystem)EventSystem.current).localUser; var currentIndex = characterSelectController?.selectedSurvivorIndex ?? (SurvivorIndex)EclipseRun.cvEclipseSurvivorIndex.value; var canSelectSameCharacter = ConfigHelper.CanSelectSameCharacter.Value; var survivors = SurvivorCatalog.orderedSurvivorDefs.Where(survivorDef => (canSelectSameCharacter || currentIndex != survivorDef.survivorIndex) && !survivorDef.hidden && SurvivorCatalog.SurvivorIsUnlockedOnThisClient(survivorDef.survivorIndex)); var randomIndex = survivors.ElementAt(UnityEngine.Random.Range(0, survivors.Count())).survivorIndex; if (characterSelectController) { characterSelectController.SelectSurvivor(randomIndex); characterSelectController.SetSurvivorInfoPanelActive(true); } if (eclipseRunScreenController) { eclipseRunScreenController.SelectSurvivor(randomIndex); } if (RandomCharacterSelectionPlugin.ScrollableLobbyUILoaded) { ScrollableLobbyUISelectCharacter(randomIndex); } localUser.currentNetworkUser?.CallCmdSetBodyPreference(BodyCatalog.FindBodyIndex(SurvivorCatalog.GetSurvivorDef(randomIndex).bodyPrefab)); }
// A hacky method. Don't ask questions. private static void SpawnPlayerbotAsSummon(CharacterMaster owner, SurvivorIndex survivorIndex) { SurvivorDef def = SurvivorCatalog.GetSurvivorDef(survivorIndex); if (def == null) { return; } GameObject bodyPrefab = def.bodyPrefab; if (bodyPrefab == null) { return; } // Get card SpawnCard card = (SpawnCard)Resources.Load("SpawnCards/CharacterSpawnCards/cscBeetleGuardAlly"); // Spawn request DirectorSpawnRequest spawnRequest = new DirectorSpawnRequest(card, new DirectorPlacementRule { placementMode = DirectorPlacementRule.PlacementMode.Approximate, minDistance = 3f, maxDistance = 40f, spawnOnTarget = owner.GetBody().transform }, RoR2Application.rng); spawnRequest.ignoreTeamMemberLimit = true; spawnRequest.teamIndexOverride = new TeamIndex?(TeamIndex.Player); //spawnRequest.summonerBodyObject = owner.GetBody().gameObject; // Spawn GameObject gameObject = DirectorCore.instance.TrySpawnObject(spawnRequest); if (gameObject) { CharacterMaster master = gameObject.GetComponent <CharacterMaster>(); AIOwnership aiOwnership = gameObject.AddComponent <AIOwnership>() as AIOwnership; BaseAI ai = gameObject.GetComponent <BaseAI>(); if (master) { master.name = "PlayerBot"; master.bodyPrefab = bodyPrefab; SetRandomSkin(master, bodyPrefab); master.Respawn(master.GetBody().transform.position, master.GetBody().transform.rotation); master.teamIndex = TeamIndex.Player; master.GiveMoney(owner.money); master.inventory.CopyItemsFrom(owner.inventory); master.inventory.GiveItem(ItemIndex.DrizzlePlayerHelper, 1); // Allow the bots to spawn in the next stage master.destroyOnBodyDeath = false; master.gameObject.AddComponent <SetDontDestroyOnLoad>(); } if (aiOwnership) { aiOwnership.ownerMaster = owner; } if (ai) { ai.name = "PlayerBot"; ai.leader.gameObject = owner.GetBody().gameObject; ai.fullVision = true; ai.aimVectorDampTime = .01f; ai.aimVectorMaxSpeed = 180f; } InjectSkillDrivers(gameObject, ai, survivorIndex); if (AutoPurchaseItems.Value) { // Add item manager ItemManager itemManager = gameObject.AddComponent <ItemManager>() as ItemManager; } // Add to playerbot list playerbots.Add(gameObject); } }
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.")}"); }
// Token: 0x06002560 RID: 9568 RVA: 0x000A2874 File Offset: 0x000A0A74 private void Update() { if (this.targetSkill) { if (this.tooltipProvider) { Color color = Color.gray; SurvivorIndex survivorIndexFromBodyIndex = SurvivorCatalog.GetSurvivorIndexFromBodyIndex(this.targetSkill.characterBody.bodyIndex); if (survivorIndexFromBodyIndex != SurvivorIndex.None) { color = SurvivorCatalog.GetSurvivorDef(survivorIndexFromBodyIndex).primaryColor; float h; float s; float num; Color.RGBToHSV(color, out h, out s, out num); num = ((num > 0.7f) ? 0.7f : num); color = Color.HSVToRGB(h, s, num); } this.tooltipProvider.titleColor = color; this.tooltipProvider.titleToken = this.targetSkill.skillNameToken; this.tooltipProvider.bodyToken = this.targetSkill.skillDescriptionToken; } float cooldownRemaining = this.targetSkill.cooldownRemaining; float num2 = this.targetSkill.CalculateFinalRechargeInterval(); int stock = this.targetSkill.stock; bool flag = stock > 0 || cooldownRemaining == 0f; bool flag2 = this.targetSkill.IsReady(); if (this.previousStock < stock) { Util.PlaySound("Play_UI_cooldownRefresh", RoR2Application.instance.gameObject); } if (this.animator) { if (this.targetSkill.maxStock > 1) { this.animator.SetBool(this.animatorStackString, true); } else { this.animator.SetBool(this.animatorStackString, false); } } if (this.isReadyPanelObject) { this.isReadyPanelObject.SetActive(flag2); } if (!this.wasReady && flag && this.flashPanelObject) { this.flashPanelObject.SetActive(true); } if (this.cooldownText) { if (flag) { this.cooldownText.gameObject.SetActive(false); } else { SkillIcon.sharedStringBuilder.Clear(); SkillIcon.sharedStringBuilder.AppendInt(Mathf.CeilToInt(cooldownRemaining), 0U, uint.MaxValue); this.cooldownText.SetText(SkillIcon.sharedStringBuilder); this.cooldownText.gameObject.SetActive(true); } } if (this.iconImage) { this.iconImage.enabled = true; this.iconImage.color = (flag2 ? Color.white : Color.gray); this.iconImage.sprite = this.targetSkill.icon; } if (this.cooldownRemapPanel) { float num3 = 1f; if (num2 >= Mathf.Epsilon) { num3 = 1f - cooldownRemaining / num2; } float num4 = num3; this.cooldownRemapPanel.enabled = (num4 < 1f); this.cooldownRemapPanel.color = new Color(1f, 1f, 1f, num3); } if (this.stockText) { if (this.targetSkill.maxStock > 1) { this.stockText.gameObject.SetActive(true); SkillIcon.sharedStringBuilder.Clear(); SkillIcon.sharedStringBuilder.AppendInt(this.targetSkill.stock, 0U, uint.MaxValue); this.stockText.SetText(SkillIcon.sharedStringBuilder); } else { this.stockText.gameObject.SetActive(false); } } this.wasReady = flag; this.previousStock = stock; return; } if (this.tooltipProvider) { this.tooltipProvider.bodyColor = Color.gray; this.tooltipProvider.titleToken = ""; this.tooltipProvider.bodyToken = ""; } if (this.cooldownText) { this.cooldownText.gameObject.SetActive(false); } if (this.stockText) { this.stockText.gameObject.SetActive(false); } if (this.iconImage) { this.iconImage.enabled = false; this.iconImage.sprite = null; } }
private static void SpawnPlayerbotAsPlayer(CharacterMaster owner, SurvivorIndex survivorIndex) { SurvivorDef def = SurvivorCatalog.GetSurvivorDef(survivorIndex); if (def == null) { return; } GameObject bodyPrefab = def.bodyPrefab; if (bodyPrefab == null) { return; } // Card PlayerBotSpawnCard card = ScriptableObject.CreateInstance <PlayerBotSpawnCard>(); card.hullSize = HullClassification.Human; card.nodeGraphType = MapNodeGroup.GraphType.Ground; card.occupyPosition = false; card.sendOverNetwork = true; card.forbiddenFlags = NodeFlags.NoCharacterSpawn; card.prefab = Resources.Load <GameObject>("prefabs/charactermasters/CommandoMaster"); card.playerbotName = bodyPrefab.GetComponent <CharacterBody>().GetDisplayName(); card.bodyPrefab = bodyPrefab; // Spawn DirectorSpawnRequest spawnRequest = new DirectorSpawnRequest(card, new DirectorPlacementRule { placementMode = DirectorPlacementRule.PlacementMode.Approximate, minDistance = 3f, maxDistance = 40f, spawnOnTarget = owner.GetBody().transform }, RoR2Application.rng); spawnRequest.ignoreTeamMemberLimit = true; //spawnRequest.summonerBodyObject = owner.GetBody().gameObject; spawnRequest.teamIndexOverride = new TeamIndex?(TeamIndex.Player); GameObject gameObject = DirectorCore.instance.TrySpawnObject(spawnRequest); if (gameObject) { // Add components EntityStateMachine stateMachine = gameObject.AddComponent <PlayerBotStateMachine>() as EntityStateMachine; BaseAI ai = gameObject.AddComponent <PlayerBotBaseAI>() as BaseAI; AIOwnership aiOwnership = gameObject.AddComponent <AIOwnership>() as AIOwnership; aiOwnership.ownerMaster = owner; CharacterMaster master = gameObject.GetComponent <CharacterMaster>(); PlayerCharacterMasterController playerMaster = gameObject.GetComponent <PlayerCharacterMasterController>(); // Random skin SetRandomSkin(master, bodyPrefab); // Set commponent values master.SetFieldValue("aiComponents", gameObject.GetComponents <BaseAI>()); master.GiveMoney(owner.money); master.inventory.CopyItemsFrom(owner.inventory); master.inventory.GiveItem(ItemIndex.DrizzlePlayerHelper, 1); master.destroyOnBodyDeath = false; // Allow the bots to spawn in the next stage playerMaster.name = master.GetBody().GetDisplayName(); // Add custom skills InjectSkillDrivers(gameObject, ai, survivorIndex); if (AutoPurchaseItems.Value) { // Add item manager ItemManager itemManager = gameObject.AddComponent <ItemManager>() as ItemManager; } // Add to playerbot list playerbots.Add(gameObject); // Cleanup Destroy(card); } }
// Token: 0x060020F1 RID: 8433 RVA: 0x0009ABA4 File Offset: 0x00098DA4 private void Update() { this.SetEventSystem(this.eventSystemLocator.eventSystem); if (this.previousSurvivorIndex != this.selectedSurvivorIndex) { this.RebuildLocal(); this.previousSurvivorIndex = this.selectedSurvivorIndex; } if (this.characterDisplayPads.Length != 0) { for (int i = 0; i < this.characterDisplayPads.Length; i++) { CharacterSelectController.CharacterPad characterPad = this.characterDisplayPads[i]; NetworkUser networkUser = null; List <NetworkUser> list = new List <NetworkUser>(NetworkUser.readOnlyInstancesList.Count); list.AddRange(NetworkUser.readOnlyLocalPlayersList); for (int j = 0; j < NetworkUser.readOnlyInstancesList.Count; j++) { NetworkUser item = NetworkUser.readOnlyInstancesList[j]; if (!list.Contains(item)) { list.Add(item); } } if (i < list.Count) { networkUser = list[i]; } if (networkUser) { GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(networkUser.bodyIndexPreference); SurvivorDef survivorDef = SurvivorCatalog.FindSurvivorDefFromBody(bodyPrefab); if (survivorDef != null) { SurvivorDef survivorDef2 = SurvivorCatalog.GetSurvivorDef(characterPad.displaySurvivorIndex); bool flag = true; if (survivorDef2 != null && survivorDef2.bodyPrefab == bodyPrefab) { flag = false; } if (flag) { GameObject displayPrefab = survivorDef.displayPrefab; this.ClearPadDisplay(characterPad); if (displayPrefab) { characterPad.displayInstance = UnityEngine.Object.Instantiate <GameObject>(displayPrefab, characterPad.padTransform.position, characterPad.padTransform.rotation, characterPad.padTransform); } characterPad.displaySurvivorIndex = survivorDef.survivorIndex; } } else { this.ClearPadDisplay(characterPad); } } else { this.ClearPadDisplay(characterPad); } if (!characterPad.padTransform) { return; } this.characterDisplayPads[i] = characterPad; if (this.characterDisplayPads[i].padTransform) { this.characterDisplayPads[i].padTransform.gameObject.SetActive(this.characterDisplayPads[i].displayInstance != null); } } } if (!RoR2Application.isInSinglePlayer) { bool flag2 = this.IsClientReady(); this.readyButton.gameObject.SetActive(!flag2); this.unreadyButton.gameObject.SetActive(flag2); } }
// Token: 0x06002598 RID: 9624 RVA: 0x000A38C4 File Offset: 0x000A1AC4 public void PushSurvivorIndexToCharacterSelect(CharacterSelectController chararcterSelectController) { if (!PreGameController.instance || !PreGameController.instance.IsCharacterSwitchingCurrentlyAllowed()) { return; } chararcterSelectController.SelectSurvivor(this.survivorIndex); LocalUser localUser = ((MPEventSystem)EventSystem.current).localUser; if (localUser.eventSystem == EventSystem.current) { NetworkUser currentNetworkUser = localUser.currentNetworkUser; if (currentNetworkUser == null) { return; } currentNetworkUser.CallCmdSetBodyPreference(BodyCatalog.FindBodyIndex(SurvivorCatalog.GetSurvivorDef(this.survivorIndex).bodyPrefab)); } }
// Token: 0x06002210 RID: 8720 RVA: 0x0009325C File Offset: 0x0009145C private void RebuildLocal() { Loadout loadout = new Loadout(); LocalUser localUser = this.localUser; if (localUser != null) { UserProfile userProfile = localUser.userProfile; if (userProfile != null) { userProfile.CopyLoadout(loadout); } } SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(this.selectedSurvivorIndex); int bodyIndexFromSurvivorIndex = SurvivorCatalog.GetBodyIndexFromSurvivorIndex(this.selectedSurvivorIndex); Color color = Color.white; string text = string.Empty; string text2 = string.Empty; string viewableName = string.Empty; if (survivorDef != null) { color = survivorDef.primaryColor; text = Language.GetString(survivorDef.displayNameToken); text2 = Language.GetString(survivorDef.descriptionToken); } List <CharacterSelectController.StripDisplayData> list = new List <CharacterSelectController.StripDisplayData>(); if (bodyIndexFromSurvivorIndex != -1) { GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(bodyIndexFromSurvivorIndex); SkillLocator component = bodyPrefab.GetComponent <SkillLocator>(); if (component.passiveSkill.enabled) { list.Add(new CharacterSelectController.StripDisplayData { enabled = true, primaryColor = color, icon = component.passiveSkill.icon, titleString = Language.GetString(component.passiveSkill.skillNameToken), descriptionString = Language.GetString(component.passiveSkill.skillDescriptionToken) }); } GenericSkill[] components = bodyPrefab.GetComponents <GenericSkill>(); for (int i = 0; i < components.Length; i++) { uint skillVariant = loadout.bodyLoadoutManager.GetSkillVariant(bodyIndexFromSurvivorIndex, i); SkillDef skillDef = components[i].skillFamily.variants[(int)skillVariant].skillDef; list.Add(new CharacterSelectController.StripDisplayData { enabled = true, primaryColor = color, icon = skillDef.icon, titleString = Language.GetString(skillDef.skillNameToken), descriptionString = Language.GetString(skillDef.skillDescriptionToken) }); } viewableName = "/Loadout/Bodies/" + BodyCatalog.GetBodyName(bodyIndexFromSurvivorIndex) + "/"; } this.skillStripAllocator.AllocateElements(list.Count); for (int j = 0; j < list.Count; j++) { this.RebuildStrip(this.skillStripAllocator.elements[j], list[j]); } this.survivorName.SetText(text); this.survivorDescription.SetText(text2); Image[] array = this.primaryColorImages; for (int k = 0; k < array.Length; k++) { array[k].color = color; } TextMeshProUGUI[] array2 = this.primaryColorTexts; for (int k = 0; k < array2.Length; k++) { array2[k].color = color; } this.loadoutViewableTag.viewableName = viewableName; }
private void RebuildPage() { var survivorIndicies = survivorIndexList.Skip(currentPageIndex * survivorsPerPage).Take(survivorsPerPage).ToArray(); var elements = survivorIconControllers.elements; for (var index = 0; index < elements.Count; ++index) { var element = elements[index]; if (index >= survivorIndicies.Length) { element.gameObject.SetActive(false); continue; } element.gameObject.SetActive(true); var survivorIndex = survivorIndicies[index]; var survivorDef = SurvivorCatalog.GetSurvivorDef(survivorIndex); element.survivorIndex = survivorIndex; var buttonComponent = element.GetComponent <HGButton>(); var survivorDescription = Language.GetString(survivorDef.descriptionToken); var length = survivorDescription.IndexOf(Environment.NewLine); if (length != -1) { survivorDescription = survivorDescription.Substring(0, length); } var unlockableDef = UnlockableCatalog.GetUnlockableDef(survivorDef.unlockableName); if (unlockableDef != null) { if (SurvivorCatalog.SurvivorIsUnlockedOnThisClient(survivorIndex)) { buttonComponent.hoverToken = Language.GetStringFormatted("CHARACTER_DESCRIPTION_AND_UNLOCK_FORMAT", survivorDescription, unlockableDef.getUnlockedString()); } else { buttonComponent.hoverToken = Language.GetStringFormatted("CHARACTER_DESCRIPTION_AND_UNLOCK_FORMAT", Language.GetString("UNIDENTIFIED"), unlockableDef.getHowToUnlockString()); } } else { buttonComponent.hoverToken = survivorDescription; } element.shouldRebuild = true; } for (var index = 0; index < fillerCount; index++) { fillerIcons[index].gameObject.SetActive(IsOnLastPage); } if (buttonHistory && buttonHistory.lastRememberedGameObject) { if (eventSystemLocator && eventSystemLocator.eventSystem) { if (eventSystemLocator.eventSystem.currentInputSource == MPEventSystem.InputSource.Gamepad) { if (buttonHistory.lastRememberedGameObject.activeInHierarchy) { buttonHistory.lastRememberedGameObject.GetComponent <HGButton>().OnSelect(new BaseEventData(EventSystem.current)); } else { elements.LastOrDefault(el => el.gameObject.activeInHierarchy)?.GetComponent <HGButton>().Select(); } } } } previousButtonComponent.interactable = !IsOnFirstPage; nextButtonComponent.interactable = !IsOnLastPage; }
// Token: 0x06002219 RID: 8729 RVA: 0x000936D8 File Offset: 0x000918D8 private void Update() { this.SetEventSystem(this.eventSystemLocator.eventSystem); if (this.previousSurvivorIndex != this.selectedSurvivorIndex) { this.RebuildLocal(); this.previousSurvivorIndex = this.selectedSurvivorIndex; } if (this.characterDisplayPads.Length != 0) { List <NetworkUser> sortedNetworkUsersList = this.GetSortedNetworkUsersList(); for (int i = 0; i < this.characterDisplayPads.Length; i++) { ref CharacterSelectController.CharacterPad ptr = ref this.characterDisplayPads[i]; NetworkUser networkUser = null; if (i < sortedNetworkUsersList.Count) { networkUser = sortedNetworkUsersList[i]; } if (networkUser) { GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(networkUser.bodyIndexPreference); SurvivorDef survivorDef = SurvivorCatalog.FindSurvivorDefFromBody(bodyPrefab); if (survivorDef != null) { SurvivorDef survivorDef2 = SurvivorCatalog.GetSurvivorDef(ptr.displaySurvivorIndex); bool flag = true; if (survivorDef2 != null && survivorDef2.bodyPrefab == bodyPrefab) { flag = false; } if (flag) { GameObject displayPrefab = survivorDef.displayPrefab; this.ClearPadDisplay(ptr); if (displayPrefab) { ptr.displayInstance = UnityEngine.Object.Instantiate <GameObject>(displayPrefab, ptr.padTransform.position, ptr.padTransform.rotation, ptr.padTransform); } ptr.displaySurvivorIndex = survivorDef.survivorIndex; this.OnNetworkUserLoadoutChanged(networkUser); } } else { this.ClearPadDisplay(ptr); } } else { this.ClearPadDisplay(ptr); } if (!ptr.padTransform) { return; } if (this.characterDisplayPads[i].padTransform) { this.characterDisplayPads[i].padTransform.gameObject.SetActive(this.characterDisplayPads[i].displayInstance != null); } } }
private static void SpawnPlayerbotAsPlayer(CharacterMaster owner, SurvivorIndex survivorIndex) { SurvivorDef def = SurvivorCatalog.GetSurvivorDef(survivorIndex); if (def == null) { return; } else if (!def.CheckRequiredExpansionEnabled()) { Debug.Log("You do not have the proper expansion enabled."); return; } GameObject bodyPrefab = def.bodyPrefab; if (bodyPrefab == null) { return; } // Card PlayerBotSpawnCard card = ScriptableObject.CreateInstance <PlayerBotSpawnCard>(); card.hullSize = HullClassification.Human; card.nodeGraphType = MapNodeGroup.GraphType.Ground; card.occupyPosition = false; card.sendOverNetwork = true; card.forbiddenFlags = NodeFlags.NoCharacterSpawn; card.prefab = LegacyResourcesAPI.Load <GameObject>("Prefabs/CharacterMasters/CommandoMaster"); //card.bodyPrefab = bodyPrefab; // Spawn DirectorSpawnRequest spawnRequest = new DirectorSpawnRequest(card, new DirectorPlacementRule { placementMode = DirectorPlacementRule.PlacementMode.Approximate, minDistance = 3f, maxDistance = 40f, spawnOnTarget = owner.GetBody().transform }, RoR2Application.rng); spawnRequest.ignoreTeamMemberLimit = true; spawnRequest.teamIndexOverride = new TeamIndex?(TeamIndex.Player); spawnRequest.onSpawnedServer = result => { GameObject gameObject = result.spawnedInstance; if (gameObject) { // Add components EntityStateMachine stateMachine = gameObject.AddComponent <PlayerBotStateMachine>() as EntityStateMachine; BaseAI ai = gameObject.AddComponent <PlayerBotBaseAI>() as BaseAI; AIOwnership aiOwnership = gameObject.AddComponent <AIOwnership>() as AIOwnership; aiOwnership.ownerMaster = owner; CharacterMaster master = gameObject.GetComponent <CharacterMaster>(); PlayerCharacterMasterController playerMaster = gameObject.GetComponent <PlayerCharacterMasterController>(); playerMaster.name = "PlayerBot"; // Required to bypass entitlements master.bodyPrefab = bodyPrefab; master.Respawn(master.transform.position, master.transform.rotation); // Random skin SetRandomSkin(master, bodyPrefab); // Set commponent values master.SetFieldValue("aiComponents", gameObject.GetComponents <BaseAI>()); master.destroyOnBodyDeath = false; // Allow the bots to spawn in the next stage // Starting items GiveStartingItems(owner, master); // Add custom skills InjectSkillDrivers(gameObject, ai, survivorIndex); if (AutoPurchaseItems.Value) { // Add item manager ItemManager itemManager = gameObject.AddComponent <ItemManager>() as ItemManager; } // Add to playerbot list playerbots.Add(gameObject); } }; DirectorCore.instance.TrySpawnObject(spawnRequest); // Cleanup Destroy(card); }
private static void SpawnPlayerbotAsSummon(CharacterMaster owner, SurvivorIndex survivorIndex) { SurvivorDef def = SurvivorCatalog.GetSurvivorDef(survivorIndex); if (def == null) { return; } GameObject bodyPrefab = def.bodyPrefab; if (bodyPrefab == null) { return; } // Card PlayerBotSpawnCard card = ScriptableObject.CreateInstance <PlayerBotSpawnCard>(); card.hullSize = HullClassification.Human; card.nodeGraphType = MapNodeGroup.GraphType.Ground; card.occupyPosition = false; card.sendOverNetwork = true; card.forbiddenFlags = NodeFlags.NoCharacterSpawn; card.prefab = Resources.Load <GameObject>("prefabs/charactermasters/CommandoMonsterMaster"); card.playerbotName = bodyPrefab.GetComponent <CharacterBody>().GetDisplayName(); card.bodyPrefab = bodyPrefab; // Spawn request DirectorSpawnRequest spawnRequest = new DirectorSpawnRequest(card, new DirectorPlacementRule { placementMode = DirectorPlacementRule.PlacementMode.Approximate, minDistance = 3f, maxDistance = 40f, spawnOnTarget = owner.GetBody().transform }, RoR2Application.rng); spawnRequest.ignoreTeamMemberLimit = true; spawnRequest.teamIndexOverride = new TeamIndex?(TeamIndex.Player); //spawnRequest.summonerBodyObject = owner.GetBody().gameObject; // Spawn GameObject gameObject = DirectorCore.instance.TrySpawnObject(spawnRequest); if (gameObject) { CharacterMaster master = gameObject.GetComponent <CharacterMaster>(); BaseAI ai = gameObject.GetComponent <BaseAI>(); AIOwnership aiOwnership = gameObject.AddComponent <AIOwnership>() as AIOwnership; aiOwnership.ownerMaster = owner; if (master) { master.name = "PlayerBot"; SetRandomSkin(master, bodyPrefab); master.teamIndex = TeamIndex.Player; GiveStartingItems(owner, master); // Allow the bots to spawn in the next stage master.destroyOnBodyDeath = false; master.gameObject.AddComponent <SetDontDestroyOnLoad>(); } if (ai) { ai.name = "PlayerBot"; ai.leader.gameObject = owner.GetBody().gameObject; ai.neverRetaliateFriendlies = true; ai.fullVision = true; ai.aimVectorDampTime = .01f; ai.aimVectorMaxSpeed = 180f; } InjectSkillDrivers(gameObject, ai, survivorIndex); if (AutoPurchaseItems.Value) { // Add item manager ItemManager itemManager = gameObject.AddComponent <ItemManager>() as ItemManager; } // Add to playerbot list playerbots.Add(gameObject); } }
private static SkillLocator FindSkillLocator(SurvivorIndex survivor) { SkillLocator locator = SurvivorCatalog.GetSurvivorDef(survivor)?.bodyPrefab.GetComponent <SkillLocator>(); return(locator); }
public static GenericSkill GetSkill(ExpandedSkillSlot expandedSlot, SurvivorIndex survivor) { GameObject survivorbodyPrefab = SurvivorCatalog.GetSurvivorDef(survivor).bodyPrefab; return(GetSkill(expandedSlot, survivorbodyPrefab)); }