private static IEnumerator HandleCharacterChange() { //Pixelator.Instance.FadeToBlack(0.5f, false); InputDevice lastActiveDevice = GameManager.Instance.LastUsedInputDeviceForConversation; Vector3 position = GameManager.Instance.SecondaryPlayer.transform.position; //Destroy Player 2 if (GameManager.Instance.CurrentGameType == GameManager.GameType.COOP_2_PLAYER) { GameManager.Instance.SecondaryPlayer.SetInputOverride("getting deleted"); GameManager.Instance.ClearSecondaryPlayer(); if (GameManager.Instance.PrimaryPlayer) { GameManager.Instance.PrimaryPlayer.ReinitializeMovementRestrictors(); } yield return(null); } //Build new Player 2 GameManager.Instance.CurrentGameType = GameManager.GameType.COOP_2_PLAYER; if (GameManager.Instance.PrimaryPlayer) { GameManager.Instance.PrimaryPlayer.ReinitializeMovementRestrictors(); } PlayerController newPlayer = GeneratePlayer(position); yield return(null); GameUIRoot.Instance.ConvertCoreUIToCoopMode(); PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(newPlayer.specRigidbody, null, false); GameManager.Instance.MainCameraController.ClearPlayerCache(); BraveInput.ReassignAllControllers(lastActiveDevice); if (Foyer.Instance) { Foyer.Instance.ProcessPlayerEnteredFoyer(newPlayer); Foyer.Instance.OnCoopModeChanged?.Invoke(); } GameManager.Instance.SecondaryPlayer.PlayerIDX = 1; GameManager.Instance.SecondaryPlayer.characterIdentity = PlayableCharacters.CoopCultist; //Reset GameManager.Instance.RefreshAllPlayers(); ToolsCharApi.Print("Character swapped", "FFFFFF", true); yield break; }
public static List <FoyerCharacterSelectFlag> AddCustomCharactersToFoyer(List <FoyerCharacterSelectFlag> sortedByX) { if (!hasInitialized) { Init(); hasInitialized = true; } List <FoyerCharacterSelectFlag> list = new List <FoyerCharacterSelectFlag>(); foreach (var character in CharacterBuilder.storedCharacters) { try { ToolsCharApi.Print($"Adding {character.Key} to the breach."); var identity = character.Value.First.baseCharacter; var selectCharacter = AddCharacterToFoyer(character.Key, GetFlagFromIdentity(identity, sortedByX).gameObject); if (selectCharacter.PrerequisitesFulfilled()) { sortedByX.Insert(6, selectCharacter); list.Add(selectCharacter); Foyer.Instance.OnPlayerCharacterChanged += selectCharacter.OnSelectedCharacterCallback; } else { UnityEngine.Object.Destroy(selectCharacter.gameObject); } } catch (Exception e) { ToolsCharApi.PrintError($"An error occured while adding character {character.Key} to the breach."); ToolsCharApi.PrintException(e); } } foreach (var flag in sortedByX) { ResetToIdle(flag); } return(list); }
public static void SwitchSecondaryCharacter(string[] args) { if (args == null || args.Length < 1) { return; } if (!GameManager.Instance.SecondaryPlayer) { ToolsCharApi.PrintError("You need to enter co-op mode before using the character2 command"); return; } prefabPath = "Player" + args[0]; var prefab = (GameObject)BraveResources.Load(prefabPath, ".prefab"); if (prefab == null) { ToolsCharApi.Print("Failed getting prefab for " + args[0]); return; } GameManager.Instance.StartCoroutine(HandleCharacterChange()); Hooks.ResetInfiniteGuns(); }
public static List <Tuple <PickupObject, bool> > GetAltguns(string[] lines, int startIndex, out int endIndex) { endIndex = startIndex; ToolsCharApi.Print("altguns loadout..."); List <Tuple <PickupObject, bool> > items = new List <Tuple <PickupObject, bool> >(); //ToolsCharApi.PrintError("go f**k yourself"); string line; string[] args; for (int i = startIndex; i < lines.Length; i++) { endIndex = i; line = lines[i].ToLower().Trim(); if (string.IsNullOrEmpty(line)) { continue; } if (line.StartsWith("</altguns>")) { return(items); } args = line.Split(' '); if (args.Length == 0) { continue; } if (!Gungeon.Game.Items.ContainsID(args[0])) { ToolsCharApi.PrintError("Could not find item with ID: \"" + args[0] + "\""); continue; } var item = Gungeon.Game.Items[args[0]]; if (item == null) { ToolsCharApi.PrintError("Could not find item with ID: \"" + args[0] + "\""); continue; } var gun = item.GetComponent <Gun>(); if (gun == null) { ToolsCharApi.PrintError("\"" + args[0] + "\" isn't a gun..."); continue; } if (args.Length > 1 && args[1].Contains("infinite")) { if (gun != null) { if (!CharacterBuilder.guns.Contains(gun) && !gun.InfiniteAmmo) { CharacterBuilder.guns.Add(gun); } items.Add(new Tuple <PickupObject, bool>(item, true)); ToolsCharApi.Print(" " + item.EncounterNameOrDisplayName + " (infinite)"); continue; } else { ToolsCharApi.PrintError(item.EncounterNameOrDisplayName + " is not a gun, and therefore cannot be infinite"); } } else { items.Add(new Tuple <PickupObject, bool>(item, false)); ToolsCharApi.Print(" " + item.EncounterNameOrDisplayName); } } ToolsCharApi.PrintError("Invalid loadout setup, expecting '</altguns>' but found none"); return(new List <Tuple <PickupObject, bool> >()); }
private static CustomCharacterData GetCharacterData(string filePath) { filePath = filePath.Replace("/", ".").Replace("\\", "."); ToolsCharApi.StartTimer("Loading data for " + Path.GetFileName(filePath)); ToolsCharApi.Print(""); ToolsCharApi.Print("--Loading " + Path.GetFileName(filePath) + "--", "0000FF"); //string customCharacterDir = Path.Combine(CharacterDirectory, filePath).Replace("/", ".").Replace("\\", "."); string dataFilePath = Path.Combine(filePath, "characterdata.txt").Replace("/", ".").Replace("\\", "."); var assembly = Assembly.GetCallingAssembly(); var lines = new string[0]; using (Stream stream = assembly.GetManifestResourceStream(dataFilePath)) using (StreamReader reader = new StreamReader(stream)) { var linesList = new List <string>(); string line = null; while ((line = reader.ReadLine()) != null) { linesList.Add(line); } //ToolsCharApi.PrintError(linesList.Count().ToString()); lines = linesList.ToArray(); } if (lines.Count() <= 0) { ToolsCharApi.PrintError($"No \"{DataFile}\" file found for " + Path.GetFileName(filePath)); return(null); } //var lines = ToolsCharApi.GetLinesFromFile(dataFilePath); var data = ParseCharacterData(lines); string spritesDir = Path.Combine(filePath, "sprites").Replace("/", ".").Replace("\\", "."); string newSpritesDir = Path.Combine(filePath, "newspritesetup").Replace("/", ".").Replace("\\", "."); string newAltSpritesDir = Path.Combine(filePath, "newaltspritesetup").Replace("/", ".").Replace("\\", "."); string altSpritesDir = Path.Combine(filePath, "alt_sprites").Replace("/", ".").Replace("\\", "."); string loadoutDir = Path.Combine(filePath, "loadoutsprites").Replace("/", ".").Replace("\\", "."); string foyerDir = Path.Combine(filePath, "foyercard").Replace("/", ".").Replace("\\", "."); string punchoutDir = Path.Combine(filePath, "punchout").Replace("/", ".").Replace("\\", "."); string punchoutSpritesDir = Path.Combine(filePath, "punchout.sprites").Replace("/", ".").Replace("\\", "."); string[] resources = ToolsCharApi.GetResourceNames(); for (int i = 0; i < resources.Length; i++) { if (resources[i].Contains(filePath)) { if (resources[i].StartsWith(spritesDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && data.sprites == null) { //ToolsCharApi.PrintError("Found: Sprites folder"); data.sprites = ToolsCharApi.GetTexturesFromResource(spritesDir); } if (resources[i].StartsWith(altSpritesDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && data.altSprites == null) { //ToolsCharApi.PrintError("Found: Alt Sprites folder"); data.altSprites = ToolsCharApi.GetTexturesFromResource(altSpritesDir); } if (resources[i].StartsWith(newSpritesDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && string.IsNullOrEmpty(data.pathForSprites)) { //ToolsCharApi.PrintError("Found: New Sprites folder"); data.pathForSprites = newSpritesDir; } if (resources[i].StartsWith(newAltSpritesDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && string.IsNullOrEmpty(data.pathForAltSprites)) { //ToolsCharApi.PrintError("Found: New Sprites folder"); data.pathForAltSprites = newAltSpritesDir; } if (resources[i].StartsWith(foyerDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && data.foyerCardSprites == null) { //ToolsCharApi.PrintError("Found: Foyer card folder"); data.foyerCardSprites = ToolsCharApi.GetTexturesFromResource(foyerDir); } if (resources[i].StartsWith(loadoutDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && data.loadoutSprites == null) { //ToolsCharApi.PrintError("Found: Loadout card folder"); data.loadoutSprites = ToolsCharApi.GetTexturesFromResource(loadoutDir); //ToolsCharApi.PrintError(data.loadoutSprites.Count.ToString()); } if (resources[i].StartsWith(punchoutSpritesDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && data.punchoutSprites == null) { ToolsCharApi.Print("Found: Punchout Sprites folder"); Debug.Log("Found: Punchout Sprites folder"); data.punchoutSprites = new Dictionary <string, Texture2D>(); foreach (var tex in ToolsCharApi.GetTexturesFromResource(punchoutSpritesDir)) { data.punchoutSprites.Add(tex.name, tex); } } if (resources[i].StartsWith(punchoutDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && data.punchoutFaceCards == null) { data.punchoutFaceCards = new List <Texture2D>(); //ETGModConsole.Log(punchoutDir); var punchoutSprites = ToolsCharApi.GetTexturesFromResource(punchoutDir); foreach (var tex in punchoutSprites) { string name = tex.name.ToLower(); if (name.Contains("facecard1") || name.Contains("facecard2") || name.Contains("facecard3")) { data.punchoutFaceCards.Add(tex); ToolsCharApi.Print("Found: Punchout facecard " + tex.name); } } } } } //ToolsCharApi.PrintError("new sprites"); //ToolsCharApi.PrintError("alt sprites"); //ToolsCharApi.PrintError("foyer card sprites"); //ToolsCharApi.PrintError("loadout sprites"); List <Texture2D> miscTextures = ToolsCharApi.GetTexturesFromResource(filePath); foreach (var tex in miscTextures) { string name = tex.name.ToLower(); if (name.Equals("icon")) { //ToolsCharApi.PrintError("Found: Icon "); data.minimapIcon = tex; } if (name.Equals("coop_page_death")) { //ToolsCharApi.PrintError("Found: Icon "); data.coopDeathScreenIcon = tex; } if (name.Contains("bosscard_")) { //ToolsCharApi.PrintError("Found: Bosscard"); //BotsModule.Log(name.ToLower().Replace("bosscard_", "").Replace("0", "")); data.bossCard.Add(tex); } if (name.Equals("playersheet")) { //ToolsCharApi.PrintError("Found: Playersheet"); data.playerSheet = tex; } if (name.Equals("facecard")) { //ToolsCharApi.PrintError("Found: Facecard"); data.faceCard = tex; } if (name.Equals("win_pic_junkan")) { //ToolsCharApi.PrintError("Found: Junkan Win Pic"); data.junkanWinPic = tex; } if (name.Equals("win_pic")) { //ToolsCharApi.PrintError("Found: Past Win Pic"); data.pastWinPic = tex; } if (name.Equals("alt_skin_obj_sprite_001")) { //ToolsCharApi.PrintError("Found: alt_skin_obj_sprite_001"); data.altObjSprite1 = tex; } if (name.Equals("alt_skin_obj_sprite_002")) { //ToolsCharApi.PrintError("Found: alt_skin_obj_sprite_002"); data.altObjSprite2 = tex; } } //ToolsCharApi.PrintError("other sprites"); //ToolsCharApi.StopTimerAndReport("Loading data for " + Path.GetFileName(directories[i])); return(data); }
private static FoyerCharacterSelectFlag AddCharacterToFoyer(string characterPath, GameObject selectFlagPrefab) { //Gather character data var customCharacter = CharacterBuilder.storedCharacters[characterPath.ToLower()]; //if (!CheckUnlocked(customCharacter.First)) //{ // return null; //} ToolsCharApi.Print(" Got custom character"); //Create new object FoyerCharacterSelectFlag selectFlag = GameObject.Instantiate(selectFlagPrefab).GetComponent <FoyerCharacterSelectFlag>(); selectFlag.prerequisites = customCharacter.First.prerequisites; FakePrefab.MarkAsFakePrefab(selectFlag.gameObject); SceneManager.MoveGameObjectToScene(selectFlag.gameObject, SceneManager.GetActiveScene()); selectFlag.transform.position = customCharacter.First.foyerPos; selectFlag.CharacterPrefabPath = characterPath; selectFlag.name = "NPC_FoyerCharacter_" + customCharacter.First.nameShort; ToolsCharApi.Print(" Made select flag"); //Replace sprites HandleSprites(selectFlag, customCharacter.Second.GetComponent <PlayerController>()); ToolsCharApi.Print(" Replaced sprites"); var td = selectFlag.talkDoer; GameObject groundThingHandler = new GameObject($"{customCharacter.First.nameShort}GroundThingHandler"); groundThingHandler.transform.position = customCharacter.First.foyerPos; //Setup overhead card if (!string.IsNullOrEmpty(customCharacter.First.pathForSprites)) { var idleDoer = selectFlag.gameObject.GetComponent <CharacterSelectIdleDoer>(); idleDoer.AnimationLibraries = customCharacter.First.idleDoer.AnimationLibraries; idleDoer.coreIdleAnimation = customCharacter.First.idleDoer.coreIdleAnimation; idleDoer.onSelectedAnimation = customCharacter.First.idleDoer.onSelectedAnimation; idleDoer.EeveeTex = customCharacter.First.idleDoer.EeveeTex; idleDoer.idleMax = customCharacter.First.idleDoer.idleMax; idleDoer.idleMin = customCharacter.First.idleDoer.idleMin; idleDoer.IsEevee = customCharacter.First.idleDoer.IsEevee; idleDoer.phases = customCharacter.First.idleDoer.phases; } selectFlag.gameObject.GetComponent <tk2dSpriteAnimator>().DefaultClipId = customCharacter.Second.GetComponent <PlayerController>().spriteAnimator.GetClipIdByName("select_idle"); if (customCharacter.First.removeFoyerExtras) { foreach (var child in selectFlag.gameObject.transform) { //wow look i did a peta and killed a dog for no reason if (((Transform)child).gameObject.name == "Doggy") { UnityEngine.Object.DestroyImmediate(((Transform)child).gameObject); } } foreach (var phase in selectFlag.gameObject.GetComponent <CharacterSelectIdleDoer>().phases) { phase.vfxTrigger = CharacterSelectIdlePhase.VFXPhaseTrigger.NONE; phase.endVFXSpriteAnimator = null; } } foreach (var thing in customCharacter.First.randomFoyerBullshitNNAskedFor) { UnityEngine.Object.Instantiate <GameObject>(thing.First, Foyer.Instance.transform.Find("Livery xform")).transform.position = customCharacter.First.foyerPos + thing.Second; } CreateOverheadCard(selectFlag, customCharacter.First); //FakePrefab.MarkAsFakePrefab(selectFlag.OverheadElement); //ETGModConsole.Log(selectFlag.OverheadElement.ToString()); td.OverheadUIElementOnPreInteract = selectFlag.OverheadElement; //FakePrefab.MarkAsFakePrefab(td.OverheadUIElementOnPreInteract); ToolsCharApi.Print(" Made Overhead Card"); //Change the effect of talking to the character foreach (var state in selectFlag.playmakerFsm.Fsm.FsmComponent.FsmStates) { foreach (var action in state.Actions) { if (action is HutongCharacter) { ((HutongCharacter)action).PlayerPrefabPath = characterPath; } } } MakeSkinSwapper(customCharacter.First); ToolsCharApi.Print(" Added swapper"); //Make interactable if (!Dungeonator.RoomHandler.unassignedInteractableObjects.Contains(td)) { Dungeonator.RoomHandler.unassignedInteractableObjects.Add(td); } ToolsCharApi.Print(" Adjusted Talk-Doer"); //Player changed callback - Hides and shows player select object Foyer.Instance.OnPlayerCharacterChanged += (player) => { OnPlayerCharacterChanged(player, selectFlag, characterPath); }; ToolsCharApi.Print(" Added callback"); return(selectFlag); }
public static void BuildCharacter(CustomCharacterData data, bool hasAltSkin, bool paradoxUsesSprites, bool removeFoyerExtras, bool hasArmourlessAnimations = false, bool usesArmourNotHealth = false, bool hasCustomPast = false, string customPast = "", int metaCost = 0, bool useGlow = false, GlowMatDoer glowVars = null, GlowMatDoer altGlowVars = null) { var basePrefab = GetPlayerPrefab(data.baseCharacter); if (basePrefab == null) { ToolsCharApi.PrintError("Could not find prefab for: " + data.baseCharacter.ToString()); return; } ToolsCharApi.Print(""); ToolsCharApi.Print("--Building Character: " + data.nameShort + "--", "0000FF"); PlayerController playerController; GameObject gameObject = GameObject.Instantiate(basePrefab); playerController = gameObject.GetComponent <PlayerController>(); var customCharacter = gameObject.AddComponent <CustomCharacter>(); customCharacter.data = data; data.characterID = storedCharacters.Count; playerController.AllowZeroHealthState = usesArmourNotHealth; playerController.ForceZeroHealthState = usesArmourNotHealth; playerController.hasArmorlessAnimations = hasArmourlessAnimations; playerController.altHandName = "hand_alt"; playerController.SwapHandsOnAltCostume = true; GameObject.DontDestroyOnLoad(gameObject); CustomizeCharacter(playerController, data, paradoxUsesSprites); data.useGlow = useGlow; if (useGlow) { data.emissiveColor = glowVars.emissiveColor; data.emissiveColorPower = glowVars.emissiveColorPower; data.emissivePower = glowVars.emissivePower; } data.removeFoyerExtras = removeFoyerExtras; data.metaCost = metaCost; if (useGlow) { var material = new Material(EnemyDatabase.GetOrLoadByName("GunNut").sprite.renderer.material); //var material = new Material(ShaderCache.Acquire("Brave/UnlitTintableCutoutEmissive")); material.DisableKeyword("BRIGHTNESS_CLAMP_ON"); material.EnableKeyword("BRIGHTNESS_CLAMP_OFF"); material.SetTexture("_MainTexture", material.GetTexture("_MainTex")); material.SetColor("_EmissiveColor", glowVars.emissiveColor); material.SetFloat("_EmissiveColorPower", glowVars.emissiveColorPower); material.SetFloat("_EmissivePower", glowVars.emissivePower); material.SetFloat("_EmissiveThresholdSensitivity", 0.5f); data.glowMaterial = material; } if (useGlow && hasAltSkin) { var material = new Material(EnemyDatabase.GetOrLoadByName("GunNut").sprite.renderer.material); //var material = new Material(ShaderCache.Acquire("Brave/UnlitTintableCutoutEmissive")); material.DisableKeyword("BRIGHTNESS_CLAMP_ON"); material.EnableKeyword("BRIGHTNESS_CLAMP_OFF"); material.SetTexture("_MainTexture", material.GetTexture("_MainTex")); material.SetColor("_EmissiveColor", altGlowVars.emissiveColor); material.SetFloat("_EmissiveColorPower", altGlowVars.emissiveColorPower); material.SetFloat("_EmissivePower", altGlowVars.emissivePower); material.SetFloat("_EmissiveThresholdSensitivity", 0.5f); data.altGlowMaterial = material; } data.normalMaterial = new Material(ShaderCache.Acquire("Brave/PlayerShader")); basePrefab = null; storedCharacters.Add(data.nameInternal.ToLower(), new Tuple <CustomCharacterData, GameObject>(data, gameObject)); //BotsModule.Log("nameInternal: " + data.nameInternal, BotsModule.TEXT_COLOR); customCharacter.past = customPast; customCharacter.hasPast = hasCustomPast; gameObject.SetActive(false); FakePrefab.MarkAsFakePrefab(gameObject); }
public IEnumerator CheckInfiniteGuns() { while (!checkedGuns) { ToolsCharApi.Print(" Data check"); if (data == null) { ToolsCharApi.PrintError("Couldn't find a character data object for this player!"); yield return(new WaitForSeconds(.1f)); } ToolsCharApi.Print(" Loadout check"); var loadout = data.loadout; if (loadout == null) { checkedGuns = true; yield break; } var player = GetComponent <PlayerController>(); if (player?.inventory?.AllGuns == null) { ToolsCharApi.PrintError("Player or inventory not found"); yield return(new WaitForSeconds(.1f)); } ToolsCharApi.Print($"Doing infinite gun check on {player.name}"); this.infiniteGunIDs = GetInfiniteGunIDs(); ToolsCharApi.Print(" Gun check"); foreach (var gun in player.inventory.AllGuns) { if (infiniteGunIDs.Contains(gun.PickupObjectId)) { if (!Hooks.gunBackups.ContainsKey(gun.PickupObjectId)) { var backup = new Hooks.GunBackupData() { InfiniteAmmo = gun.InfiniteAmmo, PreventStartingOwnerFromDropping = gun.PreventStartingOwnerFromDropping, CanBeDropped = gun.CanBeDropped, PersistsOnDeath = gun.PersistsOnDeath }; Hooks.gunBackups.Add(gun.PickupObjectId, backup); var prefab = PickupObjectDatabase.GetById(gun.PickupObjectId) as Gun; prefab.InfiniteAmmo = true; prefab.PersistsOnDeath = true; prefab.CanBeDropped = false; prefab.PreventStartingOwnerFromDropping = true; } gun.InfiniteAmmo = true; gun.PersistsOnDeath = true; gun.CanBeDropped = false; gun.PreventStartingOwnerFromDropping = true; ToolsCharApi.Print($" {gun.name} is infinite now."); } } checkedGuns = true; yield break; } }