public static CustomCharacterData BuildCharacter(string filePath, CustomPlayableCharacters identity, Vector3 foyerPos, bool hasAltSkin, Vector3 altSwapperPos, bool removeFoyerExtras = true, bool hasArmourlessAnimations = false, bool usesArmourNotHealth = false, bool paradoxUsesSprites = true,
                                                         bool useGlow = false, GlowMatDoer glowVars = null, GlowMatDoer altGlowVars = null, int metaCost = 0, bool hasCustomPast = false, string customPast = "")
        {
            //ETGModConsole.Log(BotsModule.FilePath);
            //ETGModConsole.Log(BotsModule.ZipFilePath);

            var data = GetCharacterData(filePath);

            data.foyerPos = foyerPos;
            data.idleDoer = new CharacterSelectIdleDoer
            {
                onSelectedAnimation = "select_choose",
                coreIdleAnimation   = "select_idle",
                idleMax             = 10,
                idleMin             = 4,
                EeveeTex            = null,
                IsEevee             = false,
                AnimationLibraries  = new tk2dSpriteAnimation[0],
                phases = new CharacterSelectIdlePhase[0],
            };

            //BotsModule.Log(data.nameInternal);
            //data.atlas = GameUIRoot.Instance.ConversationBar.portraitSprite.Atlas;//obj.GetOrAddComponent<dfAtlas>();



            data.skinSwapperPos = altSwapperPos;

            data.identity = identity;

            bool success = true;

            if (!CharApiHiveMind.AddNewCharacter(CharApi.prefix, (PlayableCharacters)identity))
            {
                ToolsCharApi.PrintError($"Duplicate Character ID found!! Character building for {identity} has been stopped to avoid horribly breaking things!");
                success = false;
            }
            else
            {
                try
                {
                    CharacterBuilder.BuildCharacter(data, hasAltSkin, paradoxUsesSprites, removeFoyerExtras, hasArmourlessAnimations, usesArmourNotHealth, hasCustomPast, customPast, metaCost, useGlow, glowVars, altGlowVars);
                    myPlayableCharacters.Add((PlayableCharacters)data.identity);
                }
                catch (Exception e)
                {
                    success = false;
                    ToolsCharApi.PrintError("An error occured while creating the character: " + data.name);
                    ToolsCharApi.PrintException(e);
                }
            }


            if (success)
            {
                ToolsCharApi.Print("Built prefab for: " + data.name);
                return(data);
            }
            return(null);
        }
Exemple #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);
        }