예제 #1
0
        public override void Init()
        {
            base.Init();
            Data.spectateRect = CalculateSpectateRect();
            SpectateRectSide allowedSides = SpectateRectSide.All;

            if (Data.spectateRect.Width > Data.spectateRect.Height)
            {
                allowedSides = SpectateRectSide.Vertical;
            }
            else if (Data.spectateRect.Height > Data.spectateRect.Width)
            {
                allowedSides = SpectateRectSide.Horizontal;
            }
            Data.spectateRectAllowedSides = SpectatorCellFinder.FindSingleBestSide(Data.spectateRect, base.Map, allowedSides);
        }
예제 #2
0
        public static void DebugFlashPotentialSpectatorCells(CellRect spectateRect, Map map, SpectateRectSide allowedSides = SpectateRectSide.All, int margin = 1)
        {
            List <IntVec3> list = new List <IntVec3>();
            int            num  = 50;

            for (int i = 0; i < num; i++)
            {
                IntVec3 intVec;
                if (!SpectatorCellFinder.TryFindSpectatorCellFor(null, spectateRect, map, out intVec, allowedSides, margin, list))
                {
                    break;
                }
                list.Add(intVec);
                float    a   = Mathf.Lerp(1f, 0.08f, (float)i / (float)num);
                Material mat = SolidColorMaterials.SimpleSolidColorMaterial(new Color(0f, 0.8f, 0f, a), false);
                map.debugDrawer.FlashCell(intVec, mat, (i + 1).ToString(), 50);
            }
            SpectateRectSide spectateRectSide = SpectatorCellFinder.FindSingleBestSide(spectateRect, map, allowedSides, margin);
            IntVec3          centerCell       = spectateRect.CenterCell;

            switch (spectateRectSide)
            {
            case SpectateRectSide.Up:
                centerCell.z += spectateRect.Height / 2 + 10;
                break;

            case SpectateRectSide.Right:
                centerCell.x += spectateRect.Width / 2 + 10;
                break;

            case SpectateRectSide.Down:
                centerCell.z -= spectateRect.Height / 2 + 10;
                break;

            case SpectateRectSide.Left:
                centerCell.x -= spectateRect.Width / 2 + 10;
                break;
            }
            map.debugDrawer.FlashLine(spectateRect.CenterCell, centerCell, 50);
        }