예제 #1
0
        public static void GenerateNonOverlappingCoordinates()
        {
            foreach (ResearchProjectDef current in DefDatabase <ResearchProjectDef> .AllDefsListForReading)
            {
                current.x = current.researchViewX;
                current.y = current.researchViewY;
            }
            int num = 0;

            while (true)
            {
                bool flag = false;
                foreach (ResearchProjectDef current2 in DefDatabase <ResearchProjectDef> .AllDefsListForReading)
                {
                    foreach (ResearchProjectDef current3 in DefDatabase <ResearchProjectDef> .AllDefsListForReading)
                    {
                        if (current2 != current3 && current2.tab == current3.tab)
                        {
                            bool flag2 = Mathf.Abs(current2.x - current3.x) < 0.5f;
                            bool flag3 = Mathf.Abs(current2.y - current3.y) < 0.25f;
                            if (flag2 && flag3)
                            {
                                flag = true;
                                if (current2.x <= current3.x)
                                {
                                    current2.x -= 0.1f;
                                    current3.x += 0.1f;
                                }
                                else
                                {
                                    current2.x += 0.1f;
                                    current3.x -= 0.1f;
                                }
                                if (current2.y <= current3.y)
                                {
                                    current2.y -= 0.1f;
                                    current3.y += 0.1f;
                                }
                                else
                                {
                                    current2.y += 0.1f;
                                    current3.y -= 0.1f;
                                }
                                current2.x += 0.001f;
                                current2.y += 0.001f;
                                current3.x -= 0.001f;
                                current3.y -= 0.001f;
                                ResearchProjectDef.ClampInCoordinateLimits(current2);
                                ResearchProjectDef.ClampInCoordinateLimits(current3);
                            }
                        }
                    }
                }
                if (!flag)
                {
                    break;
                }
                num++;
                if (num > 200)
                {
                    goto Block_4;
                }
            }
            return;

Block_4:
            Log.Error("Couldn't relax research project coordinates apart after " + 200 + " passes.", false);
        }
예제 #2
0
        public static void GenerateNonOverlappingCoordinates()
        {
            foreach (ResearchProjectDef item in DefDatabase <ResearchProjectDef> .AllDefsListForReading)
            {
                item.x = item.researchViewX;
                item.y = item.researchViewY;
            }
            int num = 0;

            while (true)
            {
                bool flag = false;
                foreach (ResearchProjectDef item2 in DefDatabase <ResearchProjectDef> .AllDefsListForReading)
                {
                    foreach (ResearchProjectDef item3 in DefDatabase <ResearchProjectDef> .AllDefsListForReading)
                    {
                        if (item2 != item3 && item2.tab == item3.tab)
                        {
                            bool flag2 = Mathf.Abs(item2.x - item3.x) < 0.5;
                            bool flag3 = Mathf.Abs(item2.y - item3.y) < 0.25;
                            if (flag2 && flag3)
                            {
                                flag = true;
                                if (item2.x <= item3.x)
                                {
                                    item2.x -= 0.1f;
                                    item3.x += 0.1f;
                                }
                                else
                                {
                                    item2.x += 0.1f;
                                    item3.x -= 0.1f;
                                }
                                if (item2.y <= item3.y)
                                {
                                    item2.y -= 0.1f;
                                    item3.y += 0.1f;
                                }
                                else
                                {
                                    item2.y += 0.1f;
                                    item3.y -= 0.1f;
                                }
                                item2.x += 0.001f;
                                item2.y += 0.001f;
                                item3.x -= 0.001f;
                                item3.y -= 0.001f;
                                ResearchProjectDef.ClampInCoordinateLimits(item2);
                                ResearchProjectDef.ClampInCoordinateLimits(item3);
                            }
                        }
                    }
                }
                if (flag)
                {
                    num++;
                    if (num > 200)
                    {
                        break;
                    }
                    continue;
                }
                return;
            }
            Log.Error("Couldn't relax research project coordinates apart after " + 200 + " passes.");
        }