Anonymous Anonymous - 14 days ago
564 0

No description

C#

FNISaa1

using GenerateFNISforUsers.My;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using Microsoft.VisualBasic.MyServices;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;

namespace GenerateFNISforUsers
{
  [StandardModule]
  internal sealed class FNISaa1
  {
    public class FNISaa
    {
      public static string[] AAAnim = new string[546];
      public static uint[] AAAnimCrc32 = new uint[546];
      public static string[] AAPath = new string[546];
      public static int[] AAAnimToGroup = new int[546];
      public static string[] AAGroup = new string[55];
      public static uint[] AAGroupBehaviors = new uint[55];
      public static int[] AAnAnim = new int[55];
      public static int[] AAAnimIndex = new int[55];
      public static int[] AASetsPerGroup = new int[55];
      public static string[] AAPrefix = new string[31];
      public static FNISaa1.FNISaa.AASetType[] AASet = new FNISaa1.FNISaa.AASetType[129];
      public const int AAmaxGroup = 54;
      public const int AAmaxAnim = 545;
      public static int iAAGroup;
      public static int iAAAnim;
      public static int AATotalAnimCount;
      public static bool isAADataRead;
      public static int AACurrentPrefixID;
      public static int iAAPrefix;
      public static int iAASet;
      public static int nAAgroups;
      public static int nAAfilesdef;
      public static bool isAAdef;
      public static List<FNISaa1.FNISaa.AATriggerDef> AATriggerList;
      public static FNISaa1.FNISaa.AATriggerDef[] AATriggerArray;
      public const string sPCEA2MainFolder = "..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\";
      public const int MaxPCEA2Dir = 10;
      public const string PCEA2_Overview = "..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\PCEA2_Overview.txt";
      public const string PCEA2_FileList = "..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\FNIS_FNIS_PCEA2_List.txt";
      public const string PCEA2_Version = "..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\FNIS_FNIS_PCEA2_Version.txt";
      public static StreamWriter MyStreamWriter;
      public static List<FNISaa1.FNISaa.AAcrcInfo> AAcrcList;

