コード例 #1
0
        internal static void Configure(ModComponent modComponent)
        {
            ModRepairableComponent modRepairableComponent = modComponent.GetComponent <ModRepairableComponent>();

            if (modRepairableComponent == null)
            {
                return;
            }

            Repairable repairable = ModUtils.GetOrCreateComponent <Repairable>(modRepairableComponent);

            repairable.m_RepairAudio       = modRepairableComponent.Audio;
            repairable.m_DurationMinutes   = modRepairableComponent.Minutes;
            repairable.m_ConditionIncrease = modRepairableComponent.Condition;

            if (modRepairableComponent.MaterialNames.Length != modRepairableComponent.MaterialCounts.Length)
            {
                throw new ArgumentException("MaterialNames and MaterialCounts do not have the same length on gear item '" + modRepairableComponent.name + "'.");
            }

            repairable.m_RequiredGear      = ModUtils.GetItems <GearItem>(modRepairableComponent.MaterialNames, modRepairableComponent.name);
            repairable.m_RequiredGearUnits = modRepairableComponent.MaterialCounts;

            repairable.m_RepairToolChoices    = ModUtils.GetItems <ToolsItem>(modRepairableComponent.RequiredTools, modRepairableComponent.name);
            repairable.m_RequiresToolToRepair = repairable.m_RepairToolChoices.Length > 0;
        }
コード例 #2
0
ファイル: Mapper.cs プロジェクト: ds5678/ModComponent
        private static void PostProcess(ModComponent modComponent)
        {
            modComponent.gameObject.layer = vp_Layer.Gear;

            GearItem gearItem = modComponent.GetComponent <GearItem>();

            gearItem.m_SkinnedMeshRenderers = ModUtils.NotNull <SkinnedMeshRenderer>(gearItem.m_SkinnedMeshRenderers);

            GameObject   template     = Resources.Load <GameObject>("GEAR_CoffeeCup");
            MeshRenderer meshRenderer = template.GetComponentInChildren <MeshRenderer>();

            foreach (var eachMeshRenderer in gearItem.m_MeshRenderers)
            {
                foreach (var eachMaterial in eachMeshRenderer.materials)
                {
                    if (eachMaterial.shader.name == "Standard")
                    {
                        eachMaterial.shader         = meshRenderer.material.shader;
                        eachMaterial.shaderKeywords = meshRenderer.material.shaderKeywords;

                        if (eachMaterial.GetTexture("_dmg_texture") is null)
                        {
                            eachMaterial.SetTexture("_dmg_texture", eachMaterial.GetTexture("_MainTex"));
                        }
                    }
                }
            }

            ConsoleWaitlist.MaybeRegisterConsoleGearName(modComponent.GetEffectiveConsoleName(), modComponent.name);

            UnityEngine.Object.DontDestroyOnLoad(modComponent.gameObject);
        }
コード例 #3
0
ファイル: Mapper.cs プロジェクト: nbakulev/ModComponent
        private static void PostProcess(ModComponent modComponent)
        {
            modComponent.gameObject.layer = vp_Layer.Gear;

            GearItem gearItem = modComponent.GetComponent <GearItem>();

            gearItem.m_SkinnedMeshRenderers = ModUtils.NotNull(gearItem.m_SkinnedMeshRenderers);

            GameObject   template     = Resources.Load <GameObject>("GEAR_CoffeeCup");
            MeshRenderer meshRenderer = template.GetComponentInChildren <MeshRenderer>();

            foreach (var eachMeshRenderer in gearItem.m_MeshRenderers)
            {
                foreach (var eachMaterial in eachMeshRenderer.materials)
                {
                    if (eachMaterial.shader.name == "Standard")
                    {
                        Debug.Log("Updating shader of " + modComponent.name);
                        eachMaterial.shader         = meshRenderer.material.shader;
                        eachMaterial.shaderKeywords = meshRenderer.material.shaderKeywords;
                    }
                }
            }

            ModUtils.RegisterConsoleGearName(modComponent.GetEffectiveConsoleName(), modComponent.name);

            if (modComponent.Radial != Radial.None)
            {
                RadialConfigurator.RegisterGear(modComponent.Radial, modComponent.name);
            }

            UnityEngine.Object.DontDestroyOnLoad(modComponent.gameObject);
        }