示例#1
0
 public static void HideSkin(SkinDef skin)
 {
     if (!hiddenIfLockedSkins.Contains(skin))
     {
         hiddenIfLockedSkins.Add(skin);
     }
 }
示例#2
0
        /// <summary>
        /// Creates a new SkinDef from a SkinDefInfo.
        /// Note that this prevents null-refs by disabling SkinDef awake while the SkinDef is being created.
        /// The things that occur during awake are performed when first applied to a character instead.
        /// </summary>
        /// <param name="skin"></param>
        /// <returns></returns>
        public static SkinDef CreateNewSkinDef(SkinDefInfo skin)
        {
            if (!IsLoaded)
            {
                R2API.Logger.LogError("LoadoutAPI is not loaded. Please use [R2API.Utils.SubModuleDependency]");
                return(null);
            }
            On.RoR2.SkinDef.Awake += DoNothing;

            SkinDef newSkin = ScriptableObject.CreateInstance <SkinDef>();

            newSkin.baseSkins             = skin.baseSkins;
            newSkin.icon                  = skin.icon;
            newSkin.unlockableName        = skin.unlockableName;
            newSkin.rootObject            = skin.rootObject;
            newSkin.rendererInfos         = skin.rendererInfos;
            newSkin.gameObjectActivations = skin.gameObjectActivations;
            newSkin.meshReplacements      = skin.meshReplacements;
            newSkin.nameToken             = skin.nameToken;
            newSkin.name                  = skin.name;

            On.RoR2.SkinDef.Awake -= DoNothing;

            addedSkins.Add(newSkin);
            return(newSkin);
        }
示例#3
0
        private static void InitializeNemSkins()
        {
            if (Prefabs.nemPaladinPrefab == null)
            {
                return;
            }

            GameObject bodyPrefab = Prefabs.nemPaladinPrefab;

            GameObject     model          = bodyPrefab.GetComponentInChildren <ModelLocator>().modelTransform.gameObject;
            CharacterModel characterModel = model.GetComponent <CharacterModel>();

            ModelSkinController skinController = model.AddComponent <ModelSkinController>();
            ChildLocator        childLocator   = model.GetComponent <ChildLocator>();

            SkinnedMeshRenderer mainRenderer = characterModel.mainSkinnedMeshRenderer;

            List <SkinDef> skinDefs = new List <SkinDef>();

            #region DefaultSkin
            CharacterModel.RendererInfo[] defaultRenderers = characterModel.baseRendererInfos;
            SkinDef defaultSkin = CreateSkinDef("PALADINBODY_DEFAULT_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texMainSkin"), defaultRenderers, mainRenderer, model);
            defaultSkin.meshReplacements = new SkinDef.MeshReplacement[0];

            skinDefs.Add(defaultSkin);
            #endregion

            skinController.skins = skinDefs.ToArray();
        }
示例#4
0
        public static SkinDef CreateSkinDef(string skinName, Sprite skinIcon, CharacterModel.RendererInfo[] rendererInfos, SkinnedMeshRenderer mainRenderer, GameObject root, string unlockName, Mesh skinMesh)
        {
            LoadoutAPI.SkinDefInfo skinDefInfo = new LoadoutAPI.SkinDefInfo
            {
                BaseSkins             = Array.Empty <SkinDef>(),
                GameObjectActivations = new SkinDef.GameObjectActivation[0],
                Icon             = skinIcon,
                MeshReplacements = new SkinDef.MeshReplacement[]
                {
                    new SkinDef.MeshReplacement
                    {
                        renderer = mainRenderer,
                        mesh     = skinMesh
                    }
                },
                MinionSkinReplacements = new SkinDef.MinionSkinReplacement[0],
                Name      = skinName,
                NameToken = skinName,
                ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0],
                RendererInfos  = rendererInfos,
                RootObject     = root,
                UnlockableName = unlockName
            };

            SkinDef skin = LoadoutAPI.CreateNewSkinDef(skinDefInfo);

            return(skin);
        }
示例#5
0
        private static void SkinDefApply(Action <SkinDef, GameObject> orig, SkinDef self, GameObject modelObject)
        {
            orig(self, modelObject);

            try
            {
                RemoveInvalidModelObjects();

                appliedModificatons.TryGetValue(modelObject, out var modificatons);

                if (self != SkinDef)
                {
                    if (modificatons != null)
                    {
                        appliedModificatons.Remove(modelObject);
                        ClearSkinModifications(modificatons);
                    }
                    return;
                }
                if (modificatons == null)
                {
                    appliedModificatons[modelObject] = ApplySkinModifications(modelObject);
                }
            }
            catch (Exception e)
            {
                InstanceLogger.LogWarning("An error occured while adding accessories to a Mercenary2B skin");
                InstanceLogger.LogError(e);
            }
        }
        private static void RevertSkin(GameObject modelObject, SkinDef skinDef)
        {
            if (reverseSkins.TryGetValue(modelObject, out var reverseSkin))
            {
                reverseSkin.Apply();
            }
            reverseSkins[modelObject] = new ReverseSkin(modelObject, skinDef);

            VerifyDictionary();
        }
        private ModelSkinController AddDefaultSkin(GameObject def)
        {
            base.Logger.LogInfo("Adding default skin to " + def);

            ModelSkinController component = def.GetComponentInChildren <ModelLocator>().modelTransform.gameObject.AddComponent <ModelSkinController>();
            CharacterModel      model     = def.GetComponentInChildren <ModelLocator>().modelTransform.GetComponentInChildren <CharacterModel>();

            LoadoutAPI.SkinDefInfo skinDefInfo = default(LoadoutAPI.SkinDefInfo);
            skinDefInfo.BaseSkins             = new SkinDef[0];
            skinDefInfo.Icon                  = LoadoutAPI.CreateSkinIcon(Color.black, Color.white, Color.black, Color.white);
            skinDefInfo.NameToken             = "Default";
            skinDefInfo.UnlockableName        = "";
            skinDefInfo.RootObject            = def.GetComponentInChildren <ModelLocator>().modelTransform.gameObject;
            skinDefInfo.RendererInfos         = model.baseRendererInfos;
            skinDefInfo.MeshReplacements      = new SkinDef.MeshReplacement[0];
            skinDefInfo.GameObjectActivations = new SkinDef.GameObjectActivation[1] {
                new SkinDef.GameObjectActivation()
                {
                    gameObject = def, shouldActivate = true
                }
            };
            skinDefInfo.Name = "DEFAULT_" + def.name + "_SKIN";

            if (model)
            {
                skinDefInfo.RendererInfos = model.baseRendererInfos;

                for (int i = 0; i < skinDefInfo.RendererInfos.Length; i++)
                {
                    skinDefInfo.RendererInfos[i].defaultMaterial.enableInstancing         = true;
                    skinDefInfo.RendererInfos[i].renderer.material.enableInstancing       = true;
                    skinDefInfo.RendererInfos[i].renderer.sharedMaterial.enableInstancing = true;
                }

                SkinDef skinDef3 = LoadoutAPI.CreateNewSkinDef(skinDefInfo);
                component.skins = new SkinDef[1] {
                    skinDef3
                };

                LoadoutAPI.AddSkinToCharacter(def, skinDef3);

                SkinDef[] skins = component.skins;

                SkinDef[][] newSkins = typeof(BodyCatalog).GetFieldValue <SkinDef[][]>("skins");
                newSkins[BodyCatalog.FindBodyIndex(def)] = skins;
                typeof(BodyCatalog).SetFieldValue <SkinDef[][]>("skins", newSkins);
            }
            else
            {
                base.Logger.LogError("Unable to create new skin for " + def);
            }

            return(component);
        }
示例#8
0
        public static void RegisterSkins()
        {
            GameObject bodyPrefab = GrovetenderPlugin.myCharacter;

            GameObject     model          = bodyPrefab.GetComponentInChildren <ModelLocator>().modelTransform.gameObject;
            CharacterModel characterModel = model.GetComponent <CharacterModel>();

            if (model.GetComponent <ModelSkinController>())
            {
                GrovetenderPlugin.Destroy(model.GetComponent <ModelSkinController>());
            }

            ModelSkinController skinController = model.AddComponent <ModelSkinController>();
            ChildLocator        childLocator   = model.GetComponent <ChildLocator>();

            SkinnedMeshRenderer mainRenderer = Reflection.GetFieldValue <SkinnedMeshRenderer>(characterModel, "mainSkinnedMeshRenderer");

            LanguageAPI.Add("GROVETENDERBODY_DEFAULT_SKIN_NAME", "Default");

            LoadoutAPI.SkinDefInfo skinDefInfo = default(LoadoutAPI.SkinDefInfo);
            skinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            skinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];
            skinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];

            skinDefInfo.GameObjectActivations = Array.Empty <SkinDef.GameObjectActivation>();

            skinDefInfo.Icon             = LoadoutAPI.CreateSkinIcon(new Color(0.09f, 0.03f, 0.03f), new Color(0.039f, 0.039f, 0.078f), new Color(0.61f, 0.59f, 0.5f), new Color(0.9f, 0.9f, 0.9f));
            skinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[0];

            /*{
             *  new SkinDef.MeshReplacement
             *  {
             *      renderer = mainRenderer,
             *      mesh = mainRenderer.sharedMesh
             *  }
             * };*/
            skinDefInfo.Name           = "GROVETENDERBODY_DEFAULT_SKIN_NAME";
            skinDefInfo.NameToken      = "GROVETENDERBODY_DEFAULT_SKIN_NAME";
            skinDefInfo.RendererInfos  = characterModel.baseRendererInfos;
            skinDefInfo.RootObject     = model;
            skinDefInfo.UnlockableName = "";

            SkinDef defaultSkin = LoadoutAPI.CreateNewSkinDef(skinDefInfo);

            skinController.skins = new SkinDef[1]
            {
                defaultSkin
            };
        }
示例#9
0
        /// <summary>
        /// use this to add a skin change event for the sword effects in css
        /// <para> otherwise in css your skin won't show the sword effect properly </para>
        /// </summary>
        ///
        /// <param name="def">
        /// pass in your skilldef here
        /// </param>
        ///
        /// <param name="cssEffect">
        /// use an entry in this enum to choose an effect
        /// <para> DEFAULT, LUNAR, BEEFY, TAR, YELLOW, GREEN, GREENSCYTHE, RED, REDSCYTHE, PURPLE, FLAME </para>
        /// <para> if you want me to add a new one f**k it let me know </para>
        /// </param>
        public static void AddCSSSkinChangeResponse(SkinDef def, paladinCSSEffect cssEffect)
        {
            //duplicating a skinchangeresponse from defaults that I set up in editor
            SkinChangeResponse newSkinResponse = defaultResponses[(int)cssEffect];

            newSkinResponse.triggerSkin = def;

            //gotta do this song and dance instead of simply adding our own custom skinchangeresponses because for some reason adding events for skinchangeresponses in code doesn't work
            //or at least didn't work last time i tried
            SkinChangeResponse[] addedSkinchange = new SkinChangeResponse[] {
                newSkinResponse
            };

            paladinCSSPreviewController.skinChangeResponses = paladinCSSPreviewController.skinChangeResponses.Concat(addedSkinchange).ToArray();
        }
示例#10
0
        private static void SkinSetup()
        {
            GameObject     model          = survivorPrefab.GetComponentInChildren <ModelLocator>().modelTransform.gameObject;
            CharacterModel characterModel = model.GetComponent <CharacterModel>();

            if (model.GetComponent <ModelSkinController>())
            {
                DiggerPlugin.Destroy(model.GetComponent <ModelSkinController>());
            }

            ModelSkinController skinController = model.AddComponent <ModelSkinController>();
            ChildLocator        childLocator   = model.GetComponent <ChildLocator>();

            SkinnedMeshRenderer mainRenderer = Reflection.GetFieldValue <SkinnedMeshRenderer>(characterModel, "mainSkinnedMeshRenderer");

            LanguageAPI.Add("DIRESEEKER_BODY_DEFAULT_SKIN_NAME", "Default");

            LoadoutAPI.SkinDefInfo skinDefInfo = default(LoadoutAPI.SkinDefInfo);
            skinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            skinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];
            skinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];

            skinDefInfo.GameObjectActivations = Array.Empty <SkinDef.GameObjectActivation>();

            skinDefInfo.Icon             = Assets.mainAssetBundle.LoadAsset <Sprite>("texMoltenAchievement");
            skinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[0];

            /*{
             *  new SkinDef.MeshReplacement
             *  {
             *      renderer = mainRenderer,
             *      mesh = mainRenderer.sharedMesh
             *  }
             * };*/
            skinDefInfo.Name           = "DIRESEEKER_BODY_DEFAULT_SKIN_NAME";
            skinDefInfo.NameToken      = "DIRESEEKER_BODY_DEFAULT_SKIN_NAME";
            skinDefInfo.RendererInfos  = characterModel.baseRendererInfos;
            skinDefInfo.RootObject     = model;
            skinDefInfo.UnlockableName = "";

            SkinDef defaultSkin = LoadoutAPI.CreateNewSkinDef(skinDefInfo);

            skinController.skins = new SkinDef[1]
            {
                defaultSkin
            };
        }
