public void OnContentLoad() { // Set survivor dict SurvivorDict.Add("mult", SurvivorCatalog.FindSurvivorIndex("Toolbot")); SurvivorDict.Add("mul-t", SurvivorCatalog.FindSurvivorIndex("Toolbot")); SurvivorDict.Add("toolbot", SurvivorCatalog.FindSurvivorIndex("Toolbot")); SurvivorDict.Add("hunt", SurvivorCatalog.FindSurvivorIndex("Huntress")); SurvivorDict.Add("huntress", SurvivorCatalog.FindSurvivorIndex("Huntress")); SurvivorDict.Add("engi", SurvivorCatalog.FindSurvivorIndex("Engi")); SurvivorDict.Add("engineer", SurvivorCatalog.FindSurvivorIndex("Engi")); SurvivorDict.Add("mage", SurvivorCatalog.FindSurvivorIndex("Mage")); SurvivorDict.Add("arti", SurvivorCatalog.FindSurvivorIndex("Mage")); SurvivorDict.Add("artificer", SurvivorCatalog.FindSurvivorIndex("Mage")); SurvivorDict.Add("merc", SurvivorCatalog.FindSurvivorIndex("Merc")); SurvivorDict.Add("mercenary", SurvivorCatalog.FindSurvivorIndex("Merc")); SurvivorDict.Add("rex", SurvivorCatalog.FindSurvivorIndex("Treebot")); SurvivorDict.Add("treebot", SurvivorCatalog.FindSurvivorIndex("Treebot")); SurvivorDict.Add("croco", SurvivorCatalog.FindSurvivorIndex("Croco")); SurvivorDict.Add("capt", SurvivorCatalog.FindSurvivorIndex("Captain")); // Add skill helpers AiSkillHelperCatalog.Populate(); // Config InitialBots = new ConfigEntry <int> [RandomSurvivorsList.Count]; for (int i = 0; i < RandomSurvivorsList.Count; i++) { string name = BodyCatalog.GetBodyName(SurvivorCatalog.GetBodyIndexFromSurvivorIndex(RandomSurvivorsList[i])).Replace("\'", ""); InitialBots[i] = Config.Bind("Starting Bots", "StartingBots." + name, 0, "Starting amount of bots to spawn at the start of a run. (" + name + ")"); } }
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); }
public override void SetupLate() { base.SetupLate(); ToolbotBodyIndex = (int)SurvivorCatalog.GetBodyIndexFromSurvivorIndex(SurvivorCatalog.FindSurvivorIndex("Toolbot")); if (ToolbotBodyIndex < 0) { Debug.Log("SEARCHME: Failed finding toolbot"); } }
private ModelSkinController AddDefaultSkin(SurvivorDef def) { base.Logger.LogInfo("Adding default skin to " + def); ModelSkinController component = def.bodyPrefab.GetComponent <ModelLocator>().modelTransform.gameObject.AddComponent <ModelSkinController>(); CharacterModel model = def.bodyPrefab.GetComponent <ModelLocator>().modelTransform.GetComponent <CharacterModel>(); LoadoutAPI.SkinDefInfo skinDefInfo = default(LoadoutAPI.SkinDefInfo); skinDefInfo.BaseSkins = new SkinDef[0]; skinDefInfo.Icon = LoadoutAPI.CreateSkinIcon(Color.black, Color.white, Color.black, Color.white); skinDefInfo.NameToken = "Default"; skinDefInfo.UnlockableName = ""; skinDefInfo.RootObject = def.bodyPrefab.GetComponent <ModelLocator>().modelTransform.gameObject; skinDefInfo.RendererInfos = model.baseRendererInfos; skinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[0]; skinDefInfo.GameObjectActivations = new SkinDef.GameObjectActivation[1] { new SkinDef.GameObjectActivation() { gameObject = def.bodyPrefab, shouldActivate = true } }; skinDefInfo.Name = "SKIN_" + def.bodyPrefab.name + "_DEFAULT"; if (model) { skinDefInfo.RendererInfos = model.baseRendererInfos; for (int i = 0; i < skinDefInfo.RendererInfos.Length; i++) { skinDefInfo.RendererInfos[i].defaultMaterial.enableInstancing = true; skinDefInfo.RendererInfos[i].renderer.material.enableInstancing = true; skinDefInfo.RendererInfos[i].renderer.sharedMaterial.enableInstancing = true; } SkinDef skinDef3 = LoadoutAPI.CreateNewSkinDef(skinDefInfo); component.skins = new SkinDef[1] { skinDef3 }; SkinDef[] skins = component.skins; SkinDef[][] newSkins = typeof(BodyCatalog).GetFieldValue <SkinDef[][]>("skins"); newSkins[SurvivorCatalog.GetBodyIndexFromSurvivorIndex(def.survivorIndex)] = skins; typeof(BodyCatalog).SetFieldValue <SkinDef[][]>("skins", newSkins); } else { base.Logger.LogError("Unable to create new skin for " + def); } return(component); }
private void SendMessageOnFungusPickup(On.RoR2.GenericPickupController.orig_SendPickupMessage orig, CharacterMaster master, PickupIndex pickupIndex) { if (EngineerInGame && RoR2.PickupCatalog.GetPickupDef(pickupIndex).itemIndex == ItemIndex.Mushroom) { if (master.GetBody().bodyIndex == SurvivorCatalog.GetBodyIndexFromSurvivorIndex(SurvivorIndex.Engi)) { Message.SendToAll("Mmmm! That is a tasty fungus!", Colours.Green); } else { Message.SendToAll("This m**********r stole a motherfucking fungus!", Colours.Red); } } orig(master, pickupIndex); }
public void RandomizeLoadout() { if (!PreGameController.instance || !characterSelectController) { return; } var bodyIndex = SurvivorCatalog.GetBodyIndexFromSurvivorIndex(characterSelectController.selectedSurvivorIndex); var bodySkills = BodyCatalog.GetBodyPrefabSkillSlots(bodyIndex); var bodySkins = BodyCatalog.GetBodySkins(bodyIndex); var localUser = ((MPEventSystem)EventSystem.current).localUser; var loadout = new Loadout(); localUser.userProfile.CopyLoadout(loadout); for (var i = 0; i < bodySkills.Length; i++) { var skill = bodySkills[i]; var unlockedVariants = new List <uint>(); for (uint j = 0; j < skill.skillFamily.variants.Length; j++) { if (localUser.userProfile.HasUnlockable(skill.skillFamily.variants[j].unlockableDef)) { unlockedVariants.Add(j); } } loadout.bodyLoadoutManager.SetSkillVariant(bodyIndex, i, unlockedVariants[UnityEngine.Random.Range(0, unlockedVariants.Count)]); } var unlockedSkins = new List <uint>(); for (uint j = 0; j < bodySkins.Length; j++) { if (localUser.userProfile.HasUnlockable(bodySkins[j].unlockableDef)) { unlockedSkins.Add(j); } } loadout.bodyLoadoutManager.SetSkinIndex(bodyIndex, unlockedSkins[UnityEngine.Random.Range(0, unlockedSkins.Count)]); localUser.userProfile.SetLoadout(loadout); }
private void Stage_Start(On.RoR2.Stage.orig_Start orig, Stage self) { orig(self); if (RoR2.Run.instance && NetworkUser.readOnlyInstancesList .Select(x => x.GetCurrentBody()) .Where(x => x.bodyIndex == SurvivorCatalog.GetBodyIndexFromSurvivorIndex(SurvivorIndex.Engi)) .Any()) { EngineerInGame = true; Message.SendToAll("Give yo' motherfucking fungus to the motherfucking Engineer motherfuckers", Colours.LightBlue); } else { EngineerInGame = false; Logger.LogInfo("No Engineer in party."); } }
//update character preview private void UpdateCharacterPreview(On.RoR2.UI.CharacterSelectController.orig_OnNetworkUserLoadoutChanged orig, RoR2.UI.CharacterSelectController self, NetworkUser networkUser) { orig(self, networkUser); int num = self.GetSortedNetworkUsersList().IndexOf(networkUser); if (num != -1) { RoR2.UI.CharacterSelectController.CharacterPad safe = HG.ArrayUtils.GetSafe <RoR2.UI.CharacterSelectController.CharacterPad>(self.characterDisplayPads, num); if (safe.displayInstance) { Loadout loadout = new Loadout(); networkUser.networkLoadout.CopyLoadout(loadout); int bodyIndexFromSurvivorIndex = SurvivorCatalog.GetBodyIndexFromSurvivorIndex(safe.displaySurvivorIndex); int skinIndex = (int)loadout.bodyLoadoutManager.GetSkinIndex(bodyIndexFromSurvivorIndex); SkinDef safe2 = HG.ArrayUtils.GetSafe <SkinDef>(BodyCatalog.GetBodySkins(bodyIndexFromSurvivorIndex), skinIndex); CharacterModel componentInChildren = safe.displayInstance.GetComponentInChildren <CharacterModel>(); if (componentInChildren && safe2 != null) { safe2.Apply(componentInChildren.gameObject); } } } }
public void AddSkin(SurvivorDef def, string SkinFolder, ConfigFile config) { GameObject gameObject = def.bodyPrefab; LoadoutAPI.SkinDefInfo skinDefInfo = new LoadoutAPI.SkinDefInfo(); skinDefInfo.BaseSkins = new SkinDef[0]; skinDefInfo.Icon = LoadoutAPI.CreateSkinIcon(config.Bind <Color>("", "IconColorTop", Color.magenta).Value, config.Bind <Color>("", "IconColorRight", Color.black).Value, config.Bind <Color>("", "IconColorBottom", Color.magenta).Value, config.Bind <Color>("", "IconColorLeft", Color.black).Value); skinDefInfo.NameToken = config.Bind <string>("", "SkinName", "DefaultName").Value; skinDefInfo.UnlockableName = config.Bind <string>("", "UnlockableName", "").Value; skinDefInfo.RootObject = def.bodyPrefab.GetComponent <ModelLocator>().modelTransform.gameObject; skinDefInfo.RendererInfos = new CharacterModel.RendererInfo[0]; skinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[0]; skinDefInfo.GameObjectActivations = new SkinDef.GameObjectActivation[0]; skinDefInfo.Name = "SKIN_" + gameObject.name + "_DEFAULT"; int MeshReplacementIndex = config.Bind <int>("", "MeshReplacementIndex", 0).Value; if (MeshReplacementIndex != -1) { skinDefInfo.MeshReplacements = gameObject.GetComponent <ModelLocator>().modelTransform.GetComponent <ModelSkinController>().skins[MeshReplacementIndex].meshReplacements; skinDefInfo.RendererInfos = gameObject.GetComponent <ModelLocator>().modelTransform.GetComponent <ModelSkinController>().skins[MeshReplacementIndex].rendererInfos; } CharacterModel.RendererInfo[] rendererInfos = skinDefInfo.RendererInfos; CharacterModel.RendererInfo[] array = new CharacterModel.RendererInfo[rendererInfos.Length]; rendererInfos.CopyTo(array, 0); foreach (string MaterialFolder in Directory.EnumerateDirectories(SkinFolder)) { string[] MaterialIndexVs = MaterialFolder.Split(new string[] { @"\" }, StringSplitOptions.None); string RendererName = MaterialIndexVs[MaterialIndexVs.Length - 1]; int index = Array.IndexOf(array, array.FirstOrDefault(x => x.renderer.name == RendererName)); Material defaultMaterial = array[index].defaultMaterial; if (defaultMaterial) { defaultMaterial = UnityEngine.Object.Instantiate <Material>(defaultMaterial); foreach (string FilePath in Directory.EnumerateFiles(MaterialFolder)) { if (FilePath.EndsWith(".PNG") || FilePath.EndsWith(".png")) { string[] FilePathVs = FilePath.Split(new string[] { @"\" }, StringSplitOptions.None); string FileName = FilePathVs[FilePathVs.Length - 1].Replace(".PNG", ""); Texture2D savedTex = new Texture2D(1, 1, TextureFormat.RGBAFloat, false, true); ImageConversion.LoadImage(savedTex, System.IO.File.ReadAllBytes(FilePath)); savedTex.Apply(); if (defaultMaterial.HasProperty(FileName)) { defaultMaterial.enableInstancing = true; defaultMaterial.SetTexture(FileName, GetReadableTextureCopy(savedTex)); } } else if (FilePath.EndsWith(".cfg")) { string[] ConfigPathVs = FilePath.Split(new string[] { @"\" }, StringSplitOptions.None); string ConfigName = @"BepInEx\skins\" + ConfigPathVs[ConfigPathVs.Length - 4] + @"\" + ConfigPathVs[ConfigPathVs.Length - 3] + @"\" + ConfigPathVs[ConfigPathVs.Length - 2] + @"\" + ConfigPathVs[ConfigPathVs.Length - 1]; BepInEx.Configuration.ConfigFile perMatConfig = new ConfigFile(ConfigName, true); { foreach (string value in floatProperties) { if (defaultMaterial.HasProperty(value)) { defaultMaterial.SetFloat(value, perMatConfig.Bind <float>("", value, defaultMaterial.GetFloat(value), new ConfigDescription("Sets the value for " + value)).Value); } } foreach (string value in colorProperties) { if (defaultMaterial.HasProperty(value)) { defaultMaterial.SetColor(value, perMatConfig.Bind <Color>("", value, defaultMaterial.GetColor(value), new ConfigDescription("Sets the value for " + value)).Value); } } foreach (string value in defaultMaterial.shaderKeywords) { bool isEnabled = perMatConfig.Bind <bool>("", value, defaultMaterial.IsKeywordEnabled(value), new ConfigDescription("Sets the value for " + value)).Value; if (isEnabled) { defaultMaterial.EnableKeyword(value); } else { defaultMaterial.DisableKeyword(value); } } } } else if (FilePath.EndsWith(".obj")) { Mesh holderMesh = new Mesh(); ObjImporter newMesh = new ObjImporter(); holderMesh = newMesh.ImportFile(FilePath); if (array[index].renderer.gameObject.GetComponent <MeshFilter>()) { Array.Resize(ref skinDefInfo.MeshReplacements, skinDefInfo.MeshReplacements.Length + 1); skinDefInfo.MeshReplacements[skinDefInfo.MeshReplacements.Length - 1].mesh = holderMesh; skinDefInfo.MeshReplacements[skinDefInfo.MeshReplacements.Length - 1].renderer = array[index].renderer; (skinDefInfo.MeshReplacements[skinDefInfo.MeshReplacements.Length - 1].renderer as SkinnedMeshRenderer).sharedMesh = holderMesh; } } else { base.Logger.LogError("Unsupported file found in material folder: " + FilePath); } } array[index].defaultMaterial = defaultMaterial; } } base.Logger.LogInfo("Added new skin to " + def.bodyPrefab.name + " with name " + skinDefInfo.NameToken); skinDefInfo.RendererInfos = array; LoadoutAPI.AddSkinToCharacter(def.bodyPrefab, skinDefInfo); SkinDef[] skins = def.bodyPrefab.GetComponent <ModelLocator>().modelTransform.GetComponent <ModelSkinController>().skins; SkinDef[][] newSkins = typeof(BodyCatalog).GetFieldValue <SkinDef[][]>("skins"); newSkins[SurvivorCatalog.GetBodyIndexFromSurvivorIndex(def.survivorIndex)] = skins; typeof(BodyCatalog).SetFieldValue <SkinDef[][]>("skins", newSkins); }
// 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 Awake() { Instance = this; logbookBodyOptions = MapBodiesToOptions( SurvivorCatalog.orderedSurvivorDefs.Select(survivorDef => BodyCatalog.GetBodyPrefabBodyComponent(SurvivorCatalog.GetBodyIndexFromSurvivorIndex(survivorDef.survivorIndex))) .Union(BodyCatalog.allBodyPrefabBodyBodyComponents.Where(characterBody => characterBody && characterBody.GetComponent <DeathRewards>()?.logUnlockableDef))); allBodyOptions = MapBodiesToOptions(BodyCatalog.allBodyPrefabBodyBodyComponents); dropdown.Options = logbookBodyOptions; (dropdown.OnItemSelected ?? (dropdown.OnItemSelected = new SearchableDropdown.DropdownEvent())).AddListener(SelectModel); List <SearchableDropdown.OptionData> MapBodiesToOptions(IEnumerable <CharacterBody> bodies) { return(bodies .Select(characterBody => (characterBody, characterModel: characterBody.GetComponentInChildren <CharacterModel>())) .Where(el => el.characterModel) .Select(el => { var modelInfo = new ModelPrefabInfo { modelPrefab = el.characterModel.gameObject, bodyName = el.characterBody.name, modelName = el.characterModel.name, localizedBodyName = Language.GetString(el.characterBody.baseNameToken), characterBody = el.characterBody }; return new SearchableDropdown.OptionData(modelInfo, $"{modelInfo.localizedBodyName} || {modelInfo.bodyName} || {modelInfo.modelName}"); }) .ToList()); } }
// 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(); } } } } } }