private static IntVec3 FindArtySpot(ThingDef artyDef, Rot4 rot, Map map) { CellRect cellRect = CellRect.CenteredOn(SiegeBlueprintPlacer.center, 8); cellRect.ClipInsideMap(map); int num = 0; while (true) { num++; if (num > 200) { break; } IntVec3 randomCell = cellRect.RandomCell; if (map.reachability.CanReach(randomCell, SiegeBlueprintPlacer.center, PathEndMode.OnCell, TraverseMode.NoPassClosedDoors, Danger.Deadly)) { if (!randomCell.Roofed(map)) { if (SiegeBlueprintPlacer.CanPlaceBlueprintAt(randomCell, rot, artyDef, map)) { return(randomCell); } } } } return(IntVec3.Invalid); }
public static IEnumerable <Blueprint_Build> PlaceBlueprints(IntVec3 placeCenter, Map map, Faction placeFaction, float points) { SiegeBlueprintPlacer.center = placeCenter; SiegeBlueprintPlacer.faction = placeFaction; using (IEnumerator <Blueprint_Build> enumerator = SiegeBlueprintPlacer.PlaceSandbagBlueprints(map).GetEnumerator()) { if (enumerator.MoveNext()) { Blueprint_Build blue2 = enumerator.Current; yield return(blue2); /*Error: Unable to find new state assignment for yield return*/; } } using (IEnumerator <Blueprint_Build> enumerator2 = SiegeBlueprintPlacer.PlaceArtilleryBlueprints(points, map).GetEnumerator()) { if (enumerator2.MoveNext()) { Blueprint_Build blue = enumerator2.Current; yield return(blue); /*Error: Unable to find new state assignment for yield return*/; } } yield break; IL_0166: /*Error near IL_0167: Unexpected return in MoveNext()*/; }
private static IEnumerable <Blueprint_Build> MakeSandbagLine(IntVec3 root, Map map, Rot4 growDir, int maxLength) { int i = 0; if (i < maxLength && SiegeBlueprintPlacer.CanPlaceBlueprintAt(root, Rot4.North, ThingDefOf.Sandbags, map)) { yield return(GenConstruct.PlaceBlueprintForBuild(ThingDefOf.Sandbags, root, map, Rot4.North, SiegeBlueprintPlacer.faction, null)); /*Error: Unable to find new state assignment for yield return*/; } }
public static IEnumerable <Blueprint_Build> PlaceBlueprints(IntVec3 placeCenter, Map map, Faction placeFaction, float points) { SiegeBlueprintPlacer.center = placeCenter; SiegeBlueprintPlacer.faction = placeFaction; foreach (Blueprint_Build blue in SiegeBlueprintPlacer.PlaceSandbagBlueprints(map)) { yield return(blue); } foreach (Blueprint_Build blue2 in SiegeBlueprintPlacer.PlaceArtilleryBlueprints(points, map)) { yield return(blue2); } }
private static IEnumerable <Blueprint_Build> MakeSandbagLine(IntVec3 root, Map map, Rot4 growDir, int maxLength) { IntVec3 cur = root; for (int i = 0; i < maxLength; i++) { if (!SiegeBlueprintPlacer.CanPlaceBlueprintAt(cur, Rot4.North, ThingDefOf.Sandbags, map)) { break; } yield return(GenConstruct.PlaceBlueprintForBuild(ThingDefOf.Sandbags, cur, map, Rot4.North, SiegeBlueprintPlacer.faction, null)); SiegeBlueprintPlacer.placedSandbagLocs.Add(cur); cur += growDir.FacingCell; } }
private static IntVec3 FindSandbagRoot(Map map) { CellRect cellRect = CellRect.CenteredOn(SiegeBlueprintPlacer.center, 13); cellRect.ClipInsideMap(map); CellRect cellRect2 = CellRect.CenteredOn(SiegeBlueprintPlacer.center, 8); cellRect2.ClipInsideMap(map); int num = 0; IntVec3 randomCell; for (;;) { num++; if (num > 200) { break; } randomCell = cellRect.RandomCell; if (!cellRect2.Contains(randomCell)) { if (map.reachability.CanReach(randomCell, SiegeBlueprintPlacer.center, PathEndMode.OnCell, TraverseMode.NoPassClosedDoors, Danger.Deadly)) { if (SiegeBlueprintPlacer.CanPlaceBlueprintAt(randomCell, Rot4.North, ThingDefOf.Sandbags, map)) { bool flag = false; for (int i = 0; i < SiegeBlueprintPlacer.placedSandbagLocs.Count; i++) { float num2 = (float)(SiegeBlueprintPlacer.placedSandbagLocs[i] - randomCell).LengthHorizontalSquared; if (num2 < 36f) { flag = true; } } if (!flag) { goto IL_104; } } } } } return(IntVec3.Invalid); IL_104: return(randomCell); }
private static IEnumerable <Blueprint_Build> PlaceSandbagBlueprints(Map map) { SiegeBlueprintPlacer.placedSandbagLocs.Clear(); int numSandbags = SiegeBlueprintPlacer.NumSandbagRange.RandomInRange; int i = 0; while (i < numSandbags) { IntVec3 bagRoot = SiegeBlueprintPlacer.FindSandbagRoot(map); if (bagRoot.IsValid) { Rot4 growDirA = (bagRoot.x <= SiegeBlueprintPlacer.center.x) ? Rot4.East : Rot4.West; Rot4 growDirB = (bagRoot.z <= SiegeBlueprintPlacer.center.z) ? Rot4.North : Rot4.South; using (IEnumerator <Blueprint_Build> enumerator = SiegeBlueprintPlacer.MakeSandbagLine(bagRoot, map, growDirA, SiegeBlueprintPlacer.SandbagLengthRange.RandomInRange).GetEnumerator()) { if (enumerator.MoveNext()) { Blueprint_Build bag2 = enumerator.Current; yield return(bag2); /*Error: Unable to find new state assignment for yield return*/; } } bagRoot += growDirB.FacingCell; using (IEnumerator <Blueprint_Build> enumerator2 = SiegeBlueprintPlacer.MakeSandbagLine(bagRoot, map, growDirB, SiegeBlueprintPlacer.SandbagLengthRange.RandomInRange).GetEnumerator()) { if (enumerator2.MoveNext()) { Blueprint_Build bag = enumerator2.Current; yield return(bag); /*Error: Unable to find new state assignment for yield return*/; } } i++; continue; } break; } yield break; IL_0271: /*Error near IL_0272: Unexpected return in MoveNext()*/; }
private static IEnumerable <Blueprint_Build> PlaceSandbagBlueprints(Map map) { SiegeBlueprintPlacer.placedSandbagLocs.Clear(); int numSandbags = SiegeBlueprintPlacer.NumSandbagRange.RandomInRange; for (int i = 0; i < numSandbags; i++) { IntVec3 bagRoot = SiegeBlueprintPlacer.FindSandbagRoot(map); if (!bagRoot.IsValid) { yield break; } Rot4 growDirA; if (bagRoot.x > SiegeBlueprintPlacer.center.x) { growDirA = Rot4.West; } else { growDirA = Rot4.East; } Rot4 growDirB; if (bagRoot.z > SiegeBlueprintPlacer.center.z) { growDirB = Rot4.South; } else { growDirB = Rot4.North; } foreach (Blueprint_Build bag in SiegeBlueprintPlacer.MakeSandbagLine(bagRoot, map, growDirA, SiegeBlueprintPlacer.SandbagLengthRange.RandomInRange)) { yield return(bag); } bagRoot += growDirB.FacingCell; foreach (Blueprint_Build bag2 in SiegeBlueprintPlacer.MakeSandbagLine(bagRoot, map, growDirB, SiegeBlueprintPlacer.SandbagLengthRange.RandomInRange)) { yield return(bag2); } } yield break; }
private static IEnumerable <Blueprint_Build> PlaceArtilleryBlueprints(float points, Map map) { IEnumerable <ThingDef> artyDefs = from def in DefDatabase <ThingDef> .AllDefs where def.building != null && def.building.buildingTags.Contains("Artillery_BaseDestroyer") select def; int numArtillery = Mathf.RoundToInt(points / 60f); numArtillery = Mathf.Clamp(numArtillery, 1, 2); for (int i = 0; i < numArtillery; i++) { Rot4 rot = Rot4.Random; ThingDef artyDef = artyDefs.RandomElement <ThingDef>(); IntVec3 artySpot = SiegeBlueprintPlacer.FindArtySpot(artyDef, rot, map); if (!artySpot.IsValid) { break; } yield return(GenConstruct.PlaceBlueprintForBuild(artyDef, artySpot, map, rot, SiegeBlueprintPlacer.faction, ThingDefOf.Steel)); points -= 60f; } }
private static IEnumerable <Blueprint_Build> PlaceArtilleryBlueprints(float points, Map map) { IEnumerable <ThingDef> artyDefs = from def in DefDatabase <ThingDef> .AllDefs where def.building != null && def.building.buildingTags.Contains("Artillery_BaseDestroyer") select def; int numArtillery2 = Mathf.RoundToInt((float)(points / 60.0)); numArtillery2 = Mathf.Clamp(numArtillery2, 1, 2); int i = 0; if (i < numArtillery2) { Rot4 rot = Rot4.Random; ThingDef artyDef = artyDefs.RandomElement(); IntVec3 artySpot = SiegeBlueprintPlacer.FindArtySpot(artyDef, rot, map); if (artySpot.IsValid) { yield return(GenConstruct.PlaceBlueprintForBuild(artyDef, artySpot, map, rot, SiegeBlueprintPlacer.faction, ThingDefOf.Steel)); /*Error: Unable to find new state assignment for yield return*/; } } }
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; }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; bool flag = false; switch (num) { case 0u: SiegeBlueprintPlacer.center = placeCenter; SiegeBlueprintPlacer.faction = placeFaction; enumerator = SiegeBlueprintPlacer.PlaceSandbagBlueprints(map).GetEnumerator(); num = 4294967293u; break; case 1u: break; case 2u: goto IL_E9; default: return(false); } try { switch (num) { } if (enumerator.MoveNext()) { blue = enumerator.Current; this.$current = blue; if (!this.$disposing) { this.$PC = 1; } flag = true; return(true); } } finally { if (!flag) { if (enumerator != null) { enumerator.Dispose(); } } } enumerator2 = SiegeBlueprintPlacer.PlaceArtilleryBlueprints(points, map).GetEnumerator(); num = 4294967293u; try { IL_E9: switch (num) { } if (enumerator2.MoveNext()) { blue2 = enumerator2.Current; this.$current = blue2; if (!this.$disposing) { this.$PC = 2; } flag = true; return(true); } } finally { if (!flag) { if (enumerator2 != null) { enumerator2.Dispose(); } } } this.$PC = -1; return(false); }