Anonymous Anonymous - 4 months ago
1939 0

No description

C#

FNIScommon1

using GenerateFNISforUsers.My;
using IWshRuntimeLibrary;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using Microsoft.VisualBasic.MyServices;
using Microsoft.Win32;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows.Forms;

namespace GenerateFNISforUsers
{
  [StandardModule]
  internal sealed class FNIScommon1
  {
    public class FNIScommon
    {
      public static int DebugIndent = 0;
      public static Process hkxcmdProcess = new Process();
      public static string[] AnimType = new string[10001];
      public static ulong[] AnimOption = new ulong[10001];
      public static int[] AnimBlend = new int[10001];
      public static string[] AnimEvent = new string[10001];
      public static int[] AnimBehavior = new int[10001];
      public static int[] AnimAE = new int[10001];
      public static int[] AnimNumAE = new int[10001];
      public static int[] AnimAEEvent = new int[2001];
      public static string[] AnimAETime = new string[2001];
      public static int[] AnimAV = new int[10001];
      public static int[] AnimNumAV = new int[10001];
      public static int[] AnimAVid = new int[20001];
      public static bool[] AnimAVinvers = new bool[20001];
      public static string[,] AnimObject = new string[4, 1001];
      public static int[] AnimSfirst = new int[4001];
      public static int[] AnimFufirst = new int[2001];
      public static int[] AnimChfirst = new int[1001];
      public static string[] AnimFile = new string[10001];
      public static int[] AnimMod = new int[10001];
      public static bool[] AnimKoption = new bool[10001];
      public static string[] MyMod = new string[201];
      public static string[] MyModVers = new string[201];
      public static string[] BehaviorTemplate = new string[601];
      public static int[] Anz_AO = new int[17];
      public static int[] FurnitureID = new int[4001];
      public static string[] PatchID = new string[21];
      public static bool[] isPatch = new bool[21];
      public static string[] PatchText = new string[21];
      public static string[] PatchCheckFile = new string[21];
      public static int[] PatchAddAnims = new int[21];
      public static uint[] PatchReqBehaviors = new uint[21];
      public static bool isSKELETON = false;
      public static string[] SkeletonID = new string[21];
      public static int[] nBonesSkeleton = new int[21];
      public static int[] PatchSkeletonSize = new int[21];
      public static string[] tUIu = new string[34];
      public static string[] tUIm = new string[34];
      public static string[] tMsgu = new string[34];
      public static string[] tMsgm = new string[34];
      public static string[] tWarn = new string[34];
      public static string[] tErr = new string[34];
      public static string[] tPatch = new string[34];
      public static int[] AnzAnimVars = new int[17];
      public static string[,] AnimVarName = new string[101, 17];
      public static string[,] AnimVarType = new string[101, 17];
      public static string[,] AnimVarValue = new string[101, 17];
      public static string[] ArrDefaultF = new string[16001];
      public static string[] ArrDefaultM = new string[16001];
      public static bool isPCEA2 = false;
      public static bool isPCEA = false;
      public static bool isGENDER = false;
      public static bool isHKX_COMPAT = false;
      public static int[] SymAddrVal = new int[31];
      public static string[] SymAddr = new string[31];
      public static int[] firstAO = new int[10001];
      public static int[] nAO = new int[10001];
      public static int[] AOList = new int[10001];
      public static bool[] AOfirst = new bool[10001];
      public static string[] BlendList = new string[1001];
      public static int[] OptimizedIndex = new int[21];
      public static string[] BO_List = new string[101];
      public static int[] BO_DefaultAnims = new int[101];
      public static string AllAEfile = "..\\GenerateFNIS_for_Users\\AnimEvents.txt";
      public static bool AllAEread = false;
      public static string[] AllAEbehavior = new string[17];
      public static int[] AllAEfirst = new int[17];
      public static int[] AllAEnum = new int[17];
      public static int[] CustomAEnum = new int[17];
      public static string[,] CustomAE = new string[17, 1001];
      public static string AllAVfile = "..\\GenerateFNIS_for_Users\\AnimVars.txt";
      public static bool AllAVread = false;
      public static int[] AllAVfirst = new int[17];
      public static int[] AllAVnum = new int[17];
      public static string AllTemplatesFile = "..\\GenerateFNIS_for_Users\\FNIS_Templates.txt";
      public static FNIScommon1.FNIScommon.AllTemplatesEntry[] AllTemplates = new FNIScommon1.FNIScommon.AllTemplatesEntry[41];
      public static uint[] crc_tab32 = new uint[257];
      public static int[] MRD_BO_nAnims = new int[101];
      public static int[] MRD_BO_nMRD = new int[101];
      public static FNIScommon1.FNIScommon.PatchAFData[] PatchAF = new FNIScommon1.FNIScommon.PatchAFData[1001];
      public static int[] nPatchAF = new int[5];
      public const int MAXANIMALL = 10000;
      public static int SkyrimEdition;
      public static int DebugOutput;
      public static bool DebugDataRead;
      public const string DebugDataFile = "..\\GenerateFNIS_for_Users\\DebugData.txt";
      public static int InputLineDeb;
      public static int OutputLineDeb;
      public static int FromTemplate;
      public static int ToTemplate;
      public static int PreCache;
      public static short TestGeneration;
      public const int MAXANIM = 2000;
      public const int MAXMODS = 200;
      public const int MAXBLOCKLEN = 600;
      public const int MAXPATCHES = 20;
      public const int MAXANIMVARS = 100;
      public const string PathToMeshes = "..\\..\\meshes\\";
      public const string PathToActors = "..\\..\\meshes\\actors\\";
      public const string PathToCharacter = "..\\..\\meshes\\actors\\character\\";
      public const string PathToBehavior = "..\\..\\meshes\\actors\\character\\behaviors\\";
      public const string PathToMale = "..\\..\\meshes\\actors\\character\\characters\\";
      public const string PathToFemale = "..\\..\\meshes\\actors\\character\\characters female\\";
      public const string PathToAnimation = "..\\..\\meshes\\actors\\character\\animations\\";
      public const string PathToSkeletonF = "..\\..\\meshes\\actors\\character\\character assets female\\";
      public const string PathToSkeletonM = "..\\..\\meshes\\actors\\character\\character assets\\";
      public const string PathToTemplate = "templates\\";
      public const string PathToTempLog = "temporary_logs\\";
      public const string PathToFNISforUsers = "..\\GenerateFNIS_for_Users\\";
      public const string PathToLanguages = "..\\GenerateFNIS_for_Users\\languages\\";
      public const string PathToScripts = "..\\..\\scripts\\";
      public const string GFUDir = "\\data\\tools\\GenerateFNIS_for_Users";
      public const string FNISTemplateFile = "templates\\FNIS_Behavior_Template.txt";
      public const string DefaultMaleTemplateFile = "templates\\defaultmale_Template.txt";
      public const string DefaultFeMaleTemplateFile = "templates\\defaultfemale_Template.txt";
      public const string FNISUserLog = "temporary_logs\\GenerateFNIS_LogFile.txt";
      public const string DummyStartFile = "temporary_logs\\DummyStart.txt";
      public const string PatchFile = "PatchList.txt";
      public const string PatchFileSE = "PatchListSE.txt";
      public const string MyPatches = "MyPatches.txt";
      public const string CPCFileName = "CustomPreCacheFiles.txt";
      public const string FNISBehaviorName = "FNIS_*_Behavior.hkx";
      public const string DontAskFile = "DontAskAgainForLink.txt";
      public const string DontAskText = "This file prevents being asked again, if you want a link on your desktop.";
      public const string hkxcmd_Params32 = "convert -v:WIN32 \"*\" \"#\"";
      public const string hkxcmd_Params64 = "convert -v:AMD64 \"*\" \"#\"";
      public static string hkxcmd_Params;
      public const string hkxcmd_ParamsSkel = "convert -v:xml temporary_logs\\skeleton.hkx temporary_logs\\skeleton.xml";
      public const string hkxcmdFile = "hkxcmd.exe";
      public static string InstallDir;
      public static bool IsSteam;
      public static StreamWriter LogFile;
      public static StreamWriter BehaviorFile;
      public static int iAnimAEET;
      public static int iAnimAV;
      public static int iSline;
      public static string[] AnimFileAA;
      public static string AnimListFile;
      public static int AnzAnim;
      public static int AnzAnimChar;
      public static int TotalAnimations;
      public static int AnzMod;
      public static int AnzModChar;
      public static int Anz_b;
      public static int Anz_s;
      public static int Anz_sG;
      public static int Anz_fu;
      public static int Anz_fuG;
      public static int Anz_ofa;
      public static int Anz_aa;
      public static int Anz_pa;
      public static int Anz_km;
      public static int Anz_ch;
      public static int Anz_chG;
      public static int AE1_b;
      public static int AE1_c;
      public static int AE1_s;
      public static int AE1_sgf;
      public static int AE1_sgl;
      public static int AE1_fu;
      public static int AE1_fuG;
      public static int AE1_ofa;
      public static int AE1_aa;
      public static int AE1_pa;
      public static int AE1_km;
      public static int AE1_chG;
      public static int AE1_trigger;
      public static int AF1;
      public static string CurrentTemplate;
      public static int TemplateLine;
      public static int CurrentLine;
      public static int BlockStartInTemplate;
      public static int InputLine;
      public static int OutputLine;
      public static int RecIndex;
      public static string ErrString;
      public static int ErrInt;
      public static int WarningCount;
      public static int TotalWarnings;
      public static int RetCode;
      public static bool LogOpen;
      public static bool FullLog;
      public static TextBox Textbox;
      public static int PatchCount;
      public static int Patch_NumElement;
      public const string SkeletonName = "SKELETON";
      public const int SkeletonDefaultBones = 99;
      public static int SkeletonCount;
      public static int currBones;
      public const int TEXTPERCATEGORY = 33;
      public static int iArrDefaultF;
      public static int iArrDefaultM;
      public const string PCEA2Name = "PCEA2";
      public const string PCEAName = "PCEA";
      public static List<string> PCEAList;
      public const string GENDERname = "GENDER";
      public const string HKX_COMPATname = "HKX_COMPAT";
      public static string lastLanguage;
      public static int RecIncrement;
      public static int SymAddrInd;
      public static int nextAO;
      public static int lastBlend;
      public static int IsOptimizedBlock;
      public static int OptimizedCount;
      public static int MtBehaviorRI;
      public static int B0_masterRI;
      public static int MtBehaviorAA;
      public static int B0_masterAA;
      public static int FirstSubBlockLine;
      public static int SubBlockMult;
      public const string BOFile = "..\\GenerateFNIS_for_Users\\BehavioredObjects.txt";
      public static int MyBO;
      public static string MyBOFolder;
      public static string MyDefaultAE;
      public static string MyAOUnequip;
      public static int No_BO;
      public static int No_BOmods;
      public const int is_definition = -2;
      public const int is_template = -1;
      public const int is_custom = 0;
      public const int is_mt_behavior = 1;
      public const int is_0_master = 2;
      public const int is_default = 3;
      public const int is_otherBehavior = 4;
      public const int nTEMPLATE = 16;
      public static uint isAAbehavior;
      public static ulong h_option;
      public static ulong hminus_option;
      public static ulong hplus_option;
      public static ulong F_option;
      public static ulong L_option;
      public static ulong AV_option;
      public static ulong k_option;
      public static ulong o_option;
      public static ulong ominus_option;
      public static ulong oplus_option;
      public static ulong bsa_option;
      public static ulong ac_option;
      public static ulong ac0_option;
      public static ulong ac1_option;
      public static ulong mdz_option;
      public static int CurrentTemplateType;
      public static string[] AllAE;
      public static string[] AllAV;
      public static int nAllTemplates;
      public static string OptionTime;
      public static bool FNIS_for_Users;
      public static bool called_from_Projects;
      public static List<FNIScommon1.FNIScommon.AEcc> AEList;
      public static List<FNIScommon1.FNIScommon.AnimFilecc> AnimFileList;
      public static List<FNIScommon1.FNIScommon.MRD_Data> MRD_DataListONE;
      public static List<FNIScommon1.FNIScommon.MRD_Data> MRD_DataListALL;
      public static int MRD_LastAnim;
      public static float MRD_LastTime;
      public static string MRD_LastTimeS;
      public static bool MRD_LastIsMD;
      public static int iPatchAF;

