Ejemplo n.º 1
0
        public static Vector3 WarObjectCollisionPosOffsetFor(WarObject warObject)
        {
            if (!warObject.Spawned)
            {
                return(Vector3.zero);
            }
            bool  flag = warObject.Spawned && warObject.pather.Moving;
            float d    = 0.15f * Verse.Find.WorldGrid.averageTileSize;

            if (!flag || warObject.pather.nextTile == warObject.pather.Destination)
            {
                int num                        = (!flag) ? warObject.Tile : warObject.pather.nextTile;
                int warObjectsCount            = 0;
                int warObjectsWithLowerIdCount = 0;
                GetWarObjectsStandingAtOrAboutToStandAt(num, out warObjectsCount, out warObjectsWithLowerIdCount, warObject);
                if (warObjectsCount == 0)
                {
                    return(Vector3.zero);
                }
                return(WorldRendererUtility.ProjectOnQuadTangentialToPlanet(Verse.Find.WorldGrid.GetTileCenter(num), GenGeo.RegularPolygonVertexPosition(warObjectsCount, warObjectsWithLowerIdCount) * d));
            }
            if (DrawPosCollides(warObject))
            {
                Rand.PushState();
                Rand.Seed = warObject.ID;
                float f = Rand.Range(0f, 360f);
                Rand.PopState();
                Vector2 point = new Vector2(Mathf.Cos(f), Mathf.Sin(f)) * d;
                return(WorldRendererUtility.ProjectOnQuadTangentialToPlanet(PatherTweenedPosRoot(warObject), point));
            }
            return(Vector3.zero);
        }
        public static Vector3 CaravanCollisionPosOffsetFor(VehicleCaravan caravan)
        {
            if (!caravan.Spawned)
            {
                return(Vector3.zero);
            }
            bool  flag = caravan.Spawned && caravan.vPather.Moving;
            float d    = BaseRadius * Find.WorldGrid.averageTileSize;

            if (!flag || caravan.vPather.nextTile == caravan.vPather.Destination)
            {
                int num;
                if (flag)
                {
                    num = caravan.vPather.nextTile;
                }
                else
                {
                    num = caravan.Tile;
                }
                GetCaravansStandingAtOrAboutToStandAt(num, out int num2, out int vertexIndex, caravan);
                if (num2 == 0)
                {
                    return(Vector3.zero);
                }
                return(WorldRendererUtility.ProjectOnQuadTangentialToPlanet(Find.WorldGrid.GetTileCenter(num), GenGeo.RegularPolygonVertexPosition(num2, vertexIndex) * d));
            }
            else
            {
                if (DrawPosCollides(caravan))
                {
                    Rand.PushState();
                    Rand.Seed = caravan.ID;
                    float f = Rand.Range(0f, 360f);
                    Rand.PopState();
                    Vector2 point = new Vector2(Mathf.Cos(f), Mathf.Sin(f)) * d;
                    return(WorldRendererUtility.ProjectOnQuadTangentialToPlanet(PatherTweenedPosRoot(caravan), point));
                }
                return(Vector3.zero);
            }
        }