Esempio n. 1
0
        private static void OnPlayerCharacterChanged(PlayerController player, FoyerCharacterSelectFlag selectCharacter, string characterPath)
        {
            if (player.name.ToLower().Contains(characterPath))
            {
                ToolsCharApi.Print("Selected: " + characterPath);
                if (selectCharacter.gameObject.activeSelf)
                {
                    selectCharacter.ClearOverheadElement();
                    selectCharacter.talkDoer.OnExitRange(null);
                    selectCharacter.gameObject.SetActive(false);
                    selectCharacter.GetComponent <SpeculativeRigidbody>().enabled = false;
                }
            }
            else if (!selectCharacter.gameObject.activeSelf)
            {
                selectCharacter.gameObject.SetActive(true);
                SpriteOutlineManager.RemoveOutlineFromSprite(selectCharacter.sprite, true);
                SpriteOutlineManager.AddOutlineToSprite(selectCharacter.sprite, Color.black);

                selectCharacter.specRigidbody.enabled = true;
                PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(selectCharacter.specRigidbody, null, false);

                CharacterSelectIdleDoer idleDoer = selectCharacter.GetComponent <CharacterSelectIdleDoer>();
                idleDoer.enabled = true;
            }
        }
Esempio n. 2
0
        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);
            }
        }
        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);
        }