      public static void Initialize_Globals()
      {
        FNIScommon1.FNIScommon.AnzAnim = 0;
        FNIScommon1.FNIScommon.AnzMod = 0;
        FNIScommon1.FNIScommon.Anz_b = 0;
        FNIScommon1.FNIScommon.Anz_s = 0;
        FNIScommon1.FNIScommon.Anz_sG = 0;
        FNIScommon1.FNIScommon.Anz_fuG = 0;
        FNIScommon1.FNIScommon.Anz_aa = 0;
        FNIScommon1.FNIScommon.Anz_ch = 0;
        FNIScommon1.FNIScommon.Anz_chG = 0;
        FNIScommon1.FNIScommon.nextAO = 0;
        FNIScommon1.FNIScommon.BlendList[0] = "0.6";
        FNIScommon1.FNIScommon.lastBlend = 0;
        FNIScommon1.FNIScommon.WarningCount = 0;
        FNIScommon1.FNIScommon.BehaviorFile = (StreamWriter) null;
        FNIScommon1.FNIScommon.MyBO = 0;
        FNIScommon1.FNIScommon.iAnimAEET = 0;
        FNIScommon1.FNIScommon.iAnimAV = 0;
        FNIScommon1.FNIScommon.InputLine = 0;
        FNIScommon1.FNIScommon.OutputLine = 0;
        Array.Clear((Array) FNIScommon1.FNIScommon.Anz_AO, 0, checked (Information.UBound((Array) FNIScommon1.FNIScommon.Anz_AO, 1) + 1));
        Array.Clear((Array) FNIScommon1.FNIScommon.nAO, 0, checked (Information.UBound((Array) FNIScommon1.FNIScommon.nAO, 1) + 1));
        Array.Clear((Array) FNIScommon1.FNIScommon.CustomAEnum, 0, checked (Information.UBound((Array) FNIScommon1.FNIScommon.CustomAEnum, 1) + 1));
        Array.Clear((Array) FNIScommon1.FNIScommon.AnzAnimVars, 0, checked (Information.UBound((Array) FNIScommon1.FNIScommon.AnzAnimVars, 1) + 1));
        FNIScommon1.FNIScommon.MRD_DataListONE = new List<FNIScommon1.FNIScommon.MRD_Data>();
        FNIScommon1.FNIScommon.CRC32_Tab_Init();
        FNIScommon1.FNIScommon.hkxcmdProcess.StartInfo.UseShellExecute = false;
        FNIScommon1.FNIScommon.hkxcmdProcess.StartInfo.FileName = ".\\hkxcmd.exe";
        FNIScommon1.FNIScommon.hkxcmdProcess.StartInfo.CreateNoWindow = true;
        FNIScommon1.FNIScommon.h_option = FNIScommon1.FNIScommon.GetOptions("h", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.hminus_option = FNIScommon1.FNIScommon.GetOptions("h-", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.hplus_option = FNIScommon1.FNIScommon.GetOptions("h+", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.F_option = FNIScommon1.FNIScommon.GetOptions("F", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.L_option = FNIScommon1.FNIScommon.GetOptions("L", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.AV_option = FNIScommon1.FNIScommon.GetOptions("AV", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.k_option = FNIScommon1.FNIScommon.GetOptions("k", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.o_option = FNIScommon1.FNIScommon.GetOptions("o", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.ominus_option = FNIScommon1.FNIScommon.GetOptions("o-", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.oplus_option = FNIScommon1.FNIScommon.GetOptions("o+", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.bsa_option = FNIScommon1.FNIScommon.GetOptions("bsa", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.ac_option = FNIScommon1.FNIScommon.GetOptions("ac", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.ac0_option = FNIScommon1.FNIScommon.GetOptions("ac0", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.ac1_option = FNIScommon1.FNIScommon.GetOptions("ac1", FNIScommon1.FNIScommon.AnimListFile, -2);
        FNIScommon1.FNIScommon.mdz_option = FNIScommon1.FNIScommon.GetOptions("mdz", FNIScommon1.FNIScommon.AnimListFile, -2);
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static string[] ReadAFile(string FileName)
      {
        if (!MyProject.Computer.FileSystem.FileExists(FileName.ToUpperInvariant()))
        {
          FNIScommon1.FNIScommon.ErrString = FileName;
          Information.Err().Raise(2001, (object) null, (object) null, (object) null, (object) null);
        }
        FileStream fileStream = new FileStream(FileName, FileMode.Open);
        StreamReader streamReader = new StreamReader((Stream) fileStream, Encoding.UTF8);
        List<string> stringList = new List<string>();
        while (streamReader.Peek() >= 0)
          stringList.Add(streamReader.ReadLine());
        fileStream.Close();
        streamReader.Close();
        return stringList.ToArray();
      }

      public static void WriteAFile(string FileName, ref string[] StringArray, int Elements)
      {
        using (StreamWriter streamWriter = new StreamWriter(FileName))
        {
          int num = checked (Elements - 1);
          int index = 0;
          while (index <= num)
          {
            streamWriter.WriteLine(StringArray[index]);
            checked { ++index; }
          }
          streamWriter.Close();
        }
      }

      public static List<string> Combined_BOlist()
      {
        string[] strArray = Strings.Split("..\\GenerateFNIS_for_Users\\BehavioredObjects.txt", "\\", -1, CompareMethod.Binary);
        int Rank = 1;
        int index = Information.UBound((Array) strArray, Rank);
        string str = strArray[index];
        List<string> list = ((IEnumerable<string>) FNIScommon1.FNIScommon.ReadAFile("..\\GenerateFNIS_for_Users\\BehavioredObjects.txt")).ToList<string>();
        List<string> stringList = FNIScommon1.FNIScommon.Read_Directory("..\\GenerateFNIS_for_Users\\", ".txt");
        List<string>.Enumerator enumerator;
        try
        {
          enumerator = stringList.GetEnumerator();
          while (enumerator.MoveNext())
          {
            string current = enumerator.Current;
            if (Operators.CompareString(Strings.LCase(Strings.Left(current, checked (Strings.Len(str) - 3))), Strings.LCase(Strings.Left(str, checked (Strings.Len(str) - 4))) + "_", false) == 0)
              list.AddRange((IEnumerable<string>) ((IEnumerable<string>) FNIScommon1.FNIScommon.ReadAFile("..\\GenerateFNIS_for_Users\\" + current)).ToList<string>());
          }
        }
        finally
        {
          enumerator.Dispose();
        }
        return list;
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static void GenerateBehavior(string TemplateFileName, string BehaviorFileName, int BehaviorType, bool hasAA, ref string[] OutArray, ref int iOut)
      {
        bool flag1 = false;
        FileInfo fileInfo = new FileInfo(TemplateFileName);
        if (!fileInfo.Exists)
        {
          FNIScommon1.FNIScommon.ErrString = TemplateFileName;
          Information.Err().Raise(2001, (object) null, (object) null, (object) null, (object) null);
        }
        FNIScommon1.FNIScommon.CurrentTemplate = TemplateFileName;
        FNIScommon1.FNIScommon.LogOutput("Start Template: " + TemplateFileName, false, true);
        if (BehaviorType == 0)
        {
          FNIScommon1.FNIScommon.AE1_b = 11;
          FNIScommon1.FNIScommon.AE1_c = FNIScommon1.FNIScommon.AE1_b;
          FNIScommon1.FNIScommon.AE1_s = checked (FNIScommon1.FNIScommon.AE1_b + FNIScommon1.FNIScommon.Anz_b);
          FNIScommon1.FNIScommon.AE1_sgf = checked (FNIScommon1.FNIScommon.AE1_s + FNIScommon1.FNIScommon.Anz_s);
          FNIScommon1.FNIScommon.AE1_sgl = checked (FNIScommon1.FNIScommon.AE1_sgf + FNIScommon1.FNIScommon.Anz_sG);
          FNIScommon1.FNIScommon.AE1_trigger = checked (FNIScommon1.FNIScommon.AE1_sgl + FNIScommon1.FNIScommon.Anz_sG);
        }
        else if (BehaviorType == 2)
        {
          FNIScommon1.FNIScommon.AE1_pa = 1217;
          FNIScommon1.FNIScommon.AE1_km = checked (FNIScommon1.FNIScommon.AE1_pa + 2 * FNIScommon1.FNIScommon.Anz_pa);
          FNIScommon1.FNIScommon.AE1_trigger = checked (FNIScommon1.FNIScommon.AE1_km + 2 * FNIScommon1.FNIScommon.Anz_km);
        }
        else if (BehaviorType == 1)
        {
          FNIScommon1.FNIScommon.AE1_fu = 931;
          FNIScommon1.FNIScommon.AE1_fuG = checked (FNIScommon1.FNIScommon.AE1_fu + FNIScommon1.FNIScommon.Anz_fu);
          FNIScommon1.FNIScommon.AE1_ofa = checked (FNIScommon1.FNIScommon.AE1_fuG + FNIScommon1.FNIScommon.Anz_fuG);
          FNIScommon1.FNIScommon.AE1_chG = checked (FNIScommon1.FNIScommon.AE1_ofa + FNIScommon1.FNIScommon.Anz_ofa);
          FNIScommon1.FNIScommon.AE1_aa = checked (FNIScommon1.FNIScommon.AE1_chG + FNIScommon1.FNIScommon.Anz_chG);
          FNIScommon1.FNIScommon.AE1_trigger = FNIScommon1.FNIScommon.AE1_aa;
        }
        if (Information.IsNothing((object) OutArray))
        {
          FNIScommon1.FNIScommon.BehaviorFile = new StreamWriter(BehaviorFileName);
          if (FNIScommon1.FNIScommon.DebugOutput > 0)
            FNIScommon1.FNIScommon.BehaviorFile.AutoFlush = true;
        }
        else
          iOut = 0;
        FNIScommon1.FNIScommon.RecIndex = 1000;
        FNIScommon1.FNIScommon.SymAddrInd = 0;
        FNIScommon1.FNIScommon.TemplateLine = 0;
        FNIScommon1.FNIScommon.OutputLine = 0;
        string str1 = "";
        bool flag2 = false;
        bool flag3 = false;
        bool flag4 = false;
        FNIScommon1.FNIScommon.IsOptimizedBlock = 0;
        FNIScommon1.FNIScommon.Patch_NumElement = 0;
        int num1 = 3;
        int num2 = 1;
        using (FileStream fileStream = fileInfo.Open((FileMode) num1, (FileAccess) num2))
        {
          using (StreamReader streamReader = new StreamReader((Stream) fileStream))
          {
            while (!streamReader.EndOfStream)
            {
              checked { ++FNIScommon1.FNIScommon.TemplateLine; }
              FNIScommon1.FNIScommon.CurrentLine = FNIScommon1.FNIScommon.TemplateLine;
              string str2 = streamReader.ReadLine();
              if (!(FNIScommon1.FNIScommon.MyBO == 0 & (uint) BehaviorType > 0U & FNIScommon1.FNIScommon.TemplateLine == 1) || FNIScommon1.FNIScommon.Check_Template_Entry(TemplateFileName, str2) == -2)
              {
                bool flag5 = false;
                if (Operators.CompareString(Strings.Left(str2, 8), "<!-- $*$", false) == 0)
                {
                  if (!flag3)
                  {
                    flag5 = true;
                  }
                  else
                  {
                    flag3 = false;
                    flag4 = false;
                  }
                }
                else if (Operators.CompareString(Strings.Left(str2, 9), "<!-- $**$", false) == 0)
                {
                  if (!flag3)
                    flag5 = true;
                  else
                    flag4 = !flag4;
                }
                else if (Operators.CompareString(Strings.Left(str2, 7), "<!-- $*", false) == 0)
                {
                  if (flag3)
                  {
                    flag5 = true;
                  }
                  else
                  {
                    flag3 = true;
                    flag4 = true;
                    string str3 = Strings.Mid(Strings.Split(str2, "$", -1, CompareMethod.Binary)[1], 2);
                    if (Operators.CompareString(Strings.Left(str3, 1), "_", false) == 0)
                    {
                      flag4 = (int) FNIScommon1.FNIScommon.TestGeneration == 2;
                      if ((int) FNIScommon1.FNIScommon.TestGeneration == 1 & !flag1)
                      {
                        string[] strArray = Strings.Split(TemplateFileName, "\\", -1, CompareMethod.Binary);
                        FNIScommon1.FNIScommon.LogOutput("PATCHED TEMPLATE: " + strArray[Information.UBound((Array) strArray, 1)], true, true);
                        flag1 = true;
                      }
                    }
                    else if (Operators.CompareString(str3, "FNIS", false) == 0)
                      flag4 = (uint) FNIScommon1.FNIScommon.TestGeneration > 0U;
                    else if (Operators.CompareString(str3, "FNIS_AA", false) == 0)
                    {
                      flag4 = (uint) FNIScommon1.FNIScommon.TestGeneration > 0U;
                    }
                    else
                    {
                      int num3 = checked (FNIScommon1.FNIScommon.PatchCount - 1);
                      int index = 0;
                      while (index <= num3)
                      {
                        if (Operators.CompareString(str3, FNIScommon1.FNIScommon.PatchID[index], false) == 0)
                        {
                          flag4 = !FNIScommon1.FNIScommon.isPatch[index];
                          index = FNIScommon1.FNIScommon.PatchCount;
                        }
                        checked { ++index; }
                      }
                    }
                  }
                }
                if (flag5)
                {
                  FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) FNIScommon1.FNIScommon.TemplateLine) + " (" + TemplateFileName + ")";
                  Information.Err().Raise(2016, (object) null, (object) null, (object) null, (object) null);
                }
                else if (flag4 | Operators.CompareString(Strings.Left(str2, 7), "<!-- $*", false) == 0)
                  continue;
                int BlockLast;
                int BlockMult;
                int num4;
                if (Operators.CompareString(Strings.Left(str2, 7), "<!-- $$", false) == 0)
                {
                  if (flag2)
                  {
                    flag2 = false;
                    FNIScommon1.FNIScommon.MultiplyBlock(0, BlockLast, BlockMult, str1, -1, FNIScommon1.FNIScommon.IsOptimizedBlock, ref OutArray, ref iOut, BehaviorType);
                    FNIScommon1.FNIScommon.IsOptimizedBlock = 0;
                  }
                  else
                  {
                    FNIScommon1.FNIScommon.ErrInt = FNIScommon1.FNIScommon.TemplateLine;
                    FNIScommon1.FNIScommon.ErrString = TemplateFileName;
                    Information.Err().Raise(2002, (object) null, (object) null, (object) null, (object) null);
                  }
                }
                else if (Operators.CompareString(Strings.Left(str2, 6), "<!-- $", false) == 0 & (uint) Operators.CompareString(Strings.Mid(str2, 7, 1), "-", false) > 0U & (uint) Operators.CompareString(Strings.Mid(str2, 7, 1), "^", false) > 0U & (uint) Operators.CompareString(Strings.Mid(str2, 7, 2), "RI", false) > 0U & (uint) Operators.CompareString(Strings.Mid(str2, 7, 1), "*", false) > 0U & (uint) Operators.CompareString(Strings.Mid(str2, 7, 1), "#", false) > 0U)
                {
                  if (flag2)
                  {
                    FNIScommon1.FNIScommon.ErrInt = FNIScommon1.FNIScommon.TemplateLine;
                    FNIScommon1.FNIScommon.ErrString = TemplateFileName;
                    Information.Err().Raise(2003, (object) null, (object) null, (object) null, (object) null);
                  }
                  else
                  {
                    BlockLast = -1;
                    flag2 = true;
                    string[] strArray1 = Strings.Split(str2, "$", -1, CompareMethod.Binary);
                    if (Information.UBound((Array) strArray1, 1) <= 1)
                    {
                      FNIScommon1.FNIScommon.ErrInt = FNIScommon1.FNIScommon.TemplateLine;
                      Information.Err().Raise(2004, (object) null, (object) null, (object) null, (object) null);
                    }
                    else
                    {
                      FNIScommon1.FNIScommon.BlockStartInTemplate = FNIScommon1.FNIScommon.TemplateLine;
                      FNIScommon1.FNIScommon.RecIncrement = 0;
                      string str3 = strArray1[1];
                      string[] strArray2 = Strings.Split(str3, ":", -1, CompareMethod.Binary);
                      if (Information.UBound((Array) strArray2, 1) >= 1)
                      {
                        FNIScommon1.FNIScommon.SymAddr[FNIScommon1.FNIScommon.SymAddrInd] = strArray2[0];
                        if (Information.UBound((Array) strArray2, 1) == 2)
                        {
                          if (Versioned.IsNumeric((object) strArray2[1]))
                            FNIScommon1.FNIScommon.RecIndex = Conversions.ToInteger(strArray2[1]);
                          else if (Operators.CompareString(strArray2[1], "RI", false) == 0)
                            checked { FNIScommon1.FNIScommon.RecIndex += 0; }
                          strArray2[1] = strArray2[2];
                        }
                        FNIScommon1.FNIScommon.SymAddrVal[FNIScommon1.FNIScommon.SymAddrInd] = FNIScommon1.FNIScommon.RecIndex;
                        string[] strArray3 = Strings.Split(strArray2[1], "/", -1, CompareMethod.Binary);
                        if (Operators.CompareString(strArray3[1], "opt", false) == 0)
                        {
                          FNIScommon1.FNIScommon.IsOptimizedBlock = 1;
                          FNIScommon1.FNIScommon.RecIncrement = 1;
                        }
                        else
                          FNIScommon1.FNIScommon.RecIncrement = FNIScommon1.FNIScommon.EvalExpression(strArray3[1], 0, 0, str1, BehaviorType);
                        str3 = strArray3[0];
                        if (FNIScommon1.FNIScommon.RecIncrement <= 0 | Operators.CompareString(FNIScommon1.FNIScommon.SymAddr[FNIScommon1.FNIScommon.SymAddrInd], "", false) == 0)
                          str3 = "";
                        if (FNIScommon1.FNIScommon.DebugOutput > 0)
                          FNIScommon1.FNIScommon.LogOutput("Symbolic:" + Conversion.Str((object) FNIScommon1.FNIScommon.SymAddrInd) + " " + FNIScommon1.FNIScommon.SymAddr[FNIScommon1.FNIScommon.SymAddrInd] + " Addr:" + Conversion.Str((object) FNIScommon1.FNIScommon.SymAddrVal[FNIScommon1.FNIScommon.SymAddrInd]), false, true);
                        checked { ++FNIScommon1.FNIScommon.SymAddrInd; }
                      }
                      else if (Strings.InStr(str3, "/", CompareMethod.Binary) > 0)
                      {
                        string[] strArray3 = Strings.Split(str3, "/", -1, CompareMethod.Binary);
                        str3 = strArray3[0];
                        FNIScommon1.FNIScommon.RecIncrement = FNIScommon1.FNIScommon.EvalExpression(strArray3[1], 0, 0, str1, BehaviorType);
                      }
                      BlockMult = FNIScommon1.FNIScommon.EvalExpression(str3, 0, 0, str1, BehaviorType);
                      if (BlockMult < 0)
                      {
                        FNIScommon1.FNIScommon.ErrInt = FNIScommon1.FNIScommon.TemplateLine;
                        FNIScommon1.FNIScommon.ErrString = TemplateFileName;
                        Information.Err().Raise(2005, (object) null, (object) null, (object) null, (object) null);
                      }
                      str1 = "";
                      if (Strings.Len(str3) <= 3 & !Versioned.IsNumeric((object) str3))
                        str1 = str3;
                    }
                  }
                }
                else if (flag2)
                {
                  if (BlockLast >= Information.UBound((Array) FNIScommon1.FNIScommon.BehaviorTemplate, 1))
                  {
                    FNIScommon1.FNIScommon.ErrInt = FNIScommon1.FNIScommon.TemplateLine;
                    FNIScommon1.FNIScommon.ErrString = TemplateFileName;
                    Information.Err().Raise(2006, (object) null, (object) null, (object) null, (object) null);
                  }
                  else
                  {
                    checked { ++BlockLast; }
                    FNIScommon1.FNIScommon.BehaviorTemplate[BlockLast] = str2;
                  }
                }
                else if (!flag4)
                {
                  if (flag3 & Operators.CompareString(Strings.Left(str2, 2), "$B", false) == 0)
                  {
                    if ((int) FNIScommon1.FNIScommon.TestGeneration == 0)
                    {
                      string str3 = "";
                      int num3 = checked (FNIScommon1.FNIScommon.currBones - 99 - 1);
                      int num5 = 0;
                      while (num5 <= num3)
                      {
                        if (num5 % 16 == 0)
                          str3 = "\t\t\t\t";
                        if (Operators.CompareString(Strings.Mid(str2, 3, 1), "0", false) == 0)
                          str3 += " 0.000000";
                        else if (Operators.CompareString(Strings.Mid(str2, 3, 1), "1", false) == 0)
                          str3 += " 1.000000";
                        else if (Operators.CompareString(Strings.Mid(str2, 3, 1), "n", false) == 0)
                        {
                          string str4 = str3;
                          string str5 = " ";
                          num4 = checked (num5 + 99);
                          string str6 = num4.ToString("d");
                          str3 = str4 + str5 + str6;
                        }
                        if (num5 == checked (FNIScommon1.FNIScommon.currBones - 99 - 1) | num5 % 16 == 15)
                        {
                          if (Information.IsNothing((object) OutArray))
                          {
                            FNIScommon1.FNIScommon.BehaviorFile.WriteLine(str3);
                          }
                          else
                          {
                            OutArray[iOut] = str3;
                            iOut = checked (iOut + 1);
                          }
                          checked { ++FNIScommon1.FNIScommon.OutputLine; }
                        }
                        checked { ++num5; }
                      }
                    }
                  }
                  else if (Operators.CompareString(Strings.Left(str2, 7), "<!-- $#", false) == 0)
                  {
                    string[] strArray = Strings.Split(Strings.Mid(str2, 8), " ", -1, CompareMethod.Binary);
                    if (Information.UBound((Array) strArray, 1) < 2)
                    {
                      FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) FNIScommon1.FNIScommon.TemplateLine) + " (" + TemplateFileName + ")";
                      Information.Err().Raise(2016, (object) null, (object) null, (object) null, (object) null);
                    }
                    string str3 = Strings.Replace(strArray[2], "$", "", 1, -1, CompareMethod.Binary);
                    int num3 = checked ((int) Math.Round(Conversion.Val(str3)));
                    if (Operators.CompareString(Strings.Left(strArray[0], 1), "_", false) == 0 & (int) FNIScommon1.FNIScommon.TestGeneration != 2)
                      checked { FNIScommon1.FNIScommon.Patch_NumElement += num3; }
                    else if ((int) FNIScommon1.FNIScommon.TestGeneration == 0)
                    {
                      if (Operators.CompareString(Strings.Left(strArray[0], 7), "FNIS_AA", false) == 0)
                      {
                        checked { FNIScommon1.FNIScommon.Patch_NumElement += FNIScommon1.FNIScommon.EvalExpression(str3, 0, 0, str1, BehaviorType); }
                      }
                      else
                      {
                        num4 = checked (FNIScommon1.FNIScommon.PatchCount - 1);
                        int index = 0;
                        while (index <= num4)
                        {
                          if (Operators.CompareString(strArray[0], FNIScommon1.FNIScommon.PatchID[index], false) == 0)
                          {
                            if (FNIScommon1.FNIScommon.isPatch[index])
                              checked { FNIScommon1.FNIScommon.Patch_NumElement += num3; }
                            index = FNIScommon1.FNIScommon.PatchCount;
                          }
                          checked { ++index; }
                        }
                      }
                    }
                  }
                  else
                  {
                    if (FNIScommon1.FNIScommon.Patch_NumElement > 0)
                    {
                      bool flag6 = true;
                      int num3 = Strings.InStr(str2, "numelements=", CompareMethod.Binary);
                      if (num3 > 0)
                      {
                        string[] strArray = Strings.Split(Strings.Mid(str2, checked (num3 + 13)), "\"", -1, CompareMethod.Binary);
                        int num5 = checked ((int) Math.Round(Conversion.Val(strArray[0])));
                        str2 = Strings.Left(str2, checked (num3 + 12)) + checked (num5 + FNIScommon1.FNIScommon.Patch_NumElement).ToString() + Strings.Mid(str2, checked (num3 + 13 + Strings.Len(strArray[0])));
                        flag6 = false;
                        FNIScommon1.FNIScommon.Patch_NumElement = 0;
                      }
                      if (flag6)
                      {
                        FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) FNIScommon1.FNIScommon.TemplateLine) + " (" + TemplateFileName + ")";
                        Information.Err().Raise(2016, (object) null, (object) null, (object) null, (object) null);
                      }
                    }
                    if ((int) FNIScommon1.FNIScommon.TestGeneration == 0 | (uint) Operators.CompareString(Strings.Left(str2, 5), "<!-- ", false) > 0U)
                    {
                      if (Information.IsNothing((object) OutArray))
                      {
                        FNIScommon1.FNIScommon.BehaviorFile.WriteLine(str2);
                      }
                      else
                      {
                        OutArray[iOut] = str2;
                        iOut = checked (iOut + 1);
                      }
                      checked { ++FNIScommon1.FNIScommon.OutputLine; }
                    }
                  }
                }
              }
            }
          }
        }
        FNIScommon1.FNIScommon.LogOutput("Max RecIndex: " + Conversion.Str((object) FNIScommon1.FNIScommon.RecIndex), false, true);
        if (Information.IsNothing((object) OutArray))
          FNIScommon1.FNIScommon.BehaviorFile.Close();
        else
          FNIScommon1.FNIScommon.WriteAFile(BehaviorFileName, ref OutArray, iOut);
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static void MultiplyBlock(int BlockFirst, int BlockLast, int BlockMult, string Blocktype, int Outerindex, int isOptimizedBlock, ref string[] OutArray, ref int iOut, int BehaviorType)
      {
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
        {
          FNIScommon1.FNIScommon.InputLine = FNIScommon1.FNIScommon.BlockStartInTemplate;
          FNIScommon1.FNIScommon.WriteDebug("MultipyBlock", 1, "BlockFirst:" + Conversion.Str((object) BlockFirst) + " BlockLast:" + Conversion.Str((object) BlockLast) + " BlockMult:" + Conversion.Str((object) BlockMult) + " Blocktype: " + Blocktype + " Outerindex:" + Conversion.Str((object) Outerindex), "");
        }
        int num1 = checked (BlockMult - 1);
        int index1 = 0;
        while (index1 <= num1)
        {
          if (isOptimizedBlock > 0 & Outerindex == -1)
          {
            FNIScommon1.FNIScommon.FurnitureID[index1] = FNIScommon1.FNIScommon.RecIndex;
            FNIScommon1.FNIScommon.OptimizedCount = 0;
            int num2 = Information.UBound((Array) FNIScommon1.FNIScommon.OptimizedIndex, 1);
            int index2 = 0;
            while (index2 <= num2)
            {
              FNIScommon1.FNIScommon.OptimizedIndex[index2] = 0;
              checked { ++index2; }
            }
          }
          bool flag1 = false;
          bool flag2 = false;
          bool flag3 = false;
          int num3 = BlockFirst;
          int num4 = BlockLast;
          int index3 = num3;
          while (index3 <= num4)
          {
            FNIScommon1.FNIScommon.InputLine = checked (FNIScommon1.FNIScommon.BlockStartInTemplate + index3 + 1);
            FNIScommon1.FNIScommon.CurrentLine = FNIScommon1.FNIScommon.InputLine;
            bool flag4;
            bool flag5;
            if (Operators.CompareString(Strings.Left(FNIScommon1.FNIScommon.BehaviorTemplate[index3], 9), "<!-- $--$", false) == 0)
            {
              if (!flag1)
              {
                FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) FNIScommon1.FNIScommon.InputLine) + " (" + FNIScommon1.FNIScommon.CurrentTemplate + ")";
                Information.Err().Raise(2015, (object) null, (object) null, (object) null, (object) null);
              }
              else
                flag3 = flag4;
            }
            else if (Operators.CompareString(Strings.Left(FNIScommon1.FNIScommon.BehaviorTemplate[index3], 8), "<!-- $-$", false) == 0)
            {
              if (!flag1)
              {
                FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) FNIScommon1.FNIScommon.InputLine) + " (" + FNIScommon1.FNIScommon.CurrentTemplate + ")";
                Information.Err().Raise(2015, (object) null, (object) null, (object) null, (object) null);
              }
              else
              {
                flag1 = false;
                flag3 = false;
              }
            }
            else if (Operators.CompareString(Strings.Left(FNIScommon1.FNIScommon.BehaviorTemplate[index3], 7), "<!-- $-", false) == 0)
            {
              if (!flag1)
              {
                flag1 = true;
                flag4 = false;
              }
              if (flag4)
              {
                flag3 = true;
              }
              else
              {
                string[] strArray = Strings.Split(FNIScommon1.FNIScommon.BehaviorTemplate[index3], "$", -1, CompareMethod.Binary);
                if (Operators.CompareString(Strings.Left(strArray[1], 5), "-aa?.", false) == 0)
                {
                  if (FNISaa1.FNISaa.isAADataRead)
                  {
                    string Right = Strings.Mid(strArray[1], 6);
                    int num2 = checked (FNISaa1.FNISaa.iAAGroup - 1);
                    int index2 = 0;
                    bool flag6;
                    while (index2 <= num2)
                    {
                      if (Operators.CompareString(FNISaa1.FNISaa.AAGroup[index2], Right, false) == 0)
                      {
                        flag4 = FNISaa1.FNISaa.AASetsPerGroup[index2] > 0;
                        if (flag4)
                          checked { ++FNISaa1.FNISaa.AATotalAnimCount; }
                        flag3 = !flag4;
                        index2 = checked (FNISaa1.FNISaa.iAAGroup + 1);
                        flag6 = true;
                      }
                      checked { ++index2; }
                    }
                    if (!flag6)
                      FNIScommon1.FNIScommon.LogOutput("AA group not found (-aa?): " + Right, true, true);
                  }
                  else
                  {
                    flag4 = false;
                    flag3 = true;
                  }
                }
                else
                {
                  long options = (long) FNIScommon1.FNIScommon.GetOptions(Strings.Mid(strArray[1], 2), FNIScommon1.FNIScommon.CurrentTemplate, -1);
                  long num2 = (long) FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(Blocktype, index1)];
                  long num5 = options & num2;
                  flag4 = options == num5;
                  flag3 = !flag4;
                }
              }
            }
            else if (Operators.CompareString(Strings.Left(FNIScommon1.FNIScommon.BehaviorTemplate[index3], 8), "<!-- $^$", false) == 0)
            {
              if (!flag2)
              {
                FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) FNIScommon1.FNIScommon.InputLine) + " (" + FNIScommon1.FNIScommon.CurrentTemplate + ")";
                Information.Err().Raise(2015, (object) null, (object) null, (object) null, (object) null);
              }
              else
              {
                if (isOptimizedBlock != 2 & !flag5)
                  FNIScommon1.FNIScommon.MultiplyBlock(FNIScommon1.FNIScommon.FirstSubBlockLine, checked (index3 - 1), FNIScommon1.FNIScommon.SubBlockMult, Blocktype, index1, isOptimizedBlock, ref OutArray, ref iOut, BehaviorType);
                flag2 = false;
                flag3 = flag5;
              }
            }
            else if (Operators.CompareString(Strings.Left(FNIScommon1.FNIScommon.BehaviorTemplate[index3], 7), "<!-- $^", false) == 0)
            {
              if (flag2)
              {
                FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) FNIScommon1.FNIScommon.InputLine) + " (" + FNIScommon1.FNIScommon.CurrentTemplate + ")";
                Information.Err().Raise(2015, (object) null, (object) null, (object) null, (object) null);
              }
              else
              {
                flag2 = true;
                flag5 = flag3;
                flag3 = true;
                FNIScommon1.FNIScommon.FirstSubBlockLine = checked (index3 + 1);
                FNIScommon1.FNIScommon.SubBlockMult = FNIScommon1.FNIScommon.EvalExpression(Strings.Mid(Strings.Split(FNIScommon1.FNIScommon.BehaviorTemplate[index3], "$", -1, CompareMethod.Binary)[1], 2), index1, 0, Blocktype, BehaviorType);
              }
            }
            else if (Operators.CompareString(Strings.Left(FNIScommon1.FNIScommon.BehaviorTemplate[index3], 9), "<!-- $RI+", false) == 0)
            {
              int integer = Conversions.ToInteger(Strings.Split(Strings.Split(FNIScommon1.FNIScommon.BehaviorTemplate[index3], "$", -1, CompareMethod.Binary)[1], "+", -1, CompareMethod.Binary)[1]);
              isOptimizedBlock = FNIScommon1.FNIScommon.OptimizedIndex[integer] != 0 ? 1 : 2;
            }
            else if (!(flag3 | isOptimizedBlock == 2 | Operators.CompareString(Strings.Left(FNIScommon1.FNIScommon.BehaviorTemplate[index3], 4), "<!--", false) == 0))
            {
              string DebugText1;
              if (Strings.InStr(FNIScommon1.FNIScommon.BehaviorTemplate[index3], "$", CompareMethod.Binary) > 0)
              {
                string[] SourceArray = Strings.Split(FNIScommon1.FNIScommon.BehaviorTemplate[index3], "$", -1, CompareMethod.Binary);
                if (Information.UBound((Array) SourceArray, 1) % 2 == 1)
                {
                  FNIScommon1.FNIScommon.ErrInt = FNIScommon1.FNIScommon.InputLine;
                  FNIScommon1.FNIScommon.ErrString = FNIScommon1.FNIScommon.CurrentTemplate;
                  Information.Err().Raise(2007, (object) null, (object) null, (object) null, (object) null);
                }
                int num2 = Information.UBound((Array) SourceArray, 1);
                int index2 = 1;
                while (index2 <= num2)
                {
                  SourceArray[index2] = FNIScommon1.FNIScommon.EvalModifier(SourceArray[index2], index1, Outerindex, Blocktype, FNIScommon1.FNIScommon.InputLine, BehaviorType);
                  checked { index2 += 2; }
                }
                DebugText1 = Strings.Join(SourceArray, "");
              }
              else
                DebugText1 = FNIScommon1.FNIScommon.BehaviorTemplate[index3];
              if (Information.IsNothing((object) OutArray))
              {
                FNIScommon1.FNIScommon.BehaviorFile.WriteLine(DebugText1);
              }
              else
              {
                OutArray[iOut] = DebugText1;
                iOut = checked (iOut + 1);
              }
              checked { ++FNIScommon1.FNIScommon.OutputLine; }
              if (FNIScommon1.FNIScommon.DebugOutput >= 3)
                FNIScommon1.FNIScommon.WriteDebug("", 99, DebugText1, "");
            }
            checked { ++index3; }
          }
          if (Outerindex < 0)
          {
            if (isOptimizedBlock > 0)
              FNIScommon1.FNIScommon.RecIndex = checked (FNIScommon1.FNIScommon.RecIndex + FNIScommon1.FNIScommon.OptimizedCount + 1);
            else
              checked { FNIScommon1.FNIScommon.RecIndex += FNIScommon1.FNIScommon.RecIncrement; }
          }
          if (isOptimizedBlock == 2)
            isOptimizedBlock = 1;
          checked { ++index1; }
        }
        if (FNIScommon1.FNIScommon.DebugOutput <= 3)
          return;
        FNIScommon1.FNIScommon.WriteDebug("MultipyBlock", 0, "", "");
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static string EvalModifier(string Modifier, int BlockIndex, int OuterIndex, string BlockType, int CurrentLine, int BehaviorType)
      {
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("EvalModifier", 1, "Modifier: " + Modifier + " Blockindex:" + Conversion.Str((object) BlockIndex) + " Outerindex:" + Conversion.Str((object) OuterIndex) + " BlockType: " + BlockType, "");
        string str1 = "";
        if (Operators.CompareString(Strings.Left(Modifier, 1), "E", false) == 0)
        {
          string str2 = Strings.Mid(Modifier, 2);
          if (Operators.CompareString(str2, "aae", false) == 0)
            str1 = FNIScommon1.FNIScommon.CustomAE[BehaviorType, BlockIndex];
          else if (Operators.CompareString(str2, "sg", false) == 0)
            str1 = FNIScommon1.FNIScommon.AnimEvent[FNIScommon1.FNIScommon.GetAI("sg", BlockIndex)];
          else if (Operators.CompareString(str2, "sgl", false) == 0)
          {
            int animStats1 = FNIScommon1.FNIScommon.Get_AnimStats("s", BlockIndex, 0, 2);
            int animStats2 = FNIScommon1.FNIScommon.Get_AnimStats("s", BlockIndex, -1, 1);
            str1 = FNIScommon1.FNIScommon.AnimEvent[checked (FNIScommon1.FNIScommon.GetAI("s", animStats1) + animStats2 - 1)];
          }
          else
            str1 = FNIScommon1.FNIScommon.AnimEvent[FNIScommon1.FNIScommon.GetAI(str2, BlockIndex)];
        }
        else if (Operators.CompareString(Strings.Left(Modifier, 1), "F", false) == 0)
        {
          if (Operators.CompareString(Modifier, "Faa", false) == 0)
            str1 = Operators.CompareString(FNIScommon1.FNIScommon.AnimFileAA[BlockIndex], "", false) == 0 ? "ERROR_AAfileNotFound" : FNIScommon1.FNIScommon.AnimFileAA[BlockIndex];
          else if (Operators.CompareString(Modifier, "Faa2", false) == 0)
          {
            string[] strArray = Strings.Split(FNIScommon1.FNIScommon.AnimFileAA[BlockIndex], "\\", -1, CompareMethod.Binary);
            str1 = Strings.Left(strArray[Information.UBound((Array) strArray, 1)], checked (Strings.Len(strArray[Information.UBound((Array) strArray, 1)]) - 4));
            if (Operators.CompareString(str1, "", false) == 0)
              str1 = "ERROR_AAfileNotFound";
          }
          else if (Operators.CompareString(Modifier, "Fpaf1", false) == 0)
          {
            int index = 0;
            int num = 0;
            str1 = "ERROR_PatchFileName";
            while (index < FNIScommon1.FNIScommon.iPatchAF)
            {
              if (FNIScommon1.FNIScommon.PatchAF[index].inDefault)
              {
                if (num == BlockIndex)
                {
                  str1 = FNIScommon1.FNIScommon.PatchAF[index].path + "\\" + FNIScommon1.FNIScommon.PatchAF[index].name;
                  index = FNIScommon1.FNIScommon.iPatchAF;
                }
                checked { ++num; }
              }
              checked { ++index; }
            }
          }
          else if (Operators.CompareString(Modifier, "Fpaf2", false) == 0)
          {
            int index = 0;
            str1 = "";
            while (index < FNIScommon1.FNIScommon.iPatchAF)
            {
              if (FNIScommon1.FNIScommon.PatchAF[index].inADSF)
              {
                if (Operators.CompareString(str1, "", false) != 0)
                  str1 += "\r\n";
                str1 = str1 + FNIScommon1.FNIScommon.PatchAF[index].ClipGenName + "\r\n" + FNIScommon1.FNIScommon.PatchAF[index].AnimationID.ToString() + "\r\n1\r\n0\r\n0\r\n0\r\n";
              }
              checked { ++index; }
            }
            if (Operators.CompareString(str1, "", false) == 0)
              str1 = " ";
          }
          else if (Strings.Len(Modifier) > 1)
          {
            if (Operators.CompareString(Strings.Mid(Modifier, 2, 1), "X", false) == 0)
            {
              int ai = FNIScommon1.FNIScommon.GetAI(Strings.Mid(Modifier, 3), BlockIndex);
              str1 = Strings.Left(FNIScommon1.FNIScommon.AnimFile[ai], checked (Strings.Len(FNIScommon1.FNIScommon.AnimFile[ai]) - 4));
            }
            else
            {
              int num;
              if (Strings.InStr(Modifier, "-", CompareMethod.Binary) == checked (Strings.Len(Modifier) - 1))
              {
                num = Conversions.ToInteger(Strings.Right(Modifier, 1));
                Modifier = Strings.Left(Modifier, checked (Strings.Len(Modifier) - 2));
              }
              else
                num = 0;
              int index = checked (FNIScommon1.FNIScommon.GetAI(Strings.Mid(Modifier, 2), BlockIndex) - num);
              str1 = FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnimMod[index]] + "\\" + FNIScommon1.FNIScommon.AnimFile[index];
            }
          }
          else if (Operators.CompareString(Modifier, "F", false) == 0)
          {
            int index = 0;
            int num = 0;
            while (index < FNIScommon1.FNIScommon.AnzAnim)
            {
              if ((uint) Operators.CompareString(FNIScommon1.FNIScommon.AnimFile[index], "", false) > 0U & !FNIScommon1.FNIScommon.AnimKoption[index])
              {
                if (num == BlockIndex)
                {
                  str1 = FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnimMod[index]] + "\\" + FNIScommon1.FNIScommon.AnimFile[index];
                  index = FNIScommon1.FNIScommon.AnzAnim;
                }
                else
                  checked { ++num; }
              }
              checked { ++index; }
            }
          }
        }
        else if (Operators.CompareString(Strings.Left(Modifier, 1), "O", false) == 0)
          str1 = FNIScommon1.FNIScommon.AnimObject[BehaviorType, BlockIndex];
        else if (Operators.CompareString(Modifier, "M1", false) == 0)
        {
          int ai = FNIScommon1.FNIScommon.GetAI(BlockType, BlockIndex);
          str1 = FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnimMod[ai]];
        }
        else if (Operators.CompareString(Modifier, "M", false) == 0)
        {
          if (BehaviorType == 0)
          {
            str1 = FNIScommon1.FNIScommon.MyMod[1];
          }
          else
          {
            str1 = FNIScommon1.FNIScommon.MyMod[checked (BlockIndex + 1)];
            if (FNIScommon1.FNIScommon.MyBO != 0)
              str1 = str1 + "_" + FNIScommon1.FNIScommon.BO_List[FNIScommon1.FNIScommon.MyBO];
          }
        }
        else if (Operators.CompareString(Strings.Left(Modifier, 3), "DAE", false) == 0)
          str1 = FNIScommon1.FNIScommon.MyDefaultAE;
        else if (Operators.CompareString(Strings.Left(Modifier, 3), "AOU", false) == 0)
          str1 = FNIScommon1.FNIScommon.MyAOUnequip;
        else if (Operators.CompareString(Strings.Left(Modifier, 2), "av", false) == 0)
          str1 = Operators.CompareString(Strings.Mid(Modifier, 3, 1), "n", false) != 0 ? (Operators.CompareString(Strings.Mid(Modifier, 3, 1), "t", false) != 0 ? (Operators.CompareString(Strings.Mid(Modifier, 3, 1), "v", false) != 0 ? "" : FNIScommon1.FNIScommon.AnimVarValue[BlockIndex, BehaviorType]) : FNIScommon1.FNIScommon.AnimVarType[BlockIndex, BehaviorType]) : FNIScommon1.FNIScommon.AnimVarName[BlockIndex, BehaviorType];
        else if (Operators.CompareString(Modifier, "BOF", false) == 0)
          str1 = FNIScommon1.FNIScommon.MyBO != 0 ? FNIScommon1.FNIScommon.MyBOFolder : "Behaviors";
        else if (Operators.CompareString(Modifier, "PAH", false) == 0 | Operators.CompareString(Modifier, "KMH", false) == 0)
        {
          int index = 0;
          int num1 = 0;
          str1 = "";
          while (index < FNIScommon1.FNIScommon.AnzAnim)
          {
            if (Operators.CompareString(Modifier, "PAH", false) == 0 & Operators.CompareString(FNIScommon1.FNIScommon.AnimType[index], "pa", false) == 0 | Operators.CompareString(Modifier, "KMH", false) == 0 & Operators.CompareString(FNIScommon1.FNIScommon.AnimType[index], "km", false) == 0)
            {
              if (num1 == BlockIndex)
              {
                uint num2 = FNIScommon1.FNIScommon.CRC32_Calc("meshes\\actors\\character\\animations\\" + Strings.LCase(FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnimMod[index]]));
                string str2 = num2.ToString("0");
                string str3 = "\r\n";
                num2 = FNIScommon1.FNIScommon.CRC32_Calc(Strings.LCase(Strings.Left(FNIScommon1.FNIScommon.AnimFile[index], checked (Strings.Len(FNIScommon1.FNIScommon.AnimFile[index]) - 4))));
                string str4 = num2.ToString("0");
                str1 = str2 + str3 + str4;
                index = FNIScommon1.FNIScommon.AnzAnim;
              }
              else
                checked { ++num1; }
            }
            checked { ++index; }
          }
        }
        else if (Operators.CompareString(Modifier, "&TAE", false) == 0)
        {
          int ai = FNIScommon1.FNIScommon.GetAI(BlockType, OuterIndex);
          int num = FNIScommon1.FNIScommon.AnimAEEvent[checked (FNIScommon1.FNIScommon.AnimAE[ai] + BlockIndex)];
          if (num < 0)
            num = checked (FNIScommon1.FNIScommon.AE1_trigger - num - 1);
          str1 = Conversion.Str((object) num);
        }
        else if (Operators.CompareString(Modifier, "&TAE1", false) == 0)
        {
          int ai = FNIScommon1.FNIScommon.GetAI(BlockType, OuterIndex);
          str1 = "";
          int num1 = -1;
          int num2 = checked (FNIScommon1.FNIScommon.AnimNumAE[ai] - 1);
          int num3 = 0;
          while (num3 <= num2)
          {
            int num4 = FNIScommon1.FNIScommon.AnimAEEvent[checked (FNIScommon1.FNIScommon.AnimAE[ai] + num3)];
            if (Operators.CompareString(Strings.Left(num4 >= 0 ? FNIScommon1.FNIScommon.AllAE[checked (FNIScommon1.FNIScommon.AllAEfirst[BehaviorType] + num4)] : FNIScommon1.FNIScommon.CustomAE[BehaviorType, checked (-num4 - 1)], 2), "2_", false) != 0)
              checked { ++num1; }
            if (num1 == BlockIndex)
            {
              if (num4 < 0)
                num4 = checked (FNIScommon1.FNIScommon.AE1_trigger - num4 - 1);
              str1 = Strings.Format((object) num4, "0");
              num3 = FNIScommon1.FNIScommon.AnimNumAE[ai];
            }
            checked { ++num3; }
          }
        }
        else if (Operators.CompareString(Modifier, "&TAE2", false) == 0)
        {
          int ai = FNIScommon1.FNIScommon.GetAI(BlockType, OuterIndex);
          str1 = "";
          int num1 = -1;
          int num2 = checked (FNIScommon1.FNIScommon.AnimNumAE[ai] - 1);
          int num3 = 0;
          while (num3 <= num2)
          {
            int num4 = FNIScommon1.FNIScommon.AnimAEEvent[checked (FNIScommon1.FNIScommon.AnimAE[ai] + num3)];
            if (Operators.CompareString(Strings.Left(num4 >= 0 ? FNIScommon1.FNIScommon.AllAE[checked (FNIScommon1.FNIScommon.AllAEfirst[BehaviorType] + num4)] : FNIScommon1.FNIScommon.CustomAE[BehaviorType, checked (-num4 - 1)], 2), "2_", false) == 0)
              checked { ++num1; }
            if (num1 == BlockIndex)
            {
              if (num4 < 0)
                num4 = checked (FNIScommon1.FNIScommon.AE1_trigger - num4 - 1);
              str1 = Strings.Format((object) num4, "0");
              num3 = FNIScommon1.FNIScommon.AnimNumAE[ai];
            }
            checked { ++num3; }
          }
        }
        else if (Operators.CompareString(Modifier, "&TT", false) == 0)
        {
          int ai = FNIScommon1.FNIScommon.GetAI(BlockType, OuterIndex);
          str1 = FNIScommon1.FNIScommon.AnimAETime[checked (FNIScommon1.FNIScommon.AnimAE[ai] + BlockIndex)];
        }
        else if (Operators.CompareString(Modifier, "&TT1", false) == 0)
        {
          int ai = FNIScommon1.FNIScommon.GetAI(BlockType, OuterIndex);
          str1 = "";
          int num1 = -1;
          int num2 = checked (FNIScommon1.FNIScommon.AnimNumAE[ai] - 1);
          int num3 = 0;
          while (num3 <= num2)
          {
            int num4 = FNIScommon1.FNIScommon.AnimAEEvent[checked (FNIScommon1.FNIScommon.AnimAE[ai] + num3)];
            if (Operators.CompareString(Strings.Left(num4 >= 0 ? FNIScommon1.FNIScommon.AllAE[checked (FNIScommon1.FNIScommon.AllAEfirst[BehaviorType] + num4)] : FNIScommon1.FNIScommon.CustomAE[BehaviorType, checked (-num4 - 1)], 2), "2_", false) != 0)
              checked { ++num1; }
            if (num1 == BlockIndex)
            {
              str1 = FNIScommon1.FNIScommon.AnimAETime[checked (FNIScommon1.FNIScommon.AnimAE[ai] + num3)];
              num3 = FNIScommon1.FNIScommon.AnimNumAE[ai];
            }
            checked { ++num3; }
          }
        }
        else if (Operators.CompareString(Modifier, "&TT2", false) == 0)
        {
          int ai = FNIScommon1.FNIScommon.GetAI(BlockType, OuterIndex);
          str1 = "";
          int num1 = -1;
          int num2 = checked (FNIScommon1.FNIScommon.AnimNumAE[ai] - 1);
          int num3 = 0;
          while (num3 <= num2)
          {
            int num4 = FNIScommon1.FNIScommon.AnimAEEvent[checked (FNIScommon1.FNIScommon.AnimAE[ai] + num3)];
            if (Operators.CompareString(Strings.Left(num4 >= 0 ? FNIScommon1.FNIScommon.AllAE[checked (FNIScommon1.FNIScommon.AllAEfirst[BehaviorType] + num4)] : FNIScommon1.FNIScommon.CustomAE[BehaviorType, checked (-num4 - 1)], 2), "2_", false) == 0)
              checked { ++num1; }
            if (num1 == BlockIndex)
            {
              str1 = FNIScommon1.FNIScommon.AnimAETime[checked (FNIScommon1.FNIScommon.AnimAE[ai] + num3)];
              num3 = FNIScommon1.FNIScommon.AnimNumAE[ai];
            }
            checked { ++num3; }
          }
        }
        else if (Operators.CompareString(Modifier, "&TT-", false) == 0)
        {
          int ai = FNIScommon1.FNIScommon.GetAI(BlockType, OuterIndex);
          str1 = Operators.CompareString(Strings.Left(FNIScommon1.FNIScommon.AnimAETime[checked (FNIScommon1.FNIScommon.AnimAE[ai] + BlockIndex)], 1), "-", false) != 0 ? "false" : "true";
        }
        else if (Operators.CompareString(Strings.Left(Modifier, 4), "AVia", false) == 0)
        {
          int ai = FNIScommon1.FNIScommon.GetAI(BlockType, BlockIndex);
          int integer = Conversions.ToInteger(Strings.Mid(Modifier, 5));
          str1 = !(FNIScommon1.FNIScommon.AnimNumAV[ai] >= integer & FNIScommon1.FNIScommon.AnimAVinvers[checked (FNIScommon1.FNIScommon.AnimAV[ai] + integer)]) ? "false" : "true";
        }
        else if (Operators.CompareString(Strings.Left(Modifier, 3), "MRD", false) == 0)
        {
          // ISSUE: variable of a compiler-generated type
          FNIScommon1.FNIScommon._Closure\u0024__271\u002D0 closure2710_1;
          // ISSUE: object of a compiler-generated type is created
          // ISSUE: variable of a compiler-generated type
          FNIScommon1.FNIScommon._Closure\u0024__271\u002D0 closure2710_2 = new FNIScommon1.FNIScommon._Closure\u0024__271\u002D0(closure2710_1);
          string[] strArray = Strings.Split(Strings.Mid(Modifier, 4), ".", -1, CompareMethod.Binary);
          // ISSUE: reference to a compiler-generated field
          closure2710_2.\u0024VB\u0024Local_BO = Conversions.ToInteger(strArray[0]);
          str1 = "";
          if (Information.UBound((Array) strArray, 1) == 1)
          {
            // ISSUE: reference to a compiler-generated field
            if (FNIScommon1.FNIScommon.MRD_BO_nAnims[closure2710_2.\u0024VB\u0024Local_BO] == 0)
              str1 = " ";
            else if (Operators.CompareString(strArray[1], "1", false) == 0)
            {
              // ISSUE: reference to a compiler-generated method
              List<FNIScommon1.FNIScommon.MRD_Data> all = FNIScommon1.FNIScommon.MRD_DataListALL.FindAll(new Predicate<FNIScommon1.FNIScommon.MRD_Data>(closure2710_2._Lambda\u0024__0));
              // ISSUE: reference to a compiler-generated field
              if (all.Count != FNIScommon1.FNIScommon.MRD_BO_nAnims[closure2710_2.\u0024VB\u0024Local_BO])
              {
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated field
                FNIScommon1.FNIScommon.WriteWarning("INCONSISTENT MR Data for " + FNIScommon1.FNIScommon.BO_List[closure2710_2.\u0024VB\u0024Local_BO] + ": should" + Conversion.Str((object) FNIScommon1.FNIScommon.MRD_BO_nAnims[closure2710_2.\u0024VB\u0024Local_BO]) + " is" + Conversion.Str((object) all.Count));
              }
              List<FNIScommon1.FNIScommon.MRD_Data>.Enumerator enumerator;
              try
              {
                enumerator = all.GetEnumerator();
                while (enumerator.MoveNext())
                {
                  FNIScommon1.FNIScommon.MRD_Data current = enumerator.Current;
                  if (Operators.CompareString(str1, "", false) != 0)
                    str1 += "\r\n";
                  str1 = str1 + "\r\n" + current.clipGenName + "\r\n" + Strings.Format((object) current.currAnim, "") + "\r\n1\r\n0\r\n0\r\n0";
                }
              }
              finally
              {
                enumerator.Dispose();
              }
            }
            else
            {
              int num1 = -1;
              string Left = "";
              string str2 = "";
              string str3 = "";
              string str4 = "";
              // ISSUE: reference to a compiler-generated method
              List<FNIScommon1.FNIScommon.MRD_Data> all = FNIScommon1.FNIScommon.MRD_DataListALL.FindAll(new Predicate<FNIScommon1.FNIScommon.MRD_Data>(closure2710_2._Lambda\u0024__1));
              List<FNIScommon1.FNIScommon.MRD_Data>.Enumerator enumerator;
              int num2;
              int num3;
              try
              {
                enumerator = all.GetEnumerator();
                while (enumerator.MoveNext())
                {
                  FNIScommon1.FNIScommon.MRD_Data current = enumerator.Current;
                  if (current.currAnim != num1)
                  {
                    if (Operators.CompareString(Left, "", false) != 0)
                    {
                      str4 = str4 + "\r\n" + Strings.Format((object) num1, "") + "\r\n" + str3 + "\r\n" + Strings.Format((object) num2, "") + Left + "\r\n" + Strings.Format((object) num3, "") + str2 + "\r\n";
                      Left = "";
                      str2 = "";
                      num2 = 0;
                      num3 = 0;
                    }
                    num1 = current.currAnim;
                  }
                  if (current.isMD)
                  {
                    str3 = [email protected][0];
                    Left = Left + "\r\n" + Strings.Join([email protected], " ");
                    checked { ++num2; }
                  }
                  else
                  {
                    str2 = str2 + "\r\n" + Strings.Join([email protected], " ");
                    checked { ++num3; }
                  }
                }
              }
              finally
              {
                enumerator.Dispose();
              }
              str1 = str4 + "\r\n" + Strings.Format((object) num1, "") + "\r\n" + str3 + "\r\n" + Strings.Format((object) num2, "") + Left + "\r\n" + Strings.Format((object) num3, "") + str2;
            }
          }
        }
        else if (Operators.CompareString(Strings.Left(Modifier, 4), "&aaT", false) == 0)
        {
          str1 = "XXX>" + Modifier + "<XXX";
          string[] strArray1 = Strings.Split(Modifier, ".", -1, CompareMethod.Binary);
          string Left = strArray1[0];
          string Right = strArray1[1];
          int integer = Conversions.ToInteger(strArray1[2]);
          int num1 = checked (FNISaa1.FNISaa.iAAGroup - 1);
          int index = 0;
          bool flag;
          int num2;
          while (index <= num1)
          {
            if (Operators.CompareString(FNISaa1.FNISaa.AAGroup[index], Right, false) == 0)
            {
              flag = true;
              num2 = index;
              index = FNISaa1.FNISaa.iAAGroup;
            }
            checked { ++index; }
          }
          if (!flag)
          {
            str1 = "";
          }
          else
          {
            int num3 = -1;
            int num4 = Information.UBound((Array) FNISaa1.FNISaa.AATriggerArray, 1);
            int iTrigger = 0;
            while (iTrigger <= num4)
            {
              if (FNISaa1.FNISaa.AATriggerArray[iTrigger].iAnim == integer & FNISaa1.FNISaa.AATriggerArray[iTrigger].group == num2 && FNISaa1.FNISaa.AATriggerArray[iTrigger].setIndex > 0)
              {
                checked { ++num3; }
                if (OuterIndex == num3)
                {
                  FNISaa1.FNISaa.GetTemplateSpecificTriggerdefs(iTrigger);
                  string[] strArray2 = Strings.Split(FNISaa1.FNISaa.AATriggerArray[iTrigger].CurrentTriggers, "/", -1, CompareMethod.Binary);
                  if (FNISaa1.FNISaa.AATriggerArray[iTrigger].CurrentnTriggers <= BlockIndex)
                    str1 = "xxx";
                  else if (Operators.CompareString(Left, "&aaTt", false) == 0)
                    str1 = strArray2[checked (BlockIndex * 2 + 1)];
                  else if (Operators.CompareString(Left, "&aaTe", false) == 0)
                    str1 = strArray2[checked (BlockIndex * 2)];
                  else if (Operators.CompareString(Left, "&aaTt-", false) == 0)
                    str1 = Operators.CompareString(Strings.Left(strArray2[checked (BlockIndex * 2 + 1)], 1), "-", false) != 0 ? "false" : "true";
                  iTrigger = 9999;
                }
              }
              checked { ++iTrigger; }
            }
          }
        }
        else if (Operators.CompareString(Strings.Left(Modifier, 4), "aap.", false) == 0)
        {
          string[] strArray = Strings.Split(Modifier, ".", -1, CompareMethod.Binary);
          string Right = strArray[1];
          int integer = Conversions.ToInteger(strArray[2]);
          bool flag = false;
          int num1 = checked (FNISaa1.FNISaa.iAAGroup - 1);
          int index1 = 0;
          while (index1 <= num1)
          {
            if (Operators.CompareString(FNISaa1.FNISaa.AAGroup[index1], Right, false) == 0)
            {
              flag = true;
              str1 = "Animations\\";
              if (BlockIndex == 0)
              {
                if (Operators.CompareString(FNISaa1.FNISaa.AAPath[FNISaa1.FNISaa.AAAnimIndex[index1]], "", false) != 0)
                  str1 = str1 + FNISaa1.FNISaa.AAPath[FNISaa1.FNISaa.AAAnimIndex[index1]] + "\\";
                else if (Information.UBound((Array) strArray, 1) == 3)
                  str1 = str1 + strArray[3] + "\\";
              }
              else
              {
                int index2 = checked (BlockIndex - 1);
                int num2 = checked (FNISaa1.FNISaa.iAASet - 1);
                int index3 = 0;
                while (index3 <= num2)
                {
                  if (FNISaa1.FNISaa.AASet[index3].group == index1)
                  {
                    if (index2 < FNISaa1.FNISaa.AASet[index3].nGroups)
                    {
                      if ((FNISaa1.FNISaa.AASet[index3].defPattern[index2] & (ulong) (1L << integer)) > 0UL)
                      {
                        str1 = str1 + FNIScommon1.FNIScommon.MyMod[FNISaa1.FNISaa.AASet[index3].imod] + "\\" + FNISaa1.FNISaa.AAPrefix[FNISaa1.FNISaa.AASet[index3].iPrefix] + Conversions.ToString(index2) + "_";
                        // ISSUE: explicit reference operation
                        // ISSUE: variable of a reference type
                        FNISaa1.FNISaa.AASetType& local = @FNISaa1.FNISaa.AASet[index3];
                        int num3 = checked (FNISaa1.FNISaa.AASet[index3].imod - 1);
                        if (FNIScommon1.FNIScommon.DebugOutput > 2)
                          FNIScommon1.FNIScommon.LogOutput(" AA found. mod: " + FNIScommon1.FNIScommon.MyMod[FNISaa1.FNISaa.AASet[index3].imod] + "/" + FNISaa1.FNISaa.AAPrefix[FNISaa1.FNISaa.AASet[index3].iPrefix] + " index: " + Strings.Format((object) index2, "") + " pattern: " + Conversion.Hex(FNISaa1.FNISaa.AASet[index3].defPattern[index2]), false, true);
                      }
                      else
                      {
                        if (Information.UBound((Array) strArray, 1) == 3)
                          str1 = str1 + strArray[3] + "\\";
                        if (FNIScommon1.FNIScommon.DebugOutput > 1)
                          FNIScommon1.FNIScommon.LogOutput(" AA not found. mod: " + FNIScommon1.FNIScommon.MyMod[FNISaa1.FNISaa.AASet[index3].imod] + "/" + FNISaa1.FNISaa.AAPrefix[FNISaa1.FNISaa.AASet[index3].iPrefix] + " index: " + Strings.Format((object) index2, "") + " pattern: " + Conversion.Hex(FNISaa1.FNISaa.AASet[index3].defPattern[index2]), false, true);
                      }
                      index3 = checked (FNISaa1.FNISaa.iAASet + 1);
                    }
                    else
                      checked { index2 -= FNISaa1.FNISaa.AASet[index3].nGroups; }
                  }
                  checked { ++index3; }
                }
              }
              index1 = checked (FNISaa1.FNISaa.iAAGroup + 1);
            }
            checked { ++index1; }
          }
          if (!flag)
            FNIScommon1.FNIScommon.LogOutput("AA group not found (-aap): " + Right, true, true);
        }
        else if (Operators.CompareString(Strings.Left(Modifier, 1), "-", false) == 0)
        {
          if (Strings.InStr(Modifier, "/", CompareMethod.Binary) > 0)
          {
            string[] SourceArray = Strings.Split(Modifier, "/", -1, CompareMethod.Binary);
            if (Information.UBound((Array) SourceArray, 1) % 3 != 0)
            {
              FNIScommon1.FNIScommon.ErrInt = CurrentLine;
              FNIScommon1.FNIScommon.ErrString = FNIScommon1.FNIScommon.CurrentTemplate;
              Information.Err().Raise(2008, (object) null, (object) null, (object) null, (object) null);
            }
            int num1 = Information.UBound((Array) SourceArray, 1);
            int index = 1;
            while (index <= num1)
            {
              int num2 = FNIScommon1.FNIScommon.EvalExpression(SourceArray[index], BlockIndex, OuterIndex, BlockType, BehaviorType);
              int num3 = FNIScommon1.FNIScommon.EvalExpression(SourceArray[checked (index + 1)], BlockIndex, OuterIndex, BlockType, BehaviorType);
              SourceArray[index] = Strings.Format((object) checked (num2 + num3 * BlockIndex), "0");
              SourceArray[checked (index + 1)] = "";
              checked { index += 3; }
            }
            Modifier = Strings.Join(SourceArray, "");
          }
          ulong AnimOption = Operators.CompareString(BlockType, "", false) == 0 ? 1UL : FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(BlockType, BlockIndex)];
          string[] strArray = Strings.Split(Strings.Mid(Modifier, 2), "|", -1, CompareMethod.Binary);
          if (Information.UBound((Array) strArray, 1) % 2 == 1)
            str1 = "";
          else if (Information.UBound((Array) strArray, 1) == 0)
          {
            ulong options = FNIScommon1.FNIScommon.GetOptions(strArray[0], FNIScommon1.FNIScommon.CurrentTemplate, -1);
            str1 = strArray[Information.UBound((Array) strArray, 1)];
            if (Information.UBound((Array) strArray, 1) == 0)
              str1 = !(FNIScommon1.FNIScommon.Has_Option(options, "B") & FNIScommon1.FNIScommon.Has_Option(AnimOption, "B")) ? (!(FNIScommon1.FNIScommon.Has_Option(options, "D") & FNIScommon1.FNIScommon.Has_Option(AnimOption, "D")) ? "" : FNIScommon1.FNIScommon.BlendList[FNIScommon1.FNIScommon.AnimBlend[FNIScommon1.FNIScommon.GetAI(BlockType, BlockIndex)]]) : FNIScommon1.FNIScommon.BlendList[FNIScommon1.FNIScommon.AnimBlend[FNIScommon1.FNIScommon.GetAI(BlockType, BlockIndex)]];
          }
          else
          {
            bool flag = false;
            if (Decimal.Compare(new Decimal(AnimOption), Decimal.Zero) > 0)
            {
              int num = checked (Information.UBound((Array) strArray, 1) - 2);
              int index = 0;
              while (index <= num)
              {
                if (Strings.Len(strArray[index]) < 4 | Strings.InStr(strArray[index], ",", CompareMethod.Binary) > 0)
                {
                  ulong options = FNIScommon1.FNIScommon.GetOptions(strArray[index], FNIScommon1.FNIScommon.CurrentTemplate, -1);
                  if ((long) options == ((long) options & (long) AnimOption))
                  {
                    str1 = strArray[checked (index + 1)];
                    index = checked (Information.UBound((Array) strArray, 1) + 1);
                    flag = true;
                  }
                }
                else if (FNIScommon1.FNIScommon.EvalExpression(strArray[index], BlockIndex, OuterIndex, BlockType, BehaviorType) > 0)
                {
                  str1 = strArray[checked (index + 1)];
                  index = checked (Information.UBound((Array) strArray, 1) + 1);
                  flag = true;
                }
                checked { index += 2; }
              }
            }
            if (!flag)
              str1 = strArray[Information.UBound((Array) strArray, 1)];
            if (Strings.InStr(str1, "%", CompareMethod.Binary) > 0)
            {
              string[] SourceArray = Strings.Split(str1, "%", -1, CompareMethod.Binary);
              if (Information.UBound((Array) SourceArray, 1) == 2)
              {
                SourceArray[1] = Strings.Format((object) FNIScommon1.FNIScommon.EvalExpression(SourceArray[1], BlockIndex, OuterIndex, BlockType, BehaviorType), "0");
                str1 = Strings.Join(SourceArray, "");
              }
            }
          }
        }
        else if (Strings.InStr(Modifier, "/", CompareMethod.Binary) > 0)
        {
          string[] strArray = Strings.Split(Modifier, "/", -1, CompareMethod.Binary);
          int num1 = FNIScommon1.FNIScommon.EvalExpression(strArray[0], BlockIndex, OuterIndex, BlockType, BehaviorType);
          int num2 = Operators.CompareString(strArray[1], "", false) != 0 ? FNIScommon1.FNIScommon.EvalExpression(strArray[1], BlockIndex, OuterIndex, BlockType, BehaviorType) : FNIScommon1.FNIScommon.RecIncrement;
          if (num1 >= 0 & num2 >= 0)
          {
            str1 = Strings.Format((object) checked (num1 + BlockIndex * num2), "0");
          }
          else
          {
            FNIScommon1.FNIScommon.ErrInt = CurrentLine;
            FNIScommon1.FNIScommon.ErrString = FNIScommon1.FNIScommon.CurrentTemplate;
            Information.Err().Raise(2007, (object) null, (object) null, (object) null, (object) null);
          }
        }
        else
        {
          string[] strArray = Strings.Split(Modifier, ":", -1, CompareMethod.Binary);
          if (Information.UBound((Array) strArray, 1) == 2)
          {
            int num1 = FNIScommon1.FNIScommon.EvalExpression(strArray[2], BlockIndex, OuterIndex, BlockType, BehaviorType);
            int index1 = -1;
            int num2 = checked (FNIScommon1.FNIScommon.SymAddrInd - 1);
            int index2 = 0;
            while (index2 <= num2)
            {
              if (Operators.CompareString(FNIScommon1.FNIScommon.SymAddr[index2], strArray[1], false) == 0)
                index1 = index2;
              checked { ++index2; }
            }
            if (index1 < 0 & FNIScommon1.FNIScommon.SymAddrInd <= Information.UBound((Array) FNIScommon1.FNIScommon.SymAddr, 1))
            {
              FNIScommon1.FNIScommon.SymAddr[FNIScommon1.FNIScommon.SymAddrInd] = strArray[1];
              index1 = FNIScommon1.FNIScommon.SymAddrInd;
              checked { ++FNIScommon1.FNIScommon.SymAddrInd; }
            }
            if (index1 >= 0)
              FNIScommon1.FNIScommon.SymAddrVal[index1] = num1;
            str1 = Strings.Format((object) num1, "0");
          }
          else
            str1 = Operators.CompareString(Modifier, "BT", false) != 0 ? Strings.Format((object) FNIScommon1.FNIScommon.EvalExpression(Modifier, BlockIndex, OuterIndex, BlockType, BehaviorType), "0") : FNIScommon1.FNIScommon.BlendList[BlockIndex];
        }
        if (Operators.CompareString(str1, "", false) == 0 | Operators.CompareString(str1, "-1", false) == 0)
        {
          FNIScommon1.FNIScommon.ErrInt = CurrentLine;
          FNIScommon1.FNIScommon.ErrString = FNIScommon1.FNIScommon.CurrentTemplate;
          Information.Err().Raise(2008, (object) null, (object) null, (object) null, (object) null);
        }
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("EvalModifier", 0, "Return: " + str1, "");
        return str1;
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static int GetAI(string CAnimType, int Index)
      {
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("GetAI", 1, "CAnimType: " + CAnimType + " Index:" + Conversion.Str((object) Index), "");
        int index = 0;
        int num = 0;
        bool flag;
        while (index < FNIScommon1.FNIScommon.AnzAnim & !flag)
        {
          if (Operators.CompareString(CAnimType, FNIScommon1.FNIScommon.AnimType[index], false) == 0)
          {
            if (Index != num)
              checked { ++num; }
            else
              goto label_9;
          }
          checked { ++index; }
        }
        FNIScommon1.FNIScommon.ErrInt = FNIScommon1.FNIScommon.CurrentLine;
        FNIScommon1.FNIScommon.ErrString = FNIScommon1.FNIScommon.CurrentTemplate;
        Information.Err().Raise(2007, (object) null, (object) null, (object) null, (object) null);
label_9:
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("GetAI", 0, "Return:" + Conversion.Str((object) index), "");
        return index;
      }

