コード例 #1
0
        private static void GenerateImplicitRaces()
        {
            try
            {
                var allLoadedThingDefs       = DefDatabase <ThingDef> .AllDefs;
                HashSet <ushort> takenHashes = new HashSet <ushort>(allLoadedThingDefs.Select(t => t.shortHash));  // Get the hashes already being used

                List <ThingDef> genRaces = new List <ThingDef>();

                foreach (ThingDef_AlienRace thingDefAlienRace in RaceGenerator.ImplicitRaces)
                {
                    var race = (ThingDef)thingDefAlienRace;
                    genRaces.Add(race);
                    DefGenerator.AddImpliedDef(race);
                    DefGenerator.AddImpliedDef(thingDefAlienRace);
                }

                foreach (ThingDef thingDef in genRaces)
                {
                    GiveHash(thingDef, takenHashes);
                }
            }
            catch (MissingMethodException e)
            {
                throw new
                      ModInitializationException($"caught missing method exception while generating implicit races! is HAR up to date?",
                                                 e);
            }
        }
コード例 #2
0
        private static void GenerateImplicitRaces()
        {
            try
            {
                List <ThingDef> genRaces = new List <ThingDef>();

                foreach (ThingDef_AlienRace thingDefAlienRace in RaceGenerator.ImplicitRaces)
                {
                    var race = (ThingDef)thingDefAlienRace;
                    genRaces.Add(race);
                    DefGenerator.AddImpliedDef(race);
                    DefGenerator.AddImpliedDef(thingDefAlienRace);
                }

                object[] tmpArr = new object[2];

                tmpArr[1] = typeof(ThingDef);
                foreach (ThingDef thingDef in genRaces)
                {
                    tmpArr[0] = thingDef;
                    GiveHashMethod.Invoke(null, tmpArr);
                }
            }
            catch (MissingMethodException e)
            {
                throw new
                      ModInitializationException($"caught missing method exception while generating implicit races! is HAR up to date?",
                                                 e);
            }
        }
コード例 #3
0
 /// <summary>
 /// Autogenerate implied PawnKindDefs for VehicleDefs
 /// </summary>
 public static void ImpliedDefGeneratorVehicles()
 {
     foreach (VehicleDef vehicleDef in DefDatabase <VehicleDef> .AllDefs)
     {
         DefGenerator.AddImpliedDef(PawnKindDefGenerator_Vehicles.GenerateImpliedPawnKindDef(vehicleDef));
     }
 }
コード例 #4
0
 private static void CopyAndStuffTerrainDef(TerrainDef terrainToCopy, List <ThingDef> stuffList)
 {
     foreach (ThingDef stuff in stuffList)
     {
         TerrainDef terrain = CopyAndStuffTerrainDef(terrainToCopy, stuff);
         DefGenerator.AddImpliedDef(terrain);
     }
 }
コード例 #5
0
ファイル: Base.cs プロジェクト: LazyRichard/WhatTheHack
        private static void GenerateImpliedRecipeDefs()
        {
            IEnumerable <RecipeDef> extraRecipeDefs = ImpliedRecipeDefs();

            foreach (RecipeDef td in extraRecipeDefs)
            {
                DefGenerator.AddImpliedDef <RecipeDef>(td);
            }
        }
コード例 #6
0
        //Patch to auto-generate EngravedWall ThingDefs for all added natural rocks
        public static void GenerateImpliedDefs_PreResolve()
        {
            IEnumerable <ThingDef> enumerable = ImpliedThingDefs();

            foreach (ThingDef def in enumerable)
            {
                DefGenerator.AddImpliedDef <ThingDef>(def);
            }
        }
コード例 #7
0
        // Token: 0x06000088 RID: 136 RVA: 0x00004224 File Offset: 0x00002424
        public static void Postfix()
        {
            JobDef jobDef;

            jobDef              = new JobDef();
            jobDef.defName      = "CompTurretReload";
            jobDef.driverClass  = typeof(JobDriver_ReloadCompTurret);
            jobDef.reportString = "reloading.";
            DefGenerator.AddImpliedDef <JobDef>(jobDef);
        }
コード例 #8
0
 public MainTabWindow_DroidWork()
 {
     if (!generatedDefs)
     {
         foreach (var def in GenerateImpliedDefs())
         {
             DefGenerator.AddImpliedDef(def);
         }
         generatedDefs = true;
     }
 }
コード例 #9
0
 private static void GenerateImpliedDefs_PreResolve_Postfix()
 {
     foreach (ThingDef def in ThingDefGenerator_Blood.ImpliedBloodDefs())
     {
         DefGenerator.AddImpliedDef(def);
     }
     DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent);
     foreach (RecipeDef op in RecipeDefGenerator_BloodSurgeries.ImpliedOperationDefs())
     {
         DefGenerator.AddImpliedDef(op);
     }
 }
コード例 #10
0
        public void createSpecialThingFilterDef(StuffCategoryDef stuffToFilter /*, ThingCategoryDef parentCategory*/)
        {
            List <ThingDef> defs = DefDatabase <ThingDef> .AllDefsListForReading;
            Boolean         skip = false;

            foreach (ThingDef def in defs)
            {
                if (def.stuffProps != null && def.stuffProps.categories.Contains(stuffToFilter))
                {
                    // avoid duplicate SpecialThingFilterDefs
                    if (def.stuffProps.categories.Count > 1)
                    {
                        List <SpecialThingFilterDef> sdefs = DefDatabase <SpecialThingFilterDef> .AllDefsListForReading;

                        foreach (SpecialThingFilterDef sdef in sdefs)
                        {
                            if (sdef.defName == "MaterialFilter_allow" + def.defName)
                            {
                                Logger.Message("Skipping duplicate " + def.defName);
                                skip = true;
                            }
                        }
                    }
                    if (!skip)
                    {
                        SpecialThingFilterDef newSpecialFilterDef = new SpecialThingFilterDef
                        {
                            defName     = "MaterialFilter_allow" + def.defName,
                            label       = def.label,
                            description = "string_allow".Translate() + " " + def.label,
                            //parentCategory = parentCategory,
                            parentCategory   = ThingCategoryDefOf.Root,
                            allowedByDefault = true,
                            saveKey          = "allow" + def.defName,
                            configurable     = true,

                            modContentPack = ModContentPack
                        };
                        string newWorkerClassName = "SpecialThingFilterWorker_" + def.defName;
                        newSpecialFilterDef.workerClass = generateDynamicClass(newWorkerClassName, def);

                        if (newSpecialFilterDef.parentCategory.childSpecialFilters.NullOrEmpty())
                        {
                            newSpecialFilterDef.parentCategory.childSpecialFilters = new List <SpecialThingFilterDef>();
                        }
                        newSpecialFilterDef.parentCategory.childSpecialFilters.Add(newSpecialFilterDef);
                        DefGenerator.AddImpliedDef(newSpecialFilterDef);
                    }
                }
                skip = false;
            }
        }
コード例 #11
0
        public static void GenerateAllShards()
        {
            foreach (ThingDef def in ThingDefGenerator_Techshards.ImpliedTechshardDefs() ?? Enumerable.Empty <ThingDef>())
            {
                DefGenerator.AddImpliedDef <ThingDef>(def);
                def.ResolveReferences();
            }

            ResourceCounter.ResetDefs();
            DefDatabase <ThingCategoryDef> .ResolveAllReferences(true, false);

            DefDatabase <RecipeDef> .ResolveAllReferences(true, true);
        }
コード例 #12
0
        private static void SortByMod(HashSet <ThingDef> apparelToSort, ThingCategoryDef thingCategoryDef, NextSortOption nextSortOption = NextSortOption.None)
        {
            Log.Message($"Sorting by mod, then by {nextSortOption}");
            foreach (ModMetaData modData in from modData in ModLister.AllInstalledMods where modData.Active select modData)
            {
                var apparelToCheck = (from apparelDef in apparelToSort where apparelDef.modContentPack.PackageId == modData.PackageId select apparelDef).ToHashSet();
                var modDefName     = $"{thingCategoryDef.defName}_{modData.PackageId}";
                if (thingCategoryDef == ThingCategoryDefOf.Apparel)
                {
                    modDefName = $"CS_{modData.PackageId}";
                }
                ThingCategoryDef modThingCategory = DefDatabase <ThingCategoryDef> .GetNamedSilentFail(modDefName);

                if (modThingCategory == null)
                {
                    modThingCategory = new ThingCategoryDef {
                        defName = modDefName, label = modData.Name
                    };
                    DefGenerator.AddImpliedDef(modThingCategory);
                }
                if (nextSortOption == NextSortOption.None)
                {
                    AddApparelToCategory(apparelToCheck, modThingCategory);
                    if (modThingCategory.childThingDefs.Count > 0 || modThingCategory.childCategories.Count > 0)
                    {
                        thingCategoryDef.childCategories.Add(modThingCategory);
                        modThingCategory.parent = thingCategoryDef;
                    }
                }
                else
                {
                    switch (nextSortOption)
                    {
                    case NextSortOption.Layer:
                        SortByLayer(apparelToCheck, modThingCategory);
                        break;

                    case NextSortOption.Tech:
                        SortByTech(apparelToCheck, modThingCategory);
                        break;
                    }
                    if (modThingCategory.childCategories.Count > 0)
                    {
                        thingCategoryDef.childCategories.Add(modThingCategory);
                        modThingCategory.parent = thingCategoryDef;
                    }
                }
                //techLevelThingCategory.ResolveReferences();
            }
        }
コード例 #13
0
        private static void SortByTech(HashSet <ThingDef> apparelToSort, ThingCategoryDef thingCategoryDef, NextSortOption nextSortOption = NextSortOption.None)
        {
            Log.Message($"Sorting by tech, then by {nextSortOption}");
            foreach (TechLevel techLevel in Enum.GetValues(typeof(TechLevel)))
            {
                var apparelToCheck   = (from apparelDef in apparelToSort where apparelDef.techLevel == techLevel select apparelDef).ToHashSet();
                var techLevelDefName = $"{thingCategoryDef.defName}_{techLevel}";
                if (thingCategoryDef == ThingCategoryDefOf.Apparel)
                {
                    techLevelDefName = $"CS_{techLevel}";
                }
                ThingCategoryDef techLevelThingCategory = DefDatabase <ThingCategoryDef> .GetNamedSilentFail(techLevelDefName);

                if (techLevelThingCategory == null)
                {
                    techLevelThingCategory = new ThingCategoryDef {
                        defName = techLevelDefName, label = techLevel.ToStringHuman()
                    };
                    DefGenerator.AddImpliedDef(techLevelThingCategory);
                }
                if (nextSortOption == NextSortOption.None)
                {
                    AddApparelToCategory(apparelToCheck, techLevelThingCategory);
                    if (techLevelThingCategory.childThingDefs.Count > 0 || techLevelThingCategory.childCategories.Count > 0)
                    {
                        thingCategoryDef.childCategories.Add(techLevelThingCategory);
                        techLevelThingCategory.parent = thingCategoryDef;
                    }
                }
                else
                {
                    switch (nextSortOption)
                    {
                    case NextSortOption.Layer:
                        SortByLayer(apparelToCheck, techLevelThingCategory);
                        break;

                    case NextSortOption.Mod:
                        SortByMod(apparelToCheck, techLevelThingCategory);
                        break;
                    }
                    if (techLevelThingCategory.childCategories.Count > 0)
                    {
                        thingCategoryDef.childCategories.Add(techLevelThingCategory);
                        techLevelThingCategory.parent = thingCategoryDef;
                    }
                }
                //techLevelThingCategory.ResolveReferences();
            }
        }
コード例 #14
0
        public static void Prefix()
        {
            var materials = new List <ThingDef>();

            if (LoadedModManager.GetMod <SimplyMoreBridgesMod>().GetSettings <SimplyMoreBridgesSettings>().GenerateFromAll)
            {
                materials = (from dd in DefDatabase <ThingDef> .AllDefsListForReading where dd.stuffProps != null && dd.stuffProps.categories != null && (dd.stuffProps.categories.Contains(StuffCategoryDefOf.Metallic) || dd.stuffProps.categories.Contains(StuffCategoryDefOf.Stony)) select dd).ToList();
            }
            else
            {
                materials = (from dd in DefDatabase <ThingDef> .AllDefsListForReading where dd.defName == "Plasteel" || dd.defName == "Steel" || dd.defName == "BlocksSandstone" || dd.defName == "BlocksGranite" || dd.defName == "BlocksLimestone" || dd.defName == "BlocksSlate" || dd.defName == "BlocksMarble" select dd).ToList();
            }
            Log.Message($"SimplyMoreBridges: Found {materials.Count} materials to generate bridge-definitions for.");

            List <TerrainDef> stonyBridgesToAdd = new List <TerrainDef>();
            List <TerrainDef> metalBridgesToAdd = new List <TerrainDef>();

            foreach (var material in materials)
            {
                try
                {
                    if (material.stuffProps.categories.Contains(StuffCategoryDefOf.Stony))
                    {
                        stonyBridgesToAdd.Add(GenerateBridgeDef(material, true));
                        stonyBridgesToAdd.Add(GenerateBridgeDef(material, false));
                    }
                    else
                    {
                        metalBridgesToAdd.Add(GenerateBridgeDef(material, true));
                        metalBridgesToAdd.Add(GenerateBridgeDef(material, false));
                    }
                }
                catch (Exception exception)
                {
                    Log.Warning($"SimplyMoreBridges: Failed to generate bridge definition for {material.defName}. Error: {exception.ToString()}");
                }
            }
            Log.Message($"SimplyMoreBridges: Generated the following stony bridges: {string.Join(",", stonyBridgesToAdd)}");
            Log.Message($"SimplyMoreBridges: Generated the following metal bridges: {string.Join(",", metalBridgesToAdd)}");
            //DefDatabase<TerrainDef>.Add(bridgesToAdd);
            foreach (TerrainDef terrainDef in stonyBridgesToAdd)
            {
                DefGenerator.AddImpliedDef(terrainDef);
            }
            foreach (TerrainDef terrainDef in metalBridgesToAdd)
            {
                DefGenerator.AddImpliedDef(terrainDef);
            }
        }
コード例 #15
0
ファイル: Numbers.cs プロジェクト: drummeur/kNumbers
        private static void Columndefs()
        {
            foreach (PawnColumnDef pawnColumnDef in ImpliedPawnColumnDefs())
            {
                DefGenerator.AddImpliedDef(pawnColumnDef);
            }
            //yeah I will set an icon for it because I can.
            var pcd = DefDatabase <PawnColumnDef> .GetNamed("ManhunterOnDamageChance");

            pcd.headerIcon = "UI/Icons/Animal/Predator";
            pcd.headerAlwaysInteractable = true;
            var pred = DefDatabase <PawnColumnDef> .GetNamed("Predator");

            pred.sortable = true;
        }
コード例 #16
0
        public static void ResolveSplits()
        {
            if (ResearchProjectHelper.oldNewMap.Count == 0)
            {
                return;
            }

            var cache = AccessTools.Field(typeof(ResearchProjectDef), "cachedUnlockedDefs");

            foreach (ResearchProjectDef rpd in ResearchProjectHelper.oldNewMap.Keys)
            {
                ResearchProjectDef toResolve = oldNewMap[rpd];
                DefGenerator.AddImpliedDef <ResearchProjectDef>(toResolve);

                cache.SetValue(rpd, null);
            }
            ResearchProjectDef.GenerateNonOverlappingCoordinates();
        }
コード例 #17
0
        private static void GenerateImplicitRaces()
        {
            var allLoadedThingDefs       = DefDatabase <ThingDef> .AllDefs;
            HashSet <ushort> takenHashes = new HashSet <ushort>(allLoadedThingDefs.Select(t => t.shortHash));  // Get the hashes already being used

            List <ThingDef> genRaces = new List <ThingDef>();

            foreach (ThingDef_AlienRace thingDefAlienRace in RaceGenerator.ImplicitRaces)
            {
                var race = (ThingDef)thingDefAlienRace;
                genRaces.Add(race);
                DefGenerator.AddImpliedDef(race);
                DefGenerator.AddImpliedDef(thingDefAlienRace);
            }

            foreach (ThingDef thingDef in genRaces)
            {
                GiveHash(thingDef, takenHashes);
            }
        }
コード例 #18
0
        // Token: 0x06000088 RID: 136 RVA: 0x00004224 File Offset: 0x00002424
        public static void Postfix()
        {
            ThingDef thingDef;

            thingDef             = new ThingDef();
            thingDef.defName     = "Mote_CompTurretStun";
            thingDef.label       = "Mote";
            thingDef.category    = ThingCategory.Mote;
            thingDef.thingClass  = typeof(Graphic_Mote);
            thingDef.graphicData = new GraphicData();
            thingDef.graphicData.graphicClass = typeof(MoteCompTurretAttached);
            thingDef.graphicData.shaderType   = DefDatabase <ShaderTypeDef> .GetNamed("Mote");

            thingDef.altitudeLayer         = AltitudeLayer.MetaOverlays;
            thingDef.tickerType            = TickerType.Normal;
            thingDef.useHitPoints          = false;
            thingDef.isSaveable            = false;
            thingDef.rotatable             = false;
            thingDef.mote                  = new MoteProperties();
            thingDef.mote.solidTime        = 9999;
            thingDef.mote.needsMaintenance = true;
            DefGenerator.AddImpliedDef <ThingDef>(thingDef);
        }
コード例 #19
0
        /// <summary>
        /// The sorting of apparel into categories
        /// </summary>
        /// <param name="apparelToSort"></param>
        /// <param name="thingCategoryDef"></param>
        private static void AddApparelToCategory(HashSet <ThingDef> apparelToSort, ThingCategoryDef thingCategoryDef)
        {
            var armoredDefName = $"{thingCategoryDef.defName}_Armored";
            ThingCategoryDef armoredThingCategory = DefDatabase <ThingCategoryDef> .GetNamedSilentFail(armoredDefName);

            if (armoredThingCategory == null)
            {
                armoredThingCategory = new ThingCategoryDef {
                    defName = armoredDefName, label = "CS_Armored".Translate()
                };
                DefGenerator.AddImpliedDef(armoredThingCategory);
            }
            armoredThingCategory.childCategories.Clear();
            armoredThingCategory.childThingDefs.Clear();
            var psyfocusDefName = $"{thingCategoryDef.defName}_Psyfocus";
            ThingCategoryDef psyfocusThingCategory = DefDatabase <ThingCategoryDef> .GetNamedSilentFail(psyfocusDefName);

            if (psyfocusThingCategory == null)
            {
                psyfocusThingCategory = new ThingCategoryDef {
                    defName = psyfocusDefName, label = "CS_Psyfocus".Translate()
                };
                DefGenerator.AddImpliedDef(psyfocusThingCategory);
            }
            psyfocusThingCategory.childCategories.Clear();
            psyfocusThingCategory.childThingDefs.Clear();
            var royaltyDefName = $"{thingCategoryDef.defName}_Royalty";
            ThingCategoryDef royaltyThingCategory = DefDatabase <ThingCategoryDef> .GetNamedSilentFail(royaltyDefName);

            if (royaltyThingCategory == null)
            {
                royaltyThingCategory = new ThingCategoryDef {
                    defName = royaltyDefName, label = "CS_Royalty".Translate()
                };
                DefGenerator.AddImpliedDef(royaltyThingCategory);
            }
            royaltyThingCategory.childCategories.Clear();
            royaltyThingCategory.childThingDefs.Clear();
            thingCategoryDef.childCategories.Clear();
            thingCategoryDef.childThingDefs.Clear();
            foreach (var apparel in apparelToSort)
            {
                if (ClothingSorterMod.instance.Settings.ArmoredSeparate)
                {
                    if ((apparel.StatBaseDefined(StatDefOf.ArmorRating_Blunt) && apparel.GetStatValueAbstract(StatDefOf.ArmorRating_Blunt) > ClothingSorterMod.instance.Settings.ArmorRating) ||
                        (apparel.StatBaseDefined(StatDefOf.ArmorRating_Sharp) && apparel.GetStatValueAbstract(StatDefOf.ArmorRating_Sharp) > ClothingSorterMod.instance.Settings.ArmorRating) ||
                        (apparel.StatBaseDefined(StatDefOf.StuffEffectMultiplierArmor) && apparel.GetStatValueAbstract(StatDefOf.StuffEffectMultiplierArmor) > ClothingSorterMod.instance.Settings.ArmorRating * 2))
                    {
                        apparel.thingCategories.Add(armoredThingCategory);
                        armoredThingCategory.childThingDefs.Add(apparel);
                        continue;
                    }
                }
                if (ModLister.RoyaltyInstalled && ClothingSorterMod.instance.Settings.PsychicSeparate)
                {
                    if (apparel.apparel?.tags?.Contains("Psychic") == true)
                    {
                        apparel.thingCategories.Add(psyfocusThingCategory);
                        psyfocusThingCategory.childThingDefs.Add(apparel);
                        continue;
                    }
                }
                if (ModLister.RoyaltyInstalled && ClothingSorterMod.instance.Settings.RoyaltySeparate)
                {
                    if (apparel.apparel?.tags?.Contains("Royal") == true)
                    {
                        apparel.thingCategories.Add(royaltyThingCategory);
                        royaltyThingCategory.childThingDefs.Add(apparel);
                        continue;
                    }
                }
                apparel.thingCategories.Add(thingCategoryDef);
                thingCategoryDef.childThingDefs.Add(apparel);
            }
            if (ClothingSorterMod.instance.Settings.ArmoredSeparate && armoredThingCategory.childThingDefs.Count > 0)
            {
                armoredThingCategory.parent = thingCategoryDef;
                thingCategoryDef.childCategories.Add(armoredThingCategory);
                //armoredThingCategory.ResolveReferences();
            }
            if (ModLister.RoyaltyInstalled && ClothingSorterMod.instance.Settings.PsychicSeparate && psyfocusThingCategory.childThingDefs.Count > 0)
            {
                psyfocusThingCategory.parent = thingCategoryDef;
                thingCategoryDef.childCategories.Add(psyfocusThingCategory);
                //psyfocusThingCategory.ResolveReferences();
            }
            if (ModLister.RoyaltyInstalled && ClothingSorterMod.instance.Settings.RoyaltySeparate && royaltyThingCategory.childThingDefs.Count > 0)
            {
                royaltyThingCategory.parent = thingCategoryDef;
                thingCategoryDef.childCategories.Add(royaltyThingCategory);
                //psyfocusThingCategory.ResolveReferences();
            }
            //thingCategoryDef.ResolveReferences();
        }
コード例 #20
0
        public static void Prefix()
        {
            var materials =
                LoadedModManager.GetMod <SimplyMoreBridgesMod>().GetSettings <SimplyMoreBridgesSettings>().GenerateFromAll
                    ? (from dd in DefDatabase <ThingDef> .AllDefsListForReading
                       where dd.stuffProps?.categories != null &&
                       (dd.stuffProps.categories.Contains(StuffCategoryDefOf.Metallic) ||
                        dd.stuffProps.categories.Contains(StuffCategoryDefOf.Stony))
                       select dd).ToList()
                    : (from dd in DefDatabase <ThingDef> .AllDefsListForReading
                       where dd.defName == "Plasteel" || dd.defName == "Steel" || dd.defName == "BlocksSandstone" ||
                       dd.defName == "BlocksGranite" || dd.defName == "BlocksLimestone" ||
                       dd.defName == "BlocksSlate" || dd.defName == "BlocksMarble"
                       select dd).ToList();

            Log.Message($"SimplyMoreBridges: Found {materials.Count} materials to generate bridge-definitions for.");

            var stonyBridgesToAdd = new HashSet <TerrainDef>();
            var metalBridgesToAdd = new HashSet <TerrainDef>();

            foreach (var material in materials)
            {
                try
                {
                    if (material.stuffProps.categories.Contains(StuffCategoryDefOf.Stony))
                    {
                        stonyBridgesToAdd.Add(GenerateBridgeDef(material, true, stonyBridgesToAdd));
                        if (LoadedModManager.GetMod <SimplyMoreBridgesMod>().GetSettings <SimplyMoreBridgesSettings>()
                            .AddVisuals)
                        {
                            stonyBridgesToAdd.Add(GenerateBridgeDef(material, true, stonyBridgesToAdd, "Flagstone"));
                        }

                        stonyBridgesToAdd.Add(GenerateBridgeDef(material, false, stonyBridgesToAdd));
                        if (LoadedModManager.GetMod <SimplyMoreBridgesMod>().GetSettings <SimplyMoreBridgesSettings>()
                            .AddVisuals)
                        {
                            stonyBridgesToAdd.Add(GenerateBridgeDef(material, false, stonyBridgesToAdd, "Flagstone"));
                        }
                    }
                    else
                    {
                        metalBridgesToAdd.Add(GenerateBridgeDef(material, true, metalBridgesToAdd));
                        if (LoadedModManager.GetMod <SimplyMoreBridgesMod>().GetSettings <SimplyMoreBridgesSettings>()
                            .AddVisuals)
                        {
                            if (material.defName == "Steel")
                            {
                                metalBridgesToAdd.Add(GenerateBridgeDef(material, true, metalBridgesToAdd, "Concrete"));
                            }

                            metalBridgesToAdd.Add(GenerateBridgeDef(material, true, metalBridgesToAdd, "PavedTile"));
                        }

                        if (LoadedModManager.GetMod <SimplyMoreBridgesMod>().GetSettings <SimplyMoreBridgesSettings>()
                            .GenerateFloorlike)
                        {
                            if (material.defName == "Silver")
                            {
                                metalBridgesToAdd.Add(GenerateBridgeDef(material, true, metalBridgesToAdd, "Sterile"));
                            }
                        }

                        metalBridgesToAdd.Add(GenerateBridgeDef(material, false, metalBridgesToAdd));
                        if (LoadedModManager.GetMod <SimplyMoreBridgesMod>().GetSettings <SimplyMoreBridgesSettings>()
                            .AddVisuals)
                        {
                            if (material.defName == "Steel")
                            {
                                metalBridgesToAdd.Add(GenerateBridgeDef(material, false, metalBridgesToAdd,
                                                                        "Concrete"));
                            }

                            metalBridgesToAdd.Add(GenerateBridgeDef(material, false, metalBridgesToAdd, "PavedTile"));
                        }

                        if (!LoadedModManager.GetMod <SimplyMoreBridgesMod>().GetSettings <SimplyMoreBridgesSettings>()
                            .GenerateFloorlike)
                        {
                            continue;
                        }

                        if (material.defName == "Silver")
                        {
                            metalBridgesToAdd.Add(GenerateBridgeDef(material, false, metalBridgesToAdd, "Sterile"));
                        }
                    }
                }
                catch (Exception exception)
                {
                    Log.Warning(
                        $"SimplyMoreBridges: Failed to generate bridge definition for {material.defName}. Error: {exception}");
                }
            }

            Log.Message(
                $"SimplyMoreBridges: Generated the following stony bridges: {string.Join(",", stonyBridgesToAdd)}");
            Log.Message(
                $"SimplyMoreBridges: Generated the following metal bridges: {string.Join(",", metalBridgesToAdd)}");
            foreach (var terrainDef in stonyBridgesToAdd)
            {
                DefGenerator.AddImpliedDef(terrainDef);
            }

            foreach (var terrainDef in metalBridgesToAdd)
            {
                DefGenerator.AddImpliedDef(terrainDef);
            }
        }
        // Token: 0x06000088 RID: 136 RVA: 0x00004224 File Offset: 0x00002424
        public static void Postfix()
        {
            //	Log.Message("GenerateImpliedDefs_PreResolve");

            PawnGroupKindDef pawnGroupKindDef = new PawnGroupKindDef();

            pawnGroupKindDef.defName     = "Hive_OgsOld_ExtraHives";
            pawnGroupKindDef.workerClass = typeof(PawnGroupKindWorker_Normal);
            DefGenerator.AddImpliedDef <PawnGroupKindDef>(pawnGroupKindDef);

            pawnGroupKindDef             = new PawnGroupKindDef();
            pawnGroupKindDef.defName     = "Tunneler_OgsOld_ExtraHives";
            pawnGroupKindDef.workerClass = typeof(PawnGroupKindWorker_Normal);
            DefGenerator.AddImpliedDef <PawnGroupKindDef>(pawnGroupKindDef);

            PawnsArrivalModeDef pawnsArrivalModeDef = new PawnsArrivalModeDef();

            pawnsArrivalModeDef.defName        = "EdgeTunnelIn_OgsOld_ExtraHives";
            pawnsArrivalModeDef.textEnemy      = "A group of {0} from {1} have tunneled in nearby.";
            pawnsArrivalModeDef.textFriendly   = "A group of friendly {0} from {1} have tunneled in nearby.";
            pawnsArrivalModeDef.textWillArrive = "{0_pawnsPluralDef} will tunnel in.";
            pawnsArrivalModeDef.workerClass    = typeof(OgsOld_ExtraHives.PawnsArrivalModeWorker_EdgeTunnel);

            /*
             * pawnsArrivalModeDef.selectionWeightCurve = new SimpleCurve();
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(300f,0f));
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(700f,0.3f));
             */
            DefGenerator.AddImpliedDef <PawnsArrivalModeDef>(pawnsArrivalModeDef);

            pawnsArrivalModeDef                = new PawnsArrivalModeDef();
            pawnsArrivalModeDef.defName        = "EdgeTunnelInGroups_OgsOld_ExtraHives";
            pawnsArrivalModeDef.textEnemy      = "Several separate groups of {0} from {1} have tunneled in nearby.";
            pawnsArrivalModeDef.textFriendly   = "Several separate groups of friendly {0} from {1} have tunneled in nearby.";
            pawnsArrivalModeDef.textWillArrive = "Several separate groups of {0_pawnsPluralDef} will tunnel in.";
            pawnsArrivalModeDef.workerClass    = typeof(OgsOld_ExtraHives.PawnsArrivalModeWorker_EdgeTunnelGroups);

            /*
             * pawnsArrivalModeDef.selectionWeightCurve = new SimpleCurve();
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(100f, 0f));
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(300f, 0.2f));
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(700f, 0.5f));
             * pawnsArrivalModeDef.pointsFactorCurve = new SimpleCurve();
             * pawnsArrivalModeDef.pointsFactorCurve.Add(new CurvePoint(0f, 0.9f));
             */
            DefGenerator.AddImpliedDef <PawnsArrivalModeDef>(pawnsArrivalModeDef);

            pawnsArrivalModeDef                = new PawnsArrivalModeDef();
            pawnsArrivalModeDef.defName        = "CenterTunnelIn_OgsOld_ExtraHives";
            pawnsArrivalModeDef.textEnemy      = "A group of {0} from {1} have tunneled in right on top of you!";
            pawnsArrivalModeDef.textFriendly   = "A group of friendly {0} from {1} have tunneled in right on top of you!";
            pawnsArrivalModeDef.textWillArrive = "{0_pawnsPluralDef} will tunnel in right on top of you.";
            pawnsArrivalModeDef.workerClass    = typeof(OgsOld_ExtraHives.PawnsArrivalModeWorker_CenterTunnel);

            /*
             * pawnsArrivalModeDef.selectionWeightCurve = new SimpleCurve();
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(300f, 0.0f));
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(1000f, 3.5f));
             * pawnsArrivalModeDef.pointsFactorCurve = new SimpleCurve();
             * pawnsArrivalModeDef.pointsFactorCurve.Add(new CurvePoint(0f, 0.75f));
             * pawnsArrivalModeDef.pointsFactorCurve.Add(new CurvePoint(5000f, 0.5f));
             */
            DefGenerator.AddImpliedDef <PawnsArrivalModeDef>(pawnsArrivalModeDef);

            pawnsArrivalModeDef                = new PawnsArrivalModeDef();
            pawnsArrivalModeDef.defName        = "RandomTunnelIn_OgsOld_ExtraHives";
            pawnsArrivalModeDef.textEnemy      = "A group of {0} from {1} have tunneled in. They are scattered all over the area!";
            pawnsArrivalModeDef.textFriendly   = "A group of friendly {0} from {1} have tunneled in. They are scattered all over the area!";
            pawnsArrivalModeDef.textWillArrive = "{0_pawnsPluralDef} will tunnel in.";
            pawnsArrivalModeDef.workerClass    = typeof(OgsOld_ExtraHives.PawnsArrivalModeWorker_RandomTunnel);

            /*
             * pawnsArrivalModeDef.selectionWeightCurve = new SimpleCurve();
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(300f, 0f));
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(1000f, 1.9f));
             * pawnsArrivalModeDef.pointsFactorCurve = new SimpleCurve();
             * pawnsArrivalModeDef.pointsFactorCurve.Add(new CurvePoint(0f, 0.7f));
             * pawnsArrivalModeDef.pointsFactorCurve.Add(new CurvePoint(5000f, 0.45f));
             */
            DefGenerator.AddImpliedDef <PawnsArrivalModeDef>(pawnsArrivalModeDef);

            ThingDef thingDef = new ThingDef();

            thingDef.defName                   = "InfestedMeteoriteIncoming_OgsOld_ExtraHives";
            thingDef.category                  = ThingCategory.Ethereal;
            thingDef.thingClass                = typeof(Skyfaller);
            thingDef.useHitPoints              = false;
            thingDef.drawOffscreen             = true;
            thingDef.tickerType                = TickerType.Normal;
            thingDef.altitudeLayer             = AltitudeLayer.Skyfaller;
            thingDef.drawerType                = DrawerType.RealtimeOnly;
            thingDef.skyfaller                 = new SkyfallerProperties();
            thingDef.label                     = "meteorite (incoming)";
            thingDef.size                      = new IntVec2(3, 3);
            thingDef.graphicData               = new GraphicData();
            thingDef.graphicData.texPath       = "Things/Skyfaller/Meteorite";
            thingDef.graphicData.graphicClass  = typeof(Graphic_Single);
            thingDef.graphicData.shaderType    = ShaderTypeDefOf.Transparent;
            thingDef.graphicData.drawSize      = new Vector2(10, 10);
            thingDef.skyfaller.shadowSize      = new Vector2(3, 3);
            thingDef.skyfaller.explosionRadius = 4;
            thingDef.skyfaller.explosionDamage = DamageDefOf.Bomb;
            thingDef.skyfaller.rotateGraphicTowardsDirection = true;
            thingDef.skyfaller.speed = 1.2f;
            DefGenerator.AddImpliedDef <ThingDef>(thingDef);

            thingDef               = new ThingDef();
            thingDef.defName       = "Tunneler_OgsOld_ExtraHives";
            thingDef.category      = ThingCategory.Ethereal;
            thingDef.thingClass    = typeof(OgsOld_ExtraHives.TunnelRaidSpawner);
            thingDef.useHitPoints  = false;
            thingDef.drawOffscreen = true;
            thingDef.alwaysFlee    = true;
            thingDef.tickerType    = TickerType.Normal;
            thingDef.altitudeLayer = AltitudeLayer.Skyfaller;
            thingDef.drawerType    = DrawerType.RealtimeOnly;
            thingDef.label         = "tunnel (incoming)";
            thingDef.size          = new IntVec2(1, 1);
            DefGenerator.AddImpliedDef <ThingDef>(thingDef);



            //PawnsArrivalModeDef

            /*
             * thingDef = new ThingDef();
             * thingDef.defName = "Hive_OgsOld_ExtraHives";
             * thingDef.category = ThingCategory.Ethereal;
             * thingDef.thingClass = typeof(OgsOld_ExtraHives.TunnelRaidSpawner);
             * thingDef.useHitPoints = false;
             * thingDef.drawOffscreen = true;
             * thingDef.alwaysFlee = true;
             * thingDef.tickerType = TickerType.Normal;
             * thingDef.altitudeLayer = AltitudeLayer.Skyfaller;
             * thingDef.drawerType = DrawerType.RealtimeOnly;
             * thingDef.label = "tunnel (incoming)";
             * thingDef.size = new IntVec2(3,3);
             * DefGenerator.AddImpliedDef<ThingDef>(thingDef);
             *
             */

            //RuleDef

            RuleDef ruleDef;

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveBaseMaker";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveBaseMaker";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_Hivebase());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveMoundMaker";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveMoundMaker";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_HiveBaseMoundMaker());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveClearChamber";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveClearChamber";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_ClearChamber());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveInterals";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveInterals";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_HiveInternals());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveOutdoorLighting";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveOutdoorLighting";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_OutdoorLightingHivebase());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveRandomCorpse";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveRandomCorpse";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_RandomCorpse());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveRandomDamage";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveRandomDamage";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_RandomDamage());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveRandomHives";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveRandomHives";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_RandomHives());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_PawnGroup";
            ruleDef.symbol    = "OgsOld_ExtraHives_PawnGroup";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_PawnHiveGroup());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_Pawn";
            ruleDef.symbol    = "OgsOld_ExtraHives_Pawn";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_SingleHivePawn());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);
        }
コード例 #22
0
 private static void DoPlayLoad()
 {
     GraphicDatabase.Clear();
     DeepProfiler.Start("Load all active mods.");
     try
     {
         LoadedModManager.LoadAllActiveMods();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Load language metadata.");
     try
     {
         LanguageDatabase.LoadAllMetadata();
     }
     finally
     {
         DeepProfiler.End();
     }
     LongEventHandler.SetCurrentEventText("LoadingDefs".Translate());
     DeepProfiler.Start("Copy all Defs from mods to global databases.");
     try
     {
         foreach (Type item in typeof(Def).AllSubclasses())
         {
             GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item, "AddAllInMods");
         }
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Resolve cross-references between non-implied Defs.");
     try
     {
         DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Rebind defs (early).");
     try
     {
         DefOfHelper.RebindAllDefOfs(true);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Generate implied Defs (pre-resolve).");
     try
     {
         DefGenerator.GenerateImpliedDefs_PreResolve();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs.");
     try
     {
         DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Rebind DefOfs (final).");
     try
     {
         DefOfHelper.RebindAllDefOfs(false);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Other def binding, resetting and global operations.");
     try
     {
         PlayerKnowledgeDatabase.ReloadAndRebind();
         LessonAutoActivator.Reset();
         CostListCalculator.Reset();
         PawnApparelGenerator.Reset();
         RestUtility.Reset();
         ThoughtUtility.Reset();
         PawnWeaponGenerator.Reset();
         ThinkTreeKeyAssigner.Reset();
         ThingCategoryNodeDatabase.FinalizeInit();
         TrainableUtility.Reset();
         HaulAIUtility.Reset();
         GenConstruct.Reset();
         WorkGiver_FillFermentingBarrel.Reset();
         WorkGiver_DoBill.Reset();
         Pawn.Reset();
         WorkGiver_InteractAnimal.Reset();
         WorkGiver_Warden_DoExecution.Reset();
         WorkGiver_GrowerSow.Reset();
         WorkGiver_Miner.Reset();
         MedicalCareUtility.Reset();
         InspectPaneUtility.Reset();
         GraphicDatabaseHeadRecords.Reset();
         DateReadout.Reset();
         ResearchProjectDef.GenerateNonOverlappingCoordinates();
         WorkGiver_FixBrokenDownBuilding.CacheTranslations();
         ItemCollectionGeneratorUtility.Reset();
         BaseGen.Reset();
         HealthUtility.Reset();
         ResourceCounter.ResetDefs();
         WildSpawner.Reset();
         ApparelProperties.Reset();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Resolve references.");
     try
     {
         foreach (Type item2 in typeof(Def).AllSubclasses())
         {
             if (item2 != typeof(ThingDef))
             {
                 GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item2, "ResolveAllReferences", true);
             }
         }
         DefDatabase <ThingDef> .ResolveAllReferences(true);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Generate implied Defs (post-resolve).");
     try
     {
         DefGenerator.GenerateImpliedDefs_PostResolve();
     }
     finally
     {
         DeepProfiler.End();
     }
     if (Prefs.DevMode)
     {
         DeepProfiler.Start("Error check all defs.");
         try
         {
             foreach (Type item3 in typeof(Def).AllSubclasses())
             {
                 GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item3, "ErrorCheckAllDefs");
             }
         }
         finally
         {
             DeepProfiler.End();
         }
     }
     LongEventHandler.SetCurrentEventText("Initializing".Translate());
     DeepProfiler.Start("Load keyboard preferences.");
     try
     {
         KeyPrefs.Init();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Short hash giving.");
     try
     {
         ShortHashGiver.GiveAllShortHashes();
     }
     finally
     {
         DeepProfiler.End();
     }
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         DeepProfiler.Start("Load backstories.");
         try
         {
             BackstoryDatabase.ReloadAllBackstories();
         }
         finally
         {
             DeepProfiler.End();
         }
     });
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         DeepProfiler.Start("Inject selected language data into game data.");
         try
         {
             LanguageDatabase.activeLanguage.InjectIntoData();
             GenLabel.ClearCache();
         }
         finally
         {
             DeepProfiler.End();
         }
     });
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         StaticConstructorOnStartupUtility.CallAll();
         if (Prefs.DevMode)
         {
             StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes();
         }
     });
 }
コード例 #23
0
ファイル: Class1.cs プロジェクト: Ogliss/Muv-Luv-Annihilation
        // Token: 0x06000088 RID: 136 RVA: 0x00004224 File Offset: 0x00002424
        public static void Postfix()
        {
            ThingDef thingDef;

            if (DefDatabase <ThingDef> .GetNamedSilentFail("Mote_BloodPuff") == null)
            {
                thingDef                        = new ThingDef();
                thingDef.defName                = "Mote_BloodPuff";
                thingDef.label                  = "blood";
                thingDef.category               = ThingCategory.Mote;
                thingDef.thingClass             = typeof(Graphic_Mote);
                thingDef.graphicData            = new GraphicData();
                thingDef.graphicData.texPath    = "Things/Mote/BodyImpact";
                thingDef.graphicData.shaderType = DefDatabase <ShaderTypeDef> .GetNamed("Mote");

                thingDef.altitudeLayer    = AltitudeLayer.MoteOverhead;
                thingDef.tickerType       = TickerType.Normal;
                thingDef.useHitPoints     = false;
                thingDef.isSaveable       = false;
                thingDef.rotatable        = false;
                thingDef.mote             = new MoteProperties();
                thingDef.mote.fadeInTime  = 0.04f;
                thingDef.mote.solidTime   = 0.25f;
                thingDef.mote.fadeOutTime = 0.1f;
                DefGenerator.AddImpliedDef <ThingDef>(thingDef);
            }

            if (DefDatabase <ThingDef> .GetNamedSilentFail("Mote_Blood_Puff") == null)
            {
                thingDef                        = new ThingDef();
                thingDef.defName                = "Mote_Blood_Puff";
                thingDef.label                  = "blood";
                thingDef.category               = ThingCategory.Mote;
                thingDef.thingClass             = typeof(Graphic_Mote);
                thingDef.graphicData            = new GraphicData();
                thingDef.graphicData.texPath    = "Things/Mote/BodyImpact";
                thingDef.graphicData.shaderType = DefDatabase <ShaderTypeDef> .GetNamed("Mote");

                thingDef.altitudeLayer    = AltitudeLayer.MoteOverhead;
                thingDef.tickerType       = TickerType.Normal;
                thingDef.useHitPoints     = false;
                thingDef.isSaveable       = false;
                thingDef.rotatable        = false;
                thingDef.mote             = new MoteProperties();
                thingDef.mote.fadeInTime  = 0.04f;
                thingDef.mote.solidTime   = 0.25f;
                thingDef.mote.fadeOutTime = 0.1f;
                DefGenerator.AddImpliedDef <ThingDef>(thingDef);
            }
            EffecterDef effecterDef;

            if (DefDatabase <EffecterDef> .GetNamedSilentFail("LaserImpact") == null)
            {
                effecterDef          = new EffecterDef();
                effecterDef.defName  = "LaserImpact";
                effecterDef.label    = "laser impact";
                effecterDef.children = new List <SubEffecterDef>();
                effecterDef.children.Add(new SubEffecterDef()
                {
                    subEffecterClass   = typeof(SubEffecter_SprayerTriggered),
                    moteDef            = ThingDef.Named("Mote_SparkFlash"),
                    positionLerpFactor = 0.6f,
                    chancePerTick      = 0.2f,
                    scale        = new FloatRange(2.5f, 4.5f),
                    spawnLocType = MoteSpawnLocType.OnSource
                });
                effecterDef.children.Add(new SubEffecterDef()
                {
                    subEffecterClass = typeof(SubEffecter_SprayerTriggered),
                    positionRadius   = 0.2f,
                    moteDef          = ThingDef.Named("Mote_AirPuff"),
                    burstCount       = new IntRange(4, 5),
                    speed            = new FloatRange(0.4f, 0.8f),
                    scale            = new FloatRange(0.5f, 0.8f),
                    spawnLocType     = MoteSpawnLocType.OnSource
                });
                effecterDef.children.Add(new SubEffecterDef()
                {
                    subEffecterClass = typeof(SubEffecter_SprayerTriggered),
                    positionRadius   = 0.2f,
                    moteDef          = ThingDef.Named("Mote_SparkThrownFast"),
                    burstCount       = new IntRange(4, 5),
                    speed            = new FloatRange(3.3f, 5f),
                    scale            = new FloatRange(0.1f, 0.2f),
                    spawnLocType     = MoteSpawnLocType.OnSource
                });
                effecterDef.children.Add(new SubEffecterDef()
                {
                    subEffecterClass = typeof(SubEffecter_SprayerTriggered),
                    positionRadius   = 0.2f,
                    moteDef          = ThingDef.Named("Mote_MicroSparksFast"),
                    burstCount       = new IntRange(1, 1),
                    speed            = new FloatRange(0.3f, 0.4f),
                    rotationRate     = new FloatRange(5f, 10f),
                    scale            = new FloatRange(0.3f, 0.5f),
                    spawnLocType     = MoteSpawnLocType.OnSource
                });

                effecterDef.children.Add(new SubEffecterDef()
                {
                    subEffecterClass = typeof(SubEffecter_SprayerTriggered),
                    positionRadius   = 0.1f,
                    moteDef          = ThingDef.Named("Mote_SparkFlash"),
                    burstCount       = new IntRange(1, 1),
                    scale            = new FloatRange(0.9f, 1.3f),
                    spawnLocType     = MoteSpawnLocType.OnSource
                });
                effecterDef.offsetTowardsTarget = new FloatRange();
                effecterDef.positionRadius      = 0.01f;
                DefGenerator.AddImpliedDef <EffecterDef>(effecterDef);
            }
        }
コード例 #24
0
        private static void SortByLayer(HashSet <ThingDef> apparelToSort, ThingCategoryDef thingCategoryDef, NextSortOption nextSortOption = NextSortOption.None)
        {
            Log.Message($"Sorting by layer, then by {nextSortOption}");
            var layerDefs = (from layerDef in DefDatabase <ApparelLayerDef> .AllDefsListForReading orderby layerDef.label select layerDef).ToList();

            layerDefs.Add(new ApparelLayerDef {
                defName = "Layer_None", label = "NoLayer".Translate()
            });
            var selectedLayers = new List <ApparelLayerDef>();

            for (var layerInt = 0; layerInt < layerDefs.Count(); layerInt++)
            {
                if (ClothingSorterMod.instance.Settings.CombineLayers && layerDefs.Count() > layerInt + 1 && layerDefs[layerInt].label.ToLower() == layerDefs[layerInt + 1].label.ToLower())
                {
                    selectedLayers.Add(layerDefs[layerInt]);
                    continue;
                }
                var layerDef = layerDefs[layerInt];
                selectedLayers.Add(layerDef);
                var apparelToCheck = (from apparelDef in apparelToSort where apparelDef.apparel?.layers?.Count() > 0 && apparelDef.apparel.layers.SharesElementWith(selectedLayers) select apparelDef).ToHashSet();
                if (layerDef.defName == "Layer_None")
                {
                    apparelToCheck = (from apparelDef in apparelToSort where apparelDef.apparel == null || apparelDef.apparel.layers == null || apparelDef.apparel.layers.Count() == 0 select apparelDef).ToHashSet();
                }
                selectedLayers.Clear();
                var layerDefName = $"{thingCategoryDef.defName}_{layerDef}";
                if (thingCategoryDef == ThingCategoryDefOf.Apparel)
                {
                    layerDefName = $"CS_{layerDef}";
                }
                ThingCategoryDef layerThingCategory = DefDatabase <ThingCategoryDef> .GetNamedSilentFail(layerDefName);

                if (layerThingCategory == null)
                {
                    layerThingCategory = new ThingCategoryDef {
                        defName = layerDefName, label = layerDef.label
                    };
                    DefGenerator.AddImpliedDef(layerThingCategory);
                }
                if (nextSortOption == NextSortOption.None)
                {
                    AddApparelToCategory(apparelToCheck, layerThingCategory);
                    if (layerThingCategory.childThingDefs.Count > 0 || layerThingCategory.childCategories.Count > 0)
                    {
                        thingCategoryDef.childCategories.Add(layerThingCategory);
                        layerThingCategory.parent = thingCategoryDef;
                    }
                }
                else
                {
                    switch (nextSortOption)
                    {
                    case NextSortOption.Tech:
                        SortByTech(apparelToCheck, layerThingCategory);
                        break;

                    case NextSortOption.Mod:
                        SortByMod(apparelToCheck, layerThingCategory);
                        break;
                    }
                    if (layerThingCategory.childCategories.Count > 0)
                    {
                        thingCategoryDef.childCategories.Add(layerThingCategory);
                        layerThingCategory.parent = thingCategoryDef;
                    }
                }
                //layerThingCategory.ResolveReferences();
            }
        }
コード例 #25
0
        static MyStaticConstructor()
        {
            List <ThingDef> impliedDefs   = new List <ThingDef>();
            StringBuilder   stringBuilder = new StringBuilder("[LuluChunkWalls] Dynamic patched the following defs: ");
            bool            first         = true;
            float           wallWork      = ThingDefOf.Wall.statBases.GetStatValueFromList(StatDefOf.WorkToBuild, 135);
            float           floorWork     = TerrainDefOf.Concrete.statBases.GetStatValueFromList(StatDefOf.WorkToBuild, 100);

            MethodInfo newThingBlueprintDef   = typeof(ThingDefGenerator_Buildings).GetMethod("NewBlueprintDef_Thing", BindingFlags.NonPublic | BindingFlags.Static);
            MethodInfo newThingFrameDef       = typeof(ThingDefGenerator_Buildings).GetMethod("NewFrameDef_Thing", BindingFlags.NonPublic | BindingFlags.Static);
            MethodInfo newTerrainBlueprintDef = typeof(ThingDefGenerator_Buildings).GetMethod("NewBlueprintDef_Terrain", BindingFlags.NonPublic | BindingFlags.Static);
            MethodInfo newTerrainFrameDef     = typeof(ThingDefGenerator_Buildings).GetMethod("NewFrameDef_Terrain", BindingFlags.NonPublic | BindingFlags.Static);
            MethodInfo giveShortHash          = typeof(ShortHashGiver).GetMethod("GiveShortHash", BindingFlags.NonPublic | BindingFlags.Static);

            foreach (ThingDef thingDef in DefDatabase <ThingDef> .AllDefs)
            {
                if (thingDef.building?.isNaturalRock ?? false)
                {
                    ThingDef chunkDef = thingDef.building.mineableThing;

                    if (chunkDef?.thingCategories?.Contains(ThingCategoryDefOf.StoneChunks) ?? false)
                    {
                        // Ensure lists are initialized.
                        if (thingDef.building.blueprintGraphicData == null)
                        {
                            thingDef.building.blueprintGraphicData = new GraphicData();
                        }
                        if (thingDef.costList == null)
                        {
                            thingDef.costList = new List <ThingDefCountClass>();
                        }
                        if (thingDef.researchPrerequisites == null)
                        {
                            thingDef.researchPrerequisites = new List <ResearchProjectDef>();
                        }
                        if (thingDef.statBases == null)
                        {
                            thingDef.statBases = new List <StatModifier>();
                        }

                        StuffProperties productProps = (chunkDef.butcherProducts?.Where(p => p.thingDef.IsStuff).FirstOrDefault()?.thingDef ?? ThingDefOf.BlocksGranite).stuffProps;
                        float           stuffWork    = productProps.statOffsets.GetStatOffsetFromList(StatDefOf.WorkToBuild);
                        float           stuffFactor  = productProps.statFactors.GetStatFactorFromList(StatDefOf.WorkToBuild);

                        // Patch the def.
                        thingDef.building.blueprintGraphicData.texPath = "Lulu/ChunkWalls/ChunkWalls_Blueprint_Atlas";
                        thingDef.constructionSkillPrerequisite         = 6;
                        thingDef.costList.Add(new ThingDefCountClass(chunkDef, 2));
                        thingDef.designationCategory        = DesignationCategoryDefOf.Structure;
                        thingDef.designatorDropdown         = MyDefOf.LuluChunkWalls_NaturalWall;
                        thingDef.placingDraggableDimensions = 1;
                        thingDef.researchPrerequisites.Add(MyDefOf.Stonecutting);
                        thingDef.statBases.Add(new StatModifier {
                            stat = StatDefOf.WorkToBuild, value = (wallWork + stuffWork) * (stuffFactor + 3)
                        });                                                                                                                                              // was 2430
                        thingDef.terrainAffordanceNeeded = TerrainAffordanceDefOf.Heavy;
                        thingDef.uiIconPath = "Lulu/ChunkWalls/ChunkWalls_MenuIcon";

                        // Manually create implied defs (we're past the point where they'd be generated automatically).
                        impliedDefs.Add((ThingDef)newThingBlueprintDef.Invoke(null, new object[] { thingDef, false, null }));
                        impliedDefs.Add((ThingDef)newThingFrameDef.Invoke(null, new object[] { thingDef }));

                        // Finalize graphic data.
                        thingDef.ResolveReferences();
                        thingDef.PostLoad();

                        // Build the log string.
                        if (first)
                        {
                            stringBuilder.Append(thingDef.defName);
                            first = false;
                        }
                        else
                        {
                            stringBuilder.AppendWithComma(thingDef.defName);
                        }

                        TerrainDef terrainDef = thingDef.building.leaveTerrain;

                        if (terrainDef != null)
                        {
                            if (terrainDef.costList == null)
                            {
                                terrainDef.costList = new List <ThingDefCountClass>();
                            }
                            if (terrainDef.researchPrerequisites == null)
                            {
                                terrainDef.researchPrerequisites = new List <ResearchProjectDef>();
                            }
                            if (terrainDef.statBases == null)
                            {
                                terrainDef.statBases = new List <StatModifier>();
                            }
                            terrainDef.constructionSkillPrerequisite = 6;
                            terrainDef.costList.Add(new ThingDefCountClass(chunkDef, 1));
                            terrainDef.designationCategory = MyDefOf.Floors;
                            terrainDef.designatorDropdown  = MyDefOf.LuluChunkWalls_NaturalFloor;
                            terrainDef.researchPrerequisites.Add(MyDefOf.Stonecutting);
                            terrainDef.statBases.Add(new StatModifier {
                                stat = StatDefOf.WorkToBuild, value = (floorWork + stuffWork) * (stuffFactor + 3)
                            });                                                                                                                                                     // was 1500
                            terrainDef.terrainAffordanceNeeded = TerrainAffordanceDefOf.Heavy;
                            impliedDefs.Add((ThingDef)newTerrainBlueprintDef.Invoke(null, new object[] { terrainDef }));
                            impliedDefs.Add((ThingDef)newTerrainFrameDef.Invoke(null, new object[] { terrainDef }));
                            stringBuilder.AppendWithComma(terrainDef.defName);
                        }
                    }
                }
            }

            // Add the created implied defs to the def database.
            foreach (ThingDef impliedDef in impliedDefs)
            {
                DefGenerator.AddImpliedDef(impliedDef);
                impliedDef.ResolveReferences();
                giveShortHash.Invoke(null, new object[] { impliedDef, typeof(ThingDef) });
            }

            // Regenerate the references in designation categories to make sure everything shows up to the player.
            DesignationCategoryDefOf.Structure.ResolveReferences();
            MyDefOf.Floors.ResolveReferences();

            // Report on what we've done.
            Log.Message(stringBuilder.ToString());
        }
コード例 #26
0
ファイル: MyClass.cs プロジェクト: emipa606/EtchedStoneWalls
        static RSSW_Initializer()
        {
            var harmony = new Harmony("net.rainbeau.rimworld.mod.smoothstone");

            harmony.PatchAll(Assembly.GetExecutingAssembly());
            var usingNPS = false;

            if (ModsConfig.ActiveModsInLoadOrder.Any(mod => mod.Name.Contains("Nature's Pretty Sweet")))
            {
                usingNPS = true;
            }
            List <ThingDef> allThings = DefDatabase <ThingDef> .AllDefsListForReading;

            for (var i = 0; i < allThings.Count; i++)
            {
                if (allThings[i].defName == "SmoothedLavaRock" && usingNPS.Equals(false))
                {
                }
                else if (allThings[i].defName.Contains("Smoothed") && !allThings[i].defName.Contains("Etched") && allThings[i].category == ThingCategory.Building && allThings[i].thingClass == typeof(Mineable))
                {
                    if (allThings[i].defName == "SmoothedLavaRock")
                    {
                        allThings[i].building.mineableThing      = ThingDef.Named("TKKN_ChunkLava");
                        allThings[i].building.mineableDropChance = 0.25f;
                    }
                    //
                    ThingDef newEtchedStone = GenerateBaseStructure(allThings[i]);
                    newEtchedStone.defName             = "Etched" + allThings[i].defName;
                    newEtchedStone.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label;
                    newEtchedStone.description         = allThings[i].description + "RSSW.EtchedWall".Translate();
                    newEtchedStone.graphicData.texPath = "Walls/Wall_Atlas_Basic";
                    DefGenerator.AddImpliedDef(newEtchedStone);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStone, typeof(ThingDef) });
                    //
                    var newEtchedStoneAtom = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneAtom.defName             = "Etched" + allThings[i].defName + "XXAtom";
                    newEtchedStoneAtom.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneAtom.description         = "RSSW.EtchedWallAtom".Translate();
                    newEtchedStoneAtom.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Atom";
                    DefGenerator.AddImpliedDef(newEtchedStoneAtom);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneAtom, typeof(ThingDef) });
                    //
                    var newEtchedStoneBeer = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneBeer.defName             = "Etched" + allThings[i].defName + "XXBeer";
                    newEtchedStoneBeer.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneBeer.description         = "RSSW.EtchedWallBeer".Translate();
                    newEtchedStoneBeer.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Beer";
                    DefGenerator.AddImpliedDef(newEtchedStoneBeer);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneBeer, typeof(ThingDef) });
                    //
                    var newEtchedStoneCheese = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneCheese.defName             = "Etched" + allThings[i].defName + "XXCheese";
                    newEtchedStoneCheese.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneCheese.description         = "RSSW.EtchedWallCheese".Translate();
                    newEtchedStoneCheese.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Cheese";
                    DefGenerator.AddImpliedDef(newEtchedStoneCheese);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneCheese, typeof(ThingDef) });
                    //
                    var newEtchedStoneDoor = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneDoor.defName             = "Etched" + allThings[i].defName + "XXDoor";
                    newEtchedStoneDoor.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneDoor.description         = "RSSW.EtchedWallDoor".Translate();
                    newEtchedStoneDoor.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Door";
                    DefGenerator.AddImpliedDef(newEtchedStoneDoor);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneDoor, typeof(ThingDef) });
                    //
                    var newEtchedStoneShovel = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneShovel.defName             = "Etched" + allThings[i].defName + "XXShovel";
                    newEtchedStoneShovel.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneShovel.description         = "RSSW.EtchedWallShovel".Translate();
                    newEtchedStoneShovel.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Shovel";
                    DefGenerator.AddImpliedDef(newEtchedStoneShovel);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneShovel, typeof(ThingDef) });
                    //
                    var newEtchedStoneBoomalope = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneBoomalope.defName             = "Etched" + allThings[i].defName + "XXBoomalope";
                    newEtchedStoneBoomalope.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneBoomalope.description         = "RSSW.EtchedWallBoomalope".Translate();
                    newEtchedStoneBoomalope.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Boomalope";
                    DefGenerator.AddImpliedDef(newEtchedStoneBoomalope);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneBoomalope, typeof(ThingDef) });
                    //
                    var newEtchedStoneForest = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneForest.defName             = "Etched" + allThings[i].defName + "XXForest";
                    newEtchedStoneForest.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneForest.description         = "RSSW.EtchedWallForest".Translate();
                    newEtchedStoneForest.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Forest";
                    DefGenerator.AddImpliedDef(newEtchedStoneForest);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneForest, typeof(ThingDef) });
                    //
                    var newEtchedStoneHouse = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneHouse.defName             = "Etched" + allThings[i].defName + "XXHouse";
                    newEtchedStoneHouse.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneHouse.description         = "RSSW.EtchedWallHouse".Translate();
                    newEtchedStoneHouse.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_House";
                    DefGenerator.AddImpliedDef(newEtchedStoneHouse);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneHouse, typeof(ThingDef) });
                    //
                    var newEtchedStonePlanet = GenerateBaseStructure(allThings[i]);
                    newEtchedStonePlanet.defName             = "Etched" + allThings[i].defName + "XXPlanet";
                    newEtchedStonePlanet.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStonePlanet.description         = "RSSW.EtchedWallPlanet".Translate();
                    newEtchedStonePlanet.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Planet";
                    DefGenerator.AddImpliedDef(newEtchedStonePlanet);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStonePlanet, typeof(ThingDef) });
                    //
                    var newEtchedStoneRocket = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneRocket.defName             = "Etched" + allThings[i].defName + "XXRocket";
                    newEtchedStoneRocket.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneRocket.description         = "RSSW.EtchedWallRocket".Translate();
                    newEtchedStoneRocket.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Rocket";
                    DefGenerator.AddImpliedDef(newEtchedStoneRocket);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneRocket, typeof(ThingDef) });
                    //
                    var newEtchedStoneGerbils = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneGerbils.defName             = "Etched" + allThings[i].defName + "XXGerbils";
                    newEtchedStoneGerbils.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneGerbils.description         = "RSSW.EtchedWallGerbils".Translate();
                    newEtchedStoneGerbils.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Gerbils";
                    DefGenerator.AddImpliedDef(newEtchedStoneGerbils);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneGerbils, typeof(ThingDef) });
                    //
                    var newEtchedStoneIsland = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneIsland.defName             = "Etched" + allThings[i].defName + "XXIsland";
                    newEtchedStoneIsland.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneIsland.description         = "RSSW.EtchedWallIsland".Translate();
                    newEtchedStoneIsland.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Island";
                    DefGenerator.AddImpliedDef(newEtchedStoneIsland);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneIsland, typeof(ThingDef) });
                    //
                    var newEtchedStoneMan = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneMan.defName             = "Etched" + allThings[i].defName + "XXMan";
                    newEtchedStoneMan.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneMan.description         = "RSSW.EtchedWallMan".Translate();
                    newEtchedStoneMan.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Man";
                    DefGenerator.AddImpliedDef(newEtchedStoneMan);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneMan, typeof(ThingDef) });
                    //
                    var newEtchedStoneRose = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneRose.defName             = "Etched" + allThings[i].defName + "XXRose";
                    newEtchedStoneRose.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneRose.description         = "RSSW.EtchedWallRose".Translate();
                    newEtchedStoneRose.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Rose";
                    DefGenerator.AddImpliedDef(newEtchedStoneRose);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneRose, typeof(ThingDef) });
                    //
                    var newEtchedStoneWoman = GenerateBaseStructure(allThings[i]);
                    newEtchedStoneWoman.defName             = "Etched" + allThings[i].defName + "XXWoman";
                    newEtchedStoneWoman.label               = "RSSW.EtchedWall.label1".Translate() + allThings[i].label + "RSSW.EtchedWall.label2".Translate();
                    newEtchedStoneWoman.description         = "RSSW.EtchedWallWoman".Translate();
                    newEtchedStoneWoman.graphicData.texPath = "WallsDecorated/Wall_Atlas_Bricks_Woman";
                    DefGenerator.AddImpliedDef(newEtchedStoneWoman);
                    AccessTools.Method(typeof(ShortHashGiver), "GiveShortHash", null, null).Invoke(null, new object[] { newEtchedStoneWoman, typeof(ThingDef) });
                    //
                    allThings[i].building.smoothedThing = newEtchedStone;
                }
            }
        }
コード例 #27
0
ファイル: PlayDataLoader.cs プロジェクト: KraigXu/GameProject
        private static void DoPlayLoad()
        {
            DeepProfiler.Start("GraphicDatabase.Clear()");
            try
            {
                GraphicDatabase.Clear();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Load all active mods.");
            try
            {
                LoadedModManager.LoadAllActiveMods();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Load language metadata.");
            try
            {
                LanguageDatabase.InitAllMetadata();
            }
            finally
            {
                DeepProfiler.End();
            }
            LongEventHandler.SetCurrentEventText("LoadingDefs".Translate());
            DeepProfiler.Start("Copy all Defs from mods to global databases.");
            try
            {
                foreach (Type item in typeof(Def).AllSubclasses())
                {
                    GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item, "AddAllInMods");
                }
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Resolve cross-references between non-implied Defs.");
            try
            {
                DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent);
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Rebind defs (early).");
            try
            {
                DefOfHelper.RebindAllDefOfs(earlyTryMode: true);
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("TKeySystem.BuildMappings()");
            try
            {
                TKeySystem.BuildMappings();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Inject selected language data into game data (early pass).");
            try
            {
                LanguageDatabase.activeLanguage.InjectIntoData_BeforeImpliedDefs();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Generate implied Defs (pre-resolve).");
            try
            {
                DefGenerator.GenerateImpliedDefs_PreResolve();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs.");
            try
            {
                DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors);
            }
            finally
            {
                DirectXmlCrossRefLoader.Clear();
                DeepProfiler.End();
            }
            DeepProfiler.Start("Rebind DefOfs (final).");
            try
            {
                DefOfHelper.RebindAllDefOfs(earlyTryMode: false);
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Other def binding, resetting and global operations (pre-resolve).");
            try
            {
                PlayerKnowledgeDatabase.ReloadAndRebind();
                LessonAutoActivator.Reset();
                CostListCalculator.Reset();
                Pawn.ResetStaticData();
                PawnApparelGenerator.Reset();
                RestUtility.Reset();
                ThoughtUtility.Reset();
                ThinkTreeKeyAssigner.Reset();
                ThingCategoryNodeDatabase.FinalizeInit();
                TrainableUtility.Reset();
                HaulAIUtility.Reset();
                GenConstruct.Reset();
                MedicalCareUtility.Reset();
                InspectPaneUtility.Reset();
                GraphicDatabaseHeadRecords.Reset();
                DateReadout.Reset();
                ResearchProjectDef.GenerateNonOverlappingCoordinates();
                BaseGen.Reset();
                ResourceCounter.ResetDefs();
                ApparelProperties.ResetStaticData();
                WildPlantSpawner.ResetStaticData();
                PawnGenerator.Reset();
                TunnelHiveSpawner.ResetStaticData();
                Hive.ResetStaticData();
                ExpectationsUtility.Reset();
                WealthWatcher.ResetStaticData();
                SkillUI.Reset();
                QuestNode_GetThingPlayerCanProduce.ResetStaticData();
                Pawn_PsychicEntropyTracker.ResetStaticData();
                ColoredText.ResetStaticData();
                QuestNode_GetRandomNegativeGameCondition.ResetStaticData();
                RoyalTitleUtility.ResetStaticData();
                RewardsGenerator.ResetStaticData();
                WorkGiver_FillFermentingBarrel.ResetStaticData();
                WorkGiver_DoBill.ResetStaticData();
                WorkGiver_InteractAnimal.ResetStaticData();
                WorkGiver_Warden_DoExecution.ResetStaticData();
                WorkGiver_GrowerSow.ResetStaticData();
                WorkGiver_Miner.ResetStaticData();
                WorkGiver_FixBrokenDownBuilding.ResetStaticData();
                WorkGiver_ConstructDeliverResources.ResetStaticData();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Resolve references.");
            try
            {
                DeepProfiler.Start("ThingCategoryDef resolver");
                try
                {
                    DefDatabase <ThingCategoryDef> .ResolveAllReferences();
                }
                finally
                {
                    DeepProfiler.End();
                }
                DeepProfiler.Start("RecipeDef resolver");
                try
                {
                    DeepProfiler.enabled = false;
                    DefDatabase <RecipeDef> .ResolveAllReferences(onlyExactlyMyType : true, parallel : true);

                    DeepProfiler.enabled = true;
                }
                finally
                {
                    DeepProfiler.End();
                }
                DeepProfiler.Start("Static resolver calls");
                try
                {
                    foreach (Type item2 in typeof(Def).AllSubclasses())
                    {
                        if (!(item2 == typeof(ThingDef)) && !(item2 == typeof(ThingCategoryDef)) && !(item2 == typeof(RecipeDef)))
                        {
                            GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item2, "ResolveAllReferences", true, false);
                        }
                    }
                }
                finally
                {
                    DeepProfiler.End();
                }
                DeepProfiler.Start("ThingDef resolver");
                try
                {
                    DefDatabase <ThingDef> .ResolveAllReferences();
                }
                finally
                {
                    DeepProfiler.End();
                }
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Generate implied Defs (post-resolve).");
            try
            {
                DefGenerator.GenerateImpliedDefs_PostResolve();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Other def binding, resetting and global operations (post-resolve).");
            try
            {
                PawnWeaponGenerator.Reset();
                BuildingProperties.FinalizeInit();
                ThingSetMakerUtility.Reset();
            }
            finally
            {
                DeepProfiler.End();
            }
            if (Prefs.DevMode)
            {
                DeepProfiler.Start("Error check all defs.");
                try
                {
                    foreach (Type item3 in typeof(Def).AllSubclasses())
                    {
                        GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item3, "ErrorCheckAllDefs");
                    }
                }
                finally
                {
                    DeepProfiler.End();
                }
            }
            LongEventHandler.SetCurrentEventText("Initializing".Translate());
            DeepProfiler.Start("Load keyboard preferences.");
            try
            {
                KeyPrefs.Init();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("Short hash giving.");
            try
            {
                ShortHashGiver.GiveAllShortHashes();
            }
            finally
            {
                DeepProfiler.End();
            }
            LongEventHandler.ExecuteWhenFinished(delegate
            {
                DeepProfiler.Start("Load backstories.");
                try
                {
                    BackstoryDatabase.ReloadAllBackstories();
                }
                finally
                {
                    DeepProfiler.End();
                }
            });
            LongEventHandler.ExecuteWhenFinished(delegate
            {
                DeepProfiler.Start("Inject selected language data into game data.");
                try
                {
                    LanguageDatabase.activeLanguage.InjectIntoData_AfterImpliedDefs();
                    GenLabel.ClearCache();
                }
                finally
                {
                    DeepProfiler.End();
                }
            });
            LongEventHandler.ExecuteWhenFinished(delegate
            {
                DeepProfiler.Start("Static constructor calls");
                try
                {
                    StaticConstructorOnStartupUtility.CallAll();
                    if (Prefs.DevMode)
                    {
                        StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes();
                    }
                }
                finally
                {
                    DeepProfiler.End();
                }
                DeepProfiler.Start("Garbage Collection");
                try
                {
                    AbstractFilesystem.ClearAllCache();
                    GC.Collect(int.MaxValue, GCCollectionMode.Forced);
                }
                finally
                {
                    DeepProfiler.End();
                }
            });
        }
        static void Postfix()
        {
            RecipeDef installHeart = DefDatabase <RecipeDef> .GetNamed("InstallNaturalHeart");

            foreach (BodyPartDef part in DefDatabase <MutationDef> .AllDefs.Where(x => x.affectedParts != null).SelectMany(x => x.affectedParts).Distinct())
            {
                ThingDef def = new ThingDef();
                def.isTechHediff    = true;
                def.category        = ThingCategory.Item;
                def.thingClass      = typeof(ThingWithComps);
                def.thingCategories = new List <ThingCategoryDef>()
                {
                    ThingCategoryDefOf.BodyParts
                };
                def.graphicData = new GraphicData()
                {
                    graphicClass = typeof(Graphic_Single), texPath = "Radiology/Items/MutatedBodyPartBox"
                };
                def.uiIconPath   = "Radiology/Items/MutatedBodyPartBox";
                def.useHitPoints = true;
                def.selectable   = true;
                def.SetStatBaseValue(StatDefOf.MaxHitPoints, 50f);
                def.SetStatBaseValue(StatDefOf.Flammability, 0.7f);
                def.SetStatBaseValue(StatDefOf.MarketValue, 500f);
                def.SetStatBaseValue(StatDefOf.Mass, 1f);
                def.SetStatBaseValue(StatDefOf.SellPriceFactor, 1.0f);
                def.altitudeLayer  = AltitudeLayer.Item;
                def.tickerType     = TickerType.Never;
                def.alwaysHaulable = true;
                def.rotatable      = false;
                def.pathCost       = 15;
                def.drawGUIOverlay = true;
                def.modContentPack = Radiology.modContentPack;
                def.tradeability   = Tradeability.None;
                def.defName        = "Mutated" + part.defName;
                def.label          = "Mutated " + part.label;
                def.description    = "Mutated " + part.label;
                def.comps.Add(new CompProperties_Forbiddable());
                def.comps.Add(new CompProperties_Glower()
                {
                    glowColor = new ColorInt(0, 255, 0), glowRadius = 1
                });
                def.comps.Add(new CompProperties()
                {
                    compClass = typeof(CompHediffStorage)
                });


                RecipeDef recipe = new RecipeDef();
                recipe.defName               = "InstallMutated" + part.defName;
                recipe.label                 = "install mutated " + part.label;
                recipe.description           = "Install a mutated " + part.label + ".";
                recipe.descriptionHyperlinks = new List <DefHyperlink>()
                {
                    def
                };
                recipe.jobString       = "Installing mutated " + part.label + ".";
                recipe.workerClass     = typeof(Recipe_InstallMutatedBodyPart);
                recipe.targetsBodyPart = true;
                recipe.dontShowIfAnyIngredientMissing = true;

                recipe.effectWorking              = installHeart.effectWorking;
                recipe.soundWorking               = installHeart.soundWorking;
                recipe.workSpeedStat              = installHeart.workSpeedStat;
                recipe.workSkill                  = installHeart.workSkill;
                recipe.workSkillLearnFactor       = installHeart.workSkillLearnFactor;
                recipe.workAmount                 = installHeart.workAmount;
                recipe.anesthetize                = installHeart.anesthetize;
                recipe.deathOnFailedSurgeryChance = installHeart.deathOnFailedSurgeryChance;

                recipe.surgerySuccessChanceFactor = 1.2f;
                recipe.modContentPack             = Radiology.modContentPack;

                IngredientCount medicine = new IngredientCount();
                medicine.SetBaseCount(2);
                medicine.filter.SetAllow(RimWorld.ThingDefOf.MedicineIndustrial, true);
                recipe.ingredients.Add(medicine);

                IngredientCount mutatedPart = new IngredientCount();
                mutatedPart.filter.SetAllow(def, true);
                recipe.ingredients.Add(mutatedPart);

                recipe.recipeUsers             = new List <ThingDef>(installHeart.recipeUsers);
                recipe.appliedOnFixedBodyParts = new List <BodyPartDef>()
                {
                    part
                };
                recipe.skillRequirements = new List <SkillRequirement>()
                {
                    new SkillRequirement()
                    {
                        minLevel = 8, skill = SkillDefOf.Medicine
                    }
                };

                def.descriptionHyperlinks = new List <DefHyperlink>()
                {
                    recipe
                };

                if (!ignoreParts.Contains(part.defName))
                {
                    Radiology.bodyPartItems[part] = def;
                }
                Radiology.itemBodyParts[def] = part;

                DefGenerator.AddImpliedDef(def);
                DefGenerator.AddImpliedDef(recipe);
            }
        }