Esempio n. 1
0
        protected override void ScatterAt(IntVec3 c, Map map, int stackCount = 1)
        {
            RimEconomyWorldManager rimEconomyWorldManager = Find.World.GetComponent <RimEconomyWorldManager>();
            List <Speciality>      specialities           = rimEconomyWorldManager.getSettlementTileSpecialities(map.Tile);
            int      specialityPowerCount = specialities.Count + (specialities.FindAll((Speciality speciality) => speciality.produceSilver()).Count) * RimEconomy.SilverPower;
            int      extraFactionBasePowerPerSpeciality = RimEconomy.SettingInt["extraFactionBasePowerPerSpeciality"].Value;
            IntRange factionBaseSizeRange = new IntRange(Math.Min(map.Size.x - 50, 34 + (int)(specialityPowerCount * extraFactionBasePowerPerSpeciality)), Math.Min(map.Size.z - 50, 38 + (int)(specialityPowerCount * extraFactionBasePowerPerSpeciality)));
            int      randomInRange        = factionBaseSizeRange.RandomInRange;
            int      randomInRange2       = factionBaseSizeRange.RandomInRange;
            CellRect rect = new CellRect(c.x - randomInRange / 2, c.z - randomInRange2 / 2, randomInRange, randomInRange2);
            Faction  faction;

            if (map.ParentFaction == null || map.ParentFaction == Faction.OfPlayer)
            {
                faction = Find.FactionManager.RandomEnemyFaction(false, false, true, TechLevel.Undefined);
            }
            else
            {
                faction = map.ParentFaction;
            }
            rect.ClipInsideMap(map);
            ResolveParams resolveParams = default(ResolveParams);

            resolveParams.rect                  = rect;
            resolveParams.faction               = faction;
            BaseGen.globalSettings.map          = map;
            BaseGen.globalSettings.minBuildings = 1;
            BaseGen.globalSettings.minBarracks  = 1;
            BaseGen.symbolStack.Push("factionBase", resolveParams);
            BaseGen.Generate();
        }
        private bool reset()
        {
            Settlement settlement = TradeSession.trader as Settlement;

            if (settlement != null)
            {
                RimEconomyWorldManager specialityWorldManager = Find.World.GetComponent <RimEconomyWorldManager>();
                List <Speciality>      specialityList         = specialityWorldManager.getSettlementSpecialities(settlement);
                if (productionListWithoutQuantity == null)
                {
                    List <Thing> fullProductionList = specialityWorldManager.getSettlementProductionList(settlement);
                    productionListWithoutQuantity = fullProductionList.GetRange(0, Math.Max(Math.Min(5, fullProductionList.Count), (int)(Rand.Value * fullProductionList.Count)));
                    productionListWithoutQuantity.AddRange(specialityWorldManager.getSettlementRawMaterials(settlement).ConvertAll((ThingDef input) => {
                        if (input.race != null)
                        {
                            Speciality speciality = specialityList.Find((Speciality obj) => obj.AnimalSpeciality != null && obj.AnimalSpeciality.race == input);
                            return(PawnGenerator.GeneratePawn(speciality.AnimalSpeciality));
                        }
                        else
                        {
                            return(ThingMaker.MakeThing(input));
                        }
                    }));
                }
                if (totalPriceRange == FloatRange.Zero)
                {
                    int countBounus = specialityList.Aggregate(0, (int count, Speciality speciality) => count + speciality.getAllBounus().Count + (speciality.produceSilver() ? RimEconomy.SilverPower : 0));
                    totalPriceRange = new FloatRange(1000 * countBounus, 2000 * countBounus);
                }
                maxTechLevelGenerate = TradeSession.trader.Faction.def.techLevel;
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        public override void Generate(Map map)
        {
            RimEconomyWorldManager specialitiesWorldManager = Find.World.GetComponent <RimEconomyWorldManager>();
            Speciality             speciality = specialitiesWorldManager.getTileSpeciality(map.Tile);

            if (speciality != null)
            {
                RimEconomyMapManager specialityMapManager = map.GetComponent <RimEconomyMapManager>();
                specialityMapManager.GenerateMap(speciality);
            }
        }
        public override void GenerateFresh(string seed)
        {
            RimEconomyWorldManager rimEconomyWorldManager = Find.World.GetComponent <RimEconomyWorldManager>();

            rimEconomyWorldManager.generateSpecialitiesFresh(seed);
        }