      public static int EvalExpression(string CountString, int BlockIndex, int OuterIndex, string CurrentBlockType, int BehaviorType)
      {
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("EvalExpression", 1, "Expr: " + CountString + " BlockIndex:" + Conversion.Str((object) BlockIndex) + " Outerindex:" + Conversion.Str((object) OuterIndex) + " Curr.BlockType: " + CurrentBlockType, "");
        string[] strArray1 = Strings.Split(CountString, "+", -1, CompareMethod.Binary);
        int num1;
        int num2;
        if (Operators.CompareString(strArray1[0], "RI", false) == 0)
        {
          num1 = FNIScommon1.FNIScommon.RecIndex;
          if (Information.UBound((Array) strArray1, 1) > 0)
          {
            int index = !Versioned.IsNumeric((object) strArray1[1]) ? FNIScommon1.FNIScommon.EvalExpression(Strings.Mid(CountString, 4), BlockIndex, OuterIndex, CurrentBlockType, BehaviorType) : Conversions.ToInteger(strArray1[1]);
            if (FNIScommon1.FNIScommon.IsOptimizedBlock == 1)
            {
              if (FNIScommon1.FNIScommon.OptimizedIndex[index] == 0)
              {
                checked { ++FNIScommon1.FNIScommon.OptimizedCount; }
                FNIScommon1.FNIScommon.OptimizedIndex[index] = FNIScommon1.FNIScommon.OptimizedCount;
              }
              index = FNIScommon1.FNIScommon.OptimizedIndex[index];
            }
            checked { num1 += index; }
          }
        }
        else
        {
          num1 = 0;
          int num3 = Information.UBound((Array) strArray1, 1);
          int index1 = 0;
          while (index1 <= num3)
          {
            int num4 = 0;
            string[] strArray2 = Strings.Split(strArray1[index1], "*", -1, CompareMethod.Binary);
            int num5;
            if (Information.UBound((Array) strArray2, 1) == 1)
            {
              num5 = Conversions.ToInteger(strArray2[0]);
              strArray1[index1] = strArray2[1];
            }
            else
              num5 = 1;
            if (Versioned.IsNumeric((object) strArray1[index1]))
              num4 = Conversions.ToInteger(strArray1[index1]);
            else if (Operators.CompareString(strArray1[index1], "b", false) == 0)
              num4 = FNIScommon1.FNIScommon.Anz_b;
            else if (Operators.CompareString(strArray1[index1], "s", false) == 0)
              num4 = FNIScommon1.FNIScommon.Anz_s;
            else if (Operators.CompareString(strArray1[index1], "c", false) == 0)
              num4 = checked (FNIScommon1.FNIScommon.Anz_b + FNIScommon1.FNIScommon.Anz_s);
            else if (Operators.CompareString(strArray1[index1], "sg", false) == 0)
              num4 = FNIScommon1.FNIScommon.Anz_sG;
            else if (Operators.CompareString(strArray1[index1], "fu", false) == 0)
              num4 = FNIScommon1.FNIScommon.Anz_fu;
            else if (Operators.CompareString(strArray1[index1], "fug", false) == 0)
              num4 = FNIScommon1.FNIScommon.Anz_fuG;
            else if (Operators.CompareString(strArray1[index1], "ofa", false) == 0)
              num4 = FNIScommon1.FNIScommon.Anz_ofa;
            else if (Operators.CompareString(strArray1[index1], "pa", false) == 0)
              num4 = FNIScommon1.FNIScommon.Anz_pa;
            else if (Operators.CompareString(strArray1[index1], "km", false) == 0)
              num4 = FNIScommon1.FNIScommon.Anz_km;
            else if (Operators.CompareString(strArray1[index1], "chg", false) == 0)
              num4 = FNIScommon1.FNIScommon.Anz_chG;
            else if (Operators.CompareString(strArray1[index1], "aae", false) == 0)
              num4 = FNIScommon1.FNIScommon.CustomAEnum[BehaviorType];
            else if (Operators.CompareString(strArray1[index1], "AO", false) == 0)
              num4 = FNIScommon1.FNIScommon.Anz_AO[BehaviorType];
            else if (Operators.CompareString(strArray1[index1], "?b", false) == 0)
            {
              if (FNIScommon1.FNIScommon.Anz_b > 0)
                num4 = 1;
            }
            else if (Operators.CompareString(strArray1[index1], "?c", false) == 0)
            {
              if (checked (FNIScommon1.FNIScommon.Anz_b + FNIScommon1.FNIScommon.Anz_s) > 0)
                num4 = 1;
            }
            else if (Operators.CompareString(strArray1[index1], "?o-", false) == 0)
            {
              if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex)], "o-"))
                num4 = 1;
            }
            else if (Operators.CompareString(strArray1[index1], "?oo", false) == 0)
            {
              if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex)], "o+"))
                num4 = 1;
            }
            else if (Operators.CompareString(strArray1[index1], "?h-", false) == 0)
            {
              if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex)], "h-"))
                num4 = 1;
            }
            else if (Operators.CompareString(strArray1[index1], "?h", false) == 0)
            {
              if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex)], "h+"))
                num4 = 1;
            }
            else if (Operators.CompareString(strArray1[index1], "?F", false) == 0)
            {
              if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex)], "F"))
                num4 = 1;
            }
            else if (Operators.CompareString(strArray1[index1], "?L", false) == 0)
            {
              if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex)], "L"))
                num4 = 1;
            }
            else if (Operators.CompareString(strArray1[index1], "?a", false) == 0)
            {
              if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex)], "a"))
                num4 = 1;
            }
            else if (Operators.CompareString(strArray1[index1], "?ac1", false) == 0)
            {
              if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex)], "ac") | FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex)], "ac1"))
                num4 = 1;
            }
            else if (Operators.CompareString(strArray1[index1], "?ac0", false) == 0)
            {
              if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex)], "ac") | FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex)], "ac0"))
                num4 = 1;
            }
            else if (Operators.CompareString(strArray1[index1], "?mdz", false) == 0)
            {
              if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex)], "mdz"))
                num4 = 1;
            }
            else if (Operators.CompareString(Strings.Left(strArray1[index1], 3), "AE1", false) == 0)
            {
              string Left = Strings.Mid(strArray1[index1], 4);
              if (Operators.CompareString(Left, "c", false) == 0)
                num4 = FNIScommon1.FNIScommon.AE1_c;
              else if (Operators.CompareString(Left, "b", false) == 0)
                num4 = FNIScommon1.FNIScommon.AE1_b;
              else if (Operators.CompareString(Left, "s", false) == 0)
                num4 = FNIScommon1.FNIScommon.AE1_s;
              else if (Operators.CompareString(Left, "sgf", false) == 0)
                num4 = FNIScommon1.FNIScommon.AE1_sgf;
              else if (Operators.CompareString(Left, "sgl", false) == 0)
                num4 = FNIScommon1.FNIScommon.AE1_sgl;
              else if (Operators.CompareString(Left, "fu", false) == 0)
                num4 = FNIScommon1.FNIScommon.AE1_fu;
              else if (Operators.CompareString(Left, "fug", false) == 0)
                num4 = FNIScommon1.FNIScommon.AE1_fuG;
              else if (Operators.CompareString(Left, "ofa", false) == 0)
                num4 = FNIScommon1.FNIScommon.AE1_ofa;
              else if (Operators.CompareString(Left, "aa", false) == 0)
                num4 = FNIScommon1.FNIScommon.AE1_aa;
              else if (Operators.CompareString(Left, "pa", false) == 0)
                num4 = FNIScommon1.FNIScommon.AE1_pa;
              else if (Operators.CompareString(Left, "km", false) == 0)
                num4 = FNIScommon1.FNIScommon.AE1_km;
              else if (Operators.CompareString(Left, "chg", false) == 0)
                num4 = FNIScommon1.FNIScommon.AE1_chG;
              else if (Operators.CompareString(Left, "trigger", false) == 0)
              {
                num4 = FNIScommon1.FNIScommon.AE1_trigger;
              }
              else
              {
                num2 = -1;
                goto label_270;
              }
            }
            else if (Operators.CompareString(strArray1[index1], "ao", false) == 0 | Operators.CompareString(strArray1[index1], "ao1", false) == 0 | Operators.CompareString(strArray1[index1], "ao2", false) == 0)
            {
              int ai = FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex);
              if (Operators.CompareString(strArray1[index1], "ao", false) == 0)
              {
                num4 = FNIScommon1.FNIScommon.nAO[ai];
              }
              else
              {
                int num6 = checked (FNIScommon1.FNIScommon.nAO[ai] - 1);
                int num7 = 0;
                while (num7 <= num6)
                {
                  if (Operators.CompareString(strArray1[index1], "ao1", false) == 0 == FNIScommon1.FNIScommon.AOfirst[checked (FNIScommon1.FNIScommon.firstAO[ai] + num7)])
                    checked { ++num4; }
                  checked { ++num7; }
                }
              }
            }
            else if (Operators.CompareString(strArray1[index1], "&ao", false) == 0 | Operators.CompareString(strArray1[index1], "&ao1", false) == 0 | Operators.CompareString(strArray1[index1], "&ao2", false) == 0)
            {
              int ai = FNIScommon1.FNIScommon.GetAI(CurrentBlockType, OuterIndex);
              if (Operators.CompareString(strArray1[index1], "&ao", false) == 0)
              {
                num4 = FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[ai] + BlockIndex)];
              }
              else
              {
                int num6 = -1;
                int num7 = checked (FNIScommon1.FNIScommon.nAO[ai] - 1);
                int num8 = 0;
                while (num8 <= num7)
                {
                  if (Operators.CompareString(strArray1[index1], "&ao1", false) == 0 == FNIScommon1.FNIScommon.AOfirst[checked (FNIScommon1.FNIScommon.firstAO[ai] + num8)])
                  {
                    checked { ++num6; }
                    if (num6 == BlockIndex)
                    {
                      checked { num4 += FNIScommon1.FNIScommon.AOList[FNIScommon1.FNIScommon.firstAO[ai] + num8]; }
                      num8 = FNIScommon1.FNIScommon.nAO[ai];
                    }
                  }
                  checked { ++num8; }
                }
              }
            }
            else if (Operators.CompareString(strArray1[index1], "T", false) == 0)
            {
              int ai = FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex);
              num4 = FNIScommon1.FNIScommon.AnimNumAE[ai];
            }
            else if (Operators.CompareString(strArray1[index1], "T1", false) == 0)
            {
              int ai = FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex);
              int num6 = checked (FNIScommon1.FNIScommon.AnimNumAE[ai] - 1);
              int num7 = 0;
              while (num7 <= num6)
              {
                int num8 = FNIScommon1.FNIScommon.AnimAEEvent[checked (FNIScommon1.FNIScommon.AnimAE[ai] + num7)];
                if (Operators.CompareString(Strings.Left(num8 >= 0 ? FNIScommon1.FNIScommon.AllAE[checked (FNIScommon1.FNIScommon.AllAEfirst[BehaviorType] + num8)] : FNIScommon1.FNIScommon.CustomAE[BehaviorType, checked (-num8 - 1)], 2), "2_", false) != 0)
                  checked { ++num4; }
                checked { ++num7; }
              }
            }
            else if (Operators.CompareString(strArray1[index1], "T2", false) == 0)
            {
              int ai = FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex);
              int num6 = checked (FNIScommon1.FNIScommon.AnimNumAE[ai] - 1);
              int num7 = 0;
              while (num7 <= num6)
              {
                int num8 = FNIScommon1.FNIScommon.AnimAEEvent[checked (FNIScommon1.FNIScommon.AnimAE[ai] + num7)];
                if (Operators.CompareString(Strings.Left(num8 >= 0 ? FNIScommon1.FNIScommon.AllAE[checked (FNIScommon1.FNIScommon.AllAEfirst[BehaviorType] + num8)] : FNIScommon1.FNIScommon.CustomAE[BehaviorType, checked (-num8 - 1)], 2), "2_", false) == 0)
                  checked { ++num4; }
                checked { ++num7; }
              }
            }
            else if (Operators.CompareString(strArray1[index1], "AV", false) == 0)
            {
              int ai = FNIScommon1.FNIScommon.GetAI(CurrentBlockType, BlockIndex);
              num4 = FNIScommon1.FNIScommon.AnimNumAV[ai];
            }
            else if (Operators.CompareString(strArray1[index1], "&AVI", false) == 0)
            {
              int ai = FNIScommon1.FNIScommon.GetAI(CurrentBlockType, OuterIndex);
              int num6 = FNIScommon1.FNIScommon.AnimAVid[checked (FNIScommon1.FNIScommon.AnimAV[ai] + BlockIndex)];
              if (num6 >= 0)
                checked { num4 += num6; }
              else
                checked { num1 += FNIScommon1.FNIScommon.AllAVnum[BehaviorType] - num6 - 1; }
            }
            else if (Operators.CompareString(strArray1[index1], "&fu", false) == 0)
              num4 = FNIScommon1.FNIScommon.Get_AnimStats("fu", -1, BlockIndex, 1);
            else if (Operators.CompareString(strArray1[index1], "&&fu", false) == 0)
              num4 = FNIScommon1.FNIScommon.Get_AnimStats("fu", BlockIndex, -1, 1);
            else if (Operators.CompareString(strArray1[index1], "&fug", false) == 0)
              num4 = FNIScommon1.FNIScommon.Get_AnimStats("fu", -1, BlockIndex, 4);
            else if (Operators.CompareString(strArray1[index1], "!fu", false) == 0)
              num4 = FNIScommon1.FNIScommon.Get_AnimStats("fu", OuterIndex, BlockIndex, 3);
            else if (Operators.CompareString(strArray1[index1], "%fu", false) == 0)
              num4 = OuterIndex <= -1 ? FNIScommon1.FNIScommon.Get_AnimStats("fu", BlockIndex, 0, 2) : FNIScommon1.FNIScommon.Get_AnimStats("fu", OuterIndex, BlockIndex, 2);
            else if (Operators.CompareString(strArray1[index1], ".fu", false) == 0)
              num4 = FNIScommon1.FNIScommon.Get_AnimStats("fu", -1, BlockIndex, 5);
            else if (Operators.CompareString(Strings.Left(strArray1[index1], 4), "aan.", false) == 0)
            {
              if (FNISaa1.FNISaa.isAADataRead)
              {
                string Right = Strings.Mid(strArray1[index1], 5);
                int num6 = checked (FNISaa1.FNISaa.iAAGroup - 1);
                int index2 = 0;
                bool flag;
                while (index2 <= num6)
                {
                  if (Operators.CompareString(FNISaa1.FNISaa.AAGroup[index2], Right, false) == 0)
                  {
                    checked { num4 += FNISaa1.FNISaa.AASetsPerGroup[index2] + 1; }
                    index2 = checked (FNISaa1.FNISaa.iAAGroup + 1);
                    flag = true;
                  }
                  checked { ++index2; }
                }
                if (!flag)
                  FNIScommon1.FNIScommon.LogOutput("AA group not found (aan): " + Right, true, true);
              }
            }
            else if (Operators.CompareString(strArray1[index1], "BL", false) == 0)
              num4 = checked (FNIScommon1.FNIScommon.lastBlend + 1);
            else if (Operators.CompareString(strArray1[index1], "&bl", false) == 0)
              num4 = FNIScommon1.FNIScommon.AnimBlend[BlockIndex];
            else if (Operators.CompareString(strArray1[index1], "&s", false) == 0)
              num4 = FNIScommon1.FNIScommon.Get_AnimStats("s", -1, BlockIndex, 1);
            else if (Operators.CompareString(strArray1[index1], "&&s", false) == 0)
              num4 = FNIScommon1.FNIScommon.Get_AnimStats("s", BlockIndex, -1, 1);
            else if (Operators.CompareString(strArray1[index1], "&sg", false) == 0)
              num4 = FNIScommon1.FNIScommon.Get_AnimStats("s", -1, BlockIndex, 4);
            else if (Operators.CompareString(strArray1[index1], "%s", false) == 0)
              num4 = FNIScommon1.FNIScommon.Get_AnimStats("s", OuterIndex, BlockIndex, 2);
            else if (Operators.CompareString(strArray1[index1], "m", false) == 0)
              num4 = FNIScommon1.FNIScommon.AnzMod;
            else if (Operators.CompareString(strArray1[index1], "faa", false) == 0)
            {
              int num6 = checked (FNISaa1.FNISaa.iAASet - 1);
              int index2 = 0;
              while (index2 <= num6)
              {
                checked { num4 += FNISaa1.FNISaa.AASet[index2].nAnims; }
                checked { ++index2; }
              }
            }
            else if (Operators.CompareString(strArray1[index1], "?faa", false) == 0)
            {
              int num6 = checked (FNISaa1.FNISaa.iAASet - 1);
              int index2 = 0;
              while (index2 <= num6)
              {
                if (FNISaa1.FNISaa.AASet[index2].nAnims > 0)
                  num4 = 1;
                checked { ++index2; }
              }
            }
            else if (Operators.CompareString(strArray1[index1], "f", false) == 0)
            {
              int num6 = checked (FNIScommon1.FNIScommon.AnzAnim - 1);
              int index2 = 0;
              while (index2 <= num6)
              {
                if ((uint) Operators.CompareString(FNIScommon1.FNIScommon.AnimFile[index2], "", false) > 0U & !FNIScommon1.FNIScommon.AnimKoption[index2])
                  checked { ++num4; }
                checked { ++index2; }
              }
            }
            else if (Operators.CompareString(strArray1[index1], "PA", false) == 0)
            {
              int patchCount = FNIScommon1.FNIScommon.PatchCount;
              int index2 = 0;
              while (index2 <= patchCount)
              {
                if (FNIScommon1.FNIScommon.isPatch[index2])
                  checked { num4 += FNIScommon1.FNIScommon.PatchAddAnims[index2]; }
                checked { ++index2; }
              }
            }
            else if (Operators.CompareString(strArray1[index1], "&B", false) == 0)
              num4 = (int) FNIScommon1.FNIScommon.TestGeneration <= 0 ? FNIScommon1.FNIScommon.currBones : 99;
            else if (Operators.CompareString(strArray1[index1], "BI", false) == 0)
              num4 = BlockIndex;
            else if (Operators.CompareString(Strings.Left(strArray1[index1], 1), ":", false) == 0)
            {
              int num6 = checked (FNIScommon1.FNIScommon.SymAddrInd - 1);
              int index2 = 0;
              while (index2 <= num6)
              {
                if (Operators.CompareString(Strings.LCase(Strings.Mid(strArray1[index1], 2)), Strings.LCase(FNIScommon1.FNIScommon.SymAddr[index2]), false) == 0)
                {
                  checked { num4 += FNIScommon1.FNIScommon.SymAddrVal[index2]; }
                  index2 = FNIScommon1.FNIScommon.SymAddrInd;
                }
                checked { ++index2; }
              }
            }
            else if (Operators.CompareString(strArray1[index1], "av", false) == 0)
              num4 = FNIScommon1.FNIScommon.AnzAnimVars[BehaviorType];
            else if (Operators.CompareString(Strings.Left(strArray1[index1], 3), "mra", false) == 0)
            {
              int integer = Conversions.ToInteger(Strings.Mid(strArray1[index1], 4));
              if (integer >= 0 & integer < Information.UBound((Array) FNIScommon1.FNIScommon.MRD_BO_nAnims, 1))
              {
                num4 = FNIScommon1.FNIScommon.MRD_BO_nAnims[integer];
              }
              else
              {
                num2 = -1;
                goto label_270;
              }
            }
            else if (Operators.CompareString(Strings.Left(strArray1[index1], 3), "mrd", false) == 0)
            {
              int integer = Conversions.ToInteger(Strings.Mid(strArray1[index1], 4));
              if (integer >= 0 & integer < Information.UBound((Array) FNIScommon1.FNIScommon.MRD_BO_nMRD, 1))
              {
                num4 = FNIScommon1.FNIScommon.MRD_BO_nMRD[integer];
              }
              else
              {
                num2 = -1;
                goto label_270;
              }
            }
            else if (Operators.CompareString(Strings.Left(strArray1[index1], 4), "?mra", false) == 0)
            {
              int integer = Conversions.ToInteger(Strings.Mid(strArray1[index1], 5));
              if (integer >= 0 & integer < Information.UBound((Array) FNIScommon1.FNIScommon.MRD_BO_nAnims, 1))
              {
                if (FNIScommon1.FNIScommon.MRD_BO_nMRD[integer] > 0)
                  num4 = 1;
              }
              else
              {
                num2 = -1;
                goto label_270;
              }
            }
            else if (Operators.CompareString(strArray1[index1], "paf1", false) == 0)
              num4 = FNIScommon1.FNIScommon.nPatchAF[1];
            else if (Operators.CompareString(strArray1[index1], "paf2", false) == 0)
              num4 = FNIScommon1.FNIScommon.nPatchAF[2];
            else if (Operators.CompareString(strArray1[index1], "?paf2", false) == 0)
            {
              if (FNIScommon1.FNIScommon.nPatchAF[2] > 0)
                num4 = 1;
            }
            else if (Operators.CompareString(Strings.Left(strArray1[index1], 3), "aaT", false) == 0)
            {
              if (Information.IsNothing((object) FNISaa1.FNISaa.AATriggerList))
              {
                num4 = 0;
              }
              else
              {
                string[] strArray3 = Strings.Split(strArray1[index1], ".", -1, CompareMethod.Binary);
                string Right = strArray3[1];
                int integer = Conversions.ToInteger(strArray3[2]);
                bool flag = false;
                int num6 = checked (FNISaa1.FNISaa.iAAGroup - 1);
                int index2 = 0;
                int num7;
                while (index2 <= num6)
                {
                  if (Operators.CompareString(FNISaa1.FNISaa.AAGroup[index2], Right, false) == 0)
                  {
                    flag = true;
                    num7 = index2;
                    index2 = FNISaa1.FNISaa.iAAGroup;
                  }
                  checked { ++index2; }
                }
                if (!flag)
                {
                  num4 = FNISaa1.FNISaa.iAAGroup != 0 ? -1 : 0;
                }
                else
                {
                  int num8 = -1;
                  int num9 = -1;
                  int num10 = -1;
                  if (BlockIndex == 1)
                    BlockIndex = BlockIndex;
                  int num11 = Information.UBound((Array) FNISaa1.FNISaa.AATriggerArray, 1);
                  int iTrigger = 0;
                  int currentnTriggers;
                  int num12;
                  while (iTrigger <= num11)
                  {
                    if (FNISaa1.FNISaa.AATriggerArray[iTrigger].iAnim == integer & FNISaa1.FNISaa.AATriggerArray[iTrigger].group == num7)
                    {
                      FNISaa1.FNISaa.GetTemplateSpecificTriggerdefs(iTrigger);
                      if (FNISaa1.FNISaa.AATriggerArray[iTrigger].setIndex > 0)
                      {
                        checked { ++num8; }
                        if (BlockIndex == num8)
                          num9 = FNISaa1.FNISaa.AATriggerArray[iTrigger].CurrentnTriggers;
                      }
                      if (FNISaa1.FNISaa.AATriggerArray[iTrigger].setIndex == BlockIndex)
                      {
                        currentnTriggers = FNISaa1.FNISaa.AATriggerArray[iTrigger].CurrentnTriggers;
                        num10 = num8;
                      }
                      checked { ++num12; }
                    }
                    checked { ++iTrigger; }
                  }
                  num4 = Operators.CompareString(strArray3[0], "aaT", false) != 0 ? (Operators.CompareString(strArray3[0], "aaTN", false) != 0 ? (Operators.CompareString(strArray3[0], "aaTn", false) != 0 ? (Operators.CompareString(strArray3[0], "aaTi", false) != 0 ? -1 : num10) : num9) : currentnTriggers) : num12;
                }
              }
            }
            else if (Operators.CompareString(strArray1[index1], "state", false) == 0)
            {
              int index2 = 0;
              int num6 = 0;
              while (index2 <= FNIScommon1.FNIScommon.AnzAnim)
              {
                if (Operators.CompareString(FNIScommon1.FNIScommon.AnimType[index2], "s", false) == 0)
                {
                  if (Decimal.Compare(new Decimal(FNIScommon1.FNIScommon.AnimOption[index2] & FNIScommon1.FNIScommon.F_option), Decimal.Zero) != 0)
                    num4 = 0;
                  else
                    checked { ++num4; }
                  if (num6 == BlockIndex)
                    index2 = checked (FNIScommon1.FNIScommon.AnzAnim + 2);
                  checked { ++num6; }
                }
                checked { ++index2; }
              }
              if (index2 < checked (FNIScommon1.FNIScommon.AnzAnim + 2))
              {
                num2 = -1;
                goto label_270;
              }
            }
            checked { num1 += num5 * num4; }
            checked { ++index1; }
          }
        }
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("EvalExpression", 0, "  OUT: " + Conversion.Str((object) num1), "");
        num2 = num1;
