コード例 #1
0
 /// <summary>
 /// Creates a new linking package relative to a load order.<br/>
 /// Will resolve links to the highest overriding mod containing the record being sought. <br/>
 /// Modification of the target LoadOrder, or Mods on the LoadOrder is not safe.  Internal caches can become
 /// incorrect if modifications occur on content already cached.
 /// </summary>
 /// <param name="loadOrder">LoadOrder to construct the package relative to</param>
 /// <returns>LinkPackage attached to given LoadOrder</returns>
 public static ImmutableLoadOrderLinkCache <TMod, TModGetter> ToImmutableLinkCache <TMod, TModGetter>(
     this LoadOrder <TModGetter> loadOrder)
     where TMod : class, IContextMod <TMod>, TModGetter
     where TModGetter : class, IContextGetterMod <TMod>
 {
     return(new ImmutableLoadOrderLinkCache <TMod, TModGetter>(loadOrder.ListedOrder));
 }
コード例 #2
0
ファイル: OverrideMixIns.cs プロジェクト: Deigue/Mutagen
 /// <summary>
 /// Will find and return the most overridden version of each record in the load order of the given type
 /// USAGE NOTE: <br/>
 /// Typically you should only supply the Getter interfaces for the type. <br/>
 /// A setter interface being given can result in no records being found, as most LoadOrders are readonly.
 /// </summary>
 /// <typeparam name="TMod">Mod type that the load order contains</typeparam>
 /// <param name="loadOrder">LoadOrder to iterate over</param>
 /// <param name="type">
 /// Type of record to search for and iterate. <br/>
 /// USAGE NOTE: <br/>
 /// Typically you should only supply the Getter interfaces for the type. <br/>
 /// A setter interface being given can result in no records being found, as most LoadOrders are readonly.
 /// </param>
 /// <param name="includeDeletedRecords">Whether to include deleted records in the output</param>
 /// <returns>Enumerable of the most overridden version of each record of the given type, optionally including deleted ones</returns>
 public static IEnumerable <IMajorRecordCommonGetter> WinningOverrides <TMod>(
     this LoadOrder <TMod> loadOrder,
     Type type,
     bool includeDeletedRecords = true)
     where TMod : class, IModGetter
 {
     return(loadOrder.PriorityOrder.WinningOverrides(type, includeDeletedRecords: includeDeletedRecords));
 }
コード例 #3
0
 /// <summary>
 /// Will find and return the most overridden version of each record in the load order of the given type
 /// USAGE NOTE: <br/>
 /// Typically you should only supply the Getter interfaces for the type. <br/>
 /// A setter interface being given can result in no records being found, as most LoadOrders are readonly.
 /// </summary>
 /// <typeparam name="TMod">Mod type that the load order contains</typeparam>
 /// <typeparam name="TMajor">
 /// Type of record to search for and iterate. <br/>
 /// USAGE NOTE: <br/>
 /// Typically you should only supply the Getter interfaces for the type. <br/>
 /// A setter interface being given can result in no records being found, as most LoadOrders are readonly.
 /// </typeparam>
 /// <param name="loadOrder">LoadOrder to iterate over</param>
 /// <param name="includeDeletedRecords">Whether to include deleted records in the output</param>
 /// <returns>Enumerable of the most overridden version of each record of the given type, optionally including deleted ones</returns>
 public static IEnumerable <TMajor> WinningOverrides <TMod, TMajor>(
     this LoadOrder <TMod> loadOrder,
     bool includeDeletedRecords = false)
     where TMod : class, IModGetter
     where TMajor : class, IMajorRecordCommonGetter
 {
     return(loadOrder.PriorityOrder.WinningOverrides <TMajor>(includeDeletedRecords: includeDeletedRecords));
 }
コード例 #4
0
        public static ILoadOrderGetter <TListing> ToLoadOrder <TListing>(this IEnumerable <TListing> listings)
            where TListing : IModListingGetter
        {
            var ret = new LoadOrder <TListing>();

            ret.Add(listings);
            return(ret);
        }
コード例 #5
0
 public void Dispose()
 {
     if (!_dispose)
     {
         return;
     }
     LoadOrder.Dispose();
     LinkCache.Dispose();
 }
コード例 #6
0
ファイル: OverrideMixIns.cs プロジェクト: Deigue/Mutagen
 /// <summary>
 /// Will find and return the most overridden version of each record in the list of mods of the given type. <br/>
 /// <br />
 /// Additionally, it will come wrapped in a context object that has knowledge of where each record came from. <br/>
 /// This context helps when trying to override deep records such as Cells/PlacedObjects/etc, as the context is able to navigate
 /// and insert the record into the proper location for you. <br />
 /// <br />
 /// This system is overkill for simpler top-level records.
 /// </summary>
 /// <typeparam name="TMod">Setter Mod type to target</typeparam>
 /// <typeparam name="TModGetter">Getter Mod type to target</typeparam>
 /// <param name="loadOrder">LoadOrder to iterate over</param>
 /// <param name="linkCache">LinkCache to use when creating parent objects</param>
 /// <param name="type">
 /// Type of record to search for and iterate. <br/>
 /// USAGE NOTE: <br/>
 /// Typically you should only supply the Getter interfaces for the type. <br/>
 /// A setter interface being given can result in no records being found, as most LoadOrders are readonly.
 /// </param>
 /// <param name="includeDeletedRecords">Whether to include deleted records in the output</param>
 /// <returns>Enumerable of the most overridden version of each record of the given type, optionally including deleted ones</returns>
 public static IEnumerable <IModContext <TMod, IMajorRecordCommon, IMajorRecordCommonGetter> > WinningOverrideContexts <TMod, TModGetter>(
     this LoadOrder <TModGetter> loadOrder,
     ILinkCache linkCache,
     Type type,
     bool includeDeletedRecords = true)
     where TMod : class, IMod, TModGetter
     where TModGetter : class, IModGetter, IMajorRecordContextEnumerable <TMod>
 {
     return(loadOrder.PriorityOrder.WinningOverrideContexts <TMod, TModGetter>(linkCache, type, includeDeletedRecords: includeDeletedRecords));
 }
コード例 #7
0
 /// <summary>
 /// Creates a mutable load order link cache by combining an existing immutable load order cache,
 /// plus a set of mods to be put at the end of the load order and allow to be mutable.
 /// </summary>
 /// <param name="immutableBaseCache">LoadOrderCache to use as the immutable base</param>
 /// <param name="mutableMods">Set of mods to place at the end of the load order, which are allowed to be modified afterwards</param>
 /// <returns>LinkPackage attached to given LoadOrder</returns>
 public static MutableLoadOrderLinkCache <TMod, TModGetter> ToMutableLinkCache <TMod, TModGetter>(
     this LoadOrder <IModListing <TModGetter> > immutableBaseCache,
     params TMod[] mutableMods)
     where TMod : class, IContextMod <TMod>, TModGetter
     where TModGetter : class, IContextGetterMod <TMod>
 {
     return(new MutableLoadOrderLinkCache <TMod, TModGetter>(
                immutableBaseCache.ToImmutableLinkCache <TMod, TModGetter>(),
                mutableMods));
 }
コード例 #8
0
 /// <summary>
 /// Creates a new linking package relative to a load order.<br/>
 /// Will resolve links to the highest overriding mod containing the record being sought. <br/>
 /// Modification of the target LoadOrder, or Mods on the LoadOrder is not safe.  Internal caches can become
 /// incorrect if modifications occur on content already cached.
 /// </summary>
 /// <param name="loadOrder">LoadOrder to construct the package relative to</param>
 /// <returns>LinkPackage attached to given LoadOrder</returns>
 public static ImmutableLoadOrderLinkCache <TMod, TModGetter> ToImmutableLinkCache <TMod, TModGetter>(
     this LoadOrder <IModListing <TModGetter> > loadOrder)
     where TMod : class, IContextMod <TMod>, TModGetter
     where TModGetter : class, IContextGetterMod <TMod>
 {
     return(new ImmutableLoadOrderLinkCache <TMod, TModGetter>(
                loadOrder
                .Select(listing => listing.Value.Mod)
                .NotNull()));
 }
