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));
                }
            }
        }
        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 c = iterator.Current;
                if (c.InBounds(pawn.Map))
                {
                    List <Thing> thingList = c.GetThingList(pawn.Map);
                    for (int i = 0; i < thingList.Count; i++)
                    {
                        Pawn pawn2 = thingList[i] as Pawn;
                        if (pawn2 != null && pawn2 != pawn)
                        {
                            if (pawn2.GetPosture() == PawnPosture.Standing)
                            {
                                if (pawn2.pather.MovingNow)
                                {
                                    if ((pawn2.Position == nextCell && PawnCollisionTweenerUtility.WillBeFasterOnNextCell(pawn, pawn2)) || pawn2.pather.nextCell == nextCell || pawn2.Position == pawn.Position || (pawn2.pather.nextCell == pawn.Position && PawnCollisionTweenerUtility.WillBeFasterOnNextCell(pawn2, pawn)))
                                    {
                                        if (pawn2.thingIDNumber < pawn.thingIDNumber)
                                        {
                                            return(false);
                                        }
                                    }
                                }
                                else if (pawn2.Position == pawn.Position || pawn2.Position == nextCell)
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                }
                iterator.MoveNext();
            }
            return(true);
        }
예제 #3
0
        private Vector3 TweenedPosRoot()
        {
            if (!this.pawn.Spawned)
            {
                return(this.pawn.Position.ToVector3Shifted());
            }
            float num = this.MovedPercent();

            return(this.pawn.pather.nextCell.ToVector3Shifted() * num + this.pawn.Position.ToVector3Shifted() * (1f - num) + PawnCollisionTweenerUtility.PawnCollisionPosOffsetFor(this.pawn));
        }