label_270:
        return num2;
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static int Get_AnimStats(string CAnimType, int nGroup, int nAnim, int result)
      {
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("Get_AnimStats", 1, "CAnimType: " + CAnimType + " ngroup:" + Conversion.Str((object) nGroup) + " nAnim:" + Conversion.Str((object) nAnim) + " result:" + Conversion.Str((object) result), "");
        int index1 = 0;
        int num1 = -1;
        int num2 = -1;
        int index2 = -1;
        int num3 = -1;
        int num4;
        while (index1 < FNIScommon1.FNIScommon.AnzAnim)
        {
          if (Operators.CompareString(FNIScommon1.FNIScommon.AnimType[index1], CAnimType, false) == 0)
          {
            checked { ++index2; }
            int num5;
            if (Decimal.Compare(new Decimal(FNIScommon1.FNIScommon.AnimOption[index1] & FNIScommon1.FNIScommon.F_option), Decimal.Zero) != 0)
            {
              checked { ++num2; }
              num1 = 0;
              num5 = index2;
            }
            else
              checked { ++num1; }
            if (num2 == nGroup & num1 == nAnim && result == 2)
              num3 = index2;
            if (index2 == nAnim & nGroup == -1)
            {
              if (result == 4)
                num3 = num2;
              if (result == 5)
                num3 = checked (index2 - num5);
              if (result == 1)
              {
                nAnim = -1;
                nGroup = num2;
              }
            }
            if (num1 == nAnim & nGroup == num2 && result == 3)
              num3 = FNIScommon1.FNIScommon.FurnitureID[index2];
            if (Decimal.Compare(new Decimal(FNIScommon1.FNIScommon.AnimOption[index1] & FNIScommon1.FNIScommon.L_option), Decimal.Zero) != 0 && nAnim == -1 & nGroup == num2 && result == 1)
              num3 = checked (index2 - num5 + 1);
          }
          if (num3 > -1)
          {
            if (FNIScommon1.FNIScommon.DebugOutput > 3)
              FNIScommon1.FNIScommon.WriteDebug("Get_AnimStats", 0, "return:" + Conversion.Str((object) num3), "");
            num4 = num3;
            goto label_27;
          }
          else
            checked { ++index1; }
        }
        FNIScommon1.FNIScommon.ErrInt = FNIScommon1.FNIScommon.CurrentLine;
        FNIScommon1.FNIScommon.ErrString = FNIScommon1.FNIScommon.CurrentTemplate;
        Information.Err().Raise(2007, (object) null, (object) null, (object) null, (object) null);
        num4 = -1;
label_27:
        return num4;
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static ulong GetOptions(string OptionString, string CurFile, int Filetype)
      {
        string[] SourceArray1 = new string[15]
        {
          "a",
          "h",
          "Tn",
          "B",
          "o",
          "k",
          "st",
          "bsa",
          "D",
          "T",
          "ac",
          "ac0",
          "ac1",
          "AV",
          "md"
        };
        string[] SourceArray2 = new string[7]
        {
          "F",
          "L",
          "h+",
          "h-",
          "o+",
          "o-",
          "mdz"
        };
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("GetOptions", 1, "Optionstring: " + OptionString + " Currentline:" + Conversion.Str((object) FNIScommon1.FNIScommon.CurrentLine), "");
        string[] strArray1 = !(Filetype == -1 | Filetype == -2) ? SourceArray1 : Strings.Split(Strings.Join(SourceArray1, "/") + "/" + Strings.Join(SourceArray2, "/"), "/", -1, CompareMethod.Binary);
        ulong num1;
        if (Filetype == -2)
        {
          int num2 = Information.UBound((Array) strArray1, 1);
          int index = 0;
          while (index <= num2)
          {
            if (Operators.CompareString(OptionString, strArray1[index], false) == 0)
            {
              num1 = checked ((ulong) Math.Round(Math.Pow(2.0, unchecked ((double) index))));
              goto label_35;
            }
            else
              checked { ++index; }
          }
          num1 = 0UL;
        }
        else
        {
          string[] strArray2 = Strings.Split(OptionString, ",", -1, CompareMethod.Binary);
          ulong num2 = 0;
          string duration = "9.8765";
          int num3 = Information.UBound((Array) strArray2, 1);
          int index1 = 0;
          while (index1 <= num3)
          {
            bool flag1 = false;
            bool flag2 = true;
            string Left = Strings.Left(strArray2[index1], 1);
            if (Operators.CompareString(Left, "T", false) == 0 & (uint) Operators.CompareString(strArray2[index1], "Tn", false) > 0U & Filetype != -1)
            {
              flag2 = FNIScommon1.FNIScommon.ReadTriggerOption(Strings.Mid(strArray2[index1], 2), duration, Filetype);
              strArray2[index1] = "T";
            }
            if (Operators.CompareString(Strings.Left(strArray2[index1], 2), "AV", false) == 0 & Strings.Len(strArray2[index1]) > 2 & Filetype != -1)
            {
              flag2 &= FNIScommon1.FNIScommon.ReadAnimVarOption(Strings.Mid(strArray2[index1], 3), FNIScommon1.FNIScommon.AnzAnim, Filetype, checked (FNIScommon1.FNIScommon.iSline + 1));
              strArray2[index1] = "AV";
            }
            int num4 = Information.UBound((Array) strArray1, 1);
            int index2 = 0;
            while (index2 <= num4)
            {
              if (Operators.CompareString(strArray2[index1], strArray1[index2], false) == 0 | Operators.CompareString(Left, "B", false) == 0 & Operators.CompareString(strArray1[index2], "B", false) == 0 | Operators.CompareString(Left, "D", false) == 0 & Operators.CompareString(strArray1[index2], "D", false) == 0)
              {
                flag1 = true;
                num2 |= checked ((ulong) Math.Round(Math.Pow(2.0, unchecked ((double) index2))));
                if (Filetype != -1 && Operators.CompareString(strArray1[index2], "B", false) == 0 | Operators.CompareString(strArray1[index2], "D", false) == 0)
                {
                  FNIScommon1.FNIScommon.OptionTime = Strings.Mid(strArray2[index1], 2);
                  if (Operators.CompareString(strArray1[index2], "D", false) == 0)
                    duration = FNIScommon1.FNIScommon.OptionTime;
                  string[] SourceArray3 = Strings.Split(FNIScommon1.FNIScommon.OptionTime, ".", -1, CompareMethod.Binary);
                  if (Information.UBound((Array) SourceArray3, 1) != 1 | !Versioned.IsNumeric((object) Strings.Join(SourceArray3, "")))
                  {
                    flag1 = false;
                    index2 = 999;
                  }
                }
              }
              checked { ++index2; }
            }
            if (!(flag1 & flag2))
            {
              if (Filetype != -1)
                FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) checked (FNIScommon1.FNIScommon.CurrentLine + 1)) + " (" + CurFile + "):  " + strArray2[index1];
              else
                FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) FNIScommon1.FNIScommon.CurrentLine) + " (" + CurFile + "):  " + strArray2[index1];
              if (Filetype == -1)
                Information.Err().Raise(2015, (object) null, (object) null, (object) null, (object) null);
              else
                Information.Err().Raise(2010, (object) null, (object) null, (object) null, (object) null);
            }
            checked { ++index1; }
          }
          if (FNIScommon1.FNIScommon.DebugOutput > 3)
            FNIScommon1.FNIScommon.WriteDebug("GetOptions", 0, "    Return:" + num2.ToString("X3") + " (mdz,o-,o+,h- // h+,L,F,md // AV,ac,T,D // bsa,st,k,o // B,Tn,h,a)", "");
          num1 = num2;
        }
