public static bool ModifyCarriedThingDrawPosWorker(ref Vector3 drawPos, ref bool behind, ref bool flip, IntVec3 placeCell, Pawn pawn) { if (pawn.pather.Moving) { return(false); } Thing carriedThing = pawn.carryTracker.CarriedThing; if (carriedThing == null || !carriedThing.IngestibleNow) { return(false); } if (placeCell.IsValid && placeCell.AdjacentToCardinal(pawn.Position) && placeCell.HasEatSurface(pawn.Map) && carriedThing.def.ingestible.ingestHoldUsesTable) { drawPos = new Vector3((float)placeCell.x + 0.5f, drawPos.y, (float)placeCell.z + 0.5f); return(true); } if (carriedThing.def.ingestible.ingestHoldOffsetStanding != null) { HoldOffset holdOffset = carriedThing.def.ingestible.ingestHoldOffsetStanding.Pick(pawn.Rotation); if (holdOffset != null) { drawPos += holdOffset.offset; behind = holdOffset.behind; flip = holdOffset.flip; return(true); } } return(false); }
private void ReconstructPathAndDestroyWalls(IntVec3 foundDest, Room room, ResolveParams rp) { Map map = BaseGen.globalSettings.map; map.floodFiller.ReconstructLastFloodFillPath(foundDest, SymbolResolver_EnsureCanReachMapEdge.path); while (SymbolResolver_EnsureCanReachMapEdge.path.Count >= 2 && SymbolResolver_EnsureCanReachMapEdge.path[0].AdjacentToCardinal(room) && SymbolResolver_EnsureCanReachMapEdge.path[1].AdjacentToCardinal(room)) { SymbolResolver_EnsureCanReachMapEdge.path.RemoveAt(0); } IntVec3 intVec = IntVec3.Invalid; ThingDef thingDef = null; IntVec3 intVec2 = IntVec3.Invalid; ThingDef thingDef2 = null; for (int i = 0; i < SymbolResolver_EnsureCanReachMapEdge.path.Count; i++) { Building edifice = SymbolResolver_EnsureCanReachMapEdge.path[i].GetEdifice(map); if (this.IsWallOrRock(edifice)) { if (!intVec.IsValid) { intVec = SymbolResolver_EnsureCanReachMapEdge.path[i]; thingDef = edifice.Stuff; } intVec2 = SymbolResolver_EnsureCanReachMapEdge.path[i]; thingDef2 = edifice.Stuff; edifice.Destroy(DestroyMode.Vanish); } } if (intVec.IsValid) { ThingDef arg_132_0; if ((arg_132_0 = thingDef) == null) { arg_132_0 = (rp.wallStuff ?? BaseGenUtility.RandomCheapWallStuff(rp.faction, false)); } ThingDef stuff = arg_132_0; Thing thing = ThingMaker.MakeThing(ThingDefOf.Door, stuff); thing.SetFaction(rp.faction, null); GenSpawn.Spawn(thing, intVec, map, WipeMode.Vanish); } if (intVec2.IsValid && intVec2 != intVec && !intVec2.AdjacentToCardinal(intVec)) { ThingDef arg_1A6_0; if ((arg_1A6_0 = thingDef2) == null) { arg_1A6_0 = (rp.wallStuff ?? BaseGenUtility.RandomCheapWallStuff(rp.faction, false)); } ThingDef stuff2 = arg_1A6_0; Thing thing2 = ThingMaker.MakeThing(ThingDefOf.Door, stuff2); thing2.SetFaction(rp.faction, null); GenSpawn.Spawn(thing2, intVec2, map, WipeMode.Vanish); } }
// Token: 0x060052A0 RID: 21152 RVA: 0x00129A28 File Offset: 0x00127E28 private bool CheckForFreeInterceptBetween(Vector3 lastExactPos, Vector3 newExactPos) { IntVec3 intVec = lastExactPos.ToIntVec3(); IntVec3 intVec2 = newExactPos.ToIntVec3(); if (intVec2 == intVec) { return(false); } if (!intVec.InBounds(base.Map) || !intVec2.InBounds(base.Map)) { return(false); } if (intVec2.AdjacentToCardinal(intVec)) { return(this.CheckForFreeIntercept(intVec2)); } if (VerbUtility.InterceptChanceFactorFromDistance(this.origin, intVec2) <= 0f) { return(false); } Vector3 vector = lastExactPos; Vector3 v = newExactPos - lastExactPos; Vector3 b = v.normalized * 0.2f; int num = (int)(v.MagnitudeHorizontal() / 0.2f); Stuffable_Projectile.checkedCells.Clear(); int num2 = 0; for (; ;) { vector += b; IntVec3 intVec3 = vector.ToIntVec3(); if (!Stuffable_Projectile.checkedCells.Contains(intVec3)) { if (this.CheckForFreeIntercept(intVec3)) { break; } Stuffable_Projectile.checkedCells.Add(intVec3); } num2++; if (num2 > num) { return(false); } if (intVec3 == intVec2) { return(false); } } return(true); }
private void ReconstructPathAndDestroyWalls(IntVec3 foundDest, Room room, ResolveParams rp) { Map map = BaseGen.globalSettings.map; map.floodFiller.ReconstructLastFloodFillPath(foundDest, path); while (path.Count >= 2 && path[0].AdjacentToCardinal(room) && path[1].AdjacentToCardinal(room)) { path.RemoveAt(0); } IntVec3 intVec = IntVec3.Invalid; ThingDef thingDef = null; IntVec3 intVec2 = IntVec3.Invalid; ThingDef thingDef2 = null; for (int i = 0; i < path.Count; i++) { Building edifice = path[i].GetEdifice(map); if (IsWallOrRock(edifice)) { if (!intVec.IsValid) { intVec = path[i]; thingDef = edifice.Stuff; } intVec2 = path[i]; thingDef2 = edifice.Stuff; edifice.Destroy(); } } if (intVec.IsValid) { ThingDef stuff = thingDef ?? rp.wallStuff ?? BaseGenUtility.RandomCheapWallStuff(rp.faction); Thing thing = ThingMaker.MakeThing(ThingDefOf.Door, stuff); thing.SetFaction(rp.faction); GenSpawn.Spawn(thing, intVec, map); } if (intVec2.IsValid && intVec2 != intVec && !intVec2.AdjacentToCardinal(intVec)) { ThingDef stuff2 = thingDef2 ?? rp.wallStuff ?? BaseGenUtility.RandomCheapWallStuff(rp.faction); Thing thing2 = ThingMaker.MakeThing(ThingDefOf.Door, stuff2); thing2.SetFaction(rp.faction); GenSpawn.Spawn(thing2, intVec2, map); } }
private bool CheckForFreeInterceptBetween(Vector3 lastExactPos, Vector3 newExactPos) { IntVec3 intVec = lastExactPos.ToIntVec3(); IntVec3 intVec2 = newExactPos.ToIntVec3(); if (intVec2 == intVec) { return(false); } if (!intVec.InBounds() || !intVec2.InBounds()) { return(false); } if (intVec2.AdjacentToCardinal(intVec)) { bool flag = this.CheckForFreeIntercept(intVec2); if (DebugViewSettings.drawInterceptChecks) { if (flag) { MoteMaker.ThrowText(intVec2.ToVector3Shifted(), "x", -1f); } else { MoteMaker.ThrowText(intVec2.ToVector3Shifted(), "o", -1f); } } return(flag); } if (this.origin.ToIntVec3().DistanceToSquared(intVec2) > 16f) { Vector3 vector = lastExactPos; Vector3 v = newExactPos - lastExactPos; Vector3 b = v.normalized * 0.2f; int num = (int)(v.MagnitudeHorizontal() / 0.2f); ProjectileCP.checkedCells.Clear(); int num2 = 0; while (true) { vector += b; IntVec3 intVec3 = vector.ToIntVec3(); if (!ProjectileCP.checkedCells.Contains(intVec3)) { if (this.CheckForFreeIntercept(intVec3)) { break; } ProjectileCP.checkedCells.Add(intVec3); } if (DebugViewSettings.drawInterceptChecks) { MoteMaker.ThrowText(vector, "o", -1f); } num2++; if (num2 > num) { return(false); } if (intVec3 == intVec2) { return(false); } } if (DebugViewSettings.drawInterceptChecks) { MoteMaker.ThrowText(vector, "x", -1f); } return(true); } return(false); }
public new void PawnRotatorTick() { if (pawn.Destroyed) { return; } if (pawn.pather.Moving) { if (pawn.pather.curPath == null || pawn.pather.curPath.NodesLeftCount < 1) { return; } FaceAdjacentCell(this, pawn.pather.nextCell); } else { Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid) { if (stance_Busy.focusTarg.HasThing) { Face(stance_Busy.focusTarg.Thing.DrawPos); } else { FaceCell(stance_Busy.focusTarg.Cell); } return; } if (pawn.jobs.curJob != null) { LocalTargetInfo target = pawn.CurJob.GetTarget(pawn.jobs.curDriver.rotateToFace); if (target.HasThing) { bool flag = false; IntVec3 c = default(IntVec3); CellRect cellRect = target.Thing.OccupiedRect(); for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { if (pawn.Position == new IntVec3(j, 0, i)) { Face(target.Thing.DrawPos); return; } } } for (int k = cellRect.minZ; k <= cellRect.maxZ; k++) { for (int l = cellRect.minX; l <= cellRect.maxX; l++) { IntVec3 intVec = new IntVec3(l, 0, k); if (intVec.AdjacentToCardinal(pawn.Position)) { FaceAdjacentCell(this, intVec); return; } if (intVec.AdjacentTo8Way(pawn.Position)) { flag = true; c = intVec; } } } if (flag) { if (DebugViewSettings.drawPawnRotatorTarget) { pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.6f, "jbthing"); GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), c.ToVector3Shifted()); } FaceAdjacentCell(this, c); return; } } else if (pawn.Position.AdjacentTo8Way(target.Cell)) { if (DebugViewSettings.drawPawnRotatorTarget) { pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.2f, "jbloc"); GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), target.Cell.ToVector3Shifted()); } FaceAdjacentCell(this, target.Cell); return; } } } }