      public static void AAInitialize()
      {
        FNISaa1.FNISaa.nAAgroups = 0;
        FNISaa1.FNISaa.nAAfilesdef = 0;
        FNISaa1.FNISaa.iAAGroup = 0;
        FNISaa1.FNISaa.iAAAnim = 0;
        FNISaa1.FNISaa.iAASet = 0;
        FNISaa1.FNISaa.iAAPrefix = 0;
        FNIScommon1.FNIScommon.isAAbehavior = 0U;
        FNISaa1.FNISaa.isAADataRead = false;
        Array.Clear((Array) FNISaa1.FNISaa.AAPrefix, 0, checked (Information.UBound((Array) FNISaa1.FNISaa.AAPrefix, 1) + 1));
        Array.Clear((Array) FNISaa1.FNISaa.AASetsPerGroup, 0, checked (Information.UBound((Array) FNISaa1.FNISaa.AASetsPerGroup, 1) + 1));
        FNISaa1.FNISaa.AATriggerList = new List<FNISaa1.FNISaa.AATriggerDef>();
        FNISaa1.FNISaa.AAcrcList = new List<FNISaa1.FNISaa.AAcrcInfo>();
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static void ExecAAPrefix(string Prefix, string ErrString2)
      {
        if (FNIScommon1.FNIScommon.DebugOutput > 1)
          FNIScommon1.FNIScommon.LogOutput("AA ExexAAPrefix mod: " + FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnzMod] + " Prefix: " + Prefix, false, true);
        FNIScommon1.FNIScommon.ErrString = ErrString2;
        if (FNISaa1.FNISaa.iAAPrefix == 30)
        {
          FNIScommon1.FNIScommon.LogOutput("Too many mods with Alternate Animations (>30)", true, true);
          Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
        }
        if (Strings.Len(Prefix) != 3)
          Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
        int num = checked (FNISaa1.FNISaa.iAAPrefix - 1);
        int index = 0;
        while (index <= num)
        {
          if (Operators.CompareString(Strings.LCase(Prefix), Strings.LCase(FNISaa1.FNISaa.AAPrefix[index]), false) == 0)
          {
            FNIScommon1.FNIScommon.LogOutput("\r\n\r\nSame Alternate Animation prefix >" + Strings.LCase(Prefix) + "< used by DIFFERENT mods !!!!!", true, false);
            Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
          }
          checked { ++index; }
        }
        FNISaa1.FNISaa.AAPrefix[FNISaa1.FNISaa.iAAPrefix] = Prefix;
        checked { ++FNISaa1.FNISaa.iAAPrefix; }
        FNISaa1.FNISaa.isAAdef = true;
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static void ExecAASet(string Group, string Number, string ErrString2)
      {
        int anzAa = FNIScommon1.FNIScommon.Anz_aa;
        if (FNIScommon1.FNIScommon.DebugOutput > 1)
          FNIScommon1.FNIScommon.LogOutput("AA ExexAASet mod: " + FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnzMod] + " Group: " + Group + " Number: " + Number, false, true);
        int integer = Conversions.ToInteger(Number);
        FNIScommon1.FNIScommon.ErrString = ErrString2;
        if (!FNISaa1.FNISaa.isAAdef)
          Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
        if (integer < 1 | integer > 10)
        {
          FNIScommon1.FNIScommon.LogOutput("Wrong number of Alternate Animation groups (<1, > 10)", true, true);
          Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
        }
        if (FNISaa1.FNISaa.iAAPrefix == 128)
        {
          FNIScommon1.FNIScommon.LogOutput("Too many Alternate Animation groups overall (> 128)", true, true);
          Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
        }
        if (!FNISaa1.FNISaa.isAADataRead)
          FNISaa1.FNISaa.ReadAAgroups_and_animations();
        int num1 = checked (FNISaa1.FNISaa.iAAGroup - 1);
        int index1 = 0;
        bool flag;
        while (index1 <= num1)
        {
          if (Operators.CompareString(Strings.LCase(Group), FNISaa1.FNISaa.AAGroup[index1], false) == 0)
          {
            flag = true;
            FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].group = index1;
            FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].imod = FNIScommon1.FNIScommon.AnzMod;
            FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].iPrefix = checked (FNISaa1.FNISaa.iAAPrefix - 1);
            FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].nGroups = integer;
            FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].nAnims = 0;
            // ISSUE: variable of a reference type
            int& local;
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            int num2 = checked (^(local = @FNISaa1.FNISaa.AASetsPerGroup[index1]) + integer);
            // ISSUE: explicit reference operation
            ^local = num2;
            index1 = FNISaa1.FNISaa.iAAGroup;
          }
          checked { ++index1; }
        }
        if (!flag)
          Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
        FNIScommon1.FNIScommon.isAAbehavior |= FNISaa1.FNISaa.AAGroupBehaviors[FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].group];
        if (FNIScommon1.FNIScommon.DebugOutput > 1)
          FNIScommon1.FNIScommon.LogOutput(" Group " + Conversions.ToString(FNISaa1.FNISaa.iAASet) + ": " + Conversions.ToString(FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].group) + " Behaviors: " + Conversions.ToString(FNISaa1.FNISaa.AAGroupBehaviors[FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].group]) + " / " + Conversion.Hex(FNISaa1.FNISaa.AAGroupBehaviors[FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].group]), false, true);
        ulong[] numArray = new ulong[checked (integer + 1)];
        FileSystemProxy fileSystem = MyProject.Computer.FileSystem;
        int num3 = checked (integer - 1);
        int index2 = 0;
        while (index2 <= num3)
        {
          "..\\..\\meshes\\actors\\character\\animations\\" + FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnzMod] + " " + FNISaa1.FNISaa.AAPrefix[FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].iPrefix] + Strings.Format((object) index2, "") + "_*.hkx";
          uint num2 = FNIScommon1.FNIScommon.CRC32_Calc("meshes\\actors\\character\\animations\\" + Strings.LCase(FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnzMod]));
          string String1 = Strings.LCase("\\" + Strings.Join(Directory.GetFiles("..\\..\\meshes\\actors\\character\\animations\\" + FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnzMod], FNISaa1.FNISaa.AAPrefix[FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].iPrefix] + Strings.Format((object) index2, "") + "_*.hkx"), "\\") + "\\");
          int num4 = checked (FNISaa1.FNISaa.AAnAnim[FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].group] - 1);
          int num5 = 0;
          while (num5 <= num4)
          {
            string str = FNISaa1.FNISaa.AAPrefix[FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].iPrefix] + Strings.Format((object) index2, "") + "_" + FNISaa1.FNISaa.AAAnim[checked (FNISaa1.FNISaa.AAAnimIndex[FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].group] + num5)];
            if (Strings.InStr(String1, "\\" + str + "\\", CompareMethod.Binary) > 0)
            {
              numArray[index2] = numArray[index2] | (ulong) (1L << num5);
              checked { ++FNIScommon1.FNIScommon.Anz_aa; }
              // ISSUE: variable of a reference type
              int& local;
              // ISSUE: explicit reference operation
              // ISSUE: explicit reference operation
              int num6 = checked (^(local = @FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].nAnims) + 1);
              // ISSUE: explicit reference operation
              ^local = num6;
              FNISaa1.FNISaa.AAcrcInfo aacrcInfo;
              aacrcInfo.FileName = Strings.LCase(Strings.Left(str, checked (Strings.Len(str) - 4)));
              aacrcInfo.crc32 = FNIScommon1.FNIScommon.CRC32_Calc(aacrcInfo.FileName);
              aacrcInfo.path_crc = num2;
              aacrcInfo.reffile_crc = FNIScommon1.FNIScommon.CRC32_Calc(Strings.Mid(aacrcInfo.FileName, 6));
              FNISaa1.FNISaa.AAcrcList.Add(aacrcInfo);
              if (FNIScommon1.FNIScommon.DebugOutput > 2)
                FNIScommon1.FNIScommon.LogOutput("AA file found: " + str, false, true);
              FNIScommon1.FNIScommon.Check_hkx_type("..\\..\\meshes\\actors\\character\\animations\\" + FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnzMod] + "\\" + str);
            }
            else if (FNIScommon1.FNIScommon.DebugOutput > 1)
              FNIScommon1.FNIScommon.LogOutput("AA file doesn't exist. mod: " + FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnzMod] + " file: " + str, false, true);
            checked { ++num5; }
          }
          checked { ++index2; }
        }
        FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].defPattern = numArray;
        string str1 = " -";
        int num7 = checked (Information.UBound((Array) FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].defPattern, 1) - 1);
        int index3 = 0;
        while (index3 <= num7)
        {
          str1 = str1 + " " + Conversion.Hex(FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].defPattern[index3]);
          checked { ++index3; }
        }
        // ISSUE: explicit reference operation
        // ISSUE: variable of a reference type
        FNISaa1.FNISaa.AASetType& local1 = @FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet];
        checked { FNISaa1.FNISaa.nAAgroups += integer; }
        checked { FNISaa1.FNISaa.nAAfilesdef += integer * FNISaa1.FNISaa.AAnAnim[FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].group]; }
        FNIScommon1.FNIScommon.LogOutput("AA Set" + Conversion.Str((object) FNISaa1.FNISaa.iAASet) + " - mod: " + FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnzMod] + " group: " + Group + " ngroups:" + Conversion.Str((object) integer) + " files found/missing:" + Conversion.Str((object) checked (FNIScommon1.FNIScommon.Anz_aa - anzAa)) + "/" + Conversion.Str((object) checked (integer * FNISaa1.FNISaa.AAnAnim[FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].group] + anzAa - FNIScommon1.FNIScommon.Anz_aa)) + " Bhav.pattern: " + Conversion.Hex(FNISaa1.FNISaa.AAGroupBehaviors[FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].group]), false, true);
        if (FNIScommon1.FNIScommon.DebugOutput > 1)
          FNIScommon1.FNIScommon.LogOutput("AA Set data - group:" + Conversion.Str((object) FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].group) + " imod:" + Conversion.Str((object) FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].imod) + " ngroups:" + Conversion.Str((object) FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].nGroups) + " iPrefix:" + Conversion.Str((object) FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].iPrefix) + " nAnims:" + Conversion.Str((object) FNISaa1.FNISaa.AASet[FNISaa1.FNISaa.iAASet].nAnims), false, true);
        checked { ++FNISaa1.FNISaa.iAASet; }
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static void ExecAATrigger(string line, string ErrString2)
      {
        FNIScommon1.FNIScommon.ErrString = ErrString2;
        if (!FNISaa1.FNISaa.isAAdef)
          Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
        string[] strArray = Strings.Split(line, "/", -1, CompareMethod.Binary);
        FNISaa1.FNISaa.AATriggerDef aaTriggerDef = new FNISaa1.FNISaa.AATriggerDef();
        uint num1 = FNIScommon1.FNIScommon.CRC32_Calc(Strings.Mid(Strings.LCase(strArray[1]), 6));
        int num2 = checked (FNISaa1.FNISaa.iAAAnim - 1);
        int index1 = 0;
        while (index1 <= num2)
        {
          if ((int) num1 == (int) FNISaa1.FNISaa.AAAnimCrc32[index1])
          {
            aaTriggerDef.iAnim = index1;
            index1 = checked (FNISaa1.FNISaa.iAAAnim + 1);
          }
          checked { ++index1; }
        }
        if (index1 == FNISaa1.FNISaa.iAAAnim)
          Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
        aaTriggerDef.group = FNISaa1.FNISaa.AAAnimToGroup[aaTriggerDef.iAnim];
        // ISSUE: variable of a reference type
        int& local1;
        // ISSUE: explicit reference operation
        // ISSUE: explicit reference operation
        int num3 = checked (^(local1 = @aaTriggerDef.iAnim) - FNISaa1.FNISaa.AAAnimIndex[FNISaa1.FNISaa.AAAnimToGroup[aaTriggerDef.iAnim]]);
        // ISSUE: explicit reference operation
        ^local1 = num3;
        int integer;
        if (Versioned.IsNumeric((object) Strings.Mid(strArray[1], 4, 1)))
        {
          integer = Conversions.ToInteger(Strings.Mid(strArray[1], 4, 1));
          aaTriggerDef.setIndex = checked (integer + 1);
        }
        else
          Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
        int num4 = checked (FNISaa1.FNISaa.iAASet - 1);
        int index2 = 0;
        int nGroups;
        while (index2 <= num4)
        {
          if (FNISaa1.FNISaa.AASet[index2].group == aaTriggerDef.group)
          {
            if (FNISaa1.FNISaa.AASet[index2].imod == FNIScommon1.FNIScommon.AnzMod)
            {
              if (integer > FNISaa1.FNISaa.AASet[index2].nGroups)
                Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
              nGroups = FNISaa1.FNISaa.AASet[index2].nGroups;
            }
            else
            {
              // ISSUE: variable of a reference type
              int& local2;
              // ISSUE: explicit reference operation
              // ISSUE: explicit reference operation
              int num5 = checked (^(local2 = @aaTriggerDef.setIndex) + FNISaa1.FNISaa.AASet[index2].nGroups);
              // ISSUE: explicit reference operation
              ^local2 = num5;
            }
          }
          checked { ++index2; }
        }
        if (nGroups == 0)
          Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
        aaTriggerDef.currentTemplate = -1;
        aaTriggerDef.nTriggers = checked (Information.UBound((Array) strArray, 1) - 2) / 2;
        aaTriggerDef.Triggers = "";
        int num6 = checked (Information.UBound((Array) strArray, 1) - 2);
        int index3 = 2;
        while (index3 <= num6)
        {
          string[] SourceArray = Strings.Split(strArray[checked (index3 + 1)], ".", -1, CompareMethod.Binary);
          if (Information.UBound((Array) SourceArray, 1) != 1 | !Versioned.IsNumeric((object) Strings.Join(SourceArray, "")))
            Information.Err().Raise(2011, (object) null, (object) null, (object) null, (object) null);
          aaTriggerDef.Triggers = aaTriggerDef.Triggers + "/" + strArray[index3] + "/" + strArray[checked (index3 + 1)];
          checked { index3 += 2; }
        }
        FNISaa1.FNISaa.AATriggerList.Add(aaTriggerDef);
        FNIScommon1.FNIScommon.LogOutput("FNIS AA Trigger " + strArray[1] + " group:" + Conversion.Str((object) aaTriggerDef.group) + " iAnim:" + Conversion.Str((object) aaTriggerDef.iAnim) + " triggers: " + aaTriggerDef.Triggers, false, true);
      }

      public static void ReadAAgroups_and_animations()
      {
        string[] strArray1 = FNIScommon1.FNIScommon.ReadAFile("Alternate_AnimationGroups.txt");
        int num1 = Information.UBound((Array) strArray1, 1);
        int index1 = 0;
        while (index1 <= num1)
        {
          string str1 = strArray1[index1];
          if (Operators.CompareString(Strings.Left(str1, 1), "*", false) != 0)
          {
            if (Operators.CompareString(Strings.Left(str1, 1), "'", false) == 0)
            {
              FNISaa1.FNISaa.AAGroup[FNISaa1.FNISaa.iAAGroup] = Strings.Mid(str1, 2);
              FNISaa1.FNISaa.AAAnimIndex[FNISaa1.FNISaa.iAAGroup] = FNISaa1.FNISaa.iAAAnim;
              FNISaa1.FNISaa.AAnAnim[FNISaa1.FNISaa.iAAGroup] = 0;
              FNISaa1.FNISaa.AAGroupBehaviors[FNISaa1.FNISaa.iAAGroup] = 0U;
              checked { ++FNISaa1.FNISaa.iAAGroup; }
            }
            else if (Strings.Len(str1) > 5)
            {
              string[] strArray2 = Strings.Split(str1, " ", -1, CompareMethod.Binary);
              int index2 = 0;
              string str2 = strArray2[index2];
              FNISaa1.FNISaa.AAAnim[FNISaa1.FNISaa.iAAAnim] = str2;
              // ISSUE: variable of a reference type
              int& local;
              // ISSUE: explicit reference operation
              // ISSUE: explicit reference operation
              int num2 = checked (^(local = @FNISaa1.FNISaa.AAnAnim[FNISaa1.FNISaa.iAAGroup - 1]) + 1);
              // ISSUE: explicit reference operation
              ^local = num2;
              int num3 = Strings.InStrRev(str2, "\\", -1, CompareMethod.Binary);
              if (num3 > 0)
              {
                FNISaa1.FNISaa.AAAnim[FNISaa1.FNISaa.iAAAnim] = Strings.Mid(str2, checked (num3 + 1));
                FNISaa1.FNISaa.AAPath[FNISaa1.FNISaa.iAAAnim] = Strings.Left(str2, checked (num3 - 1));
              }
              else
              {
                FNISaa1.FNISaa.AAAnim[FNISaa1.FNISaa.iAAAnim] = str2;
                FNISaa1.FNISaa.AAPath[FNISaa1.FNISaa.iAAAnim] = "";
              }
              FNISaa1.FNISaa.AAAnimToGroup[FNISaa1.FNISaa.iAAAnim] = checked (FNISaa1.FNISaa.iAAGroup - 1);
              FNISaa1.FNISaa.AAAnimCrc32[FNISaa1.FNISaa.iAAAnim] = FNIScommon1.FNIScommon.CRC32_Calc(FNISaa1.FNISaa.AAAnim[FNISaa1.FNISaa.iAAAnim]);
              checked { ++FNISaa1.FNISaa.iAAAnim; }
              int index3 = 1;
              string str3 = strArray2[index3];
              int num4 = 0;
              do
              {
                if (Operators.CompareString(Strings.Mid(str3, checked (num4 + 1), 1), "0", false) != 0)
                {
                  FNISaa1.FNISaa.AAGroupBehaviors[checked (FNISaa1.FNISaa.iAAGroup - 1)] = FNISaa1.FNISaa.AAGroupBehaviors[checked (FNISaa1.FNISaa.iAAGroup - 1)] | checked ((uint) (1 << 17 - num4));
                  if (FNIScommon1.FNIScommon.DebugOutput > 1)
                    FNIScommon1.FNIScommon.LogOutput("AA GroupBehaviors " + FNISaa1.FNISaa.AAGroup[checked (FNISaa1.FNISaa.iAAGroup - 1)] + " " + Conversion.Hex(FNISaa1.FNISaa.AAGroupBehaviors[checked (FNISaa1.FNISaa.iAAGroup - 1)]), false, true);
                }
                checked { ++num4; }
              }
              while (num4 <= 17);
            }
            checked { ++index1; }
          }
          else
            break;
        }
        FNISaa1.FNISaa.isAADataRead = true;
        FNIScommon1.FNIScommon.LogOutput("AA read." + Conversion.Str((object) FNISaa1.FNISaa.iAAGroup) + " groups," + Conversion.Str((object) FNISaa1.FNISaa.iAAAnim) + " animations.", false, true);
        if (FNIScommon1.FNIScommon.DebugOutput <= 1)
          return;
        int num5 = checked (FNISaa1.FNISaa.iAAGroup - 1);
        int index4 = 0;
        while (index4 <= num5)
        {
          FNIScommon1.FNIScommon.LogOutput("AA group" + Conversion.Str((object) index4) + ": " + FNISaa1.FNISaa.AAGroup[index4] + Conversion.Str((object) FNISaa1.FNISaa.AAnAnim[index4]) + " anims", false, true);
          checked { ++index4; }
        }
      }

      public static void AA_PostProcessing()
      {
        if (FNIScommon1.FNIScommon.Anz_aa > 0)
        {
          FNIScommon1.FNIScommon.AnimFileAA = new string[checked (FNIScommon1.FNIScommon.Anz_aa + 1)];
          int num1 = checked (FNISaa1.FNISaa.iAASet - 1);
          int index1 = 0;
          while (index1 <= num1)
          {
            int num2 = checked (FNISaa1.FNISaa.AASet[index1].nGroups - 1);
            int index2 = 0;
            while (index2 <= num2)
            {
              ulong num3 = FNISaa1.FNISaa.AASet[index1].defPattern[index2];
              int num4 = checked (FNISaa1.FNISaa.AAnAnim[FNISaa1.FNISaa.AASet[index1].group] - 1);
              int num5 = 0;
              while (num5 <= num4)
              {
                int index3;
                if (Decimal.Compare(new Decimal(num3 & (ulong) (1L << num5)), Decimal.Zero) > 0 & index3 < FNIScommon1.FNIScommon.Anz_aa)
                {
                  FNIScommon1.FNIScommon.AnimFileAA[index3] = FNIScommon1.FNIScommon.MyMod[FNISaa1.FNISaa.AASet[index1].imod] + "\\" + FNISaa1.FNISaa.AAPrefix[FNISaa1.FNISaa.AASet[index1].iPrefix] + Strings.Format((object) index2, "") + "_" + FNISaa1.FNISaa.AAAnim[checked (FNISaa1.FNISaa.AAAnimIndex[FNISaa1.FNISaa.AASet[index1].group] + num5)];
                  checked { ++index3; }
                }
                checked { ++num5; }
              }
              checked { ++index2; }
            }
            checked { ++index1; }
          }
        }
        FNISaa1.FNISaa.AATriggerArray = FNISaa1.FNISaa.AATriggerList.ToArray();
      }

      public static void GetTemplateSpecificTriggerdefs(int iTrigger)
      {
        if (FNISaa1.FNISaa.AATriggerArray[iTrigger].currentTemplate == FNIScommon1.FNIScommon.CurrentTemplateType)
          return;
        FNISaa1.FNISaa.AATriggerArray[iTrigger].currentTemplate = FNIScommon1.FNIScommon.CurrentTemplateType;
        FNISaa1.FNISaa.AATriggerArray[iTrigger].CurrentnTriggers = 0;
        FNISaa1.FNISaa.AATriggerArray[iTrigger].CurrentTriggers = "";
        FNIScommon1.FNIScommon.ReadAllAEfile();
        string[] strArray = Strings.Split(FNISaa1.FNISaa.AATriggerArray[iTrigger].Triggers, "/", -1, CompareMethod.Binary);
        int nTriggers = FNISaa1.FNISaa.AATriggerArray[iTrigger].nTriggers;
        int num1 = 1;
        while (num1 <= nTriggers)
        {
          string Right = Strings.LCase(strArray[checked (num1 * 2 - 1)]);
          int num2 = -1;
          int num3 = checked (FNIScommon1.FNIScommon.AllAEnum[FNIScommon1.FNIScommon.CurrentTemplateType] - 1);
          int num4 = 0;
          while (num4 <= num3)
          {
            if (Operators.CompareString(Strings.LCase(FNIScommon1.FNIScommon.AllAE[checked (FNIScommon1.FNIScommon.AllAEfirst[FNIScommon1.FNIScommon.CurrentTemplateType] + num4)]), Right, false) == 0)
            {
              num2 = num4;
              num4 = 9999;
            }
            checked { ++num4; }
          }
          if (num2 >= 0)
          {
            // ISSUE: variable of a reference type
            int& local1;
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            int num5 = checked (^(local1 = @FNISaa1.FNISaa.AATriggerArray[iTrigger].CurrentnTriggers) + 1);
            // ISSUE: explicit reference operation
            ^local1 = num5;
            // ISSUE: variable of a reference type
            string& local2;
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            string str = ^(local2 = @FNISaa1.FNISaa.AATriggerArray[iTrigger].CurrentTriggers) + Strings.Format((object) num2, "") + "/" + strArray[checked (num1 * 2)] + "/";
            // ISSUE: explicit reference operation
            ^local2 = str;
          }
          checked { ++num1; }
        }
      }

      public static void Patch_FNIS_aa_pex()
      {
        List<FNISaa1.FNISaa.AASetType> aaSetTypeList = new List<FNISaa1.FNISaa.AASetType>();
        int num1 = checked (FNISaa1.FNISaa.iAASet - 1);
        int index1 = 0;
        while (index1 <= num1)
        {
          aaSetTypeList.Add(FNISaa1.FNISaa.AASet[index1]);
          checked { ++index1; }
        }
        List<FNISaa1.FNISaa.AASetType> source1 = aaSetTypeList;
        Func<FNISaa1.FNISaa.AASetType, int> keySelector1;
        // ISSUE: reference to a compiler-generated field
        if (FNISaa1.FNISaa._Closure\u0024__.\u0024I37\u002D0 != null)
        {
          // ISSUE: reference to a compiler-generated field
          keySelector1 = FNISaa1.FNISaa._Closure\u0024__.\u0024I37\u002D0;
        }
        else
        {
          // ISSUE: reference to a compiler-generated field
          FNISaa1.FNISaa._Closure\u0024__.\u0024I37\u002D0 = keySelector1 = (Func<FNISaa1.FNISaa.AASetType, int>) (AASetEntry => AASetEntry.group);
        }
        IOrderedEnumerable<FNISaa1.FNISaa.AASetType> source2 = source1.OrderBy<FNISaa1.FNISaa.AASetType, int>(keySelector1);
        Func<FNISaa1.FNISaa.AASetType, int> keySelector2;
        // ISSUE: reference to a compiler-generated field
        if (FNISaa1.FNISaa._Closure\u0024__.\u0024I37\u002D1 != null)
        {
          // ISSUE: reference to a compiler-generated field
          keySelector2 = FNISaa1.FNISaa._Closure\u0024__.\u0024I37\u002D1;
        }
        else
        {
          // ISSUE: reference to a compiler-generated field
          FNISaa1.FNISaa._Closure\u0024__.\u0024I37\u002D1 = keySelector2 = (Func<FNISaa1.FNISaa.AASetType, int>) (AASetEntry => AASetEntry.iPrefix);
        }
        IOrderedEnumerable<FNISaa1.FNISaa.AASetType> source3 = source2.ThenBy<FNISaa1.FNISaa.AASetType, int>(keySelector2);
        Func<FNISaa1.FNISaa.AASetType, VB\u0024AnonymousType_0<int, int, int>> selector;
        // ISSUE: reference to a compiler-generated field
        if (FNISaa1.FNISaa._Closure\u0024__.\u0024I37\u002D2 != null)
        {
          // ISSUE: reference to a compiler-generated field
          selector = FNISaa1.FNISaa._Closure\u0024__.\u0024I37\u002D2;
        }
        else
        {
          // ISSUE: reference to a compiler-generated field
          FNISaa1.FNISaa._Closure\u0024__.\u0024I37\u002D2 = selector = AASetEntry => new
          {
            iPrefix = AASetEntry.iPrefix,
            group = AASetEntry.group,
            nGroups = AASetEntry.nGroups
          };
        }
        IEnumerable<VB\u0024AnonymousType_0<int, int, int>> datas = source3.Select(selector);
        int[] numArray1 = new int[55];
        int index2 = 0;
        do
        {
          numArray1[index2] = 1;
          checked { ++index2; }
        }
        while (index2 <= 53);
        long isAabehavior = (long) FNIScommon1.FNIScommon.isAAbehavior;
        FNIScommon1.FNIScommon.LogOutput("Creating file FNIS_aa.pex", false, true);
        byte[] numArray2 = File.ReadAllBytes("templates\\FNIS_aa2_TEMPLATE.pex");
        numArray2[617] = checked ((byte) (48 + unchecked (FNISaa1.FNISaa.iAAPrefix / 10)));
        numArray2[618] = checked ((byte) (48 + unchecked (FNISaa1.FNISaa.iAAPrefix % 10)));
        int num2 = checked (FNISaa1.FNISaa.iAAPrefix - 1);
        int index3 = 0;
        while (index3 <= num2)
        {
          int num3 = 0;
          do
          {
            Strings.Asc(Strings.Mid(FNISaa1.FNISaa.AAPrefix[index3], checked (num3 + 1), 1));
            numArray2[checked (388 + index3 * 5 + num3)] = checked ((byte) Strings.Asc(Strings.Mid(FNISaa1.FNISaa.AAPrefix[index3], num3 + 1, 1)));
            checked { ++num3; }
          }
          while (num3 <= 2);
          checked { ++index3; }
        }
        IEnumerator<VB\u0024AnonymousType_0<int, int, int>> enumerator;
        int num4;
        try
        {
          enumerator = datas.GetEnumerator();
          while (enumerator.MoveNext())
          {
            var current = enumerator.Current;
            numArray2[checked (786 + num4 * 8 + 0)] = checked ((byte) (48 + unchecked (current.iPrefix / 10)));
            numArray2[checked (786 + num4 * 8 + 1)] = checked ((byte) (48 + unchecked (current.iPrefix % 10)));
            numArray2[checked (786 + num4 * 8 + 2)] = checked ((byte) (48 + unchecked (current.group / 10)));
            numArray2[checked (786 + num4 * 8 + 3)] = checked ((byte) (48 + unchecked (current.group % 10)));
            numArray2[checked (786 + num4 * 8 + 4)] = checked ((byte) (48 + unchecked (numArray1[current.group] / 10)));
            numArray2[checked (786 + num4 * 8 + 5)] = checked ((byte) (48 + unchecked (numArray1[current.group] % 10)));
            // ISSUE: variable of a reference type
            int& local;
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            int num3 = checked (^(local = @numArray1[current.group]) + current.nGroups);
            // ISSUE: explicit reference operation
            ^local = num3;
            checked { ++num4; }
          }
        }
        finally
        {
          if (enumerator != null)
            enumerator.Dispose();
        }
        numArray2[621] = checked ((byte) (48 + unchecked (FNISaa1.FNISaa.iAASet / 100)));
        numArray2[622] = checked ((byte) (48 + unchecked (FNISaa1.FNISaa.iAASet % 100 / 10)));
        numArray2[623] = checked ((byte) (48 + unchecked (FNISaa1.FNISaa.iAASet % 10)));
        int num5 = checked ((int) unchecked ((long) FNIScommon1.FNIScommon.CRC32_Calc(numArray2, 786, checked (786 + num4 * 8 - 3)) % 500000L) + (int) unchecked ((long) FNIScommon1.FNIScommon.CRC32_Calc(numArray2, 388, checked (388 + FNISaa1.FNISaa.iAAPrefix * 5 - 3)) % 500000L));
        int num6 = 0;
        do
        {
          numArray2[checked (631 - num6)] = checked ((byte) (48 + unchecked (num5 % 10)));
          num5 /= 10;
          checked { ++num6; }
        }
        while (num6 <= 5);
        File.WriteAllBytes("..\\..\\scripts\\FNIS_aa2.pex", numArray2);
      }

      [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
      public static void PCEA2()
      {
        string[] PCEA2Folder = new string[11];
        bool[,] flagArray1 = new bool[11, 546];
        string[] strArray1 = new string[11];
        int[] numArray1 = new int[11];
        string[,] strArray2 = new string[11, 55];
        string[,] strArray3 = new string[11, 55];
        string[] BitPattern = new string[11];
        int[] numArray2 = new int[546];
        int[,] numArray3 = new int[11, 55];
        bool[] flagArray2 = new bool[55];
        int[,] numArray4 = new int[12, 55];
        List<FNISaa1.FNISaa.AAfileInfo>[] aafileInfoListArray = new List<FNISaa1.FNISaa.AAfileInfo>[12];
        FNISaa1.FNISaa.AAfileInfo aafileInfo1 = new FNISaa1.FNISaa.AAfileInfo();
        if (!FNISaa1.FNISaa.isAADataRead)
          FNISaa1.FNISaa.ReadAAgroups_and_animations();
        int num1 = 0;
        int nPCEA2Folders;
        do
        {
          string[] directories = Directory.GetDirectories("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\", Conversions.ToString(Strings.Chr(checked (48 + num1))) + "*");
          int num2 = Information.UBound((Array) directories, 1);
          int index = 0;
          while (index <= num2)
          {
            string[] strArray4 = Strings.Split(directories[index], "\\", -1, CompareMethod.Binary);
            if (nPCEA2Folders < 10)
            {
              PCEA2Folder[nPCEA2Folders] = strArray4[Information.UBound((Array) strArray4, 1)];
              checked { ++nPCEA2Folders; }
            }
            else
              FNIScommon1.FNIScommon.WriteWarning("Too many PCEA2 subfolders: " + strArray4[Information.UBound((Array) strArray4, 1)]);
            checked { ++index; }
          }
          checked { ++num1; }
        }
        while (num1 <= 9);
        List<string> stringList = new List<string>();
        int num3 = checked (nPCEA2Folders - 1);
        int index1 = 0;
        while (index1 <= num3)
        {
          strArray1[index1] = "";
          DirectoryInfo directoryInfo = new DirectoryInfo("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\" + PCEA2Folder[index1]);
          FileInfo[] files1 = directoryInfo.GetFiles("*.hkx");
          aafileInfoListArray[index1] = new List<FNISaa1.FNISaa.AAfileInfo>();
          FileInfo[] fileInfoArray = files1;
          int index2 = 0;
          while (index2 < fileInfoArray.Length)
          {
            FileInfo fileInfo = fileInfoArray[index2];
            string Left = Strings.LCase(fileInfo.Name);
            bool flag = false;
            int num2 = checked (FNISaa1.FNISaa.iAAAnim - 1);
            int index3 = 0;
            while (index3 <= num2)
            {
              if (Operators.CompareString(Left, FNISaa1.FNISaa.AAAnim[index3], false) == 0)
              {
                flagArray1[index1, index3] = true;
                flag = true;
                aafileInfo1.AAanimationID = index3;
                aafileInfo1.length = checked ((int) fileInfo.Length);
                aafileInfo1.ctime = fileInfo.LastWriteTime;
                aafileInfo1.iPCEA2Folder = index1;
                aafileInfoListArray[index1].Add(aafileInfo1);
                break;
              }
              checked { ++index3; }
            }
            if (!flag)
            {
              // ISSUE: variable of a reference type
              string& local1;
              // ISSUE: explicit reference operation
              // ISSUE: explicit reference operation
              string str = ^(local1 = @strArray1[index1]) + Left + " ";
              // ISSUE: explicit reference operation
              ^local1 = str;
              // ISSUE: variable of a reference type
              int& local2;
              // ISSUE: explicit reference operation
              // ISSUE: explicit reference operation
              int num4 = checked (^(local2 = @numArray1[index1]) + 1);
              // ISSUE: explicit reference operation
              ^local2 = num4;
            }
            checked { ++index2; }
          }
          FileInfo[] files2 = directoryInfo.GetFiles("FNIS_PCEA2_*List.txt");
          int index4 = 0;
          while (index4 < files2.Length)
          {
            FileInfo fileInfo = files2[index4];
            stringList.Add(">" + Strings.Format((object) index1, ""));
            string[] strArray4 = FNIScommon1.FNIScommon.ReadAFile("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\" + PCEA2Folder[index1] + "\\" + fileInfo.Name);
            int num2 = Information.UBound((Array) strArray4, 1);
            int index3 = 0;
            while (index3 <= num2)
            {
              string str1 = Strings.Trim(Strings.Replace(Strings.Replace(strArray4[index3], "\t", " ", 1, -1, CompareMethod.Binary), "  ", " ", 1, -1, CompareMethod.Binary));
              if (Operators.CompareString(Strings.Left(str1, 2), "T ", false) == 0 & Strings.Len(str1) > 10)
              {
                string[] SourceArray = Strings.Split(str1, " ", -1, CompareMethod.Binary);
                string str2 = Strings.LCase(SourceArray[1]);
                if (Operators.CompareString(Strings.Right(str2, 4), ".hkx", false) == 0)
                {
                  int num4 = checked (FNISaa1.FNISaa.iAAAnim - 1);
                  int index5 = 0;
                  while (index5 <= num4)
                  {
                    if (Operators.CompareString(str2, FNISaa1.FNISaa.AAAnim[index5], false) == 0)
                    {
                      if (flagArray1[index1, index5])
                      {
                        SourceArray[0] = "T" + Strings.Format((object) index5, "");
                        string str3 = Strings.Join(SourceArray, " ");
                        index5 = FNISaa1.FNISaa.iAAAnim;
                        stringList.Add(str3);
                        int num5;
                        checked { ++num5; }
                      }
                      else
                        FNIScommon1.FNIScommon.LogOutput("PCEA2 file missing: " + PCEA2Folder[index1] + "\\" + str2, true, true);
                    }
                    checked { ++index5; }
                  }
                }
              }
              checked { ++index3; }
            }
            checked { ++index4; }
          }
          checked { ++index1; }
        }
        int num6 = checked (nPCEA2Folders - 1);
        int index6 = 0;
        while (index6 <= num6)
        {
          int index2 = 0;
          do
          {
            if (flagArray1[index6, index2])
            {
              // ISSUE: variable of a reference type
              int& local1;
              // ISSUE: explicit reference operation
              int num2 = checked (^(local1 = numArray3.Address(index6, FNISaa1.FNISaa.AAAnimToGroup[index2])) + 1);
              // ISSUE: explicit reference operation
              ^local1 = num2;
              flagArray2[FNISaa1.FNISaa.AAAnimToGroup[index2]] = true;
              // ISSUE: variable of a reference type
              string& local2;
              // ISSUE: explicit reference operation
              string str = ^(local2 = strArray2.Address(index6, FNISaa1.FNISaa.AAAnimToGroup[index2])) + " " + FNISaa1.FNISaa.AAAnim[index2];
              // ISSUE: explicit reference operation
              ^local2 = str;
            }
            else
            {
              if (FNISaa1.FNISaa.AAAnimToGroup[index2] == 0)
                index6 = index6;
              // ISSUE: variable of a reference type
              string& local;
              // ISSUE: explicit reference operation
              string str = ^(local = strArray3.Address(index6, FNISaa1.FNISaa.AAAnimToGroup[index2])) + " " + FNISaa1.FNISaa.AAAnim[index2];
              // ISSUE: explicit reference operation
              ^local = str;
            }
            checked { ++index2; }
          }
          while (index2 <= 544);
          checked { ++index6; }
        }
        int index7 = 0;
        do
        {
          int index2 = 0;
          do
          {
            numArray4[index7, index2] = -1;
            checked { ++index2; }
          }
          while (index2 <= 54);
          checked { ++index7; }
        }
        while (index7 <= 10);
        int num7 = checked (nPCEA2Folders - 1);
        int index8 = 0;
        while (index8 <= num7)
        {
          string str = "";
          int index2 = 0;
          do
          {
            if (numArray3[index8, index2] > 0)
            {
              // ISSUE: variable of a reference type
              int& local;
              // ISSUE: explicit reference operation
              int num2 = checked (^(local = numArray4.Address(10, index2)) + 1);
              // ISSUE: explicit reference operation
              ^local = num2;
              numArray4[index8, index2] = numArray4[10, index2];
              str += "1";
            }
            else
              str += "0";
            checked { ++index2; }
          }
          while (index2 <= 53);
          BitPattern[index8] = str;
          checked { ++index8; }
        }
        if (MyProject.Computer.FileSystem.FileExists("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\FNIS_FNIS_PCEA2_List.txt".ToUpperInvariant()))
          MyProject.Computer.FileSystem.DeleteFile("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\FNIS_FNIS_PCEA2_List.txt");
        FNISaa1.FNISaa.MyStreamWriter = new StreamWriter("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\FNIS_FNIS_PCEA2_List.txt");
        if (MyProject.Computer.FileSystem.FileExists("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\FNIS_FNIS_PCEA2_Version.txt".ToUpperInvariant()))
        {
          string[] strArray4 = FNIScommon1.FNIScommon.ReadAFile("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\FNIS_FNIS_PCEA2_Version.txt");
          if (Operators.CompareString(Strings.Left(strArray4[0], 7), "Version", false) == 0)
            FNISaa1.FNISaa.MyStreamWriter.WriteLine(strArray4[0]);
        }
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("AAPrefix fp2");
        int index9 = 0;
        do
        {
          if (flagArray2[index9])
          {
            int num2 = 0;
            int num4 = checked (nPCEA2Folders - 1);
            int index2 = 0;
            while (index2 <= num4)
            {
              if (numArray3[index2, index9] > 0)
                checked { ++num2; }
              checked { ++index2; }
            }
            FNISaa1.FNISaa.MyStreamWriter.WriteLine("AAset " + FNISaa1.FNISaa.AAGroup[index9] + " " + Strings.Format((object) num2, ""));
          }
          checked { ++index9; }
        }
        while (index9 <= 53);
        List<string>.Enumerator enumerator1;
        try
        {
          enumerator1 = stringList.GetEnumerator();
          while (enumerator1.MoveNext())
          {
            string current = enumerator1.Current;
            int integer;
            if (Operators.CompareString(Strings.Left(current, 1), ">", false) == 0)
              integer = Conversions.ToInteger(Strings.Mid(current, 2));
            else if (Operators.CompareString(Strings.Left(current, 1), "T", false) == 0)
            {
              string[] SourceArray = Strings.Split(current, " ", -1, CompareMethod.Binary);
              SourceArray[1] = "fp2" + Strings.Format((object) numArray4[integer, FNISaa1.FNISaa.AAAnimToGroup[Conversions.ToInteger(Strings.Mid(SourceArray[0], 2))]], "") + "_" + SourceArray[1];
              SourceArray[0] = "T";
              FNISaa1.FNISaa.MyStreamWriter.WriteLine(Strings.Join(SourceArray, " "));
            }
          }
        }
        finally
        {
          enumerator1.Dispose();
        }
        FNISaa1.FNISaa.MyStreamWriter.Close();
        FNISaa1.FNISaa.Patch_FNIS_PCEA2_pex(nPCEA2Folders, PCEA2Folder, BitPattern);
        FileInfo[] files = new DirectoryInfo("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\").GetFiles("*.hkx");
        aafileInfoListArray[10] = new List<FNISaa1.FNISaa.AAfileInfo>();
        int num8 = Information.UBound((Array) files, 1);
        int index10 = 0;
        while (index10 <= num8)
        {
          aafileInfo1.AAfilename = files[index10].Name;
          aafileInfo1.length = checked ((int) files[index10].Length);
          aafileInfo1.ctime = files[index10].LastWriteTime;
          aafileInfoListArray[10].Add(aafileInfo1);
          checked { ++index10; }
        }
        List<FNISaa1.FNISaa.AAfileInfo> aafileInfoList1 = aafileInfoListArray[10];
        Comparison<FNISaa1.FNISaa.AAfileInfo> comparison1;
        // ISSUE: reference to a compiler-generated field
        if (FNISaa1.FNISaa._Closure\u0024__.\u0024I46\u002D0 != null)
        {
          // ISSUE: reference to a compiler-generated field
          comparison1 = FNISaa1.FNISaa._Closure\u0024__.\u0024I46\u002D0;
        }
        else
        {
          // ISSUE: reference to a compiler-generated field
          FNISaa1.FNISaa._Closure\u0024__.\u0024I46\u002D0 = comparison1 = (Comparison<FNISaa1.FNISaa.AAfileInfo>) ((x, y) => x.AAfilename.CompareTo(y.AAfilename));
        }
        aafileInfoList1.Sort(comparison1);
        aafileInfoListArray[11] = new List<FNISaa1.FNISaa.AAfileInfo>();
        int num9 = checked (nPCEA2Folders - 1);
        int index11 = 0;
        while (index11 <= num9)
        {
          List<FNISaa1.FNISaa.AAfileInfo>.Enumerator enumerator2;
          try
          {
            enumerator2 = aafileInfoListArray[index11].GetEnumerator();
            while (enumerator2.MoveNext())
            {
              aafileInfo1 = enumerator2.Current;
              aafileInfo1.AAfilename = "fp2" + Strings.Format((object) numArray4[index11, FNISaa1.FNISaa.AAAnimToGroup[aafileInfo1.AAanimationID]], "") + "_" + FNISaa1.FNISaa.AAAnim[aafileInfo1.AAanimationID];
              aafileInfoListArray[11].Add(aafileInfo1);
            }
          }
          finally
          {
            enumerator2.Dispose();
          }
          checked { ++index11; }
        }
        List<FNISaa1.FNISaa.AAfileInfo> aafileInfoList2 = aafileInfoListArray[11];
        Comparison<FNISaa1.FNISaa.AAfileInfo> comparison2;
        // ISSUE: reference to a compiler-generated field
        if (FNISaa1.FNISaa._Closure\u0024__.\u0024I46\u002D1 != null)
        {
          // ISSUE: reference to a compiler-generated field
          comparison2 = FNISaa1.FNISaa._Closure\u0024__.\u0024I46\u002D1;
        }
        else
        {
          // ISSUE: reference to a compiler-generated field
          FNISaa1.FNISaa._Closure\u0024__.\u0024I46\u002D1 = comparison2 = (Comparison<FNISaa1.FNISaa.AAfileInfo>) ((x, y) => x.AAfilename.CompareTo(y.AAfilename));
        }
        aafileInfoList2.Sort(comparison2);
        int count1 = aafileInfoListArray[10].Count;
        int count2 = aafileInfoListArray[11].Count;
        int index12 = 0;
        int index13 = 0;
        int num10;
        int num11;
        int num12;
        int num13;
        while (index12 < count1 | index13 < count2)
        {
          if (index12 >= count1)
          {
            FNISaa1.FNISaa.AAfileInfo aafileInfo2 = aafileInfoListArray[11][index13];
            FileSystem.FileCopy("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\" + PCEA2Folder[aafileInfo2.iPCEA2Folder] + "\\" + Strings.Mid(aafileInfo2.AAfilename, 6), "..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\" + aafileInfo2.AAfilename);
            checked { ++index13; }
            checked { ++num10; }
          }
          else if (index13 >= count2)
          {
            FNISaa1.FNISaa.AAfileInfo aafileInfo2 = aafileInfoListArray[10][index12];
            files[index12].Delete();
            checked { ++index12; }
            checked { ++num11; }
          }
          else
          {
            FNISaa1.FNISaa.AAfileInfo aafileInfo2 = aafileInfoListArray[10][index12];
            FNISaa1.FNISaa.AAfileInfo aafileInfo3 = aafileInfoListArray[11][index13];
            int num2 = string.Compare(aafileInfo2.AAfilename, aafileInfo3.AAfilename, true);
            if (FNIScommon1.FNIScommon.DebugOutput > 2)
              FNIScommon1.FNIScommon.LogOutput("PCEA2 compare: " + Conversions.ToString(num2) + " " + aafileInfo2.AAfilename + " " + aafileInfo3.AAfilename, false, true);
            if (num2 == 0)
            {
              if (aafileInfo2.length == aafileInfo3.length & DateTime.Compare(aafileInfo2.ctime, aafileInfo3.ctime) == 0)
              {
                checked { ++num12; }
              }
              else
              {
                FileSystem.FileCopy("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\" + PCEA2Folder[aafileInfo3.iPCEA2Folder] + "\\" + Strings.Mid(aafileInfo3.AAfilename, 6), "..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\" + aafileInfo3.AAfilename);
                checked { ++num13; }
              }
              checked { ++index12; }
              checked { ++index13; }
            }
            else if (num2 > 0)
            {
              FileSystem.FileCopy("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\" + PCEA2Folder[aafileInfo3.iPCEA2Folder] + "\\" + Strings.Mid(aafileInfo3.AAfilename, 6), "..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\" + aafileInfo3.AAfilename);
              checked { ++index13; }
              checked { ++num10; }
            }
            else
            {
              MyProject.Computer.FileSystem.DeleteFile("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\" + aafileInfo2.AAfilename);
              checked { ++index12; }
              checked { ++num11; }
            }
          }
        }
        if (FNIScommon1.FNIScommon.DebugOutput > 2)
          FNIScommon1.FNIScommon.LogOutput("PCEA2 - Files Added: " + Strings.Format((object) num10, "") + " Removed: " + Strings.Format((object) num11, "") + " Replaced: " + Strings.Format((object) num13, "") + " Kept: " + Strings.Format((object) num12, ""), false, true);
        if (MyProject.Computer.FileSystem.FileExists("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\PCEA2_Overview.txt".ToUpperInvariant()))
          MyProject.Computer.FileSystem.DeleteFile("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\PCEA2_Overview.txt");
        FNISaa1.FNISaa.MyStreamWriter = new StreamWriter("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2\\PCEA2_Overview.txt");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("PCEA2_Overview.txt");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("How to read this:");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("\tThis overview can be used by experienced players to optimize their use of FNIS PCEA2. See the instructions for further details.");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("\tmtidle\tName of the alternate animation (AA) group");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("\t(1)\t\tNumber of animations which are part of this group");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("\t2/1\t\t2: Number of AA animations provided by the above selection  -  1: Number of AA animations not included");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("\t\"Animations not supported by FNIS Alternate Animations\"");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("\t\t\tThe following animatimations cannot be used to replace standard animations.");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("\t\t\tEither FNIS doesn't support these.  Or animators have mis-spelled a name, or provided a replacer for an animation which is not supported by Skyrim itself");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("\t\"Animations not included\"");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("\t\t\tThe following animations are not part of this selection.");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("\t\t\tOften animators only provide some animation for one group, and let the game use vanilla for the rest. You might want to fill these up with custom animatons from other mods");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("");
        string str4 = Strings.StrDup(21, " ");
        string str5 = Strings.Left(str4 + str4, 16);
        int num14 = checked (nPCEA2Folders - 1);
        int index14 = 0;
        while (index14 <= num14)
        {
          str5 += Strings.Left(Strings.Left(PCEA2Folder[index14], 20) + str4, 21);
          checked { ++index14; }
        }
        FNISaa1.FNISaa.MyStreamWriter.WriteLine(str5);
        int index15 = 0;
        do
        {
          if (flagArray2[index15])
          {
            string str1 = Strings.Left(Strings.Left(FNISaa1.FNISaa.AAGroup[index15], 10) + str4, 11) + Strings.Right(" (" + Strings.Format((object) FNISaa1.FNISaa.AAnAnim[index15], "") + ")", 4) + " ";
            int num2 = checked (nPCEA2Folders - 1);
            int index2 = 0;
            while (index2 <= num2)
            {
              if (numArray3[index2, index15] > 0)
                str1 += Strings.Left(" " + Strings.Format((object) numArray3[index2, index15], "") + "/" + Strings.Format((object) checked (FNISaa1.FNISaa.AAnAnim[index15] - numArray3[index2, index15]), "") + str4, 21);
              else
                str1 += str4;
              checked { ++index2; }
            }
            FNISaa1.FNISaa.MyStreamWriter.WriteLine(str1);
          }
          checked { ++index15; }
        }
        while (index15 <= 53);
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("Animations not supported by FNIS Alternate Animations");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("=====================================================");
        int num15 = checked (nPCEA2Folders - 1);
        int index16 = 0;
        while (index16 <= num15)
        {
          if (numArray1[index16] > 0)
          {
            FNISaa1.FNISaa.MyStreamWriter.WriteLine(PCEA2Folder[index16] + ":");
            FNISaa1.FNISaa.MyStreamWriter.WriteLine("    " + FNISaa1.FNISaa.SplitLines(strArray1[index16]));
          }
          checked { ++index16; }
        }
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("Animations not included");
        FNISaa1.FNISaa.MyStreamWriter.WriteLine("=======================");
        int num16 = checked (nPCEA2Folders - 1);
        int index17 = 0;
        while (index17 <= num16)
        {
          FNISaa1.FNISaa.MyStreamWriter.WriteLine(PCEA2Folder[index17]);
          int index2 = 0;
          do
          {
            if ((uint) Operators.CompareString(strArray3[index17, index2], "", false) > 0U & (uint) Operators.CompareString(strArray2[index17, index2], "", false) > 0U)
              FNISaa1.FNISaa.MyStreamWriter.WriteLine("    " + FNISaa1.FNISaa.AAGroup[index2] + ":" + FNISaa1.FNISaa.SplitLines(strArray3[index17, index2]));
            checked { ++index2; }
          }
          while (index2 <= 53);
          checked { ++index17; }
        }
        FNISaa1.FNISaa.MyStreamWriter.Close();
      }

      public static string SplitLines(string line)
      {
        string str1;
        if (Strings.Len(line) > 100)
        {
          string[] SourceArray = Strings.Split(line, " ", -1, CompareMethod.Binary);
          int num = checked (Information.UBound((Array) SourceArray, 1) - 1);
          int index = 10;
          while (index <= num)
          {
            // ISSUE: variable of a reference type
            string& local;
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            string str2 = ^(local = @SourceArray[index]) + "\r\n      ";
            // ISSUE: explicit reference operation
            ^local = str2;
            checked { index += 10; }
          }
          str1 = Strings.Join(SourceArray, " ");
        }
        else
          str1 = line;
        return str1;
      }

      public static void Patch_FNIS_PCEA2_pex(int nPCEA2Folders, string[] PCEA2Folder, string[] BitPattern)
      {
        List<FNISaa1.FNISaa.AASetType> aaSetTypeList = new List<FNISaa1.FNISaa.AASetType>();
        int num1 = checked (FNISaa1.FNISaa.iAASet - 1);
        int index1 = 0;
        while (index1 <= num1)
        {
          aaSetTypeList.Add(FNISaa1.FNISaa.AASet[index1]);
          checked { ++index1; }
        }
        List<FNISaa1.FNISaa.AASetType> source1 = aaSetTypeList;
        Func<FNISaa1.FNISaa.AASetType, int> keySelector1;
        // ISSUE: reference to a compiler-generated field
        if (FNISaa1.FNISaa._Closure\u0024__.\u0024I48\u002D0 != null)
        {
          // ISSUE: reference to a compiler-generated field
          keySelector1 = FNISaa1.FNISaa._Closure\u0024__.\u0024I48\u002D0;
        }
        else
        {
          // ISSUE: reference to a compiler-generated field
          FNISaa1.FNISaa._Closure\u0024__.\u0024I48\u002D0 = keySelector1 = (Func<FNISaa1.FNISaa.AASetType, int>) (AASetEntry => AASetEntry.group);
        }
        IOrderedEnumerable<FNISaa1.FNISaa.AASetType> source2 = source1.OrderBy<FNISaa1.FNISaa.AASetType, int>(keySelector1);
        Func<FNISaa1.FNISaa.AASetType, int> keySelector2;
        // ISSUE: reference to a compiler-generated field
        if (FNISaa1.FNISaa._Closure\u0024__.\u0024I48\u002D1 != null)
        {
          // ISSUE: reference to a compiler-generated field
          keySelector2 = FNISaa1.FNISaa._Closure\u0024__.\u0024I48\u002D1;
        }
        else
        {
          // ISSUE: reference to a compiler-generated field
          FNISaa1.FNISaa._Closure\u0024__.\u0024I48\u002D1 = keySelector2 = (Func<FNISaa1.FNISaa.AASetType, int>) (AASetEntry => AASetEntry.iPrefix);
        }
        IOrderedEnumerable<FNISaa1.FNISaa.AASetType> source3 = source2.ThenBy<FNISaa1.FNISaa.AASetType, int>(keySelector2);
        Func<FNISaa1.FNISaa.AASetType, VB\u0024AnonymousType_0<int, int, int>> selector;
        // ISSUE: reference to a compiler-generated field
        if (FNISaa1.FNISaa._Closure\u0024__.\u0024I48\u002D2 != null)
        {
          // ISSUE: reference to a compiler-generated field
          selector = FNISaa1.FNISaa._Closure\u0024__.\u0024I48\u002D2;
        }
        else
        {
          // ISSUE: reference to a compiler-generated field
          FNISaa1.FNISaa._Closure\u0024__.\u0024I48\u002D2 = selector = AASetEntry => new
          {
            iPrefix = AASetEntry.iPrefix,
            group = AASetEntry.group,
            nGroups = AASetEntry.nGroups
          };
        }
        source3.Select(selector);
        int[] numArray1 = new int[55];
        int index2 = 0;
        do
        {
          numArray1[index2] = 1;
          checked { ++index2; }
        }
        while (index2 <= 53);
        FNIScommon1.FNIScommon.LogOutput("Creating file FNIS_PCEA2.pex", false, true);
        byte[] numArray2 = File.ReadAllBytes("templates\\FNIS_PCEA2_TEMPLATE.pex");
        string str1 = "";
        int index3 = 0;
        do
        {
          string str2;
          if (index3 >= nPCEA2Folders)
          {
            str2 = "XX" + Strings.StrDup(18, Strings.Format((object) index3, ""));
            str1 = str1 + "X" + Strings.StrDup(53, Strings.Format((object) index3, ""));
          }
          else
          {
            str2 = Strings.Left(PCEA2Folder[index3] + "                    ", 20);
            str1 += BitPattern[index3];
          }
          int num2 = 0;
          do
          {
            numArray2[checked (231 + index3 * 22 + num2)] = checked ((byte) Strings.Asc(Strings.Mid(str2, num2 + 1, 1)));
            checked { ++num2; }
          }
          while (num2 <= 19);
          checked { ++index3; }
        }
        while (index3 <= 9);
        int num3 = 0;
        do
        {
          numArray2[checked (496 + num3)] = checked ((byte) Strings.Asc(Strings.Mid(str1, num3 + 1, 1)));
          checked { ++num3; }
        }
        while (num3 <= 539);
        int num4 = checked ((int) unchecked ((long) FNIScommon1.FNIScommon.CRC32_Calc(numArray2, 231, 448) % 500000L) + (int) unchecked ((long) FNIScommon1.FNIScommon.CRC32_Calc(numArray2, 496, 1035) % 500000L));
        int num5 = 0;
        do
        {
          numArray2[checked (478 - num5)] = checked ((byte) (48 + unchecked (num4 % 10)));
          num4 /= 10;
          checked { ++num5; }
        }
        while (num5 <= 5);
        File.WriteAllBytes("..\\..\\scripts\\FNIS_PCEA2.pex", numArray2);
      }

      public struct AASetType
      {
        public int group;
        public int imod;
        public int iPrefix;
        public int nGroups;
        public int nAnims;
        public ulong[] defPattern;
      }

      public struct AAcrcInfo
      {
        public string FileName;
        public uint crc32;
        public uint path_crc;
        public uint reffile_crc;
      }

      public struct AATriggerDef
      {
        public int iAnim;
        public int group;
        public int setIndex;
        public int nTriggers;
        public string Triggers;
        public int currentTemplate;
        public int CurrentnTriggers;
        public string CurrentTriggers;
      }

      public struct AAfileInfo
      {
        public string AAfilename;
        public int AAanimationID;
        public int length;
        public DateTime ctime;
        public int iPCEA2Folder;
      }
    }
  }
}
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 = current.@params[0];
                    Left = Left + "\r\n" + Strings.Join(current.@params, " ");
                    checked { ++num2; }
                  }
                  else
                  {
                    str2 = str2 + "\r\n" + Strings.Join(current.@params, " ");
                    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(current.@params, " ");
            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;
      }
    }
  }
}
C#

GenerateFNISUsers

using GenerateFNISforUsers.My;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using Microsoft.VisualBasic.MyServices;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows.Forms;

namespace GenerateFNISforUsers
{
  [DesignerGenerated]
  public class GenerateFNISUsers : Form
  {
    public static GenerateFNISUsers.CustomPreCache[] CustomPreCacheSet = new GenerateFNISUsers.CustomPreCache[51];
    public static GenerateFNISUsers.PCEAgenderFileData[] PCEAgenderFile = new GenerateFNISUsers.PCEAgenderFileData[501];
    private const string FNISBehaviorVersion = "V7.0";
    private const string FNISBehaviorVersExt = "";
    private const string SkyrimMinVersion = "1.8.151";
    private string FNISVersionText;
    private string SkyrimVersion;
    private string SkyrimExe;
    private string SkyrimName;
    private string GeneratorName;
    private bool optionChanged;
    private const string FNISmodList = "FNISmodList.txt";
    private string[] FNISModList1;
    private List<string> FNISModlist2L;
    public static int iCustomPreCacheSet;
    public static string[] CPCFile;
    public static int iPCEAgenderFile;
    public static string FirstPatchLine;
    public static string PatchDefFile;
    private IContainer components;

    internal virtual TextBox TextBox1 { get; [MethodImpl(MethodImplOptions.Synchronized)] set; }

    internal virtual Button Button1
    {
      get
      {
        return this._Button1;
      }
      [MethodImpl(MethodImplOptions.Synchronized)] set
      {
        EventHandler eventHandler = new EventHandler(this.Button1_Click);
        Button button1_1 = this._Button1;
        if (button1_1 != null)
          button1_1.Click -= eventHandler;
        this._Button1 = value;
        Button button1_2 = this._Button1;
        if (button1_2 == null)
          return;
        button1_2.Click += eventHandler;
      }
    }

    internal virtual Button Button2
    {
      get
      {
        return this._Button2;
      }
      [MethodImpl(MethodImplOptions.Synchronized)] set
      {
        EventHandler eventHandler = new EventHandler(this.Button2_Click);
        Button button2_1 = this._Button2;
        if (button2_1 != null)
          button2_1.Click -= eventHandler;
        this._Button2 = value;
        Button button2_2 = this._Button2;
        if (button2_2 == null)
          return;
        button2_2.Click += eventHandler;
      }
    }

    internal virtual Button Button3
    {
      get
      {
        return this._Button3;
      }
      [MethodImpl(MethodImplOptions.Synchronized)] set
      {
        EventHandler eventHandler = new EventHandler(this.Button3_Click);
        Button button3_1 = this._Button3;
        if (button3_1 != null)
          button3_1.Click -= eventHandler;
        this._Button3 = value;
        Button button3_2 = this._Button3;
        if (button3_2 == null)
          return;
        button3_2.Click += eventHandler;
      }
    }

    internal virtual CheckedListBox Patch_ListBox
    {
      get
      {
        return this._Patch_ListBox;
      }
      [MethodImpl(MethodImplOptions.Synchronized)] set
      {
        EventHandler eventHandler = new EventHandler(this.Patch_ListBox_SelectedIndexChanged);
        CheckedListBox patchListBox1 = this._Patch_ListBox;
        if (patchListBox1 != null)
          patchListBox1.SelectedIndexChanged -= eventHandler;
        this._Patch_ListBox = value;
        CheckedListBox patchListBox2 = this._Patch_ListBox;
        if (patchListBox2 == null)
          return;
        patchListBox2.SelectedIndexChanged += eventHandler;
      }
    }

    internal virtual TextBox PatchList_Header { get; [MethodImpl(MethodImplOptions.Synchronized)] set; }

    internal virtual TextBox TextBox2 { get; [MethodImpl(MethodImplOptions.Synchronized)] set; }

    internal virtual ComboBox LanguageBox
    {
      get
      {
        return this._LanguageBox;
      }
      [MethodImpl(MethodImplOptions.Synchronized)] set
      {
        EventHandler eventHandler = new EventHandler(this.LanguageBox_SelectedIndexChanged);
        ComboBox languageBox1 = this._LanguageBox;
        if (languageBox1 != null)
          languageBox1.SelectedIndexChanged -= eventHandler;
        this._LanguageBox = value;
        ComboBox languageBox2 = this._LanguageBox;
        if (languageBox2 == null)
          return;
        languageBox2.SelectedIndexChanged += eventHandler;
      }
    }

    internal virtual Button Button5
    {
      get
      {
        return this._Button5;
      }
      [MethodImpl(MethodImplOptions.Synchronized)] set
      {
        EventHandler eventHandler = new EventHandler(this.Button5_Click);
        Button button5_1 = this._Button5;
        if (button5_1 != null)
          button5_1.Click -= eventHandler;
        this._Button5 = value;
        Button button5_2 = this._Button5;
        if (button5_2 == null)
          return;
        button5_2.Click += eventHandler;
      }
    }

    internal virtual RichTextBox RichTextBox1
    {
      get
      {
        return this._RichTextBox1;
      }
      [MethodImpl(MethodImplOptions.Synchronized)] set
      {
        LinkClickedEventHandler clickedEventHandler = new LinkClickedEventHandler(this.RichTextBox1_LinkClicked);
        RichTextBox richTextBox1_1 = this._RichTextBox1;
        if (richTextBox1_1 != null)
          richTextBox1_1.LinkClicked -= clickedEventHandler;
        this._RichTextBox1 = value;
        RichTextBox richTextBox1_2 = this._RichTextBox1;
        if (richTextBox1_2 == null)
          return;
        richTextBox1_2.LinkClicked += clickedEventHandler;
      }
    }

    internal virtual RichTextBox RichTextBox2 { get; [MethodImpl(MethodImplOptions.Synchronized)] set; }

    public GenerateFNISUsers()
    {
      this.Load += new EventHandler(this.GenerateFNISUsers_Load);
      this.FormClosing += new FormClosingEventHandler(this.Form1_FormClosing);
      this.InitializeComponent();
    }

    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
    private void GenerateFNISUsers_Load(object sender, EventArgs e)
    {
      int num1;
      int num2;
      try
      {
        ProjectData.ClearProjectError();
        num1 = 2;
        FNIScommon1.FNIScommon.FNIS_for_Users = true;
        FNIScommon1.FNIScommon.RetCode = 1;
        FNIScommon1.FNIScommon.LogOpen = false;
        FNIScommon1.FNIScommon.called_from_Projects = false;
        FNIScommon1.FNIScommon.SkyrimEdition = 0;
        this.SkyrimVersion = "??.??.??";
        this.GeneratorName = "GenerateFNISforUsers";
        if (Operators.CompareString(Strings.LCase(Strings.Left(Environment.CurrentDirectory, 14)), "c:\\users\\haral", false) == 0)
        {
          FNIScommon1.FNIScommon.called_from_Projects = true;
          FNIScommon1.FNIScommon.SkyrimEdition = 1;
          Microsoft.VisualBasic.FileSystem.ChDir("c:\\GAMES\\Steam\\SteamApps\\common\\skyrim\\Data\\tools\\GenerateFNIS_for_Users");
        }
        else
        {
          if (Operators.CompareString(Strings.LCase(Environment.CurrentDirectory), Strings.LCase(Application.StartupPath), false) != 0)
            Microsoft.VisualBasic.FileSystem.ChDir(Application.StartupPath);
          if (MyProject.Computer.FileSystem.FileExists("PatchListSE.txt".ToUpperInvariant()))
            checked { FNIScommon1.FNIScommon.SkyrimEdition += 2; }
          if (MyProject.Computer.FileSystem.FileExists("PatchList.txt".ToUpperInvariant()))
            checked { ++FNIScommon1.FNIScommon.SkyrimEdition; }
          if (FNIScommon1.FNIScommon.SkyrimEdition == 3)
            FNIScommon1.FNIScommon.SkyrimEdition = !MyProject.Computer.FileSystem.FileExists("..\\..\\..\\SkyrimSE.exe".ToUpperInvariant()) ? 1 : 2;
        }
        if (FNIScommon1.FNIScommon.SkyrimEdition == 2)
        {
          GenerateFNISUsers.PatchDefFile = "PatchListSE.txt";
          this.SkyrimExe = "..\\..\\..\\SkyrimSE.exe";
          this.SkyrimName = "Skyrim SE 64bit";
          FNIScommon1.FNIScommon.hkxcmd_Params = "convert -v:AMD64 \"*\" \"#\"";
          this.FNISVersionText = "V7.0 (Skyrim SE 64bit)";
          // ISSUE: variable of a reference type
          string& local;
          // ISSUE: explicit reference operation
          // ISSUE: explicit reference operation
          string str = ^(local = @this.GeneratorName) + " SE";
          // ISSUE: explicit reference operation
          ^local = str;
          this.RichTextBox1.Visible = false;
          this.RichTextBox2.Visible = true;
          this.BackColor = Color.Goldenrod;
        }
        else if (FNIScommon1.FNIScommon.SkyrimEdition == 1)
        {
          GenerateFNISUsers.PatchDefFile = "PatchList.txt";
          this.SkyrimExe = "..\\..\\..\\TESV.exe";
          this.SkyrimName = "Skyrim 32bit";
          FNIScommon1.FNIScommon.hkxcmd_Params = "convert -v:WIN32 \"*\" \"#\"";
          this.FNISVersionText = "V7.0 (Skyrim 32bit)";
          this.RichTextBox2.Visible = false;
        }
        this.Text = this.Text + " " + this.FNISVersionText;
        FNIScommon1.FNIScommon.Get_LanguageFiles(this.LanguageBox);
        this.TextBox1.Text = Strings.Replace(this.TextBox1.Text, "<v>", this.FNISVersionText, 1, -1, CompareMethod.Binary);
        FNIScommon1.FNIScommon.Textbox = this.TextBox1;
        if (FNIScommon1.FNIScommon.SkyrimEdition == 0)
        {
          Information.Err().Description = "PatchList.txt/PatchListSE.txt " + FNIScommon1.FNIScommon.tErr[3] + " - " + FNIScommon1.FNIScommon.tErr[17];
          Information.Err().Raise(2001, (object) null, (object) null, (object) null, (object) null);
        }
        FNIScommon1.FNIScommon.Read_AllTemplates_File();
        this.Initialize_PatchBox();
        if (MyProject.Computer.FileSystem.FileExists("..\\GenerateFNIS_for_Users\\BehavioredObjects.txt"))
        {
          this.Button5.Enabled = true;
          goto label_24;
        }
        else
          goto label_24;
label_19:
        num2 = -1;
        switch (num1)
        {
          case 2:
            this.TextBox1.Text = "\r\n\r\nError " + Conversion.Str((object) Information.Err().Number) + "  " + Information.Err().Description;
            this.TextBox1.ForeColor = Color.Red;
            this.Button1.Enabled = false;
            goto label_24;
        }
      }
      catch (Exception ex) when (ex is Exception & (uint) num1 > 0U & num2 == 0)
      {
        ProjectData.SetProjectError(ex);
        goto label_19;
      }
      throw ProjectData.CreateProjectError(-2146828237);
label_24:
      if (num2 == 0)
        return;
      ProjectData.ClearProjectError();
    }

    private void Button1_Click(object sender, EventArgs e)
    {
      this.Button2.Enabled = false;
      this.Main();
    }

    private void Button2_Click(object sender, EventArgs e)
    {
      this.ConsistenceCheck();
    }

    private void Button3_Click(object sender, EventArgs e)
    {
      this.Store_Patches();
      FNIScommon1.FNIScommon.CreateShortCut(this.GeneratorName);
      Environment.Exit(FNIScommon1.FNIScommon.RetCode);
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
      this.Store_Patches();
      Environment.Exit(FNIScommon1.FNIScommon.RetCode);
    }

    private void Button5_Click(object sender, EventArgs e)
    {
      if (MessageBox.Show(FNIScommon1.FNIScommon.tMsgu[25] + "\r\n" + FNIScommon1.FNIScommon.tMsgu[26], "GenerateFNISforUsers", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes)
        return;
      this.DeInstall_BOs();
      FNIScommon1.FNIScommon.LogOutput("\r\n" + FNIScommon1.FNIScommon.tMsgu[27], true, true);
    }

    private void Patch_ListBox_SelectedIndexChanged(object sender, EventArgs e)
    {
      int selectedIndex = this.Patch_ListBox.SelectedIndex;
      if (selectedIndex < 0)
        return;
      FNIScommon1.FNIScommon.isPatch[selectedIndex] = this.Patch_ListBox.GetItemChecked(selectedIndex);
      if (Operators.CompareString(FNIScommon1.FNIScommon.PatchID[selectedIndex], "PCEA2", false) == 0)
        FNIScommon1.FNIScommon.isPCEA2 = FNIScommon1.FNIScommon.isPatch[selectedIndex];
      if (Operators.CompareString(FNIScommon1.FNIScommon.PatchID[selectedIndex], "PCEA", false) == 0)
        FNIScommon1.FNIScommon.isPCEA = FNIScommon1.FNIScommon.isPatch[selectedIndex];
      if (Operators.CompareString(FNIScommon1.FNIScommon.PatchID[selectedIndex], "GENDER", false) == 0)
        FNIScommon1.FNIScommon.isGENDER = FNIScommon1.FNIScommon.isPatch[selectedIndex];
      if (Operators.CompareString(FNIScommon1.FNIScommon.PatchID[selectedIndex], "SKELETON", false) == 0)
        FNIScommon1.FNIScommon.isSKELETON = FNIScommon1.FNIScommon.isPatch[selectedIndex];
      if (Operators.CompareString(FNIScommon1.FNIScommon.PatchID[selectedIndex], "HKX_COMPAT", false) == 0)
        FNIScommon1.FNIScommon.isHKX_COMPAT = FNIScommon1.FNIScommon.isPatch[selectedIndex];
      if (FNIScommon1.FNIScommon.LogOpen)
        FNIScommon1.FNIScommon.LogOutput("Patch" + Conversion.Str((object) selectedIndex) + " " + FNIScommon1.FNIScommon.PatchID[selectedIndex] + ": " + Conversion.Str((object) FNIScommon1.FNIScommon.isPatch[selectedIndex]), true, true);
      this.optionChanged = true;
    }

    private void LanguageBox_SelectedIndexChanged(object sender, EventArgs e)
    {
      FNIScommon1.FNIScommon.Read_LanguagFile(this.LanguageBox);
      int num = checked (FNIScommon1.FNIScommon.PatchCount - 1);
      int index = 0;
      while (index <= num)
      {
        if (Operators.CompareString(FNIScommon1.FNIScommon.lastLanguage, "english", false) == 0)
        {
          this.Patch_ListBox.Items[index] = (object) FNIScommon1.FNIScommon.PatchText[index];
          FNIScommon1.FNIScommon.tPatch[checked (index + 1)] = FNIScommon1.FNIScommon.PatchText[index];
        }
        else if (Strings.Len(FNIScommon1.FNIScommon.tPatch[checked (index + 1)]) > 1)
          this.Patch_ListBox.Items[index] = (object) FNIScommon1.FNIScommon.tPatch[checked (index + 1)];
        checked { ++index; }
      }
      this.Button1.Text = FNIScommon1.FNIScommon.tUIu[1];
      this.Button2.Text = FNIScommon1.FNIScommon.tUIu[2];
      this.Button3.Text = FNIScommon1.FNIScommon.tUIu[3];
      this.Button5.Text = FNIScommon1.FNIScommon.tUIu[13];
      this.PatchList_Header.Text = FNIScommon1.FNIScommon.tUIu[4];
      this.TextBox2.Text = FNIScommon1.FNIScommon.tUIu[6];
      this.TextBox1.Text = FNIScommon1.FNIScommon.tUIu[7] + "\r\n\r\n" + FNIScommon1.FNIScommon.tUIu[9] + "\r\n" + FNIScommon1.FNIScommon.tUIu[10] + "\r\n" + FNIScommon1.FNIScommon.tUIu[11] + "\r\n" + FNIScommon1.FNIScommon.tUIu[12] + "\r\n\r\n";
    }

    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
    public void Main()
    {
      int num1;
      int num2;
      try
      {
        ProjectData.ClearProjectError();
        num1 = 2;
        string str1 = "...";
        FNIScommon1.FNIScommon.FNIS_for_Users = true;
        FNIScommon1.FNIScommon.Initialize_Globals();
        FNISaa1.FNISaa.AAInitialize();
        FNIScommon1.FNIScommon.RetCode = 0;
        FNIScommon1.FNIScommon.Anz_fuG = 0;
        FNIScommon1.FNIScommon.Anz_fu = 0;
        FNIScommon1.FNIScommon.Anz_ofa = 0;
        FNIScommon1.FNIScommon.Anz_pa = 0;
        FNIScommon1.FNIScommon.Anz_km = 0;
        FNIScommon1.FNIScommon.Anz_aa = 0;
        GenerateFNISUsers.iPCEAgenderFile = 0;
        FNIScommon1.FNIScommon.iPatchAF = 0;
        GenerateFNISUsers.iCustomPreCacheSet = 0;
        FNIScommon1.FNIScommon.AEList = new List<FNIScommon1.FNIScommon.AEcc>();
        FNIScommon1.FNIScommon.AnimFileList = new List<FNIScommon1.FNIScommon.AnimFilecc>();
        FNIScommon1.FNIScommon.MRD_DataListALL = new List<FNIScommon1.FNIScommon.MRD_Data>();
        Array.Clear((Array) FNIScommon1.FNIScommon.MRD_BO_nAnims, 0, checked (Information.UBound((Array) FNIScommon1.FNIScommon.MRD_BO_nAnims, 1) + 1));
        Array.Clear((Array) FNIScommon1.FNIScommon.MRD_BO_nMRD, 0, checked (Information.UBound((Array) FNIScommon1.FNIScommon.MRD_BO_nMRD, 1) + 1));
        Array.Clear((Array) FNIScommon1.FNIScommon.PatchAF, 0, checked (Information.UBound((Array) FNIScommon1.FNIScommon.PatchAF, 1) + 1));
        FNIScommon1.FNIScommon.MRD_LastAnim = -1;
        this.TextBox1.Text = "";
        FNIScommon1.FNIScommon.MyBO = 0;
        FNIScommon1.FNIScommon.BO_List[FNIScommon1.FNIScommon.MyBO] = "character";
        FNIScommon1.FNIScommon.BO_DefaultAnims[FNIScommon1.FNIScommon.MyBO] = 1656;
        FileSystemProxy fileSystem = MyProject.Computer.FileSystem;
        if (!fileSystem.DirectoryExists("..\\..\\meshes\\actors\\character\\animations\\"))
          fileSystem.CreateDirectory("..\\..\\meshes\\actors\\character\\animations\\");
        if (!fileSystem.DirectoryExists("..\\..\\meshes\\actors\\character\\characters\\"))
          fileSystem.CreateDirectory("..\\..\\meshes\\actors\\character\\characters\\");
        if (!fileSystem.DirectoryExists("..\\..\\meshes\\actors\\character\\characters female\\"))
          fileSystem.CreateDirectory("..\\..\\meshes\\actors\\character\\characters female\\");
        if (!fileSystem.DirectoryExists("..\\..\\meshes\\actors\\character\\behaviors\\"))
          fileSystem.CreateDirectory("..\\..\\meshes\\actors\\character\\behaviors\\");
        if (!fileSystem.DirectoryExists("temporary_logs\\"))
          fileSystem.CreateDirectory("temporary_logs\\");
        if (fileSystem.FileExists("..\\..\\Scripts\\FNISVersionGenerated.pex".ToUpperInvariant()))
          fileSystem.DeleteFile("..\\..\\Scripts\\FNISVersionGenerated.pex");
        if (fileSystem.FileExists("temporary_logs\\GenerateFNIS_LogFile.txt".ToUpperInvariant()))
          fileSystem.DeleteFile("temporary_logs\\GenerateFNIS_LogFile.txt");
        FNIScommon1.FNIScommon.LogFile = new StreamWriter("temporary_logs\\GenerateFNIS_LogFile.txt");
        FNIScommon1.FNIScommon.LogOpen = true;
        FNIScommon1.FNIScommon.WriteDebug("", 99, "Start Debug", "");
        if (FNIScommon1.FNIScommon.DebugOutput > 1)
          FNIScommon1.FNIScommon.LogFile.AutoFlush = true;
        FNIScommon1.FNIScommon.InstallDir = "";
        FNIScommon1.FNIScommon.IsSteam = false;
        FNIScommon1.FNIScommon.Get_InstallDir();
        if (!FNIScommon1.FNIScommon.IsSteam)
        {
          FNIScommon1.FNIScommon.WriteWarning(FNIScommon1.FNIScommon.tWarn[11]);
          str1 = "....";
        }
        FNIScommon1.FNIScommon.LogOutput("FNIS Behavior V7.0   " + DateAndTime.Now.ToString(), true, true);
        string upperInvariant1 = Strings.Replace(FNIScommon1.FNIScommon.InstallDir + "\\data\\tools\\GenerateFNIS_for_Users", "\\\\", "\\", 1, -1, CompareMethod.Binary).ToUpperInvariant();
        string upperInvariant2 = Strings.Replace(Application.StartupPath, "\\\\", "\\", 1, -1, CompareMethod.Binary).ToUpperInvariant();
        string Right = upperInvariant2;
        int num3 = 0;
        if (Operators.CompareString(upperInvariant1, Right, num3 != 0) != 0)
        {
          FNIScommon1.FNIScommon.LogOutput(FNIScommon1.FNIScommon.tWarn[20] + " " + Application.StartupPath + "\\GenerateFNISforUsers.exe", true, true);
          if (FNIScommon1.FNIScommon.IsSteam & Strings.InStr(Strings.LCase(upperInvariant2), "steamapps", CompareMethod.Binary) <= 0 & !FNIScommon1.FNIScommon.called_from_Projects)
            FNIScommon1.FNIScommon.WriteWarning(FNIScommon1.FNIScommon.tWarn[3]);
        }
        else if (!MyProject.Computer.FileSystem.FileExists(this.SkyrimExe.ToUpperInvariant()))
        {
          FNIScommon1.FNIScommon.WriteWarning(Strings.Replace(FNIScommon1.FNIScommon.tWarn[22], "<1>", this.SkyrimExe, 1, -1, CompareMethod.Binary));
          FNIScommon1.FNIScommon.WriteWarning(FNIScommon1.FNIScommon.tWarn[2]);
        }
        else
          this.SkyrimVersion = FileVersionInfo.GetVersionInfo(this.SkyrimExe).ProductVersion;
        string LogText = this.SkyrimName + ": " + this.SkyrimVersion + " - " + FNIScommon1.FNIScommon.InstallDir;
        if (FNIScommon1.FNIScommon.IsSteam)
          LogText += " (Steam)";
        FNIScommon1.FNIScommon.LogOutput(LogText, true, true);
        if (FNIScommon1.FNIScommon.SkyrimEdition == 1 && !this.SkyrimMinVersOK(this.SkyrimVersion, "1.8.151"))
          FNIScommon1.FNIScommon.WriteWarning(FNIScommon1.FNIScommon.tWarn[12] + " (1.8.151)");
        if (Operators.CompareString(this.SkyrimVersion, "??.??.??", false) == 0 & FNIScommon1.FNIScommon.IsSteam & !FNIScommon1.FNIScommon.called_from_Projects)
          FNIScommon1.FNIScommon.LogOutput(FNIScommon1.FNIScommon.tWarn[21] + " " + Strings.Replace(FNIScommon1.FNIScommon.InstallDir + "\\data\\tools\\GenerateFNIS_for_Users", "\\\\", "\\", 1, -1, CompareMethod.Binary), true, true);
        FNIScommon1.FNIScommon.LogOutput("", true, true);
        if (!fileSystem.DirectoryExists("temporary_logs\\"))
          Information.Err().Raise(2019, (object) null, (object) null, (object) null, (object) null);
        if (!fileSystem.FileExists("hkxcmd.exe"))
          Information.Err().Raise(2023, (object) null, (object) null, (object) null, (object) null);
        FNIScommon1.FNIScommon.Check_Template_Entry(GenerateFNISUsers.PatchDefFile, GenerateFNISUsers.FirstPatchLine);
        if (fileSystem.FileExists("FNISmodList.txt"))
        {
          this.FNISModList1 = FNIScommon1.FNIScommon.ReadAFile("FNISmodList.txt");
          fileSystem.DeleteFile("FNISmodList.txt");
        }
        else
          this.FNISModList1 = (string[]) null;
        this.FNISModlist2L = new List<string>();
        string SkelName1 = "";
        string SkelName2 = "";
        int nBones1;
        this.GetSkeletonBones("..\\..\\meshes\\actors\\character\\character assets female\\skeleton_female.hkx", ref nBones1, ref SkelName1);
        FNIScommon1.FNIScommon.Check_hkx_type("..\\..\\meshes\\actors\\character\\character assets female\\skeleton_female.hkx");
        int nBones2;
        this.GetSkeletonBones("..\\..\\meshes\\actors\\character\\character assets\\skeleton.hkx", ref nBones2, ref SkelName2);
        FNIScommon1.FNIScommon.Check_hkx_type("..\\..\\meshes\\actors\\character\\character assets\\skeleton.hkx");
        FNIScommon1.FNIScommon.LogOutput(Strings.Replace(Strings.Replace(Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[12], "<1>", SkelName1, 1, -1, CompareMethod.Binary), "<2>", Strings.Format((object) nBones1, "0"), 1, -1, CompareMethod.Binary), "<3>", SkelName2, 1, -1, CompareMethod.Binary), "<4>", Strings.Format((object) nBones2, "0"), 1, -1, CompareMethod.Binary), true, true);
        if (!FNIScommon1.FNIScommon.isSKELETON & (nBones1 != 99 | nBones2 != 99))
          FNIScommon1.FNIScommon.WriteWarning(FNIScommon1.FNIScommon.tWarn[7]);
        string[] StringArray;
        if (fileSystem.FileExists("temporary_logs\\DummyStart.txt"))
        {
          FNIScommon1.FNIScommon.FullLog = false;
        }
        else
        {
          FNIScommon1.FNIScommon.FullLog = true;
          string FileName = "temporary_logs\\DummyStart.txt";
          StringArray = new string[0];
          int Elements = 0;
          FNIScommon1.FNIScommon.WriteAFile(FileName, ref StringArray, Elements);
        }
        FNIScommon1.FNIScommon.Display_Dirs(true);
        int index1 = 0;
        do
        {
          if (FNIScommon1.FNIScommon.isPatch[index1])
          {
            int num4 = Strings.InStr(FNIScommon1.FNIScommon.PatchText[index1], "- ", CompareMethod.Binary);
            if (num4 <= 0)
              FNIScommon1.FNIScommon.LogOutput(FNIScommon1.FNIScommon.tMsgu[1] + ": " + FNIScommon1.FNIScommon.PatchText[index1], true, true);
            else
              FNIScommon1.FNIScommon.LogOutput(FNIScommon1.FNIScommon.tMsgu[1] + ": " + Strings.Left(FNIScommon1.FNIScommon.PatchText[index1], checked (num4 - 1)), true, true);
            if (Operators.CompareString(FNIScommon1.FNIScommon.PatchCheckFile[index1], "", false) != 0 && !fileSystem.FileExists(FNIScommon1.FNIScommon.PatchCheckFile[index1].ToUpperInvariant()))
              FNIScommon1.FNIScommon.WriteWarning(Strings.Left(FNIScommon1.FNIScommon.PatchText[index1], checked (num4 - 1)) + " " + FNIScommon1.FNIScommon.tWarn[4]);
            if (Operators.CompareString(FNIScommon1.FNIScommon.PatchID[index1], "PCEA", false) == 0 && fileSystem.DirectoryExists("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2"))
              FNIScommon1.FNIScommon.WriteWarning(FNIScommon1.FNIScommon.tWarn[16]);
          }
          checked { ++index1; }
        }
        while (index1 <= 19);
        FNIScommon1.FNIScommon.LogOutput("", true, true);
        if (fileSystem.DirectoryExists("..\\..\\meshes\\actors\\character\\animations\\FNIS_PCEA2"))
        {
          FNIScommon1.FNIScommon.LogOutput("Installing FNIS PCEA2", true, true);
          FNISaa1.FNISaa.PCEA2();
        }
        FNIScommon1.FNIScommon.PCEAList = new List<string>();
        StringArray = Directory.GetDirectories("..\\..\\meshes\\actors\\character\\animations\\");
        int index2 = 0;
        while (index2 < StringArray.Length)
        {
          string Expression = StringArray[index2];
          string[] strArray = Strings.Split(Expression, "\\", -1, CompareMethod.Binary);
          int Rank = 1;
          int index3 = Information.UBound((Array) strArray, Rank);
          string str2 = strArray[index3];
          if (Operators.CompareString(Strings.UCase(str2), "PCEA", false) == 0 | Strings.Len(str2) == 5 & Operators.CompareString(Strings.UCase(Strings.Left(str2, 4)), "PCEA", false) == 0)
          {
            FNIScommon1.FNIScommon.PCEAList.Add(str2);
          }
          else
          {
            FNIScommon1.FNIScommon.AnimListFile = Expression + "\\FNIS_" + str2 + "_List.txt";
            string str3 = "..\\..\\meshes\\actors\\character\\behaviors\\" + Strings.Replace("FNIS_*_Behavior.hkx", "*", str2, 1, -1, CompareMethod.Binary);
            if (fileSystem.FileExists(FNIScommon1.FNIScommon.AnimListFile))
            {
              if (fileSystem.FileExists(str3.ToUpperInvariant()))
              {
                int anzFuG = FNIScommon1.FNIScommon.Anz_fuG;
                int anzOfa = FNIScommon1.FNIScommon.Anz_ofa;
                int anzPa = FNIScommon1.FNIScommon.Anz_pa;
                int anzKm = FNIScommon1.FNIScommon.Anz_km;
                int anzCh = FNIScommon1.FNIScommon.Anz_ch;
                int anzAa = FNIScommon1.FNIScommon.Anz_aa;
                int anzAnim = FNIScommon1.FNIScommon.AnzAnim;
                checked { ++FNIScommon1.FNIScommon.AnzMod; }
                FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnzMod] = str2;
                FNIScommon1.FNIScommon.Check_hkx_type("..\\..\\meshes\\actors\\character\\behaviors\\FNIS_" + FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnzMod] + "_Behavior.hkx");
                FNIScommon1.FNIScommon.LogOutput(FNIScommon1.FNIScommon.tMsgu[2] + " " + str2, true, false);
                FNIScommon1.FNIScommon.ReadAnimationFile(FNIScommon1.FNIScommon.AnimListFile, FNIScommon1.FNIScommon.AnzMod, false);
                FNIScommon1.FNIScommon.LogOutput(" " + FNIScommon1.FNIScommon.MyModVers[FNIScommon1.FNIScommon.AnzMod] + " ", true, false);
                if (checked (FNIScommon1.FNIScommon.Anz_fuG + FNIScommon1.FNIScommon.Anz_ofa + FNIScommon1.FNIScommon.Anz_pa + FNIScommon1.FNIScommon.Anz_km + FNIScommon1.FNIScommon.Anz_aa + FNIScommon1.FNIScommon.Anz_ch - anzFuG - anzOfa - anzPa - anzKm - anzAa - anzCh) > 0)
                  FNIScommon1.FNIScommon.LogOutput(" " + Strings.Replace(Strings.Replace(Strings.Replace(Strings.Replace(Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[21], "<1>", Conversion.Str((object) checked (FNIScommon1.FNIScommon.Anz_fuG - anzFuG)), 1, -1, CompareMethod.Binary), "<2>", Conversion.Str((object) checked (FNIScommon1.FNIScommon.Anz_ofa - anzOfa)), 1, -1, CompareMethod.Binary), "<3>", Conversion.Str((object) checked (FNIScommon1.FNIScommon.Anz_pa - anzPa)), 1, -1, CompareMethod.Binary), "<4>", Conversion.Str((object) checked (FNIScommon1.FNIScommon.Anz_km - anzKm)), 1, -1, CompareMethod.Binary), "<5>", Conversion.Str((object) checked (FNIScommon1.FNIScommon.Anz_ch - anzCh)), 1, -1, CompareMethod.Binary), "<6>", Conversion.Str((object) checked (FNIScommon1.FNIScommon.Anz_aa - anzAa)), 1, -1, CompareMethod.Binary) + " ...", true, true);
                else
                  FNIScommon1.FNIScommon.LogOutput("...", true, true);
                FNIScommon1.FNIScommon.LogOutput("Number of animations for " + str2 + ": " + Conversions.ToString(checked (FNIScommon1.FNIScommon.AnzAnim + FNIScommon1.FNIScommon.Anz_aa - anzAnim - anzAa)) + " Total non-AA: " + Conversions.ToString(FNIScommon1.FNIScommon.AnzAnim) + " Total AA: " + Conversions.ToString(FNIScommon1.FNIScommon.Anz_aa), false, true);
                if (Operators.CompareString(Strings.UCase(str2), "FNISBASE", false) == 0 && Operators.CompareString(Strings.Mid(Strings.Split("V7.0", " ", -1, CompareMethod.Binary)[0], 2), Strings.Mid(Strings.Split(FNIScommon1.FNIScommon.MyModVers[FNIScommon1.FNIScommon.AnzMod], " ", -1, CompareMethod.Binary)[0], 2), false) != 0)
                  FNIScommon1.FNIScommon.WriteWarning(Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.tWarn[5], "<1>", "V7.0", 1, -1, CompareMethod.Binary), "<2>", FNIScommon1.FNIScommon.MyModVers[FNIScommon1.FNIScommon.AnzMod], 1, -1, CompareMethod.Binary));
              }
              else
                FNIScommon1.FNIScommon.WriteWarning(Strings.Replace(FNIScommon1.FNIScommon.tWarn[6], "<1>", " \"Animations\\" + str2 + "\"", 1, -1, CompareMethod.Binary));
            }
          }
          checked { ++index2; }
        }
        this.Read_PatchAFNames();
        FNISaa1.FNISaa.AA_PostProcessing();
        FNIScommon1.FNIScommon.DumpAnimList_Result();
        FNIScommon1.FNIScommon.LogOutput("\r\n" + FNIScommon1.FNIScommon.tMsgu[3] + str1, true, true);
        FNIScommon1.FNIScommon.TestGeneration = (short) 0;
        if (FNIScommon1.FNIScommon.called_from_Projects & !Directory.EnumerateFileSystemEntries("..\\..\\meshes\\actors\\character\\animations\\").Any<string>())
        {
          FNIScommon1.FNIScommon.TestGeneration = !FNIScommon1.FNIScommon.isPatch[0] ? (short) 2 : (short) 1;
          int num4 = (int) Interaction.MsgBox((object) ("No Animations directory found: generate without custom data.\r\nWithout patches: " + ((int) FNIScommon1.FNIScommon.TestGeneration == 2).ToString()), MsgBoxStyle.OkOnly, (object) null);
        }
        FNIScommon1.FNIScommon.LogOutput(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[4], "<1>", "defaultfemale.xml", 1, -1, CompareMethod.Binary) + " ...", false, true);
        if (fileSystem.FileExists("temporary_logs\\defaultfemale.xml"))
          fileSystem.DeleteFile("temporary_logs\\defaultfemale.xml");
        if (fileSystem.FileExists("defaultfemale.hkx"))
          fileSystem.DeleteFile("defaultfemale.hkx");
        FNIScommon1.FNIScommon.currBones = nBones1;
        FNIScommon1.FNIScommon.GenerateBehavior("templates\\defaultfemale_Template.txt", "temporary_logs\\defaultfemale.xml", 3, false, ref FNIScommon1.FNIScommon.ArrDefaultF, ref FNIScommon1.FNIScommon.iArrDefaultF);
        this.Read_AnimsInDefault(1, ref FNIScommon1.FNIScommon.ArrDefaultF, FNIScommon1.FNIScommon.iArrDefaultF, "..\\..\\meshes\\actors\\character\\animations\\", (string) null, (string) null, (string) null);
        FNIScommon1.FNIScommon.LogOutput(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[4], "<1>", "defaultmale.xml", 1, -1, CompareMethod.Binary) + " ...", false, true);
        FNIScommon1.FNIScommon.currBones = nBones2;
        if (fileSystem.FileExists("temporary_logs\\defaultmale.xml"))
          fileSystem.DeleteFile("temporary_logs\\defaultmale.xml");
        if (fileSystem.FileExists("defaultmale.hkx"))
          fileSystem.DeleteFile("defaultmale.hkx");
        FNIScommon1.FNIScommon.GenerateBehavior("templates\\defaultmale_Template.txt", "temporary_logs\\defaultmale.xml", 3, false, ref FNIScommon1.FNIScommon.ArrDefaultM, ref FNIScommon1.FNIScommon.iArrDefaultM);
        this.Read_AnimsInDefault(2, ref FNIScommon1.FNIScommon.ArrDefaultM, FNIScommon1.FNIScommon.iArrDefaultM, "..\\..\\meshes\\actors\\character\\animations\\", (string) null, (string) null, (string) null);
        if (FNIScommon1.FNIScommon.isGENDER)
        {
          FNIScommon1.FNIScommon.LogOutput(FNIScommon1.FNIScommon.tMsgu[8] + " ...", false, true);
          this.Generate_GENDER_Default(true);
          this.Generate_GENDER_Default(false);
        }
        if (FNIScommon1.FNIScommon.isPCEA)
        {
          if (!(fileSystem.DirectoryExists("..\\..\\meshes\\actors\\character\\animations\\PCEA") & fileSystem.DirectoryExists("..\\..\\meshes\\actors\\character\\animations\\PCEA\\male") & fileSystem.DirectoryExists("..\\..\\meshes\\actors\\character\\animations\\PCEA\\female")))
            Information.Err().Raise(2022, (object) null, (object) null, (object) null, (object) null);
          List<string>.Enumerator enumerator = FNIScommon1.FNIScommon.PCEAList.GetEnumerator();
          while (enumerator.MoveNext())
          {
            string current = enumerator.Current;
            FNIScommon1.FNIScommon.LogOutput(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[7], "<1>", current, 1, -1, CompareMethod.Binary) + " ...", false, true);
            this.Generate_PCEA_Default(current, true);
            this.Generate_PCEA_Default(current, false);
          }
          enumerator.Dispose();
        }
        FNIScommon1.FNIScommon.hkxcmdProcess.StartInfo.Arguments = Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.hkxcmd_Params, "*", "temporary_logs\\defaultfemale.xml", 1, -1, CompareMethod.Binary), "#", "temporary_logs\\defaultfemale.hkx", 1, -1, CompareMethod.Binary);
        FNIScommon1.FNIScommon.hkxcmdProcess.Start();
        FNIScommon1.FNIScommon.hkxcmdProcess.WaitForExit();
        FNIScommon1.FNIScommon.hkxcmdProcess.StartInfo.Arguments = Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.hkxcmd_Params, "*", "temporary_logs\\defaultmale.xml", 1, -1, CompareMethod.Binary), "#", "temporary_logs\\defaultmale.hkx", 1, -1, CompareMethod.Binary);
        FNIScommon1.FNIScommon.hkxcmdProcess.Start();
        FNIScommon1.FNIScommon.hkxcmdProcess.WaitForExit();
        if (FNIScommon1.FNIScommon.isPCEA)
        {
          List<string>.Enumerator enumerator = FNIScommon1.FNIScommon.PCEAList.GetEnumerator();
          while (enumerator.MoveNext())
          {
            string current = enumerator.Current;
            FNIScommon1.FNIScommon.hkxcmdProcess.StartInfo.Arguments = Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.hkxcmd_Params, "*", "temporary_logs\\" + current + "defaultfemale.xml", 1, -1, CompareMethod.Binary), "#", current + "defaultfemale.hkx", 1, -1, CompareMethod.Binary);
            FNIScommon1.FNIScommon.hkxcmdProcess.Start();
            FNIScommon1.FNIScommon.hkxcmdProcess.WaitForExit();
            FNIScommon1.FNIScommon.hkxcmdProcess.StartInfo.Arguments = Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.hkxcmd_Params, "*", "temporary_logs\\" + current + "defaultmale.xml", 1, -1, CompareMethod.Binary), "#", current + "defaultmale.hkx", 1, -1, CompareMethod.Binary);
            FNIScommon1.FNIScommon.hkxcmdProcess.Start();
            FNIScommon1.FNIScommon.hkxcmdProcess.WaitForExit();
          }
          enumerator.Dispose();
        }
        string[] strArray1 = Strings.Split("0_master/1hm_behavior/1hm_locomotion/bashbehavior/blockbehavior/bow_direction_behavior/crossbow_direction_behavior/horsebehavior/idlebehavior/magic_readied_direction_behavior/magicbehavior/magicmountedbehavior/mt_behavior/shout_behavior/shoutmounted_behavior/sprintbehavior/staggerbehavior/weapequip", "/", -1, CompareMethod.Binary);
        int[] numArray = new int[18]
        {
          2,
          3,
          4,
          5,
          6,
          7,
          0,
          0,
          8,
          9,
          10,
          11,
          1,
          12,
          0,
          13,
          14,
          15
        };
        FNIScommon1.FNIScommon.LogOutput("isAAbehavior " + Conversions.ToString(FNIScommon1.FNIScommon.isAAbehavior) + " / " + Conversion.Hex(FNIScommon1.FNIScommon.isAAbehavior), false, true);
        uint isAabehavior = FNIScommon1.FNIScommon.isAAbehavior;
        int num5 = checked (FNIScommon1.FNIScommon.PatchCount - 1);
        int index4 = 0;
        while (index4 <= num5)
        {
          if (FNIScommon1.FNIScommon.isPatch[index4] & (ulong) FNIScommon1.FNIScommon.PatchReqBehaviors[index4] > 0UL)
            isAabehavior |= FNIScommon1.FNIScommon.PatchReqBehaviors[index4];
          checked { ++index4; }
        }
        uint num6 = 259063;
        FNIScommon1.FNIScommon.MtBehaviorRI = 0;
        string Expression1 = "";
        int num7 = 0;
        string[] OutArray1;
        do
        {
          bool flag1 = Decimal.Compare(new Decimal((ulong) isAabehavior & 1UL), Decimal.One) == 0;
          bool flag2 = Decimal.Compare(new Decimal((ulong) num6 & 1UL), Decimal.One) == 0;
          string str2 = strArray1[checked (17 - num7)];
          FNIScommon1.FNIScommon.CurrentTemplateType = numArray[checked (17 - num7)];
          if (FNIScommon1.FNIScommon.DebugOutput > 1)
            FNIScommon1.FNIScommon.LogOutput(str2 + ": aa " + Conversions.ToString(flag1) + " supported: " + Conversions.ToString(flag2), false, true);
          if (fileSystem.FileExists(("temporary_logs\\" + str2 + ".xml").ToUpperInvariant()))
            fileSystem.DeleteFile("temporary_logs\\" + str2 + ".xml");
          if (fileSystem.FileExists(("..\\..\\meshes\\actors\\character\\behaviors\\" + str2 + ".hkx").ToUpperInvariant()))
            fileSystem.DeleteFile("..\\..\\meshes\\actors\\character\\behaviors\\" + str2 + ".hkx");
          isAabehavior >>= 1;
          num6 >>= 1;
          if ((flag1 | (int) FNIScommon1.FNIScommon.TestGeneration > 0) & flag2 | num7 == 17 | num7 == 5 & (FNIScommon1.FNIScommon.Anz_fu > 0 | FNIScommon1.FNIScommon.Anz_ofa > 0 | FNIScommon1.FNIScommon.Anz_chG > 0))
          {
            Expression1 = Expression1 + str2 + " ";
            FNIScommon1.FNIScommon.LogOutput(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[4], "<1>", str2 + ".hkx", 1, -1, CompareMethod.Binary) + " ...", false, true);
            int num4 = 4;
            if (num7 == 17)
              num4 = 2;
            if (num7 == 5)
              num4 = 1;
            FNISaa1.FNISaa.AATotalAnimCount = 0;
            string TemplateFileName = "templates\\" + str2 + "_TEMPLATE.txt";
            string BehaviorFileName = "temporary_logs\\" + str2 + ".xml";
            int BehaviorType = num4;
            int num8 = flag1 ? 1 : 0;
            OutArray1 = (string[]) null;
            int iOut = 0;
            FNIScommon1.FNIScommon.GenerateBehavior(TemplateFileName, BehaviorFileName, BehaviorType, num8 != 0, ref OutArray1, ref iOut);
            if (num7 == 17)
            {
              FNIScommon1.FNIScommon.B0_masterRI = FNIScommon1.FNIScommon.RecIndex;
              FNIScommon1.FNIScommon.B0_masterAA = FNISaa1.FNISaa.AATotalAnimCount;
            }
            if (num7 == 5)
            {
              FNIScommon1.FNIScommon.MtBehaviorRI = FNIScommon1.FNIScommon.RecIndex;
              FNIScommon1.FNIScommon.MtBehaviorAA = FNISaa1.FNISaa.AATotalAnimCount;
            }
            FNIScommon1.FNIScommon.LogOutput("Converting " + str2 + ".xml to .hkx", false, true);
            FNIScommon1.FNIScommon.hkxcmdProcess.StartInfo.Arguments = Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.hkxcmd_Params, "*", "temporary_logs\\" + str2 + ".xml", 1, -1, CompareMethod.Binary), "#", "temporary_logs\\" + str2 + ".hkx", 1, -1, CompareMethod.Binary);
            FNIScommon1.FNIScommon.hkxcmdProcess.Start();
            FNIScommon1.FNIScommon.hkxcmdProcess.WaitForExit();
          }
          else if (flag2 & (int) FNIScommon1.FNIScommon.TestGeneration == 0)
          {
            int index3 = FNIScommon1.FNIScommon.Read_Template_Entry(str2 + "_TEMPLATE.txt");
            if (index3 >= 0 && FNIScommon1.FNIScommon.AllTemplates[index3].bAutomaticPatch)
              fileSystem.CopyFile("templates\\" + str2 + "_PATCHED.hkx", "..\\..\\meshes\\actors\\character\\behaviors\\" + str2 + ".hkx");
          }
          checked { ++num7; }
        }
        while (num7 <= 17);
        FNIScommon1.FNIScommon.ErrString = "";
        if (fileSystem.FileExists("temporary_logs\\defaultfemale.hkx"))
          fileSystem.MoveFile("temporary_logs\\defaultfemale.hkx", "..\\..\\meshes\\actors\\character\\characters female\\defaultfemale.hkx", true);
        else
          FNIScommon1.FNIScommon.ErrString += "defaultfemale.hkx ";
        if (fileSystem.FileExists("temporary_logs\\defaultmale.hkx"))
          fileSystem.MoveFile("temporary_logs\\defaultmale.hkx", "..\\..\\meshes\\actors\\character\\characters\\defaultmale.hkx", true);
        else
          FNIScommon1.FNIScommon.ErrString += "defaultmale.hkx ";
        if (FNIScommon1.FNIScommon.isPCEA)
        {
          List<string>.Enumerator enumerator = FNIScommon1.FNIScommon.PCEAList.GetEnumerator();
          while (enumerator.MoveNext())
          {
            string current = enumerator.Current;
            string str2 = Strings.Len(current) != 4 ? ".hk" + Strings.Right(current, 1) : ".hkp";
            if (fileSystem.FileExists(current + "defaultfemale.hkx"))
              fileSystem.MoveFile(current + "defaultfemale.hkx", "..\\..\\meshes\\actors\\character\\characters female\\defaultfemale" + str2, true);
            else
              FNIScommon1.FNIScommon.ErrString = FNIScommon1.FNIScommon.ErrString + current + "defaultfemale.hkx ";
            if (fileSystem.FileExists(current + "defaultmale.hkx"))
              fileSystem.MoveFile(current + "defaultmale.hkx", "..\\..\\meshes\\actors\\character\\characters\\defaultmale" + str2, true);
            else
              FNIScommon1.FNIScommon.ErrString = FNIScommon1.FNIScommon.ErrString + current + "defaultmale.hkx ";
          }
          enumerator.Dispose();
        }
        OutArray1 = Strings.Split(Expression1, " ", -1, CompareMethod.Binary);
        int index5 = 0;
        while (index5 < OutArray1.Length)
        {
          string Left = OutArray1[index5];
          if (Operators.CompareString(Left, "", false) != 0)
          {
            if (fileSystem.FileExists(("temporary_logs\\" + Left + ".hkx").ToUpperInvariant()))
              fileSystem.MoveFile("temporary_logs\\" + Left + ".hkx", "..\\..\\meshes\\actors\\character\\behaviors\\" + Left + ".hkx", true);
            else
              FNIScommon1.FNIScommon.ErrString = FNIScommon1.FNIScommon.ErrString + Left + ".hkx ";
          }
          checked { ++index5; }
        }
        if (Operators.CompareString(FNIScommon1.FNIScommon.ErrString, "", false) != 0)
          Information.Err().Raise(2012, (object) null, (object) null, (object) null, (object) null);
        this.FNISModlist2L.Add(Strings.Format((object) fileSystem.GetFileInfo("..\\..\\meshes\\actors\\character\\behaviors\\0_master.hkx").Length, ""));
        if (fileSystem.FileExists("temporary_logs\\DummyStart.txt"))
          fileSystem.DeleteFile("temporary_logs\\DummyStart.txt");
        if (fileSystem.FileExists("..\\..\\meshes\\animationsetdatasinglefile.txt"))
          fileSystem.DeleteFile("..\\..\\meshes\\animationsetdatasinglefile.txt");
        this.Read_CustomPreCheckFile();
        string[] OutArray2;
        if (checked (FNIScommon1.FNIScommon.Anz_pa + FNIScommon1.FNIScommon.Anz_km) > 0 | FNIScommon1.FNIScommon.isPCEA | FNIScommon1.FNIScommon.isGENDER | GenerateFNISUsers.iCustomPreCacheSet > 0 | !Information.IsNothing((object) FNISaa1.FNISaa.AAcrcList))
        {
          FNIScommon1.FNIScommon.LogOutput(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[4], "<1>", "animationsetdatasinglefile.txt", 1, -1, CompareMethod.Binary) + " ...", false, true);
          string TemplateFileName = "templates\\animationsetdatasinglefile_TEMPLATE.txt";
          string BehaviorFileName = "..\\..\\meshes\\animationsetdatasinglefile.txt";
          int BehaviorType = 3;
          int num4 = 0;
          OutArray2 = (string[]) null;
          int iOut = 0;
          FNIScommon1.FNIScommon.GenerateBehavior(TemplateFileName, BehaviorFileName, BehaviorType, num4 != 0, ref OutArray2, ref iOut);
          if (FNIScommon1.FNIScommon.isPCEA | FNIScommon1.FNIScommon.isGENDER | GenerateFNISUsers.iCustomPreCacheSet > 0 | !Information.IsNothing((object) FNISaa1.FNISaa.AAcrcList))
            this.add_ASDSF_precache();
        }
        FNISaa1.FNISaa.Patch_FNIS_aa_pex();
        FNIScommon1.FNIScommon.Check_all_hkx_files("..\\..\\meshes\\actors\\character\\animations\\");
        FNIScommon1.FNIScommon.Check_all_hkx_files("..\\..\\meshes\\actors\\character\\animations\\female\\");
        FNIScommon1.FNIScommon.Check_all_hkx_files("..\\..\\meshes\\actors\\character\\animations\\male\\");
        if (FNIScommon1.FNIScommon.isPCEA)
        {
          FNIScommon1.FNIScommon.Check_all_hkx_files("..\\..\\meshes\\actors\\character\\animations\\PCEA\\female\\");
          FNIScommon1.FNIScommon.Check_all_hkx_files("..\\..\\meshes\\actors\\character\\animations\\PCEA\\male\\");
        }
        if (FNIScommon1.FNIScommon.MtBehaviorRI > 0)
          FNIScommon1.FNIScommon.LogOutput("mt_behavior " + FNIScommon1.FNIScommon.tMsgu[24] + ": " + Strings.Format((object) ((double) checked (100 * FNIScommon1.FNIScommon.MtBehaviorRI - 5220) / 4780.0), "0.0") + " %  " + Strings.Replace(Strings.Replace(Strings.Replace(Strings.Replace(" " + FNIScommon1.FNIScommon.tMsgu[6], "<1>", Conversion.Str((object) FNIScommon1.FNIScommon.Anz_fuG), 1, -1, CompareMethod.Binary), "<2>", Conversion.Str((object) FNIScommon1.FNIScommon.Anz_ofa), 1, -1, CompareMethod.Binary), "<3>", Conversion.Str((object) FNIScommon1.FNIScommon.Anz_ch), 1, -1, CompareMethod.Binary), "<4>", Conversion.Str((object) FNIScommon1.FNIScommon.MtBehaviorAA), 1, -1, CompareMethod.Binary), false, true);
        FNIScommon1.FNIScommon.LogOutput("0_master " + FNIScommon1.FNIScommon.tMsgu[24] + ": " + Strings.Format((object) ((double) checked (100 * FNIScommon1.FNIScommon.B0_masterRI - 2530) / 7470.0), "0.0") + " %  " + Strings.Replace(Strings.Replace(Strings.Replace(" " + FNIScommon1.FNIScommon.tMsgu[22], "<1>", Conversion.Str((object) FNIScommon1.FNIScommon.Anz_pa), 1, -1, CompareMethod.Binary), "<2>", Conversion.Str((object) FNIScommon1.FNIScommon.Anz_km), 1, -1, CompareMethod.Binary), "<3>", Conversion.Str((object) FNIScommon1.FNIScommon.B0_masterAA), 1, -1, CompareMethod.Binary), false, true);
        FNIScommon1.FNIScommon.LogOutput("Alternate Animation mods:" + Conversion.Str((object) FNISaa1.FNISaa.iAAPrefix) + " sets:" + Conversion.Str((object) FNISaa1.FNISaa.iAASet) + " total groups:" + Conversion.Str((object) FNISaa1.FNISaa.nAAgroups) + " added file slots:" + Conversion.Str((object) FNISaa1.FNISaa.nAAfilesdef) + " alternate files:" + Conversion.Str((object) FNIScommon1.FNIScommon.Anz_aa), true, true);
        FNIScommon1.FNIScommon.TotalWarnings = FNIScommon1.FNIScommon.WarningCount;
        FNIScommon1.FNIScommon.TotalAnimations = 0;
        FNIScommon1.FNIScommon.AnzModChar = FNIScommon1.FNIScommon.AnzMod;
        FNIScommon1.FNIScommon.AnzAnimChar = checked (FNIScommon1.FNIScommon.AnzAnim + FNIScommon1.FNIScommon.Anz_aa - FNIScommon1.FNIScommon.Anz_sG - FNIScommon1.FNIScommon.Anz_fuG);
        this.Execute_BehavioredObjects();
        FNIScommon1.FNIScommon.MyBO = 0;
        FNIScommon1.FNIScommon.WarningCount = 0;
        if (MyProject.Computer.FileSystem.FileExists("..\\..\\meshes\\animationdatasinglefile.txt"))
          MyProject.Computer.FileSystem.DeleteFile("..\\..\\meshes\\animationdatasinglefile.txt");
        if (FNIScommon1.FNIScommon.MRD_DataListALL.Count > 0 | FNIScommon1.FNIScommon.Anz_aa > 0 | FNIScommon1.FNIScommon.nPatchAF[2] > 0)
        {
          if (FNIScommon1.FNIScommon.DebugOutput > 0)
          {
            List<FNIScommon1.FNIScommon.MRD_Data>.Enumerator enumerator = FNIScommon1.FNIScommon.MRD_DataListALL.GetEnumerator();
            while (enumerator.MoveNext())
            {
              FNIScommon1.FNIScommon.MRD_Data current = enumerator.Current;
              string str2 = Strings.Join(current.@params, " ");
              if (FNIScommon1.FNIScommon.DebugOutput > 1)
                FNIScommon1.FNIScommon.LogOutput("YYY MRDALL first " + current.firstOfBlock.ToString() + " ismd " + current.isMD.ToString() + " curranim " + current.currAnim.ToString() + " modid " + current.modId.ToString() + " BOid " + current.BOId.ToString() + " " + str2, false, true);
            }
            enumerator.Dispose();
          }
          FNIScommon1.FNIScommon.LogOutput(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[4], "<1>", "animationdatasinglefile.txt", 1, -1, CompareMethod.Binary) + " ...", false, true);
          string TemplateFileName = "templates\\animationdatasinglefile_TEMPLATE.txt";
          string BehaviorFileName = "..\\..\\meshes\\animationdatasinglefile.txt";
          int BehaviorType = 3;
          int num4 = 0;
          OutArray2 = (string[]) null;
          int iOut = 0;
          FNIScommon1.FNIScommon.GenerateBehavior(TemplateFileName, BehaviorFileName, BehaviorType, num4 != 0, ref OutArray2, ref iOut);
        }
        checked { FNIScommon1.FNIScommon.TotalWarnings += FNIScommon1.FNIScommon.WarningCount; }
        string str4 = "";
        if (FNIScommon1.FNIScommon.TotalWarnings > 0)
          str4 = ".";
        FNIScommon1.FNIScommon.LogOutput("", true, true);
        FNIScommon1.FNIScommon.LogOutput(Strings.Replace(Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[11] + str4, "<1>", Conversion.Str((object) FNIScommon1.FNIScommon.AnzAnimChar), 1, -1, CompareMethod.Binary), "<2>", Conversion.Str((object) FNIScommon1.FNIScommon.AnzModChar), 1, -1, CompareMethod.Binary), "<3>", "character", 1, -1, CompareMethod.Binary), true, true);
        if (FNIScommon1.FNIScommon.TotalAnimations > 0)
          FNIScommon1.FNIScommon.LogOutput(Strings.Replace(Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[29] + str4, "<1>", Conversion.Str((object) FNIScommon1.FNIScommon.TotalAnimations), 1, -1, CompareMethod.Binary), "<2>", Conversion.Str((object) FNIScommon1.FNIScommon.No_BOmods), 1, -1, CompareMethod.Binary), "<3>", Conversion.Str((object) FNIScommon1.FNIScommon.No_BO), 1, -1, CompareMethod.Binary), true, true);
        if (FNIScommon1.FNIScommon.TotalWarnings > 0)
        {
          FNIScommon1.FNIScommon.LogOutput(Conversion.Str((object) FNIScommon1.FNIScommon.TotalWarnings) + " " + FNIScommon1.FNIScommon.tWarn[8] + ".", true, true);
          FNIScommon1.FNIScommon.RetCode = -1;
        }
        MyProject.Computer.FileSystem.CopyFile("templates\\FNISVersionGenerated_TEMPLATE.pex", "..\\..\\Scripts\\FNISVersionGenerated.pex", true);
        string[] array = this.FNISModlist2L.ToArray();
        FNIScommon1.FNIScommon.WriteAFile("FNISmodList.txt", ref array, checked (Information.UBound((Array) array, 1) + 1));
        FNIScommon1.FNIScommon.Textbox.SelectionStart = 0;
        FNIScommon1.FNIScommon.Textbox.ScrollToCaret();
        this.Button2.Enabled = true;
        this.optionChanged = false;