label_35:
        return num1;
      }

      public static bool ReadTriggerOption(string OptionString, string duration, int TemplateType)
      {
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("ReadTriggerOption", 1, "Optionstring: " + OptionString + " TemplateType:" + Conversion.Str((object) TemplateType), "");
        bool flag = false;
        FNIScommon1.FNIScommon.ReadAllAEfile();
        string[] strArray = Strings.Split(OptionString, "/", -1, CompareMethod.Binary);
        if (Information.UBound((Array) strArray, 1) == 1)
        {
          int num1 = 9999;
          string Left = Strings.LCase(strArray[0]);
          int num2 = checked (FNIScommon1.FNIScommon.AllAEnum[TemplateType] - 1);
          int num3 = 0;
          while (num3 <= num2)
          {
            if (Operators.CompareString(Left, Strings.LCase(FNIScommon1.FNIScommon.AllAE[checked (FNIScommon1.FNIScommon.AllAEfirst[TemplateType] + num3)]), false) == 0)
            {
              num1 = num3;
              num3 = 9999;
            }
            checked { ++num3; }
          }
          if (num1 == 9999)
          {
            int num4 = checked (FNIScommon1.FNIScommon.CustomAEnum[TemplateType] - 1);
            int index = 0;
            while (index <= num4)
            {
              if (Operators.CompareString(Left, Strings.LCase(FNIScommon1.FNIScommon.CustomAE[TemplateType, index]), false) == 0)
              {
                num1 = checked (-1 - index);
                index = 9999;
              }
              checked { ++index; }
            }
            if (num1 == 9999)
            {
              FNIScommon1.FNIScommon.CustomAE[TemplateType, FNIScommon1.FNIScommon.CustomAEnum[TemplateType]] = strArray[0];
              // ISSUE: variable of a reference type
              int& local;
              // ISSUE: explicit reference operation
              // ISSUE: explicit reference operation
              int num5 = checked (^(local = @FNIScommon1.FNIScommon.CustomAEnum[TemplateType]) + 1);
              // ISSUE: explicit reference operation
              ^local = num5;
              num1 = checked (-FNIScommon1.FNIScommon.CustomAEnum[TemplateType]);
            }
          }
          if (Operators.CompareString(strArray[1], "D", false) == 0)
            strArray[1] = duration;
          string[] SourceArray = Strings.Split(strArray[1], ".", -1, CompareMethod.Binary);
          if (Information.UBound((Array) SourceArray, 1) == 1 & Versioned.IsNumeric((object) Strings.Join(SourceArray, "")))
          {
            FNIScommon1.FNIScommon.AnimAEEvent[FNIScommon1.FNIScommon.iAnimAEET] = num1;
            FNIScommon1.FNIScommon.AnimAETime[FNIScommon1.FNIScommon.iAnimAEET] = strArray[1];
            checked { ++FNIScommon1.FNIScommon.iAnimAEET; }
            // ISSUE: variable of a reference type
            int& local;
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            int num4 = checked (^(local = @FNIScommon1.FNIScommon.AnimNumAE[FNIScommon1.FNIScommon.AnzAnim]) + 1);
            // ISSUE: explicit reference operation
            ^local = num4;
            flag = true;
          }
        }
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("ReadTriggerOption", 0, "    Return:" + Conversion.Str((object) flag), "");
        return flag;
      }

      public static bool ReadAnimVarOption(string OptionString, int CurrAnim, int TemplateType, int LineOfGroup)
      {
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("ReadAnimVarOption", 1, "Optionstring: " + OptionString + " CurrAnim: " + Conversion.Str((object) CurrAnim) + " TemplateType:" + Conversion.Str((object) TemplateType), "");
        FNIScommon1.FNIScommon.AnimAVinvers[FNIScommon1.FNIScommon.iAnimAV] = Operators.CompareString(Strings.Left(OptionString, 1), "I", false) == 0;
        string str = OptionString;
        if (FNIScommon1.FNIScommon.AnimAVinvers[FNIScommon1.FNIScommon.iAnimAV])
          str = Strings.Mid(OptionString, 2);
        bool flag1;
        if (Operators.CompareString(FNIScommon1.FNIScommon.AnimType[CurrAnim], "fu", false) != 0 || !(Operators.CompareString(Strings.LCase(str), "banimationdriven", false) == 0 | Operators.CompareString(Strings.LCase(str), "bhumanoidfootikenable", false) == 0))
        {
          if (!FNIScommon1.FNIScommon.AllAVread)
          {
            FNIScommon1.FNIScommon.AllAV = FNIScommon1.FNIScommon.ReadAFile(FNIScommon1.FNIScommon.AllAVfile);
            int index1 = 0;
            int index2 = 0;
            do
            {
              FNIScommon1.FNIScommon.AllAVfirst[index2] = checked (index1 + 1);
              string[] strArray = Strings.Split(FNIScommon1.FNIScommon.AllAV[index1], ";", -1, CompareMethod.Binary);
              FNIScommon1.FNIScommon.AllAVnum[index2] = Conversions.ToInteger(strArray[1]);
              if (FNIScommon1.FNIScommon.AllAVnum[index2] == 0)
              {
                flag1 = false;
                goto label_40;
              }
              else
              {
                index1 = checked (index1 + FNIScommon1.FNIScommon.AllAVnum[index2] + 1);
                checked { ++index2; }
              }
            }
            while (index2 <= 2);
            FNIScommon1.FNIScommon.AllAVread = true;
          }
          int num1 = 9999;
          string Left = Strings.LCase(str);
          int num2 = checked (FNIScommon1.FNIScommon.AllAVnum[TemplateType] - 1);
          int num3 = 0;
          while (num3 <= num2)
          {
            if (Operators.CompareString(Left, Strings.LCase(FNIScommon1.FNIScommon.AllAV[checked (FNIScommon1.FNIScommon.AllAVfirst[TemplateType] + num3)]), false) == 0)
            {
              num1 = num3;
              num3 = 9999;
            }
            checked { ++num3; }
          }
          if (num1 == 9999)
          {
            int num4 = checked (FNIScommon1.FNIScommon.AnzAnimVars[TemplateType] - 1);
            int index = 0;
            while (index <= num4)
            {
              if (Operators.CompareString(Left, Strings.LCase(FNIScommon1.FNIScommon.AnimVarName[index, TemplateType]), false) == 0)
              {
                num1 = checked (-1 - index);
                index = 9999;
              }
              checked { ++index; }
            }
            if (num1 == 9999)
            {
              FNIScommon1.FNIScommon.AnimVarName[FNIScommon1.FNIScommon.AnzAnimVars[TemplateType], TemplateType] = str;
              FNIScommon1.FNIScommon.AnimVarType[FNIScommon1.FNIScommon.AnzAnimVars[TemplateType], TemplateType] = "BOOL";
              FNIScommon1.FNIScommon.AnimVarValue[FNIScommon1.FNIScommon.AnzAnimVars[TemplateType], TemplateType] = "0";
              // ISSUE: variable of a reference type
              int& local;
              // ISSUE: explicit reference operation
              // ISSUE: explicit reference operation
              int num5 = checked (^(local = @FNIScommon1.FNIScommon.AnzAnimVars[TemplateType]) + 1);
              // ISSUE: explicit reference operation
              ^local = num5;
              num1 = checked (-FNIScommon1.FNIScommon.AnzAnimVars[TemplateType]);
            }
          }
          bool flag2 = false;
          int num6 = checked (FNIScommon1.FNIScommon.AnimNumAV[CurrAnim] - 1);
          int num7 = 0;
          while (num7 <= num6)
          {
            if (FNIScommon1.FNIScommon.AnimAVid[checked (FNIScommon1.FNIScommon.AnimAV[CurrAnim] + num7)] == num1)
              flag2 = true;
            checked { ++num7; }
          }
          if (LineOfGroup > 1)
          {
            int num4 = checked (FNIScommon1.FNIScommon.AnimNumAV[CurrAnim - LineOfGroup + 1] - 1);
            int num5 = 0;
            while (num5 <= num4)
            {
              if (FNIScommon1.FNIScommon.AnimAVid[checked (FNIScommon1.FNIScommon.AnimAV[CurrAnim - LineOfGroup + 1] + num5)] == num1)
                flag2 = true;
              checked { ++num5; }
            }
          }
          if (!flag2)
          {
            FNIScommon1.FNIScommon.AnimAVid[FNIScommon1.FNIScommon.iAnimAV] = num1;
            checked { ++FNIScommon1.FNIScommon.iAnimAV; }
            // ISSUE: variable of a reference type
            int& local;
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            int num4 = checked (^(local = @FNIScommon1.FNIScommon.AnimNumAV[CurrAnim]) + 1);
            // ISSUE: explicit reference operation
            ^local = num4;
          }
        }
        bool flag3 = FNIScommon1.FNIScommon.AnimNumAV[CurrAnim] <= 5;
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("ReadAnimVarOption", 0, "    Return:" + Conversion.Str((object) flag3), "");
        flag1 = flag3;
label_40:
        return flag1;
      }

      public static bool Has_Option(ulong AnimOption, string CheckOption)
      {
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("Has_Option", 1, "AnimOption: " + Conversion.Str((object) AnimOption) + " CheckOption: " + CheckOption, "");
        bool flag = (AnimOption & FNIScommon1.FNIScommon.GetOptions(CheckOption, FNIScommon1.FNIScommon.AnimListFile, -1)) > 0UL;
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("Has_Option", 0, "    Return: " + Conversion.Str((object) flag), "");
        return flag;
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static void ReadAnimationFile(string AnimListFile, int Anzmod, bool SKip_CC = false)
      {
        if (FNIScommon1.FNIScommon.DebugOutput > 1)
          FNIScommon1.FNIScommon.WriteDebug("Read_Animationfile", 1, "X1: " + Conversion.Str((object) 1) + " X2: " + Conversion.Str((object) 2), "");
        FNIScommon1.FNIScommon.MyModVers[Anzmod] = "V?.?";
        string[] SourceArray = Strings.Split(AnimListFile, "\\", -1, CompareMethod.Binary);
        SourceArray[Information.UBound((Array) SourceArray, 1)] = "";
        string str1 = Strings.Join(SourceArray, "\\") + "\\";
        int anzAnim = FNIScommon1.FNIScommon.AnzAnim;
        string[] strArray1 = FNIScommon1.FNIScommon.ReadAFile(AnimListFile);
        int groupType = 0;
        FNIScommon1.FNIScommon.iSline = 0;
        FNISaa1.FNISaa.isAAdef = false;
        FNIScommon1.FNIScommon.AF1 = 1656;
        int patchCount = FNIScommon1.FNIScommon.PatchCount;
        int index1 = 0;
        while (index1 <= patchCount)
        {
          if (FNIScommon1.FNIScommon.isPatch[index1])
            checked { FNIScommon1.FNIScommon.AF1 += FNIScommon1.FNIScommon.PatchAddAnims[index1]; }
          checked { ++index1; }
        }
        int num1 = Information.UBound((Array) strArray1, 1);
        int index2 = 0;
        bool IsOptimized;
        while (index2 <= num1)
        {
          FNIScommon1.FNIScommon.CurrentLine = index2;
          int num2 = Strings.InStr(strArray1[index2], "'", CompareMethod.Binary);
          if (num2 > 0)
            strArray1[index2] = Strings.Left(strArray1[index2], checked (num2 - 1));
          string[] strArray2 = Strings.Split(Strings.Replace(Strings.Replace(strArray1[index2] + "  ", "\t", " ", 1, -1, CompareMethod.Binary), "\n", " ", 1, -1, CompareMethod.Binary), " ", -1, CompareMethod.Binary);
          int index3 = 0;
          int num3 = Information.UBound((Array) strArray2, 1);
          int index4 = 0;
          while (index4 <= num3)
          {
            if (Strings.Len(strArray2[index4]) > 0)
            {
              strArray2[index3] = strArray2[index4];
              checked { ++index3; }
            }
            checked { ++index4; }
          }
          if (index3 != 0)
          {
            string Left = strArray2[0];
            if (Operators.CompareString(Strings.LCase(Left), "version", false) == 0)
            {
              string str2 = strArray2[1];
              if (Operators.CompareString(Strings.Left(Strings.LCase(str2), 1), "v", false) == 0)
                str2 = Strings.Mid(str2, 2);
              FNIScommon1.FNIScommon.MyModVers[Anzmod] = "V" + str2;
            }
            else if (Operators.CompareString(Strings.LCase(Left), "aaprefix", false) == 0)
            {
              FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) checked (index2 + 1)) + " (" + AnimListFile + "):  " + strArray1[index2];
              if (index3 != 2)
                Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
              else if (FNIScommon1.FNIScommon.FNIS_for_Users)
                FNISaa1.FNISaa.ExecAAPrefix(strArray2[1], FNIScommon1.FNIScommon.ErrString);
            }
            else if (Operators.CompareString(Strings.LCase(Left), "aaset", false) == 0)
            {
              FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) checked (index2 + 1)) + " (" + AnimListFile + "):  " + strArray1[index2];
              if (index3 < 2 | index3 > 3)
                Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
              else if (index3 == 2)
                FNISaa1.FNISaa.ExecAASet(strArray2[1], "1", FNIScommon1.FNIScommon.ErrString);
              else if (FNIScommon1.FNIScommon.FNIS_for_Users)
                FNISaa1.FNISaa.ExecAASet(strArray2[1], strArray2[2], FNIScommon1.FNIScommon.ErrString);
            }
            else if (Operators.CompareString(Left, "T", false) == 0)
            {
              FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) checked (index2 + 1)) + " (" + AnimListFile + "):  " + strArray1[index2];
              if (index3 == 1)
                Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
              else if (Operators.CompareString(Strings.Right(Strings.LCase(strArray2[1]), 4), ".hkx", false) != 0)
                Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
              else if (FNIScommon1.FNIScommon.FNIS_for_Users)
              {
                string line = "";
                int num4 = index3;
                int index5 = 1;
                while (index5 <= num4)
                {
                  line = line + "/" + strArray2[index5];
                  checked { ++index5; }
                }
                FNISaa1.FNISaa.ExecAATrigger(line, FNIScommon1.FNIScommon.ErrString);
              }
            }
            else
            {
              int index5;
              if (Operators.CompareString(Strings.LCase(Left), "animvar", false) == 0 | Operators.CompareString(Left, "MD", false) == 0 | Operators.CompareString(Left, "RD", false) == 0)
              {
                if (Operators.CompareString(Strings.LCase(Left), "animvar", false) == 0)
                {
                  if (!FNIScommon1.FNIScommon.FNIS_for_Users)
                  {
                    if (index3 == 4 && Operators.CompareString(strArray2[2], "INT32", false) == 0 | Operators.CompareString(strArray2[2], "BOOL", false) == 0 | Operators.CompareString(strArray2[2], "REAL", false) == 0)
                    {
                      FNIScommon1.FNIScommon.AnimVarName[FNIScommon1.FNIScommon.AnzAnimVars[0], 0] = strArray2[1];
                      FNIScommon1.FNIScommon.AnimVarType[FNIScommon1.FNIScommon.AnzAnimVars[0], 0] = strArray2[2];
                      FNIScommon1.FNIScommon.AnimVarValue[FNIScommon1.FNIScommon.AnzAnimVars[0], 0] = strArray2[3];
                      // ISSUE: variable of a reference type
                      int& local;
                      // ISSUE: explicit reference operation
                      // ISSUE: explicit reference operation
                      int num4 = checked (^(local = @FNIScommon1.FNIScommon.AnzAnimVars[0]) + 1);
                      // ISSUE: explicit reference operation
                      ^local = num4;
                      goto label_159;
                    }
                  }
                  else
                    goto label_159;
                }
                else if (Operators.CompareString(Left, "MD", false) == 0 | Operators.CompareString(Left, "RD", false) == 0)
                {
                  FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) checked (index2 + 1)) + " (" + AnimListFile + "):  " + strArray1[index2];
                  if (FNIScommon1.FNIScommon.AnzAnim <= 0)
                    Information.Err().Raise(2029, (object) null, (object) null, (object) null, (object) null);
                  else if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[checked (FNIScommon1.FNIScommon.AnzAnim - 1)], "md"))
                    Information.Err().Raise(2029, (object) null, (object) null, (object) null, (object) null);
                  else if (Operators.CompareString(Left, "MD", false) == 0)
                  {
                    if (FNIScommon1.FNIScommon.Check_MRD(true, checked (FNIScommon1.FNIScommon.AnzAnim - 1), new string[4]
                    {
                      strArray2[1],
                      strArray2[2],
                      strArray2[3],
                      strArray2[4]
                    }, index5))
                      goto label_159;
                  }
                  else if (Operators.CompareString(Left, "RD", false) == 0)
                  {
                    if (index3 == 3)
                    {
                      if (FNIScommon1.FNIScommon.Check_MRD(false, checked (FNIScommon1.FNIScommon.AnzAnim - 1), new string[2]
                      {
                        strArray2[1],
                        strArray2[2]
                      }, index5))
                        goto label_159;
                    }
                    else if (index3 == 6)
                    {
                      if (FNIScommon1.FNIScommon.Check_MRD(false, checked (FNIScommon1.FNIScommon.AnzAnim - 1), new string[5]
                      {
                        strArray2[1],
                        strArray2[2],
                        strArray2[3],
                        strArray2[4],
                        strArray2[5]
                      }, index5))
                        goto label_159;
                    }
                  }
                }
                FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) checked (index2 + 1)) + " (" + AnimListFile + "):  " + strArray1[index2];
                Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
              }
              index5 = !(Operators.CompareString(Left, "ofa", false) == 0 | Operators.CompareString(Left, "fu", false) == 0 | Operators.CompareString(Left, "fuo", false) == 0 | Operators.CompareString(Left, "ch", false) == 0 | groupType != 1 & Operators.CompareString(Left, "+", false) == 0) ? (!(Operators.CompareString(Left, "pa", false) == 0 | Operators.CompareString(Left, "km", false) == 0) ? 0 : 2) : 1;
              if (FNIScommon1.FNIScommon.AnzAnim >= 10000 | checked (FNIScommon1.FNIScommon.AnzAnim - anzAnim) >= 2000)
              {
                FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) checked (index2 + 1)) + " (" + AnimListFile + "):  " + strArray1[index2];
                Information.Err().Raise(2026, (object) null, (object) null, (object) null, (object) null);
              }
              if (FNIScommon1.FNIScommon.iSline > 0 & (uint) Operators.CompareString(Left, "+", false) > 0U)
              {
                FNIScommon1.FNIScommon.Finish_Multiline(IsOptimized, groupType);
                FNIScommon1.FNIScommon.iSline = 0;
              }
              FNIScommon1.FNIScommon.AnimAE[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.iAnimAEET;
              FNIScommon1.FNIScommon.AnimNumAE[FNIScommon1.FNIScommon.AnzAnim] = 0;
              FNIScommon1.FNIScommon.AnimAV[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.iAnimAV;
              FNIScommon1.FNIScommon.AnimNumAV[FNIScommon1.FNIScommon.AnzAnim] = 0;
              bool flag1;
              int num5;
              if (Operators.CompareString(Strings.Left(strArray2[1], 1), "-", false) == 0)
              {
                if (Operators.CompareString(Left, "pa", false) == 0)
                {
                  // ISSUE: variable of a reference type
                  string& local;
                  // ISSUE: explicit reference operation
                  // ISSUE: explicit reference operation
                  string str2 = ^(local = @strArray2[1]) + ",T2_pairedstop/D";
                  // ISSUE: explicit reference operation
                  ^local = str2;
                }
                else if (Operators.CompareString(Left, "km", false) == 0)
                {
                  // ISSUE: variable of a reference type
                  string& local;
                  // ISSUE: explicit reference operation
                  // ISSUE: explicit reference operation
                  string str2 = ^(local = @strArray2[1]) + ",T2_killmoveend/D,T2_killactor/D,T2_pairend/D";
                  // ISSUE: explicit reference operation
                  ^local = str2;
                }
                FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.GetOptions(Strings.Mid(strArray2[1], 2), AnimListFile, index5);
                if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim], "ac"))
                  FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] | FNIScommon1.FNIScommon.ac1_option | FNIScommon1.FNIScommon.ac0_option;
                FNIScommon1.FNIScommon.AnimKoption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim], "k");
                flag1 = FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim], "o");
                if (Operators.CompareString(FNIScommon1.FNIScommon.OptionTime, "", false) != 0 && FNIScommon1.FNIScommon.FNIS_for_Users == (uint) index5 > 0U)
                {
                  FNIScommon1.FNIScommon.AnimBlend[FNIScommon1.FNIScommon.AnzAnim] = -1;
                  int lastBlend = FNIScommon1.FNIScommon.lastBlend;
                  int index6 = 0;
                  while (index6 <= lastBlend)
                  {
                    if (Operators.CompareString(FNIScommon1.FNIScommon.OptionTime, FNIScommon1.FNIScommon.BlendList[index6], false) == 0)
                      FNIScommon1.FNIScommon.AnimBlend[FNIScommon1.FNIScommon.AnzAnim] = index6;
                    checked { ++index6; }
                  }
                  if (FNIScommon1.FNIScommon.AnimBlend[FNIScommon1.FNIScommon.AnzAnim] == -1)
                  {
                    checked { ++FNIScommon1.FNIScommon.lastBlend; }
                    FNIScommon1.FNIScommon.BlendList[FNIScommon1.FNIScommon.lastBlend] = FNIScommon1.FNIScommon.OptionTime;
                    FNIScommon1.FNIScommon.AnimBlend[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.lastBlend;
                  }
                }
                num5 = 4;
              }
              else
              {
                FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = 0UL;
                FNIScommon1.FNIScommon.AnimKoption[FNIScommon1.FNIScommon.AnzAnim] = false;
                flag1 = false;
                num5 = 3;
              }
              if (FNIScommon1.FNIScommon.MyBO != 0)
                FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] | FNIScommon1.FNIScommon.h_option;
              bool flag2 = FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim], "D");
              if ((Operators.CompareString(Left, "pa", false) == 0 | Operators.CompareString(Left, "km", false) == 0) ^ flag2)
              {
                FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) index2) + " (" + AnimListFile + "):  -D";
                Information.Err().Raise(2010, (object) null, (object) null, (object) null, (object) null);
              }
              if (Operators.CompareString(Left, "o", false) == 0)
              {
                Left = "b";
                FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] | FNIScommon1.FNIScommon.o_option;
                flag1 = true;
              }
              if (Operators.CompareString(Left, "b", false) == 0)
              {
                checked { ++FNIScommon1.FNIScommon.Anz_b; }
                if (!FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim], "h"))
                {
                  FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] | FNIScommon1.FNIScommon.hminus_option;
                  FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] | FNIScommon1.FNIScommon.hplus_option;
                }
                if (flag1 & !FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim], "st"))
                  FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] | FNIScommon1.FNIScommon.ominus_option;
              }
              else if (Operators.CompareString(Left, "ofa", false) == 0)
                checked { ++FNIScommon1.FNIScommon.Anz_ofa; }
              else if (Operators.CompareString(Left, "s", false) == 0 | Operators.CompareString(Left, "so", false) == 0 | Operators.CompareString(Left, "S", false) == 0)
              {
                IsOptimized = (uint) Operators.CompareString(Left, "s", false) > 0U;
                Left = "s";
                groupType = 1;
                FNIScommon1.FNIScommon.iSline = 1;
                checked { ++FNIScommon1.FNIScommon.Anz_sG; }
                checked { ++FNIScommon1.FNIScommon.Anz_s; }
                FNIScommon1.FNIScommon.AnimSfirst[FNIScommon1.FNIScommon.Anz_sG] = FNIScommon1.FNIScommon.AnzAnim;
                FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] | FNIScommon1.FNIScommon.F_option;
              }
              else if (Operators.CompareString(Left, "fu", false) == 0 | Operators.CompareString(Left, "fuo", false) == 0)
              {
                IsOptimized = Operators.CompareString(Left, "fuo", false) == 0;
                Left = "fu";
                groupType = 2;
                FNIScommon1.FNIScommon.iSline = 1;
                checked { ++FNIScommon1.FNIScommon.Anz_fuG; }
                checked { ++FNIScommon1.FNIScommon.Anz_fu; }
                FNIScommon1.FNIScommon.AnimFufirst[FNIScommon1.FNIScommon.Anz_fuG] = FNIScommon1.FNIScommon.AnzAnim;
                FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] | FNIScommon1.FNIScommon.F_option;
              }
              else if (Operators.CompareString(Left, "ch", false) == 0)
              {
                groupType = 3;
                FNIScommon1.FNIScommon.iSline = 1;
                checked { ++FNIScommon1.FNIScommon.Anz_chG; }
                checked { ++FNIScommon1.FNIScommon.Anz_ch; }
                FNIScommon1.FNIScommon.AnimChfirst[FNIScommon1.FNIScommon.Anz_chG] = FNIScommon1.FNIScommon.AnzAnim;
                FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] | FNIScommon1.FNIScommon.F_option;
              }
              else if (Operators.CompareString(Left, "+", false) == 0)
              {
                if (groupType == 1)
                {
                  checked { ++FNIScommon1.FNIScommon.Anz_s; }
                  Left = "s";
                }
                else if (groupType == 2)
                {
                  checked { ++FNIScommon1.FNIScommon.Anz_fu; }
                  Left = "fu";
                }
                else if (groupType == 3)
                {
                  checked { ++FNIScommon1.FNIScommon.Anz_ch; }
                  Left = "ch";
                }
                if (FNIScommon1.FNIScommon.iSline == 0)
                  index3 = 0;
                checked { ++FNIScommon1.FNIScommon.iSline; }
              }
              else if (Operators.CompareString(Left, "pa", false) == 0)
                checked { ++FNIScommon1.FNIScommon.Anz_pa; }
              else if (Operators.CompareString(Left, "km", false) == 0)
              {
                checked { ++FNIScommon1.FNIScommon.Anz_km; }
              }
              else
              {
                FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) checked (index2 + 1)) + " (" + AnimListFile + "):  " + strArray1[index2];
                Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
              }
              FNIScommon1.FNIScommon.AnimType[FNIScommon1.FNIScommon.AnzAnim] = Left;
              if (!FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim], "md") && Operators.CompareString(Left, "b", false) == 0 | Operators.CompareString(Left, "s", false) == 0)
                FNIScommon1.FNIScommon.ReadAnimVarOption("bAnimationDriven", FNIScommon1.FNIScommon.AnzAnim, index5, FNIScommon1.FNIScommon.iSline);
              if (FNIScommon1.FNIScommon.AnimNumAV[FNIScommon1.FNIScommon.AnzAnim] > 0)
                FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] | FNIScommon1.FNIScommon.AV_option;
              if (flag1)
              {
                if (index3 > num5)
                  FNIScommon1.FNIScommon.nAO[FNIScommon1.FNIScommon.AnzAnim] = checked (index3 - num5);
                else
                  index3 = 0;
              }
              else if (index3 == num5)
                FNIScommon1.FNIScommon.nAO[FNIScommon1.FNIScommon.AnzAnim] = 0;
              else
                index3 = 0;
              if (index3 == 0)
              {
                FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) checked (index2 + 1)) + " (" + AnimListFile + "):  " + strArray1[index2];
                Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
              }
              FNIScommon1.FNIScommon.AnimMod[FNIScommon1.FNIScommon.AnzAnim] = Anzmod;
              FNIScommon1.FNIScommon.AnimEvent[FNIScommon1.FNIScommon.AnzAnim] = strArray2[checked (num5 - 2)];
              FNIScommon1.FNIScommon.AnimFile[FNIScommon1.FNIScommon.AnzAnim] = strArray2[checked (num5 - 1)];
              FNIScommon1.FNIScommon.AnimBehavior[FNIScommon1.FNIScommon.AnzAnim] = index5;
              if (!SKip_CC)
              {
                FNIScommon1.FNIScommon.AEcc aecc1 = new FNIScommon1.FNIScommon.AEcc();
                aecc1.actor = FNIScommon1.FNIScommon.MyBO;
                aecc1.modname = FNIScommon1.FNIScommon.MyMod[Anzmod];
                aecc1.AE = FNIScommon1.FNIScommon.AnimEvent[FNIScommon1.FNIScommon.AnzAnim];
                aecc1.comp = FNIScommon1.FNIScommon.BO_List[aecc1.actor] + aecc1.AE + aecc1.modname;
                FNIScommon1.FNIScommon.AEcc aecc2 = aecc1;
                FNIScommon1.FNIScommon.AEList.Add(aecc2);
                FNIScommon1.FNIScommon.Check_hkx_type("..\\..\\meshes\\actors\\character\\animations\\" + FNIScommon1.FNIScommon.MyMod[Anzmod] + "\\" + FNIScommon1.FNIScommon.AnimFile[FNIScommon1.FNIScommon.AnzAnim]);
              }
              if (flag1 & FNIScommon1.FNIScommon.FNIS_for_Users == (uint) index5 > 0U)
              {
                FNIScommon1.FNIScommon.firstAO[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.nextAO;
                FNIScommon1.FNIScommon.nAO[FNIScommon1.FNIScommon.AnzAnim] = checked (index3 - num5);
                checked { FNIScommon1.FNIScommon.nextAO += FNIScommon1.FNIScommon.nAO[FNIScommon1.FNIScommon.AnzAnim]; }
                int num4 = checked (FNIScommon1.FNIScommon.nAO[FNIScommon1.FNIScommon.AnzAnim] - 1);
                int num6 = 0;
                while (num6 <= num4)
                {
                  int num7 = -1;
                  string str2 = strArray2[checked (num5 + num6)];
                  bool flag3 = true;
                  if (Operators.CompareString(Strings.Mid(str2, checked (Strings.Len(str2) - 1), 1), "/", false) == 0)
                  {
                    if (Operators.CompareString(Strings.Right(str2, 1), "2", false) == 0)
                      flag3 = false;
                    else if (Operators.CompareString(Strings.Right(str2, 1), "1", false) != 0)
                      index3 = 0;
                    str2 = Strings.Left(str2, checked (Strings.Len(str2) - 2));
                  }
                  int num8 = checked (FNIScommon1.FNIScommon.Anz_AO[index5] - 1);
                  int index6 = 0;
                  while (index6 <= num8)
                  {
                    if (Operators.CompareString(Strings.LCase(str2), Strings.LCase(FNIScommon1.FNIScommon.AnimObject[index5, index6]), false) == 0)
                      num7 = index6;
                    checked { ++index6; }
                  }
                  if (num7 == -1)
                  {
                    FNIScommon1.FNIScommon.AnimObject[index5, FNIScommon1.FNIScommon.Anz_AO[index5]] = str2;
                    num7 = FNIScommon1.FNIScommon.Anz_AO[index5];
                    // ISSUE: variable of a reference type
                    int& local;
                    // ISSUE: explicit reference operation
                    // ISSUE: explicit reference operation
                    int num9 = checked (^(local = @FNIScommon1.FNIScommon.Anz_AO[index5]) + 1);
                    // ISSUE: explicit reference operation
                    ^local = num9;
                  }
                  FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[FNIScommon1.FNIScommon.AnzAnim] + num6)] = num7;
                  FNIScommon1.FNIScommon.AOfirst[checked (FNIScommon1.FNIScommon.firstAO[FNIScommon1.FNIScommon.AnzAnim] + num6)] = flag3;
                  checked { ++num6; }
                }
              }
              else
                FNIScommon1.FNIScommon.nAO[FNIScommon1.FNIScommon.AnzAnim] = 0;
              if (Operators.CompareString(Strings.Left(FNIScommon1.FNIScommon.AnimEvent[FNIScommon1.FNIScommon.AnzAnim], 1), "-", false) == 0)
                index3 = 0;
              if (Operators.CompareString(Strings.Left(FNIScommon1.FNIScommon.AnimFile[FNIScommon1.FNIScommon.AnzAnim], 1), "-", false) == 0)
                index3 = 0;
              if (Operators.CompareString(Strings.LCase(Strings.Right(FNIScommon1.FNIScommon.AnimEvent[FNIScommon1.FNIScommon.AnzAnim], 4)), ".hkx", false) == 0)
                index3 = 0;
              if (index3 == 0)
              {
                FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) checked (index2 + 1)) + " (" + AnimListFile + "):  " + strArray1[index2];
                Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
              }
              checked { ++FNIScommon1.FNIScommon.AnzAnim; }
            }
          }
