예제 #1
0
        // create a category def and plop it into the defDB
        private ThingCategoryDef CreateChildCategory(
            ThingCategoryDef thisRoot,
            string bodypart,
            string label,
            string type)
        {
            // create cat def
            ThingCategoryDef cat =
                new ThingCategoryDef
            {
                parent  = thisRoot,
                label   = label,
                defName = GetChildCatName(bodypart, label, type)
            };

            DefDatabase <ThingCategoryDef> .Add(cat);

            // don't forget to call the PostLoad() function, or you'll get swarmed in red... (ugh)
            cat.PostLoad();

            // update parent
            cat.parent.childCategories.Add(cat);

            // done!
            return(cat);
        }
        private ThingCategoryDef createNewThingCategoryDef(string defName, string label, ThingCategoryDef parent, string description = "")
        {
            ThingCategoryDef newCatDef = new ThingCategoryDef
            {
                defName        = "allow" + defName,
                label          = "string_allowed".Translate() + " " + label,
                description    = description,
                parent         = parent,
                modContentPack = ModContentPack
            };

            newCatDef.parent.childCategories.Add(newCatDef);
            ModContentPack.AddDef(newCatDef);
            newCatDef.PostLoad();
            return(newCatDef);
        }
예제 #3
0
        // create a category def and plop it into the defDB
        private ThingCategoryDef CreateCategory( string label, string type )
        {
            // create cat def
            ThingCategoryDef cat = new ThingCategoryDef();
            cat.parent = apparelRoot;
            cat.label = label;
            cat.defName = GetCatName( label, type );
            DefDatabase<ThingCategoryDef>.Add( cat );

            // don't forget to call the PostLoad() function, or you'll get swarmed in red... (ugh)
            cat.PostLoad();

            // update parent
            cat.parent.childCategories.Add( cat );

            // done!
            return cat;
        }