label_171:
        FNIScommon1.FNIScommon.FinishSub();
        goto label_177;
label_172:
        num2 = -1;
        switch (num1)
        {
          case 2:
            FNIScommon1.FNIScommon.WriteError();
            goto label_171;
        }
      }
      catch (Exception ex) when (ex is Exception & (uint) num1 > 0U & num2 == 0)
      {
        ProjectData.SetProjectError(ex);
        goto label_172;
      }
      throw ProjectData.CreateProjectError(-2146828237);
label_177:
      if (num2 == 0)
        return;
      ProjectData.ClearProjectError();
    }

    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
    public void Initialize_PatchBox()
    {
      if (!MyProject.Computer.FileSystem.FileExists(GenerateFNISUsers.PatchDefFile.ToUpperInvariant()))
      {
        FNIScommon1.FNIScommon.ErrString = GenerateFNISUsers.PatchDefFile;
        Information.Err().Raise(2001, (object) null, (object) null, (object) null, (object) null);
      }
      else
      {
        string[] strArray1 = FNIScommon1.FNIScommon.ReadAFile(GenerateFNISUsers.PatchDefFile);
        bool flag1 = false;
        string[] strArray2;
        if (MyProject.Computer.FileSystem.FileExists("MyPatches.txt"))
        {
          strArray2 = FNIScommon1.FNIScommon.ReadAFile("MyPatches.txt");
          flag1 = true;
          if (Information.UBound((Array) strArray2, 1) > 0)
          {
            string[] strArray3 = Strings.Split(strArray2[0], ":", -1, CompareMethod.Binary);
            if (Operators.CompareString(strArray3[0], "Language", false) == 0)
              FNIScommon1.FNIScommon.lastLanguage = Strings.LCase(Strings.RTrim(strArray3[1]));
          }
        }
        else
          strArray2 = (string[]) null;
        this.optionChanged = false;
        FNIScommon1.FNIScommon.PatchCount = 0;
        FNIScommon1.FNIScommon.SkeletonCount = 0;
        FNIScommon1.FNIScommon.isPCEA = false;
        FNIScommon1.FNIScommon.isGENDER = false;
        FNIScommon1.FNIScommon.isSKELETON = false;
        this.Patch_ListBox.BeginUpdate();
        bool flag2 = true;
        string[] strArray4 = strArray1;
        int index1 = 0;
        while (index1 < strArray4.Length)
        {
          string str = strArray4[index1];
          if (flag2)
          {
            GenerateFNISUsers.FirstPatchLine = str;
            flag2 = false;
            if (Operators.CompareString(Strings.Left(str, 18), "<!-- FNIS template", false) == 0)
              goto label_29;
          }
          string Left = Strings.Left(str, 1);
          if (FNIScommon1.FNIScommon.PatchCount < 20 & Strings.Len(str) > 0 & (uint) Operators.CompareString(Left, "'", false) > 0U & (uint) Operators.CompareString(Left, " ", false) > 0U)
          {
            string[] strArray3 = Strings.Split(str, "#", -1, CompareMethod.Binary);
            if (Information.UBound((Array) strArray3, 1) > 0)
            {
              if (Operators.CompareString(strArray3[1], "", false) == 0)
                strArray3[1] = "0";
              if (Operators.CompareString(strArray3[2], "", false) == 0)
                strArray3[2] = "0";
              if (Operators.CompareString(strArray3[3], "", false) == 0)
                strArray3[3] = "0";
              if (Conversions.ToInteger(strArray3[2]) > 0)
              {
                FNIScommon1.FNIScommon.SkeletonID[FNIScommon1.FNIScommon.SkeletonCount] = strArray3[0];
                FNIScommon1.FNIScommon.nBonesSkeleton[FNIScommon1.FNIScommon.SkeletonCount] = Conversions.ToInteger(strArray3[2]);
                FNIScommon1.FNIScommon.PatchSkeletonSize[FNIScommon1.FNIScommon.SkeletonCount] = Conversions.ToInteger(strArray3[3]);
                checked { ++FNIScommon1.FNIScommon.SkeletonCount; }
              }
              else
              {
                FNIScommon1.FNIScommon.PatchID[FNIScommon1.FNIScommon.PatchCount] = strArray3[0];
                FNIScommon1.FNIScommon.PatchAddAnims[FNIScommon1.FNIScommon.PatchCount] = Conversions.ToInteger(strArray3[1]);
                FNIScommon1.FNIScommon.PatchReqBehaviors[FNIScommon1.FNIScommon.PatchCount] = checked ((uint) Convert.ToInt32(strArray3[3], 16));
                FNIScommon1.FNIScommon.PatchText[FNIScommon1.FNIScommon.PatchCount] = Strings.Replace(Strings.Replace(strArray3[4], "\t", " ", 1, -1, CompareMethod.Binary), "\n", " ", 1, -1, CompareMethod.Binary);
                FNIScommon1.FNIScommon.PatchCheckFile[FNIScommon1.FNIScommon.PatchCount] = "";
                if (Information.UBound((Array) strArray3, 1) >= 5)
                  FNIScommon1.FNIScommon.PatchCheckFile[FNIScommon1.FNIScommon.PatchCount] = strArray3[5];
                FNIScommon1.FNIScommon.isPatch[FNIScommon1.FNIScommon.PatchCount] = false;
                this.Patch_ListBox.Enabled = true;
                this.Patch_ListBox.Items.Add((object) FNIScommon1.FNIScommon.PatchText[FNIScommon1.FNIScommon.PatchCount]);
                if (flag1)
                {
                  string[] strArray5 = strArray2;
                  int index2 = 0;
                  while (index2 < strArray5.Length)
                  {
                    if (Operators.CompareString(strArray5[index2], FNIScommon1.FNIScommon.PatchID[FNIScommon1.FNIScommon.PatchCount], false) == 0)
                      this.Patch_ListBox.SetItemChecked(FNIScommon1.FNIScommon.PatchCount, true);
                    checked { ++index2; }
                  }
                }
                this.Patch_ListBox.SetSelected(FNIScommon1.FNIScommon.PatchCount, true);
                checked { ++FNIScommon1.FNIScommon.PatchCount; }
              }
            }
          }
label_29:
          checked { ++index1; }
        }
        this.Patch_ListBox.EndUpdate();
        this.Patch_ListBox.TopIndex = 0;
      }
    }

    public void Store_Patches()
    {
      string[] StringArray = new string[11];
      if (MyProject.Computer.FileSystem.FileExists("MyPatches.txt"))
        MyProject.Computer.FileSystem.DeleteFile("MyPatches.txt");
      int Elements;
      if (Operators.CompareString(FNIScommon1.FNIScommon.lastLanguage, "english", false) == 0 | Operators.CompareString(FNIScommon1.FNIScommon.lastLanguage, "", false) == 0)
      {
        Elements = 0;
      }
      else
      {
        StringArray[0] = "Language:" + FNIScommon1.FNIScommon.lastLanguage;
        Elements = 1;
      }
      int num = checked (FNIScommon1.FNIScommon.PatchCount - 1);
      int index = 0;
      while (index <= num)
      {
        if (FNIScommon1.FNIScommon.isPatch[index] & (uint) Operators.CompareString(FNIScommon1.FNIScommon.PatchID[index], "HKX_COMPAT", false) > 0U)
        {
          StringArray[Elements] = FNIScommon1.FNIScommon.PatchID[index];
          checked { ++Elements; }
        }
        checked { ++index; }
      }
      if (Elements <= 0)
        return;
      FNIScommon1.FNIScommon.WriteAFile("MyPatches.txt", ref StringArray, Elements);
    }

    public void Generate_PCEA_Default(string PCEAdir, bool isMale)
    {
      int num1;
      int num2;
      try
      {
        ProjectData.ClearProjectError();
        num1 = 2;
        string[] strArray1 = new string[2001];
        string[] strArray2 = new string[4001];
        string[] strArray3 = new string[10001];
        string suffix = Strings.Len(PCEAdir) != 4 ? Strings.Right(PCEAdir, 1) : "t";
        string str1;
        string PathToAnimsShort;
        string str2;
        if (isMale)
        {
          str1 = "..\\..\\meshes\\actors\\character\\animations\\" + PCEAdir + "\\male\\";
          PathToAnimsShort = PCEAdir + "\\male";
          str2 = "temporary_logs\\" + PCEAdir + "defaultmale.xml";
        }
        else
        {
          str1 = "..\\..\\meshes\\actors\\character\\animations\\" + PCEAdir + "\\female\\";
          PathToAnimsShort = PCEAdir + "\\female";
          str2 = "temporary_logs\\" + PCEAdir + "defaultfemale.xml";
        }
        FileSystemProxy fileSystem = MyProject.Computer.FileSystem;
        if (!fileSystem.DirectoryExists(str1))
          fileSystem.CreateDirectory(str1);
        if (fileSystem.FileExists(str2))
          fileSystem.DeleteFile(str2);
        if (isMale)
        {
          this.Read_AnimsInDefault(7, ref FNIScommon1.FNIScommon.ArrDefaultM, FNIScommon1.FNIScommon.iArrDefaultM, str1, PathToAnimsShort, str2, suffix);
          goto label_16;
        }
        else
        {
          this.Read_AnimsInDefault(6, ref FNIScommon1.FNIScommon.ArrDefaultF, FNIScommon1.FNIScommon.iArrDefaultF, str1, PathToAnimsShort, str2, suffix);
          goto label_16;
        }
label_11:
        num2 = -1;
        switch (num1)
        {
          case 2:
            FNIScommon1.FNIScommon.WriteError();
            FNIScommon1.FNIScommon.FinishSub();
            goto label_16;
        }
      }
      catch (Exception ex) when (ex is Exception & (uint) num1 > 0U & num2 == 0)
      {
        ProjectData.SetProjectError(ex);
        goto label_11;
      }
      throw ProjectData.CreateProjectError(-2146828237);
label_16:
      if (num2 == 0)
        return;
      ProjectData.ClearProjectError();
    }

    public void Generate_GENDER_Default(bool isMale)
    {
      int num1;
      int num2;
      try
      {
        ProjectData.ClearProjectError();
        num1 = 2;
        string[] strArray1 = new string[2001];
        string[] strArray2 = new string[4001];
        string[] strArray3 = new string[10001];
        string str;
        string PathToAnimsShort;
        if (isMale)
        {
          str = "..\\..\\meshes\\actors\\character\\animations\\male\\";
          PathToAnimsShort = "male";
        }
        else
        {
          str = "..\\..\\meshes\\actors\\character\\animations\\female\\";
          PathToAnimsShort = "female";
        }
        if (!MyProject.Computer.FileSystem.DirectoryExists(str))
        {
          FNIScommon1.FNIScommon.LogOutput(FNIScommon1.FNIScommon.tMsgu[15] + " " + PathToAnimsShort, true, true);
          goto label_14;
        }
        else if (isMale)
        {
          this.Read_AnimsInDefault(5, ref FNIScommon1.FNIScommon.ArrDefaultM, FNIScommon1.FNIScommon.iArrDefaultM, str, PathToAnimsShort, "temporary_logs\\defaultmale.xml", (string) null);
          goto label_14;
        }
        else
        {
          this.Read_AnimsInDefault(4, ref FNIScommon1.FNIScommon.ArrDefaultF, FNIScommon1.FNIScommon.iArrDefaultF, str, PathToAnimsShort, "temporary_logs\\defaultfemale.xml", (string) null);
          goto label_14;
        }
label_9:
        num2 = -1;
        switch (num1)
        {
          case 2:
            FNIScommon1.FNIScommon.WriteError();
            FNIScommon1.FNIScommon.FinishSub();
            goto label_14;
        }
      }
      catch (Exception ex) when (ex is Exception & (uint) num1 > 0U & num2 == 0)
      {
        ProjectData.SetProjectError(ex);
        goto label_9;
      }
      throw ProjectData.CreateProjectError(-2146828237);
label_14:
      if (num2 == 0)
        return;
      ProjectData.ClearProjectError();
    }

    public bool SkyrimMinVersOK(string SkyrimVers, string MinVers)
    {
      string[] strArray1 = Strings.Split(SkyrimVers, ".", -1, CompareMethod.Binary);
      bool flag;
      if (Operators.CompareString(strArray1[0], "??", false) == 0)
      {
        flag = true;
      }
      else
      {
        string[] strArray2 = Strings.Split(MinVers, ".", -1, CompareMethod.Binary);
        int index = 0;
        while (index <= 2)
        {
          int num = 0;
          if (Information.UBound((Array) strArray1, 1) >= index && Versioned.IsNumeric((object) strArray1[index]))
            num = Conversions.ToInteger(strArray1[index]);
          if (num < Conversions.ToInteger(strArray2[index]))
          {
            flag = false;
            goto label_12;
          }
          else if (num > Conversions.ToInteger(strArray2[index]))
          {
            flag = true;
            goto label_12;
          }
          else
            checked { ++index; }
        }
        flag = true;
      }
label_12:
      return flag;
    }

    public void GetSkeletonBones(string Skel, ref int nBones, ref string SkelName)
    {
      nBones = 99;
      SkelName = "Default";
      FileSystemProxy fileSystem = MyProject.Computer.FileSystem;
      if (fileSystem.FileExists(Skel))
      {
        SkelName = "Unknown";
        if (fileSystem.FileExists("temporary_logs\\skeleton.hkx"))
          fileSystem.DeleteFile("temporary_logs\\skeleton.hkx");
        if (FNIScommon1.FNIScommon.SkyrimEdition == 1)
        {
          if (fileSystem.FileExists("temporary_logs\\Skeleton.xml"))
            fileSystem.DeleteFile("temporary_logs\\Skeleton.xml");
          fileSystem.CopyFile(Skel, "temporary_logs\\skeleton.hkx");
          FNIScommon1.FNIScommon.hkxcmdProcess.StartInfo.Arguments = "convert -v:xml temporary_logs\\skeleton.hkx temporary_logs\\skeleton.xml";
          FNIScommon1.FNIScommon.hkxcmdProcess.Start();
          FNIScommon1.FNIScommon.hkxcmdProcess.WaitForExit();
          if (fileSystem.FileExists("temporary_logs\\Skeleton.xml"))
          {
            string[] strArray1 = FNIScommon1.FNIScommon.ReadAFile("temporary_logs\\Skeleton.xml");
            int index = 0;
            nBones = 0;
            while (index <= Information.UBound((Array) strArray1, 1))
            {
              if (Strings.InStr(strArray1[index], "parentIndices", CompareMethod.Binary) > 0)
              {
                string[] strArray2 = Strings.Split(strArray1[index], "\"", -1, CompareMethod.Binary);
                if (Information.UBound((Array) strArray2, 1) > 3)
                {
                  nBones = Conversions.ToInteger(strArray2[3]);
                  index = Information.UBound((Array) strArray1, 1);
                }
              }
              checked { ++index; }
            }
          }
          if (nBones != 99 & (uint) nBones > 0U)
          {
            int num = checked (FNIScommon1.FNIScommon.SkeletonCount - 1);
            int index = 0;
            while (index <= num)
            {
              if (nBones == FNIScommon1.FNIScommon.nBonesSkeleton[index])
                SkelName = FNIScommon1.FNIScommon.SkeletonID[index];
              checked { ++index; }
            }
          }
        }
        else
        {
          nBones = 0;
          int length = checked ((int) fileSystem.GetFileInfo(Skel).Length);
          int num1 = checked (FNIScommon1.FNIScommon.SkeletonCount - 1);
          int index = 0;
          int num2;
          while (index <= num1)
          {
            if (length == FNIScommon1.FNIScommon.PatchSkeletonSize[index])
            {
              nBones = FNIScommon1.FNIScommon.nBonesSkeleton[index];
              SkelName = FNIScommon1.FNIScommon.SkeletonID[index];
            }
            if (index == checked (FNIScommon1.FNIScommon.SkeletonCount - 1))
              num2 = FNIScommon1.FNIScommon.nBonesSkeleton[index];
            checked { ++index; }
          }
          if (nBones == 0)
            nBones = num2;
        }
      }
    }

    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
    public void add_ASDSF_precache()
    {
      string[] strArray = new string[1001];
      FileInfo fileInfo1 = new FileInfo("..\\..\\meshes\\animationsetdatasinglefile.txt");
      FileInfo fileInfo2 = new FileInfo("..\\..\\meshes\\animationsetdatasinglefile2.txt");
      if (!fileInfo1.Exists)
      {
        FNIScommon1.FNIScommon.ErrString = "..\\..\\meshes\\animationsetdatasinglefile.txt";
        Information.Err().Raise(2001, (object) null, (object) null, (object) null, (object) null);
      }
      int iline = 0;
      int oline = 0;
      int num1 = 0;
      bool bEOF = false;
      StreamWriter sw = new StreamWriter((Stream) fileInfo2.Open(FileMode.Create, FileAccess.Write));
      int num2 = 3;
      int num3 = 1;
      using (FileStream fileStream = fileInfo1.Open((FileMode) num2, (FileAccess) num3))
      {
        using (StreamReader sr = new StreamReader((Stream) fileStream))
        {
          while (!sr.EndOfStream)
          {
            string Left = this.ASDSF_IO(sr, sw, ref iline, ref oline, ref bEOF, true);
            if (num1 == 0)
            {
              if (Operators.CompareString(Left, "_MTSolo.txt", false) == 0)
              {
                num1 = 1;
                if (FNIScommon1.FNIScommon.DebugOutput > 1)
                  FNIScommon1.FNIScommon.LogOutput("ASDSF pre-cache - MTsolo iline:" + Conversion.Str((object) iline) + " oline:" + Conversion.Str((object) oline), false, true);
              }
            }
            else if (num1 == 1)
            {
              if (Operators.CompareString(Left, "V3", false) == 0)
                num1 = 2;
            }
            else if (num1 == 2 | num1 == 5)
            {
              if (FNIScommon1.FNIScommon.DebugOutput > 1)
                FNIScommon1.FNIScommon.LogOutput("ASDSF pre-cache - V3 iline:" + Conversion.Str((object) iline) + " oline:" + Conversion.Str((object) oline), false, true);
              int integer1 = Conversions.ToInteger(Left);
              int num4 = 1;
              string str;
              while (num4 <= integer1)
              {
                str = this.ASDSF_IO(sr, sw, ref iline, ref oline, ref bEOF, true);
                checked { ++num4; }
              }
              int num5 = checked (Conversions.ToInteger(this.ASDSF_IO(sr, sw, ref iline, ref oline, ref bEOF, true)) * 3);
              int num6 = 1;
              while (num6 <= num5)
              {
                str = this.ASDSF_IO(sr, sw, ref iline, ref oline, ref bEOF, true);
                checked { ++num6; }
              }
              int integer2 = Conversions.ToInteger(this.ASDSF_IO(sr, sw, ref iline, ref oline, ref bEOF, true));
              int num7 = 1;
              while (num7 <= integer2)
              {
                str = this.ASDSF_IO(sr, sw, ref iline, ref oline, ref bEOF, true);
                str = this.ASDSF_IO(sr, sw, ref iline, ref oline, ref bEOF, true);
                int integer3 = Conversions.ToInteger(this.ASDSF_IO(sr, sw, ref iline, ref oline, ref bEOF, true));
                int num8 = 1;
                while (num8 <= integer3)
                {
                  str = this.ASDSF_IO(sr, sw, ref iline, ref oline, ref bEOF, true);
                  checked { ++num8; }
                }
                checked { ++num7; }
              }
              int integer4 = Conversions.ToInteger(this.ASDSF_IO(sr, sw, ref iline, ref oline, ref bEOF, false));
              if (integer4 > 1000)
                throw new ApplicationException("Too many animations in animation block:" + Conversion.Str((object) integer4));
              int num9 = integer4;
              int num10 = checked (3 * integer4 - 1);
              int index1 = 0;
              while (index1 <= num10)
              {
                strArray[index1] = this.ASDSF_IO(sr, sw, ref iline, ref oline, ref bEOF, false);
                checked { ++index1; }
              }
              List<string> stringList = new List<string>();
              int num11 = 0;
              int num12 = checked (integer4 - 1);
              int num13 = 0;
              while (num13 <= num12)
              {
                uint uinteger1 = Conversions.ToUInteger(strArray[checked (num13 * 3)]);
                uint uinteger2 = Conversions.ToUInteger(strArray[checked (num13 * 3 + 1)]);
                int num8 = checked (GenerateFNISUsers.iPCEAgenderFile - 1);
                int index2 = 0;
                while (index2 <= num8)
                {
                  if ((int) GenerateFNISUsers.PCEAgenderFile[index2].crc == (int) uinteger2)
                  {
                    int num14 = checked (1000 * -(GenerateFNISUsers.PCEAgenderFile[index2].isGender_F ? 1 : 0) + 100 * -(GenerateFNISUsers.PCEAgenderFile[index2].isGender_M ? 1 : 0) + 10 * -(GenerateFNISUsers.PCEAgenderFile[index2].isPCEA_F ? 1 : 0) + -(GenerateFNISUsers.PCEAgenderFile[index2].isPCEA_M ? 1 : 0));
                    if (FNIScommon1.FNIScommon.DebugOutput > 1)
                      FNIScommon1.FNIScommon.LogOutput("ASDSF pre-cache - FOUND filename: " + Conversion.Str((object) checked (-num14)) + " " + GenerateFNISUsers.PCEAgenderFile[index2].name + Conversion.Str((object) uinteger2) + " " + strArray[checked (num13 * 3)], false, true);
                    if (num1 == 2)
                    {
                      if (GenerateFNISUsers.PCEAgenderFile[index2].isGender_F & (long) uinteger1 != 3729484155L)
                      {
                        stringList.Add("3729484155\r\n" + strArray[checked (num13 * 3 + 1)]);
                        checked { ++num11; }
                      }
                      if (GenerateFNISUsers.PCEAgenderFile[index2].isPCEA_F)
                      {
                        stringList.Add("1345400644\r\n" + strArray[checked (num13 * 3 + 1)]);
                        checked { ++num11; }
                      }
                    }
                    else if (num1 == 5)
                    {
                      if (GenerateFNISUsers.PCEAgenderFile[index2].isGender_M & (long) uinteger1 != 911414905L)
                      {
                        stringList.Add("911414905\r\n" + strArray[checked (num13 * 3 + 1)]);
                        checked { ++num11; }
                      }
                      if (GenerateFNISUsers.PCEAgenderFile[index2].isPCEA_M)
                      {
                        stringList.Add("4276040576\r\n" + strArray[checked (num13 * 3 + 1)]);
                        checked { ++num11; }
                      }
                    }
                    index2 = GenerateFNISUsers.iPCEAgenderFile;
                  }
                  checked { ++index2; }
                }
                List<FNISaa1.FNISaa.AAcrcInfo>.Enumerator enumerator;
                if (!Information.IsNothing((object) FNISaa1.FNISaa.AAcrcList))
                {
                  try
                  {
                    enumerator = FNISaa1.FNISaa.AAcrcList.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                      FNISaa1.FNISaa.AAcrcInfo current = enumerator.Current;
                      if ((int) current.reffile_crc == (int) uinteger2)
                      {
                        if (FNIScommon1.FNIScommon.DebugOutput > 2)
                          FNIScommon1.FNIScommon.LogOutput("AA pre-cache reference found: " + current.FileName + " ref_path: " + Conversions.ToString(uinteger1), false, true);
                        stringList.Add(Conversions.ToString(current.path_crc) + "\r\n" + Conversions.ToString(current.crc32));
                        checked { ++num11; }
                      }
                    }
                  }
                  finally
                  {
                    enumerator.Dispose();
                  }
                }
                int num15 = checked (GenerateFNISUsers.iCustomPreCacheSet - 1);
                int index3 = 0;
                while (index3 <= num15)
                {
                  GenerateFNISUsers.CustomPreCache customPreCache = GenerateFNISUsers.CustomPreCacheSet[index3];
                  if ((int) uinteger1 == (int) customPreCache.refpath_crc & (int) uinteger2 == (int) customPreCache.reffile_crc)
                  {
                    // ISSUE: variable of a reference type
                    int& local;
                    // ISSUE: explicit reference operation
                    // ISSUE: explicit reference operation
                    int num14 = checked (^(local = @GenerateFNISUsers.CustomPreCacheSet[index3].refcount) + 1);
                    // ISSUE: explicit reference operation
                    ^local = num14;
                    if (customPreCache.refnumber1 == 0 | customPreCache.refnumber1 == GenerateFNISUsers.CustomPreCacheSet[index3].refcount | customPreCache.refnumber2 == GenerateFNISUsers.CustomPreCacheSet[index3].refcount)
                    {
                      if (FNIScommon1.FNIScommon.DebugOutput > 1)
                        FNIScommon1.FNIScommon.LogOutput("ASDSF pre-cache - FOUND reference: " + Conversion.Str((object) uinteger1) + " " + Conversion.Str((object) uinteger2) + " " + Conversion.Str((object) GenerateFNISUsers.CustomPreCacheSet[index3].refcount) + "/" + Conversion.Str((object) customPreCache.refnumber1) + "/" + Conversion.Str((object) customPreCache.refnumber2), false, true);
                      int num16 = checked (customPreCache.nCustomAnims - 1);
                      int num17 = 0;
                      while (num17 <= num16)
                      {
                        stringList.Add(Strings.Format((object) customPreCache.custompath_crc, "") + "\r\n" + GenerateFNISUsers.CPCFile[checked (customPreCache.indexCustomAnims + num17)]);
                        checked { ++num11; }
                        checked { ++num17; }
                      }
                    }
                  }
                  checked { ++index3; }
                }
                checked { ++num13; }
              }
              sw.WriteLine(Strings.Format((object) checked (num9 + num11), ""));
              int num18 = checked (3 * num9 - 1);
              int index4 = 0;
              while (index4 <= num18)
              {
                sw.WriteLine(strArray[index4]);
                checked { ++index4; }
              }
              List<string>.Enumerator enumerator1;
              try
              {
                enumerator1 = stringList.GetEnumerator();
                while (enumerator1.MoveNext())
                {
                  string current = enumerator1.Current;
                  sw.WriteLine(current);
                  sw.WriteLine("7891816");
                }
              }
              finally
              {
                enumerator1.Dispose();
              }
              checked { oline += 3 * (num9 + num11) + 1; }
              checked { ++num1; }
            }
            else if (num1 == 3)
            {
              if (Operators.CompareString(Left, "V3", false) == 0)
              {
                num1 = 2;
              }
              else
              {
                num1 = 4;
                if (FNIScommon1.FNIScommon.DebugOutput > 1)
                  FNIScommon1.FNIScommon.LogOutput("ASDSF pre-cache - 2nd part iline:" + Conversion.Str((object) iline) + " oline:" + Conversion.Str((object) oline), false, true);
              }
            }
            else if (num1 == 4)
            {
              if (Operators.CompareString(Left, "V3", false) == 0)
                num1 = 5;
            }
            else if (num1 == 6)
            {
              if (Operators.CompareString(Left, "V3", false) == 0)
              {
                num1 = 5;
              }
              else
              {
                num1 = 7;
                if (FNIScommon1.FNIScommon.DebugOutput > 1)
                  FNIScommon1.FNIScommon.LogOutput("ASDSF pre-cache - remaining lines iline:" + Conversion.Str((object) iline) + " oline:" + Conversion.Str((object) oline), false, true);
              }
            }
            if (bEOF)
            {
              FNIScommon1.FNIScommon.LogOutput("ASDSF pre-cache - animationsetdatasinglefile.txt UNEXPECTED STRUCTURE iline:" + Conversion.Str((object) iline) + " oline:" + Conversion.Str((object) oline), true, true);
              throw new ApplicationException("UNEXPECTED STRUCTURE iline:" + Conversion.Str((object) iline) + " oline:" + Conversion.Str((object) oline));
            }
          }
          sr.Close();
          sw.Close();
          FileSystemProxy fileSystem = MyProject.Computer.FileSystem;
          if (fileSystem.FileExists("..\\..\\meshes\\animationsetdatasinglefile.SAVE"))
            fileSystem.DeleteFile("..\\..\\meshes\\animationsetdatasinglefile.SAVE");
          if (fileSystem.FileExists("..\\..\\meshes\\animationsetdatasinglefile.txt"))
            fileSystem.DeleteFile("..\\..\\meshes\\animationsetdatasinglefile.txt");
          fileSystem.RenameFile("..\\..\\meshes\\animationsetdatasinglefile2.txt", "animationsetdatasinglefile.txt");
        }
      }
      if (FNIScommon1.FNIScommon.DebugOutput <= 2)
        return;
      FNIScommon1.FNIScommon.LogOutput("ASDSF pre-cache - DONE iline:" + Conversion.Str((object) iline) + " oline:" + Conversion.Str((object) oline), false, true);
    }

    public string ASDSF_IO(StreamReader sr, StreamWriter sw, ref int iline, ref int oline, ref bool bEOF, bool WriteBack = true)
    {
      if (sr.EndOfStream)
        bEOF = true;
      string str = sr.ReadLine();
      iline = checked (iline + 1);
      if (WriteBack)
      {
        sw.WriteLine(str);
        oline = checked (oline + 1);
      }
      return str;
    }

    public void Read_CustomPreCheckFile()
    {
      GenerateFNISUsers.CustomPreCache customPreCache = new GenerateFNISUsers.CustomPreCache();
      GenerateFNISUsers.iCustomPreCacheSet = 0;
      GenerateFNISUsers.CPCFile = FNIScommon1.FNIScommon.ReadAFile("CustomPreCacheFiles.txt");
      int index1 = 0;
      int num1 = Information.UBound((Array) GenerateFNISUsers.CPCFile, 1);
      int index2 = 0;
      while (index2 <= num1)
      {
        if (Operators.CompareString(Strings.Left(GenerateFNISUsers.CPCFile[index2], 1), "'", false) != 0)
        {
          string Left = Strings.Replace(Strings.Replace(GenerateFNISUsers.CPCFile[index2], " ", "", 1, -1, CompareMethod.Binary), "\t", "", 1, -1, CompareMethod.Binary);
          if (Operators.CompareString(Left, "", false) != 0)
          {
            GenerateFNISUsers.CPCFile[index1] = Left;
            checked { ++index1; }
          }
        }
        checked { ++index2; }
      }
      try
      {
        int index3 = 0;
        while (index3 < index1)
        {
          string Right = Strings.LCase(GenerateFNISUsers.CPCFile[index3]);
          bool flag = false;
          int num2 = checked (FNIScommon1.FNIScommon.AnzMod - 1);
          int index4 = 0;
          while (index4 <= num2)
          {
            if (Operators.CompareString(Strings.LCase(FNIScommon1.FNIScommon.MyMod[index4]), Right, false) == 0)
            {
              flag = true;
              index4 = FNIScommon1.FNIScommon.AnzMod;
            }
            checked { ++index4; }
          }
          if (FNIScommon1.FNIScommon.DebugOutput > 1)
            FNIScommon1.FNIScommon.LogOutput("ASDSF ReadCustomPreCheckFile. Mod " + Right + " installed:" + Conversion.Str((object) flag), false, true);
          if (flag)
          {
            customPreCache.refcount = 0;
            customPreCache.refpath_crc = Conversions.ToUInteger(GenerateFNISUsers.CPCFile[checked (index3 + 1)]);
            string str = GenerateFNISUsers.CPCFile[checked (index3 + 2)];
            int num3 = Strings.InStr(GenerateFNISUsers.CPCFile[checked (index3 + 2)], "/", CompareMethod.Binary);
            if (num3 > 0)
            {
              customPreCache.reffile_crc = Conversions.ToUInteger(Strings.Left(str, checked (num3 - 1)));
              string[] strArray = Strings.Split(Strings.Mid(str, checked (num3 + 1)), ",", -1, CompareMethod.Binary);
              customPreCache.refnumber1 = Conversions.ToInteger(strArray[0]);
              customPreCache.refnumber2 = Conversions.ToInteger(strArray[1]);
            }
            else
            {
              customPreCache.reffile_crc = Conversions.ToUInteger(str);
              customPreCache.refnumber1 = 0;
            }
            customPreCache.custompath_crc = Conversions.ToUInteger(GenerateFNISUsers.CPCFile[checked (index3 + 3)]);
            customPreCache.nCustomAnims = Conversions.ToInteger(GenerateFNISUsers.CPCFile[checked (index3 + 4)]);
            if (customPreCache.nCustomAnims > 500)
              throw new ApplicationException("Too many animations in CustomPreCacheFiles.txt");
            customPreCache.indexCustomAnims = checked (index3 + 5);
            GenerateFNISUsers.CustomPreCacheSet[GenerateFNISUsers.iCustomPreCacheSet] = customPreCache;
            checked { ++GenerateFNISUsers.iCustomPreCacheSet; }
            FNIScommon1.FNIScommon.LogOutput("ASDSF ReadCustomPreCheckFile. Found entry for " + Conversion.Str((object) customPreCache.refpath_crc) + " " + Conversion.Str((object) customPreCache.reffile_crc) + " " + Conversion.Str((object) customPreCache.refnumber1) + "/" + Conversion.Str((object) customPreCache.refnumber2), false, true);
          }
          checked { index3 += 5 + Conversions.ToInteger(GenerateFNISUsers.CPCFile[index3 + 4]); }
        }
      }
      catch (Exception ex)
      {
        ProjectData.SetProjectError(ex);
        FNIScommon1.FNIScommon.LogOutput("\r\n>>Warning: wrong file structure for CustomPreCacheFiles.txt - " + ex.Message + "<<\r\n", true, true);
        checked { ++FNIScommon1.FNIScommon.WarningCount; }
        ProjectData.ClearProjectError();
      }
    }

    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
    public void Execute_BehavioredObjects()
    {
      List<string> stringList1 = new List<string>();
      FNIScommon1.FNIScommon.No_BO = 0;
      if (!MyProject.Computer.FileSystem.FileExists("..\\GenerateFNIS_for_Users\\BehavioredObjects.txt".ToUpperInvariant()))
      {
        FNIScommon1.FNIScommon.LogOutput("\r\n" + FNIScommon1.FNIScommon.tMsgu[5], true, true);
      }
      else
      {
        FNIScommon1.FNIScommon.LogOutput("\r\n" + FNIScommon1.FNIScommon.tMsgu[28], true, true);
        List<string>.Enumerator enumerator1;
        try
        {
          enumerator1 = FNIScommon1.FNIScommon.Combined_BOlist().GetEnumerator();
          while (enumerator1.MoveNext())
          {
            string current1 = enumerator1.Current;
            FileSystemProxy fileSystem = MyProject.Computer.FileSystem;
            if (Operators.CompareString(Strings.Left(current1, 1), "'", false) != 0)
            {
              string[] strArray1 = Strings.Split(current1, ";", -1, CompareMethod.Binary);
              if (Information.UBound((Array) strArray1, 1) >= 9)
              {
                FNIScommon1.FNIScommon.Initialize_Globals();
                FNIScommon1.FNIScommon.MyBO = Conversions.ToInteger(strArray1[8]);
                FNIScommon1.FNIScommon.BO_List[FNIScommon1.FNIScommon.MyBO] = strArray1[0];
                FNIScommon1.FNIScommon.BO_DefaultAnims[FNIScommon1.FNIScommon.MyBO] = Conversions.ToInteger(strArray1[9]);
                string str1 = "..\\..\\meshes\\" + strArray1[1] + "\\";
                string Expression1 = strArray1[2];
                string Expression2 = strArray1[3];
                Strings.Replace(Strings.Replace(strArray1[4], " ", "", 1, -1, CompareMethod.Binary), "\t", "", 1, -1, CompareMethod.Binary);
                bool flag1 = (uint) Operators.CompareString(strArray1[5], "", false) > 0U;
                if (flag1)
                  flag1 = !(fileSystem.FileExists("..\\..\\Dragonborn.bsa") | fileSystem.FileExists("..\\..\\Dawnguard.bsa"));
                bool SKip_CC = (uint) Operators.CompareString(strArray1[7], "", false) > 0U;
                string[] strArray2 = Strings.Split(Expression2, "\\", -1, CompareMethod.Binary);
                FNIScommon1.FNIScommon.MyBOFolder = strArray2[0];
                string str2 = strArray2[1];
                string str3 = Strings.Left(str2, checked (Strings.Len(str2) - 4));
                string str4 = str3 + ".xml";
                string str5;
                if (flag1)
                {
                  str5 = str3 + "_noDLC_TEMPLATE.txt";
                  FNIScommon1.FNIScommon.LogOutput(FNIScommon1.FNIScommon.BO_List[FNIScommon1.FNIScommon.MyBO] + " behavior for non-DLC user", false, true);
                }
                else
                  str5 = str3 + "_TEMPLATE.txt";
                string mpath = str1 + FNIScommon1.FNIScommon.MyBOFolder + "\\";
                string Delimiter = "\\";
                int Limit = -1;
                int num1 = 0;
                string[] strArray3 = Strings.Split(Expression1, Delimiter, Limit, (CompareMethod) num1);
                string str6 = str1 + strArray3[0] + "\\";
                string str7 = strArray3[Information.UBound((Array) strArray3, 1)];
                string str8 = Strings.Left(str7, checked (Strings.Len(str7) - 4));
                string str9 = str8 + "_default_TEMPLATE.txt";
                string str10 = str8 + ".xml";
                string upperInvariant = (mpath + Strings.Left(str2, checked (Strings.Len(str2) - 4)) + "_FNIS.hkx").ToUpperInvariant();
                if (fileSystem.FileExists(upperInvariant))
                  fileSystem.DeleteFile(upperInvariant);
                if (!(!fileSystem.DirectoryExists(str1.ToUpperInvariant()) | !fileSystem.FileExists((str6 + str9).ToUpperInvariant()) | !fileSystem.FileExists((mpath + str5).ToUpperInvariant())))
                {
                  List<string> stringList2 = FNIScommon1.FNIScommon.Read_Directory(str1 + "animations", "");
                  List<string>.Enumerator enumerator2;
                  try
                  {
                    enumerator2 = stringList2.GetEnumerator();
                    while (enumerator2.MoveNext())
                    {
                      string current2 = enumerator2.Current;
                      string AnimListFile = str1 + "animations\\" + current2 + "\\FNIS_" + current2 + "_" + FNIScommon1.FNIScommon.BO_List[FNIScommon1.FNIScommon.MyBO] + "_list.txt";
                      string str11 = mpath + "FNIS_" + current2 + "_" + FNIScommon1.FNIScommon.BO_List[FNIScommon1.FNIScommon.MyBO] + "_behavior.hkx";
                      if (fileSystem.FileExists(AnimListFile.ToUpperInvariant()))
                      {
                        if (fileSystem.FileExists(str11.ToUpperInvariant()))
                        {
                          checked { ++FNIScommon1.FNIScommon.AnzMod; }
                          FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnzMod] = current2;
                          bool flag2 = true;
                          List<string>.Enumerator enumerator3;
                          try
                          {
                            enumerator3 = stringList1.GetEnumerator();
                            while (enumerator3.MoveNext())
                            {
                              string current3 = enumerator3.Current;
                              if (Operators.CompareString(Strings.LCase(current2), Strings.LCase(current3), false) == 0)
                                flag2 = false;
                            }
                          }
                          finally
                          {
                            enumerator3.Dispose();
                          }
                          if (flag2)
                          {
                            stringList1.Add(current2);
                            FNIScommon1.FNIScommon.LogOutput(FNIScommon1.FNIScommon.tMsgu[2] + " " + current2, true, false);
                          }
                          FNIScommon1.FNIScommon.ReadAnimationFile(AnimListFile, FNIScommon1.FNIScommon.AnzMod, SKip_CC);
                          if (flag2)
                            FNIScommon1.FNIScommon.LogOutput(" " + FNIScommon1.FNIScommon.MyModVers[FNIScommon1.FNIScommon.AnzMod] + " ...", true, true);
                        }
                        else
                          FNIScommon1.FNIScommon.WriteWarning(Strings.Replace(FNIScommon1.FNIScommon.tWarn[6], "<1>", " \"Animations\\" + current2 + "\"", 1, -1, CompareMethod.Binary) + " (" + FNIScommon1.FNIScommon.BO_List[FNIScommon1.FNIScommon.MyBO] + ")");
                      }
                    }
                  }
                  finally
                  {
                    enumerator2.Dispose();
                  }
                  if (FNIScommon1.FNIScommon.AnzAnim > 0)
                  {
                    checked { ++FNIScommon1.FNIScommon.No_BO; }
                    string[] ModList = (string[]) null;
                    FNIScommon1.FNIScommon.ErrString = "";
                    if (this.mustGenerate0master(mpath, str2, mpath + str5, false, ref ModList))
                    {
                      string TemplateFileName = mpath + str5;
                      string BehaviorFileName = "temporary_logs\\" + str4;
                      int BehaviorType = 2;
                      int num2 = 0;
                      string[] OutArray = (string[]) null;
                      int iOut = 0;
                      FNIScommon1.FNIScommon.GenerateBehavior(TemplateFileName, BehaviorFileName, BehaviorType, num2 != 0, ref OutArray, ref iOut);
                      if (fileSystem.FileExists((mpath + str2).ToUpperInvariant()))
                        fileSystem.DeleteFile(mpath + str2);
                      FNIScommon1.FNIScommon.hkxcmdProcess.StartInfo.Arguments = Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.hkxcmd_Params, "*", "temporary_logs\\" + str4, 1, -1, CompareMethod.Binary), "#", "temporary_logs\\" + str2, 1, -1, CompareMethod.Binary);
                      FNIScommon1.FNIScommon.hkxcmdProcess.Start();
                      FNIScommon1.FNIScommon.hkxcmdProcess.WaitForExit();
                      fileSystem.CopyFile("DebugData.txt", "temporary_logs\\DebugData.txt", true);
                      if (fileSystem.FileExists(("temporary_logs\\" + str2).ToUpperInvariant()))
                        fileSystem.MoveFile("temporary_logs\\" + str2, mpath + str2);
                      else
                        FNIScommon1.FNIScommon.ErrString = str2 + " ";
                    }
                    FNIScommon1.FNIScommon.GenerateBehavior(str6 + str9, "temporary_logs\\" + str10, 3, false, ref FNIScommon1.FNIScommon.ArrDefaultF, ref FNIScommon1.FNIScommon.iArrDefaultF);
                    if (!SKip_CC)
                      this.Read_AnimsInDefault(3, ref FNIScommon1.FNIScommon.ArrDefaultF, FNIScommon1.FNIScommon.iArrDefaultF, str1 + "animations\\", (string) null, (string) null, (string) null);
                    if (fileSystem.FileExists(str6 + str7.ToUpperInvariant()))
                      fileSystem.DeleteFile(str6 + str7.ToUpperInvariant());
                    FNIScommon1.FNIScommon.hkxcmdProcess.StartInfo.Arguments = Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.hkxcmd_Params, "*", "temporary_logs\\" + str10, 1, -1, CompareMethod.Binary), "#", "temporary_logs\\" + str7, 1, -1, CompareMethod.Binary);
                    FNIScommon1.FNIScommon.hkxcmdProcess.Start();
                    FNIScommon1.FNIScommon.hkxcmdProcess.WaitForExit();
                    fileSystem.CopyFile("DebugData.txt", "temporary_logs\\DebugData.txt", true);
                    if (fileSystem.FileExists(("temporary_logs\\" + str7).ToUpperInvariant()))
                      fileSystem.MoveFile("temporary_logs\\" + str7, str6 + str7);
                    else
                      FNIScommon1.FNIScommon.ErrString = FNIScommon1.FNIScommon.ErrString + str7 + " ";
                    if (Operators.CompareString(FNIScommon1.FNIScommon.ErrString, "", false) != 0)
                      Information.Err().Raise(2012, (object) null, (object) null, (object) null, (object) null);
                    this.FNISModlist2L.Add(Strings.Format((object) fileSystem.GetFileInfo(mpath + str2).Length, ""));
                    FNIScommon1.FNIScommon.LogOutput(Strings.Replace(Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[11], "<1>", Conversion.Str((object) FNIScommon1.FNIScommon.AnzAnim), 1, -1, CompareMethod.Binary), "<2>", Conversion.Str((object) FNIScommon1.FNIScommon.AnzMod), 1, -1, CompareMethod.Binary), "<3>", FNIScommon1.FNIScommon.BO_List[FNIScommon1.FNIScommon.MyBO], 1, -1, CompareMethod.Binary), false, true);
                    if (FNIScommon1.FNIScommon.WarningCount > 0)
                      FNIScommon1.FNIScommon.LogOutput(Conversion.Str((object) FNIScommon1.FNIScommon.WarningCount) + " " + FNIScommon1.FNIScommon.tWarn[8] + ".", false, true);
                  }
                  checked { FNIScommon1.FNIScommon.TotalAnimations += FNIScommon1.FNIScommon.AnzAnim; }
                  checked { FNIScommon1.FNIScommon.TotalWarnings += FNIScommon1.FNIScommon.WarningCount; }
                }
              }
            }
          }
        }
        finally
        {
          enumerator1.Dispose();
        }
        FNIScommon1.FNIScommon.No_BOmods = stringList1.Count;
      }
    }

    public void DeInstall_BOs()
    {
      FileSystemProxy fileSystem = MyProject.Computer.FileSystem;
      List<string>.Enumerator enumerator;
      try
      {
        enumerator = FNIScommon1.FNIScommon.Combined_BOlist().GetEnumerator();
        while (enumerator.MoveNext())
        {
          string current = enumerator.Current;
          string Delimiter = ";";
          int Limit = -1;
          int num1 = 0;
          string[] strArray = Strings.Split(current, Delimiter, Limit, (CompareMethod) num1);
          int Length = 1;
          if ((uint) Operators.CompareString(Strings.Left(current, Length), "'", false) > 0U & Information.UBound((Array) strArray, 1) >= 3)
          {
            string str1 = strArray[0];
            string directory = "..\\..\\meshes\\" + strArray[1];
            if (fileSystem.DirectoryExists(directory))
            {
              string str2 = directory + "\\" + strArray[2];
              string str3 = directory + "\\" + strArray[3];
              short num2 = checked ((short) (Strings.InStrRev(Strings.LCase(directory), "\\", -1, CompareMethod.Binary) + 1));
              if (fileSystem.FileExists(str3))
              {
                fileSystem.DeleteFile(str3);
                FNIScommon1.FNIScommon.LogOutput(Strings.Mid(str3, (int) num2) + " " + FNIScommon1.FNIScommon.tMsgu[31], true, true);
              }
              if (fileSystem.FileExists(str2))
              {
                fileSystem.DeleteFile(str2);
                FNIScommon1.FNIScommon.LogOutput(Strings.Mid(str2, (int) num2) + " " + FNIScommon1.FNIScommon.tMsgu[31], true, true);
              }
            }
          }
        }
      }
      finally
      {
        enumerator.Dispose();
      }
    }

    public bool mustGenerate0master(string mpath, string mfile, string tfile, bool force, ref string[] ModList)
    {
      List<string> stringList = new List<string>();
      bool flag = true;
      FileSystemProxy fileSystem = MyProject.Computer.FileSystem;
      int length1 = checked ((int) fileSystem.GetFileInfo(tfile).Length);
      int anzMod = FNIScommon1.FNIScommon.AnzMod;
      int index1 = 1;
      while (index1 <= anzMod)
      {
        stringList.Add(FNIScommon1.FNIScommon.MyMod[index1]);
        checked { ++index1; }
      }
      stringList.Sort();
      this.FNISModlist2L.Add(":" + FNIScommon1.FNIScommon.BO_List[FNIScommon1.FNIScommon.MyBO]);
      this.FNISModlist2L.AddRange((IEnumerable<string>) stringList);
      this.FNISModlist2L.Add(Strings.Format((object) length1, ""));
      ModList = stringList.ToArray();
      if (!Information.IsNothing((object) this.FNISModList1) & fileSystem.FileExists(mpath + mfile) & !force)
      {
        int num1 = -1;
        int num2 = checked (Information.UBound((Array) this.FNISModList1, 1) - 2);
        int index2 = 0;
        while (index2 <= num2)
        {
          if (Operators.CompareString(this.FNISModList1[index2], ":" + FNIScommon1.FNIScommon.BO_List[FNIScommon1.FNIScommon.MyBO], false) == 0)
          {
            num1 = index2;
            index2 = Information.UBound((Array) this.FNISModList1, 1);
          }
          checked { ++index2; }
        }
        int num3;
        if (num1 > -1)
        {
          num3 = -1;
          int num4 = checked (num1 + 1);
          int num5 = Information.UBound((Array) this.FNISModList1, 1);
          int index3 = num4;
          while (index3 <= num5)
          {
            if (Operators.CompareString(Strings.Left(this.FNISModList1[index3], 1), ":", false) == 0)
            {
              num3 = checked (index3 - num1 - 3);
              index3 = Information.UBound((Array) this.FNISModList1, 1);
            }
            checked { ++index3; }
          }
          if (num3 < 0)
            num3 = checked (Information.UBound((Array) this.FNISModList1, 1) - num1 - 2);
        }
        int length2 = checked ((int) fileSystem.GetFileInfo(mpath + mfile).Length);
        if (Information.UBound((Array) this.FNISModList1, 1) == -1 | num1 == -1)
        {
          flag = true;
        }
        else
        {
          string str1 = this.FNISModList1[checked (num1 + num3 + 1)];
          string str2 = this.FNISModList1[checked (num1 + num3 + 2)];
          if (num3 == FNIScommon1.FNIScommon.AnzMod & Versioned.IsNumeric((object) str1) & Versioned.IsNumeric((object) str2) && Conversions.ToInteger(str1) == length1 & Conversions.ToInteger(str2) > 0)
          {
            flag = false;
            int num4 = checked (FNIScommon1.FNIScommon.AnzMod - 1);
            int index3 = 0;
            while (index3 <= num4)
            {
              if (Operators.CompareString(this.FNISModList1[checked (num1 + 1 + index3)], ModList[index3], false) != 0)
                flag = true;
              checked { ++index3; }
            }
          }
        }
      }
      if (flag)
        FNIScommon1.FNIScommon.LogOutput("Generate " + mfile, false, true);
      else
        FNIScommon1.FNIScommon.LogOutput(mfile + " ok", false, true);
      return flag;
    }

    public void Read_AnimsInDefault(int action, ref string[] DefaultArray, int NoElem, string PathToAnims, string PathToAnimsShort, string Outfile, string suffix)
    {
      List<string> stringList = new List<string>();
      bool[] flagArray = new bool[2001];
      string str1 = "";
      int num1;
      if (action >= 4 & action <= 7)
      {
        num1 = 0;
        int num2 = checked ((int) Math.Round(Math.Pow(2.0, unchecked ((double) checked (action - 4)))));
        IEnumerator<string> enumerator;
        try
        {
          enumerator = MyProject.Computer.FileSystem.GetFiles(PathToAnims, Microsoft.VisualBasic.FileIO.SearchOption.SearchTopLevelOnly, "*.hkx").GetEnumerator();
          while (enumerator.MoveNext())
          {
            string[] strArray = Strings.Split(enumerator.Current, "\\", -1, CompareMethod.Binary);
            int Rank = 1;
            int index1 = Information.UBound((Array) strArray, Rank);
            string str2 = strArray[index1];
            stringList.Add(str2);
            uint num3 = FNIScommon1.FNIScommon.CRC32_Calc(Strings.LCase(Strings.Left(str2, checked (Strings.Len(str2) - 4))));
            int index2 = 0;
            bool flag = false;
            while (!flag & index2 < GenerateFNISUsers.iPCEAgenderFile)
            {
              if ((int) GenerateFNISUsers.PCEAgenderFile[index2].crc == (int) num3)
              {
                if (FNIScommon1.FNIScommon.DebugOutput > 1)
                  FNIScommon1.FNIScommon.LogOutput(Conversion.Str((object) action) + " Multi PCEA/Gender filename: " + GenerateFNISUsers.PCEAgenderFile[index2].name, false, true);
                flag = true;
              }
              if (!flag)
                checked { ++index2; }
            }
            if (!flag & GenerateFNISUsers.iPCEAgenderFile < Information.UBound((Array) GenerateFNISUsers.PCEAgenderFile, 1))
            {
              GenerateFNISUsers.PCEAgenderFile[GenerateFNISUsers.iPCEAgenderFile].crc = num3;
              GenerateFNISUsers.PCEAgenderFile[GenerateFNISUsers.iPCEAgenderFile].name = str2;
              GenerateFNISUsers.PCEAgenderFile[GenerateFNISUsers.iPCEAgenderFile].isGender_F = false;
              GenerateFNISUsers.PCEAgenderFile[GenerateFNISUsers.iPCEAgenderFile].isGender_M = false;
              GenerateFNISUsers.PCEAgenderFile[GenerateFNISUsers.iPCEAgenderFile].isPCEA_F = false;
              GenerateFNISUsers.PCEAgenderFile[GenerateFNISUsers.iPCEAgenderFile].isPCEA_M = false;
              if (FNIScommon1.FNIScommon.DebugOutput > 1)
                FNIScommon1.FNIScommon.LogOutput(Conversion.Str((object) action) + "   New PCEA/Gender filename: " + GenerateFNISUsers.PCEAgenderFile[GenerateFNISUsers.iPCEAgenderFile].name, false, true);
              index2 = GenerateFNISUsers.iPCEAgenderFile;
              flag = true;
              checked { ++GenerateFNISUsers.iPCEAgenderFile; }
            }
            if (flag)
            {
              if (action == 4)
                GenerateFNISUsers.PCEAgenderFile[index2].isGender_F = true;
              else if (action == 5)
                GenerateFNISUsers.PCEAgenderFile[index2].isGender_M = true;
              else if (action == 6)
                GenerateFNISUsers.PCEAgenderFile[index2].isPCEA_F = true;
              else if (action == 7)
                GenerateFNISUsers.PCEAgenderFile[index2].isPCEA_M = true;
            }
          }
        }
        finally
        {
          if (enumerator != null)
            enumerator.Dispose();
        }
        if (action == 4 | action == 5)
          str1 = "GENDER";
        else if (action == 6 | action == 7)
          str1 = "PCEA";
      }
      int index3 = 0;
      while ((Strings.InStr(DefaultArray[index3], "<hkcstring>", CompareMethod.Binary) == 0 | Strings.InStr(DefaultArray[index3], "<!--", CompareMethod.Binary) == 1) & index3 < NoElem)
        checked { ++index3; }
      int num4 = 0;
      while (Strings.InStr(DefaultArray[index3], "<!-- Start FNIS", CompareMethod.Binary) == 0 & Strings.InStr(DefaultArray[index3], "</hkparam>", CompareMethod.Binary) <= 0 & index3 < NoElem)
      {
        string str2 = DefaultArray[index3];
        int num2 = Strings.InStr(str2, "<!--", CompareMethod.Binary);
        int num3 = Strings.InStr(str2, "<hkcstring>", CompareMethod.Binary);
        int Start = Strings.InStr(str2, "</hkcstring>", CompareMethod.Binary);
        if (num3 > 1 & Start > num3 & (num2 == 0 | num2 > Start))
        {
          string[] strArray = Strings.Split(Strings.Mid(str2, checked (num3 + 11), checked (Start - num3 - 11)), "\\", -1, CompareMethod.Binary);
          int Rank = 1;
          int index1 = Information.UBound((Array) strArray, Rank);
          string str3 = strArray[index1];
          if (action == 1 | action == 3)
          {
            FNIScommon1.FNIScommon.AnimFilecc animFilecc = new FNIScommon1.FNIScommon.AnimFilecc()
            {
              actor = FNIScommon1.FNIScommon.MyBO,
              modname = "Skyrim",
              animfile = str3,
              animfile_crc = FNIScommon1.FNIScommon.CRC32_Calc(Strings.LCase(str3)),
              animfile_ID = num4,
              animpath = "",
              isbsa = true,
              comp = FNIScommon1.FNIScommon.BO_List[FNIScommon1.FNIScommon.MyBO] + str3
            };
            FNIScommon1.FNIScommon.AnimFileList.Add(animFilecc);
            checked { ++num4; }
          }
          else if (action >= 4 & action <= 7)
          {
            int index2 = 0;
            List<string>.Enumerator enumerator;
            try
            {
              enumerator = stringList.GetEnumerator();
              while (enumerator.MoveNext())
              {
                string current = enumerator.Current;
                if (Operators.CompareString(str3.ToUpperInvariant(), current.ToUpperInvariant(), false) == 0)
                {
                  DefaultArray[index3] = Strings.Left(str2, checked (num3 + 10)) + "animations\\" + PathToAnimsShort + "\\" + str3 + Strings.Mid(str2, Start);
                  if (FNIScommon1.FNIScommon.DebugOutput > 1)
                    FNIScommon1.FNIScommon.LogOutput(str1 + " file: Animations\\" + PathToAnimsShort + "\\" + str3, false, true);
                  checked { ++num1; }
                  flagArray[index2] = true;
                }
                checked { ++index2; }
              }
            }
            finally
            {
              enumerator.Dispose();
            }
          }
        }
        checked { ++index3; }
      }
      FNIScommon1.FNIScommon.AnimFilecc animFilecc1;
      if (action == 1)
      {
        int num2 = checked (FNIScommon1.FNIScommon.iPatchAF - 1);
        int index1 = 0;
        while (index1 <= num2)
        {
          if (FNIScommon1.FNIScommon.PatchAF[index1].inDefault)
          {
            animFilecc1 = new FNIScommon1.FNIScommon.AnimFilecc();
            animFilecc1.actor = 0;
            animFilecc1.modname = FNIScommon1.FNIScommon.PatchAF[index1].path;
            animFilecc1.animfile = FNIScommon1.FNIScommon.PatchAF[index1].name;
            animFilecc1.animfile_crc = FNIScommon1.FNIScommon.CRC32_Calc(Strings.LCase(animFilecc1.animfile));
            animFilecc1.animfile_ID = num4;
            animFilecc1.animpath = PathToAnims;
            animFilecc1.isbsa = true;
            animFilecc1.comp = FNIScommon1.FNIScommon.BO_List[0] + animFilecc1.animfile;
            FNIScommon1.FNIScommon.AnimFilecc animFilecc2 = animFilecc1;
            FNIScommon1.FNIScommon.AnimFileList.Add(animFilecc2);
            FNIScommon1.FNIScommon.PatchAF[index1].AnimationID = num4;
            checked { ++num4; }
          }
          checked { ++index1; }
        }
      }
      if (action == 1 | action == 3)
      {
        int num2 = checked (FNIScommon1.FNIScommon.AnzAnim - 1);
        int index1 = 0;
        while (index1 <= num2)
        {
          if ((uint) Operators.CompareString(FNIScommon1.FNIScommon.AnimFile[index1], "", false) > 0U & !FNIScommon1.FNIScommon.AnimKoption[index1])
          {
            animFilecc1 = new FNIScommon1.FNIScommon.AnimFilecc();
            animFilecc1.actor = FNIScommon1.FNIScommon.MyBO;
            animFilecc1.modname = FNIScommon1.FNIScommon.MyMod[FNIScommon1.FNIScommon.AnimMod[index1]];
            animFilecc1.animfile = FNIScommon1.FNIScommon.AnimFile[index1];
            animFilecc1.animfile_crc = FNIScommon1.FNIScommon.CRC32_Calc(Strings.LCase(FNIScommon1.FNIScommon.AnimFile[index1]));
            animFilecc1.animfile_ID = num4;
            animFilecc1.animpath = PathToAnims;
            animFilecc1.isbsa = FNIScommon1.FNIScommon.Has_Option(FNIScommon1.FNIScommon.AnimOption[index1], "bsa");
            animFilecc1.comp = FNIScommon1.FNIScommon.BO_List[animFilecc1.actor] + animFilecc1.animfile;
            FNIScommon1.FNIScommon.AnimFilecc animFilecc2 = animFilecc1;
            FNIScommon1.FNIScommon.AnimFileList.Add(animFilecc2);
            checked { ++num4; }
          }
          checked { ++index1; }
        }
      }
      if (action == 1)
      {
        int num2 = checked (FNIScommon1.FNIScommon.iPatchAF - 1);
        int index1 = 0;
        while (index1 <= num2)
        {
          if (!FNIScommon1.FNIScommon.PatchAF[FNIScommon1.FNIScommon.iPatchAF].inDefault)
          {
            uint num3 = FNIScommon1.FNIScommon.CRC32_Calc(Strings.LCase(FNIScommon1.FNIScommon.PatchAF[index1].name));
            List<FNIScommon1.FNIScommon.AnimFilecc>.Enumerator enumerator;
            try
            {
              enumerator = FNIScommon1.FNIScommon.AnimFileList.GetEnumerator();
              while (enumerator.MoveNext())
              {
                FNIScommon1.FNIScommon.AnimFilecc current = enumerator.Current;
                if ((int) num3 == (int) current.animfile_crc && Operators.CompareString(Strings.LCase(FNIScommon1.FNIScommon.PatchAF[index1].path), Strings.LCase(current.modname), false) == 0)
                {
                  FNIScommon1.FNIScommon.PatchAF[index1].AnimationID = current.animfile_ID;
                  break;
                }
              }
            }
            finally
            {
              enumerator.Dispose();
            }
            if (FNIScommon1.FNIScommon.PatchAF[index1].AnimationID <= 0)
            {
              FNIScommon1.FNIScommon.WriteWarning("Patched animation file not found: " + FNIScommon1.FNIScommon.PatchAF[index1].path + "\\" + FNIScommon1.FNIScommon.PatchAF[index1].name);
              // ISSUE: variable of a reference type
              int& local1;
              // ISSUE: explicit reference operation
              // ISSUE: explicit reference operation
              int num5 = checked (^(local1 = @FNIScommon1.FNIScommon.nPatchAF[2]) - 1);
              // ISSUE: explicit reference operation
              ^local1 = num5;
              FNIScommon1.FNIScommon.PatchAF[index1].inADSF = false;
              if (FNIScommon1.FNIScommon.PatchAF[index1].inASDSF)
              {
                // ISSUE: variable of a reference type
                int& local2;
                // ISSUE: explicit reference operation
                // ISSUE: explicit reference operation
                int num6 = checked (^(local2 = @FNIScommon1.FNIScommon.nPatchAF[3]) - 1);
                // ISSUE: explicit reference operation
                ^local2 = num6;
                FNIScommon1.FNIScommon.PatchAF[index1].inASDSF = false;
              }
            }
          }
          checked { ++index1; }
        }
      }
      List<FNIScommon1.FNIScommon.AnimFilecc>.Enumerator enumerator1;
      try
      {
        enumerator1 = FNIScommon1.FNIScommon.AnimFileList.GetEnumerator();
        while (enumerator1.MoveNext())
        {
          FNIScommon1.FNIScommon.AnimFilecc current = enumerator1.Current;
          if (FNIScommon1.FNIScommon.DebugOutput > 1)
            FNIScommon1.FNIScommon.LogOutput("YYY AnimList actor animfile_ID modname animfile:" + current.actor.ToString() + " " + current.animfile_ID.ToString() + " " + current.modname + " " + current.animfile + " ", false, true);
        }
      }
      finally
      {
        enumerator1.Dispose();
      }
      if (action == 1 | action == 3)
      {
        if (FNIScommon1.FNIScommon.MRD_DataListONE.Count <= 0)
          return;
        string[] strArray = new string[10001];
        List<FNIScommon1.FNIScommon.MRD_Data>.Enumerator enumerator2;
        try
        {
          enumerator2 = FNIScommon1.FNIScommon.MRD_DataListONE.GetEnumerator();
          while (enumerator2.MoveNext())
          {
            FNIScommon1.FNIScommon.MRD_Data current1 = enumerator2.Current;
            bool flag;
            int animfileId;
            if (current1.firstOfBlock)
            {
              flag = true;
              uint num2 = current1.anim_crc32;
              List<FNIScommon1.FNIScommon.AnimFilecc>.Enumerator enumerator3;
              try
              {
                enumerator3 = FNIScommon1.FNIScommon.AnimFileList.GetEnumerator();
                while (enumerator3.MoveNext())
                {
                  FNIScommon1.FNIScommon.AnimFilecc current2 = enumerator3.Current;
                  uint animfileCrc = current2.animfile_crc;
                  if (FNIScommon1.FNIScommon.MyBO == current2.actor & (int) num2 == (int) animfileCrc)
                  {
                    animfileId = current2.animfile_ID;
                    if (current2.animfile_ID < FNIScommon1.FNIScommon.BO_DefaultAnims[FNIScommon1.FNIScommon.MyBO] | (uint) Operators.CompareString(strArray[animfileId], "", false) > 0U)
                    {
                      FNIScommon1.FNIScommon.LogOutput("WARNING: Motion Data (MD/RD) multiply defined for " + current2.animfile + ". Mods " + current2.modname + " and " + FNIScommon1.FNIScommon.MyMod[current1.modId], true, true);
                      flag = false;
                    }
                    strArray[animfileId] = current2.modname;
                    num2 = num2;
                  }
                }
              }
              finally
              {
                enumerator3.Dispose();
              }
              if (flag)
              {
                // ISSUE: variable of a reference type
                int& local;
                // ISSUE: explicit reference operation
                // ISSUE: explicit reference operation
                int num3 = checked (^(local = @FNIScommon1.FNIScommon.MRD_BO_nAnims[FNIScommon1.FNIScommon.MyBO]) + 1);
                // ISSUE: explicit reference operation
                ^local = num3;
              }
            }
            if (flag)
            {
              current1.currAnim = animfileId;
              FNIScommon1.FNIScommon.MRD_DataListALL.Add(current1);
              // ISSUE: variable of a reference type
              int& local;
              // ISSUE: explicit reference operation
              // ISSUE: explicit reference operation
              int num2 = checked (^(local = @FNIScommon1.FNIScommon.MRD_BO_nMRD[FNIScommon1.FNIScommon.MyBO]) + 1);
              // ISSUE: explicit reference operation
              ^local = num2;
            }
          }
        }
        finally
        {
          enumerator2.Dispose();
        }
        FNIScommon1.FNIScommon.MRD_DataListONE.Clear();
      }
      else if (action == 4 | action == 5)
      {
        FNIScommon1.FNIScommon.LogOutput(Conversion.Str((object) num1) + " " + FNIScommon1.FNIScommon.tMsgu[16] + " Animations\\" + PathToAnimsShort, true, true);
        FNIScommon1.FNIScommon.WriteAFile(Outfile, ref DefaultArray, NoElem);
      }
      else
      {
        if (!(action == 6 | action == 7))
          return;
        FNIScommon1.FNIScommon.LogOutput(Conversion.Str((object) num1) + " " + FNIScommon1.FNIScommon.tMsgu[16] + "Animations\\ " + PathToAnimsShort, true, true);
        int num2 = 0;
        int index1 = 0;
        List<string>.Enumerator enumerator2;
        try
        {
          enumerator2 = stringList.GetEnumerator();
          while (enumerator2.MoveNext())
          {
            string current = enumerator2.Current;
            if (!flagArray[index1])
            {
              FNIScommon1.FNIScommon.LogOutput(FNIScommon1.FNIScommon.tMsgu[14] + ": Animations\\" + PathToAnimsShort + "\\" + current, false, true);
              checked { ++num2; }
            }
            checked { ++index1; }
          }
        }
        finally
        {
          enumerator2.Dispose();
        }
        if (num2 > 0)
          FNIScommon1.FNIScommon.WriteWarning(Conversion.Str((object) num2) + " " + Strings.Replace(FNIScommon1.FNIScommon.tWarn[9], "<1>", PathToAnimsShort, 1, -1, CompareMethod.Binary));
        FNIScommon1.FNIScommon.WriteAFile(Outfile, ref DefaultArray, NoElem);
      }
    }

    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
    public void Read_PatchAFNames()
    {
      int num1;
      int num2;
      try
      {
        string str1 = "PatchAnimationFiles.txt";
        string str2 = "";
        string Right = "";
        if (!MyProject.Computer.FileSystem.FileExists(str1))
        {
          FNIScommon1.FNIScommon.ErrString = str1;
          Information.Err().Raise(2001, (object) null, (object) null, (object) null, (object) null);
        }
        string[] strArray1 = FNIScommon1.FNIScommon.ReadAFile(str1);
        ProjectData.ClearProjectError();
        num1 = 2;
        string[] strArray2 = strArray1;
        int index1 = 0;
        int num3;
        while (index1 < strArray2.Length)
        {
          string str3 = strArray2[index1];
          checked { ++num3; }
          int num4 = Strings.InStr(str3, "'", CompareMethod.Binary);
          if (num4 > 0)
            str3 = Strings.Left(str3, checked (num4 - 1));
          string str4 = str3.Replace("\t", " ").Replace("  ", " ");
          if (!(Operators.CompareString(str4, "", false) == 0 | Operators.CompareString(str4, " ", false) == 0))
          {
            string[] strArray3 = Strings.Split(str4, " ", -1, CompareMethod.Binary);
            if (Information.UBound((Array) strArray3, 1) < 3)
              Information.Err().Raise(1, (object) null, (object) null, (object) null, (object) null);
            bool flag1;
            bool flag2;
            if (Operators.CompareString(strArray3[0], str2, false) == 0)
            {
              flag2 = flag1;
            }
            else
            {
              str2 = strArray3[0];
              if (Operators.CompareString(str2, "*", false) == 0)
                flag2 = true;
              else if (Operators.CompareString(str2, "*FNIS_AA", false) == 0)
                flag2 = (long) FNIScommon1.FNIScommon.isAAbehavior > 0L;
              else if (Operators.CompareString(Strings.Left(str2, 1), "*", false) == 0)
              {
                int num5 = checked (FNIScommon1.FNIScommon.PatchCount - 1);
                int index2 = 0;
                while (index2 <= num5)
                {
                  if (Operators.CompareString(FNIScommon1.FNIScommon.PatchID[index2], Strings.Mid(str2, 2), false) == 0)
                  {
                    flag2 = FNIScommon1.FNIScommon.isPatch[index2];
                    index2 = FNIScommon1.FNIScommon.PatchCount;
                  }
                  checked { ++index2; }
                }
              }
              else
                flag2 = MyProject.Computer.FileSystem.DirectoryExists("..\\..\\meshes\\actors\\character\\animations\\" + str2);
              flag1 = flag2;
            }
            if (flag2)
            {
              string[] strArray4 = Strings.Split(strArray3[1], "/", -1, CompareMethod.Binary);
              int num5 = Information.UBound((Array) strArray4, 1);
              int index2 = 0;
              while (index2 <= num5)
              {
                if (Operators.CompareString(strArray4[index2], "1", false) == 0)
                  FNIScommon1.FNIScommon.PatchAF[FNIScommon1.FNIScommon.iPatchAF].inDefault = true;
                else if (Operators.CompareString(strArray4[index2], "2", false) == 0)
                  FNIScommon1.FNIScommon.PatchAF[FNIScommon1.FNIScommon.iPatchAF].inADSF = true;
                else if (Operators.CompareString(strArray4[index2], "3", false) == 0)
                  FNIScommon1.FNIScommon.PatchAF[FNIScommon1.FNIScommon.iPatchAF].inASDSF = true;
                else
                  Information.Err().Raise(1, (object) null, (object) null, (object) null, (object) null);
                checked { ++index2; }
              }
              if (Strings.InStr(strArray3[2], "..", CompareMethod.Binary) > 0)
                Information.Err().Raise(1, (object) null, (object) null, (object) null, (object) null);
              if (Operators.CompareString(strArray3[2], Right, false) != 0)
              {
                if (MyProject.Computer.FileSystem.DirectoryExists("..\\..\\meshes\\actors\\character\\animations\\" + strArray3[2]))
                  Right = strArray3[2];
                else
                  goto label_44;
              }
              FNIScommon1.FNIScommon.PatchAF[FNIScommon1.FNIScommon.iPatchAF].path = Right;
              if (MyProject.Computer.FileSystem.FileExists("..\\..\\meshes\\actors\\character\\animations\\" + Right + "\\" + strArray3[3]))
              {
                FNIScommon1.FNIScommon.PatchAF[FNIScommon1.FNIScommon.iPatchAF].name = strArray3[3];
                if (FNIScommon1.FNIScommon.PatchAF[FNIScommon1.FNIScommon.iPatchAF].inADSF)
                {
                  if (Information.UBound((Array) strArray3, 1) < 4)
                    Information.Err().Raise(1, (object) null, (object) null, (object) null, (object) null);
                  else
                    FNIScommon1.FNIScommon.PatchAF[FNIScommon1.FNIScommon.iPatchAF].ClipGenName = strArray3[4];
                }
                checked { ++FNIScommon1.FNIScommon.iPatchAF; }
              }
            }
          }
label_44:
          checked { ++index1; }
        }
        FNIScommon1.FNIScommon.nPatchAF[1] = 0;
        FNIScommon1.FNIScommon.nPatchAF[2] = 0;
        FNIScommon1.FNIScommon.nPatchAF[3] = 0;
        int num6 = checked (FNIScommon1.FNIScommon.iPatchAF - 1);
        int index3 = 0;
        while (index3 <= num6)
        {
          if (FNIScommon1.FNIScommon.PatchAF[index3].inDefault)
          {
            // ISSUE: variable of a reference type
            int& local;
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            int num4 = checked (^(local = @FNIScommon1.FNIScommon.nPatchAF[1]) + 1);
            // ISSUE: explicit reference operation
            ^local = num4;
          }
          if (FNIScommon1.FNIScommon.PatchAF[index3].inADSF)
          {
            // ISSUE: variable of a reference type
            int& local;
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            int num4 = checked (^(local = @FNIScommon1.FNIScommon.nPatchAF[2]) + 1);
            // ISSUE: explicit reference operation
            ^local = num4;
          }
          if (FNIScommon1.FNIScommon.PatchAF[index3].inASDSF)
          {
            // ISSUE: variable of a reference type
            int& local;
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            int num4 = checked (^(local = @FNIScommon1.FNIScommon.nPatchAF[3]) + 1);
            // ISSUE: explicit reference operation
            ^local = num4;
          }
          checked { ++index3; }
        }
        goto label_61;
label_56:
        num2 = -1;
        switch (num1)
        {
          case 2:
            FNIScommon1.FNIScommon.ErrString = Conversion.Str((object) num3) + " PatchAnimationFiles.txt";
            Information.Err().Raise(2015, (object) null, (object) null, (object) null, (object) null);
            goto label_61;
        }
      }
      catch (Exception ex) when (ex is Exception & (uint) num1 > 0U & num2 == 0)
      {
        ProjectData.SetProjectError(ex);
        goto label_56;
      }
      throw ProjectData.CreateProjectError(-2146828237);
label_61:
      if (num2 == 0)
        return;
      ProjectData.ClearProjectError();
    }

    public void ConsistenceCheck()
    {
      int num1 = 0;
      FNIScommon1.FNIScommon.LogFile = new StreamWriter("temporary_logs\\GenerateFNIS_LogFile.txt", true);
      if (FNIScommon1.FNIScommon.DebugOutput > 1)
        FNIScommon1.FNIScommon.LogFile.AutoFlush = true;
      FNIScommon1.FNIScommon.LogOpen = true;
      FNIScommon1.FNIScommon.LogOutput("", true, true);
      int num2 = -1;
      string str1 = "";
      string Replacement1 = "";
      List<FNIScommon1.FNIScommon.AEcc> aeList = FNIScommon1.FNIScommon.AEList;
      Comparison<FNIScommon1.FNIScommon.AEcc> comparison1;
      // ISSUE: reference to a compiler-generated field
      if (GenerateFNISUsers._Closure\u0024__.\u0024I46\u002D0 != null)
      {
        // ISSUE: reference to a compiler-generated field
        comparison1 = GenerateFNISUsers._Closure\u0024__.\u0024I46\u002D0;
      }
      else
      {
        // ISSUE: reference to a compiler-generated field
        GenerateFNISUsers._Closure\u0024__.\u0024I46\u002D0 = comparison1 = (Comparison<FNIScommon1.FNIScommon.AEcc>) ((x, y) => x.comp.CompareTo(y.comp));
      }
      aeList.Sort(comparison1);
      List<FNIScommon1.FNIScommon.AEcc>.Enumerator enumerator1;
      try
      {
        enumerator1 = FNIScommon1.FNIScommon.AEList.GetEnumerator();
        while (enumerator1.MoveNext())
        {
          FNIScommon1.FNIScommon.AEcc current = enumerator1.Current;
          int actor = current.actor;
          string Left = Strings.LCase(current.AE);
          int num3 = num2;
          if (actor == num3 && Operators.CompareString(Left, Strings.LCase(str1), false) == 0)
          {
            FNIScommon1.FNIScommon.LogOutput(Strings.Replace(Strings.Replace(Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[23], "<1>", current.AE, 1, -1, CompareMethod.Binary), "<2>", FNIScommon1.FNIScommon.BO_List[current.actor], 1, -1, CompareMethod.Binary), "<3>", Replacement1, 1, -1, CompareMethod.Binary), "<4>", current.modname, 1, -1, CompareMethod.Binary), true, true);
            checked { ++num1; }
          }
          num2 = current.actor;
          str1 = current.AE;
          Replacement1 = current.modname;
        }
      }
      finally
      {
        enumerator1.Dispose();
      }
      List<FNIScommon1.FNIScommon.AnimFilecc>.Enumerator enumerator2;
      try
      {
        enumerator2 = FNIScommon1.FNIScommon.AnimFileList.GetEnumerator();
        while (enumerator2.MoveNext())
        {
          FNIScommon1.FNIScommon.AnimFilecc current = enumerator2.Current;
          if (!current.isbsa && !MyProject.Computer.FileSystem.FileExists(current.animpath + current.modname + "\\" + current.animfile))
          {
            FNIScommon1.FNIScommon.LogOutput(Strings.Replace(Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[19], "<1>", current.animfile, 1, -1, CompareMethod.Binary), "<2>", FNIScommon1.FNIScommon.BO_List[current.actor], 1, -1, CompareMethod.Binary), "<3>", current.modname, 1, -1, CompareMethod.Binary), true, true);
            checked { ++num1; }
          }
        }
      }
      finally
      {
        enumerator2.Dispose();
      }
      int num4 = -1;
      string str2 = "";
      string Replacement2 = "";
      List<FNIScommon1.FNIScommon.AnimFilecc> animFileList = FNIScommon1.FNIScommon.AnimFileList;
      Comparison<FNIScommon1.FNIScommon.AnimFilecc> comparison2;
      // ISSUE: reference to a compiler-generated field
      if (GenerateFNISUsers._Closure\u0024__.\u0024I46\u002D1 != null)
      {
        // ISSUE: reference to a compiler-generated field
        comparison2 = GenerateFNISUsers._Closure\u0024__.\u0024I46\u002D1;
      }
      else
      {
        // ISSUE: reference to a compiler-generated field
        GenerateFNISUsers._Closure\u0024__.\u0024I46\u002D1 = comparison2 = (Comparison<FNIScommon1.FNIScommon.AnimFilecc>) ((x, y) => x.comp.CompareTo(y.comp));
      }
      animFileList.Sort(comparison2);
      List<FNIScommon1.FNIScommon.AnimFilecc>.Enumerator enumerator3;
      try
      {
        enumerator3 = FNIScommon1.FNIScommon.AnimFileList.GetEnumerator();
        while (enumerator3.MoveNext())
        {
          FNIScommon1.FNIScommon.AnimFilecc current = enumerator3.Current;
          if (current.actor == num4 & Operators.CompareString(Strings.LCase(current.animfile), Strings.LCase(str2), false) == 0)
          {
            FNIScommon1.FNIScommon.LogOutput(Strings.Replace(Strings.Replace(Strings.Replace(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[18], "<1>", current.animfile, 1, -1, CompareMethod.Binary), "<2>", FNIScommon1.FNIScommon.BO_List[current.actor], 1, -1, CompareMethod.Binary), "<3>", Replacement2, 1, -1, CompareMethod.Binary), "<4>", current.modname, 1, -1, CompareMethod.Binary), true, true);
            checked { ++num1; }
          }
          num4 = current.actor;
          str2 = current.animfile;
          Replacement2 = current.modname;
        }
      }
      finally
      {
        enumerator3.Dispose();
      }
      FNIScommon1.FNIScommon.LogOutput(Strings.Replace(FNIScommon1.FNIScommon.tMsgu[30], "<1>", Conversion.Str((object) num1), 1, -1, CompareMethod.Binary), true, true);
      FNIScommon1.FNIScommon.FinishSub();
    }

    public void MyHandler(object sender, UnhandledExceptionEventArgs args)
    {
      int num = (int) Interaction.MsgBox((object) ("FNIS generator caught unhandled exception : " + ((Exception) args.ExceptionObject).Message), MsgBoxStyle.OkOnly, (object) null);
    }

    private void RichTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
    {
      Process.Start(e.LinkText);
    }

    private void FNISSM2_RichTextBox_LinkClicked(object sender, LinkClickedEventArgs e)
    {
      Process.Start(e.LinkText);
    }

    [DebuggerNonUserCode]
    protected override void Dispose(bool disposing)
    {
      try
      {
        if (!disposing || this.components == null)
          return;
        this.components.Dispose();
      }
      finally
      {
        base.Dispose(disposing);
      }
    }

    [DebuggerStepThrough]
    private void InitializeComponent()
    {
      ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (GenerateFNISUsers));
      this.TextBox1 = new TextBox();
      this.Button1 = new Button();
      this.Button2 = new Button();
      this.Button3 = new Button();
      this.Patch_ListBox = new CheckedListBox();
      this.PatchList_Header = new TextBox();
      this.TextBox2 = new TextBox();
      this.LanguageBox = new ComboBox();
      this.Button5 = new Button();
      this.RichTextBox1 = new RichTextBox();
      this.RichTextBox2 = new RichTextBox();
      this.SuspendLayout();
      this.TextBox1.Font = new Font("Microsoft Sans Serif", 8f);
      this.TextBox1.ForeColor = SystemColors.WindowText;
      this.TextBox1.Location = new Point(8, 52);
      this.TextBox1.Multiline = true;
      this.TextBox1.Name = "TextBox1";
      this.TextBox1.ScrollBars = ScrollBars.Vertical;
      this.TextBox1.Size = new Size(510, 280);
      this.TextBox1.TabIndex = 2;
      this.TextBox1.Text = componentResourceManager.GetString("TextBox1.Text");
      this.Button1.BackColor = Color.Gold;
      this.Button1.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Bold);
      this.Button1.Location = new Point(50, 352);
      this.Button1.Name = "Button1";
      this.Button1.Size = new Size(428, 34);
      this.Button1.TabIndex = 1;
      this.Button1.Text = "Update FNIS Behavior";
      this.Button1.UseVisualStyleBackColor = false;
      this.Button2.Enabled = false;
      this.Button2.FlatStyle = FlatStyle.System;
      this.Button2.Font = new Font("Microsoft Sans Serif", 9f, FontStyle.Regular, GraphicsUnit.Point, (byte) 0);
      this.Button2.Location = new Point(8, 407);
      this.Button2.Name = "Button2";
      this.Button2.Size = new Size(146, 34);
      this.Button2.TabIndex = 2;
      this.Button2.Text = "Consistence Check";
      this.Button2.UseVisualStyleBackColor = true;
      this.Button3.FlatAppearance.BorderColor = Color.White;
      this.Button3.FlatAppearance.MouseDownBackColor = Color.White;
      this.Button3.FlatStyle = FlatStyle.System;
      this.Button3.Font = new Font("Microsoft Sans Serif", 9f, FontStyle.Bold, GraphicsUnit.Point, (byte) 0);
      this.Button3.Location = new Point(342, 407);
      this.Button3.Name = "Button3";
      this.Button3.Size = new Size(175, 34);
      this.Button3.TabIndex = 3;
      this.Button3.Text = "Exit";
      this.Button3.UseVisualStyleBackColor = true;
      this.Patch_ListBox.BackColor = Color.LemonChiffon;
      this.Patch_ListBox.BorderStyle = BorderStyle.None;
      this.Patch_ListBox.CheckOnClick = true;
      this.Patch_ListBox.Enabled = false;
      this.Patch_ListBox.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Regular, GraphicsUnit.Point, (byte) 0);
      this.Patch_ListBox.FormattingEnabled = true;
      this.Patch_ListBox.Location = new Point(8, 496);
      this.Patch_ListBox.Name = "Patch_ListBox";
      this.Patch_ListBox.Size = new Size(510, 195);
      this.Patch_ListBox.TabIndex = 4;
      this.PatchList_Header.BackColor = Color.LemonChiffon;
      this.PatchList_Header.BorderStyle = BorderStyle.None;
      this.PatchList_Header.Enabled = false;
      this.PatchList_Header.Font = new Font("Microsoft Sans Serif", 9f, FontStyle.Bold, GraphicsUnit.Point, (byte) 0);
      this.PatchList_Header.Location = new Point(8, 457);
      this.PatchList_Header.MinimumSize = new Size(510, 16);
      this.PatchList_Header.Multiline = true;
      this.PatchList_Header.Name = "PatchList_Header";
      this.PatchList_Header.Size = new Size(510, 18);
      this.PatchList_Header.TabIndex = 5;
      this.PatchList_Header.Text = "Available Patches  (DON'T tick if unknown!)";
      this.PatchList_Header.TextAlign = HorizontalAlignment.Center;
      this.TextBox2.BackColor = Color.LemonChiffon;
      this.TextBox2.BorderStyle = BorderStyle.None;
      this.TextBox2.Enabled = false;
      this.TextBox2.Font = new Font("Microsoft Sans Serif", 9f, FontStyle.Bold, GraphicsUnit.Point, (byte) 0);
      this.TextBox2.ForeColor = Color.Chocolate;
      this.TextBox2.Location = new Point(8, 475);
      this.TextBox2.Multiline = true;
      this.TextBox2.Name = "TextBox2";
      this.TextBox2.Size = new Size(510, 20);
      this.TextBox2.TabIndex = 6;
      this.TextBox2.Text = "* Patch requires additional files (animations, etc.) from original mod";
      this.TextBox2.TextAlign = HorizontalAlignment.Center;
      this.LanguageBox.DropDownStyle = ComboBoxStyle.DropDownList;
      this.LanguageBox.FormattingEnabled = true;
      this.LanguageBox.Location = new Point(370, 23);
      this.LanguageBox.MinimumSize = new Size(4, 0);
      this.LanguageBox.Name = "LanguageBox";
      this.LanguageBox.Size = new Size(149, 21);
      this.LanguageBox.TabIndex = 7;
      this.Button5.Enabled = false;
      this.Button5.FlatStyle = FlatStyle.System;
      this.Button5.Font = new Font("Microsoft Sans Serif", 9f, FontStyle.Regular, GraphicsUnit.Point, (byte) 0);
      this.Button5.Location = new Point(171, 407);
      this.Button5.Name = "Button5";
      this.Button5.Size = new Size(146, 34);
      this.Button5.TabIndex = 9;
      this.Button5.Text = "De-Install Creatures";
      this.Button5.UseVisualStyleBackColor = true;
      this.RichTextBox1.BackColor = Color.Chocolate;
      this.RichTextBox1.BorderStyle = BorderStyle.None;
      this.RichTextBox1.ForeColor = Color.White;
      this.RichTextBox1.Location = new Point(8, 3);
      this.RichTextBox1.Name = "RichTextBox1";
      this.RichTextBox1.Size = new Size(350, 43);
      this.RichTextBox1.TabIndex = 10;
      this.RichTextBox1.Text = "FNIS: http://www.nexusmods.com/skyrim/mods/11811\nFNIS Sexy Move: http://www.nexusmods.com/skyrim/mods/54521\nFNIS PCEA2: http://www.nexusmods.com/skyrim/mods/71055";
      this.RichTextBox2.BackColor = Color.Goldenrod;
      this.RichTextBox2.BorderStyle = BorderStyle.None;
      this.RichTextBox2.ForeColor = Color.White;
      this.RichTextBox2.Location = new Point(8, 3);
      this.RichTextBox2.Name = "RichTextBox2";
      this.RichTextBox2.ScrollBars = RichTextBoxScrollBars.None;
      this.RichTextBox2.Size = new Size(360, 43);
      this.RichTextBox2.TabIndex = 14;
      this.RichTextBox2.Text = componentResourceManager.GetString("RichTextBox2.Text");
      this.RichTextBox2.WordWrap = false;
      this.AutoScaleDimensions = new SizeF(6f, 13f);
      this.AutoScaleMode = AutoScaleMode.Font;
      this.BackColor = Color.Chocolate;
      this.ClientSize = new Size(530, 697);
      this.Controls.Add((Control) this.RichTextBox2);
      this.Controls.Add((Control) this.Button5);
      this.Controls.Add((Control) this.LanguageBox);
      this.Controls.Add((Control) this.TextBox2);
      this.Controls.Add((Control) this.PatchList_Header);
      this.Controls.Add((Control) this.Patch_ListBox);
      this.Controls.Add((Control) this.Button3);
      this.Controls.Add((Control) this.Button2);
      this.Controls.Add((Control) this.Button1);
      this.Controls.Add((Control) this.TextBox1);
      this.Controls.Add((Control) this.RichTextBox1);
      this.Font = new Font("Microsoft Sans Serif", 8.5f, FontStyle.Regular, GraphicsUnit.Point, (byte) 0);
      this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
      this.Icon = (Icon) componentResourceManager.GetObject("$this.Icon");
      this.Name = "GenerateFNISUsers";
      this.Text = "Generate FNIS for Users";
      this.ResumeLayout(false);
      this.PerformLayout();
    }

    public struct CustomPreCache
    {
      public uint refpath_crc;
      public uint reffile_crc;
      public int refnumber1;
      public int refnumber2;
      public int refcount;
      public uint custompath_crc;
      public int nCustomAnims;
      public int indexCustomAnims;
    }

    public struct PCEAgenderFileData
    {
      public uint crc;
      public string name;
      public bool isGender_F;
      public bool isGender_M;
      public bool isPCEA_F;
      public bool isPCEA_M;
    }
  }
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download