label_159:
          checked { ++index2; }
        }
        if (FNIScommon1.FNIScommon.iSline > 0)
          FNIScommon1.FNIScommon.Finish_Multiline(IsOptimized, groupType);
        int num10 = anzAnim;
        int num11 = checked (FNIScommon1.FNIScommon.AnzAnim - 1);
        int index7 = num10;
        while (index7 <= num11)
        {
          if (FNIScommon1.FNIScommon.AnimNumAV[index7] > 0)
            FNIScommon1.FNIScommon.AnimOption[index7] = FNIScommon1.FNIScommon.AnimOption[index7] | FNIScommon1.FNIScommon.AV_option;
          if (!FNIScommon1.FNIScommon.AnimKoption[index7])
          {
            int num2 = checked (index7 - 1);
            int index3 = 0;
            while (index3 <= num2)
            {
              if (!FNIScommon1.FNIScommon.AnimKoption[index3] & Strings.Len(FNIScommon1.FNIScommon.AnimFile[index7]) > 0 && Operators.CompareString(Strings.LCase(FNIScommon1.FNIScommon.AnimFile[index7]), Strings.LCase(FNIScommon1.FNIScommon.AnimFile[index3]), false) == 0)
              {
                FNIScommon1.FNIScommon.AnimKoption[index7] = true;
                FNIScommon1.FNIScommon.AnimOption[index7] = FNIScommon1.FNIScommon.AnimOption[index7] | FNIScommon1.FNIScommon.k_option;
              }
              checked { ++index3; }
            }
            if (Operators.CompareString(Strings.LCase(FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnimMod[index7]]), "niruinsbusinessplan", false) == 0)
              FNIScommon1.FNIScommon.AnimOption[index7] = FNIScommon1.FNIScommon.AnimOption[index7] | FNIScommon1.FNIScommon.bsa_option;
            if (!(Operators.CompareString(FNIScommon1.FNIScommon.AnimFile[index7], "", false) == 0 | FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index7], "k") | FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index7], "bsa")) & (Operators.CompareString(FNIScommon1.FNIScommon.AnimType[index7], "fu", false) == 0 | Operators.CompareString(FNIScommon1.FNIScommon.AnimType[index7], "ofa", false) == 0) == FNIScommon1.FNIScommon.FNIS_for_Users && !MyProject.Computer.FileSystem.FileExists(str1 + FNIScommon1.FNIScommon.AnimFile[index7]))
              FNIScommon1.FNIScommon.WriteWarning(FNIScommon1.FNIScommon.tWarn[15] + " " + FNIScommon1.FNIScommon.AnimFile[index7]);
          }
          checked { ++index7; }
        }
        if (FNIScommon1.FNIScommon.DebugOutput <= 0)
          return;
        if (FNIScommon1.FNIScommon.DebugOutput > 1)
          FNIScommon1.FNIScommon.WriteDebug("ReadAnimationFile", 0, "", "");
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
        {
          string[] strArray2 = Strings.Split(Strings.Join(new string[15]
          {
            "a",
            "h",
            "Tn",
            "B",
            "o",
            "k",
            "st",
            "bsa",
            "D",
            "T",
            "ac",
            "ac0",
            "ac1",
            "AV",
            "md"
          }, "/") + "/" + Strings.Join(new string[7]
          {
            "F",
            "L",
            "h+",
            "h-",
            "o+",
            "o-",
            "mdz"
          }, "/"), "/", -1, CompareMethod.Binary);
          int num2 = checked (FNIScommon1.FNIScommon.AnzAnim - 1);
          int index3 = 0;
          while (index3 <= num2)
          {
            string str2 = Conversion.Str((object) index3) + ": " + FNIScommon1.FNIScommon.AnimOption[index3].ToString("X4") + "," + FNIScommon1.FNIScommon.AnimType[index3] + ", " + FNIScommon1.FNIScommon.AnimEvent[index3] + ", " + FNIScommon1.FNIScommon.AnimFile[index3] + "," + Conversion.Str((object) FNIScommon1.FNIScommon.nAO[index3]);
            int num3 = checked (FNIScommon1.FNIScommon.nAO[index3] - 1);
            int num4 = 0;
            while (num4 <= num3)
            {
              str2 = str2 + Conversion.Str((object) FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index3] + num4)]) + " " + FNIScommon1.FNIScommon.AnimObject[FNIScommon1.FNIScommon.AnimBehavior[index3], FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index3] + num4)]];
              checked { ++num4; }
            }
            string LogText = str2 + "  --  ";
            int num5 = Information.UBound((Array) strArray2, 1);
            int index4 = 0;
            while (index4 <= num5)
            {
              if (Decimal.Compare(new Decimal(FNIScommon1.FNIScommon.AnimOption[index3] & checked ((ulong) Math.Round(Math.Pow(2.0, unchecked ((double) index4))))), Decimal.Zero) > 0)
                LogText = LogText + strArray2[index4] + "  ";
              checked { ++index4; }
            }
            FNIScommon1.FNIScommon.LogOutput(LogText, false, true);
            checked { ++index3; }
          }
        }
        if (FNIScommon1.FNIScommon.DebugOutput <= 1 || !FNIScommon1.FNIScommon.FNIS_for_Users)
          return;
        FNIScommon1.FNIScommon.LogOutput("Motion/Rotation Data:", false, true);
        List<FNIScommon1.FNIScommon.MRD_Data>.Enumerator enumerator;
        try
        {
          enumerator = FNIScommon1.FNIScommon.MRD_DataListONE.GetEnumerator();
          while (enumerator.MoveNext())
          {
            FNIScommon1.FNIScommon.MRD_Data current = enumerator.Current;
            string str2 = Strings.Join([email protected], " ");
            FNIScommon1.FNIScommon.LogOutput("YYY MRDONE first " + current.firstOfBlock.ToString() + " ismd " + current.isMD.ToString() + " curranim " + current.currAnim.ToString() + " modid " + current.modId.ToString() + " BOid " + current.BOId.ToString() + " " + str2, false, true);
          }
        }
        finally
        {
          enumerator.Dispose();
        }
      }

      public static bool Check_MRD(bool isMD, int currAnim, string[] @params, int whichBehavior)
      {
        string[] strArray1 = @params;
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("Check_MRD", 1, "isMD: " + Conversion.Str((object) isMD) + " currAnim: " + Conversion.Str((object) currAnim), "");
        bool flag1;
        if (currAnim < 0)
          flag1 = false;
        else if (isMD & Information.UBound((Array) @params, 1) != 3)
          flag1 = false;
        else if (!isMD & Information.UBound((Array) @params, 1) != 1 & Information.UBound((Array) @params, 1) != 4)
        {
          flag1 = false;
        }
        else
        {
          if (currAnim != FNIScommon1.FNIScommon.MRD_LastAnim)
          {
            if (!isMD)
            {
              flag1 = false;
              goto label_38;
            }
            else
              FNIScommon1.FNIScommon.MRD_LastTime = -0.01f;
          }
          else if (isMD & !FNIScommon1.FNIScommon.MRD_LastIsMD)
          {
            flag1 = false;
            goto label_38;
          }
          else if (!isMD & FNIScommon1.FNIScommon.MRD_LastIsMD)
            FNIScommon1.FNIScommon.MRD_LastTime = -0.01f;
          bool flag2 = currAnim != FNIScommon1.FNIScommon.MRD_LastAnim;
          FNIScommon1.FNIScommon.MRD_LastAnim = currAnim;
          FNIScommon1.FNIScommon.MRD_LastIsMD = isMD;
          if (isMD)
            FNIScommon1.FNIScommon.MRD_LastTimeS = @params[0];
          int num1 = Information.UBound((Array) @params, 1);
          int index1 = 0;
          while (index1 <= num1)
          {
            float num2;
            try
            {
              num2 = float.Parse(@params[index1], (IFormatProvider) CultureInfo.InvariantCulture);
            }
            catch (Exception ex)
            {
              ProjectData.SetProjectError(ex);
              flag1 = false;
              ProjectData.ClearProjectError();
              goto label_38;
            }
            if (index1 == 0)
            {
              if ((double) num2 <= (double) FNIScommon1.FNIScommon.MRD_LastTime)
              {
                flag1 = false;
                goto label_38;
              }
              else
                FNIScommon1.FNIScommon.MRD_LastTime = num2;
            }
            else if (isMD)
            {
              if (index1 == 3 & (double) num2 > 1.0 && !FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[currAnim], "mdz"))
              {
                FNIScommon1.FNIScommon.AnimOption[currAnim] = FNIScommon1.FNIScommon.AnimOption[currAnim] | FNIScommon1.FNIScommon.mdz_option;
                if (Operators.CompareString(FNIScommon1.FNIScommon.AnimType[currAnim], "b", false) == 0)
                  FNIScommon1.FNIScommon.ReadAnimVarOption("IbHumanoidFootIKEnable", currAnim, whichBehavior, FNIScommon1.FNIScommon.iSline);
              }
            }
            else if (Information.UBound((Array) @params, 1) == 4 & (double) Math.Abs(num2) > 1.0 | Information.UBound((Array) @params, 1) == 1 & (double) Math.Abs(num2) > 180.0)
            {
              flag1 = false;
              goto label_38;
            }
            else if (Information.UBound((Array) @params, 1) == 1)
            {
              string[] strArray2 = new string[5]
              {
                @params[0],
                "0",
                "0",
                null,
                null
              };
              int index2 = 3;
              double num3 = Math.Sin(Math.PI * (double) num2 / 360.0);
              string str1 = num3.ToString("F6", (IFormatProvider) CultureInfo.InvariantCulture);
              strArray2[index2] = str1;
              int index3 = 4;
              num3 = Math.Cos(Math.PI * (double) num2 / 360.0);
              string str2 = num3.ToString("F6", (IFormatProvider) CultureInfo.InvariantCulture);
              strArray2[index3] = str2;
              strArray1 = strArray2;
            }
            checked { ++index1; }
          }
          FNIScommon1.FNIScommon.MRD_Data mrdData = new FNIScommon1.FNIScommon.MRD_Data()
          {
            isMD = isMD,
            currAnim = currAnim,
            anim_crc32 = FNIScommon1.FNIScommon.CRC32_Calc(Strings.LCase(FNIScommon1.FNIScommon.AnimFile[currAnim])),
            modId = FNIScommon1.FNIScommon.AnimMod[currAnim],
            BOId = FNIScommon1.FNIScommon.MyBO,
            clipGenName = FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnimMod[currAnim]] + "_" + Strings.Left(FNIScommon1.FNIScommon.AnimFile[currAnim], checked (Strings.Len(FNIScommon1.FNIScommon.AnimFile[currAnim]) - 4)),
            firstOfBlock = flag2,
            @params = strArray1
          };
          FNIScommon1.FNIScommon.MRD_DataListONE.Add(mrdData);
          if (FNIScommon1.FNIScommon.DebugOutput > 3)
            FNIScommon1.FNIScommon.WriteDebug("Check_MRD", 0, "", "");
          flag1 = true;
        }
