示例#1
0
 void ProcessWeapons()
 {
     WeaponExplosions = new Dictionary <string, string>();
     WeaponFiles      = new Dictionary <string, string>();
     foreach (var filePath in Directory.GetFiles(ModFolder + "/weapons"))
     {
         var text = File.ReadAllText(filePath);
         foreach (dynamic returValue in GetTdfTableFromString(L, text))
         {
             if (returValue is LuaTable)
             {
                 foreach (var kvp in returValue.Values)
                 {
                     string weaponName = kvp.Key.Value;
                     WeaponFiles.Add(weaponName, FilesFinder.FixPath(filePath));
                     if (kvp.Value.GetField("explosiongenerator") is LuaString)
                     {
                         string explosionGenerator = kvp.Value.GetField("explosiongenerator").Value;
                         if (explosionGenerator.StartsWith("custom:"))
                         {
                             WeaponExplosions.Add(weaponName, explosionGenerator.Substring(7, explosionGenerator.Length - 7).ToLower());
                         }
                     }
                 }
             }
         }
     }
 }
示例#2
0
        public ModInfo(string modFolder)
        {
            this.ModFolder = FilesFinder.FixPath(modFolder);
            L = Lua.luaL_newstate();
            Lua.luaL_openlibs(L);
            CLua.TraceDoString(L, 0, Resources.luastuff);

            ProcessResources();
            ProcessExplosions();
            ProcessWeapons();
        }
示例#3
0
        void ProcessResources()
        {
            var     resourcesPath = ModFolder + "\\gamedata\\resources.lua";
            dynamic resources     = CLua.TraceDoString(L, 1, File.ReadAllText(resourcesPath))[0];

            ProjectileTextures = new Dictionary <string, string>();
            var textures = resources.GetField("graphics").GetField("projectiletextures");

            foreach (var kvp in textures.Values)
            {
                ProjectileTextures.Add(kvp.Key.Value, FilesFinder.FixPath(ModFolder + "/bitmaps/" + textures.GetField(kvp.Key.Value).Value));
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            var ca = new ModInfo(@"c:\work\zk\trunk\mods\zk");
            var units = File.ReadAllLines("unitlist.txt").Where(x => !string.IsNullOrEmpty(x)).ToArray();
            var resources = new List<string>();
            foreach (var unit in units)
            {
                var f = new FilesFinder(unit, ca);
                f.Print();
                resources.Add(f.CopyTo(@"C:\temp\zkfix"));
            }

            foreach (var resource in resources.SelectMany(r => r.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Where(s => !String.IsNullOrWhiteSpace(s))).Distinct().OrderBy(x=>x))
            {
                Debug.WriteLine(resource);
            }

            Debug.WriteLine("END");
        }
示例#5
0
        static void Main(string[] args)
        {
            var ca        = new ModInfo(@"c:\work\zk\trunk\mods\zk");
            var units     = File.ReadAllLines("unitlist.txt").Where(x => !string.IsNullOrEmpty(x)).ToArray();
            var resources = new List <string>();

            foreach (var unit in units)
            {
                var f = new FilesFinder(unit, ca);
                f.Print();
                resources.Add(f.CopyTo(@"C:\temp\zkfix"));
            }

            foreach (var resource in resources.SelectMany(r => r.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Where(s => !String.IsNullOrWhiteSpace(s))).Distinct().OrderBy(x => x))
            {
                Debug.WriteLine(resource);
            }

            Debug.WriteLine("END");
        }