Exemplo n.º 1
0
        public void CreatePatch(Patch patch, IList <ValuePair <Model> > npcs)
        {
            var modifiedNpcs = npcs.Where(x => x.Modified).ToList();

            if (!modifiedNpcs.Any())
            {
                return;
            }

            var npcMap = new CharacterReferences()
                         .LoadMap(modifiedNpcs.Select(x => x.Default));

            var modifications = new List <(ValuePair <Model> Npc, string File)>();

            foreach (var npc in modifiedNpcs)
            {
                if (!npcMap.TryGetValue(npc.Default, out var files))
                {
                    continue;
                }
                foreach (var file in files)
                {
                    modifications.Add((npc, file));
                }
            }

            foreach (var mods in modifications.GroupBy(x => x.File))
            {
                UpdateCharacterReference(patch, mods.Key, mods.Select(x => x.Npc));
            }

            var mapping = modifiedNpcs.Select(x => (x.Default.Id, x.Value.Id));

            patch.AddObject(mapping, MapName);
        }