コード例 #1
0
        public static Vector3 CaravanCollisionPosOffsetFor(Caravan caravan)
        {
            if (!caravan.Spawned)
            {
                return(Vector3.zero);
            }
            bool  flag = caravan.Spawned && caravan.pather.Moving;
            float d    = (float)(0.15000000596046448 * Find.WorldGrid.averageTileSize);

            if (flag && caravan.pather.nextTile != caravan.pather.Destination)
            {
                if (CaravanTweenerUtility.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(CaravanTweenerUtility.PatherTweenedPosRoot(caravan), point));
                }
                return(Vector3.zero);
            }
            int num         = (!flag) ? caravan.Tile : caravan.pather.nextTile;
            int num2        = 0;
            int vertexIndex = 0;

            CaravanTweenerUtility.GetCaravansStandingAtOrAboutToStandAt(num, out num2, out vertexIndex, caravan);
            if (num2 == 0)
            {
                return(Vector3.zero);
            }
            return(WorldRendererUtility.ProjectOnQuadTangentialToPlanet(Find.WorldGrid.GetTileCenter(num), GenGeo.RegularPolygonVertexPosition(num2, vertexIndex) * d));
        }
コード例 #2
0
        private static bool DrawPosCollides(Caravan caravan)
        {
            Vector3        a        = CaravanTweenerUtility.PatherTweenedPosRoot(caravan);
            float          num      = (float)(Find.WorldGrid.averageTileSize * 0.20000000298023224);
            List <Caravan> caravans = Find.WorldObjects.Caravans;

            for (int i = 0; i < caravans.Count; i++)
            {
                Caravan caravan2 = caravans[i];
                if (caravan2 != caravan && Vector3.Distance(a, CaravanTweenerUtility.PatherTweenedPosRoot(caravan2)) < num)
                {
                    return(true);
                }
            }
            return(false);
        }