示例#11
0
        /// <summary>
        /// Creates a new SkinDef from a SkinDefInfo.
        /// Note that this prevents null-refs by disabling SkinDef awake while the SkinDef is being created.
        /// The things that occur during awake are performed when first applied to a character instead.
        /// </summary>
        /// <param name="skin"></param>
        /// <returns></returns>
        public static SkinDef CreateNewSkinDef(SkinDefInfo skin)
        {
            On.RoR2.SkinDef.Awake += DoNothing;

            SkinDef newSkin = ScriptableObject.CreateInstance <SkinDef>();

            newSkin.baseSkins      = skin.baseSkins;
            newSkin.icon           = skin.icon;
            newSkin.unlockableName = skin.unlockableName;
            newSkin.rootObject     = skin.rootObject;
            newSkin.rendererInfos  = skin.rendererInfos;
            newSkin.nameToken      = skin.nameToken;
            newSkin.name           = skin.name;

            On.RoR2.SkinDef.Awake -= DoNothing;
            return(newSkin);
        }
示例#12
0
        public static SkinDef CreateSkinDef(string skinName, Sprite skinIcon, CharacterModel.RendererInfo[] rendererInfos, SkinnedMeshRenderer mainRenderer, GameObject root, UnlockableDef unlockableDef, Mesh skinMesh)
        {
            SkinDefInfo skinDefInfo = new SkinDefInfo
            {
                BaseSkins             = Array.Empty <SkinDef>(),
                GameObjectActivations = new SkinDef.GameObjectActivation[0],
                Icon             = skinIcon,
                MeshReplacements = new SkinDef.MeshReplacement[]
                {
                    new SkinDef.MeshReplacement
                    {
                        renderer = mainRenderer,
                        mesh     = skinMesh
                    }
                },
                MinionSkinReplacements = new SkinDef.MinionSkinReplacement[0],
                Name      = skinName,
                NameToken = skinName,
                ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0],
                RendererInfos = rendererInfos,
                RootObject    = root,
                UnlockableDef = unlockableDef
            };

            On.RoR2.SkinDef.Awake += DoNothing;

            SkinDef skinDef = ScriptableObject.CreateInstance <RoR2.SkinDef>();

            skinDef.baseSkins                   = skinDefInfo.BaseSkins;
            skinDef.icon                        = skinDefInfo.Icon;
            skinDef.unlockableDef               = skinDefInfo.UnlockableDef;
            skinDef.rootObject                  = skinDefInfo.RootObject;
            skinDef.rendererInfos               = skinDefInfo.RendererInfos;
            skinDef.gameObjectActivations       = skinDefInfo.GameObjectActivations;
            skinDef.meshReplacements            = skinDefInfo.MeshReplacements;
            skinDef.projectileGhostReplacements = skinDefInfo.ProjectileGhostReplacements;
            skinDef.minionSkinReplacements      = skinDefInfo.MinionSkinReplacements;
            skinDef.nameToken                   = skinDefInfo.NameToken;
            skinDef.name                        = skinDefInfo.Name;

            On.RoR2.SkinDef.Awake -= DoNothing;

            return(skinDef);
        }
示例#13
0
        private static void CreateSkins()
        {
            GameObject     model          = characterPrefab.GetComponentInChildren <ModelLocator>().modelTransform.gameObject;
            CharacterModel characterModel = model.GetComponent <CharacterModel>();

            ModelSkinController skinController = model.AddComponent <ModelSkinController>();
            ChildLocator        childLocator   = model.GetComponent <ChildLocator>();

            SkinnedMeshRenderer mainRenderer = characterModel.mainSkinnedMeshRenderer;

            CharacterModel.RendererInfo[] defaultRenderers = characterModel.baseRendererInfos;

            List <SkinDef> skins = new List <SkinDef>();

            #region DefaultSkin
            SkinDef defaultSkin = Modules.Skins.CreateSkinDef(HenryPlugin.developerPrefix + "_HENRY_BODY_DEFAULT_SKIN_NAME",
                                                              Assets.mainAssetBundle.LoadAsset <Sprite>("texMainSkin"),
                                                              defaultRenderers,
                                                              mainRenderer,
                                                              model);
            skins.Add(defaultSkin);
            #endregion

            #region MasterySkin
            Material masteryMat = Modules.Assets.CreateMaterial("matHenryAlt");
            CharacterModel.RendererInfo[] masteryRendererInfos = SkinRendererInfos(defaultRenderers, new Material[]
            {
                masteryMat,
                masteryMat,
                masteryMat
            });

            SkinDef masterySkin = Modules.Skins.CreateSkinDef(HenryPlugin.developerPrefix + "_HENRY_BODY_MASTERY_SKIN_NAME",
                                                              Assets.mainAssetBundle.LoadAsset <Sprite>("texMasteryAchievement"),
                                                              masteryRendererInfos,
                                                              mainRenderer,
                                                              model,
                                                              HenryPlugin.developerPrefix + "_HENRY_BODY_MASTERYUNLOCKABLE_REWARD_ID");
            skins.Add(masterySkin);
            #endregion

            skinController.skins = skins.ToArray();
        }
示例#14
0
        public static void RegisterSkins()
        {
            GameObject bodyPrefab = Templar.myCharacter;

            GameObject          model          = bodyPrefab.GetComponentInChildren <ModelLocator>().modelTransform.gameObject;
            CharacterModel      characterModel = model.GetComponent <CharacterModel>();
            ModelSkinController skinController = model.AddComponent <ModelSkinController>();
            ChildLocator        childLocator   = model.GetComponent <ChildLocator>();
            SkinnedMeshRenderer mainRenderer   = Reflection.GetFieldValue <SkinnedMeshRenderer>(characterModel, "mainSkinnedMeshRenderer");

            #region Default Skin
            LanguageAPI.Add("Templar_DEFAULT_SKIN", "Default");
            LoadoutAPI.SkinDefInfo skinDefInfo = default(LoadoutAPI.SkinDefInfo);
            skinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            skinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];
            skinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];
            skinDefInfo.Icon             = LoadoutAPI.CreateSkinIcon(new Color(0.64f, 0.31f, 0.22f), new Color(0.54f, 0.21f, 0.12f), new Color(0.64f, 0.31f, 0.22f), new Color(0.54f, 0.21f, 0.12f));
            skinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[0];
            skinDefInfo.Name             = "Templar_DEFAULT_SKIN";
            skinDefInfo.NameToken        = "Templar_DEFAULT_SKIN";
            skinDefInfo.RendererInfos    = characterModel.baseRendererInfos;
            skinDefInfo.RootObject       = model;
            CharacterModel.RendererInfo[] rendererInfos = skinDefInfo.RendererInfos;
            CharacterModel.RendererInfo[] array         = new CharacterModel.RendererInfo[rendererInfos.Length];
            rendererInfos.CopyTo(array, 0);
            Material material = array[0].defaultMaterial;
            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(LegacyResourcesAPI.Load <GameObject>("Prefabs/CharacterBodies/ClayBruiserBody").GetComponentInChildren <CharacterModel>().baseRendererInfos[0].defaultMaterial);
                array[0].defaultMaterial = material;
            }
            skinDefInfo.RendererInfos = array;
            SkinDef defaultSkin = LoadoutAPI.CreateNewSkinDef(skinDefInfo);
            #endregion

            var skinDefs = new List <SkinDef>()
            {
                defaultSkin
            };

            skinController.skins = skinDefs.ToArray();
        }
示例#15
0
        public static Skin Create(CharacterModel character, params SkinDef[] baseSkins)
        {
            if (character == null)
            {
                throw new ArgumentNullException(nameof(character));
            }

            GameObject root = character.gameObject;

            if (root == null)
            {
                throw new ArgumentNullException(nameof(character));
            }

            ModelSkinController controller = root.AddOrGetComponent <ModelSkinController>();

            if (controller == null)
            {
                throw new ArgumentNullException(nameof(character));
            }
            controller.skins ??= Array.Empty <SkinDef>();

            HooksCore.RoR2.SkinDef.Awake.On += DoNothing;
            SkinDef def = ScriptableObject.CreateInstance <SkinDef>();

            HooksCore.RoR2.SkinDef.Awake.On -= DoNothing;

            if (def == null)
            {
                throw new Exception("Failed to create SkinDef");
            }

            def.rootObject = root;
            def.baseSkins  = baseSkins;

            if (baseSkins.Length == 0)
            {
                def.rendererInfos = character.baseRendererInfos.Clone() as CharacterModel.RendererInfo[];
            }

            return(new Skin(def, root, character, controller));
        }
        ////////////////////////////////////////////////////////////////////////////
        ////// Local Functions (these should not need to be changed when added to different skins)

        //private static void SkinDefApply(On.RoR2.SkinDef.orig_Apply orig, SkinDef self, GameObject modelObject) //Old SkinDefApply for use w/ mmhook
        private static void SkinDefApply(Action <SkinDef, GameObject> orig, SkinDef self, GameObject modelObject)
        {
            orig(self, modelObject);

            RemoveInvalidModelObjects();

            ModifiedObjects.TryGetValue(modelObject, out var modificatons);

            try
            {
                //if we are on another character/skin
                if (self != SkinDef)
                {
                    if (modificatons != null)
                    {
                        ClearSkinModifications(LastModelObject, modificatons);
                    }
                    return;
                }

                if (modificatons == null)
                {
                    //otherwise if are now applying modded skin and no modifcations have been made, then apply modifications

                    //create new Applied Entry and pass into Apply
                    AppliedModifications NewMods = new AppliedModifications();
                    ModifiedObjects.Add(modelObject, NewMods);
                    ApplySkinModifications(modelObject, NewMods);
                }
            }
            catch (Exception e)
            {
                //error logging may need to be skin specific
                InstanceLogger.LogWarning("An error occured while adding accessories to a skin");
                InstanceLogger.LogError(e);
            }

            //print heiarchy
            //RuneFoxMods.Utils.readheiarchy(modelObject);
        }
示例#17
0
        public ReverseSkin(GameObject modelObject, SkinDef skinDef)
        {
            this.modelObject = modelObject;
            skinDef.Bake();
            var runtimeSkin = skinDef.runtimeSkin;

            baseRendererInfos.AddRange(modelObject.GetComponent <CharacterModel>().baseRendererInfos);
            foreach (var objectActivation in runtimeSkin.gameObjectActivationTemplates)
            {
                gameObjectActivationTemplates.Add(new SkinDef.GameObjectActivationTemplate
                {
                    path           = objectActivation.path,
                    shouldActivate = !objectActivation.shouldActivate
                });
            }
            foreach (var meshReplacement in runtimeSkin.meshReplacementTemplates)
            {
                var renderer = modelObject.transform.Find(meshReplacement.path).GetComponent <Renderer>();

                Mesh mesh = null;
                switch (renderer)
                {
                case MeshRenderer _:
                    mesh = renderer.GetComponent <MeshFilter>().sharedMesh;
                    break;

                case SkinnedMeshRenderer skinnedMeshRenderer:
                    mesh = skinnedMeshRenderer.sharedMesh;
                    break;
                }

                meshReplacementTemplates.Add(new SkinDef.MeshReplacementTemplate
                {
                    path = meshReplacement.path,
                    mesh = mesh
                });
            }
        }
示例#18
0
        //update character preview
        private void UpdateCharacterPreview(On.RoR2.UI.CharacterSelectController.orig_OnNetworkUserLoadoutChanged orig, RoR2.UI.CharacterSelectController self, NetworkUser networkUser)
        {
            orig(self, networkUser);
            int num = self.GetSortedNetworkUsersList().IndexOf(networkUser);

            if (num != -1)
            {
                RoR2.UI.CharacterSelectController.CharacterPad safe = HG.ArrayUtils.GetSafe <RoR2.UI.CharacterSelectController.CharacterPad>(self.characterDisplayPads, num);
                if (safe.displayInstance)
                {
                    Loadout loadout = new Loadout();
                    networkUser.networkLoadout.CopyLoadout(loadout);
                    int            bodyIndexFromSurvivorIndex = SurvivorCatalog.GetBodyIndexFromSurvivorIndex(safe.displaySurvivorIndex);
                    int            skinIndex           = (int)loadout.bodyLoadoutManager.GetSkinIndex(bodyIndexFromSurvivorIndex);
                    SkinDef        safe2               = HG.ArrayUtils.GetSafe <SkinDef>(BodyCatalog.GetBodySkins(bodyIndexFromSurvivorIndex), skinIndex);
                    CharacterModel componentInChildren = safe.displayInstance.GetComponentInChildren <CharacterModel>();
                    if (componentInChildren && safe2 != null)
                    {
                        safe2.Apply(componentInChildren.gameObject);
                    }
                }
            }
        }
示例#19
0
        private static void InitializeSkins()
        {
            GameObject     model          = bodyPrefab.GetComponentInChildren <ModelLocator>().modelTransform.gameObject;
            CharacterModel characterModel = model.GetComponent <CharacterModel>();

            DestroyImmediate(model.GetComponent <ModelSkinController>());
            ModelSkinController skinController = model.AddComponent <ModelSkinController>();
            ChildLocator        childLocator   = model.GetComponent <ChildLocator>();

            SkinnedMeshRenderer mainRenderer = characterModel.mainSkinnedMeshRenderer;

            CharacterModel.RendererInfo[] defaultRenderers = characterModel.baseRendererInfos;

            List <SkinDef> skins = new List <SkinDef>();

            #region DefaultSkin
            SkinDef defaultSkin = Modules.Skins.CreateSkinDef("Default",
                                                              Loadouts.CreateSkinIcon(new Color(0.8f, 0.8f, 0.8f), new Color(0.8f, 0.8f, 0.8f), new Color(0.8f, 0.8f, 0.8f), new Color(0.8f, 0.8f, 0.8f)),
                                                              defaultRenderers,
                                                              mainRenderer,
                                                              model);

            skins.Add(defaultSkin);
            #endregion

            #region MasterySkin
            SkinDef masterySkin = Modules.Skins.CreateSkinDef("Mastery",
                                                              Loadouts.CreateSkinIcon(new Color(0.15f, 0.15f, 0.15f), new Color(0.15f, 0.15f, 0.15f), new Color(0.15f, 0.15f, 0.15f), new Color(0.15f, 0.15f, 0.15f)),
                                                              defaultRenderers,
                                                              mainRenderer,
                                                              model);

            skins.Add(masterySkin);
            #endregion

            skinController.skins = skins.ToArray();
        }
