Esempio n. 1
0
 public static void Generate()
 {
     if (BaseGen.working)
     {
         Log.Error("Cannot call Generate() while already generating. Nested calls are not allowed.");
     }
     else
     {
         BaseGen.working = true;
         try
         {
             if (BaseGen.symbolStack.Empty)
             {
                 Log.Warning("Symbol stack is empty.");
             }
             else if (BaseGen.globalSettings.map == null)
             {
                 Log.Error("Called BaseGen.Resolve() with null map.");
             }
             else
             {
                 int num  = BaseGen.symbolStack.Count - 1;
                 int num2 = 0;
                 while (true)
                 {
                     if (!BaseGen.symbolStack.Empty)
                     {
                         num2++;
                         if (num2 <= 100000)
                         {
                             Pair <string, ResolveParams> toResolve = BaseGen.symbolStack.Pop();
                             if (BaseGen.symbolStack.Count == num)
                             {
                                 GlobalSettings obj    = BaseGen.globalSettings;
                                 ResolveParams  second = toResolve.Second;
                                 obj.mainRect = second.rect;
                                 num--;
                             }
                             try
                             {
                                 BaseGen.Resolve(toResolve);
                             }
                             catch (Exception ex)
                             {
                                 Log.Error("Error while resolving symbol \"" + toResolve.First + "\" with params=" + toResolve.Second + "\n\nException: " + ex);
                             }
                             continue;
                         }
                         break;
                     }
                     return;
                 }
                 Log.Error("Error in BaseGen: Too many iterations. Infinite loop?");
             }
         }
         catch (Exception arg)
         {
             Log.Error("Error in BaseGen: " + arg);
         }
         finally
         {
             BaseGen.working = false;
             BaseGen.symbolStack.Clear();
             BaseGen.globalSettings.Clear();
         }
     }
 }