public static void DropThingsNear(IntVec3 dropCenter, Map map, IEnumerable <Thing> things, int openDelay = 110, bool canInstaDropDuringInit = false, bool leaveSlag = false, bool canRoofPunch = true, bool explode = false) { foreach (Thing thing in things) { List <Thing> list = new List <Thing>(); list.Add(thing); DropPodUtility.tempList.Add(list); } DropPodUtility.DropThingGroupsNear(dropCenter, map, DropPodUtility.tempList, openDelay, canInstaDropDuringInit, leaveSlag, canRoofPunch, explode); DropPodUtility.tempList.Clear(); }
public override void GenerateIntoMap(Map map) { if (Find.GameInitData == null) { return; } List <List <Thing> > list = new List <List <Thing> >(); foreach (Pawn item in Find.GameInitData.startingAndOptionalPawns) { list.Add(new List <Thing> { item }); } List <Thing> list2 = new List <Thing>(); foreach (ScenPart scenPart in Find.Scenario.AllParts) { list2.AddRange(scenPart.PlayerStartingThings()); } int num = 0; foreach (Thing thing in list2) { if (thing.def.CanHaveFaction) { thing.SetFactionDirect(Faction.OfPlayer); } list[num].Add(thing); num++; if (num >= list.Count) { num = 0; } } IntVec3 playerStartSpot = MapGenerator.PlayerStartSpot; List <List <Thing> > thingsGroups = list; bool instaDrop = Find.GameInitData.QuickStarted || this.method != PlayerPawnsArriveMethod.DropPods; DropPodUtility.DropThingGroupsNear(playerStartSpot, map, thingsGroups, 110, instaDrop, true, true); }
public override void Init() { base.Init(); LordToilData_Siege data = this.Data; data.baseRadius = Mathf.InverseLerp(14f, 25f, (float)this.lord.ownedPawns.Count / 50f); data.baseRadius = Mathf.Clamp(data.baseRadius, 14f, 25f); List <Thing> list = new List <Thing>(); foreach (Blueprint_Build current in SiegeBlueprintPlacer.PlaceBlueprints(data.siegeCenter, base.Map, this.lord.faction, data.blueprintPoints)) { data.blueprints.Add(current); foreach (ThingDefCountClass cost in current.MaterialsNeeded()) { Thing thing = list.FirstOrDefault((Thing t) => t.def == cost.thingDef); if (thing != null) { thing.stackCount += cost.count; } else { Thing thing2 = ThingMaker.MakeThing(cost.thingDef, null); thing2.stackCount = cost.count; list.Add(thing2); } } ThingDef thingDef = current.def.entityDefToBuild as ThingDef; if (thingDef != null) { ThingDef turret = thingDef; bool allowEMP = false; TechLevel techLevel = this.lord.faction.def.techLevel; ThingDef thingDef2 = TurretGunUtility.TryFindRandomShellDef(turret, allowEMP, true, techLevel, false, 250f); if (thingDef2 != null) { Thing thing3 = ThingMaker.MakeThing(thingDef2, null); thing3.stackCount = 5; list.Add(thing3); } } } for (int i = 0; i < list.Count; i++) { list[i].stackCount = Mathf.CeilToInt((float)list[i].stackCount * Rand.Range(1f, 1.2f)); } List <List <Thing> > list2 = new List <List <Thing> >(); for (int j = 0; j < list.Count; j++) { while (list[j].stackCount > list[j].def.stackLimit) { int num = Mathf.CeilToInt((float)list[j].def.stackLimit * Rand.Range(0.9f, 0.999f)); Thing thing4 = ThingMaker.MakeThing(list[j].def, null); thing4.stackCount = num; list[j].stackCount -= num; list.Add(thing4); } } List <Thing> list3 = new List <Thing>(); for (int k = 0; k < list.Count; k++) { list3.Add(list[k]); if (k % 2 == 1 || k == list.Count - 1) { list2.Add(list3); list3 = new List <Thing>(); } } List <Thing> list4 = new List <Thing>(); int num2 = Mathf.RoundToInt(LordToil_Siege.MealCountRangePerRaider.RandomInRange * (float)this.lord.ownedPawns.Count); for (int l = 0; l < num2; l++) { Thing item = ThingMaker.MakeThing(ThingDefOf.MealSurvivalPack, null); list4.Add(item); } list2.Add(list4); DropPodUtility.DropThingGroupsNear(data.siegeCenter, base.Map, list2, 110, false, false, true); data.desiredBuilderFraction = LordToil_Siege.BuilderCountFraction.RandomInRange; }