public static void HandleMinimapIcons(PlayerController player, CustomCharacterData data) { player.minimapIconPrefab = GameObject.Instantiate(player.minimapIconPrefab); var minimapSprite = player.minimapIconPrefab.GetComponent <tk2dSprite>(); GameObject.DontDestroyOnLoad(minimapSprite); string iconName = "Player_" + player.name + "_001"; int id = minimapSprite.Collection.GetSpriteIdByName(iconName, -1); //return -1 if not found if (id < 0) { var spriteDef = minimapSprite.GetCurrentSpriteDef(); var copy = spriteDef.Copy(); copy.ReplaceTexture(data.minimapIcon); copy.name = iconName; id = AddSpriteToCollection(copy, minimapSprite.Collection); } else { Tools.Print("Minimap icon for " + iconName + " already found, not generating a new one"); } //SetMinimapIconSpriteID(minimapSprite.spriteId, id); minimapSprite.SetSprite(id); }
public static void HandleSprites(PlayerController player, CustomCharacterData data) { if (data.minimapIcon != null) { HandleMinimapIcons(player, data); } if (data.bossCard != null) { HandleBossCards(player, data); } if (data.sprites != null || data.playerSheet != null) { HandleAnimations(player, data); } //face card stuff uiAtlas = GameUIRoot.Instance.ConversationBar.portraitSprite.Atlas; if (data.faceCard != null) { HandleFacecards(player, data); } if (data.punchoutFaceCards != null && data.punchoutFaceCards.Count > 0) { HandlePunchoutFaceCards(data); } }
public static void BuildCharacter(CustomCharacterData data) { var basePrefab = GetPlayerPrefab(data.baseCharacter); if (basePrefab == null) { Tools.PrintError("Could not find prefab for: " + data.baseCharacter.ToString()); return; } Tools.Print(""); Tools.Print("--Building Character: " + data.nameShort + "--", "0000FF"); PlayerController playerController; GameObject gameObject = GameObject.Instantiate(basePrefab); playerController = gameObject.GetComponent <PlayerController>(); playerController.gameObject.AddComponent <CustomCharacter>().data = data; data.characterID = storedCharacters.Count; GameObject.DontDestroyOnLoad(gameObject); CustomizeCharacter(playerController, data); basePrefab = null; storedCharacters.Add(data.nameInternal.ToLower(), new Tuple <CustomCharacterData, GameObject>(data, gameObject)); gameObject.SetActive(false); FakePrefab.MarkAsFakePrefab(gameObject); }
public static void HandleStrings(PlayerController player, CustomCharacterData data) { player.name = data.nameInternal; if (data.faceCard != null) { player.uiPortraitName = data.nameInternal + "_facecard"; } HandleDictionaries(data); }
public static void HandleBossCards(PlayerController player, CustomCharacterData data) { int count = player.BosscardSprites.Count; player.BosscardSprites = new List <Texture2D>(); for (int i = 0; i < count; i++) { player.BosscardSprites.Add(data.bossCard); } }
public static void HandleDictionaries(CustomCharacterData data) { string keyBase = data.nameShort.ToUpper(); StringHandler.AddStringDefinition("#PLAYER_NAME_" + keyBase, data.name); //TODO override the get methods instead of overwriting! StringHandler.AddStringDefinition("#PLAYER_NICK_" + keyBase, data.nickname); StringHandler.AddDFStringDefinition("#CHAR_" + keyBase, data.name); StringHandler.AddDFStringDefinition("#CHAR_" + keyBase + "_SHORT", data.nameShort); }
public void CheckInfiniteGuns() { Tools.Print("Doing infinite gun check..."); try { Tools.Print(" Data check"); if (data == null) { var gameobjName = this.gameObject.name.ToLower().Replace("(clone)", ""); foreach (var cc in CharacterBuilder.storedCharacters.Keys) { if (cc.ToLower().Contains(gameobjName)) { data = CharacterBuilder.storedCharacters[cc].First; } } } if (data == null) { Tools.PrintError("Couldn't find a character data object for this player!"); return; } Tools.Print(" Loadout check"); var loadout = data.loadout; if (loadout == null) { checkedGuns = true; return; } var player = GetComponent <PlayerController>(); if (player?.inventory?.AllGuns == null) { Tools.PrintError("Player or inventory not found"); return; } CollectInfiniteGunIDs(); //Store all infinite gun PickupObject IDs in "infiniteGunIDs" Tools.Print(" Gun check"); foreach (var gun in player.inventory.AllGuns) { if (infiniteGunIDs.Contains(gun.PickupObjectId)) { gun.InfiniteAmmo = true; } } checkedGuns = true; } catch (Exception e) { Tools.PrintError("Infinite gun check failed"); //Tools.PrintException(e); } }
public static void HandleFacecards(PlayerController player, CustomCharacterData data) { var atlas = uiAtlas; var atlasTex = atlas.Texture; dfAtlas.ItemInfo info = new dfAtlas.ItemInfo(); info.name = player.name + "_facecard"; info.region = TextureStitcher.AddFaceCardToAtlas(data.faceCard, atlasTex, uiFaceCards.Count, uiFacecardBounds); info.sizeInPixels = faceCardSizeInPixels; atlas.AddItem(info); if (atlas.Replacement) { atlas.Replacement.Material.mainTexture = atlasTex; } uiFaceCards.Add(info); }
public static void HandlePunchoutSprites(PunchoutPlayerController player, CustomCharacterData data) { var primaryPlayer = GameManager.Instance.PrimaryPlayer; player.PlayerUiSprite.Atlas = uiAtlas; if (data != null) { if (data.punchoutSprites != null && player.sprite.Collection.name != (data.nameShort + " Punchout Collection")) { HandlePunchoutAnimations(player, data); } if (data.faceCard != null) { player.PlayerUiSprite.SpriteName = data.nameInternal + "_punchout_facecard1"; } } }
public static void HandlePunchoutAnimations(PunchoutPlayerController player, CustomCharacterData data) { Tools.Print("Replacing punchout sprites..."); var orig = player.sprite.Collection; var copyCollection = GameObject.Instantiate(orig); GameObject.DontDestroyOnLoad(copyCollection); tk2dSpriteDefinition[] copyDefinitions = new tk2dSpriteDefinition[orig.spriteDefinitions.Length]; for (int i = 0; i < copyCollection.spriteDefinitions.Length; i++) { copyDefinitions[i] = orig.spriteDefinitions[i].Copy(); } copyCollection.spriteDefinitions = copyDefinitions; foreach (var tex in data.punchoutSprites) { var def = copyCollection.GetSpriteDefinition(tex.name); if (def != null) { def.ReplaceTexture(tex.CropWhiteSpace()); } } player.spriteAnimator.Library = GameObject.Instantiate(player.spriteAnimator.Library); GameObject.DontDestroyOnLoad(player.spriteAnimator.Library); foreach (var clip in player.spriteAnimator.Library.clips) { for (int i = 0; i < clip.frames.Length; i++) { clip.frames[i].spriteCollection = copyCollection; } } copyCollection.name = data.nameShort + " Punchout Collection"; //CharacterBuilder.storedCollections.Add(data.nameInternal, copyCollection); player.sprite.Collection = copyCollection; Tools.Print("Punchout sprites successfully replaced"); }
public static void HandlePunchoutFaceCards(CustomCharacterData data) { var atlas = uiAtlas; var atlasTex = atlas.Texture; if (data.punchoutFaceCards != null) { Tools.Print("Adding punchout facecards"); int count = Mathf.Min(data.punchoutFaceCards.Count, 3); for (int i = 0; i < count; i++) { dfAtlas.ItemInfo info = new dfAtlas.ItemInfo(); info.name = data.nameInternal + "_punchout_facecard" + (i + 1); info.region = TextureStitcher.AddFaceCardToAtlas(data.punchoutFaceCards[i], atlasTex, uiFaceCards.Count, uiFacecardBounds); info.sizeInPixels = faceCardSizeInPixels; atlas.AddItem(info); uiFaceCards.Add(info); } } }
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; }
void GetData() { try { var gameobjName = this.gameObject.name.ToLower().Replace("(clone)", "").Trim(); foreach (var cc in CharacterBuilder.storedCharacters.Keys) { if (cc.ToLower().Equals(gameobjName)) { data = CharacterBuilder.storedCharacters[cc].First; } } } catch { failedToFindData = true; } if (data == null) { failedToFindData = true; } }
public static void HandleAnimations(PlayerController player, CustomCharacterData data) { var orig = player.sprite.Collection; var copyCollection = GameObject.Instantiate(orig); GameObject.DontDestroyOnLoad(copyCollection); tk2dSpriteDefinition[] copyDefinitions = new tk2dSpriteDefinition[orig.spriteDefinitions.Length]; for (int i = 0; i < copyCollection.spriteDefinitions.Length; i++) { copyDefinitions[i] = orig.spriteDefinitions[i].Copy(); } copyCollection.spriteDefinitions = copyDefinitions; if (data.playerSheet != null) { Tools.Print(" Using sprite sheet replacement.", "FFBB00"); var materialsToCopy = orig.materials; copyCollection.materials = new Material[orig.materials.Length]; for (int i = 0; i < copyCollection.materials.Length; i++) { if (materialsToCopy[i] == null) { continue; } var mat = new Material(materialsToCopy[i]); GameObject.DontDestroyOnLoad(mat); mat.mainTexture = data.playerSheet; mat.name = materialsToCopy[i].name; copyCollection.materials[i] = mat; } for (int i = 0; i < copyCollection.spriteDefinitions.Length; i++) { foreach (var mat in copyCollection.materials) { if (mat != null && copyDefinitions[i].material.name.Equals(mat.name)) { copyDefinitions[i].material = mat; copyDefinitions[i].materialInst = new Material(mat); } } } } else if (data.sprites != null) { Tools.Print(" Using individual sprite replacement.", "FFBB00"); bool notSlinger = data.baseCharacter != PlayableCharacters.Gunslinger; RuntimeAtlasPage page = new RuntimeAtlasPage(); for (int i = 0; i < data.sprites.Count; i++) { var tex = data.sprites[i]; float nw = (tex.width) / 16f; float nh = (tex.height) / 16f; var def = copyCollection.GetSpriteDefinition(tex.name); if (def != null) { if (notSlinger && def.boundsDataCenter != Vector3.zero) { var ras = page.Pack(tex); def.materialInst.mainTexture = ras.texture; def.uvs = ras.uvs; def.extractRegion = true; def.position0 = new Vector3(0, 0, 0); def.position1 = new Vector3(nw, 0, 0); def.position2 = new Vector3(0, nh, 0); def.position3 = new Vector3(nw, nh, 0); def.boundsDataCenter = new Vector2(nw / 2, nh / 2); def.untrimmedBoundsDataCenter = def.boundsDataCenter; def.boundsDataExtents = new Vector2(nw, nh); def.untrimmedBoundsDataExtents = def.boundsDataExtents; } else { def.ReplaceTexture(tex); } } } page.Apply(); } else { Tools.Print(" Not replacing sprites.", "FFFF00"); } player.spriteAnimator.Library = GameObject.Instantiate(player.spriteAnimator.Library); GameObject.DontDestroyOnLoad(player.spriteAnimator.Library); foreach (var clip in player.spriteAnimator.Library.clips) { for (int i = 0; i < clip.frames.Length; i++) { clip.frames[i].spriteCollection = copyCollection; } } copyCollection.name = player.OverrideDisplayName; player.primaryHand.sprite.Collection = copyCollection; player.secondaryHand.sprite.Collection = copyCollection; player.sprite.Collection = copyCollection; }
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); }
private static void CreateOverheadCard(FoyerCharacterSelectFlag selectCharacter, CustomCharacterData data) { //Create new card instance selectCharacter.ClearOverheadElement(); selectCharacter.OverheadElement = FakePrefab.Clone(selectCharacter.OverheadElement); selectCharacter.OverheadElement.SetActive(true); 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>(); dfLabel nameLabel = infoPanel.textPanel.transform.Find("NameLabel").GetComponent <dfLabel>(); nameLabel.Text = nameLabel.GetLocalizationKey().Replace(replaceKey, data.nameShort.ToUpper()); dfLabel pastKilledLabel = infoPanel.textPanel.transform.Find("PastKilledLabel").GetComponent <dfLabel>(); pastKilledLabel.Text = "(No Past)"; infoPanel.itemsPanel.enabled = false; /* * infoPanel.itemsPanel.ResolutionChangedPostLayout += (a, b, c) => * { * infoPanel.itemsPanel.IsVisible = false; * Tools.Print("called"); * }; */ //Swap out face sprites if (data.foyerCardSprites != null) { var facecard = selectCharacter.OverheadElement.GetComponentInChildren <CharacterSelectFacecardIdleDoer>(); var orig = facecard.sprite.Collection; var copyCollection = GameObject.Instantiate(orig); tk2dSpriteDefinition[] copyDefinitions = new tk2dSpriteDefinition[orig.spriteDefinitions.Length]; for (int i = 0; i < copyCollection.spriteDefinitions.Length; i++) { copyDefinitions[i] = orig.spriteDefinitions[i].Copy(); } copyCollection.spriteDefinitions = copyDefinitions; for (int i = 0; i < data.foyerCardSprites.Count; i++) { var tex = data.foyerCardSprites[i]; var def = copyCollection.GetSpriteDefinition(tex.name); if (def != null) { Tools.ReplaceTexture(def, tex); Console.WriteLine($"REPLACED {def.name} {def.material.mainTexture.width} {def.material.mainTexture.height}"); } } facecard.sprite.Collection = copyCollection; facecard.spriteAnimator.Library = GameObject.Instantiate(facecard.spriteAnimator.Library); GameObject.DontDestroyOnLoad(facecard.spriteAnimator.Library); foreach (var clip in facecard.spriteAnimator.Library.clips) { for (int i = 0; i < clip.frames.Length; i++) { clip.frames[i].spriteCollection = copyCollection; } } Console.WriteLine($"FOYERCARDDBG"); for (int i = 0; i < copyCollection.spriteDefinitions.Length; i++) { var def = copyCollection.spriteDefinitions[i]; Console.WriteLine(def.name); if (!def.name.Contains("facecard")) { continue; } Console.WriteLine("FACECARD"); Console.WriteLine($"{def.material.mainTexture.width} {def.material.mainTexture.height} {def.uvs[0].x},{def.uvs[0].y} {def.uvs[1].x},{def.uvs[1].y} {def.uvs[2].x},{def.uvs[2].y} {def.uvs[3].x},{def.uvs[3].y} "); } } selectCharacter.OverheadElement.SetActive(false); }
//Main parse loop public static CustomCharacterData ParseCharacterData(string[] lines) { CustomCharacterData data = new CustomCharacterData(); for (int i = 0; i < lines.Length; i++) { string line = lines[i].ToLower().Trim(); string lineCaseSensitive = lines[i].Trim(); if (string.IsNullOrEmpty(line)) { continue; } if (line.StartsWith("#")) { continue; } if (line.StartsWith("<loadout>")) { data.loadout = GetLoadout(lines, i + 1, out i); continue; } if (line.StartsWith("<altguns>")) { //ToolsCharApi.PrintError("alt guns found"); data.altGun = GetAltguns(lines, i + 1, out i); continue; } if (line.StartsWith("<stats>")) { data.stats = GetStats(lines, i + 1, out i); continue; } int dividerIndex = line.IndexOf(':'); if (dividerIndex < 0) { continue; } string value = lineCaseSensitive.Substring(dividerIndex + 1).Trim(); if (line.StartsWith("base:")) { data.baseCharacter = GetCharacterFromString(value); if (data.baseCharacter == PlayableCharacters.Robot) { data.armor = 6; } continue; } if (line.StartsWith("name:")) { data.name = value; continue; } /*if (line.StartsWith("unlock:")) * { * data.unlockFlag = GetFlagFromString(value); * //BotsModule.Log(data.unlockFlag+"", BotsModule.LOST_COLOR); * continue; * }*/ if (line.StartsWith("name short:")) { data.nameShort = value.Replace(" ", "_"); data.nameInternal = "Player" + data.nameShort; continue; } if (line.StartsWith("nickname:")) { data.nickname = value; continue; } if (line.StartsWith("armor:")) { float floatValue; if (!float.TryParse(value, out floatValue)) { ToolsCharApi.PrintError("Invalid armor value: " + line); continue; } data.armor = floatValue; continue; } ToolsCharApi.PrintError($"Line {i} in {DataFile} did not meet any expected criteria:"); ToolsCharApi.PrintRaw("----" + line, true); } return(data); }
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); }
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>()); } }
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); } }