예제 #1
0
        public static void AddRemoveCaliberFromGunRecipes()
        {
            var shouldHaveLabels = (Controller.settings.EnableAmmoSystem && Controller.settings.ShowCaliberOnGuns);

            if (gunRecipesShowCaliber != shouldHaveLabels)
            {
                CE_Utility.allWeaponDefs.ForEach(x =>
                {
                    var ammoSet = x.GetCompProperties <CompProperties_AmmoUser>()?.ammoSet;

                    if (ammoSet != null)
                    {
                        RecipeDef recipeDef = DefDatabase <RecipeDef> .GetNamed("Make" + x.defName, false);

                        if (recipeDef != null)
                        {
                            var label = x.label + (shouldHaveLabels ? " (" + (string)ammoSet.LabelCap + ")" : "");

                            recipeDef.UpdateLabel("RecipeMake".Translate(label));           //Just setting recipeDef.label doesn't update Jobs nor existing recipeUsers. We need UpdateLabel.
                            recipeDef.jobString = "RecipeMakeJobString".Translate(label);   //The jobString should also be updated to reflect the name change.
                        }
                    }
                });

                gunRecipesShowCaliber = shouldHaveLabels;
            }
        }