private static bool TryFindAdjustedCoverInCell(IntVec3 shooterLoc, IntVec3 targetLoc, IntVec3 adjCell, Map map, out CoverInfo result) { Thing cover = adjCell.GetCover(map); float num2; if (cover != null && !(shooterLoc == targetLoc)) { float angleFlat = (shooterLoc - targetLoc).AngleFlat; float angleFlat2 = (adjCell - targetLoc).AngleFlat; float num = GenGeo.AngleDifferenceBetween(angleFlat2, angleFlat); if (!targetLoc.AdjacentToCardinal(adjCell)) { num = (float)(num * 1.75); } num2 = cover.def.BaseBlockChance(); if (num < 15.0) { num2 = (float)(num2 * 1.0); goto IL_010b; } if (num < 27.0) { num2 = (float)(num2 * 0.800000011920929); goto IL_010b; } if (num < 40.0) { num2 = (float)(num2 * 0.60000002384185791); goto IL_010b; } if (num < 52.0) { num2 = (float)(num2 * 0.40000000596046448); goto IL_010b; } if (num < 65.0) { num2 = (float)(num2 * 0.20000000298023224); goto IL_010b; } result = CoverInfo.Invalid; return(false); } result = CoverInfo.Invalid; return(false); IL_010b: float lengthHorizontal = (shooterLoc - adjCell).LengthHorizontal; if (lengthHorizontal < 1.8999999761581421) { num2 = (float)(num2 * 0.33329999446868896); } else if (lengthHorizontal < 2.9000000953674316) { num2 = (float)(num2 * 0.66666001081466675); } result = new CoverInfo(cover, num2); return(true); }
private static bool TryFindAdjustedCoverInCell(IntVec3 shooterLoc, LocalTargetInfo target, IntVec3 adjCell, Map map, out CoverInfo result) { IntVec3 cell = target.Cell; Thing cover = adjCell.GetCover(map); bool result2; if (cover == null || cover == target.Thing || shooterLoc == cell) { result = CoverInfo.Invalid; result2 = false; } else { float angleFlat = (shooterLoc - cell).AngleFlat; float angleFlat2 = (adjCell - cell).AngleFlat; float num = GenGeo.AngleDifferenceBetween(angleFlat2, angleFlat); if (!cell.AdjacentToCardinal(adjCell)) { num *= 1.75f; } float num2 = cover.def.BaseBlockChance(); if (num < 15f) { num2 *= 1f; } else if (num < 27f) { num2 *= 0.8f; } else if (num < 40f) { num2 *= 0.6f; } else if (num < 52f) { num2 *= 0.4f; } else { if (num >= 65f) { result = CoverInfo.Invalid; return(false); } num2 *= 0.2f; } float lengthHorizontal = (shooterLoc - adjCell).LengthHorizontal; if (lengthHorizontal < 1.9f) { num2 *= 0.3333f; } else if (lengthHorizontal < 2.9f) { num2 *= 0.66666f; } result = new CoverInfo(cover, num2); result2 = true; } return(result2); }
public static Vector2 RegularPolygonVertexPosition(int polygonVertices, int vertexIndex) { Vector2 result; if (vertexIndex < 0 || vertexIndex >= polygonVertices) { Log.Warning(string.Concat(new object[] { "Vertex index out of bounds. polygonVertices=", polygonVertices, " vertexIndex=", vertexIndex }), false); result = Vector2.zero; } else if (polygonVertices == 1) { result = Vector2.zero; } else { result = GenGeo.CalculatePolygonVertexPosition(polygonVertices, vertexIndex); } return(result); }
public static Vector3 PawnCollisionPosOffsetFor(Pawn pawn) { if (pawn.GetPosture() != PawnPosture.Standing) { return(Vector3.zero); } bool flag = pawn.Spawned && pawn.pather.MovingNow; if (!flag || pawn.pather.nextCell == pawn.pather.Destination.Cell) { if (!flag && pawn.Drawer.leaner.ShouldLean()) { return(Vector3.zero); } IntVec3 at; if (flag) { at = pawn.pather.nextCell; } else { at = pawn.Position; } int polygonVertices; int vertexIndex; bool flag2; PawnCollisionTweenerUtility.GetPawnsStandingAtOrAboutToStandAt(at, pawn.Map, out polygonVertices, out vertexIndex, out flag2, pawn); if (!flag2) { return(Vector3.zero); } return(GenGeo.RegularPolygonVertexPositionVec3(polygonVertices, vertexIndex) * 0.32f); } else { IntVec3 nextCell = pawn.pather.nextCell; if (PawnCollisionTweenerUtility.CanGoDirectlyToNextCell(pawn)) { return(Vector3.zero); } int num = pawn.thingIDNumber % 2; if (nextCell.x != pawn.Position.x) { if (num == 0) { return(new Vector3(0f, 0f, 0.32f)); } return(new Vector3(0f, 0f, -0.32f)); } else { if (num == 0) { return(new Vector3(0.32f, 0f, 0f)); } return(new Vector3(-0.32f, 0f, 0f)); } } }
public static Vector2 RegularPolygonVertexPosition(int polygonVertices, int vertexIndex) { if (vertexIndex >= 0 && vertexIndex < polygonVertices) { if (polygonVertices == 1) { return(Vector2.zero); } return(GenGeo.CalculatePolygonVertexPosition(polygonVertices, vertexIndex)); } Log.Warning("Vertex index out of bounds. polygonVertices=" + polygonVertices + " vertexIndex=" + vertexIndex); return(Vector2.zero); }
public static Vector3 PawnCollisionPosOffsetFor(Pawn pawn) { if (pawn.GetPosture() != 0) { return(Vector3.zero); } bool flag = pawn.Spawned && pawn.pather.MovingNow; if (!flag || pawn.pather.nextCell == pawn.pather.Destination.Cell) { if (!flag && pawn.Drawer.leaner.ShouldLean()) { return(Vector3.zero); } IntVec3 at = (!flag) ? pawn.Position : pawn.pather.nextCell; GetPawnsStandingAtOrAboutToStandAt(at, pawn.Map, out int pawnsCount, out int pawnsWithLowerIdCount, out bool forPawnFound, pawn); if (!forPawnFound) { return(Vector3.zero); } return(GenGeo.RegularPolygonVertexPositionVec3(pawnsCount, pawnsWithLowerIdCount) * 0.32f); } IntVec3 nextCell = pawn.pather.nextCell; if (CanGoDirectlyToNextCell(pawn)) { return(Vector3.zero); } int num = pawn.thingIDNumber % 2; int x = nextCell.x; IntVec3 position = pawn.Position; if (x != position.x) { if (num == 0) { return(new Vector3(0f, 0f, 0.32f)); } return(new Vector3(0f, 0f, -0.32f)); } if (num == 0) { return(new Vector3(0.32f, 0f, 0f)); } return(new Vector3(-0.32f, 0f, 0f)); }
public static Vector2 RegularPolygonVertexPosition(int polygonVertices, int vertexIndex) { if (vertexIndex < 0 || vertexIndex >= polygonVertices) { Log.Warning(string.Concat(new object[] { "Vertex index out of bounds. polygonVertices=", polygonVertices, " vertexIndex=", vertexIndex })); return(Vector2.zero); } if (polygonVertices == 1) { return(Vector2.zero); } return(GenGeo.CalculatePolygonVertexPosition(polygonVertices, vertexIndex)); }
public static Vector3 RegularPolygonVertexPositionVec3(int polygonVertices, int vertexIndex) { Vector2 vector = GenGeo.RegularPolygonVertexPosition(polygonVertices, vertexIndex); return(new Vector3(vector.x, 0f, vector.y)); }