예제 #1
0
        private clsResult ValidateMap_UnitPositions()
        {
            clsStructureType.enumStructureType structureType;
            clsMap.clsUnit current;
            IEnumerator enumerator;
            IEnumerator enumerator2;
            IEnumerator enumerator3;
            clsResult result = new clsResult("Validate unit positions");
            bool[,] flagArray = new bool[(this.Map.Terrain.TileSize.X - 1) + 1, (this.Map.Terrain.TileSize.Y - 1) + 1];
            clsStructureType[,] typeArray2 = new clsStructureType[(this.Map.Terrain.TileSize.X - 1) + 1, (this.Map.Terrain.TileSize.Y - 1) + 1];
            clsFeatureType[,] typeArray = new clsFeatureType[(this.Map.Terrain.TileSize.X - 1) + 1, (this.Map.Terrain.TileSize.Y - 1) + 1];
            clsMap.clsUnitGroup[,] groupArray = new clsMap.clsUnitGroup[(this.Map.Terrain.TileSize.X - 1) + 1, (this.Map.Terrain.TileSize.Y - 1) + 1];
            bool[] flagArray2 = new bool[(this.Map.Units.Count - 1) + 1];
            try
            {
                enumerator = this.Map.Units.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    current = (clsMap.clsUnit) enumerator.Current;
                    if (current.Type.Type == clsUnitType.enumType.PlayerStructure)
                    {
                        clsStructureType type = (clsStructureType) current.Type;
                        structureType = type.StructureType;
                        flagArray2[current.MapLink.ArrayPosition] = type.IsModule() | (structureType == clsStructureType.enumStructureType.ResourceExtractor);
                    }
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            try
            {
                enumerator2 = this.Map.Units.GetEnumerator();
                while (enumerator2.MoveNext())
                {
                    current = (clsMap.clsUnit) enumerator2.Current;
                    if (!flagArray2[current.MapLink.ArrayPosition])
                    {
                        modMath.sXY_int _int2;
                        modMath.sXY_int _int4;
                        modMath.sXY_int footprint = current.Type.get_GetFootprintSelected(current.Rotation);
                        this.Map.GetFootprintTileRange(current.Pos.Horizontal, footprint, ref _int4, ref _int2);
                        if ((((_int4.X < 0) | (_int2.X >= this.Map.Terrain.TileSize.X)) | (_int4.Y < 0)) | (_int2.Y >= this.Map.Terrain.TileSize.Y))
                        {
                            clsResultProblemGoto<clsResultItemPosGoto> item = modResults.CreateResultProblemGotoForObject(current);
                            item.Text = "Unit off map at position " + current.GetPosText() + ".";
                            result.ItemAdd(item);
                        }
                        else
                        {
                            int y = _int2.Y;
                            for (int i = _int4.Y; i <= y; i++)
                            {
                                int x = _int2.X;
                                for (int j = _int4.X; j <= x; j++)
                                {
                                    if (flagArray[j, i])
                                    {
                                        clsResultProblemGoto<clsResultItemPosGoto> goto2 = modResults.CreateResultProblemGotoForObject(current);
                                        goto2.Text = "Bad unit overlap on tile " + Conversions.ToString(j) + ", " + Conversions.ToString(i) + ".";
                                        result.ItemAdd(goto2);
                                    }
                                    else
                                    {
                                        flagArray[j, i] = true;
                                        if (current.Type.Type == clsUnitType.enumType.PlayerStructure)
                                        {
                                            typeArray2[j, i] = (clsStructureType) current.Type;
                                        }
                                        else if (current.Type.Type == clsUnitType.enumType.Feature)
                                        {
                                            typeArray[j, i] = (clsFeatureType) current.Type;
                                        }
                                        groupArray[j, i] = current.UnitGroup;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                if (enumerator2 is IDisposable)
                {
                    (enumerator2 as IDisposable).Dispose();
                }
            }
            try
            {
                enumerator3 = this.Map.Units.GetEnumerator();
                while (enumerator3.MoveNext())
                {
                    modMath.sXY_int _int;
                    bool flag;
                    current = (clsMap.clsUnit) enumerator3.Current;
                    if (!flagArray2[current.MapLink.ArrayPosition])
                    {
                        continue;
                    }
                    structureType = ((clsStructureType) current.Type).StructureType;
                    _int.X = (int) Math.Round(((double) (((double) current.Pos.Horizontal.X) / 128.0)));
                    _int.Y = (int) Math.Round(((double) (((double) current.Pos.Horizontal.Y) / 128.0)));
                    if ((((_int.X < 0) | (_int.X >= this.Map.Terrain.TileSize.X)) | (_int.Y < 0)) | (_int.Y >= this.Map.Terrain.TileSize.Y))
                    {
                        clsResultProblemGoto<clsResultItemPosGoto> goto3 = modResults.CreateResultProblemGotoForObject(current);
                        goto3.Text = "Module off map at position " + current.GetPosText() + ".";
                        result.ItemAdd(goto3);
                        continue;
                    }
                    if (typeArray2[_int.X, _int.Y] != null)
                    {
                        if (groupArray[_int.X, _int.Y] == current.UnitGroup)
                        {
                            switch (structureType)
                            {
                                case clsStructureType.enumStructureType.FactoryModule:
                                    if ((typeArray2[_int.X, _int.Y].StructureType == clsStructureType.enumStructureType.Factory) | (typeArray2[_int.X, _int.Y].StructureType == clsStructureType.enumStructureType.VTOLFactory))
                                    {
                                        flag = true;
                                    }
                                    else
                                    {
                                        flag = false;
                                    }
                                    goto Label_0648;

                                case clsStructureType.enumStructureType.PowerModule:
                                    if (typeArray2[_int.X, _int.Y].StructureType == clsStructureType.enumStructureType.PowerGenerator)
                                    {
                                        flag = true;
                                    }
                                    else
                                    {
                                        flag = false;
                                    }
                                    goto Label_0648;

                                case clsStructureType.enumStructureType.ResearchModule:
                                    if (typeArray2[_int.X, _int.Y].StructureType == clsStructureType.enumStructureType.Research)
                                    {
                                        flag = true;
                                    }
                                    else
                                    {
                                        flag = false;
                                    }
                                    goto Label_0648;
                            }
                            flag = false;
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                    else if (typeArray[_int.X, _int.Y] != null)
                    {
                        if (structureType == clsStructureType.enumStructureType.ResourceExtractor)
                        {
                            if (typeArray[_int.X, _int.Y].FeatureType == clsFeatureType.enumFeatureType.OilResource)
                            {
                                flag = true;
                            }
                            else
                            {
                                flag = false;
                            }
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                    else if (structureType == clsStructureType.enumStructureType.ResourceExtractor)
                    {
                        flag = true;
                    }
                    else
                    {
                        flag = false;
                    }
                Label_0648:
                    if (!flag)
                    {
                        clsResultProblemGoto<clsResultItemPosGoto> goto4 = modResults.CreateResultProblemGotoForObject(current);
                        goto4.Text = "Bad module on tile " + Conversions.ToString(_int.X) + ", " + Conversions.ToString(_int.Y) + ".";
                        result.ItemAdd(goto4);
                    }
                }
            }
            finally
            {
                if (enumerator3 is IDisposable)
                {
                    (enumerator3 as IDisposable).Dispose();
                }
            }
            return result;
        }
예제 #2
0
 private clsResult ValidateMap_Multiplayer(int PlayerCount, bool IsXPlayerFormat)
 {
     IEnumerator enumerator;
     clsResult result = new clsResult("Validate for multiplayer");
     if ((PlayerCount < 2) | (PlayerCount > 10))
     {
         result.ProblemAdd("Unable to evaluate for multiplayer due to bad number of players.");
         return result;
     }
     int[] numArray2 = new int[10];
     int[] numArray = new int[10];
     int[] numArray3 = new int[10];
     int num = 0;
     int num3 = 0;
     int num2 = Math.Max(PlayerCount, 7);
     try
     {
         enumerator = this.Map.Units.GetEnumerator();
         while (enumerator.MoveNext())
         {
             clsMap.clsUnit current = (clsMap.clsUnit) enumerator.Current;
             if (current.UnitGroup != this.Map.ScavengerUnitGroup)
             {
                 int[] numArray4;
                 int num5;
                 if (current.Type.Type == clsUnitType.enumType.PlayerDroid)
                 {
                     clsDroidDesign design = (clsDroidDesign) current.Type;
                     if (((((design.Body != null) & (design.Propulsion != null)) & (design.Turret1 != null)) & (design.TurretCount == 1)) && (design.Turret1.TurretType == clsTurret.enumTurretType.Construct))
                     {
                         numArray4 = numArray3;
                         num5 = current.UnitGroup.WZ_StartPos;
                         numArray4[num5]++;
                         if (design.IsTemplate)
                         {
                             numArray4 = numArray;
                             num5 = current.UnitGroup.WZ_StartPos;
                             numArray4[num5]++;
                         }
                     }
                 }
                 else if (current.Type.Type == clsUnitType.enumType.PlayerStructure)
                 {
                     clsStructureType type = (clsStructureType) current.Type;
                     if (type.Code == "A0CommandCentre")
                     {
                         numArray4 = numArray2;
                         num5 = current.UnitGroup.WZ_StartPos;
                         numArray4[num5]++;
                     }
                 }
             }
             if (current.Type.Type != clsUnitType.enumType.Feature)
             {
                 if ((current.UnitGroup.WZ_StartPos == num2) | (current.UnitGroup == this.Map.ScavengerUnitGroup))
                 {
                     num++;
                 }
                 else if ((current.UnitGroup.WZ_StartPos >= PlayerCount) && (num3 < 0x20))
                 {
                     num3++;
                     clsResultProblemGoto<clsResultItemPosGoto> item = modResults.CreateResultProblemGotoForObject(current);
                     item.Text = "An unused player (" + Conversions.ToString(current.UnitGroup.WZ_StartPos) + ") has a unit at " + current.GetPosText() + ".";
                     result.ItemAdd(item);
                 }
             }
         }
     }
     finally
     {
         if (enumerator is IDisposable)
         {
             (enumerator as IDisposable).Dispose();
         }
     }
     if (!((num2 <= 7) | IsXPlayerFormat) && (num > 0))
     {
         result.ProblemAdd("Scavengers are not supported on a map with this number of players without enabling X player support.");
     }
     int num6 = PlayerCount - 1;
     for (int i = 0; i <= num6; i++)
     {
         if (numArray2[i] == 0)
         {
             result.ProblemAdd("There is no Command Centre for player " + Conversions.ToString(i) + ".");
         }
         if (numArray3[i] == 0)
         {
             result.ProblemAdd("There are no constructor units for player " + Conversions.ToString(i) + ".");
         }
         else if (numArray[i] == 0)
         {
             result.WarningAdd("All constructor units for player " + Conversions.ToString(i) + " will only exist in master.");
         }
     }
     return result;
 }