示例#1
0
        private void LoadGameObjects(ModInfo mod)
        {
            foreach (var file in mod.Globals)
            {
                var globalStream = file.Value.MakeStream();
                try
                {
                    using (var reader = new BinaryReader(globalStream))
                    {
                        var globalLsf = reader.ReadBytes((int)globalStream.Length);
                        GameObjectLSFs.Add(globalLsf);
                    }
                }
                finally
                {
                    file.Value.ReleaseStream();
                }
            }

            foreach (var file in mod.LevelObjects)
            {
                var objectStream = file.Value.MakeStream();
                try
                {
                    using (var reader = new BinaryReader(objectStream))
                    {
                        var levelLsf = reader.ReadBytes((int)objectStream.Length);
                        GameObjectLSFs.Add(levelLsf);
                    }
                }
                finally
                {
                    file.Value.ReleaseStream();
                }
            }
        }
示例#2
0
        private void LoadGoals(ModInfo mod)
        {
            foreach (var file in mod.Scripts)
            {
                var scriptStream = file.Value.MakeStream();
                try
                {
                    using (var reader = new BinaryReader(scriptStream))
                    {
                        string path;
                        if (file.Value is PackagedFileInfo)
                        {
                            var pkgd = file.Value as PackagedFileInfo;
                            path = (pkgd.PackageStream as FileStream).Name + ":/" + pkgd.Name;
                        }
                        else
                        {
                            var fs = file.Value as FilesystemFileInfo;
                            path = fs.FilesystemPath;
                        }

                        var script = new GoalScript
                        {
                            Name       = Path.GetFileNameWithoutExtension(file.Value.Name),
                            Path       = path,
                            ScriptBody = reader.ReadBytes((int)scriptStream.Length)
                        };
                        GoalScripts.Add(script);
                    }
                }
                finally
                {
                    file.Value.ReleaseStream();
                }
            }
        }