label_38:
        return flag1;
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static void Finish_Multiline(bool IsOptimized, int groupType)
      {
        if (FNIScommon1.FNIScommon.DebugOutput > 3)
          FNIScommon1.FNIScommon.WriteDebug("Finish_Multiline", 1, "X1: " + Conversion.Str((object) 1) + " X2: " + Conversion.Str((object) 2), "");
        int index1;
        if (groupType == 1)
        {
          index1 = FNIScommon1.FNIScommon.AnimSfirst[FNIScommon1.FNIScommon.Anz_sG];
          if (FNIScommon1.FNIScommon.AnzAnim < checked (index1 + 2))
          {
            FNIScommon1.FNIScommon.ErrInt = checked (FNIScommon1.FNIScommon.CurrentLine - 1);
            Information.Err().Raise(2025, (object) null, (object) null, (object) null, (object) null);
          }
        }
        else if (groupType == 2)
        {
          index1 = FNIScommon1.FNIScommon.AnimFufirst[FNIScommon1.FNIScommon.Anz_fuG];
          if (FNIScommon1.FNIScommon.AnzAnim < checked (index1 + 3) | !(FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index1], "a") & FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[checked (FNIScommon1.FNIScommon.AnzAnim - 1)], "a")))
          {
            FNIScommon1.FNIScommon.ErrInt = checked (FNIScommon1.FNIScommon.CurrentLine - 1);
            Information.Err().Raise(2028, (object) null, (object) null, (object) null, (object) null);
          }
        }
        else if (groupType == 3)
        {
          index1 = FNIScommon1.FNIScommon.AnimChfirst[FNIScommon1.FNIScommon.Anz_chG];
          if (FNIScommon1.FNIScommon.AnzAnim != checked (index1 + 4))
          {
            FNIScommon1.FNIScommon.ErrInt = checked (FNIScommon1.FNIScommon.CurrentLine - 1);
            Information.Err().Raise(2028, (object) null, (object) null, (object) null, (object) null);
          }
        }
        int index2 = checked (FNIScommon1.FNIScommon.AnzAnim - 1);
        int TemplateType = FNIScommon1.FNIScommon.AnimBehavior[index2];
        FNIScommon1.FNIScommon.AnimOption[index2] = FNIScommon1.FNIScommon.AnimOption[index2] | FNIScommon1.FNIScommon.L_option;
        if (FNIScommon1.FNIScommon.MyBO == 0)
        {
          int num1 = 0;
          int num2 = index1;
          int num3 = index2;
          int index3 = num2;
          while (index3 <= num3)
          {
            if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index3], "h"))
              checked { ++num1; }
            checked { ++index3; }
          }
          if (num1 == 0)
          {
            FNIScommon1.FNIScommon.AnimOption[index1] = FNIScommon1.FNIScommon.AnimOption[index1] | FNIScommon1.FNIScommon.hminus_option;
            FNIScommon1.FNIScommon.AnimOption[index2] = FNIScommon1.FNIScommon.AnimOption[index2] | FNIScommon1.FNIScommon.hplus_option;
          }
          else if (num1 != checked (index2 - index1 + 1))
          {
            int num4 = index1;
            int num5 = index2;
            int index4 = num4;
            while (index4 <= num5)
            {
              if (!FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index4], "h"))
                FNIScommon1.FNIScommon.AnimOption[index4] = FNIScommon1.FNIScommon.AnimOption[index4] | FNIScommon1.FNIScommon.hminus_option | FNIScommon1.FNIScommon.hplus_option;
              checked { ++index4; }
            }
          }
        }
        if (groupType != 3)
        {
          bool flag1 = true;
          int num1 = checked (index1 + 1);
          int num2 = index2;
          int index3 = num1;
          while (index3 <= num2)
          {
            if (FNIScommon1.FNIScommon.nAO[index3] != FNIScommon1.FNIScommon.nAO[index1])
            {
              flag1 = false;
            }
            else
            {
              int num3 = checked (FNIScommon1.FNIScommon.nAO[index1] - 1);
              int num4 = 0;
              while (num4 <= num3)
              {
                if (FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index1] + num4)] != FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index3] + num4)])
                  flag1 = false;
                checked { ++num4; }
              }
            }
            checked { ++index3; }
          }
          if (flag1)
          {
            if (FNIScommon1.FNIScommon.nAO[index1] > 0)
            {
              FNIScommon1.FNIScommon.AnimOption[index1] = FNIScommon1.FNIScommon.AnimOption[index1] | FNIScommon1.FNIScommon.oplus_option;
              if (!FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index2], "st"))
                FNIScommon1.FNIScommon.AnimOption[index2] = FNIScommon1.FNIScommon.AnimOption[index2] | FNIScommon1.FNIScommon.ominus_option;
            }
          }
          else if (!IsOptimized)
          {
            int num3 = index1;
            int num4 = index2;
            int index4 = num3;
            while (index4 <= num4)
            {
              if (FNIScommon1.FNIScommon.nAO[index4] > 0)
                FNIScommon1.FNIScommon.AnimOption[index4] = FNIScommon1.FNIScommon.AnimOption[index4] | FNIScommon1.FNIScommon.oplus_option;
              if (index4 != index2 | !FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index2], "st"))
                FNIScommon1.FNIScommon.AnimOption[index4] = FNIScommon1.FNIScommon.AnimOption[index4] | FNIScommon1.FNIScommon.ominus_option;
              checked { ++index4; }
            }
          }
          else
          {
            bool[] flagArray1 = new bool[21];
            bool[] flagArray2 = new bool[21];
            if (FNIScommon1.FNIScommon.nAO[index2] > 0 & !FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index2], "st"))
              FNIScommon1.FNIScommon.AnimOption[index2] = FNIScommon1.FNIScommon.AnimOption[index2] | FNIScommon1.FNIScommon.ominus_option;
            bool flag2 = true;
            int num3 = index1;
            int num4 = index2;
            int index4 = num3;
            while (index4 <= num4)
            {
              if (FNIScommon1.FNIScommon.nAO[index4] > 0)
              {
                int num5 = checked (FNIScommon1.FNIScommon.nAO[index4] - 1);
                int index5 = 0;
                while (index5 <= num5)
                {
                  flagArray1[index5] = true;
                  if (index4 != index1)
                  {
                    int num6 = checked (FNIScommon1.FNIScommon.nAO[index4 - 1] - 1);
                    int num7 = 0;
                    while (num7 <= num6)
                    {
                      if (FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index4] + index5)] == FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index4 - 1] + num7)])
                        flagArray1[index5] = false;
                      checked { ++num7; }
                    }
                  }
                  flagArray2[0] = true;
                  if (index4 != index2)
                  {
                    int num6 = checked (FNIScommon1.FNIScommon.nAO[index4 + 1] - 1);
                    int num7 = 0;
                    while (num7 <= num6)
                    {
                      if (FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index4] + index5)] == FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index4 + 1] + num7)])
                        flagArray2[index5] = false;
                      checked { ++num7; }
                    }
                  }
                  else if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index4], "st"))
                    flagArray2[0] = false;
                  checked { ++index5; }
                }
                int num8 = checked (FNIScommon1.FNIScommon.nAO[index4] - 1);
                int index6 = 1;
                while (index6 <= num8)
                {
                  if (flagArray2[index6])
                    flagArray2[0] = true;
                  checked { ++index6; }
                }
                if (!flag2)
                {
                  int num6 = 0;
                  int num7 = FNIScommon1.FNIScommon.nAO[index4];
                  int index7 = 0;
                  while (index7 <= num7)
                  {
                    if (flagArray1[index7])
                    {
                      if (index7 > num6)
                        FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index4] + num6)] = FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index4] + index7)];
                      checked { ++num6; }
                    }
                    checked { ++index7; }
                  }
                  FNIScommon1.FNIScommon.nAO[index4] = num6;
                }
                if (FNIScommon1.FNIScommon.nAO[index4] > 0)
                  FNIScommon1.FNIScommon.AnimOption[index4] = FNIScommon1.FNIScommon.AnimOption[index4] | FNIScommon1.FNIScommon.oplus_option;
                if (flagArray2[0])
                  FNIScommon1.FNIScommon.AnimOption[index4] = FNIScommon1.FNIScommon.AnimOption[index4] | FNIScommon1.FNIScommon.ominus_option;
                flag2 = flagArray2[0];
              }
              checked { ++index4; }
            }
            int num9 = index2;
            int num10 = checked (index1 + 1);
            int index8 = num9;
            while (index8 >= num10)
            {
              bool flag3 = true;
              if (FNIScommon1.FNIScommon.nAO[index8] < FNIScommon1.FNIScommon.nAO[checked (index8 - 1)])
              {
                flag3 = false;
              }
              else
              {
                int num5 = checked (FNIScommon1.FNIScommon.nAO[index8 - 1] - 1);
                int num6 = 0;
                while (num6 <= num5)
                {
                  bool flag4 = false;
                  int num7 = checked (FNIScommon1.FNIScommon.nAO[index8] - 1);
                  int num8 = 0;
                  while (num8 <= num7)
                  {
                    if (FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index8] + num8)] == FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index8 - 1] + num6)])
                      flag4 = true;
                    checked { ++num8; }
                  }
                  if (!flag4)
                  {
                    flag3 = false;
                    num6 = FNIScommon1.FNIScommon.nAO[index8];
                  }
                  checked { ++num6; }
                }
              }
              if (flag3)
              {
                int num5 = 0;
                int num6 = checked (FNIScommon1.FNIScommon.nAO[index8] - 1);
                int num7 = 0;
                while (num7 <= num6)
                {
                  bool flag4 = true;
                  int num8 = checked (FNIScommon1.FNIScommon.nAO[index8 - 1] - 1);
                  int num11 = 0;
                  while (num11 <= num8)
                  {
                    if (Operators.CompareString(FNIScommon1.FNIScommon.AnimObject[TemplateType, FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index8] + num7)]], FNIScommon1.FNIScommon.AnimObject[TemplateType, FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index8 - 1] + num11)]], false) == 0)
                      flag4 = false;
                    checked { ++num11; }
                  }
                  if (flag4)
                  {
                    FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index8] + num5)] = FNIScommon1.FNIScommon.AOList[checked (FNIScommon1.FNIScommon.firstAO[index8] + num7)];
                    checked { ++num5; }
                  }
                  checked { ++num7; }
                }
                FNIScommon1.FNIScommon.nAO[index8] = num5;
              }
              else
                FNIScommon1.FNIScommon.AnimOption[index8] = FNIScommon1.FNIScommon.AnimOption[index8] | FNIScommon1.FNIScommon.ominus_option;
              if (FNIScommon1.FNIScommon.nAO[index8] > 0)
                FNIScommon1.FNIScommon.AnimOption[index8] = FNIScommon1.FNIScommon.AnimOption[index8] | FNIScommon1.FNIScommon.oplus_option;
              checked { index8 += -1; }
            }
          }
          if (groupType == 1)
          {
            FNIScommon1.FNIScommon.AnimType[FNIScommon1.FNIScommon.AnzAnim] = "sg";
            FNIScommon1.FNIScommon.AnimEvent[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimEvent[index1];
            FNIScommon1.FNIScommon.AnimEvent[index1] = FNIScommon1.FNIScommon.AnimEvent[index1] + "_REENTER";
          }
          else if (groupType == 2)
          {
            FNIScommon1.FNIScommon.AnimType[FNIScommon1.FNIScommon.AnzAnim] = "fug";
            FNIScommon1.FNIScommon.AnimEvent[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimEvent[index2] + "_DONE";
          }
          FNIScommon1.FNIScommon.AnimFile[FNIScommon1.FNIScommon.AnzAnim] = "";
          FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = 0UL;
          int num12 = index1;
          int num13 = index2;
          int index9 = num12;
          bool flag5;
          while (index9 <= num13)
          {
            if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index9], "mdz"))
            {
              FNIScommon1.FNIScommon.AnimOption[index9] = FNIScommon1.FNIScommon.AnimOption[index9] ^ FNIScommon1.FNIScommon.mdz_option;
              flag5 = true;
            }
            checked { ++index9; }
          }
          if (flag5)
            FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] | FNIScommon1.FNIScommon.mdz_option;
          FNIScommon1.FNIScommon.AnimAV[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.iAnimAV;
          FNIScommon1.FNIScommon.AnimNumAV[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimNumAV[index1];
          if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index1], "AV"))
          {
            FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] | FNIScommon1.FNIScommon.AV_option;
            FNIScommon1.FNIScommon.AnimOption[index1] = FNIScommon1.FNIScommon.AnimOption[index1] ^ FNIScommon1.FNIScommon.AV_option;
            int num3 = checked (FNIScommon1.FNIScommon.AnimNumAV[FNIScommon1.FNIScommon.AnzAnim] - 1);
            int num4 = 0;
            while (num4 <= num3)
            {
              FNIScommon1.FNIScommon.AnimAVid[FNIScommon1.FNIScommon.iAnimAV] = FNIScommon1.FNIScommon.AnimAVid[checked (FNIScommon1.FNIScommon.AnimAV[index1] + num4)];
              checked { ++FNIScommon1.FNIScommon.iAnimAV; }
              checked { ++num4; }
            }
            FNIScommon1.FNIScommon.AnimNumAV[index1] = 0;
            if (flag5)
              FNIScommon1.FNIScommon.ReadAnimVarOption("IbHumanoidFootIKEnable", FNIScommon1.FNIScommon.AnzAnim, TemplateType, FNIScommon1.FNIScommon.iSline);
          }
          if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index1], "ac"))
          {
            FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] | FNIScommon1.FNIScommon.ac_option;
            int num3 = index1;
            int num4 = index2;
            int index4 = num3;
            while (index4 <= num4)
            {
              if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index4], "ac"))
                FNIScommon1.FNIScommon.AnimOption[index4] = FNIScommon1.FNIScommon.AnimOption[index4] ^ FNIScommon1.FNIScommon.ac_option;
              checked { ++index4; }
            }
          }
        }
        else
        {
          FNIScommon1.FNIScommon.AnimType[FNIScommon1.FNIScommon.AnzAnim] = "chg";
          FNIScommon1.FNIScommon.AnimEvent[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimEvent[index1];
          if (FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index1], "o"))
          {
            FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.AnimOption[FNIScommon1.FNIScommon.AnzAnim] ^ FNIScommon1.FNIScommon.o_option;
            FNIScommon1.FNIScommon.firstAO[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.firstAO[index1];
            FNIScommon1.FNIScommon.nAO[FNIScommon1.FNIScommon.AnzAnim] = FNIScommon1.FNIScommon.nAO[index1];
          }
        }
        checked { ++FNIScommon1.FNIScommon.AnzAnim; }
        if (FNIScommon1.FNIScommon.DebugOutput <= 3)
          return;
        FNIScommon1.FNIScommon.WriteDebug("Finish_Multiline", 0, "", "");
      }

      public static void ReadAllAEfile()
      {
        if (FNIScommon1.FNIScommon.AllAEread)
          return;
        FNIScommon1.FNIScommon.AllAE = FNIScommon1.FNIScommon.ReadAFile(FNIScommon1.FNIScommon.AllAEfile);
        int index1 = 0;
        int index2 = 0;
        do
        {
          FNIScommon1.FNIScommon.AllAEfirst[index2] = checked (index1 + 1);
          string[] strArray = Strings.Split(FNIScommon1.FNIScommon.AllAE[index1], ";", -1, CompareMethod.Binary);
          FNIScommon1.FNIScommon.AllAEbehavior[index2] = strArray[0];
          FNIScommon1.FNIScommon.AllAEnum[index2] = Conversions.ToInteger(strArray[1]);
          if (FNIScommon1.FNIScommon.AllAEnum[index2] != 0)
          {
            index1 = checked (index1 + FNIScommon1.FNIScommon.AllAEnum[index2] + 1);
            checked { ++index2; }
          }
          else
            break;
        }
        while (index2 <= 15);
        FNIScommon1.FNIScommon.AllAEread = true;
      }

      public static void CRC32_Tab_Init()
      {
        int index = 0;
        do
        {
          uint num1 = checked ((uint) index);
          int num2 = 0;
          do
          {
            if ((num1 & 1U) > 0U)
              num1 = num1 >> 1 ^ 3988292384U;
            else
              num1 >>= 1;
            checked { ++num2; }
          }
          while (num2 <= 7);
          FNIScommon1.FNIScommon.crc_tab32[index] = num1;
          checked { ++index; }
        }
        while (index <= (int) byte.MaxValue);
      }

      public static uint CRC32_Calc(string input_string)
      {
        char[] charArray = input_string.ToCharArray();
        uint num1 = 0;
        int num2 = Information.UBound((Array) charArray, 1);
        int index = 0;
        while (index <= num2)
        {
          int num3 = Strings.Asc(charArray[index]);
          long num4 = (long) num1 ^ (long) num3;
          num1 = num1 >> 8 ^ FNIScommon1.FNIScommon.crc_tab32[checked ((int) (num4 & (long) byte.MaxValue))];
          checked { ++index; }
        }
        return num1;
      }

      public static uint CRC32_Calc(byte[] byte_array, int ubyte, int obyte)
      {
        uint num1 = 0;
        int num2 = ubyte;
        int num3 = obyte;
        int index = num2;
        while (index <= num3)
        {
          byte num4 = byte_array[index];
          uint num5 = num1 ^ (uint) num4;
          num1 = num1 >> 8 ^ FNIScommon1.FNIScommon.crc_tab32[checked ((int) ((long) num5 & (long) byte.MaxValue))];
          checked { ++index; }
        }
        return num1;
      }

      public static void WriteError()
      {
        if (Information.Err().Number == 0)
          return;
        string str;
        switch (Information.Err().Number)
        {
          case 2001:
            str = FNIScommon1.FNIScommon.ErrString + " " + FNIScommon1.FNIScommon.tErr[3] + " - " + FNIScommon1.FNIScommon.tErr[17];
            break;
          case 2002:
            str = FNIScommon1.FNIScommon.tErr[4] + Conversion.Str((object) FNIScommon1.FNIScommon.ErrInt) + ": " + FNIScommon1.FNIScommon.tErr[5] + ": " + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2003:
            str = FNIScommon1.FNIScommon.tErr[4] + Conversion.Str((object) FNIScommon1.FNIScommon.ErrInt) + ": " + FNIScommon1.FNIScommon.tErr[6] + ": " + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2004:
            str = FNIScommon1.FNIScommon.tErr[4] + Conversion.Str((object) FNIScommon1.FNIScommon.ErrInt) + ": " + FNIScommon1.FNIScommon.tErr[7] + ": " + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2005:
            str = FNIScommon1.FNIScommon.tErr[4] + Conversion.Str((object) FNIScommon1.FNIScommon.ErrInt) + ": " + FNIScommon1.FNIScommon.tErr[8] + ": " + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2006:
            str = FNIScommon1.FNIScommon.tErr[4] + Conversion.Str((object) FNIScommon1.FNIScommon.ErrInt) + ": " + FNIScommon1.FNIScommon.tErr[9] + " \"<!-- $$ -->\" " + FNIScommon1.FNIScommon.tErr[10] + "?";
            break;
          case 2007:
            str = FNIScommon1.FNIScommon.tErr[4] + Conversion.Str((object) FNIScommon1.FNIScommon.ErrInt) + ": " + FNIScommon1.FNIScommon.tErr[11] + ": " + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2008:
            str = FNIScommon1.FNIScommon.tErr[4] + Conversion.Str((object) FNIScommon1.FNIScommon.ErrInt) + ": " + FNIScommon1.FNIScommon.tErr[12] + ": " + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2009:
            str = FNIScommon1.FNIScommon.tErr[13] + ": " + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2010:
            str = FNIScommon1.FNIScommon.tErr[14] + ": " + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2011:
            str = FNIScommon1.FNIScommon.tErr[15] + " " + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2012:
            str = FNIScommon1.FNIScommon.tErr[16] + ": " + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2015:
            str = FNIScommon1.FNIScommon.tErr[19] + ":" + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2016:
            str = FNIScommon1.FNIScommon.tErr[20] + ":" + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2017:
            str = FNIScommon1.FNIScommon.tErr[21] + ":" + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2019:
            str = FNIScommon1.FNIScommon.tErr[1];
            break;
          case 2020:
            str = FNIScommon1.FNIScommon.tErr[22] + ": " + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2021:
            str = FNIScommon1.FNIScommon.tErr[2];
            break;
          case 2022:
            str = FNIScommon1.FNIScommon.tErr[23];
            break;
          case 2023:
            str = FNIScommon1.FNIScommon.tErr[24];
            break;
          case 2024:
            str = FNIScommon1.FNIScommon.tErr[25] + ":" + Conversion.Str((object) FNIScommon1.FNIScommon.ErrInt);
            break;
          case 2025:
            str = FNIScommon1.FNIScommon.tErr[26] + ":" + Conversion.Str((object) FNIScommon1.FNIScommon.ErrInt);
            break;
          case 2026:
            str = FNIScommon1.FNIScommon.tErr[27] + " " + FNIScommon1.FNIScommon.ErrString;
            break;
          case 2027:
            str = FNIScommon1.FNIScommon.tErr[28];
            break;
          case 2028:
            str = FNIScommon1.FNIScommon.tErr[29] + ":" + Conversion.Str((object) FNIScommon1.FNIScommon.ErrInt);
            break;
          case 2029:
            str = FNIScommon1.FNIScommon.tErr[30] + ":" + FNIScommon1.FNIScommon.ErrString;
            break;
          default:
            str = Information.Err().Description;
            break;
        }
        FNIScommon1.FNIScommon.LogOutput("\r\nERROR(" + Strings.Format((object) Information.Err().Number, "0") + "): " + str, true, true);
        FileSystemProxy fileSystem = MyProject.Computer.FileSystem;
        if (Information.Err().Number > 2000 & fileSystem.FileExists("temporary_logs\\DummyStart.txt"))
          fileSystem.DeleteFile("temporary_logs\\DummyStart.txt");
        FNIScommon1.FNIScommon.RetCode = Information.Err().Number;
      }

      public static void WriteWarning(string Warning)
      {
        FNIScommon1.FNIScommon.LogOutput(">>" + FNIScommon1.FNIScommon.tWarn[1] + ": " + Warning + "<<", true, true);
        checked { ++FNIScommon1.FNIScommon.WarningCount; }
      }

      public static void LogOutput(string LogText, bool ToTextBox, bool Newline = true)
      {
        if (ToTextBox)
        {
          if (Newline)
          {
            FNIScommon1.FNIScommon.Textbox.Text = FNIScommon1.FNIScommon.Textbox.Text + LogText + "\r\n";
            FNIScommon1.FNIScommon.Textbox.SelectionStart = FNIScommon1.FNIScommon.Textbox.Text.Length;
            FNIScommon1.FNIScommon.Textbox.ScrollToCaret();
          }
          else
            FNIScommon1.FNIScommon.Textbox.Text = FNIScommon1.FNIScommon.Textbox.Text + LogText;
        }
        if (FNIScommon1.FNIScommon.LogOpen)
        {
          if (Newline)
            FNIScommon1.FNIScommon.LogFile.WriteLine(LogText);
          else
            FNIScommon1.FNIScommon.LogFile.Write(LogText);
        }
        if (!ToTextBox)
          return;
        FNIScommon1.FNIScommon.Textbox.Update();
      }

      public static void FinishSub()
      {
        FNIScommon1.FNIScommon.Display_Dirs(false);
        FNIScommon1.FNIScommon.Textbox.SelectionStart = FNIScommon1.FNIScommon.Textbox.Text.Length;
        FNIScommon1.FNIScommon.Textbox.ScrollToCaret();
        if (FNIScommon1.FNIScommon.LogFile != null)
          FNIScommon1.FNIScommon.LogFile.Close();
        if (FNIScommon1.FNIScommon.BehaviorFile != null)
          FNIScommon1.FNIScommon.BehaviorFile.Close();
        FNIScommon1.FNIScommon.LogOpen = false;
      }

      public static int Check_hkx_type(string hkx_filename)
      {
        int num;
        if (!FNIScommon1.FNIScommon.isHKX_COMPAT)
        {
          num = 0;
        }
        else
        {
          if (MyProject.Computer.FileSystem.FileExists(hkx_filename.ToUpperInvariant()))
          {
            byte[] bytes = new byte[18];
            FileStream fileStream = File.Open(hkx_filename, FileMode.Open);
            byte[] array = bytes;
            int offset = 0;
            int count = 17;
            fileStream.Read(array, offset, count);
            fileStream.Close();
            Strings.InStr(hkx_filename, "LeitoKissingM", CompareMethod.Binary);
            if (Operators.CompareString(Strings.Left(Encoding.ASCII.GetString(bytes), 5), "<?xml", false) == 0)
            {
              num = 0;
              goto label_10;
            }
            else if (FNIScommon1.FNIScommon.SkyrimEdition == 1 & (int) bytes[16] != 4 | FNIScommon1.FNIScommon.SkyrimEdition == 2 & (int) bytes[16] != 8)
            {
              string str1 = Strings.Mid(hkx_filename, 20);
              string str2 = "";
              if (FNIScommon1.FNIScommon.SkyrimEdition == 2)
                str2 = " SE";
              string str3 = " not Skyrim";
              string str4 = str2;
              string str5 = " compatible";
              FNIScommon1.FNIScommon.WriteWarning(str1 + str3 + str4 + str5);
              num = 1;
              goto label_10;
            }
          }
          num = 0;
        }
label_10:
        return num;
      }

      public static int Check_all_hkx_files(string directory)
      {
        int num1 = 0;
        int num2;
        if (!FNIScommon1.FNIScommon.isHKX_COMPAT)
        {
          num2 = 0;
        }
        else
        {
          if (MyProject.Computer.FileSystem.DirectoryExists(directory))
          {
            List<string> stringList = FNIScommon1.FNIScommon.Read_Directory(directory, ".hkx");
            List<string>.Enumerator enumerator;
            try
            {
              enumerator = stringList.GetEnumerator();
              while (enumerator.MoveNext())
              {
                string current = enumerator.Current;
                checked { num1 += FNIScommon1.FNIScommon.Check_hkx_type(directory + current); }
              }
            }
            finally
            {
              enumerator.Dispose();
            }
          }
          num2 = num1;
        }
        return num2;
      }

      public static void Display_Dirs(bool atStart)
      {
        if (!FNIScommon1.FNIScommon.FullLog)
          return;
        if (atStart)
        {
          FNIScommon1.FNIScommon.List_Files(".\\");
          FNIScommon1.FNIScommon.List_Files("templates\\");
          FNIScommon1.FNIScommon.List_Files("temporary_logs\\");
          FNIScommon1.FNIScommon.List_Files("..\\..\\meshes\\actors\\character\\characters female\\");
          FNIScommon1.FNIScommon.List_Files("..\\..\\meshes\\actors\\character\\characters\\");
          FNIScommon1.FNIScommon.List_Files("..\\..\\meshes\\actors\\character\\animations\\");
          FNIScommon1.FNIScommon.List_Files("..\\..\\meshes\\actors\\character\\animations\\female\\");
          FNIScommon1.FNIScommon.List_Files("..\\..\\meshes\\actors\\character\\animations\\male\\");
          FNIScommon1.FNIScommon.List_Files("..\\..\\meshes\\actors\\character\\behaviors\\");
          if (FNIScommon1.FNIScommon.IsSteam)
            return;
          FNIScommon1.FNIScommon.LogOutput("Directory: .", false, true);
        }
        else
        {
          FNIScommon1.FNIScommon.List_Files("temporary_logs\\");
          FNIScommon1.FNIScommon.List_Files("..\\..\\meshes\\actors\\character\\characters female\\");
          FNIScommon1.FNIScommon.List_Files("..\\..\\meshes\\actors\\character\\characters\\");
          FNIScommon1.FNIScommon.List_Files("..\\..\\meshes\\actors\\character\\behaviors\\");
        }
      }

      public static void List_Files(string dir)
      {
        FileSystemProxy fileSystem = MyProject.Computer.FileSystem;
        string[] strArray = Strings.Split(dir, "\\", -1, CompareMethod.Binary);
        FNIScommon1.FNIScommon.LogOutput("Directory: " + strArray[checked (Information.UBound((Array) strArray, 1) - 1)], false, true);
        if (fileSystem.DirectoryExists(dir))
        {
          DirectoryInfo directoryInfo = new DirectoryInfo(dir);
          DirectoryInfo[] directories = directoryInfo.GetDirectories();
          int index1 = 0;
          while (index1 < directories.Length)
          {
            FNIScommon1.FNIScommon.LogOutput("                              <DIR>    " + directories[index1].Name, false, true);
            checked { ++index1; }
          }
          FileInfo[] files = directoryInfo.GetFiles();
          int index2 = 0;
          while (index2 < files.Length)
          {
            FileInfo fileInfo1 = files[index2];
            if (fileSystem.FileExists(dir + fileInfo1.Name))
            {
              FileInfo fileInfo2 = fileSystem.GetFileInfo(dir + fileInfo1.Name);
              string Expression = Strings.Format((object) fileInfo2.Length, " #,#0.");
              if (Strings.Len(Expression) < 16)
                Expression = Strings.Left("                ", checked (16 - Strings.Len(Expression))) + Expression;
              FNIScommon1.FNIScommon.LogOutput(" " + Conversions.ToString(fileInfo2.LastWriteTime) + Expression + "   " + fileInfo1.Name, false, true);
            }
            checked { ++index2; }
          }
        }
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static void Get_LanguageFiles(ComboBox Languagebox)
      {
        ArrayList arrayList = new ArrayList();
        string Right = "";
        if (MyProject.Computer.FileSystem.FileExists("..\\GenerateFNIS_for_Users\\MyPatches.txt".ToUpperInvariant()))
        {
          string[] strArray = Strings.Split(FNIScommon1.FNIScommon.ReadAFile("..\\GenerateFNIS_for_Users\\MyPatches.txt")[0], ":", -1, CompareMethod.Binary);
          if (Operators.CompareString(strArray[0], "Language", false) == 0)
            Right = Strings.LCase(Strings.RTrim(strArray[1]));
        }
        bool flag;
        if (MyProject.Computer.FileSystem.DirectoryExists("..\\GenerateFNIS_for_Users\\languages\\"))
        {
          string[] files = Directory.GetFiles("..\\GenerateFNIS_for_Users\\languages\\");
          int index1 = 0;
          while (index1 < files.Length)
          {
            string[] strArray = Strings.Split(files[index1], "\\", -1, CompareMethod.Binary);
            string str = Strings.LCase(strArray[Information.UBound((Array) strArray, 1)]);
            if (Operators.CompareString(Strings.Right(str, 4), ".txt", false) == 0)
            {
              flag = true;
              arrayList.Add((object) Strings.Left(str, checked (Strings.Len(str) - 4)));
            }
            checked { ++index1; }
          }
          arrayList.Sort();
          int num1 = -1;
          int num2 = checked (arrayList.Count - 1);
          int index2 = 0;
          while (index2 <= num2)
          {
            Languagebox.Items.Add(RuntimeHelpers.GetObjectValue(arrayList[index2]));
            if (Operators.CompareString(Strings.LCase(Conversions.ToString(arrayList[index2])), Right, false) == 0)
              num1 = index2;
            if (Operators.CompareString(Strings.LCase(Conversions.ToString(arrayList[index2])), "english", false) == 0 & num1 == -1)
              num1 = index2;
            checked { ++index2; }
          }
          Languagebox.SelectedIndex = num1;
        }
        if (flag)
          return;
        Information.Err().Description = "Language file(s) missing In Data\\Tools\\GenerateFNIS_for_Users\\languages";
        Information.Err().Raise(2021, (object) null, (object) null, (object) null, (object) null);
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static void Read_LanguagFile(ComboBox Languagebox)
      {
        string FileName = "..\\GenerateFNIS_for_Users\\languages\\" + Conversions.ToString(Languagebox.Items[Languagebox.SelectedIndex]) + ".txt";
        if (MyProject.Computer.FileSystem.FileExists(FileName.ToUpperInvariant()))
        {
          string[] strArray1 = FNIScommon1.FNIScommon.ReadAFile(FileName);
          FNIScommon1.FNIScommon.lastLanguage = Conversions.ToString(Languagebox.Items[Languagebox.SelectedIndex]);
          int num = Information.UBound((Array) strArray1, 1);
          int index1 = 0;
          while (index1 <= num)
          {
            int Length = Strings.InStr(strArray1[index1], "=", CompareMethod.Binary);
            if ((uint) Operators.CompareString(Strings.Left(strArray1[index1], Length), "'", false) > 0U & Length > 0)
            {
              string Expression1 = Strings.Replace(Strings.Replace(Strings.Replace(Strings.Left(strArray1[index1], checked (Length - 1)), " ", "", 1, -1, CompareMethod.Binary), "\n", "", 1, -1, CompareMethod.Binary), "\t", "", 1, -1, CompareMethod.Binary);
              string Expression2 = Strings.RTrim(Strings.Mid(strArray1[index1], checked (Length + 1)));
              string[] strArray2 = Strings.Split(Expression1, ".", -1, CompareMethod.Binary);
              string Left = Strings.LCase(strArray2[0]);
              int index2 = 0;
              if (Information.UBound((Array) strArray2, 1) > 0)
                index2 = Conversions.ToInteger(strArray2[1]);
              if (index2 >= 1 & index2 <= 32 & Strings.Len(Expression2) > 1)
              {
                if (Operators.CompareString(Left, "uiu", false) == 0)
                  FNIScommon1.FNIScommon.tUIu[index2] = Expression2;
                else if (Operators.CompareString(Left, "uim", false) == 0)
                  FNIScommon1.FNIScommon.tUIm[index2] = Expression2;
                else if (Operators.CompareString(Left, "msgu", false) == 0)
                  FNIScommon1.FNIScommon.tMsgu[index2] = Expression2;
                else if (Operators.CompareString(Left, "msgm", false) == 0)
                  FNIScommon1.FNIScommon.tMsgm[index2] = Expression2;
                else if (Operators.CompareString(Left, "warn", false) == 0)
                  FNIScommon1.FNIScommon.tWarn[index2] = Expression2;
                else if (Operators.CompareString(Left, "err", false) == 0)
                  FNIScommon1.FNIScommon.tErr[index2] = Expression2;
                else if (Operators.CompareString(Left, "ptch", false) == 0)
                  FNIScommon1.FNIScommon.tPatch[index2] = Expression2;
              }
            }
            checked { ++index1; }
          }
          if (Operators.CompareString(FNIScommon1.FNIScommon.tErr[3], "", false) != 0)
            return;
          FNIScommon1.FNIScommon.tErr[3] = "corrupt";
          FNIScommon1.FNIScommon.ErrString = FileName;
          Information.Err().Raise(2001, (object) null, (object) null, (object) null, (object) null);
        }
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static void Read_AllTemplates_File()
      {
        if (!MyProject.Computer.FileSystem.FileExists(FNIScommon1.FNIScommon.AllTemplatesFile))
        {
          FNIScommon1.FNIScommon.ErrString = FNIScommon1.FNIScommon.AllTemplatesFile;
          Information.Err().Raise(2001, (object) null, (object) null, (object) null, (object) null);
        }
        string[] strArray1 = FNIScommon1.FNIScommon.ReadAFile(FNIScommon1.FNIScommon.AllTemplatesFile);
        FNIScommon1.FNIScommon.nAllTemplates = 0;
        string[] strArray2 = strArray1;
        int index = 0;
        while (index < strArray2.Length)
        {
          string str = strArray2[index];
          int num;
          checked { ++num; }
          if (Operators.CompareString(Strings.Left(str, 1), "'", false) != 0)
          {
            string[] strArray3 = Strings.Split(str, " ", -1, CompareMethod.Binary);
            if (Information.UBound((Array) strArray3, 1) == 3)
            {
              FNIScommon1.FNIScommon.AllTemplates[FNIScommon1.FNIScommon.nAllTemplates].filename = Strings.LCase(strArray3[0]);
              FNIScommon1.FNIScommon.AllTemplates[FNIScommon1.FNIScommon.nAllTemplates].bAutomaticPatch = Operators.CompareString(strArray3[1], "1", false) == 0;
              FNIScommon1.FNIScommon.AllTemplates[FNIScommon1.FNIScommon.nAllTemplates].tDate = strArray3[2];
              uint.TryParse(strArray3[3], out FNIScommon1.FNIScommon.AllTemplates[FNIScommon1.FNIScommon.nAllTemplates].crc);
            }
            else
            {
              FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) checked (num + 1)) + " (" + FNIScommon1.FNIScommon.AllTemplatesFile + "):  " + str;
              Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
            }
            checked { ++FNIScommon1.FNIScommon.nAllTemplates; }
          }
          checked { ++index; }
        }
      }

      public static int Check_Template_Entry(string FullFileName, string firstLine)
      {
        string[] strArray = Strings.Split(FullFileName, "\\", -1, CompareMethod.Binary);
        int Rank = 1;
        int index1 = Information.UBound((Array) strArray, Rank);
        string Right = Strings.LCase(strArray[index1]);
        int num1 = -2;
        uint num2;
        uint crc;
        if (Operators.CompareString(Strings.Left(firstLine, 18), "<!-- FNIS template", false) == 0)
        {
          num1 = -1;
          long length = MyProject.Computer.FileSystem.GetFileInfo(FullFileName).Length;
          num2 = FNIScommon1.FNIScommon.CRC32_Calc(firstLine + Conversion.Str((object) length));
          int nAllTemplates = FNIScommon1.FNIScommon.nAllTemplates;
          int index2 = 0;
          while (index2 <= nAllTemplates)
          {
            if (Operators.CompareString(FNIScommon1.FNIScommon.AllTemplates[index2].filename, Right, false) == 0)
            {
              crc = FNIScommon1.FNIScommon.AllTemplates[index2].crc;
              if ((int) num2 == (int) crc)
                num1 = index2;
              index2 = FNIScommon1.FNIScommon.nAllTemplates;
            }
            checked { ++index2; }
          }
        }
        if (num1 < 0)
        {
          FNIScommon1.FNIScommon.WriteWarning(FNIScommon1.FNIScommon.tWarn[19] + " " + Right);
          if (FNIScommon1.FNIScommon.called_from_Projects)
          {
            if ((long) num2 > 0L)
              FNIScommon1.FNIScommon.LogOutput("Template with wrong crc: " + Right + "  crc read:" + Conversion.Str((object) crc) + " calculated:" + Conversion.Str((object) num2), true, true);
            else
              FNIScommon1.FNIScommon.LogOutput("Template with missing crc ", true, true);
          }
        }
        return num1;
      }

      public static int Read_Template_Entry(string FileName)
      {
        int num = -1;
        int nAllTemplates = FNIScommon1.FNIScommon.nAllTemplates;
        int index = 0;
        while (index <= nAllTemplates)
        {
          if (Operators.CompareString(FNIScommon1.FNIScommon.AllTemplates[index].filename, Strings.LCase(FileName), false) == 0)
          {
            num = index;
            index = FNIScommon1.FNIScommon.nAllTemplates;
          }
          checked { ++index; }
        }
        return num;
      }

      public static void CreateShortCut(string ProgramName)
      {
        string PathLink = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), ProgramName + ".lnk");
        FileSystemProxy fileSystem = MyProject.Computer.FileSystem;
        if (!(fileSystem.FileExists(PathLink.ToUpperInvariant()) | fileSystem.FileExists("DontAskAgainForLink.txt")))
        {
          switch (MessageBox.Show(FNIScommon1.FNIScommon.tMsgm[11] + "\r\n" + FNIScommon1.FNIScommon.tMsgm[12], ProgramName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1))
          {
            case DialogResult.Yes:
              try
              {
                // ISSUE: reference to a compiler-generated method
                // ISSUE: variable of a compiler-generated type
                IWshShortcut shortcut = (IWshShortcut) ((IWshShell3) Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8")))).CreateShortcut(PathLink);
                string executablePath = Application.ExecutablePath;
                shortcut.TargetPath = executablePath;
                int num = 1;
                shortcut.WindowStyle = num;
                string str1 = ProgramName;
                shortcut.Description = str1;
                string startupPath = Application.StartupPath;
                shortcut.WorkingDirectory = startupPath;
                string str2 = Application.ExecutablePath + ", 0";
                shortcut.IconLocation = str2;
                string empty = string.Empty;
                shortcut.Arguments = empty;
                // ISSUE: reference to a compiler-generated method
                shortcut.Save();
                break;
              }
              catch (Exception ex)
              {
                ProjectData.SetProjectError(ex);
                Exception exception = ex;
                int num = (int) MessageBox.Show(FNIScommon1.FNIScommon.tWarn[10] + " " + Environment.NewLine + exception.Message);
                ProjectData.ClearProjectError();
                break;
              }
            case DialogResult.Cancel:
              StreamWriter streamWriter = new StreamWriter("DontAskAgainForLink.txt");
              string str = "This file prevents being asked again, if you want a link on your desktop.";
              streamWriter.WriteLine(str);
              streamWriter.Close();
              break;
          }
        }
      }

      public static void Get_InstallDir()
      {
        int num1;
        int num2;
        try
        {
          ProjectData.ClearProjectError();
          num1 = 2;
          FNIScommon1.FNIScommon.InstallDir = Convert.ToString(RuntimeHelpers.GetObjectValue((FNIScommon1.FNIScommon.SkyrimEdition != 2 ? Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Bethesda Softworks\\Skyrim", false) : Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Bethesda Softworks\\Skyrim Special Edition", false)).GetValue("Installed Path")));
          if (Strings.InStr(Strings.LCase(FNIScommon1.FNIScommon.InstallDir), "skyrim", CompareMethod.Binary) <= 0)
            FNIScommon1.FNIScommon.InstallDir = Convert.ToString(RuntimeHelpers.GetObjectValue(Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 72850", false).GetValue("InstallLocation")));
          if (Strings.InStr(Strings.LCase(FNIScommon1.FNIScommon.InstallDir), "skyrim", CompareMethod.Binary) <= 0)
            FNIScommon1.FNIScommon.InstallDir = Convert.ToString(RuntimeHelpers.GetObjectValue(Registry.LocalMachine.OpenSubKey("SOFTWARE\\Bethesda Softworks\\Skyrim", false).GetValue("Installed Path")));
          if (Strings.InStr(Strings.LCase(FNIScommon1.FNIScommon.InstallDir), "skyrim", CompareMethod.Binary) <= 0)
            FNIScommon1.FNIScommon.InstallDir = Convert.ToString(RuntimeHelpers.GetObjectValue(Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 72850", false).GetValue("InstallLocation")));
          FNIScommon1.FNIScommon.IsSteam = Strings.InStr(Strings.LCase(FNIScommon1.FNIScommon.InstallDir), "steamapps", CompareMethod.Binary) > 0;
          goto label_12;
label_7:
          num2 = -1;
          switch (num1)
          {
            case 2:
              goto label_12;
          }
        }
        catch (Exception ex) when (
        {
          // ISSUE: unable to correctly present filter
          int num3;
          if (ex is Exception & (uint) num1 > 0U & num3 == 0)
          {
            SuccessfulFiltering;
          }
          else
            throw;
        }
        )
        {
          ProjectData.SetProjectError(ex);
          goto label_7;
        }
        throw ProjectData.CreateProjectError(-2146828237);
label_12:
        if (num2 == 0)
          return;
        ProjectData.ClearProjectError();
      }

      public static List<string> Read_Directory(string dir, string pattern)
      {
        int num = 0;
        List<string> stringList = new List<string>();
        if (MyProject.Computer.FileSystem.DirectoryExists(dir))
        {
          DirectoryInfo directoryInfo1 = new DirectoryInfo(dir);
          if (Operators.CompareString(pattern, "", false) == 0)
          {
            DirectoryInfo[] directories = directoryInfo1.GetDirectories();
            int index = 0;
            while (index < directories.Length)
            {
              DirectoryInfo directoryInfo2 = directories[index];
              stringList.Add(directoryInfo2.Name);
              checked { ++num; }
              checked { ++index; }
            }
          }
          else
          {
            FileInfo[] files = directoryInfo1.GetFiles();
            int index = 0;
            while (index < files.Length)
            {
              FileInfo fileInfo = files[index];
              if (Operators.CompareString(Strings.Right(Strings.LCase(fileInfo.Name), Strings.Len(pattern)), pattern, false) == 0)
              {
                stringList.Add(fileInfo.Name);
                checked { ++num; }
              }
              checked { ++index; }
            }
          }
        }
        return stringList;
      }

      public static bool WriteDebug(string FuncName, int Start, string DebugText1, string DebugText2)
      {
        string[] strArray1 = new string[4];
        if (!FNIScommon1.FNIScommon.DebugDataRead)
        {
          if (!MyProject.Computer.FileSystem.FileExists("..\\GenerateFNIS_for_Users\\DebugData.txt"))
          {
            FNIScommon1.FNIScommon.DebugOutput = 0;
          }
          else
          {
            string[] strArray2 = FNIScommon1.FNIScommon.ReadAFile("..\\GenerateFNIS_for_Users\\DebugData.txt");
            int index = 0;
            while (index < strArray2.Length)
            {
              string Expression = strArray2[index];
              string[] strArray3 = Strings.Split(Expression, "=", -1, CompareMethod.Binary);
              int num1 = -1;
              if (Versioned.IsNumeric((object) strArray3[1]))
                num1 = Conversions.ToInteger(strArray3[1]);
              if (Operators.CompareString(strArray3[0], "DebugOutput", false) == 0)
                FNIScommon1.FNIScommon.DebugOutput = num1;
              else if (Operators.CompareString(strArray3[0], "InputLineDeb", false) == 0)
                FNIScommon1.FNIScommon.InputLineDeb = num1;
              else if (Operators.CompareString(strArray3[0], "OutputLineDeb", false) == 0)
                FNIScommon1.FNIScommon.OutputLineDeb = num1;
              else if (Operators.CompareString(strArray3[0], "FromTemplate", false) == 0)
                FNIScommon1.FNIScommon.FromTemplate = num1;
              else if (Operators.CompareString(strArray3[0], "ToTemplate", false) == 0)
                FNIScommon1.FNIScommon.ToTemplate = num1;
              else if (Operators.CompareString(strArray3[0], "PreCache", false) == 0)
                FNIScommon1.FNIScommon.PreCache = num1;
              else if ((uint) Operators.CompareString(strArray3[0], "", false) > 0U | num1 < 0)
              {
                int num2 = (int) Interaction.MsgBox((object) ("Wrong Data in DebugDataFile: " + Expression), MsgBoxStyle.OkOnly, (object) null);
              }
              checked { ++index; }
            }
          }
          FNIScommon1.FNIScommon.DebugDataRead = true;
        }
        int debugIndent = FNIScommon1.FNIScommon.DebugIndent;
        int num = 0;
        while (num <= debugIndent)
        {
          strArray1[1] = strArray1[1] + ">>>";
          strArray1[2] = strArray1[2] + "   ";
          if (num != FNIScommon1.FNIScommon.DebugIndent)
            strArray1[0] = strArray1[0] + "<<<";
          checked { ++num; }
        }
        strArray1[0] = strArray1[0] + " ";
        strArray1[1] = strArray1[1] + " ";
        strArray1[2] = strArray1[2] + "  ";
        string[] strArray4 = new string[2]{ " OUT", "  IN" };
        if (Start != 99)
          checked { FNIScommon1.FNIScommon.DebugIndent += 2 * Start - 1; }
        if (FNIScommon1.FNIScommon.InputLine >= FNIScommon1.FNIScommon.FromTemplate & FNIScommon1.FNIScommon.InputLine <= FNIScommon1.FNIScommon.ToTemplate)
        {
          if (Start == 99)
          {
            FNIScommon1.FNIScommon.LogOutput(Conversion.Str((object) FNIScommon1.FNIScommon.OutputLine) + " " + DebugText1, false, true);
          }
          else
          {
            FNIScommon1.FNIScommon.LogOutput(strArray1[Start] + FuncName + strArray4[Start] + Conversion.Str((object) FNIScommon1.FNIScommon.InputLine) + Conversion.Str((object) FNIScommon1.FNIScommon.OutputLine), false, true);
            if (Operators.CompareString(DebugText1, "", false) != 0)
              FNIScommon1.FNIScommon.LogOutput(strArray1[2] + DebugText1, false, true);
            if (Operators.CompareString(DebugText2, "", false) != 0)
              FNIScommon1.FNIScommon.LogOutput(strArray1[2] + DebugText2, false, true);
          }
        }
        return !(FNIScommon1.FNIScommon.InputLineDeb == 0 & FNIScommon1.FNIScommon.OutputLineDeb == 0 | FNIScommon1.FNIScommon.InputLineDeb > 0 & FNIScommon1.FNIScommon.InputLineDeb != FNIScommon1.FNIScommon.InputLine | FNIScommon1.FNIScommon.OutputLineDeb > 0 & FNIScommon1.FNIScommon.OutputLineDeb != FNIScommon1.FNIScommon.OutputLine);
      }

      public static void DumpAnimList_Result()
      {
        string LogText = "";
        if (FNIScommon1.FNIScommon.DebugOutput < 3)
          return;
        FNIScommon1.FNIScommon.LogOutput("AnzAnim:" + Conversion.Str((object) FNIScommon1.FNIScommon.AnzAnim), false, true);
        FNIScommon1.FNIScommon.LogOutput("", false, true);
        FNIScommon1.FNIScommon.LogOutput("TriggerAE:", false, true);
        int index1 = 0;
        do
        {
          if (FNIScommon1.FNIScommon.CustomAEnum[index1] > 0)
          {
            FNIScommon1.FNIScommon.LogOutput("TriggerAEnum(" + Strings.Format((object) index1, "0") + "):" + Conversion.Str((object) FNIScommon1.FNIScommon.CustomAEnum[index1]), false, true);
            int num = checked (FNIScommon1.FNIScommon.CustomAEnum[index1] - 1);
            int index2 = 0;
            while (index2 <= num)
            {
              if (index2 % 5 == 0)
                LogText = Strings.Format((object) index2, "0") + ": ";
              LogText = LogText + Strings.Left(FNIScommon1.FNIScommon.CustomAE[index1, index2] + "                              ", 30) + " ";
              if (index2 == checked (FNIScommon1.FNIScommon.CustomAEnum[index1] - 1) | index2 % 10 == 4)
                FNIScommon1.FNIScommon.LogOutput(LogText, false, true);
              checked { ++index2; }
            }
          }
          checked { ++index1; }
        }
        while (index1 <= 2);
        FNIScommon1.FNIScommon.LogOutput("", false, true);
        FNIScommon1.FNIScommon.DumpArrayValues("AnimAE", FNIScommon1.FNIScommon.AnzAnim, FNIScommon1.FNIScommon.AnimAE, (string[]) null);
        FNIScommon1.FNIScommon.DumpArrayValues("AnimNumAE", FNIScommon1.FNIScommon.AnzAnim, FNIScommon1.FNIScommon.AnimNumAE, (string[]) null);
        FNIScommon1.FNIScommon.LogOutput("AnimAE/Time:", false, true);
        int num1 = checked (FNIScommon1.FNIScommon.AnzAnim - 1);
        int index3 = 0;
        while (index3 <= num1)
        {
          if (FNIScommon1.FNIScommon.AnimNumAE[index3] > 0)
            FNIScommon1.FNIScommon.LogOutput("Anim:" + Conversion.Str((object) index3) + " AnimNumAE:" + Conversion.Str((object) FNIScommon1.FNIScommon.AnimNumAE[index3]), false, true);
          int num2 = checked (FNIScommon1.FNIScommon.AnimNumAE[index3] - 1);
          int num3 = 0;
          while (num3 <= num2)
          {
            if (num3 % 10 == 0)
              LogText = Strings.Format((object) num3, "0") + ": ";
            LogText = LogText + Strings.Format((object) FNIScommon1.FNIScommon.AnimAEEvent[checked (FNIScommon1.FNIScommon.AnimAE[index3] + num3)], "0") + "/" + FNIScommon1.FNIScommon.AnimAETime[checked (FNIScommon1.FNIScommon.AnimAE[index3] + num3)] + " ";
            if (num3 == checked (FNIScommon1.FNIScommon.AnimNumAE[index3] - 1) | num3 % 10 == 9)
              FNIScommon1.FNIScommon.LogOutput(LogText, false, true);
            checked { ++num3; }
          }
          checked { ++index3; }
        }
        FNIScommon1.FNIScommon.LogOutput("", false, true);
        FNIScommon1.FNIScommon.DumpArrayValues("AnimAV", FNIScommon1.FNIScommon.AnzAnim, FNIScommon1.FNIScommon.AnimAV, (string[]) null);
        FNIScommon1.FNIScommon.DumpArrayValues("AnimNumAV", FNIScommon1.FNIScommon.AnzAnim, FNIScommon1.FNIScommon.AnimNumAV, (string[]) null);
        FNIScommon1.FNIScommon.DumpArrayValues("AnimAVid", FNIScommon1.FNIScommon.iAnimAV, FNIScommon1.FNIScommon.AnimAVid, (string[]) null);
        FNIScommon1.FNIScommon.LogOutput("", false, true);
        FNIScommon1.FNIScommon.LogOutput("AnzAnimVars  0:" + Conversion.Str((object) FNIScommon1.FNIScommon.AnzAnimVars[0]) + " 1:" + Conversion.Str((object) FNIScommon1.FNIScommon.AnzAnimVars[1]) + " 2:" + Conversion.Str((object) FNIScommon1.FNIScommon.AnzAnimVars[2]), false, true);
        FNIScommon1.FNIScommon.LogOutput("AnzAnimVars 0 (is_custom):", false, true);
        int anzAnimVar = FNIScommon1.FNIScommon.AnzAnimVars[0];
        int index4 = 0;
        while (index4 <= anzAnimVar)
        {
          if (index4 % 10 == 0)
            LogText = Strings.Format((object) index4, "0") + ": ";
          LogText = LogText + Strings.Left(FNIScommon1.FNIScommon.AnimVarName[index4, 0] + "          ", 10) + " ";
          if (index4 == checked (FNIScommon1.FNIScommon.AnzAnimVars[0] - 1) | index4 % 10 == 9)
            FNIScommon1.FNIScommon.LogOutput(LogText, false, true);
          checked { ++index4; }
        }
        FNIScommon1.FNIScommon.LogOutput("", false, true);
      }

      public static void DumpArrayValues(string name, int number, int[] Iarray = null, string[] Sarray = null)
      {
        string LogText = "";
        bool flag = Information.IsNothing((object) Sarray);
        int num1 = 10;
        if (!flag)
          num1 = 5;
        FNIScommon1.FNIScommon.LogOutput(name + ":", false, true);
        int num2 = checked (number - 1);
        int index = 0;
        while (index <= num2)
        {
          if (index % num1 == 0)
          {
            LogText = index.ToString() + ":";
            if (index < 10)
              LogText = " " + LogText;
          }
          if (flag)
          {
            string Expression = Iarray[index].ToString("0");
            LogText = LogText + Strings.Right("   ", Math.Max(1, checked (4 - Strings.Len(Expression)))) + Expression;
          }
          else
            LogText += Strings.Right("                      " + Sarray[index], 22);
          if (index == checked (number - 1) | index % num1 == checked (num1 - 1))
            FNIScommon1.FNIScommon.LogOutput(LogText, false, true);
          checked { ++index; }
        }
      }

      public struct AllTemplatesEntry
      {
        public string filename;
        public bool bAutomaticPatch;
        public string tDate;
        public uint crc;
      }

      public struct AEcc
      {
        public int actor;
        public string modname;
        public string AE;
        public uint AE_crc;
        public string comp;
      }

      public struct AnimFilecc
      {
        public int actor;
        public string modname;
        public string animfile;
        public uint animfile_crc;
        public int animfile_ID;
        public string animpath;
        public bool isbsa;
        public string comp;
      }

      public struct MRD_Data
      {
        public bool isMD;
        public int currAnim;
        public uint anim_crc32;
        public int modId;
        public int BOId;
        public string clipGenName;
        public bool firstOfBlock;
        public string[] @params;
      }

      public struct PatchAFData
      {
        public string name;
        public string path;
        public string ClipGenName;
        public int AnimationID;
        public bool inDefault;
        public bool inADSF;
        public bool inASDSF;
      }
    }
  }
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download