示例#20
0
        /// <summary>
        /// Adds a skin to the body prefab for a character.
        /// Will attempt to create a default skin if one is not present.
        /// Must be called during plugin Awake or OnEnable. If called afterwards the new skins must be added to bodycatalog manually.
        /// </summary>
        /// <param name="bodyPrefab">The body to add the skin to</param>
        /// <param name="skin">The SkinDef to add</param>
        /// <returns>True if successful</returns>
        public static Boolean AddSkinToCharacter(GameObject bodyPrefab, SkinDef skin)
        {
            if (bodyPrefab == null)
            {
                R2API.Logger.LogError("Tried to add skin to null body prefab.");
                return(false);
            }

            if (skin == null)
            {
                R2API.Logger.LogError("Tried to add invalid skin.");
                return(false);
            }
            addedSkins.Add(skin);

            var modelLocator = bodyPrefab.GetComponent <ModelLocator>();

            if (modelLocator == null)
            {
                R2API.Logger.LogError("Tried to add skin to invalid body prefab (No ModelLocator).");
                return(false);
            }

            var model = modelLocator.modelTransform;

            if (model == null)
            {
                R2API.Logger.LogError("Tried to add skin to body prefab with no modelTransform.");
                return(false);
            }

            if (skin.rootObject != model.gameObject)
            {
                R2API.Logger.LogError("Tried to add skin with improper root object set.");
                return(false);
            }

            var modelSkins = model.GetComponent <ModelSkinController>();

            if (modelSkins == null)
            {
                R2API.Logger.LogWarning(bodyPrefab.name + " does not have a modelSkinController.\nAdding a new one and attempting to populate the default skin.\nHighly recommended you set the controller up manually.");
                var charModel = model.GetComponent <CharacterModel>();
                if (charModel == null)
                {
                    R2API.Logger.LogError("Unable to locate CharacterModel, default skin creation aborted.");
                    return(false);
                }

                var skinnedRenderer = charModel.GetFieldValue <SkinnedMeshRenderer>("mainSkinnedMeshRenderer");
                if (skinnedRenderer == null)
                {
                    R2API.Logger.LogError("CharacterModel did not contain a main SkinnedMeshRenderer, default skin creation aborted.");
                    return(false);
                }

                var baseRenderInfos = charModel.baseRendererInfos;
                if (baseRenderInfos == null || baseRenderInfos.Length == 0)
                {
                    R2API.Logger.LogError("CharacterModel rendererInfos are invalid, default skin creation aborted.");
                    return(false);
                }

                modelSkins = model.gameObject.AddComponent <ModelSkinController>();

                var skinDefInfo = new SkinDefInfo {
                    baseSkins             = Array.Empty <SkinDef>(),
                    gameObjectActivations = Array.Empty <SkinDef.GameObjectActivation>(),
                    icon             = CreateDefaultSkinIcon(),
                    name             = "skin" + bodyPrefab.name + "Default",
                    nameToken        = bodyPrefab.name.ToUpper() + "_DEFAULT_SKIN_NAME",
                    rootObject       = model.gameObject,
                    unlockableName   = "",
                    meshReplacements = new SkinDef.MeshReplacement[1]
                    {
                        new SkinDef.MeshReplacement {
                            renderer = skinnedRenderer,
                            mesh     = skinnedRenderer.sharedMesh
                        }
                    },
                    rendererInfos = charModel.baseRendererInfos
                };

                var defaultSkinDef = CreateNewSkinDef(skinDefInfo);

                modelSkins.skins = new SkinDef[1] {
                    defaultSkinDef
                };
            }

            var skinsArray = modelSkins.skins;
            var index      = skinsArray.Length;

            Array.Resize <SkinDef>(ref skinsArray, index + 1);
            skinsArray[index] = skin;
            modelSkins.skins  = skinsArray;
            return(true);
        }
