Beispiel #1
0
        private static void FinalizeGeneratedTile(List <int> generatedTileVerts)
        {
            if ((generatedTileVerts.Count != 5 && generatedTileVerts.Count != 6) || generatedTileVerts.Count > 6)
            {
                Log.Error("Planet shape generation internal error: generated a tile with " + generatedTileVerts.Count + " vertices. Only 5 and 6 are allowed.");
                return;
            }
            if (PlanetShapeGenerator.ShouldDiscardGeneratedTile(generatedTileVerts))
            {
                return;
            }
            int count = PlanetShapeGenerator.tileIDToFinalVerts_offsets.Count;

            PlanetShapeGenerator.tileIDToFinalVerts_offsets.Add(PlanetShapeGenerator.finalVerts.Count);
            int i      = 0;
            int count2 = generatedTileVerts.Count;

            while (i < count2)
            {
                int index = generatedTileVerts[i];
                PlanetShapeGenerator.finalVerts.Add(PlanetShapeGenerator.verts[index]);
                PlanetShapeGenerator.vertToTileIDs_values[PlanetShapeGenerator.vertToTileIDs_values.IndexOf(-1, PlanetShapeGenerator.vertToTileIDs_offsets[index])] = count;
                i++;
            }
            PackedListOfLists.AddList <int>(PlanetShapeGenerator.tileIDToVerts_offsets, PlanetShapeGenerator.tileIDToVerts_values, generatedTileVerts);
        }
Beispiel #2
0
        private static void CalculateTileNeighbors()
        {
            List <int> list = new List <int>();
            int        i    = 0;

            for (int count = tileIDToVerts_offsets.Count; i < count; i++)
            {
                tmpNeighborsToAdd.Clear();
                PackedListOfLists.GetList(tileIDToVerts_offsets, tileIDToVerts_values, i, tmpVerts);
                int j = 0;
                for (int count2 = tmpVerts.Count; j < count2; j++)
                {
                    PackedListOfLists.GetList(vertToTileIDs_offsets, vertToTileIDs_values, tmpVerts[j], tmpTileIDs);
                    PackedListOfLists.GetList(vertToTileIDs_offsets, vertToTileIDs_values, tmpVerts[(j + 1) % tmpVerts.Count], list);
                    int k = 0;
                    for (int count3 = tmpTileIDs.Count; k < count3; k++)
                    {
                        int num = tmpTileIDs[k];
                        if (num != i && num != -1 && list.Contains(num))
                        {
                            tmpNeighborsToAdd.Add(num);
                        }
                    }
                }
                PackedListOfLists.AddList(tileIDToNeighbors_offsets, tileIDToNeighbors_values, tmpNeighborsToAdd);
            }
        }
Beispiel #3
0
        private static void CalculateTileNeighbors()
        {
            List <int> list  = new List <int>();
            int        i     = 0;
            int        count = PlanetShapeGenerator.tileIDToVerts_offsets.Count;

            for (; i < count; i++)
            {
                PlanetShapeGenerator.tmpNeighborsToAdd.Clear();
                PackedListOfLists.GetList(PlanetShapeGenerator.tileIDToVerts_offsets, PlanetShapeGenerator.tileIDToVerts_values, i, PlanetShapeGenerator.tmpVerts);
                int j      = 0;
                int count2 = PlanetShapeGenerator.tmpVerts.Count;
                for (; j < count2; j++)
                {
                    PackedListOfLists.GetList(PlanetShapeGenerator.vertToTileIDs_offsets, PlanetShapeGenerator.vertToTileIDs_values, PlanetShapeGenerator.tmpVerts[j], PlanetShapeGenerator.tmpTileIDs);
                    PackedListOfLists.GetList(PlanetShapeGenerator.vertToTileIDs_offsets, PlanetShapeGenerator.vertToTileIDs_values, PlanetShapeGenerator.tmpVerts[(j + 1) % PlanetShapeGenerator.tmpVerts.Count], list);
                    int k      = 0;
                    int count3 = PlanetShapeGenerator.tmpTileIDs.Count;
                    for (; k < count3; k++)
                    {
                        int num = PlanetShapeGenerator.tmpTileIDs[k];
                        if (num != i && num != -1 && list.Contains(num))
                        {
                            PlanetShapeGenerator.tmpNeighborsToAdd.Add(num);
                        }
                    }
                }
                PackedListOfLists.AddList(PlanetShapeGenerator.tileIDToNeighbors_offsets, PlanetShapeGenerator.tileIDToNeighbors_values, PlanetShapeGenerator.tmpNeighborsToAdd);
            }
        }
Beispiel #4
0
 private static void FinalizeGeneratedTile(List <int> generatedTileVerts)
 {
     if ((generatedTileVerts.Count != 5 && generatedTileVerts.Count != 6) || generatedTileVerts.Count > 6)
     {
         Log.Error("Planet shape generation internal error: generated a tile with " + generatedTileVerts.Count + " vertices. Only 5 and 6 are allowed.");
     }
     else if (!ShouldDiscardGeneratedTile(generatedTileVerts))
     {
         int count = tileIDToFinalVerts_offsets.Count;
         tileIDToFinalVerts_offsets.Add(finalVerts.Count);
         int i = 0;
         for (int count2 = generatedTileVerts.Count; i < count2; i++)
         {
             int index = generatedTileVerts[i];
             finalVerts.Add(verts[index]);
             vertToTileIDs_values[vertToTileIDs_values.IndexOf(-1, vertToTileIDs_offsets[index])] = count;
         }
         PackedListOfLists.AddList(tileIDToVerts_offsets, tileIDToVerts_values, generatedTileVerts);
     }
 }