コード例 #9
0
ファイル: LoadOrderLinkCache.cs プロジェクト: halgari/Mutagen
        /// <summary>
        /// Constructs a LoadOrderLinkCache around a target load order
        /// </summary>
        /// <param name="loadOrder">LoadOrder to resolve against when linking</param>
        public LoadOrderLinkCache(LoadOrder <TMod> loadOrder)
        {
            this._loadOrder = loadOrder;
            this._loadOrderUntypedMajorRecords = new Cache <IMajorRecordCommonGetter, FormKey>(m => m.FormKey);
            this._loadOrderMajorRecords        = new Dictionary <Type, InternalTypedCache>();
            var firstMod = _loadOrder.FirstOrDefault(m => m.Mod != null);

            this._hasAny   = firstMod?.Mod != null;
            this._gameMode = firstMod?.Mod?.GameMode ?? GameMode.Oblivion;
        }
コード例 #10
0
 public GameEnvironmentState(
     string gameFolderPath,
     LoadOrder <IModListing <TModGetter> > loadOrder,
     ILinkCache <TModSetter, TModGetter> linkCache,
     bool dispose = true)
 {
     GameFolderPath = gameFolderPath;
     LoadOrder      = loadOrder;
     LinkCache      = linkCache;
     _dispose       = dispose;
 }
コード例 #11
0
ファイル: Pipeline.cs プロジェクト: halgari/Mutagen
 public static void TypicalPatch <TMod>(
     string[] mainArgs,
     ModKey outputMod,
     IReadOnlyList <ModKey> loadOrderList,
     LoadOrder <TMod> .Importer importer,
     Func <ModKey, LoadOrder <TMod>, TMod> processor)
     where TMod : class, IMod
 {
     TypicalPatch(
         dataFolder: new Noggog.DirectoryPath(mainArgs[0]),
         outModKey: outputMod,
         loadOrderList: loadOrderList,
         processor: processor,
         importer: importer);
 }
コード例 #12
0
ファイル: Pipeline.cs プロジェクト: halgari/Mutagen
        public static void TypicalPatch <TMod>(
            DirectoryPath dataFolder,
            ModKey outModKey,
            IReadOnlyList <ModKey> loadOrderList,
            LoadOrder <TMod> .Importer importer,
            Func <ModKey, LoadOrder <TMod>, TMod> processor)
            where TMod : class, IMod
        {
            var loadOrderInternal = loadOrderList.ToList();

            loadOrderInternal.Remove(outModKey);
            var loadOrder = new LoadOrder <TMod>();

            loadOrder.Import(
                dataFolder,
                loadOrderInternal,
                importer);
            var outMod = processor(outModKey, loadOrder);

            foreach (var npc in outMod.EnumerateMajorRecords())
            {
                npc.IsCompressed = false;
            }
            var linkCache = loadOrder.CreateLinkCache();

            outMod.MasterReferences.SetTo(
                outMod.LinkFormKeys
                .Where(fk => !fk.IsNull)
                .Select(s => s.ModKey)
                .Where(modKey => modKey != outModKey)
                .Distinct()
                .OrderBy(modKey => loadOrder.IndexOf(modKey))
                .Select(modKey => new MasterReference()
            {
                Master = modKey
            }));
            outMod.SyncRecordCount();
            outMod.WriteToBinary(
                path: Path.Combine(dataFolder.Path, outModKey.FileName));
        }
コード例 #13
0
 public static MastersListOrderingByLoadOrder Factory <T>(LoadOrder <T> loadOrder)
     where T : IModKeyed
 {
     return(Factory(loadOrder.Select(listing => listing.Key)));
 }
コード例 #14
0
ファイル: ILinkCache.cs プロジェクト: halgari/Mutagen
 /// <summary>
 /// Creates a new linking package relative to a load order.
 /// </summary>
 /// <typeparam name="TMod">Mod type</typeparam>
 /// <param name="loadOrder">LoadOrder to construct the package relative to</param>
 /// <returns>LinkPackage attached to given LoadOrder</returns>
 public static ILinkCache CreateLinkCache <TMod>(this LoadOrder <TMod> loadOrder)
     where TMod : class, IModGetter
 {
     return(new LoadOrderLinkCache <TMod>(loadOrder));
 }
コード例 #15
0
 public static IEnumerable <TListing> OrderListings <TListing>(this IEnumerable <TListing> e)
     where TListing : IModListingGetter
 {
     return(LoadOrder.OrderListings(e, i => i.ModKey));
 }
コード例 #16
0
 public static IEnumerable <ModKey> OrderListings(this IEnumerable <ModKey> e)
 {
     return(LoadOrder.OrderListings(e, i => i));
 }