示例#21
0
 static partial void MercBodyMercenary2BSkinAdded(SkinDef skinDef, GameObject bodyPrefab)
 {
     SkinDef = skinDef;
 }
        public void AddSkin(GameObject gameObject, string SkinFolder, ConfigFile config)
        {
            LoadoutAPI.SkinDefInfo skinDefInfo = new LoadoutAPI.SkinDefInfo();
            skinDefInfo.BaseSkins             = new SkinDef[0];
            skinDefInfo.Icon                  = LoadoutAPI.CreateSkinIcon(config.Bind <Color>("", "IconColorTop", Color.magenta).Value, config.Bind <Color>("", "IconColorRight", Color.black).Value, config.Bind <Color>("", "IconColorBottom", Color.magenta).Value, config.Bind <Color>("", "IconColorLeft", Color.black).Value);
            skinDefInfo.NameToken             = config.Bind <string>("", "SkinName", "DefaultName").Value;
            skinDefInfo.UnlockableName        = config.Bind <string>("", "UnlockableName", "").Value;
            skinDefInfo.RootObject            = gameObject.GetComponentInChildren <ModelLocator>().modelTransform.gameObject;
            skinDefInfo.RendererInfos         = new CharacterModel.RendererInfo[0];
            skinDefInfo.MeshReplacements      = new SkinDef.MeshReplacement[0];
            skinDefInfo.GameObjectActivations = new SkinDef.GameObjectActivation[0];
            skinDefInfo.Name                  = "CUSTOM_" + gameObject.name + "_SKIN";

            base.Logger.LogInfo("Adding new skin to " + gameObject.name + " with name " + skinDefInfo.NameToken);

            int    MeshReplacementIndex = config.Bind <int>("", "MeshReplacementIndex", -1).Value;
            string MeshReplacementKey   = config.Bind <string>("", "SkinMeshToUse", "Default").Value;

            string minionSkinForBody = config.Bind <string>("", "MinionReplacementForBody", "NONE", new ConfigDescription("If this is a minion skin, determines the characterbody for it")).Value;
            string minionSkinForSkin = config.Bind <string>("", "MinionReplacementForSkin", "NONE", new ConfigDescription("If this is a minion skin, determines the characterbody for it")).Value;


            bool isMinionSkin = false;

            if (minionSkinForBody != null)
            {
                isMinionSkin = minionSkinForBody != "NONE";
            }


            if (MeshReplacementKey != "Default" && MeshReplacementKey != "Custom" && MeshReplacementKey != null)
            {
                SkinDef def1 = gameObject.GetComponentInChildren <ModelLocator>().modelTransform.GetComponentInChildren <ModelSkinController>().skins.First(x => x.nameToken == MeshReplacementKey);
                MeshReplacementIndex = Array.IndexOf(gameObject.GetComponentInChildren <ModelLocator>().modelTransform.GetComponentInChildren <ModelSkinController>().skins, def1);
            }

            SkinDef def = gameObject.GetComponentInChildren <ModelLocator>().modelTransform.GetComponentInChildren <ModelSkinController>().skins[MeshReplacementIndex];

            if (def)
            {
                skinDefInfo.MeshReplacements = def.meshReplacements;
                skinDefInfo.RendererInfos    = def.rendererInfos;
            }

            CharacterModel.RendererInfo[] rendererInfos = skinDefInfo.RendererInfos;
            CharacterModel.RendererInfo[] array         = new CharacterModel.RendererInfo[rendererInfos.Length];
            rendererInfos.CopyTo(array, 0);



            foreach (string MaterialFolder in Directory.EnumerateDirectories(SkinFolder))
            {
                //Get name of render from folder name
                string[] MaterialIndexVs = MaterialFolder.Split(new string[] { @"\" }, StringSplitOptions.None);
                string   RendererName    = MaterialIndexVs[MaterialIndexVs.Length - 1];

                //Find the renderer based on the name
                int index = Array.IndexOf(array, array.FirstOrDefault(x => x.renderer.name == RendererName));

                //Get the material of the renderer
                Material defaultMaterial = array[index].defaultMaterial;


                if (defaultMaterial)
                {
                    //Create a clone of the material
                    defaultMaterial = UnityEngine.Object.Instantiate <Material>(defaultMaterial);

                    //Iterate through all files related to this material from the skin folder
                    foreach (string FilePath in Directory.EnumerateFiles(MaterialFolder))
                    {
                        //Loading and applying textures from .png
                        if (FilePath.EndsWith(".PNG") || FilePath.EndsWith(".png"))
                        {
                            //Use File name to get texture name
                            string[] FilePathVs = FilePath.Split(new string[] { @"\" }, StringSplitOptions.None);
                            string   FileName   = FilePathVs[FilePathVs.Length - 1].Replace(".PNG", "");

                            //Create new Texture2d and load image in
                            Texture2D savedTex = new Texture2D(1, 1, TextureFormat.RGBAFloat, false, true);
                            ImageConversion.LoadImage(savedTex, System.IO.File.ReadAllBytes(FilePath));

                            //Apply the loaded image
                            savedTex.Apply();

                            //Attempt to place this image onto the material in the correct property
                            if (defaultMaterial.HasProperty(FileName))
                            {
                                defaultMaterial.enableInstancing = true;
                                defaultMaterial.SetTexture(FileName, GetReadableTextureCopy(savedTex));
                            }
                        }
                        else if (FilePath.EndsWith(".cfg"))
                        {
                            //Load the config at this path
                            BepInEx.Configuration.ConfigFile perMatConfig = new ConfigFile(FilePath, true);

                            //iterate through material properties and apply via config
                            foreach (string value in floatProperties)
                            {
                                if (defaultMaterial.HasProperty(value))
                                {
                                    defaultMaterial.SetFloat(value, perMatConfig.Bind <float>("", value, defaultMaterial.GetFloat(value), new ConfigDescription("Sets the value for " + value)).Value);
                                }
                            }

                            foreach (string value in colorProperties)
                            {
                                if (defaultMaterial.HasProperty(value))
                                {
                                    defaultMaterial.SetColor(value, perMatConfig.Bind <Color>("", value, defaultMaterial.GetColor(value), new ConfigDescription("Sets the value for " + value)).Value);
                                }
                            }

                            foreach (string value in defaultMaterial.shaderKeywords)
                            {
                                bool isEnabled = perMatConfig.Bind <bool>("", value, defaultMaterial.IsKeywordEnabled(value), new ConfigDescription("Sets the value for " + value)).Value;

                                if (isEnabled)
                                {
                                    defaultMaterial.EnableKeyword(value);
                                }
                                else
                                {
                                    defaultMaterial.DisableKeyword(value);
                                }
                            }
                        }
                        else
                        {
                            base.Logger.LogError("Unsupported file found in material folder: " + FilePath);
                        }
                    }


                    array[index].defaultMaterial = defaultMaterial;
                }
            }

            skinDefInfo.RendererInfos = array;
            LoadoutAPI.AddSkinToCharacter(gameObject, skinDefInfo);

            SkinDef[] skins = gameObject.GetComponentInChildren <ModelLocator>().modelTransform.GetComponentInChildren <ModelSkinController>().skins;

            skins[skins.Length - 1].minionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];
            skins[skins.Length - 1].projectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];


            if (isMinionSkin)
            {
                base.Logger.LogInfo("Is a minion skin");

                foreach (GameObject body in BodyCatalog.allBodyPrefabs)
                {
                    if (body.name == minionSkinForBody)
                    {
                        base.Logger.LogInfo("Applying minionskinreplacement");

                        SkinDef defForMaster = body.GetComponentInChildren <ModelSkinController>().skins.First(x => x.nameToken == minionSkinForSkin);

                        base.Logger.LogInfo("Size was " + defForMaster.minionSkinReplacements.Length);


                        Array.Resize(ref defForMaster.minionSkinReplacements, defForMaster.minionSkinReplacements.Length + 1);
                        defForMaster.minionSkinReplacements[defForMaster.minionSkinReplacements.Length - 1] = new SkinDef.MinionSkinReplacement()
                        {
                            minionBodyPrefab = gameObject, minionSkin = skins[skins.Length - 1]
                        };

                        base.Logger.LogInfo("Size is now " + defForMaster.minionSkinReplacements.Length);
                    }
                }
            }

            SkinDef[][] newSkins = typeof(BodyCatalog).GetFieldValue <SkinDef[][]>("skins");
            newSkins[BodyCatalog.FindBodyIndex(gameObject)] = skins;
            typeof(BodyCatalog).SetFieldValue <SkinDef[][]>("skins", newSkins);
        }
示例#23
0
 private static void Nothing(Action <SkinDef> orig, SkinDef self)
 {
 }
 //Name for this is generated from the skinDef generator
 static partial void BodyNameSkinNameSkinAdded(SkinDef skinDef, GameObject bodyPrefab)
 {
     SkinDef = skinDef;
 }
示例#25
0
        public static void RegisterSkins()
        {
            GameObject bodyPrefab = Prefabs.paladinPrefab;

            GameObject     model          = bodyPrefab.GetComponentInChildren <ModelLocator>().modelTransform.gameObject;
            CharacterModel characterModel = model.GetComponent <CharacterModel>();

            ModelSkinController skinController = model.AddComponent <ModelSkinController>();
            ChildLocator        childLocator   = model.GetComponent <ChildLocator>();

            SkinnedMeshRenderer mainRenderer = characterModel.mainSkinnedMeshRenderer;

            GameObject   displayPrefab       = Prefabs.paladinDisplayPrefab;
            ChildLocator displayChildLocator = displayPrefab.GetComponent <ChildLocator>();

            paladinCSSPreviewController            = displayPrefab.GetComponent <CharacterSelectSurvivorPreviewDisplayController>();
            paladinCSSPreviewController.bodyPrefab = bodyPrefab;
            defaultResponses = paladinCSSPreviewController.skinChangeResponses;

            List <SkinDef> skinDefs = new List <SkinDef>();

            GameObject cape                = childLocator.FindChild("Cape").gameObject;
            GameObject armLeft             = childLocator.FindChild("CreepyArmsLeft").gameObject;
            GameObject armRight            = childLocator.FindChild("CreepyArmsRight").gameObject;
            GameObject fuckingCrystalCrown = childLocator.FindChild("F****e").gameObject;

            allGameObjectActivations.Add(cape);
            allGameObjectActivations.Add(armLeft);
            allGameObjectActivations.Add(armRight);
            allGameObjectActivations.Add(fuckingCrystalCrown);

            SkinDef.GameObjectActivation[] defaultActivations = getActivations();
            SkinDef.GameObjectActivation[] capeActivations    = getActivations(cape);
            SkinDef.GameObjectActivation[] nkuhanaActivations = getActivations(armLeft, armRight);
            SkinDef.GameObjectActivation[] GMActivations      = getActivations(cape, fuckingCrystalCrown);

            #region DefaultSkin
            CharacterModel.RendererInfo[] defaultRenderers = characterModel.baseRendererInfos;
            int     lastRend    = defaultRenderers.Length - 1;
            SkinDef defaultSkin = CreateSkinDef("PALADINBODY_DEFAULT_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texMainSkin"), defaultRenderers, mainRenderer, model);
            defaultSkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.defaultMesh,
                    renderer = defaultRenderers[lastRend].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.defaultSwordMesh,
                    renderer = defaultRenderers[0].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.defaultCapeMesh,
                    renderer = defaultRenderers[1].renderer
                },
            };

            if (Modules.Config.cape.Value)
            {
                defaultSkin.gameObjectActivations = capeActivations;
                childLocator.FindChild("Cape").gameObject.SetActive(true);
            }
            else
            {
                defaultSkin.gameObjectActivations = defaultActivations;
            }

            AddCSSSkinChangeResponse(defaultSkin, paladinCSSEffect.DEFAULT);

            skinDefs.Add(defaultSkin);
            #endregion

            #region MasterySkin(lunar)
            CharacterModel.RendererInfo[] masteryRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(masteryRendererInfos, 0);

            // add the passive effect
            #region clone mithrix effect
            GameObject lunarPassiveEffect = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs/CharacterBodies/BrotherBody").GetComponentInChildren <ChildLocator>().FindChild("Phase3HammerFX").gameObject);
            lunarPassiveEffect.transform.parent        = childLocator.FindChild("SwordActiveEffectLunar");
            lunarPassiveEffect.transform.localScale    = Vector3.one * 0.0002f;
            lunarPassiveEffect.transform.rotation      = Quaternion.Euler(new Vector3(45, 90, 0));
            lunarPassiveEffect.transform.localPosition = new Vector3(0, 0, -0.003f);
            lunarPassiveEffect.gameObject.SetActive(true);

            lunarPassiveEffect.transform.Find("Amb_Fire_Ps, Left").localScale  = Vector3.one * 0.6f;
            lunarPassiveEffect.transform.Find("Amb_Fire_Ps, Right").localScale = Vector3.one * 0.6f;
            lunarPassiveEffect.transform.Find("Core, Light").localScale        = Vector3.one * 0.1f;
            lunarPassiveEffect.transform.Find("Blocks, Spinny").localScale     = Vector3.one * 0.4f;
            lunarPassiveEffect.transform.Find("Sparks").localScale             = Vector3.one * 0.4f;

            lunarPassiveEffect = GameObject.Instantiate(lunarPassiveEffect);
            lunarPassiveEffect.transform.parent        = displayChildLocator.FindChild("SwordActiveEffectLunar");
            lunarPassiveEffect.transform.localScale    = Vector3.one * 0.0002f;
            lunarPassiveEffect.transform.rotation      = Quaternion.Euler(new Vector3(45, 90, 0));
            lunarPassiveEffect.transform.localPosition = new Vector3(0, 0, -0.003f);
            lunarPassiveEffect.gameObject.SetActive(true);
            #endregion

            Material lunarSwordMat = CreateMaterial("matLunarSword", 0, Color.black, 1f);
            lunarSwordMat.EnableKeyword("FORCE_SPEC");
            lunarSwordMat.EnableKeyword("FRESNEL_EMISSION");
            lunarSwordMat.SetFloat("_SpecularStrength", 1f);
            masteryRendererInfos[0].defaultMaterial = lunarSwordMat;
            //masteryRendererInfos[1].defaultMaterial = CreateMaterial("matLunarCape");
            masteryRendererInfos[lastRend].defaultMaterial = CreateMaterial("matLunarPaladin", 5, Color.white, 1f);

            SkinDef masterySkin = CreateSkinDef("PALADINBODY_LUNAR_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texMasteryAchievement"), masteryRendererInfos, mainRenderer, model, Modules.Unlockables.paladinMasterySkinDef);
            masterySkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.lunarMesh,
                    renderer = defaultRenderers[lastRend].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.lunarSwordMesh,
                    renderer = defaultRenderers[0].renderer
                }
            };

            masterySkin.gameObjectActivations = defaultActivations;

            masterySkin.projectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[] {
                new SkinDef.ProjectileGhostReplacement {
                    projectilePrefab = Projectiles.swordBeamProjectile,
                    projectileGhostReplacementPrefab = Projectiles.CloneAndColorSwordBeam(new Color(0.3f, 0.1f, 1f), 1.2f)//slightly darker blue than normal
                }
            };

            AddCSSSkinChangeResponse(masterySkin, paladinCSSEffect.LUNAR);

            skinDefs.Add(masterySkin);
            #endregion

            #region GrandMasterySkin
            CharacterModel.RendererInfo[] grandMasteryRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(grandMasteryRendererInfos, 0);

            grandMasteryRendererInfos[0].defaultMaterial        = CreateMaterial("matPaladinGMSword", StaticValues.maxSwordGlow, Color.white);
            grandMasteryRendererInfos[1].defaultMaterial        = CreateMaterial("matPaladinGM", 10, Color.white);
            grandMasteryRendererInfos[lastRend].defaultMaterial = CreateMaterial("matPaladinGM", 10, Color.white);

            SkinDef grandMasterySkin = CreateSkinDef("PALADINBODY_TYPHOON_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texGrandMasteryAchievement"), grandMasteryRendererInfos, mainRenderer, model, Modules.Unlockables.paladinGrandMasterySkinDef);
            grandMasterySkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.gmMesh,
                    renderer = defaultRenderers[lastRend].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.gmSwordMesh,
                    renderer = defaultRenderers[0].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.gmCapeMesh,
                    renderer = defaultRenderers[1].renderer
                }
            };

            grandMasterySkin.gameObjectActivations = GMActivations;

            AddCSSSkinChangeResponse(grandMasterySkin, paladinCSSEffect.BEEFY);

            if (PaladinPlugin.starstormInstalled)
            {
                skinDefs.Add(grandMasterySkin);
            }

            #endregion

            #region PoisonSkin
            CharacterModel.RendererInfo[] poisonRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(poisonRendererInfos, 0);

            poisonRendererInfos[0].defaultMaterial        = CreateMaterial("matPaladinNkuhanaScythe", StaticValues.maxSwordGlow, Color.white);
            poisonRendererInfos[lastRend].defaultMaterial = CreateMaterial("matPaladinNkuhana", 3, Color.white);

            SkinDef poisonSkin = CreateSkinDef("PALADINBODY_POISON_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texPoisonAchievement"), poisonRendererInfos, mainRenderer, model, Modules.Unlockables.paladinPoisonSkinDef);
            poisonSkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.poisonMesh,
                    renderer = defaultRenderers[lastRend].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.poisonSwordMesh,
                    renderer = defaultRenderers[0].renderer
                }
                //if arms are only in this skin they don't need to be mesh replacements, just gameobjectactivations
            };

            poisonSkin.gameObjectActivations = nkuhanaActivations;

            poisonSkin.projectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[] {
                new SkinDef.ProjectileGhostReplacement {
                    projectilePrefab = Projectiles.swordBeamProjectile,
                    projectileGhostReplacementPrefab = Projectiles.CloneAndColorSwordBeam(Color.green, 0.6f)
                }
            };

            AddCSSSkinChangeResponse(poisonSkin, paladinCSSEffect.GREENSCYTHE);

            skinDefs.Add(poisonSkin);
            #endregion

            #region ClaySkin
            CharacterModel.RendererInfo[] clayRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(clayRendererInfos, 0);

            clayRendererInfos[0].defaultMaterial        = CreateMaterial("matClayPaladin", StaticValues.maxSwordGlow, Color.white);
            clayRendererInfos[lastRend].defaultMaterial = CreateMaterial("matClayPaladin", 10, Color.white);

            SkinDef claySkin = CreateSkinDef("PALADINBODY_CLAY_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texClayAchievement"), clayRendererInfos, mainRenderer, model, Modules.Unlockables.paladinClaySkinDef);
            claySkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.clayMesh,
                    renderer = defaultRenderers[lastRend].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.claySwordMesh,
                    renderer = defaultRenderers[0].renderer
                }
            };

            claySkin.gameObjectActivations = defaultActivations;

            claySkin.projectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[] {
                new SkinDef.ProjectileGhostReplacement {
                    projectilePrefab = Projectiles.swordBeamProjectile,
                    projectileGhostReplacementPrefab = Projectiles.CloneAndColorSwordBeam(new Color(1f, 0.35f, 0), 0.65f) //yello smello
                }
            };

            AddCSSSkinChangeResponse(claySkin, paladinCSSEffect.TAR);

            skinDefs.Add(claySkin);
            #endregion

            #region SpecterSkin
            CharacterModel.RendererInfo[] specterRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(specterRendererInfos, 0);

            specterRendererInfos[0].defaultMaterial        = CreateMaterial("matPaladinSpecterScythe", StaticValues.maxSwordGlow, Color.white);
            specterRendererInfos[1].defaultMaterial        = CreateMaterial("matPaladinGMOld"); //HACK
            specterRendererInfos[lastRend].defaultMaterial = CreateMaterial("matPaladinSpecter");

            SkinDef specterSkin = CreateSkinDef("PALADINBODY_SPECTER_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texSpecterSkin"), specterRendererInfos, mainRenderer, model);
            specterSkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.specterMesh,
                    renderer = defaultRenderers[lastRend].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.specterSwordMesh,
                    renderer = defaultRenderers[0].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.defaultCapeMesh,
                    renderer = defaultRenderers[1].renderer
                }
            };

            specterSkin.gameObjectActivations = capeActivations;

            specterSkin.projectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[] {
                new SkinDef.ProjectileGhostReplacement {
                    projectilePrefab = Projectiles.swordBeamProjectile,
                    projectileGhostReplacementPrefab = Projectiles.CloneAndColorSwordBeam(Color.red, 0.669f)//slightly darker blue than normal
                }
            };

            AddCSSSkinChangeResponse(specterSkin, paladinCSSEffect.REDSCYTHE);

            if (Modules.Config.cursed.Value)
            {
                skinDefs.Add(specterSkin);
            }

            #endregion

            #region DripSkin
            CharacterModel.RendererInfo[] dripRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(dripRendererInfos, 0);

            dripRendererInfos[0].defaultMaterial        = CreateMaterial("matPaladinDrip", StaticValues.maxSwordGlow, Color.white);
            dripRendererInfos[lastRend].defaultMaterial = CreateMaterial("matPaladinDrip", 3, Color.white);

            SkinDef dripSkin = CreateSkinDef("PALADINBODY_DRIP_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texDripAchievement"), dripRendererInfos, mainRenderer, model);
            dripSkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.dripMesh,
                    renderer = defaultRenderers[lastRend].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.batMesh,
                    renderer = defaultRenderers[0].renderer
                }
            };

            dripSkin.gameObjectActivations = defaultActivations;

            AddCSSSkinChangeResponse(dripSkin, paladinCSSEffect.DEFAULT);

            if (Modules.Config.cursed.Value)
            {
                skinDefs.Add(dripSkin);
            }
            #endregion

            #region MinecraftSkin
            CharacterModel.RendererInfo[] minecraftRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(minecraftRendererInfos, 0);

            minecraftRendererInfos[0].defaultMaterial        = CreateMaterial("matMinecraftSword", StaticValues.maxSwordGlow, Color.white);
            minecraftRendererInfos[lastRend].defaultMaterial = CreateMaterial("matMinecraftPaladin", 3, Color.white);

            SkinDef minecraftSkin = CreateSkinDef("PALADINBODY_MINECRAFT_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texMinecraftSkin"), minecraftRendererInfos, mainRenderer, model);
            minecraftSkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.minecraftMesh,
                    renderer = defaultRenderers[lastRend].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.minecraftSwordMesh,
                    renderer = defaultRenderers[0].renderer
                }
            };

            minecraftSkin.gameObjectActivations = defaultActivations;

            AddCSSSkinChangeResponse(minecraftSkin, paladinCSSEffect.DEFAULT);

            if (Modules.Config.cursed.Value)
            {
                skinDefs.Add(minecraftSkin);
            }
            #endregion

            #region LunarKnightSkin(lunar)
            CharacterModel.RendererInfo[] lunarKnightRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(lunarKnightRendererInfos, 0);

            lunarKnightRendererInfos[0].defaultMaterial        = CreateMaterial("matLunarKnight", StaticValues.maxSwordGlow, Color.white);;
            lunarKnightRendererInfos[lastRend].defaultMaterial = CreateMaterial("matLunarKnight", 5, Color.white, 1f);

            SkinDef lunarKnightSkin = CreateSkinDef("PALADINBODY_LUNARKNIGHT_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texMasteryAchievementLegacy"), lunarKnightRendererInfos, mainRenderer, model, Modules.Unlockables.paladinMasterySkinDef);
            lunarKnightSkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.lunarKnightMesh,
                    renderer = defaultRenderers[lastRend].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.lunarKnightSwordMesh,
                    renderer = defaultRenderers[0].renderer
                }
            };

            lunarKnightSkin.gameObjectActivations = defaultActivations;

            lunarKnightSkin.projectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[] {
                new SkinDef.ProjectileGhostReplacement {
                    projectilePrefab = Projectiles.swordBeamProjectile,
                    projectileGhostReplacementPrefab = Projectiles.CloneAndColorSwordBeam(new Color(0.3f, 0.1f, 1f), 1.2f)//mastery blue
                }
            };

            AddCSSSkinChangeResponse(lunarKnightSkin, paladinCSSEffect.DEFAULT);

            if (Config.legacySkins.Value)
            {
                skinDefs.Add(lunarKnightSkin);
            }
            #endregion
            #region GrandMasterySkinLegacy
            CharacterModel.RendererInfo[] grandMasteryLegacyRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(grandMasteryLegacyRendererInfos, 0);

            grandMasteryLegacyRendererInfos[0].defaultMaterial        = CreateMaterial("matPaladinGMSwordOld", StaticValues.maxSwordGlow, Color.white);
            grandMasteryLegacyRendererInfos[1].defaultMaterial        = CreateMaterial("matPaladinGMOld", 6.9f, Color.white);
            grandMasteryLegacyRendererInfos[lastRend].defaultMaterial = CreateMaterial("matPaladinGMOld", 6.9f, Color.white);

            SkinDef grandMasteryLegacySkin = CreateSkinDef("PALADINBODY_TYPHOONLEGACY_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texGrandMasteryAchievementLegacy"), grandMasteryLegacyRendererInfos, mainRenderer, model, Modules.Unlockables.paladinGrandMasterySkinDef);
            grandMasteryLegacySkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.gmLegacyMesh,
                    renderer = defaultRenderers[lastRend].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.gmLegacySwordMesh,
                    renderer = defaultRenderers[0].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.defaultCapeMesh,
                    renderer = defaultRenderers[1].renderer
                }
            };

            grandMasteryLegacySkin.gameObjectActivations = capeActivations;

            AddCSSSkinChangeResponse(grandMasteryLegacySkin, paladinCSSEffect.BEEFY);

            if (PaladinPlugin.starstormInstalled && Config.legacySkins.Value)
            {
                skinDefs.Add(grandMasteryLegacySkin);
            }

            #endregion
            #region PoisonSkinLegacy
            CharacterModel.RendererInfo[] poisonLegacyRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(poisonLegacyRendererInfos, 0);

            poisonLegacyRendererInfos[0].defaultMaterial        = CreateMaterial("matPaladinNkuhanaLegacy", StaticValues.maxSwordGlow, Color.white);
            poisonLegacyRendererInfos[lastRend].defaultMaterial = CreateMaterial("matPaladinNkuhanaLegacy", 3, Color.white);

            SkinDef poisonLegacySkin = CreateSkinDef("PALADINBODY_POISONLEGACY_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texPoisonAchievementLegacy"), poisonLegacyRendererInfos, mainRenderer, model, Modules.Unlockables.paladinPoisonSkinDef);
            poisonLegacySkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.poisonLegacyMesh,
                    renderer = defaultRenderers[lastRend].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.poisonLegacySwordMesh,
                    renderer = defaultRenderers[0].renderer
                }
                //if arms are only in this skin they don't need to be mesh replaced, just activated
            };

            poisonLegacySkin.gameObjectActivations = defaultActivations;

            poisonLegacySkin.projectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[] {
                new SkinDef.ProjectileGhostReplacement {
                    projectilePrefab = Projectiles.swordBeamProjectile,
                    projectileGhostReplacementPrefab = Projectiles.CloneAndColorSwordBeam(Color.green, 0.6f)
                }
            };

            AddCSSSkinChangeResponse(poisonLegacySkin, paladinCSSEffect.GREEN);

            if (Config.legacySkins.Value)
            {
                skinDefs.Add(poisonLegacySkin);
            }
            #endregion

            skinController.skins = skinDefs.ToArray();

            InitializeNemSkins();
        }
