private static bool CanGoDirectlyToNextCell(Pawn pawn) { IntVec3 nextCell = pawn.pather.nextCell; foreach (IntVec3 item in CellRect.FromLimits(nextCell, pawn.Position).ExpandedBy(1)) { if (!item.InBounds(pawn.Map)) { continue; } List <Thing> thingList = item.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { Pawn pawn2 = thingList[i] as Pawn; if (pawn2 == null || pawn2 == pawn || pawn2.GetPosture() != 0) { continue; } if (pawn2.pather.MovingNow) { if (((pawn2.Position == nextCell && WillBeFasterOnNextCell(pawn, pawn2)) || pawn2.pather.nextCell == nextCell || pawn2.Position == pawn.Position || (pawn2.pather.nextCell == pawn.Position && WillBeFasterOnNextCell(pawn2, pawn))) && pawn2.thingIDNumber < pawn.thingIDNumber) { return(false); } } else if (pawn2.Position == pawn.Position || pawn2.Position == nextCell) { return(false); } } } return(true); }
private static void BaseGen() { List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (string item in DefDatabase <RuleDef> .AllDefs.Select((RuleDef x) => x.symbol).Distinct()) { string localSymbol = item; list.Add(new DebugMenuOption(item, DebugMenuOptionMode.Action, delegate { DebugTool tool = null; IntVec3 firstCorner = default(IntVec3); tool = new DebugTool("first corner...", delegate { firstCorner = UI.MouseCell(); DebugTools.curTool = new DebugTool("second corner...", delegate { IntVec3 second = UI.MouseCell(); CellRect rect = CellRect.FromLimits(firstCorner, second).ClipInsideMap(Find.CurrentMap); RimWorld.BaseGen.BaseGen.globalSettings.map = Find.CurrentMap; RimWorld.BaseGen.BaseGen.symbolStack.Push(localSymbol, rect); RimWorld.BaseGen.BaseGen.Generate(); DebugTools.curTool = tool; }, firstCorner); }); DebugTools.curTool = tool; })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
private static bool CanGoDirectlyToNextCell(Pawn pawn) { IntVec3 nextCell = pawn.pather.nextCell; CellRect.CellRectIterator iterator = CellRect.FromLimits(nextCell, pawn.Position).ExpandedBy(1).GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; if (current.InBounds(pawn.Map)) { List <Thing> thingList = current.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { Pawn pawn2 = thingList[i] as Pawn; if (pawn2 != null && pawn2 != pawn && pawn2.GetPosture() == PawnPosture.Standing) { if (pawn2.pather.MovingNow) { if (((pawn2.Position == nextCell && WillBeFasterOnNextCell(pawn, pawn2)) || pawn2.pather.nextCell == nextCell || pawn2.Position == pawn.Position || (pawn2.pather.nextCell == pawn.Position && WillBeFasterOnNextCell(pawn2, pawn))) && pawn2.thingIDNumber < pawn.thingIDNumber) { return(false); } } else if (pawn2.Position == pawn.Position || pawn2.Position == nextCell) { return(false); } } } } iterator.MoveNext(); } return(true); }
private static void FlashSpectatorsCells() { Action <bool> act = delegate(bool bestSideOnly) { DebugTool tool = null; IntVec3 firstCorner = default(IntVec3); tool = new DebugTool("first watch rect corner...", delegate { firstCorner = UI.MouseCell(); DebugTools.curTool = new DebugTool("second watch rect corner...", delegate { IntVec3 second = UI.MouseCell(); CellRect spectateRect = CellRect.FromLimits(firstCorner, second).ClipInsideMap(Find.CurrentMap); SpectateRectSide allowedSides = SpectateRectSide.All; if (bestSideOnly) { allowedSides = SpectatorCellFinder.FindSingleBestSide(spectateRect, Find.CurrentMap); } SpectatorCellFinder.DebugFlashPotentialSpectatorCells(spectateRect, Find.CurrentMap, allowedSides); DebugTools.curTool = tool; }, firstCorner); }); DebugTools.curTool = tool; }; List <DebugMenuOption> list = new List <DebugMenuOption>(); list.Add(new DebugMenuOption("All sides", DebugMenuOptionMode.Action, delegate { act(obj: false); })); list.Add(new DebugMenuOption("Best side only", DebugMenuOptionMode.Action, delegate { act(obj: true); })); Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }