//Hook for Punchout UI being updated (called when UI updates) public static void PunchoutUpdateUI(Action <PunchoutPlayerController> orig, PunchoutPlayerController self) { orig(self); var customChar = GameManager.Instance.PrimaryPlayer.GetComponent <CustomCharacter>(); if (customChar != null) { char index = self.PlayerUiSprite.SpriteName.Last(); SpriteHandler.HandlePunchoutSprites(self, customChar.data); if (customChar.data.punchoutFaceCards != null) { self.PlayerUiSprite.SpriteName = customChar.data.nameInternal + "_punchout_facecard" + index; Tools.Print(self.PlayerUiSprite.SpriteName); } } }
public static void CustomizeCharacter(PlayerController player, CustomCharacterData data) { HandleStrings(player, data); Tools.StartTimer(" Sprite Handling"); SpriteHandler.HandleSprites(player, data); Tools.StopTimerAndReport(" Sprite Handling"); if (data.loadout != null) { HandleLoadout(player, data.loadout); } if (data.stats != null) { HandleStats(player, data.stats); } player.healthHaver.ForceSetCurrentHealth(data.health); player.healthHaver.Armor = (int)data.armor; }
private static void CreateOverheadCard(FoyerCharacterSelectFlag selectCharacter, CustomCharacterData data) { try { if (selectCharacter.OverheadElement == null) { Debug.LogError($"CHR_{data.nameShort}Panel is null"); return; } if (selectCharacter.OverheadElement?.name == $"CHR_{data.nameShort}Panel") { Debug.LogError($"CHR_{data.nameShort}Panel already exists"); return; } //Create new card instance selectCharacter.ClearOverheadElement(); var theCauseOfMySuffering = FakePrefab.Clone(selectCharacter.OverheadElement.GetComponentInChildren <CharacterSelectFacecardIdleDoer>().gameObject); selectCharacter.OverheadElement = PrefabAPI.PrefabBuilder.Clone(selectCharacter.OverheadElement); //selectCharacter.OverheadElement.SetActive(true); selectCharacter.OverheadElement.name = $"CHR_{data.nameShort}Panel"; selectCharacter.OverheadElement.GetComponent <FoyerInfoPanelController>().followTransform = selectCharacter.transform; //selectCharacter.OverheadElement.AddComponent<BotsMod.Debugger>(); //BotsMod.BotsModule.Log("0", BotsMod.BotsModule.LOST_COLOR); var customFoyerController = selectCharacter.gameObject.AddComponent <CustomCharacterFoyerController>(); customFoyerController.metaCost = data.metaCost; customFoyerController.useGlow = data.useGlow; customFoyerController.emissiveColor = data.emissiveColor; customFoyerController.emissiveColorPower = data.emissiveColorPower; customFoyerController.emissivePower = data.emissivePower; customFoyerController.data = data; string replaceKey = data.baseCharacter.ToString().ToUpper(); if (data.baseCharacter == PlayableCharacters.Soldier) { replaceKey = "MARINE"; } if (data.baseCharacter == PlayableCharacters.Pilot) { replaceKey = "ROGUE"; } if (data.baseCharacter == PlayableCharacters.Eevee) { replaceKey = "PARADOX"; } //Change text var infoPanel = selectCharacter.OverheadElement.GetComponent <FoyerInfoPanelController>(); //infoPanel.textPanel.transform.Find("NameLabel").GetComponent<dfLabel>().Text = "my ass"; //BotsMod.BotsModule.Log((infoPanel.textPanel.transform.Find("NameLabel").GetComponent<dfLabel>().Text).ToStringIfNoString(), BotsMod.BotsModule.LOST_COLOR); dfLabel nameLabel = infoPanel.textPanel.transform.Find("NameLabel").GetComponent <dfLabel>(); //why? its 3:50am and this is currently the funniest shit to me and you are powerless to stop me :) nameLabel.Text = "#CHAR_" + data.nameShort.ToString().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper() .ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper() .ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper() .ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper() .ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper().ToUpper();;// nameLabel.GetLocalizationKey().Replace(replaceKey, data.identity.ToString()); //BotsMod.BotsModule.Log(replaceKey, BotsMod.BotsModule.LOST_COLOR); dfLabel pastKilledLabel = infoPanel.textPanel.transform.Find("PastKilledLabel").GetComponent <dfLabel>(); //pastKilledLabel.Text = "(Past Killed)"; pastKilledLabel.ProcessMarkup = true; pastKilledLabel.ColorizeSymbols = true; if (data.metaCost != 0) { pastKilledLabel.ModifyLocalizedText(pastKilledLabel.Text + " (" + data.metaCost.ToString() + "[sprite \"hbux_text_icon\"])"); pastKilledLabel.ModifyLocalizedText("(Past Killed)" + " (" + data.metaCost.ToString() + "[sprite \"hbux_text_icon\"])"); } infoPanel.itemsPanel.enabled = true; var spriteObject = FakePrefab.Clone(infoPanel.itemsPanel.GetComponentInChildren <dfSprite>().gameObject); //spriteObject.SetActive(false); var posList = new List <Vector3>(); var locPosList = new List <Vector3>(); foreach (var child in infoPanel.itemsPanel.GetComponentsInChildren <dfSprite>()) { //BotsMod.BotsModule.Log(child.name + " " + child.transform.position + " -- " + child.transform.localPosition); posList.Add(child.transform.position); locPosList.Add(child.transform.localPosition); UnityEngine.Object.DestroyImmediate(child.gameObject); } for (int i = 0; i < data.loadoutSpriteNames.Count; i++) { var sprite = FakePrefab.Clone(spriteObject).GetComponent <dfSprite>(); sprite.gameObject.SetActive(true); sprite.SpriteName = data.loadoutSpriteNames[i]; sprite.Size = new Vector2(data.loadoutSprites[i].width * 3, data.loadoutSprites[i].height * 3); sprite.Atlas = GameUIRoot.Instance.ConversationBar.portraitSprite.Atlas; sprite.transform.parent = infoPanel.itemsPanel.transform; infoPanel.itemsPanel.Controls.Add(sprite); sprite.transform.position = new Vector3(1 + ((i + 0.1f) * 0.1f), -((i + 0.1f) * 0.1f), 0); sprite.transform.localPosition = new Vector3(((i + 0.1f) * 0.1f), 0, 0); //BotsMod.BotsModule.Log(data.loadoutSpriteNames[i] + sprite.transform.position + " -- " + sprite.transform.localPosition); } if (data.foyerCardSprites != null) { var facecard = selectCharacter.OverheadElement.GetComponentInChildren <CharacterSelectFacecardIdleDoer>(); theCauseOfMySuffering.transform.parent = facecard.transform.parent; theCauseOfMySuffering.transform.localScale = new Vector3(1, 1, 1); theCauseOfMySuffering.transform.localPosition = new Vector3(0, 1.687546f, 0.2250061f); theCauseOfMySuffering.transform.parent.localPosition = new Vector3(0, 0, 0); theCauseOfMySuffering.transform.parent.localScale = new Vector3(0.2f, 0.2f, 1); theCauseOfMySuffering.transform.parent.localScale = new Vector3(0.1975309f, 0.1975309f, 1); //theCauseOfMySuffering.transform.localScale = Vector3.one; //facecard.gameObject.SetActive(false); facecard.transform.parent = null; UnityEngine.Object.Destroy(facecard.gameObject); facecard = theCauseOfMySuffering.GetComponent <CharacterSelectFacecardIdleDoer>(); facecard.gameObject.name = data.nameShort + " Sprite FaceCard"; //facecard.RegenerateCache(); Debug.Log($"foyer cards arent null. {facecard.gameObject.transform.parent.position}"); Debug.Log($"foyer cards arent null. {facecard.gameObject.activeSelf}"); var orig = facecard.sprite.Collection; var idleAnimName = $"{data.nameShort}_facecard_idle"; var appearAnimName = $"{data.nameShort}_facecard_appear"; List <int> idleAnimIds = new List <int>(); List <int> appearAnimIds = new List <int>(); List <int> toCopyAppearAnimIds = new List <int> { 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, }; List <int> toCopyIdleAnimIds = new List <int> { 241, 242, 243, 244, }; foreach (var sprite in data.foyerCardSprites) { if (sprite.name.ToLower().Contains("appear")) { appearAnimIds.Add(SpriteHandler.AddSpriteToCollectionWithAnchor(sprite, orig, tk2dBaseSprite.Anchor.LowerCenter, $"{data.nameShort}_{sprite.name}")); } else if (sprite.name.ToLower().Contains("idle")) { idleAnimIds.Add(SpriteHandler.AddSpriteToCollectionWithAnchor(sprite, orig, tk2dBaseSprite.Anchor.LowerCenter, $"{data.nameShort}_{sprite.name}")); } //ETGModConsole.Log(sprite.name); } Debug.Log($"anchors done"); for (int i = 0; i < appearAnimIds.Count; i++) { orig.spriteDefinitions[appearAnimIds[i]].position0 = i >= toCopyAppearAnimIds.Count || orig.spriteDefinitions[toCopyAppearAnimIds[i]] == null ? orig.spriteDefinitions[toCopyAppearAnimIds[9]].position0 : orig.spriteDefinitions[toCopyAppearAnimIds[i]].position0; orig.spriteDefinitions[appearAnimIds[i]].position1 = i >= toCopyAppearAnimIds.Count || orig.spriteDefinitions[toCopyAppearAnimIds[i]] == null ? orig.spriteDefinitions[toCopyAppearAnimIds[9]].position1 : orig.spriteDefinitions[toCopyAppearAnimIds[i]].position1; orig.spriteDefinitions[appearAnimIds[i]].position2 = i >= toCopyAppearAnimIds.Count || orig.spriteDefinitions[toCopyAppearAnimIds[i]] == null ? orig.spriteDefinitions[toCopyAppearAnimIds[9]].position2 : orig.spriteDefinitions[toCopyAppearAnimIds[i]].position2; orig.spriteDefinitions[appearAnimIds[i]].position3 = i >= toCopyAppearAnimIds.Count || orig.spriteDefinitions[toCopyAppearAnimIds[i]] == null ? orig.spriteDefinitions[toCopyAppearAnimIds[9]].position3 : orig.spriteDefinitions[toCopyAppearAnimIds[i]].position3; /* * var safeForLaterName = orig.spriteDefinitions[appearAnimIds[i]].name; * var safeForLaterBoundsDataCenter = orig.spriteDefinitions[appearAnimIds[i]].boundsDataCenter; * var safeForLaterBoundsDataExtents = orig.spriteDefinitions[appearAnimIds[i]].boundsDataExtents; * var safeForLaterUntrimmedBoundsDataCenter = orig.spriteDefinitions[appearAnimIds[i]].untrimmedBoundsDataCenter; * var safeForLaterUntrimmedBoundsDataExtents = orig.spriteDefinitions[appearAnimIds[i]].untrimmedBoundsDataExtents; * var safeForLaterUv = orig.spriteDefinitions[appearAnimIds[i]].uvs; * * * * def.name = safeForLaterName; * def.boundsDataCenter = safeForLaterBoundsDataCenter; * def.boundsDataExtents = safeForLaterBoundsDataExtents; * def.untrimmedBoundsDataCenter = safeForLaterUntrimmedBoundsDataCenter; * def.untrimmedBoundsDataExtents = safeForLaterUntrimmedBoundsDataExtents; * def.uvs = safeForLaterUv; * * orig.spriteDefinitions[appearAnimIds[i]] = def;*/ } Debug.Log($"appearAnimIds position0-3 done"); for (int i = 0; i < idleAnimIds.Count; i++) { orig.spriteDefinitions[idleAnimIds[i]].position0 = i >= toCopyIdleAnimIds.Count || orig.spriteDefinitions[toCopyIdleAnimIds[i]] == null ? orig.spriteDefinitions[toCopyIdleAnimIds[3]].position0 : orig.spriteDefinitions[toCopyIdleAnimIds[i]].position0; orig.spriteDefinitions[idleAnimIds[i]].position1 = i >= toCopyIdleAnimIds.Count || orig.spriteDefinitions[toCopyIdleAnimIds[i]] == null ? orig.spriteDefinitions[toCopyIdleAnimIds[3]].position1 : orig.spriteDefinitions[toCopyIdleAnimIds[i]].position1; orig.spriteDefinitions[idleAnimIds[i]].position2 = i >= toCopyIdleAnimIds.Count || orig.spriteDefinitions[toCopyIdleAnimIds[i]] == null ? orig.spriteDefinitions[toCopyIdleAnimIds[3]].position2 : orig.spriteDefinitions[toCopyIdleAnimIds[i]].position2; orig.spriteDefinitions[idleAnimIds[i]].position3 = i >= toCopyIdleAnimIds.Count || orig.spriteDefinitions[toCopyIdleAnimIds[i]] == null ? orig.spriteDefinitions[toCopyIdleAnimIds[3]].position3 : orig.spriteDefinitions[toCopyIdleAnimIds[i]].position3; /* * var safeForLaterName = orig.spriteDefinitions[idleAnimIds[i]].name; * var safeForLaterBoundsDataCenter = orig.spriteDefinitions[idleAnimIds[i]].boundsDataCenter; * var safeForLaterBoundsDataExtents = orig.spriteDefinitions[idleAnimIds[i]].boundsDataExtents; * var safeForLaterUntrimmedBoundsDataCenter = orig.spriteDefinitions[idleAnimIds[i]].untrimmedBoundsDataCenter; * var safeForLaterUntrimmedBoundsDataExtents = orig.spriteDefinitions[idleAnimIds[i]].untrimmedBoundsDataExtents; * var safeForLaterUv = orig.spriteDefinitions[idleAnimIds[i]].uvs; * * * * def.name = safeForLaterName; * def.boundsDataCenter = safeForLaterBoundsDataCenter; * def.boundsDataExtents = safeForLaterBoundsDataExtents; * def.untrimmedBoundsDataCenter = safeForLaterUntrimmedBoundsDataCenter; * def.untrimmedBoundsDataExtents = safeForLaterUntrimmedBoundsDataExtents; * def.uvs = safeForLaterUv; * * orig.spriteDefinitions[idleAnimIds[i]] = def;*/ } Debug.Log($"idleAnimIds position0-3 done"); foreach (var def in orig.spriteDefinitions) { if (def.name.ToLower().Contains("appear") || def.name.ToLower().Contains("idle")) { //ETGModConsole.Log($"{def.name} [{orig.GetSpriteIdByName(def.name)}]: {def.position0} - {def.position1} - {def.position2} - {def.position3}"); } } facecard.gameObject.SetActive(true); facecard.spriteAnimator = facecard.gameObject.GetComponent <tk2dSpriteAnimator>(); SpriteBuilder.AddAnimation(facecard.spriteAnimator, orig, idleAnimIds, idleAnimName, tk2dSpriteAnimationClip.WrapMode.Loop, 4); var name = SpriteBuilder.AddAnimation(facecard.spriteAnimator, orig, appearAnimIds, appearAnimName, tk2dSpriteAnimationClip.WrapMode.Once, 17); Debug.Log($"anims added"); facecard.spriteAnimator.DefaultClipId = facecard.spriteAnimator.Library.GetClipIdByName(appearAnimName); foreach (var anim in facecard.spriteAnimator.Library.clips) { //ETGModConsole.Log($"{anim.name}: {anim.frames.Length}"); } facecard.appearAnimation = appearAnimName; facecard.coreIdleAnimation = idleAnimName; Debug.Log($"foyer card done"); } //selectCharacter.CreateOverheadElement(); } catch (Exception e) { Debug.LogError("overhead thing broke: " + e); } }
static void MakeSkinSwapper(CustomCharacterData data) { var baseSwapper = FakePrefab.Clone(Foyer.Instance.transform.Find("Livery xform").Find("costume_guide").gameObject); var altSwapper = FakePrefab.Clone(Foyer.Instance.transform.Find("Livery xform").Find("costume_guide_alt").gameObject); var sprite = baseSwapper.GetComponent <tk2dSprite>(); var altSprite = altSwapper.GetComponent <tk2dSprite>(); baseSwapper.transform.parent = Foyer.Instance.transform.Find("Livery xform"); altSwapper.transform.parent = Foyer.Instance.transform.Find("Livery xform"); sprite.SetSprite(sprite.Collection, SpriteHandler.AddSpriteToCollection(data.altObjSprite1, sprite.Collection)); altSprite.SetSprite(altSprite.Collection, SpriteHandler.AddSpriteToCollection(data.altObjSprite2, sprite.Collection)); altSwapper.name = $"costume_{data.nameShort}_alt"; baseSwapper.name = $"costume_{data.nameShort}"; var characterCostumeSwapper = baseSwapper.GetComponent <CharacterCostumeSwapper>(); characterCostumeSwapper.TargetCharacter = (PlayableCharacters)data.identity; characterCostumeSwapper.AlternateCostumeSprite = altSprite; characterCostumeSwapper.CostumeSprite = sprite; characterCostumeSwapper.HasCustomTrigger = false; characterCostumeSwapper.CustomTriggerIsFlag = false; characterCostumeSwapper.TriggerFlag = GungeonFlags.NONE; characterCostumeSwapper.CustomTriggerIsSpecialReserve = false; characterCostumeSwapper.TargetLibrary = data.AlternateCostumeLibrary; if (sprite.transform == null) { Debug.LogError("somehow the transform nulled... god is f*****g dead and BraveBehaviours killed him"); } if (altSprite.transform == null) { Debug.LogError("somehow the transform nulled... god is f*****g dead (again) and BraveBehaviours killed him"); } baseSwapper.gameObject.SetActive(true); altSwapper.gameObject.SetActive(true); baseSwapper.transform.position = data.skinSwapperPos; altSwapper.transform.position = data.skinSwapperPos; //BotsMod.BotsModule.Log($"{baseSwapper.name}: {baseSwapper.transform.position}"); if (!RoomHandler.unassignedInteractableObjects.Contains(baseSwapper.GetComponent <IPlayerInteractable>())) { RoomHandler.unassignedInteractableObjects.Add(baseSwapper.GetComponent <IPlayerInteractable>()); } if (!RoomHandler.unassignedInteractableObjects.Contains(altSwapper.GetComponent <IPlayerInteractable>())) { RoomHandler.unassignedInteractableObjects.Add(altSwapper.GetComponent <IPlayerInteractable>()); } }
public static void CustomizeCharacter(PlayerController player, CustomCharacterData data, bool paradoxUsesSprites) { HandleStrings(player, data); ToolsCharApi.StartTimer(" Sprite Handling"); SpriteHandler.HandleSprites(player, data); ToolsCharApi.StopTimerAndReport(" Sprite Handling"); if (data.loadout != null) { HandleLoadout(player, data.loadout, data.altGun); } if (data.stats != null) { HandleStats(player, data.stats); } player.healthHaver.ForceSetCurrentHealth(data.health); player.healthHaver.Armor = (int)data.armor; player.characterIdentity = (PlayableCharacters)data.identity; //player.OverridePlayerSwitchState = "Ninja"; //AkSoundEngine.switch //AkSoundEngine.SetSwitch("CHR_Player", (player.OverridePlayerSwitchState == null) ? data.nameShort : player.OverridePlayerSwitchState, player.gameObject); //AkSoundEngine.GetSwitch("CHR_Player", player.gameObject, out idk); //BotsModule.Log((player.OverridePlayerSwitchState == null) ? data.nameShort : player.OverridePlayerSwitchState); //BotsModule.Strings.Core.Set("#PLAYER_NICK_LOST", "Dead Thing"); //BotsModule.Strings.Core.Set("#PLAYER_NAME_LOST", "Lost"); StringHandler.AddStringDefinition("#PLAYER_NAME_" + player.characterIdentity.ToString().ToUpperInvariant(), data.name); StringHandler.AddStringDefinition("#PLAYER_NICK_" + player.characterIdentity.ToString().ToUpperInvariant(), data.nickname); StringHandler.AddDFStringDefinition("#CHAR_" + data.nameShort.ToString().ToUpper(), data.name); StringHandler.AddDFStringDefinition("#CHAR_" + data.nameShort.ToString().ToUpper() + "_SHORT", data.nameShort); //BotsModule.Log("Player is: " + data.nameShort.ToString(), BotsModule.LOST_COLOR); //BotsModule.Log("#CHAR_" + data.nameShort.ToUpper(), BotsModule.LOST_COLOR); /*if (!hasClearedEeveeAnims) * { * var eevee = (GameObject)ResourceCache.Acquire("PlayerEevee"); * if (eevee != null) * { * eevee.GetComponent<CharacterAnimationRandomizer>().AnimationLibraries.Clear(); * } * hasClearedEeveeAnims = true; * }*/ if (paradoxUsesSprites) { var eevee = (GameObject)ResourceCache.Acquire("PlayerEevee"); if (player.spriteAnimator.Library != null && eevee != null) { eevee.GetComponent <CharacterAnimationRandomizer>().AddOverrideAnimLibrary(player.spriteAnimator.Library); //BotsModule.Log("player.spriteAnimator.Library added"); } if (player.AlternateCostumeLibrary != null && eevee != null) { eevee.GetComponent <CharacterAnimationRandomizer>().AddOverrideAnimLibrary(player.AlternateCostumeLibrary); //BotsModule.Log("AlternateCostumeLibrary added"); } } //GameManager.Instance.PrimaryPlayer.GetComponent<CharacterAnimationRandomizer>().AddOverrideAnimLibrary(player.spriteAnimator.Library); }