示例#26
0
        public static void RegisterSkins()
        {
            GameObject bodyPrefab = DiggerPlugin.characterPrefab;

            GameObject     model          = bodyPrefab.GetComponentInChildren <ModelLocator>().modelTransform.gameObject;
            CharacterModel characterModel = model.GetComponent <CharacterModel>();

            ModelSkinController skinController = model.AddComponent <ModelSkinController>();
            ChildLocator        childLocator   = model.GetComponent <ChildLocator>();

            SkinnedMeshRenderer mainRenderer = Reflection.GetFieldValue <SkinnedMeshRenderer>(characterModel, "mainSkinnedMeshRenderer");

            GameObject diamondPickL = childLocator.FindChild("DiamondPickL").gameObject;
            GameObject diamondPickR = childLocator.FindChild("DiamondPickR").gameObject;

            GameObject[] allObjects = new GameObject[]
            {
                diamondPickL,
                diamondPickR
            };

            LanguageAPI.Add("MINERBODY_DEFAULT_SKIN_NAME", "Default");
            LanguageAPI.Add("MINERBODY_MOLTEN_SKIN_NAME", "Molten");
            LanguageAPI.Add("MINERBODY_TYPHOON_SKIN_NAME", "Conqueror");
            LanguageAPI.Add("MINERBODY_PUPLE_SKIN_NAME", "Puple");
            LanguageAPI.Add("MINERBODY_TUNDRA_SKIN_NAME", "Tundra");
            LanguageAPI.Add("MINERBODY_BLACKSMITH_SKIN_NAME", "Blacksmith");
            LanguageAPI.Add("MINERBODY_IRON_SKIN_NAME", "Iron");
            LanguageAPI.Add("MINERBODY_GOLD_SKIN_NAME", "Gold");
            LanguageAPI.Add("MINERBODY_DIAMOND_SKIN_NAME", "Diamond");
            LanguageAPI.Add("MINERBODY_STEVE_SKIN_NAME", "Minecraft");
            LanguageAPI.Add("MINERBODY_DRIP_SKIN_NAME", "Drip");

            LoadoutAPI.SkinDefInfo skinDefInfo = default(LoadoutAPI.SkinDefInfo);
            skinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            skinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];
            skinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];

            skinDefInfo.GameObjectActivations = getActivations(allObjects);

            skinDefInfo.Icon             = Resources.Load <GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponentInChildren <ModelSkinController>().skins[0].icon;
            skinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    renderer = mainRenderer,
                    mesh     = mainRenderer.sharedMesh
                }
            };
            skinDefInfo.Name          = "MINERBODY_DEFAULT_SKIN_NAME";
            skinDefInfo.NameToken     = "MINERBODY_DEFAULT_SKIN_NAME";
            skinDefInfo.RendererInfos = characterModel.baseRendererInfos;
            skinDefInfo.RootObject    = model;

            CharacterModel.RendererInfo[] rendererInfos = skinDefInfo.RendererInfos;
            CharacterModel.RendererInfo[] array         = new CharacterModel.RendererInfo[rendererInfos.Length];
            rendererInfos.CopyTo(array, 0);

            Material commandoMat = Resources.Load <GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponentInChildren <CharacterModel>().baseRendererInfos[0].defaultMaterial;

            //clone commando material for that spicy hopoo shader
            Material material = array[0].defaultMaterial;

            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(commandoMat);
                material.SetColor("_Color", Color.white);
                material.SetTexture("_MainTex", Assets.mainAssetBundle.LoadAsset <Material>("matMiner").GetTexture("_MainTex"));
                material.SetColor("_EmColor", Color.white);
                material.SetFloat("_EmPower", 0f);
                material.SetTexture("_EmTex", Assets.mainAssetBundle.LoadAsset <Material>("matMiner").GetTexture("_EmissionMap"));
                material.SetFloat("_NormalStrength", 0);
                //material.SetTexture("_NormalTex", Assets.mainAssetBundle.LoadAsset<Material>("matMiner").GetTexture("_BumpMap"));

                array[0].defaultMaterial = material;
            }

            //and do the same for the diamond picks
            material = array[1].defaultMaterial;

            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(commandoMat);
                material.SetColor("_Color", Color.white);
                material.SetTexture("_MainTex", Assets.mainAssetBundle.LoadAsset <Material>("matDiamondPick").GetTexture("_MainTex"));
                material.SetColor("_EmColor", Color.white);
                material.SetFloat("_EmPower", 0f);
                material.SetFloat("_NormalStrength", 0);

                array[1].defaultMaterial = material;
            }

            material = array[2].defaultMaterial;

            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(commandoMat);
                material.SetColor("_Color", Color.white);
                material.SetTexture("_MainTex", Assets.mainAssetBundle.LoadAsset <Material>("matDiamondPick").GetTexture("_MainTex"));
                material.SetColor("_EmColor", Color.white);
                material.SetFloat("_EmPower", 0f);
                material.SetFloat("_NormalStrength", 0);

                array[2].defaultMaterial = material;
            }

            skinDefInfo.RendererInfos = array;

            #region Default
            SkinDef defaultSkin = LoadoutAPI.CreateNewSkinDef(skinDefInfo);
            #endregion

            #region Molten
            LoadoutAPI.SkinDefInfo moltenSkinDefInfo = default(LoadoutAPI.SkinDefInfo);
            moltenSkinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            moltenSkinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];
            moltenSkinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];

            moltenSkinDefInfo.GameObjectActivations = getActivations(allObjects);

            moltenSkinDefInfo.Icon             = Assets.mainAssetBundle.LoadAsset <Sprite>("texMoltenAchievement");
            moltenSkinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    renderer = mainRenderer,
                    mesh     = mainRenderer.sharedMesh
                }
            };
            moltenSkinDefInfo.Name          = "MINERBODY_MOLTEN_SKIN_NAME";
            moltenSkinDefInfo.NameToken     = "MINERBODY_MOLTEN_SKIN_NAME";
            moltenSkinDefInfo.RendererInfos = characterModel.baseRendererInfos;
            moltenSkinDefInfo.RootObject    = model;

            rendererInfos = skinDefInfo.RendererInfos;
            array         = new CharacterModel.RendererInfo[rendererInfos.Length];
            rendererInfos.CopyTo(array, 0);

            material = array[0].defaultMaterial;

            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(material);
                material.SetTexture("_MainTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerMolten").GetTexture("_MainTex"));
                material.SetColor("_EmColor", Color.white);
                material.SetFloat("_EmPower", 5);
                material.SetTexture("_EmTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerMolten").GetTexture("_EmissionMap"));

                array[0].defaultMaterial = material;
            }

            moltenSkinDefInfo.RendererInfos = array;

            SkinDef moltenSkin = LoadoutAPI.CreateNewSkinDef(moltenSkinDefInfo);
            #endregion

            #region Puple
            LoadoutAPI.SkinDefInfo pupleSkinDefInfo = default(LoadoutAPI.SkinDefInfo);
            pupleSkinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            pupleSkinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];
            pupleSkinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];
            pupleSkinDefInfo.GameObjectActivations       = getActivations(allObjects);
            pupleSkinDefInfo.Icon             = Assets.mainAssetBundle.LoadAsset <Sprite>("texPupleAchievement");
            pupleSkinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    renderer = mainRenderer,
                    mesh     = mainRenderer.sharedMesh
                }
            };
            pupleSkinDefInfo.Name          = "MINERBODY_PUPLE_SKIN_NAME";
            pupleSkinDefInfo.NameToken     = "MINERBODY_PUPLE_SKIN_NAME";
            pupleSkinDefInfo.RendererInfos = characterModel.baseRendererInfos;
            pupleSkinDefInfo.RootObject    = model;

            rendererInfos = skinDefInfo.RendererInfos;
            array         = new CharacterModel.RendererInfo[rendererInfos.Length];
            rendererInfos.CopyTo(array, 0);

            material = array[0].defaultMaterial;

            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(material);
                material.SetTexture("_MainTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerPuple").GetTexture("_MainTex"));
                material.SetColor("_EmColor", Color.white);
                material.SetFloat("_EmPower", 1);
                material.SetTexture("_EmTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerPuple").GetTexture("_EmissionMap"));

                array[0].defaultMaterial = material;
            }

            pupleSkinDefInfo.RendererInfos = array;

            SkinDef pupleSkin = LoadoutAPI.CreateNewSkinDef(pupleSkinDefInfo);
            #endregion

            #region Tundra
            LoadoutAPI.SkinDefInfo tundraSkinDefInfo = default(LoadoutAPI.SkinDefInfo);
            tundraSkinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            tundraSkinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];
            tundraSkinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];
            tundraSkinDefInfo.GameObjectActivations       = getActivations(allObjects);
            tundraSkinDefInfo.Icon             = Assets.mainAssetBundle.LoadAsset <Sprite>("texTundraAchievement");
            tundraSkinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    renderer = mainRenderer,
                    mesh     = Assets.tundraMesh
                }
            };
            tundraSkinDefInfo.Name          = "MINERBODY_TUNDRA_SKIN_NAME";
            tundraSkinDefInfo.NameToken     = "MINERBODY_TUNDRA_SKIN_NAME";
            tundraSkinDefInfo.RendererInfos = characterModel.baseRendererInfos;
            tundraSkinDefInfo.RootObject    = model;

            rendererInfos = skinDefInfo.RendererInfos;
            array         = new CharacterModel.RendererInfo[rendererInfos.Length];
            rendererInfos.CopyTo(array, 0);

            material = array[0].defaultMaterial;

            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(material);
                material.SetTexture("_MainTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerTundra").GetTexture("_MainTex"));
                material.SetColor("_EmColor", Color.white);
                material.SetFloat("_EmPower", 0);
                material.SetTexture("_EmTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerTundra").GetTexture("_EmissionMap"));

                array[0].defaultMaterial = material;
            }

            tundraSkinDefInfo.RendererInfos = array;

            SkinDef tundraSkin = LoadoutAPI.CreateNewSkinDef(tundraSkinDefInfo);
            #endregion

            #region GrandMastery
            LoadoutAPI.SkinDefInfo grandMasterySkinDefInfo = default(LoadoutAPI.SkinDefInfo);
            grandMasterySkinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            grandMasterySkinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];
            grandMasterySkinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];
            grandMasterySkinDefInfo.GameObjectActivations       = getActivations(allObjects);
            grandMasterySkinDefInfo.Icon             = Assets.mainAssetBundle.LoadAsset <Sprite>("texGrandMasteryAchievement");
            grandMasterySkinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    renderer = mainRenderer,
                    mesh     = Assets.grandMasteryMesh
                }
            };
            grandMasterySkinDefInfo.Name          = "MINERBODY_TYPHOON_SKIN_NAME";
            grandMasterySkinDefInfo.NameToken     = "MINERBODY_TYPHOON_SKIN_NAME";
            grandMasterySkinDefInfo.RendererInfos = characterModel.baseRendererInfos;
            grandMasterySkinDefInfo.RootObject    = model;

            rendererInfos = skinDefInfo.RendererInfos;
            array         = new CharacterModel.RendererInfo[rendererInfos.Length];
            rendererInfos.CopyTo(array, 0);

            material = array[0].defaultMaterial;

            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(material);
                material.SetTexture("_MainTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerGM").GetTexture("_MainTex"));
                material.SetColor("_EmColor", Color.white);
                material.SetFloat("_EmPower", 0);
                material.SetTexture("_EmTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerGM").GetTexture("_EmissionMap"));

                array[0].defaultMaterial = material;
            }

            grandMasterySkinDefInfo.RendererInfos = array;

            SkinDef grandMasterySkin = LoadoutAPI.CreateNewSkinDef(grandMasterySkinDefInfo);
            #endregion

            #region Iron
            LoadoutAPI.SkinDefInfo ironSkinDefInfo = default(LoadoutAPI.SkinDefInfo);
            ironSkinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            ironSkinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];
            ironSkinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];
            ironSkinDefInfo.GameObjectActivations       = getActivations(allObjects);
            ironSkinDefInfo.Icon             = Resources.Load <GameObject>("Prefabs/CharacterBodies/HuntressBody").GetComponentInChildren <ModelSkinController>().skins[1].icon;
            ironSkinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    renderer = mainRenderer,
                    mesh     = mainRenderer.sharedMesh
                }
            };
            ironSkinDefInfo.Name          = "MINERBODY_IRON_SKIN_NAME";
            ironSkinDefInfo.NameToken     = "MINERBODY_IRON_SKIN_NAME";
            ironSkinDefInfo.RendererInfos = characterModel.baseRendererInfos;
            ironSkinDefInfo.RootObject    = model;

            rendererInfos = skinDefInfo.RendererInfos;
            array         = new CharacterModel.RendererInfo[rendererInfos.Length];
            rendererInfos.CopyTo(array, 0);

            material = array[0].defaultMaterial;

            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(material);
                material.SetTexture("_MainTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerIron").GetTexture("_MainTex"));
                material.SetColor("_EmColor", Color.white);
                material.SetFloat("_EmPower", 0);

                array[0].defaultMaterial = material;
            }

            ironSkinDefInfo.RendererInfos = array;

            SkinDef ironSkin = LoadoutAPI.CreateNewSkinDef(ironSkinDefInfo);
            #endregion

            #region Gold
            LoadoutAPI.SkinDefInfo goldSkinDefInfo = default(LoadoutAPI.SkinDefInfo);
            goldSkinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            goldSkinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];
            goldSkinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];
            goldSkinDefInfo.GameObjectActivations       = getActivations(allObjects);
            goldSkinDefInfo.Icon             = Resources.Load <GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponentInChildren <ModelSkinController>().skins[1].icon;
            goldSkinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    renderer = mainRenderer,
                    mesh     = mainRenderer.sharedMesh
                }
            };
            goldSkinDefInfo.Name          = "MINERBODY_GOLD_SKIN_NAME";
            goldSkinDefInfo.NameToken     = "MINERBODY_GOLD_SKIN_NAME";
            goldSkinDefInfo.RendererInfos = characterModel.baseRendererInfos;
            goldSkinDefInfo.RootObject    = model;

            rendererInfos = skinDefInfo.RendererInfos;
            array         = new CharacterModel.RendererInfo[rendererInfos.Length];
            rendererInfos.CopyTo(array, 0);

            material = array[0].defaultMaterial;

            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(material);
                material.SetTexture("_MainTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerGold").GetTexture("_MainTex"));
                material.SetColor("_EmColor", Color.white);
                material.SetFloat("_EmPower", 0f);
                material.SetTexture("_EmTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerGold").GetTexture("_EmissionMap"));

                array[0].defaultMaterial = material;
            }

            goldSkinDefInfo.RendererInfos = array;

            SkinDef goldSkin = LoadoutAPI.CreateNewSkinDef(goldSkinDefInfo);
            #endregion

            #region Diamond
            LoadoutAPI.SkinDefInfo diamondSkinDefInfo = default(LoadoutAPI.SkinDefInfo);
            diamondSkinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            diamondSkinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];
            diamondSkinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];
            diamondSkinDefInfo.GameObjectActivations       = getActivations(allObjects);
            diamondSkinDefInfo.Icon             = Resources.Load <GameObject>("Prefabs/CharacterBodies/MercBody").GetComponentInChildren <ModelSkinController>().skins[0].icon;
            diamondSkinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    renderer = mainRenderer,
                    mesh     = mainRenderer.sharedMesh
                }
            };
            diamondSkinDefInfo.Name          = "MINERBODY_DIAMOND_SKIN_NAME";
            diamondSkinDefInfo.NameToken     = "MINERBODY_DIAMOND_SKIN_NAME";
            diamondSkinDefInfo.RendererInfos = characterModel.baseRendererInfos;
            diamondSkinDefInfo.RootObject    = model;

            rendererInfos = skinDefInfo.RendererInfos;
            array         = new CharacterModel.RendererInfo[rendererInfos.Length];
            rendererInfos.CopyTo(array, 0);

            material = array[0].defaultMaterial;

            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(material);
                material.SetTexture("_MainTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerDiamond").GetTexture("_MainTex"));
                material.SetColor("_EmColor", Color.white);
                material.SetFloat("_EmPower", 0.75f);
                material.SetTexture("_EmTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerDiamond").GetTexture("_EmissionMap"));

                array[0].defaultMaterial = material;
            }

            diamondSkinDefInfo.RendererInfos = array;

            SkinDef diamondSkin = LoadoutAPI.CreateNewSkinDef(diamondSkinDefInfo);
            #endregion

            #region Blacksmith
            LoadoutAPI.SkinDefInfo blacksmithSkinDefInfo = default(LoadoutAPI.SkinDefInfo);
            blacksmithSkinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            blacksmithSkinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];
            blacksmithSkinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];
            blacksmithSkinDefInfo.GameObjectActivations       = getActivations(allObjects);
            blacksmithSkinDefInfo.Icon             = Assets.mainAssetBundle.LoadAsset <Sprite>("texBlacksmithAchievement");
            blacksmithSkinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    renderer = mainRenderer,
                    mesh     = Assets.blacksmithMesh
                }
            };
            blacksmithSkinDefInfo.Name          = "MINERBODY_BLACKSMITH_SKIN_NAME";
            blacksmithSkinDefInfo.NameToken     = "MINERBODY_BLACKSMITH_SKIN_NAME";
            blacksmithSkinDefInfo.RendererInfos = characterModel.baseRendererInfos;
            blacksmithSkinDefInfo.RootObject    = model;

            rendererInfos = skinDefInfo.RendererInfos;
            array         = new CharacterModel.RendererInfo[rendererInfos.Length];
            rendererInfos.CopyTo(array, 0);

            material = array[0].defaultMaterial;

            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(material);
                material.SetTexture("_MainTex", Assets.mainAssetBundle.LoadAsset <Material>("matBlacksmith").GetTexture("_MainTex"));
                material.SetColor("_EmColor", Color.white);
                material.SetFloat("_EmPower", 0f);
                material.SetTexture("_EmTex", Assets.mainAssetBundle.LoadAsset <Material>("matBlacksmith").GetTexture("_EmissionMap"));

                array[0].defaultMaterial = material;
            }

            blacksmithSkinDefInfo.RendererInfos = array;

            SkinDef blacksmithSkin = LoadoutAPI.CreateNewSkinDef(blacksmithSkinDefInfo);
            #endregion

            #region Drip
            LoadoutAPI.SkinDefInfo dripSkinDefInfo = default(LoadoutAPI.SkinDefInfo);
            dripSkinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            dripSkinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];
            dripSkinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];
            dripSkinDefInfo.GameObjectActivations       = getActivations(allObjects);
            dripSkinDefInfo.Icon             = Assets.mainAssetBundle.LoadAsset <Sprite>("texDripSkin");
            dripSkinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    renderer = mainRenderer,
                    mesh     = Assets.dripMesh
                }
            };
            dripSkinDefInfo.Name          = "MINERBODY_DRIP_SKIN_NAME";
            dripSkinDefInfo.NameToken     = "MINERBODY_DRIP_SKIN_NAME";
            dripSkinDefInfo.RendererInfos = characterModel.baseRendererInfos;
            dripSkinDefInfo.RootObject    = model;

            rendererInfos = skinDefInfo.RendererInfos;
            array         = new CharacterModel.RendererInfo[rendererInfos.Length];
            rendererInfos.CopyTo(array, 0);

            material = array[0].defaultMaterial;

            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(material);
                material.SetTexture("_MainTex", Assets.mainAssetBundle.LoadAsset <Material>("matDripMiner").GetTexture("_MainTex"));
                material.SetColor("_EmColor", Color.white);
                material.SetFloat("_EmPower", 0f);
                material.SetTexture("_EmTex", Assets.mainAssetBundle.LoadAsset <Material>("matDripMiner").GetTexture("_EmissionMap"));

                array[0].defaultMaterial = material;
            }

            dripSkinDefInfo.RendererInfos = array;

            SkinDef dripSkin = LoadoutAPI.CreateNewSkinDef(dripSkinDefInfo);
            #endregion

            #region Steve
            LoadoutAPI.SkinDefInfo steveSkinDefInfo = default(LoadoutAPI.SkinDefInfo);
            steveSkinDefInfo.BaseSkins = Array.Empty <SkinDef>();
            steveSkinDefInfo.MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0];
            steveSkinDefInfo.ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0];
            steveSkinDefInfo.GameObjectActivations       = getActivations(allObjects, diamondPickL, diamondPickR);
            steveSkinDefInfo.Icon             = Resources.Load <GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponentInChildren <ModelSkinController>().skins[0].icon;
            steveSkinDefInfo.MeshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    renderer = mainRenderer,
                    mesh     = Assets.steveMesh
                }
            };
            steveSkinDefInfo.Name          = "MINERBODY_STEVE_SKIN_NAME";
            steveSkinDefInfo.NameToken     = "MINERBODY_STEVE_SKIN_NAME";
            steveSkinDefInfo.RendererInfos = characterModel.baseRendererInfos;
            steveSkinDefInfo.RootObject    = model;

            rendererInfos = skinDefInfo.RendererInfos;
            array         = new CharacterModel.RendererInfo[rendererInfos.Length];
            rendererInfos.CopyTo(array, 0);

            material = array[0].defaultMaterial;

            if (material)
            {
                material = UnityEngine.Object.Instantiate <Material>(material);
                material.SetTexture("_MainTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerSteve").GetTexture("_MainTex"));
                material.SetColor("_EmColor", Color.white);
                material.SetFloat("_EmPower", 0.75f);
                material.SetTexture("_EmTex", Assets.mainAssetBundle.LoadAsset <Material>("matMinerSteve").GetTexture("_EmissionMap"));

                array[0].defaultMaterial = material;
            }

            steveSkinDefInfo.RendererInfos = array;

            SkinDef steveSkin = LoadoutAPI.CreateNewSkinDef(steveSkinDefInfo);
            #endregion

            var skinDefs = new List <SkinDef>();

            if (DiggerPlugin.starstormInstalled)
            {
                skinDefs = new List <SkinDef>()
                {
                    defaultSkin,
                    moltenSkin,
                    grandMasterySkin,
                    tundraSkin,
                    pupleSkin,
                    blacksmithSkin
                };
            }
            else
            {
                skinDefs = new List <SkinDef>()
                {
                    defaultSkin,
                    moltenSkin,
                    tundraSkin,
                    pupleSkin,
                    blacksmithSkin
                };
            }

            if (DiggerPlugin.extraSkins.Value)
            {
                skinDefs.Add(dripSkin);
                skinDefs.Add(steveSkin);
                skinDefs.Add(ironSkin);
                skinDefs.Add(goldSkin);
                skinDefs.Add(diamondSkin);
            }

            skinController.skins = skinDefs.ToArray();
        }
