Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }