コード例 #1
0
 public override void MapComponentUpdate()
 {
     base.MapComponentUpdate();
     if (this.doGeneration && path?.Length > 0)
     {
         try
         {
             SettlementGeneration.DoSettlementGeneration(this.map, this.path, this.locationDef, this.map.ParentFaction, false);
         }
         catch (Exception ex)
         {
             Log.Error(ex.ToString());
         }
         GetOrGenerateMapPatch.caravanArrival             = false;
         GetOrGenerateMapPatch.locationData               = null;
         GetOrGenerateMapPatch.customSettlementGeneration = false;
         this.doGeneration = false;
     }
     if (this.reFog)
     {
         Log.Message("Refog" + this.map);
         try
         {
             FloodFillerFog.DebugRefogMap(this.map);
         }
         catch
         {
         }
         this.reFog = false;
     }
 }
コード例 #2
0
 public static void Postfix(IntVec3 mapSize, MapParent parent, MapGeneratorDef mapGenerator, IEnumerable <GenStepWithParams> extraGenStepDefs = null, Action <Map> extraInitBeforeContentGen = null)
 {
     Log.Message("GetOrGenerateMapPatch.caravanArrival: " + GetOrGenerateMapPatch.caravanArrival);
     if (!caravanArrival)
     {
         var preset = SettlementGeneration.GetPresetFor(parent, out LocationDef locationDef);
         if (preset != null && locationDef != null)
         {
             SettlementGeneration.DoSettlementGeneration(parent.Map, preset.FullName, locationDef, parent.Faction, false);
         }
     }
 }
コード例 #3
0
        private static bool Prefix(ResolveParams rp)
        {
            Map map = BaseGen.globalSettings.map;

            if (GetOrGenerateMapPatch.customSettlementGeneration)
            {
                Faction faction = rp.faction ?? Find.FactionManager.RandomEnemyFaction();
                SettlementGeneration.DoSettlementGeneration(map, GetOrGenerateMapPatch.locationData.file.FullName, GetOrGenerateMapPatch.locationData.locationDef, faction, false);

                rp.rect = rp.rect.MovedBy(map.Center - rp.rect.CenterCell);
                //foreach (var cell in rp.rect.Cells)
                //{
                //}

                Lord          singlePawnLord = rp.singlePawnLord ?? LordMaker.MakeNewLord(faction, new LordJob_DefendBase(faction, rp.rect.CenterCell), map);
                TraverseParms traverseParms  = TraverseParms.For(TraverseMode.PassDoors);
                ResolveParams resolveParams  = rp;
                resolveParams.rect             = rp.rect;
                resolveParams.faction          = faction;
                resolveParams.singlePawnLord   = singlePawnLord;
                resolveParams.pawnGroupKindDef = (rp.pawnGroupKindDef ?? PawnGroupKindDefOf.Settlement);
                //resolveParams.singlePawnSpawnCellExtraPredicate = (rp.singlePawnSpawnCellExtraPredicate ?? ((Predicate<IntVec3>)((IntVec3 x) => map.reachability.CanReachMapEdge(x, traverseParms))));
                if (resolveParams.pawnGroupMakerParams == null)
                {
                    resolveParams.pawnGroupMakerParams             = new PawnGroupMakerParms();
                    resolveParams.pawnGroupMakerParams.tile        = map.Tile;
                    resolveParams.pawnGroupMakerParams.faction     = faction;
                    resolveParams.pawnGroupMakerParams.points      = (rp.settlementPawnGroupPoints ?? DefaultPawnsPoints.RandomInRange);
                    resolveParams.pawnGroupMakerParams.inhabitants = true;
                    resolveParams.pawnGroupMakerParams.seed        = rp.settlementPawnGroupSeed;
                }
                BaseGen.symbolStack.Push("pawnGroup", resolveParams);
                return(false);
            }
            GetOrGenerateMapPatch.customSettlementGeneration = false;
            return(true);
        }
コード例 #4
0
        public static void LoadBlueprint()
        {
            var curModName = LoadedModManager.RunningMods.Where(x => x.assemblies.loadedAssemblies.Contains(Assembly.GetExecutingAssembly())).FirstOrDefault().Name;

            Log.Message("curModName: " + curModName);
            ModMetaData modMetaData = ModLister.AllInstalledMods.FirstOrDefault((ModMetaData x) => x != null && x.Name != null && x.Active && x.Name == curModName);
            string      path        = Path.GetFullPath(modMetaData.RootDir.ToString() + "/Presets/");

            Log.Message("path: " + path);
            DirectoryInfo directoryInfo = new DirectoryInfo(path);

            if (!directoryInfo.Exists)
            {
                directoryInfo.Create();
            }

            List <DebugMenuOption> list = new List <DebugMenuOption>();

            using (IEnumerator <FileInfo> enumerator = directoryInfo.GetFiles().AsEnumerable().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    string name = enumerator.Current.Name;
                    list.Add(new DebugMenuOption(name, 0, delegate()
                    {
                        path    = path + name;
                        Map map = Find.CurrentMap;
                        SettlementGeneration.DoSettlementGeneration(map, path, null, Faction.OfPlayer, false);
                    }));
                }
            }
            if (list.Any())
            {
                Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
            }
        }