示例#27
0
        public static void RegisterSkins()
        {
            GameObject bodyPrefab = Prefabs.paladinPrefab;

            GameObject     model          = bodyPrefab.GetComponentInChildren <ModelLocator>().modelTransform.gameObject;
            CharacterModel characterModel = model.GetComponent <CharacterModel>();

            ModelSkinController skinController = model.AddComponent <ModelSkinController>();
            ChildLocator        childLocator   = model.GetComponent <ChildLocator>();

            SkinnedMeshRenderer mainRenderer = characterModel.mainSkinnedMeshRenderer;

            List <SkinDef> skinDefs = new List <SkinDef>();

            #region DefaultSkin
            CharacterModel.RendererInfo[] defaultRenderers = characterModel.baseRendererInfos;
            SkinDef defaultSkin = CreateSkinDef("PALADINBODY_DEFAULT_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texMainSkin"), defaultRenderers, mainRenderer, model, "");
            defaultSkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.defaultMesh,
                    renderer = defaultRenderers[1].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.defaultSwordMesh,
                    renderer = defaultRenderers[0].renderer
                }
            };

            skinDefs.Add(defaultSkin);
            #endregion

            #region MasterySkin
            CharacterModel.RendererInfo[] masteryRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(masteryRendererInfos, 0);

            masteryRendererInfos[0].defaultMaterial = CreateMaterial("matPaladinLunar", StaticValues.maxSwordGlow, Color.white);
            masteryRendererInfos[1].defaultMaterial = CreateMaterial("matPaladinLunar", 5, Color.white);

            SkinDef masterySkin = CreateSkinDef("PALADINBODY_LUNAR_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texMasteryAchievement"), masteryRendererInfos, mainRenderer, model, "PALADIN_MASTERYUNLOCKABLE_REWARD_ID");
            masterySkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.lunarMesh,
                    renderer = defaultRenderers[1].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.lunarSwordMesh,
                    renderer = defaultRenderers[0].renderer
                }
            };

            skinDefs.Add(masterySkin);
            #endregion

            #region PoisonSkin
            CharacterModel.RendererInfo[] poisonRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(poisonRendererInfos, 0);

            poisonRendererInfos[0].defaultMaterial = CreateMaterial("matPaladinNkuhana", StaticValues.maxSwordGlow, Color.white);
            poisonRendererInfos[1].defaultMaterial = CreateMaterial("matPaladinNkuhana", 3, Color.white);

            SkinDef poisonSkin = CreateSkinDef("PALADINBODY_POISON_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texPoisonAchievement"), poisonRendererInfos, mainRenderer, model, "PALADIN_POISONUNLOCKABLE_REWARD_ID");
            poisonSkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.poisonMesh,
                    renderer = defaultRenderers[1].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.poisonSwordMesh,
                    renderer = defaultRenderers[0].renderer
                }
            };

            skinDefs.Add(poisonSkin);
            #endregion

            #region ClaySkin
            CharacterModel.RendererInfo[] clayRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(clayRendererInfos, 0);

            clayRendererInfos[0].defaultMaterial = CreateMaterial("matClayPaladin", StaticValues.maxSwordGlow, Color.white);
            clayRendererInfos[1].defaultMaterial = CreateMaterial("matClayPaladin");

            SkinDef claySkin = CreateSkinDef("PALADINBODY_CLAY_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texClayAchievement"), clayRendererInfos, mainRenderer, model, "PALADIN_CLAYUNLOCKABLE_REWARD_ID");
            claySkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.clayMesh,
                    renderer = defaultRenderers[1].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.claySwordMesh,
                    renderer = defaultRenderers[0].renderer
                }
            };

            skinDefs.Add(claySkin);
            #endregion

            #region DripSkin
            CharacterModel.RendererInfo[] dripRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(dripRendererInfos, 0);

            dripRendererInfos[0].defaultMaterial = CreateMaterial("matPaladinDrip", StaticValues.maxSwordGlow, Color.white);
            dripRendererInfos[1].defaultMaterial = CreateMaterial("matPaladinDrip", 3, Color.white);

            SkinDef dripSkin = CreateSkinDef("PALADINBODY_DRIP_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texDripAchievement"), dripRendererInfos, mainRenderer, model, "PALADIN_dripUNLOCKABLE_REWARD_ID");
            dripSkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.dripMesh,
                    renderer = defaultRenderers[1].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.batMesh,
                    renderer = defaultRenderers[0].renderer
                }
            };

            skinDefs.Add(dripSkin);
            #endregion

            #region MinecraftSkin
            CharacterModel.RendererInfo[] minecraftRendererInfos = new CharacterModel.RendererInfo[defaultRenderers.Length];
            defaultRenderers.CopyTo(minecraftRendererInfos, 0);

            minecraftRendererInfos[0].defaultMaterial = CreateMaterial("matMinecraftSword", StaticValues.maxSwordGlow, Color.white);
            minecraftRendererInfos[1].defaultMaterial = CreateMaterial("matMinecraftPaladin", 3, Color.white);

            SkinDef minecraftSkin = CreateSkinDef("PALADINBODY_MINECRAFT_SKIN_NAME", Assets.mainAssetBundle.LoadAsset <Sprite>("texMinecraftSkin"), minecraftRendererInfos, mainRenderer, model, "");
            minecraftSkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.minecraftMesh,
                    renderer = defaultRenderers[1].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Assets.minecraftSwordMesh,
                    renderer = defaultRenderers[0].renderer
                }
            };

            skinDefs.Add(minecraftSkin);
            #endregion

            skinController.skins = skinDefs.ToArray();
        }
示例#28
0
        internal override void InitializeSkins()
        {
            GameObject     model          = bodyPrefab.GetComponentInChildren <ModelLocator>().modelTransform.gameObject;
            CharacterModel characterModel = model.GetComponent <CharacterModel>();

            ModelSkinController skinController = model.AddComponent <ModelSkinController>();
            ChildLocator        childLocator   = model.GetComponent <ChildLocator>();

            SkinnedMeshRenderer mainRenderer = characterModel.mainSkinnedMeshRenderer;

            CharacterModel.RendererInfo[] defaultRenderers = characterModel.baseRendererInfos;

            List <SkinDef> skins = new List <SkinDef>();

            #region DefaultSkin
            SkinDef defaultSkin = Modules.Skins.CreateSkinDef(HenryPlugin.developerPrefix + "_HENRY_BODY_DEFAULT_SKIN_NAME",
                                                              Assets.mainAssetBundle.LoadAsset <Sprite>("texMainSkin"),
                                                              defaultRenderers,
                                                              mainRenderer,
                                                              model);

            defaultSkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Modules.Assets.mainAssetBundle.LoadAsset <Mesh>("meshHenrySword"),
                    renderer = defaultRenderers[0].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Modules.Assets.mainAssetBundle.LoadAsset <Mesh>("meshHenryGun"),
                    renderer = defaultRenderers[1].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Modules.Assets.mainAssetBundle.LoadAsset <Mesh>("meshHenry"),
                    renderer = defaultRenderers[instance.mainRendererIndex].renderer
                }
            };

            skins.Add(defaultSkin);
            #endregion

            #region MasterySkin
            Material masteryMat = Modules.Assets.CreateMaterial("matHenryAlt");
            CharacterModel.RendererInfo[] masteryRendererInfos = SkinRendererInfos(defaultRenderers, new Material[]
            {
                masteryMat,
                masteryMat
            });

            SkinDef masterySkin = Modules.Skins.CreateSkinDef(HenryPlugin.developerPrefix + "_HENRY_BODY_MASTERY_SKIN_NAME",
                                                              Assets.mainAssetBundle.LoadAsset <Sprite>("texMasteryAchievement"),
                                                              masteryRendererInfos,
                                                              mainRenderer,
                                                              model,
                                                              masterySkinUnlockableDef);

            masterySkin.meshReplacements = new SkinDef.MeshReplacement[]
            {
                new SkinDef.MeshReplacement
                {
                    mesh     = Modules.Assets.mainAssetBundle.LoadAsset <Mesh>("meshHenrySwordAlt"),
                    renderer = defaultRenderers[0].renderer
                },
                new SkinDef.MeshReplacement
                {
                    mesh     = Modules.Assets.mainAssetBundle.LoadAsset <Mesh>("meshHenryAlt"),
                    renderer = defaultRenderers[instance.mainRendererIndex].renderer
                }
            };

            skins.Add(masterySkin);
            #endregion

            skinController.skins = skins.ToArray();
        }
示例#29
0
 private static void DoNothing(On.RoR2.SkinDef.orig_Awake orig, SkinDef self)
 {
     //Intentionally do nothing
 }
示例#30
0
        public static void Create()
        {
            body = PrefabAPI.InstantiateClone(Resources.Load <GameObject>("Prefabs/CharacterBodies/CommandoBody"), "UrsaBody", true);
            NetworkIdentity networkIdentity = body.GetComponent <NetworkIdentity>();

            networkIdentity.localPlayerAuthority = true;

            GameObject model = CreateModel(body);

            GameObject gameObject = new GameObject("ModelBase");

            gameObject.transform.parent        = body.transform;
            gameObject.transform.localPosition = new Vector3(0f, -0.81f, 0f);
            gameObject.transform.localRotation = Quaternion.identity;
            gameObject.transform.localScale    = new Vector3(1f, 1f, 1f);

            GameObject gameObject2 = new GameObject("CameraPivot");

            gameObject2.transform.parent        = gameObject.transform;
            gameObject2.transform.localPosition = new Vector3(0f, 1.6f, 0f);
            gameObject2.transform.localRotation = Quaternion.identity;
            gameObject2.transform.localScale    = Vector3.one;

            GameObject gameObject3 = new GameObject("AimOrigin");

            gameObject3.transform.parent        = gameObject.transform;
            gameObject3.transform.localPosition = new Vector3(0f, 1.4f, 0f);
            gameObject3.transform.localRotation = Quaternion.identity;
            gameObject3.transform.localScale    = Vector3.one;

            Transform transform = model.transform;

            transform.parent        = gameObject.transform;
            transform.localPosition = Vector3.zero;
            transform.localScale    = new Vector3(1f, 1f, 1f);
            transform.localRotation = Quaternion.identity;

            CharacterDirection characterDirection = body.GetComponent <CharacterDirection>();

            characterDirection.moveVector      = Vector3.zero;
            characterDirection.targetTransform = gameObject.transform;
            characterDirection.overrideAnimatorForwardTransform = null;
            characterDirection.rootMotionAccumulator            = null;
            characterDirection.modelAnimator         = model.GetComponentInChildren <Animator>();
            characterDirection.driveFromRootRotation = false;
            characterDirection.turnSpeed             = 720f;

            CharacterBody bodyComponent = body.GetComponent <CharacterBody>();

            bodyComponent.bodyIndex             = BodyIndex.None;
            bodyComponent.baseNameToken         = "URSA_NAME";
            bodyComponent.subtitleNameToken     = "URSA_SUBTITLE";
            bodyComponent.bodyFlags             = CharacterBody.BodyFlags.ImmuneToExecutes;
            bodyComponent.rootMotionInMainState = false;
            bodyComponent.mainRootSpeed         = 0;
            bodyComponent.baseMaxHealth         = Core.Config.baseMaxHealth.Value;
            bodyComponent.levelMaxHealth        = Core.Config.levelMaxHealth.Value;
            bodyComponent.baseRegen             = Core.Config.baseRegen.Value;
            bodyComponent.levelRegen            = Core.Config.levelRegen.Value;
            bodyComponent.baseMaxShield         = Core.Config.baseMaxShield.Value;
            bodyComponent.levelMaxShield        = Core.Config.levelMaxShield.Value;
            bodyComponent.baseMoveSpeed         = Core.Config.baseMoveSpeed.Value;
            bodyComponent.levelMoveSpeed        = Core.Config.levelMoveSpeed.Value;
            bodyComponent.baseAcceleration      = Core.Config.baseAcceleration.Value;
            bodyComponent.baseJumpPower         = Core.Config.baseJumpPower.Value;
            bodyComponent.levelJumpPower        = Core.Config.levelJumpPower.Value;
            bodyComponent.baseJumpCount         = Core.Config.baseJumpCount.Value;
            bodyComponent.baseDamage            = Core.Config.baseDamage.Value;
            bodyComponent.levelDamage           = Core.Config.levelDamage.Value;
            bodyComponent.baseAttackSpeed       = Core.Config.baseAttackSpeed.Value;
            bodyComponent.levelAttackSpeed      = Core.Config.levelAttackSpeed.Value;
            bodyComponent.baseCrit   = Core.Config.baseCrit.Value;
            bodyComponent.levelCrit  = Core.Config.levelCrit.Value;
            bodyComponent.baseArmor  = Core.Config.baseArmor.Value;
            bodyComponent.levelArmor = Core.Config.levelArmor.Value;
            bodyComponent.sprintingSpeedMultiplier = Core.Config.sprintingSpeedMultiplier.Value;
            bodyComponent.wasLucky           = false;
            bodyComponent.hideCrosshair      = false;
            bodyComponent.crosshairPrefab    = Resources.Load <GameObject>("prefabs/crosshair/simpledotcrosshair");
            bodyComponent.aimOriginTransform = gameObject3.transform;
            bodyComponent.hullClassification = HullClassification.Human;
            bodyComponent.portraitIcon       = Core.Assets.portrait.texture;
            bodyComponent.isChampion         = false;
            bodyComponent.currentVehicle     = null;
            bodyComponent.skinIndex          = 0U;

            LoadoutAPI.AddSkill(typeof(States.UrsaMain));
            var stateMachine = body.GetComponent <EntityStateMachine>();

            stateMachine.mainStateType = new SerializableEntityStateType(typeof(States.UrsaMain));

            CharacterMotor characterMotor = body.GetComponent <CharacterMotor>();

            characterMotor.walkSpeedPenaltyCoefficient = 1f;
            characterMotor.characterDirection          = characterDirection;
            characterMotor.muteWalkMotion = false;
            characterMotor.mass           = 200f;
            characterMotor.airControl     = 0.25f;
            characterMotor.disableAirControlUntilCollision = false;
            characterMotor.generateParametersOnAwake       = true;
            //characterMotor.useGravity = true;
            //characterMotor.isFlying = false;

            InputBankTest inputBankTest = body.GetComponent <InputBankTest>();

            inputBankTest.moveVector = Vector3.zero;

            CameraTargetParams cameraTargetParams = body.GetComponent <CameraTargetParams>();

            cameraTargetParams.cameraParams         = Resources.Load <GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponent <CameraTargetParams>().cameraParams;
            cameraTargetParams.cameraPivotTransform = null;
            cameraTargetParams.aimMode             = CameraTargetParams.AimType.Standard;
            cameraTargetParams.recoil              = Vector2.zero;
            cameraTargetParams.idealLocalCameraPos = Vector3.zero;
            cameraTargetParams.dontRaycastToPivot  = false;

            ModelLocator modelLocator = body.GetComponent <ModelLocator>();

            modelLocator.modelTransform           = transform;
            modelLocator.modelBaseTransform       = gameObject.transform;
            modelLocator.dontReleaseModelOnDeath  = false;
            modelLocator.autoUpdateModelTransform = true;
            modelLocator.dontDetatchFromParent    = false;
            modelLocator.noCorpse         = false;
            modelLocator.normalizeToFloor = true;
            modelLocator.preserveModel    = false;

            ChildLocator childLocator = model.GetComponent <ChildLocator>();

            HitBoxGroup rightClawHitBoxGroup = model.AddComponent <HitBoxGroup>();
            HitBoxGroup leftClawHitBoxGroup  = model.AddComponent <HitBoxGroup>();

            GameObject rightClawGameObject = new GameObject("RightClawHitBox");
            Transform  rightClaw           = childLocator.FindChild("R_Hand");

            rightClawGameObject.transform.parent        = rightClaw;
            rightClawGameObject.transform.localPosition = new Vector3(-0.2f, 0.2f, 0.3f);
            rightClawGameObject.transform.localScale    = Vector3.one * 6.25f;
            rightClawGameObject.transform.localRotation = Quaternion.identity;
            HitBox rightClawHitBox = rightClawGameObject.AddComponent <HitBox>();

            GameObject leftClawGameObject = new GameObject("LeftClawHitBox");
            Transform  leftClaw           = childLocator.FindChild("L_Hand");

            leftClawGameObject.transform.parent        = leftClaw;
            leftClawGameObject.transform.localPosition = new Vector3(-0.2f, 0.2f, 0.3f);
            leftClawGameObject.transform.localScale    = Vector3.one * 6.25f;
            leftClawGameObject.transform.localRotation = Quaternion.identity;
            HitBox leftClawHitBox = leftClawGameObject.AddComponent <HitBox>();

            rightClawHitBoxGroup.hitBoxes  = new HitBox[] { rightClawHitBox };
            rightClawHitBoxGroup.groupName = "RightClaw";
            leftClawHitBoxGroup.hitBoxes   = new HitBox[] { leftClawHitBox };
            leftClawHitBoxGroup.groupName  = "LeftClaw";

            Light rightLight = rightClaw.gameObject.AddComponent <Light>();

            rightLight.type      = LightType.Point;
            rightLight.color     = Color.yellow;
            rightLight.range     = 0.85f;
            rightLight.intensity = 95f;
            rightLight.enabled   = false;

            Light leftLight = leftClaw.gameObject.AddComponent <Light>();

            leftLight.type      = LightType.Point;
            leftLight.color     = Color.yellow;
            leftLight.range     = 0.85f;
            leftLight.intensity = 95f;
            leftLight.enabled   = false;

            CharacterModel characterModel = model.AddComponent <CharacterModel>();

            characterModel.body = bodyComponent;
            List <CharacterModel.RendererInfo> rendererInfos = new List <CharacterModel.RendererInfo>();

            foreach (SkinnedMeshRenderer i in model.GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                CharacterModel.RendererInfo info = new CharacterModel.RendererInfo
                {
                    defaultMaterial          = i.material,
                    renderer                 = i,
                    defaultShadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On,
                    ignoreOverlays           = false
                };
                rendererInfos.Add(info);
            }
            characterModel.baseRendererInfos = rendererInfos.ToArray();

            characterModel.autoPopulateLightInfos = true;
            characterModel.invisibilityCount      = 0;
            characterModel.temporaryOverlays      = new List <TemporaryOverlay>();

            ModelSkinController skinController = model.AddComponent <ModelSkinController>();

            LoadoutAPI.SkinDefInfo skinDefInfo = new LoadoutAPI.SkinDefInfo
            {
                BaseSkins             = Array.Empty <SkinDef>(),
                GameObjectActivations = new SkinDef.GameObjectActivation[0],
                Icon                        = Core.Assets.defaultSkinIcon,
                MeshReplacements            = new SkinDef.MeshReplacement[0],
                MinionSkinReplacements      = new SkinDef.MinionSkinReplacement[0],
                Name                        = "URSA_SKIN_DEFAULT_NAME",
                NameToken                   = "URSA_SKIN_DEFAULT_NAME",
                ProjectileGhostReplacements = new SkinDef.ProjectileGhostReplacement[0],
                RendererInfos               = rendererInfos.ToArray(),
                RootObject                  = model,
            };
            SkinDef skin = LoadoutAPI.CreateNewSkinDef(skinDefInfo);

            skinController.skins = new SkinDef[] { skin };

            TeamComponent teamComponent = null;

            if (body.GetComponent <TeamComponent>() != null)
            {
                teamComponent = body.GetComponent <TeamComponent>();
            }
            else
            {
                teamComponent = body.GetComponent <TeamComponent>();
            }
            teamComponent.hideAllyCardDisplay = false;
            teamComponent.teamIndex           = TeamIndex.None;

            HealthComponent healthComponent = body.GetComponent <HealthComponent>();

            healthComponent.health            = 90f;
            healthComponent.shield            = 0f;
            healthComponent.barrier           = 0f;
            healthComponent.magnetiCharge     = 0f;
            healthComponent.body              = null;
            healthComponent.dontShowHealthbar = false;
            healthComponent.globalDeathEventChanceCoefficient = 1f;

            body.GetComponent <Interactor>().maxInteractionDistance     = 3f;
            body.GetComponent <InteractionDriver>().highlightInteractor = true;

            CharacterDeathBehavior characterDeathBehavior = body.GetComponent <CharacterDeathBehavior>();

            characterDeathBehavior.deathStateMachine = body.GetComponent <EntityStateMachine>();
            characterDeathBehavior.deathState        = new SerializableEntityStateType(typeof(GenericCharacterDeath));

            SfxLocator sfxLocator = body.GetComponent <SfxLocator>();

            sfxLocator.deathSound      = "Play_ui_player_death";
            sfxLocator.barkSound       = "";
            sfxLocator.openSound       = "";
            sfxLocator.landingSound    = "Play_char_land";
            sfxLocator.fallDamageSound = "Play_char_land_fall_damage";
            sfxLocator.aliveLoopStart  = "";
            sfxLocator.aliveLoopStop   = "";

            Rigidbody rigidbody = body.GetComponent <Rigidbody>();

            rigidbody.mass                   = 100f;
            rigidbody.drag                   = 0f;
            rigidbody.angularDrag            = 0f;
            rigidbody.useGravity             = false;
            rigidbody.isKinematic            = true;
            rigidbody.interpolation          = RigidbodyInterpolation.None;
            rigidbody.collisionDetectionMode = CollisionDetectionMode.Discrete;
            rigidbody.constraints            = RigidbodyConstraints.None;

            CapsuleCollider capsuleCollider = body.GetComponent <CapsuleCollider>();

            capsuleCollider.isTrigger = false;
            capsuleCollider.material  = null;
            capsuleCollider.center    = new Vector3(0f, 0f, 0f);
            capsuleCollider.radius    = 0.5f;
            capsuleCollider.height    = 1.82f;
            capsuleCollider.direction = 1;

            KinematicCharacterMotor kinematicCharacterMotor = body.GetComponent <KinematicCharacterMotor>();

            kinematicCharacterMotor.CharacterController = characterMotor;
            kinematicCharacterMotor.Capsule             = capsuleCollider;
            kinematicCharacterMotor.Rigidbody           = rigidbody;

            capsuleCollider.radius   = 0.5f;
            capsuleCollider.height   = 1.82f;
            capsuleCollider.center   = new Vector3(0, 0, 0);
            capsuleCollider.material = null;

            kinematicCharacterMotor.DetectDiscreteCollisions     = false;
            kinematicCharacterMotor.GroundDetectionExtraDistance = 0f;
            kinematicCharacterMotor.MaxStepHeight                     = 0.2f;
            kinematicCharacterMotor.MinRequiredStepDepth              = 0.1f;
            kinematicCharacterMotor.MaxStableSlopeAngle               = 55f;
            kinematicCharacterMotor.MaxStableDistanceFromLedge        = 0.5f;
            kinematicCharacterMotor.PreventSnappingOnLedges           = false;
            kinematicCharacterMotor.MaxStableDenivelationAngle        = 55f;
            kinematicCharacterMotor.RigidbodyInteractionType          = RigidbodyInteractionType.None;
            kinematicCharacterMotor.PreserveAttachedRigidbodyMomentum = true;
            kinematicCharacterMotor.HasPlanarConstraint               = false;
            kinematicCharacterMotor.PlanarConstraintAxis              = Vector3.up;
            kinematicCharacterMotor.StepHandling  = StepHandlingMethod.None;
            kinematicCharacterMotor.LedgeHandling = true;
            kinematicCharacterMotor.InteractiveRigidbodyHandling = true;
            kinematicCharacterMotor.SafeMovement = false;

            HurtBoxGroup hurtBoxGroup = model.AddComponent <HurtBoxGroup>();

            HurtBox componentInChildren = model.GetComponentInChildren <CapsuleCollider>().gameObject.AddComponent <HurtBox>();

            componentInChildren.gameObject.layer = LayerIndex.entityPrecise.intVal;
            componentInChildren.healthComponent  = healthComponent;
            componentInChildren.isBullseye       = true;
            componentInChildren.damageModifier   = HurtBox.DamageModifier.Normal;
            componentInChildren.hurtBoxGroup     = hurtBoxGroup;
            componentInChildren.indexInGroup     = 0;

            hurtBoxGroup.hurtBoxes = new HurtBox[]
            {
                componentInChildren
            };

            hurtBoxGroup.mainHurtBox   = componentInChildren;
            hurtBoxGroup.bullseyeCount = 1;

            FootstepHandler footstepHandler = model.AddComponent <FootstepHandler>();

            footstepHandler.baseFootstepString           = "Play_player_footstep";
            footstepHandler.sprintFootstepOverrideString = "";
            footstepHandler.enableFootstepDust           = true;
            footstepHandler.footstepDustPrefab           = Resources.Load <GameObject>("Prefabs/GenericFootstepDust");

            RagdollController ragdollController = model.AddComponent <RagdollController>();

            ragdollController.bones = null;
            ragdollController.componentsToDisableOnRagdoll = null;

            AimAnimator aimAnimator = model.AddComponent <AimAnimator>();

            aimAnimator.inputBank          = inputBankTest;
            aimAnimator.directionComponent = characterDirection;
            aimAnimator.pitchRangeMax      = 55f;
            aimAnimator.pitchRangeMin      = -50f;
            aimAnimator.yawRangeMin        = -44f;
            aimAnimator.yawRangeMax        = 44f;
            aimAnimator.pitchGiveupRange   = 30f;
            aimAnimator.yawGiveupRange     = 10f;
            aimAnimator.giveupDuration     = 8f;

            // Adds component used for keeping track of individual Ursa's Fury Swipes damage bonus from Enrage.
            body.AddComponent <Miscellaneous.FurySwipesController>();

            // Particle System that only emits when Overpower buff is active.
            ParticleSystem.EmissionModule overpowerParticleSystemEmission = childLocator.FindChild("OverpowerParticles").GetComponent <ParticleSystem>().emission;
            overpowerParticleSystemEmission.enabled = false;

            //Doppelganger
            doppelgangerMaster = PrefabAPI.InstantiateClone(Resources.Load <GameObject>("Prefabs/CharacterMasters/CommandoMonsterMaster"), "UrsaDoppelGanger", true);

            CharacterMaster component = doppelgangerMaster.GetComponent <CharacterMaster>();

            component.bodyPrefab = body;
        }