diff --git a/Mutagen.Bethesda.Core/Extensions/GameCategoryExt.cs b/Mutagen.Bethesda.Core/Extensions/GameCategoryExt.cs index 405f7b4427..ca360c6ab1 100644 --- a/Mutagen.Bethesda.Core/Extensions/GameCategoryExt.cs +++ b/Mutagen.Bethesda.Core/Extensions/GameCategoryExt.cs @@ -9,7 +9,7 @@ public static bool HasFormVersion(this GameCategory release) GameCategory.Oblivion => false, GameCategory.Skyrim => true, GameCategory.Fallout4 => true, - _ => throw new NotImplementedException(), + GameCategory.Starfield => true, }; } @@ -20,6 +20,7 @@ public static GameRelease DefaultRelease(this GameCategory gameCategory) GameCategory.Oblivion => GameRelease.Oblivion, GameCategory.Skyrim => GameRelease.SkyrimSE, GameCategory.Fallout4 => GameRelease.Fallout4, + GameCategory.Starfield => GameRelease.Starfield, _ => throw new NotImplementedException(), }; } @@ -42,6 +43,9 @@ public static IEnumerable GetRelatedReleases(this GameCategory game case GameCategory.Fallout4: yield return GameRelease.Fallout4; yield break; + case GameCategory.Starfield: + yield return GameRelease.Starfield; + yield break; default: throw new NotImplementedException(); } @@ -55,6 +59,7 @@ public static bool HasLocalization(this GameCategory category) return false; case GameCategory.Skyrim: case GameCategory.Fallout4: + case GameCategory.Starfield: default: return true; } diff --git a/Mutagen.Bethesda.Core/InternalsPermissions.cs b/Mutagen.Bethesda.Core/InternalsPermissions.cs index 213cba7e63..63add00741 100644 --- a/Mutagen.Bethesda.Core/InternalsPermissions.cs +++ b/Mutagen.Bethesda.Core/InternalsPermissions.cs @@ -8,4 +8,5 @@ [assembly: InternalsVisibleTo("Mutagen.Bethesda.Oblivion")] [assembly: InternalsVisibleTo("Mutagen.Bethesda.Skyrim")] [assembly: InternalsVisibleTo("Mutagen.Bethesda.Fallout4")] +[assembly: InternalsVisibleTo("Mutagen.Bethesda.Starfield")] [assembly: InternalsVisibleTo("Mutagen.Bethesda.WPF")] \ No newline at end of file diff --git a/Mutagen.Bethesda.Core/Plugins/Meta/GameConstants.cs b/Mutagen.Bethesda.Core/Plugins/Meta/GameConstants.cs index 21b1d5b50f..0c03909e48 100644 --- a/Mutagen.Bethesda.Core/Plugins/Meta/GameConstants.cs +++ b/Mutagen.Bethesda.Core/Plugins/Meta/GameConstants.cs @@ -272,6 +272,76 @@ public GameConstants( }, encodings: new(NonTranslated: MutagenEncodingProvider._1252, NonLocalized: MutagenEncodingProvider._1252)); + + /// + /// Readonly singleton of Starfield game constants + /// + public static readonly GameConstants Starfield = new GameConstants( + release: GameRelease.Starfield, + modHeaderLength: 24, + modHeaderFluffLength: 16, + groupConstants: new GroupConstants( + ObjectType.Group, + headerLength: 24, + lengthLength: 4, + cell: new GroupCellConstants(6, SubTypes: new[] { 8, 9 }), + world: new GroupWorldConstants( + TopGroupType: 1, + CellGroupTypes: new[] { 2, 4 }, + CellSubGroupTypes: new[] { 3, 5 }), + topic: new GroupTopicConstants(7), + hasSubGroups: new int[] { 1, 2, 4, 6, 7, 10 }, + new GroupNesting[] + { + new GroupNesting(2, + new GroupNesting(HasTopLevelRecordType: true, 3, + new GroupNesting(6, + new GroupNesting(8), + new GroupNesting(9)))), + new GroupNesting(HasTopLevelRecordType: true, GroupType: 10, + new GroupNesting(GroupType: 7)), + new GroupNesting( + HasTopLevelRecordType: true, GroupType: 1, + new GroupNesting( + GroupType: 6, + new GroupNesting(8), + new GroupNesting(9)), + new GroupNesting(4, + new GroupNesting(HasTopLevelRecordType: true, 5, + new GroupNesting( + GroupType: 6, + new GroupNesting(8), + new GroupNesting(9))))), + }) + { + Quest = new GroupQuestConstants(10) + }, + majorConstants: new MajorRecordConstants( + headerLength: 24, + lengthLength: 4, + flagsLoc: 8, + formIDloc: 12, + formVersionLoc: 20), + subConstants: new RecordHeaderConstants( + ObjectType.Subrecord, + headerLength: 6, + lengthLength: 2), + languages: new Language[] + { + Language.English, + Language.German, + Language.Italian, + Language.Spanish, + Language.Spanish_Mexico, + Language.French, + Language.Polish, + Language.Portuguese_Brazil, + Language.Chinese, + Language.Russian, + Language.Japanese, + }, + encodings: new(NonTranslated: MutagenEncodingProvider._1252, NonLocalized: MutagenEncodingProvider._1252)); + /// /// Returns record constants related to a certain ObjectType /// @@ -310,6 +380,8 @@ public static GameConstants Get(GameRelease release) return SkyrimVR; case GameRelease.Fallout4: return Fallout4; + case GameRelease.Starfield: + return Starfield; default: throw new NotImplementedException(); } diff --git a/Mutagen.Bethesda.Kernel/GameCategory.cs b/Mutagen.Bethesda.Kernel/GameCategory.cs index df64cd40eb..a76575b736 100644 --- a/Mutagen.Bethesda.Kernel/GameCategory.cs +++ b/Mutagen.Bethesda.Kernel/GameCategory.cs @@ -13,6 +13,8 @@ public enum GameCategory Skyrim, [Description("Fallout4")] Fallout4, + [Description("Starfield")] + Starfield, } public static class GameReleaseKernelExt @@ -29,6 +31,7 @@ public static GameCategory ToCategory(this GameRelease release) GameRelease.EnderalLE => GameCategory.Skyrim, GameRelease.EnderalSE => GameCategory.Skyrim, GameRelease.Fallout4 => GameCategory.Fallout4, + GameRelease.Starfield => GameCategory.Starfield, _ => throw new NotImplementedException(), }; } @@ -45,6 +48,7 @@ public static GameCategory ToCategory(this GameRelease release) GameRelease.EnderalSE => 44, GameRelease.SkyrimVR => 44, GameRelease.Fallout4 => 131, + GameRelease.Starfield => throw new NotImplementedException(), _ => throw new NotImplementedException(), }; } diff --git a/Mutagen.Bethesda.Kernel/GameRelease.cs b/Mutagen.Bethesda.Kernel/GameRelease.cs index e51c024946..65f331b830 100644 --- a/Mutagen.Bethesda.Kernel/GameRelease.cs +++ b/Mutagen.Bethesda.Kernel/GameRelease.cs @@ -23,4 +23,6 @@ public enum GameRelease Fallout4 = 4, [Description("Skyrim Special Edition GOG")] SkyrimSEGog = 7, + [Description("Starfield")] + Starfield = 8, } \ No newline at end of file diff --git a/Mutagen.Bethesda.Starfield.Generator/Mutagen.Bethesda.Starfield.Generator.csproj b/Mutagen.Bethesda.Starfield.Generator/Mutagen.Bethesda.Starfield.Generator.csproj new file mode 100644 index 0000000000..d8b980c542 --- /dev/null +++ b/Mutagen.Bethesda.Starfield.Generator/Mutagen.Bethesda.Starfield.Generator.csproj @@ -0,0 +1,30 @@ + + + + Exe + net6.0;net7.0 + enable + enable + + + + + + + + + + + + + cs + content + Compile + + + cs + content + Compile + + + diff --git a/Mutagen.Bethesda.Starfield.Generator/Program.cs b/Mutagen.Bethesda.Starfield.Generator/Program.cs new file mode 100644 index 0000000000..d4a61e89ed --- /dev/null +++ b/Mutagen.Bethesda.Starfield.Generator/Program.cs @@ -0,0 +1,21 @@ +using Autofac; +using Mutagen.Bethesda.Generation.Generator; +using System.Diagnostics; + +ContainerBuilder builder = new(); +builder.RegisterModule(); +builder.RegisterAssemblyTypes(typeof(Program).Assembly) + .AsSelf() + .AsImplementedInterfaces(); +var cont = builder.Build(); +var runner = cont.Resolve(); + +#if DEBUG +var detector = cont.Resolve(); +detector.LineDetected.Subscribe(x => +{ + Debugger.Break(); +}); +#endif + +await runner.Generate(); \ No newline at end of file diff --git a/Mutagen.Bethesda.Starfield.Generator/SkyrimGenerationConstructor.cs b/Mutagen.Bethesda.Starfield.Generator/SkyrimGenerationConstructor.cs new file mode 100644 index 0000000000..aaa9451f82 --- /dev/null +++ b/Mutagen.Bethesda.Starfield.Generator/SkyrimGenerationConstructor.cs @@ -0,0 +1,8 @@ +using Mutagen.Bethesda.Generation.Generator; + +namespace Mutagen.Bethesda.Starfield.Generator; + +public class StarfieldGenerationConstructor : IRecordGeneration +{ + public string Name => "Starfield"; +} diff --git a/Mutagen.Bethesda.Starfield/.editorconfig b/Mutagen.Bethesda.Starfield/.editorconfig new file mode 100644 index 0000000000..076d69a4c2 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/.editorconfig @@ -0,0 +1,10 @@ +[*.cs] + +# CS0108: // Member hides inherited member; missing new keyword +dotnet_diagnostic.CS0108.severity = silent + +# CS0109: // Member does not hide an inherited member; new keyword is not required +dotnet_diagnostic.CS0109.severity = silent + +# CS0162: // Unreachable code detected +dotnet_diagnostic.CS0162.severity = silent \ No newline at end of file diff --git a/Mutagen.Bethesda.Starfield/Assets/StarfieldModelAssetType.cs b/Mutagen.Bethesda.Starfield/Assets/StarfieldModelAssetType.cs new file mode 100644 index 0000000000..bc53dc90d6 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Assets/StarfieldModelAssetType.cs @@ -0,0 +1,14 @@ +using Mutagen.Bethesda.Assets; + +namespace Mutagen.Bethesda.Starfield.Assets; + +public class StarfieldModelAssetType : IAssetType +{ +#if NET7_0_OR_GREATER + public static IAssetType Instance { get; } = new StarfieldModelAssetType(); +#else + public static readonly StarfieldModelAssetType Instance = new(); +#endif + public string BaseFolder => "Meshes"; + public IEnumerable FileExtensions => new []{".nif"}; +} \ No newline at end of file diff --git a/Mutagen.Bethesda.Starfield/Documentation/AspectInterfaceDocumentation_Generated.md b/Mutagen.Bethesda.Starfield/Documentation/AspectInterfaceDocumentation_Generated.md new file mode 100644 index 0000000000..dcc0c1e56c --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Documentation/AspectInterfaceDocumentation_Generated.md @@ -0,0 +1,10 @@ +# Aspect Interfaces +Aspect Interfaces expose common aspects of records. For example, `INamed` are implemented by all records that have a `Name`. + +Functions can then be written that take in `INamed`, allowing any record that has a name to be passed in. +## Interfaces to Concrete Classes +### IModeled +- Weapon +## Concrete Classes to Interfaces +### Weapon +- IModeled diff --git a/Mutagen.Bethesda.Starfield/Enums/GroupTypeEnum.cs b/Mutagen.Bethesda.Starfield/Enums/GroupTypeEnum.cs new file mode 100644 index 0000000000..5670a0385d --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Enums/GroupTypeEnum.cs @@ -0,0 +1,9 @@ +namespace Mutagen.Bethesda.Starfield; + +/// +/// Different categories of Group records +/// +public enum GroupTypeEnum +{ + Type = 0, +} \ No newline at end of file diff --git a/Mutagen.Bethesda.Starfield/GameEnvironmentMixIn_Generated.cs b/Mutagen.Bethesda.Starfield/GameEnvironmentMixIn_Generated.cs new file mode 100644 index 0000000000..be911b2b15 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/GameEnvironmentMixIn_Generated.cs @@ -0,0 +1,17 @@ +using Mutagen.Bethesda.Starfield; +using Mutagen.Bethesda.Environments; +using Mutagen.Bethesda.Plugins.Cache; + +namespace Mutagen.Bethesda +{ + public static class GameEnvironmentMixIn + { + public static IGameEnvironment Starfield( + this GameEnvironment env, + LinkCachePreferences? linkCachePrefs = null) + { + return env.Construct(GameRelease.Starfield, linkCachePrefs); + } + + } +} diff --git a/Mutagen.Bethesda.Starfield/ImplicitsMixIn_Generated.cs b/Mutagen.Bethesda.Starfield/ImplicitsMixIn_Generated.cs new file mode 100644 index 0000000000..fcfd2b4ce5 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/ImplicitsMixIn_Generated.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using Mutagen.Bethesda.Plugins; +using Mutagen.Bethesda.Plugins.Implicit; +using Mutagen.Bethesda.Starfield; + +namespace Mutagen.Bethesda +{ + public static class ImplicitsMixIn + { + public static IReadOnlyCollection Starfield(this ImplicitBaseMasters _) + { + return Implicits.Get(GameRelease.Starfield).BaseMasters; + } + + public static IReadOnlyCollection Starfield(this ImplicitListings _) + { + return Implicits.Get(GameRelease.Starfield).Listings; + } + + public static IReadOnlyCollection Starfield(this ImplicitRecordFormKeys _) + { + return Implicits.Get(GameRelease.Starfield).RecordFormKeys; + } + } +} diff --git a/Mutagen.Bethesda.Starfield/Interfaces/Aspect/AspectInterfaceMapping_Generated.cs b/Mutagen.Bethesda.Starfield/Interfaces/Aspect/AspectInterfaceMapping_Generated.cs new file mode 100644 index 0000000000..166de108d7 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Interfaces/Aspect/AspectInterfaceMapping_Generated.cs @@ -0,0 +1,32 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Autogenerated by Loqui. Do not manually change. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ +using System; +using System.Collections.Generic; +using Mutagen.Bethesda.Plugins.Records.Mapping; +using Mutagen.Bethesda.Plugins.Aspects; +using Loqui; + +namespace Mutagen.Bethesda.Starfield +{ + internal class StarfieldAspectInterfaceMapping : IInterfaceMapping + { + public IReadOnlyDictionary InterfaceToObjectTypes { get; } + + public GameCategory GameCategory => GameCategory.Starfield; + + public StarfieldAspectInterfaceMapping() + { + var dict = new Dictionary(); + dict[typeof(IModeled)] = new InterfaceMappingResult(true, new ILoquiRegistration[] + { + Weapon_Registration.Instance, + }); + dict[typeof(IModeledGetter)] = dict[typeof(IModeled)] with { Setter = false }; + InterfaceToObjectTypes = dict; + } + } +} + diff --git a/Mutagen.Bethesda.Starfield/Interfaces/Aspect/IModeled.cs b/Mutagen.Bethesda.Starfield/Interfaces/Aspect/IModeled.cs new file mode 100644 index 0000000000..ce70e2528d --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Interfaces/Aspect/IModeled.cs @@ -0,0 +1,19 @@ +using Mutagen.Bethesda.Plugins.Records; + +namespace Mutagen.Bethesda.Starfield; + +/// +/// Common interface for records that have a model +/// +public interface IModeled : IModeledGetter, IMajorRecordQueryable +{ + new Model? Model { get; set; } +} + +/// +/// Common interface for records that have a model +/// +public interface IModeledGetter : IMajorRecordQueryableGetter +{ + IModelGetter? Model { get; } +} \ No newline at end of file diff --git a/Mutagen.Bethesda.Starfield/Interfaces/InheritingInterfaceMapping_Generated.cs b/Mutagen.Bethesda.Starfield/Interfaces/InheritingInterfaceMapping_Generated.cs new file mode 100644 index 0000000000..eec3e2e566 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Interfaces/InheritingInterfaceMapping_Generated.cs @@ -0,0 +1,25 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Autogenerated by Loqui. Do not manually change. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ +using System; +using System.Collections.Generic; +using Mutagen.Bethesda.Plugins.Records.Mapping; +using Loqui; + +namespace Mutagen.Bethesda.Starfield; + +internal class StarfieldInheritingInterfaceMapping : IInterfaceMapping +{ + public IReadOnlyDictionary InterfaceToObjectTypes { get; } + + public GameCategory GameCategory => GameCategory.Starfield; + + public StarfieldInheritingInterfaceMapping() + { + var dict = new Dictionary(); + InterfaceToObjectTypes = dict; + } +} + diff --git a/Mutagen.Bethesda.Starfield/Interfaces/IsolatedAbstractInterfaceMapping_Generated.cs b/Mutagen.Bethesda.Starfield/Interfaces/IsolatedAbstractInterfaceMapping_Generated.cs new file mode 100644 index 0000000000..e9f61e1c46 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Interfaces/IsolatedAbstractInterfaceMapping_Generated.cs @@ -0,0 +1,25 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Autogenerated by Loqui. Do not manually change. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ +using System; +using System.Collections.Generic; +using Mutagen.Bethesda.Plugins.Records.Mapping; +using Loqui; + +namespace Mutagen.Bethesda.Starfield; + +internal class StarfieldIsolatedAbstractInterfaceMapping : IInterfaceMapping +{ + public IReadOnlyDictionary InterfaceToObjectTypes { get; } + + public GameCategory GameCategory => GameCategory.Starfield; + + public StarfieldIsolatedAbstractInterfaceMapping() + { + var dict = new Dictionary(); + InterfaceToObjectTypes = dict; + } +} + diff --git a/Mutagen.Bethesda.Starfield/Mutagen.Bethesda.Starfield.csproj b/Mutagen.Bethesda.Starfield/Mutagen.Bethesda.Starfield.csproj index e19dbe1f23..b8f44ee589 100644 --- a/Mutagen.Bethesda.Starfield/Mutagen.Bethesda.Starfield.csproj +++ b/Mutagen.Bethesda.Starfield/Mutagen.Bethesda.Starfield.csproj @@ -1,34 +1,119 @@ + - - - net6.0;net7.0 - true - true - Noggog - Mutagen - Mutagen - A C# library for manipulating, creating, and analyzing Starfield mods - 2021 - GPL-3.0-only - https://github.com/Mutagen-Modding/Mutagen - https://github.com/Mutagen-Modding/Mutagen - False - true - nullable - true - preview - - - Mutagen.Bethesda.Starfield.xml - embedded - true - - - - - - - - - - + + net6.0;net7.0 + true + true + Noggog + Mutagen + Mutagen + A C# library for manipulating, creating, and analyzing Starfield mods + 2021 + GPL-3.0-only + https://github.com/Mutagen-Modding/Mutagen + https://github.com/Mutagen-Modding/Mutagen + False + true + nullable + true + preview + + + Mutagen.Bethesda.Starfield.xml + embedded + true + + + + + + + + + + + none + None + + + none + None + + + none + None + + + none + None + + + none + None + + + + + + + cs + content + Compile + + + Model.xml + + + Model.xml + + + StarfieldModHeader.xml + + + StarfieldGroup.xml + + + StarfieldGroup.xml + + + StarfieldGroup.xml + + + StarfieldMajorRecord.xml + + + StarfieldMajorRecord.xml + + + StarfieldMod.xml + + + StarfieldModHeader.xml + + + StarfieldModHeader.xml + + + StarfieldMod.xml + + + + + + + + + + + + Npc.xml + + + Race.xml + + + Weapon.xml + + + + \ No newline at end of file diff --git a/Mutagen.Bethesda.Starfield/Mutagen.Bethesda.Starfield.xml b/Mutagen.Bethesda.Starfield/Mutagen.Bethesda.Starfield.xml new file mode 100644 index 0000000000..6050a81333 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Mutagen.Bethesda.Starfield.xml @@ -0,0 +1,304 @@ + + + + Mutagen.Bethesda.Starfield + + + + + Different categories of Group records + + + + + Common interface for records that have a model + + + + + Common interface for records that have a model + + + + + Implemented by: [Model] + + + + + Implemented by: [Model] + + + + + Implemented by: [Model] + + + + + Implemented by: [Npc, Race, Weapon] + + + + + Implemented by: [Npc, Race, Weapon] + + + + + Implemented by: [Npc, Race, Weapon] + + + + + Creates a Link Cache using a single mod as its link target.
+ Modification of the target Mod is not safe. Internal caches can become incorrect if + modifications occur on content already cached. +
+ Mod to construct the package relative to + LinkPackage attached to given mod +
+ + + Creates a Link Cache using a single mod as its link target. Mod is allowed to be modified afterwards, but + this comes at a performance cost of not allowing much caching to be done. If the mod is not expected to + be modified afterwards, use ImmutableModLinkCache instead.
+
+ Mod to construct the package relative to + LinkPackage attached to given mod +
+ + + Creates a new linking package relative to a load order.
+ Will resolve links to the highest overriding mod containing the record being sought.
+ 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. +
+ LoadOrder to construct the package relative to + LinkPackage attached to given LoadOrder +
+ + + Creates a new linking package relative to a load order.
+ Will resolve links to the highest overriding mod containing the record being sought.
+ 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. +
+ LoadOrder to construct the package relative to + LinkPackage attached to given LoadOrder +
+ + + Creates a new linking package relative to a load order.
+ Will resolve links to the highest overriding mod containing the record being sought.
+ 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. +
+ LoadOrder to construct the package relative to + LinkPackage attached to given LoadOrder +
+ + + Creates a new linking package relative to a load order.
+ Will resolve links to the highest overriding mod containing the record being sought.
+ 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. +
+ LoadOrder to construct the package relative to + LinkPackage attached to given LoadOrder +
+ + + 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. + + LoadOrderCache to use as the immutable base + Set of mods to place at the end of the load order, which are allowed to be modified afterwards + LinkPackage attached to given LoadOrder + + + + 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. + + LoadOrderCache to use as the immutable base + Set of mods to place at the end of the load order, which are allowed to be modified afterwards + LinkPackage attached to given LoadOrder + + + + 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. + + LoadOrderCache to use as the immutable base + Set of mods to place at the end of the load order, which are allowed to be modified afterwards + LinkPackage attached to given LoadOrder + + + + Scope a load order query to Npc + + ModListings to query + A typed object to do further queries on Npc + + + + Scope a load order query to Npc + + Mods to query + A typed object to do further queries on Npc + + + + Scope a load order query to Race + + ModListings to query + A typed object to do further queries on Race + + + + Scope a load order query to Race + + Mods to query + A typed object to do further queries on Race + + + + Scope a load order query to StarfieldMajorRecord + + ModListings to query + A typed object to do further queries on StarfieldMajorRecord + + + + Scope a load order query to StarfieldMajorRecord + + Mods to query + A typed object to do further queries on StarfieldMajorRecord + + + + Scope a load order query to Weapon + + ModListings to query + A typed object to do further queries on Weapon + + + + Scope a load order query to Weapon + + Mods to query + A typed object to do further queries on Weapon + + + + Aspects: IModeled + + + + + Aspects: IModeled + + + + + Aspects: IModeledGetter + + + + + Gets whether the current repository is dirty. + + + + + => @"" + + + + + => @"https://github.com/Mutagen-Modding/Mutagen.git" + + + + + => @"dev" + + + + + => @"bcc9c618d" + + + + + => @"bcc9c618d975da07e9d1c20a7309a81ecc55da1a" + + + + + => @"2023-08-30T20:57:12-05:00" + + + + + => @"37" + + + + + => @"0.42-37-gbcc9c618d" + + + + + => @"0.42" + + + + + => @"0" + + + + + => @"42" + + + + + => @"0" + + + + + => @"0" + + + + + => @"42" + + + + + => @"37" + + + + + => @"" + + + + + => @"" + + + + + => @"Tag" + + +
+
diff --git a/Mutagen.Bethesda.Starfield/Records/Common Subrecords/Model.xml b/Mutagen.Bethesda.Starfield/Records/Common Subrecords/Model.xml new file mode 100644 index 0000000000..d4051b0135 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/Common Subrecords/Model.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Mutagen.Bethesda.Starfield/Records/Common Subrecords/Model_Generated.cs b/Mutagen.Bethesda.Starfield/Records/Common Subrecords/Model_Generated.cs new file mode 100644 index 0000000000..fac32f98b3 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/Common Subrecords/Model_Generated.cs @@ -0,0 +1,1240 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Autogenerated by Loqui. Do not manually change. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ +#region Usings +using Loqui; +using Loqui.Interfaces; +using Loqui.Internal; +using Mutagen.Bethesda.Binary; +using Mutagen.Bethesda.Plugins; +using Mutagen.Bethesda.Plugins.Binary.Headers; +using Mutagen.Bethesda.Plugins.Binary.Overlay; +using Mutagen.Bethesda.Plugins.Binary.Streams; +using Mutagen.Bethesda.Plugins.Binary.Translations; +using Mutagen.Bethesda.Plugins.Exceptions; +using Mutagen.Bethesda.Plugins.Internals; +using Mutagen.Bethesda.Plugins.Records; +using Mutagen.Bethesda.Plugins.Records.Internals; +using Mutagen.Bethesda.Plugins.Records.Mapping; +using Mutagen.Bethesda.Starfield; +using Mutagen.Bethesda.Starfield.Internals; +using Mutagen.Bethesda.Translations.Binary; +using Noggog; +using Noggog.StructuredStrings; +using Noggog.StructuredStrings.CSharp; +using RecordTypeInts = Mutagen.Bethesda.Starfield.Internals.RecordTypeInts; +using RecordTypes = Mutagen.Bethesda.Starfield.Internals.RecordTypes; +using System.Buffers.Binary; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Reactive.Disposables; +using System.Reactive.Linq; +#endregion + +#nullable enable +namespace Mutagen.Bethesda.Starfield +{ + #region Class + public partial class Model : + SimpleModel, + IEquatable, + ILoquiObjectSetter, + IModel + { + #region Ctor + public Model() + { + CustomCtor(); + } + partial void CustomCtor(); + #endregion + + #region Unknown + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected MemorySlice? _Unknown; + public MemorySlice? Unknown + { + get => this._Unknown; + set => this._Unknown = value; + } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ReadOnlyMemorySlice? IModelGetter.Unknown => this.Unknown; + #endregion + + #region To String + + public override void Print( + StructuredStringBuilder sb, + string? name = null) + { + ModelMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is not IModelGetter rhs) return false; + return ((ModelCommon)((IModelGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IModelGetter? obj) + { + return ((ModelCommon)((IModelGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((ModelCommon)((IModelGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + #region Mask + public new class Mask : + SimpleModel.Mask, + IEquatable>, + IMask + { + #region Ctors + public Mask(TItem initialValue) + : base(initialValue) + { + this.Unknown = initialValue; + } + + public Mask( + TItem File, + TItem Unknown) + : base(File: File) + { + this.Unknown = Unknown; + } + + #pragma warning disable CS8618 + protected Mask() + { + } + #pragma warning restore CS8618 + + #endregion + + #region Members + public TItem Unknown; + #endregion + + #region Equals + public override bool Equals(object? obj) + { + if (!(obj is Mask rhs)) return false; + return Equals(rhs); + } + + public bool Equals(Mask? rhs) + { + if (rhs == null) return false; + if (!base.Equals(rhs)) return false; + if (!object.Equals(this.Unknown, rhs.Unknown)) return false; + return true; + } + public override int GetHashCode() + { + var hash = new HashCode(); + hash.Add(this.Unknown); + hash.Add(base.GetHashCode()); + return hash.ToHashCode(); + } + + #endregion + + #region All + public override bool All(Func eval) + { + if (!base.All(eval)) return false; + if (!eval(this.Unknown)) return false; + return true; + } + #endregion + + #region Any + public override bool Any(Func eval) + { + if (base.Any(eval)) return true; + if (eval(this.Unknown)) return true; + return false; + } + #endregion + + #region Translate + public new Mask Translate(Func eval) + { + var ret = new Model.Mask(); + this.Translate_InternalFill(ret, eval); + return ret; + } + + protected void Translate_InternalFill(Mask obj, Func eval) + { + base.Translate_InternalFill(obj, eval); + obj.Unknown = eval(this.Unknown); + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public string Print(Model.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print(sb, printMask); + return sb.ToString(); + } + + public void Print(StructuredStringBuilder sb, Model.Mask? printMask = null) + { + sb.AppendLine($"{nameof(Model.Mask)} =>"); + using (sb.Brace()) + { + if (printMask?.Unknown ?? true) + { + sb.AppendItem(Unknown, "Unknown"); + } + } + } + #endregion + + } + + public new class ErrorMask : + SimpleModel.ErrorMask, + IErrorMask + { + #region Members + public Exception? Unknown; + #endregion + + #region IErrorMask + public override object? GetNthMask(int index) + { + Model_FieldIndex enu = (Model_FieldIndex)index; + switch (enu) + { + case Model_FieldIndex.Unknown: + return Unknown; + default: + return base.GetNthMask(index); + } + } + + public override void SetNthException(int index, Exception ex) + { + Model_FieldIndex enu = (Model_FieldIndex)index; + switch (enu) + { + case Model_FieldIndex.Unknown: + this.Unknown = ex; + break; + default: + base.SetNthException(index, ex); + break; + } + } + + public override void SetNthMask(int index, object obj) + { + Model_FieldIndex enu = (Model_FieldIndex)index; + switch (enu) + { + case Model_FieldIndex.Unknown: + this.Unknown = (Exception?)obj; + break; + default: + base.SetNthMask(index, obj); + break; + } + } + + public override bool IsInError() + { + if (Overall != null) return true; + if (Unknown != null) return true; + return false; + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public override void Print(StructuredStringBuilder sb, string? name = null) + { + sb.AppendLine($"{(name ?? "ErrorMask")} =>"); + using (sb.Brace()) + { + if (this.Overall != null) + { + sb.AppendLine("Overall =>"); + using (sb.Brace()) + { + sb.AppendLine($"{this.Overall}"); + } + } + PrintFillInternal(sb); + } + } + protected override void PrintFillInternal(StructuredStringBuilder sb) + { + base.PrintFillInternal(sb); + { + sb.AppendItem(Unknown, "Unknown"); + } + } + #endregion + + #region Combine + public ErrorMask Combine(ErrorMask? rhs) + { + if (rhs == null) return this; + var ret = new ErrorMask(); + ret.Unknown = this.Unknown.Combine(rhs.Unknown); + return ret; + } + public static ErrorMask? Combine(ErrorMask? lhs, ErrorMask? rhs) + { + if (lhs != null && rhs != null) return lhs.Combine(rhs); + return lhs ?? rhs; + } + #endregion + + #region Factory + public static new ErrorMask Factory(ErrorMaskBuilder errorMask) + { + return new ErrorMask(); + } + #endregion + + } + public new class TranslationMask : + SimpleModel.TranslationMask, + ITranslationMask + { + #region Members + public bool Unknown; + #endregion + + #region Ctors + public TranslationMask( + bool defaultOn, + bool onOverall = true) + : base(defaultOn, onOverall) + { + this.Unknown = defaultOn; + } + + #endregion + + protected override void GetCrystal(List<(bool On, TranslationCrystal? SubCrystal)> ret) + { + base.GetCrystal(ret); + ret.Add((Unknown, null)); + } + + public static implicit operator TranslationMask(bool defaultOn) + { + return new TranslationMask(defaultOn: defaultOn, onOverall: defaultOn); + } + + } + #endregion + + #region Binary Translation + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected override object BinaryWriteTranslator => ModelBinaryWriteTranslation.Instance; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((ModelBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + #region Binary Create + public new static Model CreateFromBinary( + MutagenFrame frame, + TypedParseParams translationParams = default) + { + var ret = new Model(); + ((ModelSetterCommon)((IModelGetter)ret).CommonSetterInstance()!).CopyInFromBinary( + item: ret, + frame: frame, + translationParams: translationParams); + return ret; + } + + #endregion + + public static bool TryCreateFromBinary( + MutagenFrame frame, + out Model item, + TypedParseParams translationParams = default) + { + var startPos = frame.Position; + item = CreateFromBinary( + frame: frame, + translationParams: translationParams); + return startPos != frame.Position; + } + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + void IClearable.Clear() + { + ((ModelSetterCommon)((IModelGetter)this).CommonSetterInstance()!).Clear(this); + } + + internal static new Model GetNew() + { + return new Model(); + } + + } + #endregion + + #region Interface + public partial interface IModel : + ILoquiObjectSetter, + IModelGetter, + ISimpleModel + { + new MemorySlice? Unknown { get; set; } + } + + public partial interface IModelGetter : + ISimpleModelGetter, + IBinaryItem, + ILoquiObject + { + static new ILoquiRegistration StaticRegistration => Model_Registration.Instance; + ReadOnlyMemorySlice? Unknown { get; } + + } + + #endregion + + #region Common MixIn + public static partial class ModelMixIn + { + public static void Clear(this IModel item) + { + ((ModelSetterCommon)((IModelGetter)item).CommonSetterInstance()!).Clear(item: item); + } + + public static Model.Mask GetEqualsMask( + this IModelGetter item, + IModelGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + return ((ModelCommon)((IModelGetter)item).CommonInstance()!).GetEqualsMask( + item: item, + rhs: rhs, + include: include); + } + + public static string Print( + this IModelGetter item, + string? name = null, + Model.Mask? printMask = null) + { + return ((ModelCommon)((IModelGetter)item).CommonInstance()!).Print( + item: item, + name: name, + printMask: printMask); + } + + public static void Print( + this IModelGetter item, + StructuredStringBuilder sb, + string? name = null, + Model.Mask? printMask = null) + { + ((ModelCommon)((IModelGetter)item).CommonInstance()!).Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + } + + public static bool Equals( + this IModelGetter item, + IModelGetter rhs, + Model.TranslationMask? equalsMask = null) + { + return ((ModelCommon)((IModelGetter)item).CommonInstance()!).Equals( + lhs: item, + rhs: rhs, + equalsMask: equalsMask?.GetCrystal()); + } + + public static void DeepCopyIn( + this IModel lhs, + IModelGetter rhs, + out Model.ErrorMask errorMask, + Model.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + ((ModelSetterTranslationCommon)((IModelGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + errorMask = Model.ErrorMask.Factory(errorMaskBuilder); + } + + public static void DeepCopyIn( + this IModel lhs, + IModelGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask) + { + ((ModelSetterTranslationCommon)((IModelGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: false); + } + + public static Model DeepCopy( + this IModelGetter item, + Model.TranslationMask? copyMask = null) + { + return ((ModelSetterTranslationCommon)((IModelGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask); + } + + public static Model DeepCopy( + this IModelGetter item, + out Model.ErrorMask errorMask, + Model.TranslationMask? copyMask = null) + { + return ((ModelSetterTranslationCommon)((IModelGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: out errorMask); + } + + public static Model DeepCopy( + this IModelGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + return ((ModelSetterTranslationCommon)((IModelGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: errorMask); + } + + #region Binary Translation + public static void CopyInFromBinary( + this IModel item, + MutagenFrame frame, + TypedParseParams translationParams = default) + { + ((ModelSetterCommon)((IModelGetter)item).CommonSetterInstance()!).CopyInFromBinary( + item: item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + #region Field Index + internal enum Model_FieldIndex + { + File = 0, + Unknown = 1, + } + #endregion + + #region Registration + internal partial class Model_Registration : ILoquiRegistration + { + public static readonly Model_Registration Instance = new Model_Registration(); + + public static ProtocolKey ProtocolKey => ProtocolDefinition_Starfield.ProtocolKey; + + public static readonly ObjectKey ObjectKey = new ObjectKey( + protocolKey: ProtocolDefinition_Starfield.ProtocolKey, + msgID: 71, + version: 0); + + public const string GUID = "0ad037a7-7bd0-4b69-976b-b5c7869c325f"; + + public const ushort AdditionalFieldCount = 1; + + public const ushort FieldCount = 2; + + public static readonly Type MaskType = typeof(Model.Mask<>); + + public static readonly Type ErrorMaskType = typeof(Model.ErrorMask); + + public static readonly Type ClassType = typeof(Model); + + public static readonly Type GetterType = typeof(IModelGetter); + + public static readonly Type? InternalGetterType = null; + + public static readonly Type SetterType = typeof(IModel); + + public static readonly Type? InternalSetterType = null; + + public const string FullName = "Mutagen.Bethesda.Starfield.Model"; + + public const string Name = "Model"; + + public const string Namespace = "Mutagen.Bethesda.Starfield"; + + public const byte GenericCount = 0; + + public static readonly Type? GenericRegistrationType = null; + + public static readonly RecordType TriggeringRecordType = RecordTypes.MODL; + public static RecordTriggerSpecs TriggerSpecs => _recordSpecs.Value; + private static readonly Lazy _recordSpecs = new Lazy(() => + { + var triggers = RecordCollection.Factory(RecordTypes.MODL); + var all = RecordCollection.Factory( + RecordTypes.MODL, + RecordTypes.MODF); + return new RecordTriggerSpecs(allRecordTypes: all, triggeringRecordTypes: triggers); + }); + public static readonly Type BinaryWriteTranslation = typeof(ModelBinaryWriteTranslation); + #region Interface + ProtocolKey ILoquiRegistration.ProtocolKey => ProtocolKey; + ObjectKey ILoquiRegistration.ObjectKey => ObjectKey; + string ILoquiRegistration.GUID => GUID; + ushort ILoquiRegistration.FieldCount => FieldCount; + ushort ILoquiRegistration.AdditionalFieldCount => AdditionalFieldCount; + Type ILoquiRegistration.MaskType => MaskType; + Type ILoquiRegistration.ErrorMaskType => ErrorMaskType; + Type ILoquiRegistration.ClassType => ClassType; + Type ILoquiRegistration.SetterType => SetterType; + Type? ILoquiRegistration.InternalSetterType => InternalSetterType; + Type ILoquiRegistration.GetterType => GetterType; + Type? ILoquiRegistration.InternalGetterType => InternalGetterType; + string ILoquiRegistration.FullName => FullName; + string ILoquiRegistration.Name => Name; + string ILoquiRegistration.Namespace => Namespace; + byte ILoquiRegistration.GenericCount => GenericCount; + Type? ILoquiRegistration.GenericRegistrationType => GenericRegistrationType; + ushort? ILoquiRegistration.GetNameIndex(StringCaseAgnostic name) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsEnumerable(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsLoqui(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsSingleton(ushort index) => throw new NotImplementedException(); + string ILoquiRegistration.GetNthName(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsNthDerivative(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsProtected(ushort index) => throw new NotImplementedException(); + Type ILoquiRegistration.GetNthType(ushort index) => throw new NotImplementedException(); + #endregion + + } + #endregion + + #region Common + internal partial class ModelSetterCommon : SimpleModelSetterCommon + { + public new static readonly ModelSetterCommon Instance = new ModelSetterCommon(); + + partial void ClearPartial(); + + public void Clear(IModel item) + { + ClearPartial(); + item.Unknown = default; + base.Clear(item); + } + + public override void Clear(ISimpleModel item) + { + Clear(item: (IModel)item); + } + + #region Mutagen + public void RemapLinks(IModel obj, IReadOnlyDictionary mapping) + { + } + + #endregion + + #region Binary Translation + public virtual void CopyInFromBinary( + IModel item, + MutagenFrame frame, + TypedParseParams translationParams) + { + PluginUtilityTranslation.SubrecordParse( + record: item, + frame: frame, + translationParams: translationParams, + fillTyped: ModelBinaryCreateTranslation.FillBinaryRecordTypes); + } + + public override void CopyInFromBinary( + ISimpleModel item, + MutagenFrame frame, + TypedParseParams translationParams) + { + CopyInFromBinary( + item: (Model)item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + internal partial class ModelCommon : SimpleModelCommon + { + public new static readonly ModelCommon Instance = new ModelCommon(); + + public Model.Mask GetEqualsMask( + IModelGetter item, + IModelGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + var ret = new Model.Mask(false); + ((ModelCommon)((IModelGetter)item).CommonInstance()!).FillEqualsMask( + item: item, + rhs: rhs, + ret: ret, + include: include); + return ret; + } + + public void FillEqualsMask( + IModelGetter item, + IModelGetter rhs, + Model.Mask ret, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + ret.Unknown = MemorySliceExt.SequenceEqual(item.Unknown, rhs.Unknown); + base.FillEqualsMask(item, rhs, ret, include); + } + + public string Print( + IModelGetter item, + string? name = null, + Model.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + return sb.ToString(); + } + + public void Print( + IModelGetter item, + StructuredStringBuilder sb, + string? name = null, + Model.Mask? printMask = null) + { + if (name == null) + { + sb.AppendLine($"Model =>"); + } + else + { + sb.AppendLine($"{name} (Model) =>"); + } + using (sb.Brace()) + { + ToStringFields( + item: item, + sb: sb, + printMask: printMask); + } + } + + protected static void ToStringFields( + IModelGetter item, + StructuredStringBuilder sb, + Model.Mask? printMask = null) + { + SimpleModelCommon.ToStringFields( + item: item, + sb: sb, + printMask: printMask); + if ((printMask?.Unknown ?? true) + && item.Unknown is {} UnknownItem) + { + sb.AppendLine($"Unknown => {SpanExt.ToHexString(UnknownItem)}"); + } + } + + public static Model_FieldIndex ConvertFieldIndex(SimpleModel_FieldIndex index) + { + switch (index) + { + case SimpleModel_FieldIndex.File: + return (Model_FieldIndex)((int)index); + default: + throw new ArgumentException($"Index is out of range: {index.ToStringFast()}"); + } + } + + #region Equals and Hash + public virtual bool Equals( + IModelGetter? lhs, + IModelGetter? rhs, + TranslationCrystal? equalsMask) + { + if (!EqualsMaskHelper.RefEquality(lhs, rhs, out var isEqual)) return isEqual; + if (!base.Equals((ISimpleModelGetter)lhs, (ISimpleModelGetter)rhs, equalsMask)) return false; + if ((equalsMask?.GetShouldTranslate((int)Model_FieldIndex.Unknown) ?? true)) + { + if (!MemorySliceExt.SequenceEqual(lhs.Unknown, rhs.Unknown)) return false; + } + return true; + } + + public override bool Equals( + ISimpleModelGetter? lhs, + ISimpleModelGetter? rhs, + TranslationCrystal? equalsMask) + { + return Equals( + lhs: (IModelGetter?)lhs, + rhs: rhs as IModelGetter, + equalsMask: equalsMask); + } + + public virtual int GetHashCode(IModelGetter item) + { + var hash = new HashCode(); + if (item.Unknown is {} UnknownItem) + { + hash.Add(UnknownItem); + } + hash.Add(base.GetHashCode()); + return hash.ToHashCode(); + } + + public override int GetHashCode(ISimpleModelGetter item) + { + return GetHashCode(item: (IModelGetter)item); + } + + #endregion + + + public override object GetNew() + { + return Model.GetNew(); + } + + #region Mutagen + public IEnumerable EnumerateFormLinks(IModelGetter obj) + { + yield break; + } + + #endregion + + } + internal partial class ModelSetterTranslationCommon : SimpleModelSetterTranslationCommon + { + public new static readonly ModelSetterTranslationCommon Instance = new ModelSetterTranslationCommon(); + + #region DeepCopyIn + public void DeepCopyIn( + IModel item, + IModelGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + base.DeepCopyIn( + (ISimpleModel)item, + (ISimpleModelGetter)rhs, + errorMask, + copyMask, + deepCopy: deepCopy); + if ((copyMask?.GetShouldTranslate((int)Model_FieldIndex.Unknown) ?? true)) + { + if(rhs.Unknown is {} Unknownrhs) + { + item.Unknown = Unknownrhs.ToArray(); + } + else + { + item.Unknown = default; + } + } + } + + + public override void DeepCopyIn( + ISimpleModel item, + ISimpleModelGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (IModel)item, + rhs: (IModelGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + #endregion + + public Model DeepCopy( + IModelGetter item, + Model.TranslationMask? copyMask = null) + { + Model ret = (Model)((ModelCommon)((IModelGetter)item).CommonInstance()!).GetNew(); + ((ModelSetterTranslationCommon)((IModelGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: null, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + return ret; + } + + public Model DeepCopy( + IModelGetter item, + out Model.ErrorMask errorMask, + Model.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + Model ret = (Model)((ModelCommon)((IModelGetter)item).CommonInstance()!).GetNew(); + ((ModelSetterTranslationCommon)((IModelGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + ret, + item, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + errorMask = Model.ErrorMask.Factory(errorMaskBuilder); + return ret; + } + + public Model DeepCopy( + IModelGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + Model ret = (Model)((ModelCommon)((IModelGetter)item).CommonInstance()!).GetNew(); + ((ModelSetterTranslationCommon)((IModelGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: true); + return ret; + } + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + public partial class Model + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => Model_Registration.Instance; + public new static ILoquiRegistration StaticRegistration => Model_Registration.Instance; + [DebuggerStepThrough] + protected override object CommonInstance() => ModelCommon.Instance; + [DebuggerStepThrough] + protected override object CommonSetterInstance() + { + return ModelSetterCommon.Instance; + } + [DebuggerStepThrough] + protected override object CommonSetterTranslationInstance() => ModelSetterTranslationCommon.Instance; + + #endregion + + } +} + +#region Modules +#region Binary Translation +namespace Mutagen.Bethesda.Starfield +{ + public partial class ModelBinaryWriteTranslation : + SimpleModelBinaryWriteTranslation, + IBinaryWriteTranslator + { + public new static readonly ModelBinaryWriteTranslation Instance = new(); + + public static void WriteRecordTypes( + IModelGetter item, + MutagenWriter writer, + TypedWriteParams translationParams) + { + SimpleModelBinaryWriteTranslation.WriteRecordTypes( + item: item, + writer: writer, + translationParams: translationParams); + ByteArrayBinaryTranslation.Instance.Write( + writer: writer, + item: item.Unknown, + header: translationParams.ConvertToCustom(RecordTypes.MODF)); + } + + public void Write( + MutagenWriter writer, + IModelGetter item, + TypedWriteParams translationParams) + { + WriteRecordTypes( + item: item, + writer: writer, + translationParams: translationParams); + } + + public override void Write( + MutagenWriter writer, + object item, + TypedWriteParams translationParams = default) + { + Write( + item: (IModelGetter)item, + writer: writer, + translationParams: translationParams); + } + + public override void Write( + MutagenWriter writer, + ISimpleModelGetter item, + TypedWriteParams translationParams) + { + Write( + item: (IModelGetter)item, + writer: writer, + translationParams: translationParams); + } + + } + + internal partial class ModelBinaryCreateTranslation : SimpleModelBinaryCreateTranslation + { + public new static readonly ModelBinaryCreateTranslation Instance = new ModelBinaryCreateTranslation(); + + public static ParseResult FillBinaryRecordTypes( + IModel item, + MutagenFrame frame, + PreviousParse lastParsed, + Dictionary? recordParseCount, + RecordType nextRecordType, + int contentLength, + TypedParseParams translationParams = default) + { + nextRecordType = translationParams.ConvertToStandard(nextRecordType); + switch (nextRecordType.TypeInt) + { + case RecordTypeInts.MODF: + { + frame.Position += frame.MetaData.Constants.SubConstants.HeaderLength; + item.Unknown = ByteArrayBinaryTranslation.Instance.Parse(reader: frame.SpawnWithLength(contentLength)); + return (int)Model_FieldIndex.Unknown; + } + default: + return SimpleModelBinaryCreateTranslation.FillBinaryRecordTypes( + item: item, + frame: frame, + lastParsed: lastParsed, + recordParseCount: recordParseCount, + nextRecordType: nextRecordType, + contentLength: contentLength, + translationParams: translationParams.WithNoConverter()); + } + } + + } + +} +namespace Mutagen.Bethesda.Starfield +{ + #region Binary Write Mixins + public static class ModelBinaryTranslationMixIn + { + } + #endregion + + +} +namespace Mutagen.Bethesda.Starfield +{ + internal partial class ModelBinaryOverlay : + SimpleModelBinaryOverlay, + IModelGetter + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => Model_Registration.Instance; + public new static ILoquiRegistration StaticRegistration => Model_Registration.Instance; + [DebuggerStepThrough] + protected override object CommonInstance() => ModelCommon.Instance; + [DebuggerStepThrough] + protected override object CommonSetterTranslationInstance() => ModelSetterTranslationCommon.Instance; + + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected override object BinaryWriteTranslator => ModelBinaryWriteTranslation.Instance; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((ModelBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + + #region Unknown + private int? _UnknownLocation; + public ReadOnlyMemorySlice? Unknown => _UnknownLocation.HasValue ? HeaderTranslation.ExtractSubrecordMemory(_recordData, _UnknownLocation.Value, _package.MetaData.Constants) : default(ReadOnlyMemorySlice?); + #endregion + partial void CustomFactoryEnd( + OverlayStream stream, + int finalPos, + int offset); + + partial void CustomCtor(); + protected ModelBinaryOverlay( + MemoryPair memoryPair, + BinaryOverlayFactoryPackage package) + : base( + memoryPair: memoryPair, + package: package) + { + this.CustomCtor(); + } + + public static IModelGetter ModelFactory( + OverlayStream stream, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + stream = ExtractTypelessSubrecordRecordMemory( + stream: stream, + meta: package.MetaData.Constants, + translationParams: translationParams, + memoryPair: out var memoryPair, + offset: out var offset, + finalPos: out var finalPos); + var ret = new ModelBinaryOverlay( + memoryPair: memoryPair, + package: package); + ret.FillTypelessSubrecordTypes( + stream: stream, + finalPos: stream.Length, + offset: offset, + translationParams: translationParams, + fill: ret.FillRecordType); + return ret; + } + + public static IModelGetter ModelFactory( + ReadOnlyMemorySlice slice, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + return ModelFactory( + stream: new OverlayStream(slice, package), + package: package, + translationParams: translationParams); + } + + public override ParseResult FillRecordType( + OverlayStream stream, + int finalPos, + int offset, + RecordType type, + PreviousParse lastParsed, + Dictionary? recordParseCount, + TypedParseParams translationParams = default) + { + type = translationParams.ConvertToStandard(type); + switch (type.TypeInt) + { + case RecordTypeInts.MODF: + { + _UnknownLocation = (stream.Position - offset); + return (int)Model_FieldIndex.Unknown; + } + default: + return base.FillRecordType( + stream: stream, + finalPos: finalPos, + offset: offset, + type: type, + lastParsed: lastParsed, + recordParseCount: recordParseCount, + translationParams: translationParams.WithNoConverter()); + } + } + #region To String + + public override void Print( + StructuredStringBuilder sb, + string? name = null) + { + ModelMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is not IModelGetter rhs) return false; + return ((ModelCommon)((IModelGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IModelGetter? obj) + { + return ((ModelCommon)((IModelGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((ModelCommon)((IModelGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + } + +} +#endregion + +#endregion + diff --git a/Mutagen.Bethesda.Starfield/Records/Common Subrecords/SimpleModel_Generated.cs b/Mutagen.Bethesda.Starfield/Records/Common Subrecords/SimpleModel_Generated.cs new file mode 100644 index 0000000000..16ef1230bc --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/Common Subrecords/SimpleModel_Generated.cs @@ -0,0 +1,1226 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Autogenerated by Loqui. Do not manually change. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ +#region Usings +using Loqui; +using Loqui.Interfaces; +using Loqui.Internal; +using Mutagen.Bethesda.Assets; +using Mutagen.Bethesda.Binary; +using Mutagen.Bethesda.Plugins; +using Mutagen.Bethesda.Plugins.Assets; +using Mutagen.Bethesda.Plugins.Binary.Headers; +using Mutagen.Bethesda.Plugins.Binary.Overlay; +using Mutagen.Bethesda.Plugins.Binary.Streams; +using Mutagen.Bethesda.Plugins.Binary.Translations; +using Mutagen.Bethesda.Plugins.Cache; +using Mutagen.Bethesda.Plugins.Exceptions; +using Mutagen.Bethesda.Plugins.Internals; +using Mutagen.Bethesda.Plugins.Records; +using Mutagen.Bethesda.Plugins.Records.Internals; +using Mutagen.Bethesda.Plugins.Records.Mapping; +using Mutagen.Bethesda.Starfield.Assets; +using Mutagen.Bethesda.Starfield.Internals; +using Mutagen.Bethesda.Translations.Binary; +using Noggog; +using Noggog.StructuredStrings; +using Noggog.StructuredStrings.CSharp; +using RecordTypeInts = Mutagen.Bethesda.Starfield.Internals.RecordTypeInts; +using RecordTypes = Mutagen.Bethesda.Starfield.Internals.RecordTypes; +using System.Buffers.Binary; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Reactive.Disposables; +using System.Reactive.Linq; +#endregion + +#nullable enable +namespace Mutagen.Bethesda.Starfield +{ + #region Class + /// + /// Implemented by: [Model] + /// + public partial class SimpleModel : + IEquatable, + ILoquiObjectSetter, + ISimpleModel + { + #region Ctor + public SimpleModel() + { + CustomCtor(); + } + partial void CustomCtor(); + #endregion + + #region File + public AssetLink File { get; set; } = new AssetLink(); + AssetLinkGetter ISimpleModelGetter.File => this.File; + #endregion + + #region To String + + public virtual void Print( + StructuredStringBuilder sb, + string? name = null) + { + SimpleModelMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is not ISimpleModelGetter rhs) return false; + return ((SimpleModelCommon)((ISimpleModelGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(ISimpleModelGetter? obj) + { + return ((SimpleModelCommon)((ISimpleModelGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((SimpleModelCommon)((ISimpleModelGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + #region Mask + public class Mask : + IEquatable>, + IMask + { + #region Ctors + public Mask(TItem File) + { + this.File = File; + } + + #pragma warning disable CS8618 + protected Mask() + { + } + #pragma warning restore CS8618 + + #endregion + + #region Members + public TItem File; + #endregion + + #region Equals + public override bool Equals(object? obj) + { + if (!(obj is Mask rhs)) return false; + return Equals(rhs); + } + + public bool Equals(Mask? rhs) + { + if (rhs == null) return false; + if (!object.Equals(this.File, rhs.File)) return false; + return true; + } + public override int GetHashCode() + { + var hash = new HashCode(); + hash.Add(this.File); + return hash.ToHashCode(); + } + + #endregion + + #region All + public virtual bool All(Func eval) + { + if (!eval(this.File)) return false; + return true; + } + #endregion + + #region Any + public virtual bool Any(Func eval) + { + if (eval(this.File)) return true; + return false; + } + #endregion + + #region Translate + public Mask Translate(Func eval) + { + var ret = new SimpleModel.Mask(); + this.Translate_InternalFill(ret, eval); + return ret; + } + + protected void Translate_InternalFill(Mask obj, Func eval) + { + obj.File = eval(this.File); + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public string Print(SimpleModel.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print(sb, printMask); + return sb.ToString(); + } + + public void Print(StructuredStringBuilder sb, SimpleModel.Mask? printMask = null) + { + sb.AppendLine($"{nameof(SimpleModel.Mask)} =>"); + using (sb.Brace()) + { + if (printMask?.File ?? true) + { + sb.AppendItem(File, "File"); + } + } + } + #endregion + + } + + public class ErrorMask : + IErrorMask, + IErrorMask + { + #region Members + public Exception? Overall { get; set; } + private List? _warnings; + public List Warnings + { + get + { + if (_warnings == null) + { + _warnings = new List(); + } + return _warnings; + } + } + public Exception? File; + #endregion + + #region IErrorMask + public virtual object? GetNthMask(int index) + { + SimpleModel_FieldIndex enu = (SimpleModel_FieldIndex)index; + switch (enu) + { + case SimpleModel_FieldIndex.File: + return File; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public virtual void SetNthException(int index, Exception ex) + { + SimpleModel_FieldIndex enu = (SimpleModel_FieldIndex)index; + switch (enu) + { + case SimpleModel_FieldIndex.File: + this.File = ex; + break; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public virtual void SetNthMask(int index, object obj) + { + SimpleModel_FieldIndex enu = (SimpleModel_FieldIndex)index; + switch (enu) + { + case SimpleModel_FieldIndex.File: + this.File = (Exception?)obj; + break; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public virtual bool IsInError() + { + if (Overall != null) return true; + if (File != null) return true; + return false; + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public virtual void Print(StructuredStringBuilder sb, string? name = null) + { + sb.AppendLine($"{(name ?? "ErrorMask")} =>"); + using (sb.Brace()) + { + if (this.Overall != null) + { + sb.AppendLine("Overall =>"); + using (sb.Brace()) + { + sb.AppendLine($"{this.Overall}"); + } + } + PrintFillInternal(sb); + } + } + protected virtual void PrintFillInternal(StructuredStringBuilder sb) + { + { + sb.AppendItem(File, "File"); + } + } + #endregion + + #region Combine + public ErrorMask Combine(ErrorMask? rhs) + { + if (rhs == null) return this; + var ret = new ErrorMask(); + ret.File = this.File.Combine(rhs.File); + return ret; + } + public static ErrorMask? Combine(ErrorMask? lhs, ErrorMask? rhs) + { + if (lhs != null && rhs != null) return lhs.Combine(rhs); + return lhs ?? rhs; + } + #endregion + + #region Factory + public static ErrorMask Factory(ErrorMaskBuilder errorMask) + { + return new ErrorMask(); + } + #endregion + + } + public class TranslationMask : ITranslationMask + { + #region Members + private TranslationCrystal? _crystal; + public readonly bool DefaultOn; + public bool OnOverall; + public bool File; + #endregion + + #region Ctors + public TranslationMask( + bool defaultOn, + bool onOverall = true) + { + this.DefaultOn = defaultOn; + this.OnOverall = onOverall; + this.File = defaultOn; + } + + #endregion + + public TranslationCrystal GetCrystal() + { + if (_crystal != null) return _crystal; + var ret = new List<(bool On, TranslationCrystal? SubCrystal)>(); + GetCrystal(ret); + _crystal = new TranslationCrystal(ret.ToArray()); + return _crystal; + } + + protected virtual void GetCrystal(List<(bool On, TranslationCrystal? SubCrystal)> ret) + { + ret.Add((File, null)); + } + + public static implicit operator TranslationMask(bool defaultOn) + { + return new TranslationMask(defaultOn: defaultOn, onOverall: defaultOn); + } + + } + #endregion + + #region Mutagen + public IEnumerable EnumerateAssetLinks(AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) => SimpleModelCommon.Instance.EnumerateAssetLinks(this, queryCategories, linkCache, assetType); + public IEnumerable EnumerateListedAssetLinks() => SimpleModelSetterCommon.Instance.EnumerateListedAssetLinks(this); + public void RemapAssetLinks(IReadOnlyDictionary mapping, AssetLinkQuery queryCategories, IAssetLinkCache? linkCache) => SimpleModelSetterCommon.Instance.RemapAssetLinks(this, mapping, linkCache, queryCategories); + public void RemapListedAssetLinks(IReadOnlyDictionary mapping) => SimpleModelSetterCommon.Instance.RemapAssetLinks(this, mapping, null, AssetLinkQuery.Listed); + #endregion + + #region Binary Translation + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected virtual object BinaryWriteTranslator => SimpleModelBinaryWriteTranslation.Instance; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + object IBinaryItem.BinaryWriteTranslator => this.BinaryWriteTranslator; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((SimpleModelBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + #region Binary Create + public static SimpleModel CreateFromBinary( + MutagenFrame frame, + TypedParseParams translationParams = default) + { + var ret = new SimpleModel(); + ((SimpleModelSetterCommon)((ISimpleModelGetter)ret).CommonSetterInstance()!).CopyInFromBinary( + item: ret, + frame: frame, + translationParams: translationParams); + return ret; + } + + #endregion + + public static bool TryCreateFromBinary( + MutagenFrame frame, + out SimpleModel item, + TypedParseParams translationParams = default) + { + var startPos = frame.Position; + item = CreateFromBinary( + frame: frame, + translationParams: translationParams); + return startPos != frame.Position; + } + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + void IClearable.Clear() + { + ((SimpleModelSetterCommon)((ISimpleModelGetter)this).CommonSetterInstance()!).Clear(this); + } + + internal static SimpleModel GetNew() + { + return new SimpleModel(); + } + + } + #endregion + + #region Interface + /// + /// Implemented by: [Model] + /// + public partial interface ISimpleModel : + IAssetLinkContainer, + ILoquiObjectSetter, + ISimpleModelGetter + { + new AssetLink File { get; set; } + } + + /// + /// Implemented by: [Model] + /// + public partial interface ISimpleModelGetter : + ILoquiObject, + IAssetLinkContainerGetter, + IBinaryItem, + ILoquiObject + { + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object CommonInstance(); + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object? CommonSetterInstance(); + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object CommonSetterTranslationInstance(); + static ILoquiRegistration StaticRegistration => SimpleModel_Registration.Instance; + AssetLinkGetter File { get; } + + } + + #endregion + + #region Common MixIn + public static partial class SimpleModelMixIn + { + public static void Clear(this ISimpleModel item) + { + ((SimpleModelSetterCommon)((ISimpleModelGetter)item).CommonSetterInstance()!).Clear(item: item); + } + + public static SimpleModel.Mask GetEqualsMask( + this ISimpleModelGetter item, + ISimpleModelGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + return ((SimpleModelCommon)((ISimpleModelGetter)item).CommonInstance()!).GetEqualsMask( + item: item, + rhs: rhs, + include: include); + } + + public static string Print( + this ISimpleModelGetter item, + string? name = null, + SimpleModel.Mask? printMask = null) + { + return ((SimpleModelCommon)((ISimpleModelGetter)item).CommonInstance()!).Print( + item: item, + name: name, + printMask: printMask); + } + + public static void Print( + this ISimpleModelGetter item, + StructuredStringBuilder sb, + string? name = null, + SimpleModel.Mask? printMask = null) + { + ((SimpleModelCommon)((ISimpleModelGetter)item).CommonInstance()!).Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + } + + public static bool Equals( + this ISimpleModelGetter item, + ISimpleModelGetter rhs, + SimpleModel.TranslationMask? equalsMask = null) + { + return ((SimpleModelCommon)((ISimpleModelGetter)item).CommonInstance()!).Equals( + lhs: item, + rhs: rhs, + equalsMask: equalsMask?.GetCrystal()); + } + + public static void DeepCopyIn( + this ISimpleModel lhs, + ISimpleModelGetter rhs) + { + ((SimpleModelSetterTranslationCommon)((ISimpleModelGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: default, + copyMask: default, + deepCopy: false); + } + + public static void DeepCopyIn( + this ISimpleModel lhs, + ISimpleModelGetter rhs, + SimpleModel.TranslationMask? copyMask = null) + { + ((SimpleModelSetterTranslationCommon)((ISimpleModelGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: default, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + } + + public static void DeepCopyIn( + this ISimpleModel lhs, + ISimpleModelGetter rhs, + out SimpleModel.ErrorMask errorMask, + SimpleModel.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + ((SimpleModelSetterTranslationCommon)((ISimpleModelGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + errorMask = SimpleModel.ErrorMask.Factory(errorMaskBuilder); + } + + public static void DeepCopyIn( + this ISimpleModel lhs, + ISimpleModelGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask) + { + ((SimpleModelSetterTranslationCommon)((ISimpleModelGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: false); + } + + public static SimpleModel DeepCopy( + this ISimpleModelGetter item, + SimpleModel.TranslationMask? copyMask = null) + { + return ((SimpleModelSetterTranslationCommon)((ISimpleModelGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask); + } + + public static SimpleModel DeepCopy( + this ISimpleModelGetter item, + out SimpleModel.ErrorMask errorMask, + SimpleModel.TranslationMask? copyMask = null) + { + return ((SimpleModelSetterTranslationCommon)((ISimpleModelGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: out errorMask); + } + + public static SimpleModel DeepCopy( + this ISimpleModelGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + return ((SimpleModelSetterTranslationCommon)((ISimpleModelGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: errorMask); + } + + #region Binary Translation + public static void CopyInFromBinary( + this ISimpleModel item, + MutagenFrame frame, + TypedParseParams translationParams = default) + { + ((SimpleModelSetterCommon)((ISimpleModelGetter)item).CommonSetterInstance()!).CopyInFromBinary( + item: item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + #region Field Index + internal enum SimpleModel_FieldIndex + { + File = 0, + } + #endregion + + #region Registration + internal partial class SimpleModel_Registration : ILoquiRegistration + { + public static readonly SimpleModel_Registration Instance = new SimpleModel_Registration(); + + public static ProtocolKey ProtocolKey => ProtocolDefinition_Starfield.ProtocolKey; + + public static readonly ObjectKey ObjectKey = new ObjectKey( + protocolKey: ProtocolDefinition_Starfield.ProtocolKey, + msgID: 70, + version: 0); + + public const string GUID = "4cd9cae6-96f3-483f-9f1f-730cf7bcb016"; + + public const ushort AdditionalFieldCount = 1; + + public const ushort FieldCount = 1; + + public static readonly Type MaskType = typeof(SimpleModel.Mask<>); + + public static readonly Type ErrorMaskType = typeof(SimpleModel.ErrorMask); + + public static readonly Type ClassType = typeof(SimpleModel); + + public static readonly Type GetterType = typeof(ISimpleModelGetter); + + public static readonly Type? InternalGetterType = null; + + public static readonly Type SetterType = typeof(ISimpleModel); + + public static readonly Type? InternalSetterType = null; + + public const string FullName = "Mutagen.Bethesda.Starfield.SimpleModel"; + + public const string Name = "SimpleModel"; + + public const string Namespace = "Mutagen.Bethesda.Starfield"; + + public const byte GenericCount = 0; + + public static readonly Type? GenericRegistrationType = null; + + public static readonly RecordType TriggeringRecordType = RecordTypes.MODL; + public static RecordTriggerSpecs TriggerSpecs => _recordSpecs.Value; + private static readonly Lazy _recordSpecs = new Lazy(() => + { + var all = RecordCollection.Factory(RecordTypes.MODL); + return new RecordTriggerSpecs(allRecordTypes: all); + }); + public static readonly Type BinaryWriteTranslation = typeof(SimpleModelBinaryWriteTranslation); + #region Interface + ProtocolKey ILoquiRegistration.ProtocolKey => ProtocolKey; + ObjectKey ILoquiRegistration.ObjectKey => ObjectKey; + string ILoquiRegistration.GUID => GUID; + ushort ILoquiRegistration.FieldCount => FieldCount; + ushort ILoquiRegistration.AdditionalFieldCount => AdditionalFieldCount; + Type ILoquiRegistration.MaskType => MaskType; + Type ILoquiRegistration.ErrorMaskType => ErrorMaskType; + Type ILoquiRegistration.ClassType => ClassType; + Type ILoquiRegistration.SetterType => SetterType; + Type? ILoquiRegistration.InternalSetterType => InternalSetterType; + Type ILoquiRegistration.GetterType => GetterType; + Type? ILoquiRegistration.InternalGetterType => InternalGetterType; + string ILoquiRegistration.FullName => FullName; + string ILoquiRegistration.Name => Name; + string ILoquiRegistration.Namespace => Namespace; + byte ILoquiRegistration.GenericCount => GenericCount; + Type? ILoquiRegistration.GenericRegistrationType => GenericRegistrationType; + ushort? ILoquiRegistration.GetNameIndex(StringCaseAgnostic name) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsEnumerable(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsLoqui(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsSingleton(ushort index) => throw new NotImplementedException(); + string ILoquiRegistration.GetNthName(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsNthDerivative(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsProtected(ushort index) => throw new NotImplementedException(); + Type ILoquiRegistration.GetNthType(ushort index) => throw new NotImplementedException(); + #endregion + + } + #endregion + + #region Common + internal partial class SimpleModelSetterCommon + { + public static readonly SimpleModelSetterCommon Instance = new SimpleModelSetterCommon(); + + partial void ClearPartial(); + + public virtual void Clear(ISimpleModel item) + { + ClearPartial(); + item.File.SetToNull(); + } + + #region Mutagen + public void RemapLinks(ISimpleModel obj, IReadOnlyDictionary mapping) + { + } + + public IEnumerable EnumerateListedAssetLinks(ISimpleModel obj) + { + yield return obj.File; + yield break; + } + + public void RemapAssetLinks( + ISimpleModel obj, + IReadOnlyDictionary mapping, + IAssetLinkCache? linkCache, + AssetLinkQuery queryCategories) + { + if (queryCategories.HasFlag(AssetLinkQuery.Listed)) + { + obj.File.Relink(mapping); + } + } + + #endregion + + #region Binary Translation + public virtual void CopyInFromBinary( + ISimpleModel item, + MutagenFrame frame, + TypedParseParams translationParams) + { + PluginUtilityTranslation.SubrecordParse( + record: item, + frame: frame, + translationParams: translationParams, + fillTyped: SimpleModelBinaryCreateTranslation.FillBinaryRecordTypes); + } + + #endregion + + } + internal partial class SimpleModelCommon + { + public static readonly SimpleModelCommon Instance = new SimpleModelCommon(); + + public SimpleModel.Mask GetEqualsMask( + ISimpleModelGetter item, + ISimpleModelGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + var ret = new SimpleModel.Mask(false); + ((SimpleModelCommon)((ISimpleModelGetter)item).CommonInstance()!).FillEqualsMask( + item: item, + rhs: rhs, + ret: ret, + include: include); + return ret; + } + + public void FillEqualsMask( + ISimpleModelGetter item, + ISimpleModelGetter rhs, + SimpleModel.Mask ret, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + ret.File = object.Equals(item.File, rhs.File); + } + + public string Print( + ISimpleModelGetter item, + string? name = null, + SimpleModel.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + return sb.ToString(); + } + + public void Print( + ISimpleModelGetter item, + StructuredStringBuilder sb, + string? name = null, + SimpleModel.Mask? printMask = null) + { + if (name == null) + { + sb.AppendLine($"SimpleModel =>"); + } + else + { + sb.AppendLine($"{name} (SimpleModel) =>"); + } + using (sb.Brace()) + { + ToStringFields( + item: item, + sb: sb, + printMask: printMask); + } + } + + protected static void ToStringFields( + ISimpleModelGetter item, + StructuredStringBuilder sb, + SimpleModel.Mask? printMask = null) + { + if (printMask?.File ?? true) + { + sb.AppendItem(item.File, "File"); + } + } + + #region Equals and Hash + public virtual bool Equals( + ISimpleModelGetter? lhs, + ISimpleModelGetter? rhs, + TranslationCrystal? equalsMask) + { + if (!EqualsMaskHelper.RefEquality(lhs, rhs, out var isEqual)) return isEqual; + if ((equalsMask?.GetShouldTranslate((int)SimpleModel_FieldIndex.File) ?? true)) + { + if (!object.Equals(lhs.File, rhs.File)) return false; + } + return true; + } + + public virtual int GetHashCode(ISimpleModelGetter item) + { + var hash = new HashCode(); + hash.Add(item.File); + return hash.ToHashCode(); + } + + #endregion + + + public virtual object GetNew() + { + return SimpleModel.GetNew(); + } + + #region Mutagen + public IEnumerable EnumerateFormLinks(ISimpleModelGetter obj) + { + yield break; + } + + public IEnumerable EnumerateAssetLinks(ISimpleModelGetter obj, AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) + { + if (queryCategories.HasFlag(AssetLinkQuery.Listed)) + { + yield return obj.File; + } + yield break; + } + + #endregion + + } + internal partial class SimpleModelSetterTranslationCommon + { + public static readonly SimpleModelSetterTranslationCommon Instance = new SimpleModelSetterTranslationCommon(); + + #region DeepCopyIn + public virtual void DeepCopyIn( + ISimpleModel item, + ISimpleModelGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + item.File.RawPath = rhs.File.RawPath; + } + + #endregion + + public SimpleModel DeepCopy( + ISimpleModelGetter item, + SimpleModel.TranslationMask? copyMask = null) + { + SimpleModel ret = (SimpleModel)((SimpleModelCommon)((ISimpleModelGetter)item).CommonInstance()!).GetNew(); + ((SimpleModelSetterTranslationCommon)((ISimpleModelGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: null, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + return ret; + } + + public SimpleModel DeepCopy( + ISimpleModelGetter item, + out SimpleModel.ErrorMask errorMask, + SimpleModel.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + SimpleModel ret = (SimpleModel)((SimpleModelCommon)((ISimpleModelGetter)item).CommonInstance()!).GetNew(); + ((SimpleModelSetterTranslationCommon)((ISimpleModelGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + ret, + item, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + errorMask = SimpleModel.ErrorMask.Factory(errorMaskBuilder); + return ret; + } + + public SimpleModel DeepCopy( + ISimpleModelGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + SimpleModel ret = (SimpleModel)((SimpleModelCommon)((ISimpleModelGetter)item).CommonInstance()!).GetNew(); + ((SimpleModelSetterTranslationCommon)((ISimpleModelGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: true); + return ret; + } + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + public partial class SimpleModel + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => SimpleModel_Registration.Instance; + public static ILoquiRegistration StaticRegistration => SimpleModel_Registration.Instance; + [DebuggerStepThrough] + protected virtual object CommonInstance() => SimpleModelCommon.Instance; + [DebuggerStepThrough] + protected virtual object CommonSetterInstance() + { + return SimpleModelSetterCommon.Instance; + } + [DebuggerStepThrough] + protected virtual object CommonSetterTranslationInstance() => SimpleModelSetterTranslationCommon.Instance; + [DebuggerStepThrough] + object ISimpleModelGetter.CommonInstance() => this.CommonInstance(); + [DebuggerStepThrough] + object ISimpleModelGetter.CommonSetterInstance() => this.CommonSetterInstance(); + [DebuggerStepThrough] + object ISimpleModelGetter.CommonSetterTranslationInstance() => this.CommonSetterTranslationInstance(); + + #endregion + + } +} + +#region Modules +#region Binary Translation +namespace Mutagen.Bethesda.Starfield +{ + public partial class SimpleModelBinaryWriteTranslation : IBinaryWriteTranslator + { + public static readonly SimpleModelBinaryWriteTranslation Instance = new(); + + public static void WriteRecordTypes( + ISimpleModelGetter item, + MutagenWriter writer, + TypedWriteParams translationParams) + { + StringBinaryTranslation.Instance.Write( + writer: writer, + item: item.File.RawPath, + header: translationParams.ConvertToCustom(RecordTypes.MODL), + binaryType: StringBinaryType.NullTerminate); + } + + public virtual void Write( + MutagenWriter writer, + ISimpleModelGetter item, + TypedWriteParams translationParams) + { + WriteRecordTypes( + item: item, + writer: writer, + translationParams: translationParams); + } + + public virtual void Write( + MutagenWriter writer, + object item, + TypedWriteParams translationParams = default) + { + Write( + item: (ISimpleModelGetter)item, + writer: writer, + translationParams: translationParams); + } + + } + + internal partial class SimpleModelBinaryCreateTranslation + { + public static readonly SimpleModelBinaryCreateTranslation Instance = new SimpleModelBinaryCreateTranslation(); + + public static ParseResult FillBinaryRecordTypes( + ISimpleModel item, + MutagenFrame frame, + PreviousParse lastParsed, + Dictionary? recordParseCount, + RecordType nextRecordType, + int contentLength, + TypedParseParams translationParams = default) + { + nextRecordType = translationParams.ConvertToStandard(nextRecordType); + switch (nextRecordType.TypeInt) + { + case RecordTypeInts.MODL: + { + if (lastParsed.ShortCircuit((int)SimpleModel_FieldIndex.File, translationParams)) return ParseResult.Stop; + frame.Position += frame.MetaData.Constants.SubConstants.HeaderLength; + item.File.RawPath = StringBinaryTranslation.Instance.Parse( + reader: frame.SpawnWithLength(contentLength), + stringBinaryType: StringBinaryType.NullTerminate); + return (int)SimpleModel_FieldIndex.File; + } + default: + return ParseResult.Stop; + } + } + + } + +} +namespace Mutagen.Bethesda.Starfield +{ + #region Binary Write Mixins + public static class SimpleModelBinaryTranslationMixIn + { + public static void WriteToBinary( + this ISimpleModelGetter item, + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((SimpleModelBinaryWriteTranslation)item.BinaryWriteTranslator).Write( + item: item, + writer: writer, + translationParams: translationParams); + } + + } + #endregion + + +} +namespace Mutagen.Bethesda.Starfield +{ + internal partial class SimpleModelBinaryOverlay : + PluginBinaryOverlay, + ISimpleModelGetter + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => SimpleModel_Registration.Instance; + public static ILoquiRegistration StaticRegistration => SimpleModel_Registration.Instance; + [DebuggerStepThrough] + protected virtual object CommonInstance() => SimpleModelCommon.Instance; + [DebuggerStepThrough] + protected virtual object CommonSetterTranslationInstance() => SimpleModelSetterTranslationCommon.Instance; + [DebuggerStepThrough] + object ISimpleModelGetter.CommonInstance() => this.CommonInstance(); + [DebuggerStepThrough] + object? ISimpleModelGetter.CommonSetterInstance() => null; + [DebuggerStepThrough] + object ISimpleModelGetter.CommonSetterTranslationInstance() => this.CommonSetterTranslationInstance(); + + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + public IEnumerable EnumerateAssetLinks(AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) => SimpleModelCommon.Instance.EnumerateAssetLinks(this, queryCategories, linkCache, assetType); + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected virtual object BinaryWriteTranslator => SimpleModelBinaryWriteTranslation.Instance; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + object IBinaryItem.BinaryWriteTranslator => this.BinaryWriteTranslator; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((SimpleModelBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + + #region File + private int? _FileLocation; + public AssetLinkGetter File => _FileLocation.HasValue ? new AssetLinkGetter(BinaryStringUtility.ProcessWholeToZString(HeaderTranslation.ExtractSubrecordMemory(_recordData, _FileLocation.Value, _package.MetaData.Constants), encoding: _package.MetaData.Encodings.NonTranslated)) : AssetLinkGetter.Null; + #endregion + partial void CustomFactoryEnd( + OverlayStream stream, + int finalPos, + int offset); + + partial void CustomCtor(); + protected SimpleModelBinaryOverlay( + MemoryPair memoryPair, + BinaryOverlayFactoryPackage package) + : base( + memoryPair: memoryPair, + package: package) + { + this.CustomCtor(); + } + + public static ISimpleModelGetter SimpleModelFactory( + OverlayStream stream, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + stream = ExtractTypelessSubrecordRecordMemory( + stream: stream, + meta: package.MetaData.Constants, + translationParams: translationParams, + memoryPair: out var memoryPair, + offset: out var offset, + finalPos: out var finalPos); + var ret = new SimpleModelBinaryOverlay( + memoryPair: memoryPair, + package: package); + ret.FillTypelessSubrecordTypes( + stream: stream, + finalPos: stream.Length, + offset: offset, + translationParams: translationParams, + fill: ret.FillRecordType); + return ret; + } + + public static ISimpleModelGetter SimpleModelFactory( + ReadOnlyMemorySlice slice, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + return SimpleModelFactory( + stream: new OverlayStream(slice, package), + package: package, + translationParams: translationParams); + } + + public virtual ParseResult FillRecordType( + OverlayStream stream, + int finalPos, + int offset, + RecordType type, + PreviousParse lastParsed, + Dictionary? recordParseCount, + TypedParseParams translationParams = default) + { + type = translationParams.ConvertToStandard(type); + switch (type.TypeInt) + { + case RecordTypeInts.MODL: + { + if (lastParsed.ShortCircuit((int)SimpleModel_FieldIndex.File, translationParams)) return ParseResult.Stop; + _FileLocation = (stream.Position - offset); + return (int)SimpleModel_FieldIndex.File; + } + default: + return ParseResult.Stop; + } + } + #region To String + + public virtual void Print( + StructuredStringBuilder sb, + string? name = null) + { + SimpleModelMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is not ISimpleModelGetter rhs) return false; + return ((SimpleModelCommon)((ISimpleModelGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(ISimpleModelGetter? obj) + { + return ((SimpleModelCommon)((ISimpleModelGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((SimpleModelCommon)((ISimpleModelGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + } + +} +#endregion + +#endregion + diff --git a/Mutagen.Bethesda.Starfield/Records/LinkCacheMixIns_Generated.cs b/Mutagen.Bethesda.Starfield/Records/LinkCacheMixIns_Generated.cs new file mode 100644 index 0000000000..0bec37db4b --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/LinkCacheMixIns_Generated.cs @@ -0,0 +1,128 @@ +using Mutagen.Bethesda.Plugins.Order; +using Mutagen.Bethesda.Plugins.Cache; +using Mutagen.Bethesda.Plugins.Cache.Internals.Implementations; + +namespace Mutagen.Bethesda.Starfield +{ + public static class LinkCacheMixIns + { + /// + /// Creates a Link Cache using a single mod as its link target.
+ /// Modification of the target Mod is not safe. Internal caches can become incorrect if + /// modifications occur on content already cached. + ///
+ /// Mod to construct the package relative to + /// LinkPackage attached to given mod + public static ImmutableModLinkCache ToImmutableLinkCache(this IStarfieldModGetter mod) + { + return mod.ToImmutableLinkCache(); + } + + /// + /// Creates a Link Cache using a single mod as its link target. Mod is allowed to be modified afterwards, but + /// this comes at a performance cost of not allowing much caching to be done. If the mod is not expected to + /// be modified afterwards, use ImmutableModLinkCache instead.
+ ///
+ /// Mod to construct the package relative to + /// LinkPackage attached to given mod + public static MutableModLinkCache ToMutableLinkCache(this IStarfieldModGetter mod) + { + return mod.ToMutableLinkCache(); + } + + /// + /// Creates a new linking package relative to a load order.
+ /// Will resolve links to the highest overriding mod containing the record being sought.
+ /// 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. + ///
+ /// LoadOrder to construct the package relative to + /// LinkPackage attached to given LoadOrder + public static ImmutableLoadOrderLinkCache ToImmutableLinkCache(this ILoadOrderGetter loadOrder) + { + return loadOrder.ToImmutableLinkCache(); + } + + /// + /// Creates a new linking package relative to a load order.
+ /// Will resolve links to the highest overriding mod containing the record being sought.
+ /// 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. + ///
+ /// LoadOrder to construct the package relative to + /// LinkPackage attached to given LoadOrder + public static ImmutableLoadOrderLinkCache ToImmutableLinkCache(this ILoadOrderGetter> loadOrder) + { + return loadOrder.ToImmutableLinkCache(); + } + + /// + /// Creates a new linking package relative to a load order.
+ /// Will resolve links to the highest overriding mod containing the record being sought.
+ /// 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. + ///
+ /// LoadOrder to construct the package relative to + /// LinkPackage attached to given LoadOrder + public static ImmutableLoadOrderLinkCache ToImmutableLinkCache(this IEnumerable> loadOrder) + { + return loadOrder.ToImmutableLinkCache(); + } + + /// + /// Creates a new linking package relative to a load order.
+ /// Will resolve links to the highest overriding mod containing the record being sought.
+ /// 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. + ///
+ /// LoadOrder to construct the package relative to + /// LinkPackage attached to given LoadOrder + public static ImmutableLoadOrderLinkCache ToImmutableLinkCache(this IEnumerable loadOrder) + { + return loadOrder.ToImmutableLinkCache(); + } + + /// + /// 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. + /// + /// LoadOrderCache to use as the immutable base + /// Set of mods to place at the end of the load order, which are allowed to be modified afterwards + /// LinkPackage attached to given LoadOrder + public static ILinkCache ToMutableLinkCache( + this ILoadOrderGetter immutableBaseCache, + params IStarfieldMod[] mutableMods) + { + return immutableBaseCache.ToMutableLinkCache(mutableMods); + } + + /// + /// 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. + /// + /// LoadOrderCache to use as the immutable base + /// Set of mods to place at the end of the load order, which are allowed to be modified afterwards + /// LinkPackage attached to given LoadOrder + public static ILinkCache ToMutableLinkCache( + this ILoadOrderGetter> immutableBaseCache, + params IStarfieldMod[] mutableMods) + { + return immutableBaseCache.ToMutableLinkCache(mutableMods); + } + + /// + /// 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. + /// + /// LoadOrderCache to use as the immutable base + /// Set of mods to place at the end of the load order, which are allowed to be modified afterwards + /// LinkPackage attached to given LoadOrder + public static ILinkCache ToMutableLinkCache( + this IEnumerable immutableBaseCache, + params IStarfieldMod[] mutableMods) + { + return immutableBaseCache.ToMutableLinkCache(mutableMods); + } + + } +} diff --git a/Mutagen.Bethesda.Starfield/Records/ModStats_Generated.cs b/Mutagen.Bethesda.Starfield/Records/ModStats_Generated.cs new file mode 100644 index 0000000000..de32703634 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/ModStats_Generated.cs @@ -0,0 +1,1256 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Autogenerated by Loqui. Do not manually change. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ +#region Usings +using Loqui; +using Loqui.Interfaces; +using Loqui.Internal; +using Mutagen.Bethesda.Binary; +using Mutagen.Bethesda.Plugins; +using Mutagen.Bethesda.Plugins.Binary.Headers; +using Mutagen.Bethesda.Plugins.Binary.Overlay; +using Mutagen.Bethesda.Plugins.Binary.Streams; +using Mutagen.Bethesda.Plugins.Binary.Translations; +using Mutagen.Bethesda.Plugins.Exceptions; +using Mutagen.Bethesda.Plugins.Internals; +using Mutagen.Bethesda.Plugins.Records; +using Mutagen.Bethesda.Plugins.Records.Internals; +using Mutagen.Bethesda.Plugins.Records.Mapping; +using Mutagen.Bethesda.Starfield.Internals; +using Mutagen.Bethesda.Translations.Binary; +using Noggog; +using Noggog.StructuredStrings; +using Noggog.StructuredStrings.CSharp; +using RecordTypeInts = Mutagen.Bethesda.Starfield.Internals.RecordTypeInts; +using RecordTypes = Mutagen.Bethesda.Starfield.Internals.RecordTypes; +using System.Buffers.Binary; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Reactive.Disposables; +using System.Reactive.Linq; +#endregion + +#nullable enable +namespace Mutagen.Bethesda.Starfield +{ + #region Class + public partial class ModStats : + IEquatable, + ILoquiObjectSetter, + IModStats + { + #region Ctor + public ModStats() + { + CustomCtor(); + } + partial void CustomCtor(); + #endregion + + #region Version + public static readonly Single VersionDefault = 1.7f; + public Single Version { get; set; } = VersionDefault; + #endregion + #region NumRecords + public UInt32 NumRecords { get; set; } = default; + #endregion + #region NextFormID + public static readonly UInt32 NextFormIDDefault = 0x800; + public UInt32 NextFormID { get; set; } = NextFormIDDefault; + #endregion + + #region To String + + public void Print( + StructuredStringBuilder sb, + string? name = null) + { + ModStatsMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is not IModStatsGetter rhs) return false; + return ((ModStatsCommon)((IModStatsGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IModStatsGetter? obj) + { + return ((ModStatsCommon)((IModStatsGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((ModStatsCommon)((IModStatsGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + #region Mask + public class Mask : + IEquatable>, + IMask + { + #region Ctors + public Mask(TItem initialValue) + { + this.Version = initialValue; + this.NumRecords = initialValue; + this.NextFormID = initialValue; + } + + public Mask( + TItem Version, + TItem NumRecords, + TItem NextFormID) + { + this.Version = Version; + this.NumRecords = NumRecords; + this.NextFormID = NextFormID; + } + + #pragma warning disable CS8618 + protected Mask() + { + } + #pragma warning restore CS8618 + + #endregion + + #region Members + public TItem Version; + public TItem NumRecords; + public TItem NextFormID; + #endregion + + #region Equals + public override bool Equals(object? obj) + { + if (!(obj is Mask rhs)) return false; + return Equals(rhs); + } + + public bool Equals(Mask? rhs) + { + if (rhs == null) return false; + if (!object.Equals(this.Version, rhs.Version)) return false; + if (!object.Equals(this.NumRecords, rhs.NumRecords)) return false; + if (!object.Equals(this.NextFormID, rhs.NextFormID)) return false; + return true; + } + public override int GetHashCode() + { + var hash = new HashCode(); + hash.Add(this.Version); + hash.Add(this.NumRecords); + hash.Add(this.NextFormID); + return hash.ToHashCode(); + } + + #endregion + + #region All + public bool All(Func eval) + { + if (!eval(this.Version)) return false; + if (!eval(this.NumRecords)) return false; + if (!eval(this.NextFormID)) return false; + return true; + } + #endregion + + #region Any + public bool Any(Func eval) + { + if (eval(this.Version)) return true; + if (eval(this.NumRecords)) return true; + if (eval(this.NextFormID)) return true; + return false; + } + #endregion + + #region Translate + public Mask Translate(Func eval) + { + var ret = new ModStats.Mask(); + this.Translate_InternalFill(ret, eval); + return ret; + } + + protected void Translate_InternalFill(Mask obj, Func eval) + { + obj.Version = eval(this.Version); + obj.NumRecords = eval(this.NumRecords); + obj.NextFormID = eval(this.NextFormID); + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public string Print(ModStats.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print(sb, printMask); + return sb.ToString(); + } + + public void Print(StructuredStringBuilder sb, ModStats.Mask? printMask = null) + { + sb.AppendLine($"{nameof(ModStats.Mask)} =>"); + using (sb.Brace()) + { + if (printMask?.Version ?? true) + { + sb.AppendItem(Version, "Version"); + } + if (printMask?.NumRecords ?? true) + { + sb.AppendItem(NumRecords, "NumRecords"); + } + if (printMask?.NextFormID ?? true) + { + sb.AppendItem(NextFormID, "NextFormID"); + } + } + } + #endregion + + } + + public class ErrorMask : + IErrorMask, + IErrorMask + { + #region Members + public Exception? Overall { get; set; } + private List? _warnings; + public List Warnings + { + get + { + if (_warnings == null) + { + _warnings = new List(); + } + return _warnings; + } + } + public Exception? Version; + public Exception? NumRecords; + public Exception? NextFormID; + #endregion + + #region IErrorMask + public object? GetNthMask(int index) + { + ModStats_FieldIndex enu = (ModStats_FieldIndex)index; + switch (enu) + { + case ModStats_FieldIndex.Version: + return Version; + case ModStats_FieldIndex.NumRecords: + return NumRecords; + case ModStats_FieldIndex.NextFormID: + return NextFormID; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public void SetNthException(int index, Exception ex) + { + ModStats_FieldIndex enu = (ModStats_FieldIndex)index; + switch (enu) + { + case ModStats_FieldIndex.Version: + this.Version = ex; + break; + case ModStats_FieldIndex.NumRecords: + this.NumRecords = ex; + break; + case ModStats_FieldIndex.NextFormID: + this.NextFormID = ex; + break; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public void SetNthMask(int index, object obj) + { + ModStats_FieldIndex enu = (ModStats_FieldIndex)index; + switch (enu) + { + case ModStats_FieldIndex.Version: + this.Version = (Exception?)obj; + break; + case ModStats_FieldIndex.NumRecords: + this.NumRecords = (Exception?)obj; + break; + case ModStats_FieldIndex.NextFormID: + this.NextFormID = (Exception?)obj; + break; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public bool IsInError() + { + if (Overall != null) return true; + if (Version != null) return true; + if (NumRecords != null) return true; + if (NextFormID != null) return true; + return false; + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public void Print(StructuredStringBuilder sb, string? name = null) + { + sb.AppendLine($"{(name ?? "ErrorMask")} =>"); + using (sb.Brace()) + { + if (this.Overall != null) + { + sb.AppendLine("Overall =>"); + using (sb.Brace()) + { + sb.AppendLine($"{this.Overall}"); + } + } + PrintFillInternal(sb); + } + } + protected void PrintFillInternal(StructuredStringBuilder sb) + { + { + sb.AppendItem(Version, "Version"); + } + { + sb.AppendItem(NumRecords, "NumRecords"); + } + { + sb.AppendItem(NextFormID, "NextFormID"); + } + } + #endregion + + #region Combine + public ErrorMask Combine(ErrorMask? rhs) + { + if (rhs == null) return this; + var ret = new ErrorMask(); + ret.Version = this.Version.Combine(rhs.Version); + ret.NumRecords = this.NumRecords.Combine(rhs.NumRecords); + ret.NextFormID = this.NextFormID.Combine(rhs.NextFormID); + return ret; + } + public static ErrorMask? Combine(ErrorMask? lhs, ErrorMask? rhs) + { + if (lhs != null && rhs != null) return lhs.Combine(rhs); + return lhs ?? rhs; + } + #endregion + + #region Factory + public static ErrorMask Factory(ErrorMaskBuilder errorMask) + { + return new ErrorMask(); + } + #endregion + + } + public class TranslationMask : ITranslationMask + { + #region Members + private TranslationCrystal? _crystal; + public readonly bool DefaultOn; + public bool OnOverall; + public bool Version; + public bool NumRecords; + public bool NextFormID; + #endregion + + #region Ctors + public TranslationMask( + bool defaultOn, + bool onOverall = true) + { + this.DefaultOn = defaultOn; + this.OnOverall = onOverall; + this.Version = defaultOn; + this.NumRecords = defaultOn; + this.NextFormID = defaultOn; + } + + #endregion + + public TranslationCrystal GetCrystal() + { + if (_crystal != null) return _crystal; + var ret = new List<(bool On, TranslationCrystal? SubCrystal)>(); + GetCrystal(ret); + _crystal = new TranslationCrystal(ret.ToArray()); + return _crystal; + } + + protected void GetCrystal(List<(bool On, TranslationCrystal? SubCrystal)> ret) + { + ret.Add((Version, null)); + ret.Add((NumRecords, null)); + ret.Add((NextFormID, null)); + } + + public static implicit operator TranslationMask(bool defaultOn) + { + return new TranslationMask(defaultOn: defaultOn, onOverall: defaultOn); + } + + } + #endregion + + #region Binary Translation + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected object BinaryWriteTranslator => ModStatsBinaryWriteTranslation.Instance; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + object IBinaryItem.BinaryWriteTranslator => this.BinaryWriteTranslator; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((ModStatsBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + #region Binary Create + public static ModStats CreateFromBinary( + MutagenFrame frame, + TypedParseParams translationParams = default) + { + var ret = new ModStats(); + ((ModStatsSetterCommon)((IModStatsGetter)ret).CommonSetterInstance()!).CopyInFromBinary( + item: ret, + frame: frame, + translationParams: translationParams); + return ret; + } + + #endregion + + public static bool TryCreateFromBinary( + MutagenFrame frame, + out ModStats item, + TypedParseParams translationParams = default) + { + var startPos = frame.Position; + item = CreateFromBinary( + frame: frame, + translationParams: translationParams); + return startPos != frame.Position; + } + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + void IClearable.Clear() + { + ((ModStatsSetterCommon)((IModStatsGetter)this).CommonSetterInstance()!).Clear(this); + } + + internal static ModStats GetNew() + { + return new ModStats(); + } + + } + #endregion + + #region Interface + public partial interface IModStats : + ILoquiObjectSetter, + IModStatsGetter + { + new Single Version { get; set; } + new UInt32 NumRecords { get; set; } + new UInt32 NextFormID { get; set; } + } + + public partial interface IModStatsGetter : + ILoquiObject, + IBinaryItem, + ILoquiObject + { + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object CommonInstance(); + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object? CommonSetterInstance(); + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object CommonSetterTranslationInstance(); + static ILoquiRegistration StaticRegistration => ModStats_Registration.Instance; + Single Version { get; } + UInt32 NumRecords { get; } + UInt32 NextFormID { get; } + + } + + #endregion + + #region Common MixIn + public static partial class ModStatsMixIn + { + public static void Clear(this IModStats item) + { + ((ModStatsSetterCommon)((IModStatsGetter)item).CommonSetterInstance()!).Clear(item: item); + } + + public static ModStats.Mask GetEqualsMask( + this IModStatsGetter item, + IModStatsGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + return ((ModStatsCommon)((IModStatsGetter)item).CommonInstance()!).GetEqualsMask( + item: item, + rhs: rhs, + include: include); + } + + public static string Print( + this IModStatsGetter item, + string? name = null, + ModStats.Mask? printMask = null) + { + return ((ModStatsCommon)((IModStatsGetter)item).CommonInstance()!).Print( + item: item, + name: name, + printMask: printMask); + } + + public static void Print( + this IModStatsGetter item, + StructuredStringBuilder sb, + string? name = null, + ModStats.Mask? printMask = null) + { + ((ModStatsCommon)((IModStatsGetter)item).CommonInstance()!).Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + } + + public static bool Equals( + this IModStatsGetter item, + IModStatsGetter rhs, + ModStats.TranslationMask? equalsMask = null) + { + return ((ModStatsCommon)((IModStatsGetter)item).CommonInstance()!).Equals( + lhs: item, + rhs: rhs, + equalsMask: equalsMask?.GetCrystal()); + } + + public static void DeepCopyIn( + this IModStats lhs, + IModStatsGetter rhs) + { + ((ModStatsSetterTranslationCommon)((IModStatsGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: default, + copyMask: default, + deepCopy: false); + } + + public static void DeepCopyIn( + this IModStats lhs, + IModStatsGetter rhs, + ModStats.TranslationMask? copyMask = null) + { + ((ModStatsSetterTranslationCommon)((IModStatsGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: default, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + } + + public static void DeepCopyIn( + this IModStats lhs, + IModStatsGetter rhs, + out ModStats.ErrorMask errorMask, + ModStats.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + ((ModStatsSetterTranslationCommon)((IModStatsGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + errorMask = ModStats.ErrorMask.Factory(errorMaskBuilder); + } + + public static void DeepCopyIn( + this IModStats lhs, + IModStatsGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask) + { + ((ModStatsSetterTranslationCommon)((IModStatsGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: false); + } + + public static ModStats DeepCopy( + this IModStatsGetter item, + ModStats.TranslationMask? copyMask = null) + { + return ((ModStatsSetterTranslationCommon)((IModStatsGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask); + } + + public static ModStats DeepCopy( + this IModStatsGetter item, + out ModStats.ErrorMask errorMask, + ModStats.TranslationMask? copyMask = null) + { + return ((ModStatsSetterTranslationCommon)((IModStatsGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: out errorMask); + } + + public static ModStats DeepCopy( + this IModStatsGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + return ((ModStatsSetterTranslationCommon)((IModStatsGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: errorMask); + } + + #region Binary Translation + public static void CopyInFromBinary( + this IModStats item, + MutagenFrame frame, + TypedParseParams translationParams = default) + { + ((ModStatsSetterCommon)((IModStatsGetter)item).CommonSetterInstance()!).CopyInFromBinary( + item: item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + #region Field Index + internal enum ModStats_FieldIndex + { + Version = 0, + NumRecords = 1, + NextFormID = 2, + } + #endregion + + #region Registration + internal partial class ModStats_Registration : ILoquiRegistration + { + public static readonly ModStats_Registration Instance = new ModStats_Registration(); + + public static ProtocolKey ProtocolKey => ProtocolDefinition_Starfield.ProtocolKey; + + public static readonly ObjectKey ObjectKey = new ObjectKey( + protocolKey: ProtocolDefinition_Starfield.ProtocolKey, + msgID: 64, + version: 0); + + public const string GUID = "14fe521a-e32e-433c-9915-71a5f7ca5c5b"; + + public const ushort AdditionalFieldCount = 3; + + public const ushort FieldCount = 3; + + public static readonly Type MaskType = typeof(ModStats.Mask<>); + + public static readonly Type ErrorMaskType = typeof(ModStats.ErrorMask); + + public static readonly Type ClassType = typeof(ModStats); + + public static readonly Type GetterType = typeof(IModStatsGetter); + + public static readonly Type? InternalGetterType = null; + + public static readonly Type SetterType = typeof(IModStats); + + public static readonly Type? InternalSetterType = null; + + public const string FullName = "Mutagen.Bethesda.Starfield.ModStats"; + + public const string Name = "ModStats"; + + public const string Namespace = "Mutagen.Bethesda.Starfield"; + + public const byte GenericCount = 0; + + public static readonly Type? GenericRegistrationType = null; + + public static readonly RecordType TriggeringRecordType = RecordTypes.HEDR; + public static RecordTriggerSpecs TriggerSpecs => _recordSpecs.Value; + private static readonly Lazy _recordSpecs = new Lazy(() => + { + var all = RecordCollection.Factory(RecordTypes.HEDR); + return new RecordTriggerSpecs(allRecordTypes: all); + }); + public static readonly Type BinaryWriteTranslation = typeof(ModStatsBinaryWriteTranslation); + #region Interface + ProtocolKey ILoquiRegistration.ProtocolKey => ProtocolKey; + ObjectKey ILoquiRegistration.ObjectKey => ObjectKey; + string ILoquiRegistration.GUID => GUID; + ushort ILoquiRegistration.FieldCount => FieldCount; + ushort ILoquiRegistration.AdditionalFieldCount => AdditionalFieldCount; + Type ILoquiRegistration.MaskType => MaskType; + Type ILoquiRegistration.ErrorMaskType => ErrorMaskType; + Type ILoquiRegistration.ClassType => ClassType; + Type ILoquiRegistration.SetterType => SetterType; + Type? ILoquiRegistration.InternalSetterType => InternalSetterType; + Type ILoquiRegistration.GetterType => GetterType; + Type? ILoquiRegistration.InternalGetterType => InternalGetterType; + string ILoquiRegistration.FullName => FullName; + string ILoquiRegistration.Name => Name; + string ILoquiRegistration.Namespace => Namespace; + byte ILoquiRegistration.GenericCount => GenericCount; + Type? ILoquiRegistration.GenericRegistrationType => GenericRegistrationType; + ushort? ILoquiRegistration.GetNameIndex(StringCaseAgnostic name) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsEnumerable(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsLoqui(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsSingleton(ushort index) => throw new NotImplementedException(); + string ILoquiRegistration.GetNthName(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsNthDerivative(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsProtected(ushort index) => throw new NotImplementedException(); + Type ILoquiRegistration.GetNthType(ushort index) => throw new NotImplementedException(); + #endregion + + } + #endregion + + #region Common + internal partial class ModStatsSetterCommon + { + public static readonly ModStatsSetterCommon Instance = new ModStatsSetterCommon(); + + partial void ClearPartial(); + + public void Clear(IModStats item) + { + ClearPartial(); + item.Version = ModStats.VersionDefault; + item.NumRecords = default; + item.NextFormID = ModStats.NextFormIDDefault; + } + + #region Mutagen + public void RemapLinks(IModStats obj, IReadOnlyDictionary mapping) + { + } + + #endregion + + #region Binary Translation + public virtual void CopyInFromBinary( + IModStats item, + MutagenFrame frame, + TypedParseParams translationParams) + { + frame = frame.SpawnWithFinalPosition(HeaderTranslation.ParseSubrecord( + frame.Reader, + translationParams.ConvertToCustom(RecordTypes.HEDR), + translationParams.LengthOverride)); + PluginUtilityTranslation.SubrecordParse( + record: item, + frame: frame, + translationParams: translationParams, + fillStructs: ModStatsBinaryCreateTranslation.FillBinaryStructs); + } + + #endregion + + } + internal partial class ModStatsCommon + { + public static readonly ModStatsCommon Instance = new ModStatsCommon(); + + public ModStats.Mask GetEqualsMask( + IModStatsGetter item, + IModStatsGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + var ret = new ModStats.Mask(false); + ((ModStatsCommon)((IModStatsGetter)item).CommonInstance()!).FillEqualsMask( + item: item, + rhs: rhs, + ret: ret, + include: include); + return ret; + } + + public void FillEqualsMask( + IModStatsGetter item, + IModStatsGetter rhs, + ModStats.Mask ret, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + ret.Version = item.Version.EqualsWithin(rhs.Version); + ret.NumRecords = item.NumRecords == rhs.NumRecords; + ret.NextFormID = item.NextFormID == rhs.NextFormID; + } + + public string Print( + IModStatsGetter item, + string? name = null, + ModStats.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + return sb.ToString(); + } + + public void Print( + IModStatsGetter item, + StructuredStringBuilder sb, + string? name = null, + ModStats.Mask? printMask = null) + { + if (name == null) + { + sb.AppendLine($"ModStats =>"); + } + else + { + sb.AppendLine($"{name} (ModStats) =>"); + } + using (sb.Brace()) + { + ToStringFields( + item: item, + sb: sb, + printMask: printMask); + } + } + + protected static void ToStringFields( + IModStatsGetter item, + StructuredStringBuilder sb, + ModStats.Mask? printMask = null) + { + if (printMask?.Version ?? true) + { + sb.AppendItem(item.Version, "Version"); + } + if (printMask?.NumRecords ?? true) + { + sb.AppendItem(item.NumRecords, "NumRecords"); + } + if (printMask?.NextFormID ?? true) + { + sb.AppendItem(item.NextFormID, "NextFormID"); + } + } + + #region Equals and Hash + public virtual bool Equals( + IModStatsGetter? lhs, + IModStatsGetter? rhs, + TranslationCrystal? equalsMask) + { + if (!EqualsMaskHelper.RefEquality(lhs, rhs, out var isEqual)) return isEqual; + if ((equalsMask?.GetShouldTranslate((int)ModStats_FieldIndex.Version) ?? true)) + { + if (!lhs.Version.EqualsWithin(rhs.Version)) return false; + } + if ((equalsMask?.GetShouldTranslate((int)ModStats_FieldIndex.NumRecords) ?? true)) + { + if (lhs.NumRecords != rhs.NumRecords) return false; + } + if ((equalsMask?.GetShouldTranslate((int)ModStats_FieldIndex.NextFormID) ?? true)) + { + if (lhs.NextFormID != rhs.NextFormID) return false; + } + return true; + } + + public virtual int GetHashCode(IModStatsGetter item) + { + var hash = new HashCode(); + hash.Add(item.Version); + hash.Add(item.NumRecords); + hash.Add(item.NextFormID); + return hash.ToHashCode(); + } + + #endregion + + + public object GetNew() + { + return ModStats.GetNew(); + } + + #region Mutagen + public IEnumerable EnumerateFormLinks(IModStatsGetter obj) + { + yield break; + } + + #endregion + + } + internal partial class ModStatsSetterTranslationCommon + { + public static readonly ModStatsSetterTranslationCommon Instance = new ModStatsSetterTranslationCommon(); + + #region DeepCopyIn + public void DeepCopyIn( + IModStats item, + IModStatsGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + if ((copyMask?.GetShouldTranslate((int)ModStats_FieldIndex.Version) ?? true)) + { + item.Version = rhs.Version; + } + if ((copyMask?.GetShouldTranslate((int)ModStats_FieldIndex.NumRecords) ?? true)) + { + item.NumRecords = rhs.NumRecords; + } + if ((copyMask?.GetShouldTranslate((int)ModStats_FieldIndex.NextFormID) ?? true)) + { + item.NextFormID = rhs.NextFormID; + } + } + + #endregion + + public ModStats DeepCopy( + IModStatsGetter item, + ModStats.TranslationMask? copyMask = null) + { + ModStats ret = (ModStats)((ModStatsCommon)((IModStatsGetter)item).CommonInstance()!).GetNew(); + ((ModStatsSetterTranslationCommon)((IModStatsGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: null, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + return ret; + } + + public ModStats DeepCopy( + IModStatsGetter item, + out ModStats.ErrorMask errorMask, + ModStats.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + ModStats ret = (ModStats)((ModStatsCommon)((IModStatsGetter)item).CommonInstance()!).GetNew(); + ((ModStatsSetterTranslationCommon)((IModStatsGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + ret, + item, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + errorMask = ModStats.ErrorMask.Factory(errorMaskBuilder); + return ret; + } + + public ModStats DeepCopy( + IModStatsGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + ModStats ret = (ModStats)((ModStatsCommon)((IModStatsGetter)item).CommonInstance()!).GetNew(); + ((ModStatsSetterTranslationCommon)((IModStatsGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: true); + return ret; + } + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + public partial class ModStats + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => ModStats_Registration.Instance; + public static ILoquiRegistration StaticRegistration => ModStats_Registration.Instance; + [DebuggerStepThrough] + protected object CommonInstance() => ModStatsCommon.Instance; + [DebuggerStepThrough] + protected object CommonSetterInstance() + { + return ModStatsSetterCommon.Instance; + } + [DebuggerStepThrough] + protected object CommonSetterTranslationInstance() => ModStatsSetterTranslationCommon.Instance; + [DebuggerStepThrough] + object IModStatsGetter.CommonInstance() => this.CommonInstance(); + [DebuggerStepThrough] + object IModStatsGetter.CommonSetterInstance() => this.CommonSetterInstance(); + [DebuggerStepThrough] + object IModStatsGetter.CommonSetterTranslationInstance() => this.CommonSetterTranslationInstance(); + + #endregion + + } +} + +#region Modules +#region Binary Translation +namespace Mutagen.Bethesda.Starfield +{ + public partial class ModStatsBinaryWriteTranslation : IBinaryWriteTranslator + { + public static readonly ModStatsBinaryWriteTranslation Instance = new(); + + public static void WriteEmbedded( + IModStatsGetter item, + MutagenWriter writer) + { + FloatBinaryTranslation.Instance.Write( + writer: writer, + item: item.Version); + writer.Write(item.NumRecords); + writer.Write(item.NextFormID); + } + + public void Write( + MutagenWriter writer, + IModStatsGetter item, + TypedWriteParams translationParams) + { + using (HeaderExport.Subrecord( + writer: writer, + record: translationParams.ConvertToCustom(RecordTypes.HEDR), + overflowRecord: translationParams.OverflowRecordType, + out var writerToUse)) + { + WriteEmbedded( + item: item, + writer: writerToUse); + } + } + + public void Write( + MutagenWriter writer, + object item, + TypedWriteParams translationParams = default) + { + Write( + item: (IModStatsGetter)item, + writer: writer, + translationParams: translationParams); + } + + } + + internal partial class ModStatsBinaryCreateTranslation + { + public static readonly ModStatsBinaryCreateTranslation Instance = new ModStatsBinaryCreateTranslation(); + + public static void FillBinaryStructs( + IModStats item, + MutagenFrame frame) + { + item.Version = FloatBinaryTranslation.Instance.Parse(reader: frame); + item.NumRecords = frame.ReadUInt32(); + item.NextFormID = frame.ReadUInt32(); + } + + } + +} +namespace Mutagen.Bethesda.Starfield +{ + #region Binary Write Mixins + public static class ModStatsBinaryTranslationMixIn + { + public static void WriteToBinary( + this IModStatsGetter item, + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((ModStatsBinaryWriteTranslation)item.BinaryWriteTranslator).Write( + item: item, + writer: writer, + translationParams: translationParams); + } + + } + #endregion + + +} +namespace Mutagen.Bethesda.Starfield +{ + internal partial class ModStatsBinaryOverlay : + PluginBinaryOverlay, + IModStatsGetter + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => ModStats_Registration.Instance; + public static ILoquiRegistration StaticRegistration => ModStats_Registration.Instance; + [DebuggerStepThrough] + protected object CommonInstance() => ModStatsCommon.Instance; + [DebuggerStepThrough] + protected object CommonSetterTranslationInstance() => ModStatsSetterTranslationCommon.Instance; + [DebuggerStepThrough] + object IModStatsGetter.CommonInstance() => this.CommonInstance(); + [DebuggerStepThrough] + object? IModStatsGetter.CommonSetterInstance() => null; + [DebuggerStepThrough] + object IModStatsGetter.CommonSetterTranslationInstance() => this.CommonSetterTranslationInstance(); + + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected object BinaryWriteTranslator => ModStatsBinaryWriteTranslation.Instance; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + object IBinaryItem.BinaryWriteTranslator => this.BinaryWriteTranslator; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((ModStatsBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + + public Single Version => _structData.Slice(0x0, 0x4).Float(); + public UInt32 NumRecords => BinaryPrimitives.ReadUInt32LittleEndian(_structData.Slice(0x4, 0x4)); + public UInt32 NextFormID => BinaryPrimitives.ReadUInt32LittleEndian(_structData.Slice(0x8, 0x4)); + partial void CustomFactoryEnd( + OverlayStream stream, + int finalPos, + int offset); + + partial void CustomCtor(); + protected ModStatsBinaryOverlay( + MemoryPair memoryPair, + BinaryOverlayFactoryPackage package) + : base( + memoryPair: memoryPair, + package: package) + { + this.CustomCtor(); + } + + public static IModStatsGetter ModStatsFactory( + OverlayStream stream, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + stream = ExtractSubrecordStructMemory( + stream: stream, + meta: package.MetaData.Constants, + translationParams: translationParams, + length: 0xC, + memoryPair: out var memoryPair, + offset: out var offset); + var ret = new ModStatsBinaryOverlay( + memoryPair: memoryPair, + package: package); + stream.Position += 0xC + package.MetaData.Constants.SubConstants.HeaderLength; + ret.CustomFactoryEnd( + stream: stream, + finalPos: stream.Length, + offset: offset); + return ret; + } + + public static IModStatsGetter ModStatsFactory( + ReadOnlyMemorySlice slice, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + return ModStatsFactory( + stream: new OverlayStream(slice, package), + package: package, + translationParams: translationParams); + } + + #region To String + + public void Print( + StructuredStringBuilder sb, + string? name = null) + { + ModStatsMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is not IModStatsGetter rhs) return false; + return ((ModStatsCommon)((IModStatsGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IModStatsGetter? obj) + { + return ((ModStatsCommon)((IModStatsGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((ModStatsCommon)((IModStatsGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + } + +} +#endregion + +#endregion + diff --git a/Mutagen.Bethesda.Starfield/Records/Npc.xml b/Mutagen.Bethesda.Starfield/Records/Npc.xml new file mode 100644 index 0000000000..301cba7173 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/Npc.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Mutagen.Bethesda.Starfield/Records/Npc_Generated.cs b/Mutagen.Bethesda.Starfield/Records/Npc_Generated.cs new file mode 100644 index 0000000000..776e14308a --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/Npc_Generated.cs @@ -0,0 +1,1552 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Autogenerated by Loqui. Do not manually change. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ +#region Usings +using Loqui; +using Loqui.Interfaces; +using Loqui.Internal; +using Mutagen.Bethesda.Binary; +using Mutagen.Bethesda.Plugins; +using Mutagen.Bethesda.Plugins.Binary.Headers; +using Mutagen.Bethesda.Plugins.Binary.Overlay; +using Mutagen.Bethesda.Plugins.Binary.Streams; +using Mutagen.Bethesda.Plugins.Binary.Translations; +using Mutagen.Bethesda.Plugins.Cache; +using Mutagen.Bethesda.Plugins.Exceptions; +using Mutagen.Bethesda.Plugins.Internals; +using Mutagen.Bethesda.Plugins.Records; +using Mutagen.Bethesda.Plugins.Records.Internals; +using Mutagen.Bethesda.Plugins.Records.Mapping; +using Mutagen.Bethesda.Plugins.RecordTypeMapping; +using Mutagen.Bethesda.Plugins.Utility; +using Mutagen.Bethesda.Starfield; +using Mutagen.Bethesda.Starfield.Internals; +using Mutagen.Bethesda.Translations.Binary; +using Noggog; +using Noggog.StructuredStrings; +using Noggog.StructuredStrings.CSharp; +using RecordTypeInts = Mutagen.Bethesda.Starfield.Internals.RecordTypeInts; +using RecordTypes = Mutagen.Bethesda.Starfield.Internals.RecordTypes; +using System.Buffers.Binary; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Reactive.Disposables; +using System.Reactive.Linq; +#endregion + +#nullable enable +namespace Mutagen.Bethesda.Starfield +{ + #region Class + public partial class Npc : + StarfieldMajorRecord, + IEquatable, + ILoquiObjectSetter, + INpcInternal + { + #region Ctor + protected Npc() + { + CustomCtor(); + } + partial void CustomCtor(); + #endregion + + #region Race + private readonly IFormLink _Race = new FormLink(); + public IFormLink Race + { + get => _Race; + set => _Race.SetTo(value); + } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IFormLinkGetter INpcGetter.Race => this.Race; + #endregion + + #region To String + + public override void Print( + StructuredStringBuilder sb, + string? name = null) + { + NpcMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Mask + public new class Mask : + StarfieldMajorRecord.Mask, + IEquatable>, + IMask + { + #region Ctors + public Mask(TItem initialValue) + : base(initialValue) + { + this.Race = initialValue; + } + + public Mask( + TItem MajorRecordFlagsRaw, + TItem FormKey, + TItem VersionControl, + TItem EditorID, + TItem FormVersion, + TItem Version2, + TItem StarfieldMajorRecordFlags, + TItem Race) + : base( + MajorRecordFlagsRaw: MajorRecordFlagsRaw, + FormKey: FormKey, + VersionControl: VersionControl, + EditorID: EditorID, + FormVersion: FormVersion, + Version2: Version2, + StarfieldMajorRecordFlags: StarfieldMajorRecordFlags) + { + this.Race = Race; + } + + #pragma warning disable CS8618 + protected Mask() + { + } + #pragma warning restore CS8618 + + #endregion + + #region Members + public TItem Race; + #endregion + + #region Equals + public override bool Equals(object? obj) + { + if (!(obj is Mask rhs)) return false; + return Equals(rhs); + } + + public bool Equals(Mask? rhs) + { + if (rhs == null) return false; + if (!base.Equals(rhs)) return false; + if (!object.Equals(this.Race, rhs.Race)) return false; + return true; + } + public override int GetHashCode() + { + var hash = new HashCode(); + hash.Add(this.Race); + hash.Add(base.GetHashCode()); + return hash.ToHashCode(); + } + + #endregion + + #region All + public override bool All(Func eval) + { + if (!base.All(eval)) return false; + if (!eval(this.Race)) return false; + return true; + } + #endregion + + #region Any + public override bool Any(Func eval) + { + if (base.Any(eval)) return true; + if (eval(this.Race)) return true; + return false; + } + #endregion + + #region Translate + public new Mask Translate(Func eval) + { + var ret = new Npc.Mask(); + this.Translate_InternalFill(ret, eval); + return ret; + } + + protected void Translate_InternalFill(Mask obj, Func eval) + { + base.Translate_InternalFill(obj, eval); + obj.Race = eval(this.Race); + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public string Print(Npc.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print(sb, printMask); + return sb.ToString(); + } + + public void Print(StructuredStringBuilder sb, Npc.Mask? printMask = null) + { + sb.AppendLine($"{nameof(Npc.Mask)} =>"); + using (sb.Brace()) + { + if (printMask?.Race ?? true) + { + sb.AppendItem(Race, "Race"); + } + } + } + #endregion + + } + + public new class ErrorMask : + StarfieldMajorRecord.ErrorMask, + IErrorMask + { + #region Members + public Exception? Race; + #endregion + + #region IErrorMask + public override object? GetNthMask(int index) + { + Npc_FieldIndex enu = (Npc_FieldIndex)index; + switch (enu) + { + case Npc_FieldIndex.Race: + return Race; + default: + return base.GetNthMask(index); + } + } + + public override void SetNthException(int index, Exception ex) + { + Npc_FieldIndex enu = (Npc_FieldIndex)index; + switch (enu) + { + case Npc_FieldIndex.Race: + this.Race = ex; + break; + default: + base.SetNthException(index, ex); + break; + } + } + + public override void SetNthMask(int index, object obj) + { + Npc_FieldIndex enu = (Npc_FieldIndex)index; + switch (enu) + { + case Npc_FieldIndex.Race: + this.Race = (Exception?)obj; + break; + default: + base.SetNthMask(index, obj); + break; + } + } + + public override bool IsInError() + { + if (Overall != null) return true; + if (Race != null) return true; + return false; + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public override void Print(StructuredStringBuilder sb, string? name = null) + { + sb.AppendLine($"{(name ?? "ErrorMask")} =>"); + using (sb.Brace()) + { + if (this.Overall != null) + { + sb.AppendLine("Overall =>"); + using (sb.Brace()) + { + sb.AppendLine($"{this.Overall}"); + } + } + PrintFillInternal(sb); + } + } + protected override void PrintFillInternal(StructuredStringBuilder sb) + { + base.PrintFillInternal(sb); + { + sb.AppendItem(Race, "Race"); + } + } + #endregion + + #region Combine + public ErrorMask Combine(ErrorMask? rhs) + { + if (rhs == null) return this; + var ret = new ErrorMask(); + ret.Race = this.Race.Combine(rhs.Race); + return ret; + } + public static ErrorMask? Combine(ErrorMask? lhs, ErrorMask? rhs) + { + if (lhs != null && rhs != null) return lhs.Combine(rhs); + return lhs ?? rhs; + } + #endregion + + #region Factory + public static new ErrorMask Factory(ErrorMaskBuilder errorMask) + { + return new ErrorMask(); + } + #endregion + + } + public new class TranslationMask : + StarfieldMajorRecord.TranslationMask, + ITranslationMask + { + #region Members + public bool Race; + #endregion + + #region Ctors + public TranslationMask( + bool defaultOn, + bool onOverall = true) + : base(defaultOn, onOverall) + { + this.Race = defaultOn; + } + + #endregion + + protected override void GetCrystal(List<(bool On, TranslationCrystal? SubCrystal)> ret) + { + base.GetCrystal(ret); + ret.Add((Race, null)); + } + + public static implicit operator TranslationMask(bool defaultOn) + { + return new TranslationMask(defaultOn: defaultOn, onOverall: defaultOn); + } + + } + #endregion + + #region Mutagen + public static readonly RecordType GrupRecordType = Npc_Registration.TriggeringRecordType; + public override IEnumerable EnumerateFormLinks() => NpcCommon.Instance.EnumerateFormLinks(this); + public override void RemapLinks(IReadOnlyDictionary mapping) => NpcSetterCommon.Instance.RemapLinks(this, mapping); + public Npc(FormKey formKey) + { + this.FormKey = formKey; + this.FormVersion = GameRelease.Starfield.GetDefaultFormVersion()!.Value; + CustomCtor(); + } + + private Npc( + FormKey formKey, + GameRelease gameRelease) + { + this.FormKey = formKey; + this.FormVersion = gameRelease.GetDefaultFormVersion()!.Value; + CustomCtor(); + } + + internal Npc( + FormKey formKey, + ushort formVersion) + { + this.FormKey = formKey; + this.FormVersion = formVersion; + CustomCtor(); + } + + public Npc(IStarfieldMod mod) + : this(mod.GetNextFormKey()) + { + } + + public Npc(IStarfieldMod mod, string editorID) + : this(mod.GetNextFormKey(editorID)) + { + this.EditorID = editorID; + } + + public override string ToString() + { + return MajorRecordPrinter.ToString(this); + } + + protected override Type LinkType => typeof(INpc); + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is IFormLinkGetter formLink) + { + return formLink.Equals(this); + } + if (obj is not INpcGetter rhs) return false; + return ((NpcCommon)((INpcGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(INpcGetter? obj) + { + return ((NpcCommon)((INpcGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((NpcCommon)((INpcGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + #endregion + + #region Binary Translation + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected override object BinaryWriteTranslator => NpcBinaryWriteTranslation.Instance; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((NpcBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + #region Binary Create + public new static Npc CreateFromBinary( + MutagenFrame frame, + TypedParseParams translationParams = default) + { + var ret = new Npc(); + ((NpcSetterCommon)((INpcGetter)ret).CommonSetterInstance()!).CopyInFromBinary( + item: ret, + frame: frame, + translationParams: translationParams); + return ret; + } + + #endregion + + public static bool TryCreateFromBinary( + MutagenFrame frame, + out Npc item, + TypedParseParams translationParams = default) + { + var startPos = frame.Position; + item = CreateFromBinary( + frame: frame, + translationParams: translationParams); + return startPos != frame.Position; + } + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + void IClearable.Clear() + { + ((NpcSetterCommon)((INpcGetter)this).CommonSetterInstance()!).Clear(this); + } + + internal static new Npc GetNew() + { + return new Npc(); + } + + } + #endregion + + #region Interface + public partial interface INpc : + IFormLinkContainer, + ILoquiObjectSetter, + INpcGetter, + IStarfieldMajorRecordInternal + { + new IFormLink Race { get; set; } + } + + public partial interface INpcInternal : + IStarfieldMajorRecordInternal, + INpc, + INpcGetter + { + } + + [AssociatedRecordTypesAttribute(Mutagen.Bethesda.Starfield.Internals.RecordTypeInts.NPC_)] + public partial interface INpcGetter : + IStarfieldMajorRecordGetter, + IBinaryItem, + IFormLinkContainerGetter, + ILoquiObject, + IMapsToGetter + { + static new ILoquiRegistration StaticRegistration => Npc_Registration.Instance; + IFormLinkGetter Race { get; } + + } + + #endregion + + #region Common MixIn + public static partial class NpcMixIn + { + public static void Clear(this INpcInternal item) + { + ((NpcSetterCommon)((INpcGetter)item).CommonSetterInstance()!).Clear(item: item); + } + + public static Npc.Mask GetEqualsMask( + this INpcGetter item, + INpcGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + return ((NpcCommon)((INpcGetter)item).CommonInstance()!).GetEqualsMask( + item: item, + rhs: rhs, + include: include); + } + + public static string Print( + this INpcGetter item, + string? name = null, + Npc.Mask? printMask = null) + { + return ((NpcCommon)((INpcGetter)item).CommonInstance()!).Print( + item: item, + name: name, + printMask: printMask); + } + + public static void Print( + this INpcGetter item, + StructuredStringBuilder sb, + string? name = null, + Npc.Mask? printMask = null) + { + ((NpcCommon)((INpcGetter)item).CommonInstance()!).Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + } + + public static bool Equals( + this INpcGetter item, + INpcGetter rhs, + Npc.TranslationMask? equalsMask = null) + { + return ((NpcCommon)((INpcGetter)item).CommonInstance()!).Equals( + lhs: item, + rhs: rhs, + equalsMask: equalsMask?.GetCrystal()); + } + + public static void DeepCopyIn( + this INpcInternal lhs, + INpcGetter rhs, + out Npc.ErrorMask errorMask, + Npc.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + ((NpcSetterTranslationCommon)((INpcGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + errorMask = Npc.ErrorMask.Factory(errorMaskBuilder); + } + + public static void DeepCopyIn( + this INpcInternal lhs, + INpcGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask) + { + ((NpcSetterTranslationCommon)((INpcGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: false); + } + + public static Npc DeepCopy( + this INpcGetter item, + Npc.TranslationMask? copyMask = null) + { + return ((NpcSetterTranslationCommon)((INpcGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask); + } + + public static Npc DeepCopy( + this INpcGetter item, + out Npc.ErrorMask errorMask, + Npc.TranslationMask? copyMask = null) + { + return ((NpcSetterTranslationCommon)((INpcGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: out errorMask); + } + + public static Npc DeepCopy( + this INpcGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + return ((NpcSetterTranslationCommon)((INpcGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: errorMask); + } + + #region Mutagen + public static Npc Duplicate( + this INpcGetter item, + FormKey formKey, + Npc.TranslationMask? copyMask = null) + { + return ((NpcCommon)((INpcGetter)item).CommonInstance()!).Duplicate( + item: item, + formKey: formKey, + copyMask: copyMask?.GetCrystal()); + } + + public static Npc Duplicate( + this INpcGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + return ((NpcCommon)((INpcGetter)item).CommonInstance()!).Duplicate( + item: item, + formKey: formKey, + copyMask: copyMask); + } + + #endregion + + #region Binary Translation + public static void CopyInFromBinary( + this INpcInternal item, + MutagenFrame frame, + TypedParseParams translationParams = default) + { + ((NpcSetterCommon)((INpcGetter)item).CommonSetterInstance()!).CopyInFromBinary( + item: item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + #region Field Index + internal enum Npc_FieldIndex + { + MajorRecordFlagsRaw = 0, + FormKey = 1, + VersionControl = 2, + EditorID = 3, + FormVersion = 4, + Version2 = 5, + StarfieldMajorRecordFlags = 6, + Race = 7, + } + #endregion + + #region Registration + internal partial class Npc_Registration : ILoquiRegistration + { + public static readonly Npc_Registration Instance = new Npc_Registration(); + + public static ProtocolKey ProtocolKey => ProtocolDefinition_Starfield.ProtocolKey; + + public static readonly ObjectKey ObjectKey = new ObjectKey( + protocolKey: ProtocolDefinition_Starfield.ProtocolKey, + msgID: 67, + version: 0); + + public const string GUID = "bcf13200-857c-4f8b-b325-5ed79e6a0fde"; + + public const ushort AdditionalFieldCount = 1; + + public const ushort FieldCount = 8; + + public static readonly Type MaskType = typeof(Npc.Mask<>); + + public static readonly Type ErrorMaskType = typeof(Npc.ErrorMask); + + public static readonly Type ClassType = typeof(Npc); + + public static readonly Type GetterType = typeof(INpcGetter); + + public static readonly Type? InternalGetterType = null; + + public static readonly Type SetterType = typeof(INpc); + + public static readonly Type? InternalSetterType = typeof(INpcInternal); + + public const string FullName = "Mutagen.Bethesda.Starfield.Npc"; + + public const string Name = "Npc"; + + public const string Namespace = "Mutagen.Bethesda.Starfield"; + + public const byte GenericCount = 0; + + public static readonly Type? GenericRegistrationType = null; + + public static readonly RecordType TriggeringRecordType = RecordTypes.NPC_; + public static RecordTriggerSpecs TriggerSpecs => _recordSpecs.Value; + private static readonly Lazy _recordSpecs = new Lazy(() => + { + var triggers = RecordCollection.Factory(RecordTypes.NPC_); + var all = RecordCollection.Factory( + RecordTypes.NPC_, + RecordTypes.RNAM); + return new RecordTriggerSpecs(allRecordTypes: all, triggeringRecordTypes: triggers); + }); + public static readonly Type BinaryWriteTranslation = typeof(NpcBinaryWriteTranslation); + #region Interface + ProtocolKey ILoquiRegistration.ProtocolKey => ProtocolKey; + ObjectKey ILoquiRegistration.ObjectKey => ObjectKey; + string ILoquiRegistration.GUID => GUID; + ushort ILoquiRegistration.FieldCount => FieldCount; + ushort ILoquiRegistration.AdditionalFieldCount => AdditionalFieldCount; + Type ILoquiRegistration.MaskType => MaskType; + Type ILoquiRegistration.ErrorMaskType => ErrorMaskType; + Type ILoquiRegistration.ClassType => ClassType; + Type ILoquiRegistration.SetterType => SetterType; + Type? ILoquiRegistration.InternalSetterType => InternalSetterType; + Type ILoquiRegistration.GetterType => GetterType; + Type? ILoquiRegistration.InternalGetterType => InternalGetterType; + string ILoquiRegistration.FullName => FullName; + string ILoquiRegistration.Name => Name; + string ILoquiRegistration.Namespace => Namespace; + byte ILoquiRegistration.GenericCount => GenericCount; + Type? ILoquiRegistration.GenericRegistrationType => GenericRegistrationType; + ushort? ILoquiRegistration.GetNameIndex(StringCaseAgnostic name) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsEnumerable(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsLoqui(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsSingleton(ushort index) => throw new NotImplementedException(); + string ILoquiRegistration.GetNthName(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsNthDerivative(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsProtected(ushort index) => throw new NotImplementedException(); + Type ILoquiRegistration.GetNthType(ushort index) => throw new NotImplementedException(); + #endregion + + } + #endregion + + #region Common + internal partial class NpcSetterCommon : StarfieldMajorRecordSetterCommon + { + public new static readonly NpcSetterCommon Instance = new NpcSetterCommon(); + + partial void ClearPartial(); + + public void Clear(INpcInternal item) + { + ClearPartial(); + item.Race.Clear(); + base.Clear(item); + } + + public override void Clear(IStarfieldMajorRecordInternal item) + { + Clear(item: (INpcInternal)item); + } + + public override void Clear(IMajorRecordInternal item) + { + Clear(item: (INpcInternal)item); + } + + #region Mutagen + public void RemapLinks(INpc obj, IReadOnlyDictionary mapping) + { + base.RemapLinks(obj, mapping); + obj.Race.Relink(mapping); + } + + #endregion + + #region Binary Translation + public virtual void CopyInFromBinary( + INpcInternal item, + MutagenFrame frame, + TypedParseParams translationParams) + { + PluginUtilityTranslation.MajorRecordParse( + record: item, + frame: frame, + translationParams: translationParams, + fillStructs: NpcBinaryCreateTranslation.FillBinaryStructs, + fillTyped: NpcBinaryCreateTranslation.FillBinaryRecordTypes); + } + + public override void CopyInFromBinary( + IStarfieldMajorRecordInternal item, + MutagenFrame frame, + TypedParseParams translationParams) + { + CopyInFromBinary( + item: (Npc)item, + frame: frame, + translationParams: translationParams); + } + + public override void CopyInFromBinary( + IMajorRecordInternal item, + MutagenFrame frame, + TypedParseParams translationParams) + { + CopyInFromBinary( + item: (Npc)item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + internal partial class NpcCommon : StarfieldMajorRecordCommon + { + public new static readonly NpcCommon Instance = new NpcCommon(); + + public Npc.Mask GetEqualsMask( + INpcGetter item, + INpcGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + var ret = new Npc.Mask(false); + ((NpcCommon)((INpcGetter)item).CommonInstance()!).FillEqualsMask( + item: item, + rhs: rhs, + ret: ret, + include: include); + return ret; + } + + public void FillEqualsMask( + INpcGetter item, + INpcGetter rhs, + Npc.Mask ret, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + ret.Race = item.Race.Equals(rhs.Race); + base.FillEqualsMask(item, rhs, ret, include); + } + + public string Print( + INpcGetter item, + string? name = null, + Npc.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + return sb.ToString(); + } + + public void Print( + INpcGetter item, + StructuredStringBuilder sb, + string? name = null, + Npc.Mask? printMask = null) + { + if (name == null) + { + sb.AppendLine($"Npc =>"); + } + else + { + sb.AppendLine($"{name} (Npc) =>"); + } + using (sb.Brace()) + { + ToStringFields( + item: item, + sb: sb, + printMask: printMask); + } + } + + protected static void ToStringFields( + INpcGetter item, + StructuredStringBuilder sb, + Npc.Mask? printMask = null) + { + StarfieldMajorRecordCommon.ToStringFields( + item: item, + sb: sb, + printMask: printMask); + if (printMask?.Race ?? true) + { + sb.AppendItem(item.Race.FormKey, "Race"); + } + } + + public static Npc_FieldIndex ConvertFieldIndex(StarfieldMajorRecord_FieldIndex index) + { + switch (index) + { + case StarfieldMajorRecord_FieldIndex.MajorRecordFlagsRaw: + return (Npc_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.FormKey: + return (Npc_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.VersionControl: + return (Npc_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.EditorID: + return (Npc_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.FormVersion: + return (Npc_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.Version2: + return (Npc_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.StarfieldMajorRecordFlags: + return (Npc_FieldIndex)((int)index); + default: + throw new ArgumentException($"Index is out of range: {index.ToStringFast()}"); + } + } + + public static new Npc_FieldIndex ConvertFieldIndex(MajorRecord_FieldIndex index) + { + switch (index) + { + case MajorRecord_FieldIndex.MajorRecordFlagsRaw: + return (Npc_FieldIndex)((int)index); + case MajorRecord_FieldIndex.FormKey: + return (Npc_FieldIndex)((int)index); + case MajorRecord_FieldIndex.VersionControl: + return (Npc_FieldIndex)((int)index); + case MajorRecord_FieldIndex.EditorID: + return (Npc_FieldIndex)((int)index); + default: + throw new ArgumentException($"Index is out of range: {index.ToStringFast()}"); + } + } + + #region Equals and Hash + public virtual bool Equals( + INpcGetter? lhs, + INpcGetter? rhs, + TranslationCrystal? equalsMask) + { + if (!EqualsMaskHelper.RefEquality(lhs, rhs, out var isEqual)) return isEqual; + if (!base.Equals((IStarfieldMajorRecordGetter)lhs, (IStarfieldMajorRecordGetter)rhs, equalsMask)) return false; + if ((equalsMask?.GetShouldTranslate((int)Npc_FieldIndex.Race) ?? true)) + { + if (!lhs.Race.Equals(rhs.Race)) return false; + } + return true; + } + + public override bool Equals( + IStarfieldMajorRecordGetter? lhs, + IStarfieldMajorRecordGetter? rhs, + TranslationCrystal? equalsMask) + { + return Equals( + lhs: (INpcGetter?)lhs, + rhs: rhs as INpcGetter, + equalsMask: equalsMask); + } + + public override bool Equals( + IMajorRecordGetter? lhs, + IMajorRecordGetter? rhs, + TranslationCrystal? equalsMask) + { + return Equals( + lhs: (INpcGetter?)lhs, + rhs: rhs as INpcGetter, + equalsMask: equalsMask); + } + + public virtual int GetHashCode(INpcGetter item) + { + var hash = new HashCode(); + hash.Add(item.Race); + hash.Add(base.GetHashCode()); + return hash.ToHashCode(); + } + + public override int GetHashCode(IStarfieldMajorRecordGetter item) + { + return GetHashCode(item: (INpcGetter)item); + } + + public override int GetHashCode(IMajorRecordGetter item) + { + return GetHashCode(item: (INpcGetter)item); + } + + #endregion + + + public override object GetNew() + { + return Npc.GetNew(); + } + + #region Mutagen + public IEnumerable EnumerateFormLinks(INpcGetter obj) + { + foreach (var item in base.EnumerateFormLinks(obj)) + { + yield return item; + } + yield return FormLinkInformation.Factory(obj.Race); + yield break; + } + + #region Duplicate + public Npc Duplicate( + INpcGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + var newRec = new Npc(formKey); + newRec.DeepCopyIn(item, default(ErrorMaskBuilder?), copyMask); + return newRec; + } + + public override StarfieldMajorRecord Duplicate( + IStarfieldMajorRecordGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + return this.Duplicate( + item: (INpcGetter)item, + formKey: formKey, + copyMask: copyMask); + } + + public override MajorRecord Duplicate( + IMajorRecordGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + return this.Duplicate( + item: (INpcGetter)item, + formKey: formKey, + copyMask: copyMask); + } + + #endregion + + #endregion + + } + internal partial class NpcSetterTranslationCommon : StarfieldMajorRecordSetterTranslationCommon + { + public new static readonly NpcSetterTranslationCommon Instance = new NpcSetterTranslationCommon(); + + #region DeepCopyIn + public void DeepCopyIn( + INpcInternal item, + INpcGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + base.DeepCopyIn( + item, + rhs, + errorMask, + copyMask, + deepCopy: deepCopy); + } + + public void DeepCopyIn( + INpc item, + INpcGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + base.DeepCopyIn( + (IStarfieldMajorRecord)item, + (IStarfieldMajorRecordGetter)rhs, + errorMask, + copyMask, + deepCopy: deepCopy); + if ((copyMask?.GetShouldTranslate((int)Npc_FieldIndex.Race) ?? true)) + { + item.Race.SetTo(rhs.Race.FormKey); + } + } + + public override void DeepCopyIn( + IStarfieldMajorRecordInternal item, + IStarfieldMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (INpcInternal)item, + rhs: (INpcGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + public override void DeepCopyIn( + IStarfieldMajorRecord item, + IStarfieldMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (INpc)item, + rhs: (INpcGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + public override void DeepCopyIn( + IMajorRecordInternal item, + IMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (INpcInternal)item, + rhs: (INpcGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + public override void DeepCopyIn( + IMajorRecord item, + IMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (INpc)item, + rhs: (INpcGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + #endregion + + public Npc DeepCopy( + INpcGetter item, + Npc.TranslationMask? copyMask = null) + { + Npc ret = (Npc)((NpcCommon)((INpcGetter)item).CommonInstance()!).GetNew(); + ((NpcSetterTranslationCommon)((INpcGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: null, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + return ret; + } + + public Npc DeepCopy( + INpcGetter item, + out Npc.ErrorMask errorMask, + Npc.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + Npc ret = (Npc)((NpcCommon)((INpcGetter)item).CommonInstance()!).GetNew(); + ((NpcSetterTranslationCommon)((INpcGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + ret, + item, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + errorMask = Npc.ErrorMask.Factory(errorMaskBuilder); + return ret; + } + + public Npc DeepCopy( + INpcGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + Npc ret = (Npc)((NpcCommon)((INpcGetter)item).CommonInstance()!).GetNew(); + ((NpcSetterTranslationCommon)((INpcGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: true); + return ret; + } + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + public partial class Npc + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => Npc_Registration.Instance; + public new static ILoquiRegistration StaticRegistration => Npc_Registration.Instance; + [DebuggerStepThrough] + protected override object CommonInstance() => NpcCommon.Instance; + [DebuggerStepThrough] + protected override object CommonSetterInstance() + { + return NpcSetterCommon.Instance; + } + [DebuggerStepThrough] + protected override object CommonSetterTranslationInstance() => NpcSetterTranslationCommon.Instance; + + #endregion + + } +} + +#region Modules +#region Binary Translation +namespace Mutagen.Bethesda.Starfield +{ + public partial class NpcBinaryWriteTranslation : + StarfieldMajorRecordBinaryWriteTranslation, + IBinaryWriteTranslator + { + public new static readonly NpcBinaryWriteTranslation Instance = new(); + + public static void WriteRecordTypes( + INpcGetter item, + MutagenWriter writer, + TypedWriteParams translationParams) + { + MajorRecordBinaryWriteTranslation.WriteRecordTypes( + item: item, + writer: writer, + translationParams: translationParams); + FormLinkBinaryTranslation.Instance.Write( + writer: writer, + item: item.Race, + header: translationParams.ConvertToCustom(RecordTypes.RNAM)); + } + + public void Write( + MutagenWriter writer, + INpcGetter item, + TypedWriteParams translationParams) + { + using (HeaderExport.Record( + writer: writer, + record: translationParams.ConvertToCustom(RecordTypes.NPC_))) + { + try + { + StarfieldMajorRecordBinaryWriteTranslation.WriteEmbedded( + item: item, + writer: writer); + if (!item.IsDeleted) + { + writer.MetaData.FormVersion = item.FormVersion; + WriteRecordTypes( + item: item, + writer: writer, + translationParams: translationParams); + writer.MetaData.FormVersion = null; + } + } + catch (Exception ex) + { + throw RecordException.Enrich(ex, item); + } + } + } + + public override void Write( + MutagenWriter writer, + object item, + TypedWriteParams translationParams = default) + { + Write( + item: (INpcGetter)item, + writer: writer, + translationParams: translationParams); + } + + public override void Write( + MutagenWriter writer, + IStarfieldMajorRecordGetter item, + TypedWriteParams translationParams) + { + Write( + item: (INpcGetter)item, + writer: writer, + translationParams: translationParams); + } + + public override void Write( + MutagenWriter writer, + IMajorRecordGetter item, + TypedWriteParams translationParams) + { + Write( + item: (INpcGetter)item, + writer: writer, + translationParams: translationParams); + } + + } + + internal partial class NpcBinaryCreateTranslation : StarfieldMajorRecordBinaryCreateTranslation + { + public new static readonly NpcBinaryCreateTranslation Instance = new NpcBinaryCreateTranslation(); + + public override RecordType RecordType => RecordTypes.NPC_; + public static ParseResult FillBinaryRecordTypes( + INpcInternal item, + MutagenFrame frame, + PreviousParse lastParsed, + Dictionary? recordParseCount, + RecordType nextRecordType, + int contentLength, + TypedParseParams translationParams = default) + { + nextRecordType = translationParams.ConvertToStandard(nextRecordType); + switch (nextRecordType.TypeInt) + { + case RecordTypeInts.RNAM: + { + frame.Position += frame.MetaData.Constants.SubConstants.HeaderLength; + item.Race.SetTo(FormLinkBinaryTranslation.Instance.Parse(reader: frame)); + return (int)Npc_FieldIndex.Race; + } + default: + return StarfieldMajorRecordBinaryCreateTranslation.FillBinaryRecordTypes( + item: item, + frame: frame, + lastParsed: lastParsed, + recordParseCount: recordParseCount, + nextRecordType: nextRecordType, + contentLength: contentLength, + translationParams: translationParams.WithNoConverter()); + } + } + + } + +} +namespace Mutagen.Bethesda.Starfield +{ + #region Binary Write Mixins + public static class NpcBinaryTranslationMixIn + { + } + #endregion + + +} +namespace Mutagen.Bethesda.Starfield +{ + internal partial class NpcBinaryOverlay : + StarfieldMajorRecordBinaryOverlay, + INpcGetter + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => Npc_Registration.Instance; + public new static ILoquiRegistration StaticRegistration => Npc_Registration.Instance; + [DebuggerStepThrough] + protected override object CommonInstance() => NpcCommon.Instance; + [DebuggerStepThrough] + protected override object CommonSetterTranslationInstance() => NpcSetterTranslationCommon.Instance; + + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + public override IEnumerable EnumerateFormLinks() => NpcCommon.Instance.EnumerateFormLinks(this); + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected override object BinaryWriteTranslator => NpcBinaryWriteTranslation.Instance; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((NpcBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + protected override Type LinkType => typeof(INpc); + + + #region Race + private int? _RaceLocation; + public IFormLinkGetter Race => _RaceLocation.HasValue ? new FormLink(FormKey.Factory(_package.MetaData.MasterReferences!, BinaryPrimitives.ReadUInt32LittleEndian(HeaderTranslation.ExtractSubrecordMemory(_recordData, _RaceLocation.Value, _package.MetaData.Constants)))) : FormLink.Null; + #endregion + partial void CustomFactoryEnd( + OverlayStream stream, + int finalPos, + int offset); + + partial void CustomCtor(); + protected NpcBinaryOverlay( + MemoryPair memoryPair, + BinaryOverlayFactoryPackage package) + : base( + memoryPair: memoryPair, + package: package) + { + this.CustomCtor(); + } + + public static INpcGetter NpcFactory( + OverlayStream stream, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + stream = Decompression.DecompressStream(stream); + stream = ExtractRecordMemory( + stream: stream, + meta: package.MetaData.Constants, + memoryPair: out var memoryPair, + offset: out var offset, + finalPos: out var finalPos); + var ret = new NpcBinaryOverlay( + memoryPair: memoryPair, + package: package); + ret._package.FormVersion = ret; + ret.CustomFactoryEnd( + stream: stream, + finalPos: finalPos, + offset: offset); + ret.FillSubrecordTypes( + majorReference: ret, + stream: stream, + finalPos: finalPos, + offset: offset, + translationParams: translationParams, + fill: ret.FillRecordType); + return ret; + } + + public static INpcGetter NpcFactory( + ReadOnlyMemorySlice slice, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + return NpcFactory( + stream: new OverlayStream(slice, package), + package: package, + translationParams: translationParams); + } + + public override ParseResult FillRecordType( + OverlayStream stream, + int finalPos, + int offset, + RecordType type, + PreviousParse lastParsed, + Dictionary? recordParseCount, + TypedParseParams translationParams = default) + { + type = translationParams.ConvertToStandard(type); + switch (type.TypeInt) + { + case RecordTypeInts.RNAM: + { + _RaceLocation = (stream.Position - offset); + return (int)Npc_FieldIndex.Race; + } + default: + return base.FillRecordType( + stream: stream, + finalPos: finalPos, + offset: offset, + type: type, + lastParsed: lastParsed, + recordParseCount: recordParseCount, + translationParams: translationParams.WithNoConverter()); + } + } + #region To String + + public override void Print( + StructuredStringBuilder sb, + string? name = null) + { + NpcMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + public override string ToString() + { + return MajorRecordPrinter.ToString(this); + } + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is IFormLinkGetter formLink) + { + return formLink.Equals(this); + } + if (obj is not INpcGetter rhs) return false; + return ((NpcCommon)((INpcGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(INpcGetter? obj) + { + return ((NpcCommon)((INpcGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((NpcCommon)((INpcGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + } + +} +#endregion + +#endregion + diff --git a/Mutagen.Bethesda.Starfield/Records/ProtocolDefinition_Starfield.cs b/Mutagen.Bethesda.Starfield/Records/ProtocolDefinition_Starfield.cs new file mode 100644 index 0000000000..33194e1f36 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/ProtocolDefinition_Starfield.cs @@ -0,0 +1,24 @@ +using Mutagen.Bethesda.Starfield; + +namespace Loqui; + +internal class ProtocolDefinition_Starfield : IProtocolRegistration +{ + public static readonly ProtocolKey ProtocolKey = new("Starfield"); + void IProtocolRegistration.Register() => Register(); + public static void Register() + { + LoquiRegistration.Register( + StarfieldGroup_Registration.Instance, + StarfieldModHeader_Registration.Instance, + ModStats_Registration.Instance, + StarfieldMajorRecord_Registration.Instance, + StarfieldMod_Registration.Instance, + Npc_Registration.Instance, + Race_Registration.Instance, + Weapon_Registration.Instance, + SimpleModel_Registration.Instance, + Model_Registration.Instance + ); + } +} diff --git a/Mutagen.Bethesda.Starfield/Records/Race.xml b/Mutagen.Bethesda.Starfield/Records/Race.xml new file mode 100644 index 0000000000..3a25e32f60 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/Race.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Mutagen.Bethesda.Starfield/Records/Race_Generated.cs b/Mutagen.Bethesda.Starfield/Records/Race_Generated.cs new file mode 100644 index 0000000000..642deb5f42 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/Race_Generated.cs @@ -0,0 +1,1390 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Autogenerated by Loqui. Do not manually change. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ +#region Usings +using Loqui; +using Loqui.Interfaces; +using Loqui.Internal; +using Mutagen.Bethesda.Binary; +using Mutagen.Bethesda.Plugins; +using Mutagen.Bethesda.Plugins.Binary.Headers; +using Mutagen.Bethesda.Plugins.Binary.Overlay; +using Mutagen.Bethesda.Plugins.Binary.Streams; +using Mutagen.Bethesda.Plugins.Binary.Translations; +using Mutagen.Bethesda.Plugins.Exceptions; +using Mutagen.Bethesda.Plugins.Internals; +using Mutagen.Bethesda.Plugins.Records; +using Mutagen.Bethesda.Plugins.Records.Internals; +using Mutagen.Bethesda.Plugins.Records.Mapping; +using Mutagen.Bethesda.Plugins.RecordTypeMapping; +using Mutagen.Bethesda.Plugins.Utility; +using Mutagen.Bethesda.Starfield; +using Mutagen.Bethesda.Starfield.Internals; +using Mutagen.Bethesda.Translations.Binary; +using Noggog; +using Noggog.StructuredStrings; +using Noggog.StructuredStrings.CSharp; +using RecordTypeInts = Mutagen.Bethesda.Starfield.Internals.RecordTypeInts; +using RecordTypes = Mutagen.Bethesda.Starfield.Internals.RecordTypes; +using System.Buffers.Binary; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Reactive.Disposables; +using System.Reactive.Linq; +#endregion + +#nullable enable +namespace Mutagen.Bethesda.Starfield +{ + #region Class + public partial class Race : + StarfieldMajorRecord, + IEquatable, + ILoquiObjectSetter, + IRaceInternal + { + #region Ctor + protected Race() + { + CustomCtor(); + } + partial void CustomCtor(); + #endregion + + + #region To String + + public override void Print( + StructuredStringBuilder sb, + string? name = null) + { + RaceMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Mask + public new class Mask : + StarfieldMajorRecord.Mask, + IEquatable>, + IMask + { + #region Ctors + public Mask(TItem initialValue) + : base(initialValue) + { + } + + public Mask( + TItem MajorRecordFlagsRaw, + TItem FormKey, + TItem VersionControl, + TItem EditorID, + TItem FormVersion, + TItem Version2, + TItem StarfieldMajorRecordFlags) + : base( + MajorRecordFlagsRaw: MajorRecordFlagsRaw, + FormKey: FormKey, + VersionControl: VersionControl, + EditorID: EditorID, + FormVersion: FormVersion, + Version2: Version2, + StarfieldMajorRecordFlags: StarfieldMajorRecordFlags) + { + } + + #pragma warning disable CS8618 + protected Mask() + { + } + #pragma warning restore CS8618 + + #endregion + + #region Equals + public override bool Equals(object? obj) + { + if (!(obj is Mask rhs)) return false; + return Equals(rhs); + } + + public bool Equals(Mask? rhs) + { + if (rhs == null) return false; + if (!base.Equals(rhs)) return false; + return true; + } + public override int GetHashCode() + { + var hash = new HashCode(); + hash.Add(base.GetHashCode()); + return hash.ToHashCode(); + } + + #endregion + + #region All + public override bool All(Func eval) + { + if (!base.All(eval)) return false; + return true; + } + #endregion + + #region Any + public override bool Any(Func eval) + { + if (base.Any(eval)) return true; + return false; + } + #endregion + + #region Translate + public new Mask Translate(Func eval) + { + var ret = new Race.Mask(); + this.Translate_InternalFill(ret, eval); + return ret; + } + + protected void Translate_InternalFill(Mask obj, Func eval) + { + base.Translate_InternalFill(obj, eval); + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public string Print(Race.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print(sb, printMask); + return sb.ToString(); + } + + public void Print(StructuredStringBuilder sb, Race.Mask? printMask = null) + { + sb.AppendLine($"{nameof(Race.Mask)} =>"); + using (sb.Brace()) + { + } + } + #endregion + + } + + public new class ErrorMask : + StarfieldMajorRecord.ErrorMask, + IErrorMask + { + #region IErrorMask + public override object? GetNthMask(int index) + { + Race_FieldIndex enu = (Race_FieldIndex)index; + switch (enu) + { + default: + return base.GetNthMask(index); + } + } + + public override void SetNthException(int index, Exception ex) + { + Race_FieldIndex enu = (Race_FieldIndex)index; + switch (enu) + { + default: + base.SetNthException(index, ex); + break; + } + } + + public override void SetNthMask(int index, object obj) + { + Race_FieldIndex enu = (Race_FieldIndex)index; + switch (enu) + { + default: + base.SetNthMask(index, obj); + break; + } + } + + public override bool IsInError() + { + if (Overall != null) return true; + return false; + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public override void Print(StructuredStringBuilder sb, string? name = null) + { + sb.AppendLine($"{(name ?? "ErrorMask")} =>"); + using (sb.Brace()) + { + if (this.Overall != null) + { + sb.AppendLine("Overall =>"); + using (sb.Brace()) + { + sb.AppendLine($"{this.Overall}"); + } + } + PrintFillInternal(sb); + } + } + protected override void PrintFillInternal(StructuredStringBuilder sb) + { + base.PrintFillInternal(sb); + } + #endregion + + #region Combine + public ErrorMask Combine(ErrorMask? rhs) + { + if (rhs == null) return this; + var ret = new ErrorMask(); + return ret; + } + public static ErrorMask? Combine(ErrorMask? lhs, ErrorMask? rhs) + { + if (lhs != null && rhs != null) return lhs.Combine(rhs); + return lhs ?? rhs; + } + #endregion + + #region Factory + public static new ErrorMask Factory(ErrorMaskBuilder errorMask) + { + return new ErrorMask(); + } + #endregion + + } + public new class TranslationMask : + StarfieldMajorRecord.TranslationMask, + ITranslationMask + { + #region Ctors + public TranslationMask( + bool defaultOn, + bool onOverall = true) + : base(defaultOn, onOverall) + { + } + + #endregion + + public static implicit operator TranslationMask(bool defaultOn) + { + return new TranslationMask(defaultOn: defaultOn, onOverall: defaultOn); + } + + } + #endregion + + #region Mutagen + public static readonly RecordType GrupRecordType = Race_Registration.TriggeringRecordType; + public Race(FormKey formKey) + { + this.FormKey = formKey; + this.FormVersion = GameRelease.Starfield.GetDefaultFormVersion()!.Value; + CustomCtor(); + } + + private Race( + FormKey formKey, + GameRelease gameRelease) + { + this.FormKey = formKey; + this.FormVersion = gameRelease.GetDefaultFormVersion()!.Value; + CustomCtor(); + } + + internal Race( + FormKey formKey, + ushort formVersion) + { + this.FormKey = formKey; + this.FormVersion = formVersion; + CustomCtor(); + } + + public Race(IStarfieldMod mod) + : this(mod.GetNextFormKey()) + { + } + + public Race(IStarfieldMod mod, string editorID) + : this(mod.GetNextFormKey(editorID)) + { + this.EditorID = editorID; + } + + public override string ToString() + { + return MajorRecordPrinter.ToString(this); + } + + protected override Type LinkType => typeof(IRace); + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is IFormLinkGetter formLink) + { + return formLink.Equals(this); + } + if (obj is not IRaceGetter rhs) return false; + return ((RaceCommon)((IRaceGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IRaceGetter? obj) + { + return ((RaceCommon)((IRaceGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((RaceCommon)((IRaceGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + #endregion + + #region Binary Translation + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected override object BinaryWriteTranslator => RaceBinaryWriteTranslation.Instance; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((RaceBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + #region Binary Create + public new static Race CreateFromBinary( + MutagenFrame frame, + TypedParseParams translationParams = default) + { + var ret = new Race(); + ((RaceSetterCommon)((IRaceGetter)ret).CommonSetterInstance()!).CopyInFromBinary( + item: ret, + frame: frame, + translationParams: translationParams); + return ret; + } + + #endregion + + public static bool TryCreateFromBinary( + MutagenFrame frame, + out Race item, + TypedParseParams translationParams = default) + { + var startPos = frame.Position; + item = CreateFromBinary( + frame: frame, + translationParams: translationParams); + return startPos != frame.Position; + } + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + void IClearable.Clear() + { + ((RaceSetterCommon)((IRaceGetter)this).CommonSetterInstance()!).Clear(this); + } + + internal static new Race GetNew() + { + return new Race(); + } + + } + #endregion + + #region Interface + public partial interface IRace : + ILoquiObjectSetter, + IRaceGetter, + IStarfieldMajorRecordInternal + { + } + + public partial interface IRaceInternal : + IStarfieldMajorRecordInternal, + IRace, + IRaceGetter + { + } + + [AssociatedRecordTypesAttribute(Mutagen.Bethesda.Starfield.Internals.RecordTypeInts.RACE)] + public partial interface IRaceGetter : + IStarfieldMajorRecordGetter, + IBinaryItem, + ILoquiObject, + IMapsToGetter + { + static new ILoquiRegistration StaticRegistration => Race_Registration.Instance; + + } + + #endregion + + #region Common MixIn + public static partial class RaceMixIn + { + public static void Clear(this IRaceInternal item) + { + ((RaceSetterCommon)((IRaceGetter)item).CommonSetterInstance()!).Clear(item: item); + } + + public static Race.Mask GetEqualsMask( + this IRaceGetter item, + IRaceGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + return ((RaceCommon)((IRaceGetter)item).CommonInstance()!).GetEqualsMask( + item: item, + rhs: rhs, + include: include); + } + + public static string Print( + this IRaceGetter item, + string? name = null, + Race.Mask? printMask = null) + { + return ((RaceCommon)((IRaceGetter)item).CommonInstance()!).Print( + item: item, + name: name, + printMask: printMask); + } + + public static void Print( + this IRaceGetter item, + StructuredStringBuilder sb, + string? name = null, + Race.Mask? printMask = null) + { + ((RaceCommon)((IRaceGetter)item).CommonInstance()!).Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + } + + public static bool Equals( + this IRaceGetter item, + IRaceGetter rhs, + Race.TranslationMask? equalsMask = null) + { + return ((RaceCommon)((IRaceGetter)item).CommonInstance()!).Equals( + lhs: item, + rhs: rhs, + equalsMask: equalsMask?.GetCrystal()); + } + + public static void DeepCopyIn( + this IRaceInternal lhs, + IRaceGetter rhs, + out Race.ErrorMask errorMask, + Race.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + ((RaceSetterTranslationCommon)((IRaceGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + errorMask = Race.ErrorMask.Factory(errorMaskBuilder); + } + + public static void DeepCopyIn( + this IRaceInternal lhs, + IRaceGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask) + { + ((RaceSetterTranslationCommon)((IRaceGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: false); + } + + public static Race DeepCopy( + this IRaceGetter item, + Race.TranslationMask? copyMask = null) + { + return ((RaceSetterTranslationCommon)((IRaceGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask); + } + + public static Race DeepCopy( + this IRaceGetter item, + out Race.ErrorMask errorMask, + Race.TranslationMask? copyMask = null) + { + return ((RaceSetterTranslationCommon)((IRaceGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: out errorMask); + } + + public static Race DeepCopy( + this IRaceGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + return ((RaceSetterTranslationCommon)((IRaceGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: errorMask); + } + + #region Mutagen + public static Race Duplicate( + this IRaceGetter item, + FormKey formKey, + Race.TranslationMask? copyMask = null) + { + return ((RaceCommon)((IRaceGetter)item).CommonInstance()!).Duplicate( + item: item, + formKey: formKey, + copyMask: copyMask?.GetCrystal()); + } + + public static Race Duplicate( + this IRaceGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + return ((RaceCommon)((IRaceGetter)item).CommonInstance()!).Duplicate( + item: item, + formKey: formKey, + copyMask: copyMask); + } + + #endregion + + #region Binary Translation + public static void CopyInFromBinary( + this IRaceInternal item, + MutagenFrame frame, + TypedParseParams translationParams = default) + { + ((RaceSetterCommon)((IRaceGetter)item).CommonSetterInstance()!).CopyInFromBinary( + item: item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + #region Field Index + internal enum Race_FieldIndex + { + MajorRecordFlagsRaw = 0, + FormKey = 1, + VersionControl = 2, + EditorID = 3, + FormVersion = 4, + Version2 = 5, + StarfieldMajorRecordFlags = 6, + } + #endregion + + #region Registration + internal partial class Race_Registration : ILoquiRegistration + { + public static readonly Race_Registration Instance = new Race_Registration(); + + public static ProtocolKey ProtocolKey => ProtocolDefinition_Starfield.ProtocolKey; + + public static readonly ObjectKey ObjectKey = new ObjectKey( + protocolKey: ProtocolDefinition_Starfield.ProtocolKey, + msgID: 68, + version: 0); + + public const string GUID = "b8b4ae9e-e154-49e1-93c9-a4b103de73c3"; + + public const ushort AdditionalFieldCount = 0; + + public const ushort FieldCount = 7; + + public static readonly Type MaskType = typeof(Race.Mask<>); + + public static readonly Type ErrorMaskType = typeof(Race.ErrorMask); + + public static readonly Type ClassType = typeof(Race); + + public static readonly Type GetterType = typeof(IRaceGetter); + + public static readonly Type? InternalGetterType = null; + + public static readonly Type SetterType = typeof(IRace); + + public static readonly Type? InternalSetterType = typeof(IRaceInternal); + + public const string FullName = "Mutagen.Bethesda.Starfield.Race"; + + public const string Name = "Race"; + + public const string Namespace = "Mutagen.Bethesda.Starfield"; + + public const byte GenericCount = 0; + + public static readonly Type? GenericRegistrationType = null; + + public static readonly RecordType TriggeringRecordType = RecordTypes.RACE; + public static RecordTriggerSpecs TriggerSpecs => _recordSpecs.Value; + private static readonly Lazy _recordSpecs = new Lazy(() => + { + var all = RecordCollection.Factory(RecordTypes.RACE); + return new RecordTriggerSpecs(allRecordTypes: all); + }); + public static readonly Type BinaryWriteTranslation = typeof(RaceBinaryWriteTranslation); + #region Interface + ProtocolKey ILoquiRegistration.ProtocolKey => ProtocolKey; + ObjectKey ILoquiRegistration.ObjectKey => ObjectKey; + string ILoquiRegistration.GUID => GUID; + ushort ILoquiRegistration.FieldCount => FieldCount; + ushort ILoquiRegistration.AdditionalFieldCount => AdditionalFieldCount; + Type ILoquiRegistration.MaskType => MaskType; + Type ILoquiRegistration.ErrorMaskType => ErrorMaskType; + Type ILoquiRegistration.ClassType => ClassType; + Type ILoquiRegistration.SetterType => SetterType; + Type? ILoquiRegistration.InternalSetterType => InternalSetterType; + Type ILoquiRegistration.GetterType => GetterType; + Type? ILoquiRegistration.InternalGetterType => InternalGetterType; + string ILoquiRegistration.FullName => FullName; + string ILoquiRegistration.Name => Name; + string ILoquiRegistration.Namespace => Namespace; + byte ILoquiRegistration.GenericCount => GenericCount; + Type? ILoquiRegistration.GenericRegistrationType => GenericRegistrationType; + ushort? ILoquiRegistration.GetNameIndex(StringCaseAgnostic name) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsEnumerable(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsLoqui(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsSingleton(ushort index) => throw new NotImplementedException(); + string ILoquiRegistration.GetNthName(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsNthDerivative(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsProtected(ushort index) => throw new NotImplementedException(); + Type ILoquiRegistration.GetNthType(ushort index) => throw new NotImplementedException(); + #endregion + + } + #endregion + + #region Common + internal partial class RaceSetterCommon : StarfieldMajorRecordSetterCommon + { + public new static readonly RaceSetterCommon Instance = new RaceSetterCommon(); + + partial void ClearPartial(); + + public void Clear(IRaceInternal item) + { + ClearPartial(); + base.Clear(item); + } + + public override void Clear(IStarfieldMajorRecordInternal item) + { + Clear(item: (IRaceInternal)item); + } + + public override void Clear(IMajorRecordInternal item) + { + Clear(item: (IRaceInternal)item); + } + + #region Mutagen + public void RemapLinks(IRace obj, IReadOnlyDictionary mapping) + { + base.RemapLinks(obj, mapping); + } + + #endregion + + #region Binary Translation + public virtual void CopyInFromBinary( + IRaceInternal item, + MutagenFrame frame, + TypedParseParams translationParams) + { + PluginUtilityTranslation.MajorRecordParse( + record: item, + frame: frame, + translationParams: translationParams, + fillStructs: RaceBinaryCreateTranslation.FillBinaryStructs, + fillTyped: RaceBinaryCreateTranslation.FillBinaryRecordTypes); + } + + public override void CopyInFromBinary( + IStarfieldMajorRecordInternal item, + MutagenFrame frame, + TypedParseParams translationParams) + { + CopyInFromBinary( + item: (Race)item, + frame: frame, + translationParams: translationParams); + } + + public override void CopyInFromBinary( + IMajorRecordInternal item, + MutagenFrame frame, + TypedParseParams translationParams) + { + CopyInFromBinary( + item: (Race)item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + internal partial class RaceCommon : StarfieldMajorRecordCommon + { + public new static readonly RaceCommon Instance = new RaceCommon(); + + public Race.Mask GetEqualsMask( + IRaceGetter item, + IRaceGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + var ret = new Race.Mask(false); + ((RaceCommon)((IRaceGetter)item).CommonInstance()!).FillEqualsMask( + item: item, + rhs: rhs, + ret: ret, + include: include); + return ret; + } + + public void FillEqualsMask( + IRaceGetter item, + IRaceGetter rhs, + Race.Mask ret, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + base.FillEqualsMask(item, rhs, ret, include); + } + + public string Print( + IRaceGetter item, + string? name = null, + Race.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + return sb.ToString(); + } + + public void Print( + IRaceGetter item, + StructuredStringBuilder sb, + string? name = null, + Race.Mask? printMask = null) + { + if (name == null) + { + sb.AppendLine($"Race =>"); + } + else + { + sb.AppendLine($"{name} (Race) =>"); + } + using (sb.Brace()) + { + ToStringFields( + item: item, + sb: sb, + printMask: printMask); + } + } + + protected static void ToStringFields( + IRaceGetter item, + StructuredStringBuilder sb, + Race.Mask? printMask = null) + { + StarfieldMajorRecordCommon.ToStringFields( + item: item, + sb: sb, + printMask: printMask); + } + + public static Race_FieldIndex ConvertFieldIndex(StarfieldMajorRecord_FieldIndex index) + { + switch (index) + { + case StarfieldMajorRecord_FieldIndex.MajorRecordFlagsRaw: + return (Race_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.FormKey: + return (Race_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.VersionControl: + return (Race_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.EditorID: + return (Race_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.FormVersion: + return (Race_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.Version2: + return (Race_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.StarfieldMajorRecordFlags: + return (Race_FieldIndex)((int)index); + default: + throw new ArgumentException($"Index is out of range: {index.ToStringFast()}"); + } + } + + public static new Race_FieldIndex ConvertFieldIndex(MajorRecord_FieldIndex index) + { + switch (index) + { + case MajorRecord_FieldIndex.MajorRecordFlagsRaw: + return (Race_FieldIndex)((int)index); + case MajorRecord_FieldIndex.FormKey: + return (Race_FieldIndex)((int)index); + case MajorRecord_FieldIndex.VersionControl: + return (Race_FieldIndex)((int)index); + case MajorRecord_FieldIndex.EditorID: + return (Race_FieldIndex)((int)index); + default: + throw new ArgumentException($"Index is out of range: {index.ToStringFast()}"); + } + } + + #region Equals and Hash + public virtual bool Equals( + IRaceGetter? lhs, + IRaceGetter? rhs, + TranslationCrystal? equalsMask) + { + if (!EqualsMaskHelper.RefEquality(lhs, rhs, out var isEqual)) return isEqual; + if (!base.Equals((IStarfieldMajorRecordGetter)lhs, (IStarfieldMajorRecordGetter)rhs, equalsMask)) return false; + return true; + } + + public override bool Equals( + IStarfieldMajorRecordGetter? lhs, + IStarfieldMajorRecordGetter? rhs, + TranslationCrystal? equalsMask) + { + return Equals( + lhs: (IRaceGetter?)lhs, + rhs: rhs as IRaceGetter, + equalsMask: equalsMask); + } + + public override bool Equals( + IMajorRecordGetter? lhs, + IMajorRecordGetter? rhs, + TranslationCrystal? equalsMask) + { + return Equals( + lhs: (IRaceGetter?)lhs, + rhs: rhs as IRaceGetter, + equalsMask: equalsMask); + } + + public virtual int GetHashCode(IRaceGetter item) + { + var hash = new HashCode(); + hash.Add(base.GetHashCode()); + return hash.ToHashCode(); + } + + public override int GetHashCode(IStarfieldMajorRecordGetter item) + { + return GetHashCode(item: (IRaceGetter)item); + } + + public override int GetHashCode(IMajorRecordGetter item) + { + return GetHashCode(item: (IRaceGetter)item); + } + + #endregion + + + public override object GetNew() + { + return Race.GetNew(); + } + + #region Mutagen + public IEnumerable EnumerateFormLinks(IRaceGetter obj) + { + foreach (var item in base.EnumerateFormLinks(obj)) + { + yield return item; + } + yield break; + } + + #region Duplicate + public Race Duplicate( + IRaceGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + var newRec = new Race(formKey); + newRec.DeepCopyIn(item, default(ErrorMaskBuilder?), copyMask); + return newRec; + } + + public override StarfieldMajorRecord Duplicate( + IStarfieldMajorRecordGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + return this.Duplicate( + item: (IRaceGetter)item, + formKey: formKey, + copyMask: copyMask); + } + + public override MajorRecord Duplicate( + IMajorRecordGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + return this.Duplicate( + item: (IRaceGetter)item, + formKey: formKey, + copyMask: copyMask); + } + + #endregion + + #endregion + + } + internal partial class RaceSetterTranslationCommon : StarfieldMajorRecordSetterTranslationCommon + { + public new static readonly RaceSetterTranslationCommon Instance = new RaceSetterTranslationCommon(); + + #region DeepCopyIn + public void DeepCopyIn( + IRaceInternal item, + IRaceGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + base.DeepCopyIn( + item, + rhs, + errorMask, + copyMask, + deepCopy: deepCopy); + } + + public void DeepCopyIn( + IRace item, + IRaceGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + base.DeepCopyIn( + (IStarfieldMajorRecord)item, + (IStarfieldMajorRecordGetter)rhs, + errorMask, + copyMask, + deepCopy: deepCopy); + } + + public override void DeepCopyIn( + IStarfieldMajorRecordInternal item, + IStarfieldMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (IRaceInternal)item, + rhs: (IRaceGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + public override void DeepCopyIn( + IStarfieldMajorRecord item, + IStarfieldMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (IRace)item, + rhs: (IRaceGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + public override void DeepCopyIn( + IMajorRecordInternal item, + IMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (IRaceInternal)item, + rhs: (IRaceGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + public override void DeepCopyIn( + IMajorRecord item, + IMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (IRace)item, + rhs: (IRaceGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + #endregion + + public Race DeepCopy( + IRaceGetter item, + Race.TranslationMask? copyMask = null) + { + Race ret = (Race)((RaceCommon)((IRaceGetter)item).CommonInstance()!).GetNew(); + ((RaceSetterTranslationCommon)((IRaceGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: null, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + return ret; + } + + public Race DeepCopy( + IRaceGetter item, + out Race.ErrorMask errorMask, + Race.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + Race ret = (Race)((RaceCommon)((IRaceGetter)item).CommonInstance()!).GetNew(); + ((RaceSetterTranslationCommon)((IRaceGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + ret, + item, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + errorMask = Race.ErrorMask.Factory(errorMaskBuilder); + return ret; + } + + public Race DeepCopy( + IRaceGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + Race ret = (Race)((RaceCommon)((IRaceGetter)item).CommonInstance()!).GetNew(); + ((RaceSetterTranslationCommon)((IRaceGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: true); + return ret; + } + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + public partial class Race + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => Race_Registration.Instance; + public new static ILoquiRegistration StaticRegistration => Race_Registration.Instance; + [DebuggerStepThrough] + protected override object CommonInstance() => RaceCommon.Instance; + [DebuggerStepThrough] + protected override object CommonSetterInstance() + { + return RaceSetterCommon.Instance; + } + [DebuggerStepThrough] + protected override object CommonSetterTranslationInstance() => RaceSetterTranslationCommon.Instance; + + #endregion + + } +} + +#region Modules +#region Binary Translation +namespace Mutagen.Bethesda.Starfield +{ + public partial class RaceBinaryWriteTranslation : + StarfieldMajorRecordBinaryWriteTranslation, + IBinaryWriteTranslator + { + public new static readonly RaceBinaryWriteTranslation Instance = new(); + + public void Write( + MutagenWriter writer, + IRaceGetter item, + TypedWriteParams translationParams) + { + using (HeaderExport.Record( + writer: writer, + record: translationParams.ConvertToCustom(RecordTypes.RACE))) + { + try + { + StarfieldMajorRecordBinaryWriteTranslation.WriteEmbedded( + item: item, + writer: writer); + if (!item.IsDeleted) + { + MajorRecordBinaryWriteTranslation.WriteRecordTypes( + item: item, + writer: writer, + translationParams: translationParams); + } + } + catch (Exception ex) + { + throw RecordException.Enrich(ex, item); + } + } + } + + public override void Write( + MutagenWriter writer, + object item, + TypedWriteParams translationParams = default) + { + Write( + item: (IRaceGetter)item, + writer: writer, + translationParams: translationParams); + } + + public override void Write( + MutagenWriter writer, + IStarfieldMajorRecordGetter item, + TypedWriteParams translationParams) + { + Write( + item: (IRaceGetter)item, + writer: writer, + translationParams: translationParams); + } + + public override void Write( + MutagenWriter writer, + IMajorRecordGetter item, + TypedWriteParams translationParams) + { + Write( + item: (IRaceGetter)item, + writer: writer, + translationParams: translationParams); + } + + } + + internal partial class RaceBinaryCreateTranslation : StarfieldMajorRecordBinaryCreateTranslation + { + public new static readonly RaceBinaryCreateTranslation Instance = new RaceBinaryCreateTranslation(); + + public override RecordType RecordType => RecordTypes.RACE; + } + +} +namespace Mutagen.Bethesda.Starfield +{ + #region Binary Write Mixins + public static class RaceBinaryTranslationMixIn + { + } + #endregion + + +} +namespace Mutagen.Bethesda.Starfield +{ + internal partial class RaceBinaryOverlay : + StarfieldMajorRecordBinaryOverlay, + IRaceGetter + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => Race_Registration.Instance; + public new static ILoquiRegistration StaticRegistration => Race_Registration.Instance; + [DebuggerStepThrough] + protected override object CommonInstance() => RaceCommon.Instance; + [DebuggerStepThrough] + protected override object CommonSetterTranslationInstance() => RaceSetterTranslationCommon.Instance; + + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected override object BinaryWriteTranslator => RaceBinaryWriteTranslation.Instance; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((RaceBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + protected override Type LinkType => typeof(IRace); + + + partial void CustomFactoryEnd( + OverlayStream stream, + int finalPos, + int offset); + + partial void CustomCtor(); + protected RaceBinaryOverlay( + MemoryPair memoryPair, + BinaryOverlayFactoryPackage package) + : base( + memoryPair: memoryPair, + package: package) + { + this.CustomCtor(); + } + + public static IRaceGetter RaceFactory( + OverlayStream stream, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + stream = Decompression.DecompressStream(stream); + stream = ExtractRecordMemory( + stream: stream, + meta: package.MetaData.Constants, + memoryPair: out var memoryPair, + offset: out var offset, + finalPos: out var finalPos); + var ret = new RaceBinaryOverlay( + memoryPair: memoryPair, + package: package); + ret._package.FormVersion = ret; + ret.CustomFactoryEnd( + stream: stream, + finalPos: finalPos, + offset: offset); + ret.FillSubrecordTypes( + majorReference: ret, + stream: stream, + finalPos: finalPos, + offset: offset, + translationParams: translationParams, + fill: ret.FillRecordType); + return ret; + } + + public static IRaceGetter RaceFactory( + ReadOnlyMemorySlice slice, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + return RaceFactory( + stream: new OverlayStream(slice, package), + package: package, + translationParams: translationParams); + } + + #region To String + + public override void Print( + StructuredStringBuilder sb, + string? name = null) + { + RaceMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + public override string ToString() + { + return MajorRecordPrinter.ToString(this); + } + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is IFormLinkGetter formLink) + { + return formLink.Equals(this); + } + if (obj is not IRaceGetter rhs) return false; + return ((RaceCommon)((IRaceGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IRaceGetter? obj) + { + return ((RaceCommon)((IRaceGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((RaceCommon)((IRaceGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + } + +} +#endregion + +#endregion + diff --git a/Mutagen.Bethesda.Starfield/Records/RecordTypeInts_Generated.cs b/Mutagen.Bethesda.Starfield/Records/RecordTypeInts_Generated.cs new file mode 100644 index 0000000000..9ebdcf4ce6 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/RecordTypeInts_Generated.cs @@ -0,0 +1,25 @@ +namespace Mutagen.Bethesda.Starfield.Internals; + +public partial class RecordTypeInts +{ + public const int CNAM = 0x4D414E43; + public const int DATA = 0x41544144; + public const int DELE = 0x454C4544; + public const int EDID = 0x44494445; + public const int GRUP = 0x50555247; + public const int HEDR = 0x52444548; + public const int INCC = 0x43434E49; + public const int INTV = 0x56544E49; + public const int MAST = 0x5453414D; + public const int MODF = 0x46444F4D; + public const int MODL = 0x4C444F4D; + public const int NPC_ = 0x5F43504E; + public const int OFST = 0x5453464F; + public const int ONAM = 0x4D414E4F; + public const int RACE = 0x45434152; + public const int RNAM = 0x4D414E52; + public const int SNAM = 0x4D414E53; + public const int TES4 = 0x34534554; + public const int WEAP = 0x50414557; + public const int XXXX = 0x58585858; +} diff --git a/Mutagen.Bethesda.Starfield/Records/RecordTypes_Generated.cs b/Mutagen.Bethesda.Starfield/Records/RecordTypes_Generated.cs new file mode 100644 index 0000000000..c15b4564a8 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/RecordTypes_Generated.cs @@ -0,0 +1,27 @@ +using Mutagen.Bethesda.Plugins; + +namespace Mutagen.Bethesda.Starfield.Internals; + +public partial class RecordTypes +{ + public static readonly RecordType CNAM = new(0x4D414E43); + public static readonly RecordType DATA = new(0x41544144); + public static readonly RecordType DELE = new(0x454C4544); + public static readonly RecordType EDID = new(0x44494445); + public static readonly RecordType GRUP = new(0x50555247); + public static readonly RecordType HEDR = new(0x52444548); + public static readonly RecordType INCC = new(0x43434E49); + public static readonly RecordType INTV = new(0x56544E49); + public static readonly RecordType MAST = new(0x5453414D); + public static readonly RecordType MODF = new(0x46444F4D); + public static readonly RecordType MODL = new(0x4C444F4D); + public static readonly RecordType NPC_ = new(0x5F43504E); + public static readonly RecordType OFST = new(0x5453464F); + public static readonly RecordType ONAM = new(0x4D414E4F); + public static readonly RecordType RACE = new(0x45434152); + public static readonly RecordType RNAM = new(0x4D414E52); + public static readonly RecordType SNAM = new(0x4D414E53); + public static readonly RecordType TES4 = new(0x34534554); + public static readonly RecordType WEAP = new(0x50414557); + public static readonly RecordType XXXX = new(0x58585858); +} diff --git a/Mutagen.Bethesda.Starfield/Records/StarfieldGroup.cs b/Mutagen.Bethesda.Starfield/Records/StarfieldGroup.cs new file mode 100644 index 0000000000..d56c66d17c --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/StarfieldGroup.cs @@ -0,0 +1,70 @@ +using Mutagen.Bethesda.Plugins; +using Mutagen.Bethesda.Plugins.Binary.Overlay; +using Mutagen.Bethesda.Plugins.Binary.Streams; +using Mutagen.Bethesda.Plugins.Binary.Translations; +using Mutagen.Bethesda.Plugins.Records; +using Mutagen.Bethesda.Translations.Binary; +using Noggog; + +namespace Mutagen.Bethesda.Starfield; + +public partial class StarfieldGroup : AGroup +{ + public StarfieldGroup(IModGetter getter) : base(getter) + { + } + + public StarfieldGroup(IMod mod) : base(mod) + { + } + + protected override ICache ProtectedCache => this.RecordCache; +} + +public partial interface IStarfieldGroup : IGroup + where T : class, IStarfieldMajorRecordInternal, IBinaryItem +{ +} + +public partial interface IStarfieldGroupGetter : IGroupGetter + where T : class, IStarfieldMajorRecordGetter, IBinaryItem +{ +} + +partial class StarfieldGroupBinaryWriteTranslation +{ + public static partial void WriteBinaryContainedRecordTypeParseCustom( + MutagenWriter writer, + IStarfieldGroupGetter item) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + Int32BinaryTranslation.Instance.Write( + writer, + GroupRecordTypeGetter.GRUP_RECORD_TYPE.TypeInt); + } +} + +partial class StarfieldGroupBinaryCreateTranslation +{ + public static partial void FillBinaryContainedRecordTypeParseCustom( + MutagenFrame frame, + IStarfieldGroup item) + { + frame.Reader.Position += 4; + } +} + +partial class StarfieldGroupBinaryOverlay : AGroupBinaryOverlay +{ + partial void CustomFactoryEnd( + OverlayStream stream, + int finalPos, + int offset) + { + _recordCache = GroupMajorRecordCacheWrapper.Factory( + stream, + _recordData, + _package, + offset); + } +} \ No newline at end of file diff --git a/Mutagen.Bethesda.Starfield/Records/StarfieldGroup.xml b/Mutagen.Bethesda.Starfield/Records/StarfieldGroup.xml new file mode 100644 index 0000000000..12fa108f8a --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/StarfieldGroup.xml @@ -0,0 +1,21 @@ + + + + + StarfieldMajorRecord + + + + + + + + + + T + + + + + + diff --git a/Mutagen.Bethesda.Starfield/Records/StarfieldGroupWrapper.cs b/Mutagen.Bethesda.Starfield/Records/StarfieldGroupWrapper.cs new file mode 100644 index 0000000000..82ebe93421 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/StarfieldGroupWrapper.cs @@ -0,0 +1,142 @@ +using System.Collections; +using System.Diagnostics; +using Loqui; +using Loqui.Internal; +using Mutagen.Bethesda.Assets; +using Mutagen.Bethesda.Starfield.Internals; +using Mutagen.Bethesda.Plugins; +using Mutagen.Bethesda.Plugins.Assets; +using Mutagen.Bethesda.Plugins.Binary.Streams; +using Mutagen.Bethesda.Plugins.Binary.Translations; +using Mutagen.Bethesda.Plugins.Cache; +using Mutagen.Bethesda.Plugins.Records; +using Mutagen.Bethesda.Plugins.Records.Internals; +using Noggog; +using Noggog.StructuredStrings; + +namespace Mutagen.Bethesda.Starfield.Records; + +internal class StarfieldGroupWrapper : IStarfieldGroupGetter + where TMajor : class, IStarfieldMajorRecordGetter, IBinaryItem +{ + private readonly GroupMergeGetter, TMajor> _groupMerge; + + public StarfieldGroupWrapper(GroupMergeGetter, TMajor> groupMerge) + { + _groupMerge = groupMerge; + } + + #region IGroupGetter Forwarding + + public IEnumerable EnumerateFormLinks() => _groupMerge.EnumerateFormLinks(); + + public IMod SourceMod => _groupMerge.SourceMod; + + IReadOnlyCache IGroupGetter.RecordCache => _groupMerge.RecordCache; + + public TMajor this[FormKey key] => _groupMerge[key]; + + IEnumerable IGroupGetter.Records => _groupMerge.Records; + IEnumerable IGroupCommonGetter.Records => _groupMerge.Records; + IEnumerable IGroupCommonGetter.Records => _groupMerge.Records; + + IReadOnlyCache IGroupGetter.RecordCache => ((IGroupGetter)_groupMerge).RecordCache; + + public int Count => _groupMerge.Count; + + IMajorRecordGetter IGroupGetter.this[FormKey key] => ((IGroupGetter)_groupMerge)[key]; + + public IEnumerable FormKeys => _groupMerge.FormKeys; + + IEnumerable IGroupGetter.Records => ((IGroupGetter)_groupMerge).Records; + + public Type ContainedRecordType => typeof(TMajor); + + public bool ContainsKey(FormKey key) + { + return _groupMerge.ContainsKey(key); + } + + public IEnumerator GetEnumerator() + { + return _groupMerge.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable)_groupMerge).GetEnumerator(); + } + + #endregion + + #region Common Routing + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => StarfieldGroup_Registration.Instance; + + public static StarfieldGroup_Registration StaticRegistration => StarfieldGroup_Registration.Instance; + + [DebuggerStepThrough] + protected object CommonInstance(Type type0) => + GenericCommonInstanceGetter.Get(StarfieldGroupCommon.Instance, typeof(TMajor), type0); + + [DebuggerStepThrough] + protected object CommonSetterTranslationInstance() => StarfieldGroupSetterTranslationCommon.Instance; + + [DebuggerStepThrough] + object IStarfieldGroupGetter.CommonInstance(Type type0) => this.CommonInstance(type0); + + [DebuggerStepThrough] + object? IStarfieldGroupGetter.CommonSetterInstance(Type type0) => null; + + [DebuggerStepThrough] + object IStarfieldGroupGetter.CommonSetterTranslationInstance() => this.CommonSetterTranslationInstance(); + + #endregion + + public IReadOnlyCache RecordCache => _groupMerge.RecordCache; + + public GroupTypeEnum Type => _groupMerge.SubGroups[^1].Type; + + public int LastModified => _groupMerge.SubGroups[^1].LastModified; + + public int Unknown => _groupMerge.SubGroups[^1].Unknown; + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected object BinaryWriteTranslator => StarfieldGroupBinaryWriteTranslation.Instance; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + object IBinaryItem.BinaryWriteTranslator => this.BinaryWriteTranslator; + + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((StarfieldGroupBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + + public void Print(StructuredStringBuilder fg, string? name = null) + { + StarfieldGroupMixIn.Print( + item: this, + name: name); + } + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords() => this.EnumerateMajorRecords(); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords(bool throwIfUnknown) => this.EnumerateMajorRecords(throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords(Type type, bool throwIfUnknown) => this.EnumerateMajorRecords(type: type, throwIfUnknown: throwIfUnknown); + + public ILoquiRegistration ContainedRecordRegistration => _groupMerge.ContainedRecordRegistration; + + public IEnumerable EnumerateAssetLinks( + AssetLinkQuery queryCategories = AssetLinkQuery.Listed, + IAssetLinkCache? linkCache = null, + Type? assetType = null) + { + return _groupMerge.EnumerateAssetLinks(queryCategories, linkCache, assetType); + } +} \ No newline at end of file diff --git a/Mutagen.Bethesda.Starfield/Records/StarfieldGroup_Generated.cs b/Mutagen.Bethesda.Starfield/Records/StarfieldGroup_Generated.cs new file mode 100644 index 0000000000..e65755d504 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/StarfieldGroup_Generated.cs @@ -0,0 +1,2042 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Autogenerated by Loqui. Do not manually change. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ +#region Usings +using Loqui; +using Loqui.Interfaces; +using Loqui.Internal; +using Mutagen.Bethesda.Assets; +using Mutagen.Bethesda.Binary; +using Mutagen.Bethesda.Plugins; +using Mutagen.Bethesda.Plugins.Assets; +using Mutagen.Bethesda.Plugins.Binary.Headers; +using Mutagen.Bethesda.Plugins.Binary.Overlay; +using Mutagen.Bethesda.Plugins.Binary.Streams; +using Mutagen.Bethesda.Plugins.Binary.Translations; +using Mutagen.Bethesda.Plugins.Cache; +using Mutagen.Bethesda.Plugins.Exceptions; +using Mutagen.Bethesda.Plugins.Internals; +using Mutagen.Bethesda.Plugins.Records; +using Mutagen.Bethesda.Plugins.Records.Internals; +using Mutagen.Bethesda.Plugins.Records.Mapping; +using Mutagen.Bethesda.Starfield.Internals; +using Mutagen.Bethesda.Starfield.Records; +using Mutagen.Bethesda.Translations.Binary; +using Noggog; +using Noggog.StructuredStrings; +using Noggog.StructuredStrings.CSharp; +using RecordTypeInts = Mutagen.Bethesda.Starfield.Internals.RecordTypeInts; +using RecordTypes = Mutagen.Bethesda.Starfield.Internals.RecordTypes; +using System.Buffers.Binary; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Reactive.Disposables; +using System.Reactive.Linq; +#endregion + +#nullable enable +namespace Mutagen.Bethesda.Starfield +{ + #region Class + public partial class StarfieldGroup : + IEquatable>, + ILoquiObjectSetter>, + IStarfieldGroup + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + #region Ctor + protected StarfieldGroup() + { + CustomCtor(); + } + partial void CustomCtor(); + #endregion + + static StarfieldGroup() + { + T_RecordType = PluginUtilityTranslation.GetRecordType(); + } + + #region Type + public GroupTypeEnum Type { get; set; } = default; + #endregion + #region LastModified + public Int32 LastModified { get; set; } = default; + #endregion + #region Unknown + public Int32 Unknown { get; set; } = default; + #endregion + #region RecordCache + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly ICache _RecordCache = new Cache((item) => item.FormKey); + public ICache RecordCache => _RecordCache; + #region Interface Members + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ICache IStarfieldGroup.RecordCache => _RecordCache; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IReadOnlyCache IStarfieldGroupGetter.RecordCache => _RecordCache; + #endregion + + #endregion + + #region To String + + public void Print( + StructuredStringBuilder sb, + string? name = null) + { + StarfieldGroupMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is not IStarfieldGroupGetter rhs) return false; + return ((StarfieldGroupCommon)((IStarfieldGroupGetter)this).CommonInstance(typeof(T))!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IStarfieldGroupGetter? obj) + { + return ((StarfieldGroupCommon)((IStarfieldGroupGetter)this).CommonInstance(typeof(T))!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((StarfieldGroupCommon)((IStarfieldGroupGetter)this).CommonInstance(typeof(T))!).GetHashCode(this); + + #endregion + + #region Mutagen + public static readonly RecordType T_RecordType; + public override IEnumerable EnumerateFormLinks() => StarfieldGroupCommon.Instance.EnumerateFormLinks(this); + public void RemapLinks(IReadOnlyDictionary mapping) => StarfieldGroupSetterCommon.Instance.RemapLinks(this, mapping); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords() => this.EnumerateMajorRecords(); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords(bool throwIfUnknown) => this.EnumerateMajorRecords(throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords(Type type, bool throwIfUnknown) => this.EnumerateMajorRecords(type: type, throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable IMajorRecordEnumerable.EnumerateMajorRecords() => this.EnumerateMajorRecords(); + [DebuggerStepThrough] + IEnumerable IMajorRecordEnumerable.EnumerateMajorRecords(bool throwIfUnknown) => this.EnumerateMajorRecords(throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable IMajorRecordEnumerable.EnumerateMajorRecords(Type? type, bool throwIfUnknown) => this.EnumerateMajorRecords(type: type, throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(FormKey formKey) => this.Remove(formKey); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(HashSet formKeys) => this.Remove(formKeys); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(IEnumerable formKeys) => this.Remove(formKeys); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(FormKey formKey, Type type, bool throwIfUnknown) => this.Remove(formKey, type, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(HashSet formKeys, Type type, bool throwIfUnknown) => this.Remove(formKeys, type, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(IEnumerable formKeys, Type type, bool throwIfUnknown) => this.Remove(formKeys, type, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(FormKey formKey, bool throwIfUnknown) => this.Remove(formKey, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(HashSet formKeys, bool throwIfUnknown) => this.Remove(formKeys, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(IEnumerable formKeys, bool throwIfUnknown) => this.Remove(formKeys, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(TMajor record, bool throwIfUnknown) => this.Remove(record, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(IEnumerable records, bool throwIfUnknown) => this.Remove(records, throwIfUnknown); + public override IEnumerable EnumerateAssetLinks(AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) => StarfieldGroupCommon.Instance.EnumerateAssetLinks(this, queryCategories, linkCache, assetType); + public override IEnumerable EnumerateListedAssetLinks() => StarfieldGroupSetterCommon.Instance.EnumerateListedAssetLinks(this); + public override void RemapAssetLinks(IReadOnlyDictionary mapping, AssetLinkQuery queryCategories, IAssetLinkCache? linkCache) => StarfieldGroupSetterCommon.Instance.RemapAssetLinks(this, mapping, linkCache, queryCategories); + public override void RemapListedAssetLinks(IReadOnlyDictionary mapping) => StarfieldGroupSetterCommon.Instance.RemapAssetLinks(this, mapping, null, AssetLinkQuery.Listed); + #endregion + + #region Binary Translation + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected object BinaryWriteTranslator => StarfieldGroupBinaryWriteTranslation.Instance; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + object IBinaryItem.BinaryWriteTranslator => this.BinaryWriteTranslator; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((StarfieldGroupBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + #region Binary Create + public static StarfieldGroup CreateFromBinary( + MutagenFrame frame, + TypedParseParams translationParams = default) + { + var ret = new StarfieldGroup(); + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)ret).CommonSetterInstance(typeof(T))!).CopyInFromBinary( + item: ret, + frame: frame, + translationParams: translationParams); + return ret; + } + + #endregion + + public static bool TryCreateFromBinary( + MutagenFrame frame, + out StarfieldGroup item, + TypedParseParams translationParams = default) + { + var startPos = frame.Position; + item = CreateFromBinary( + frame: frame, + translationParams: translationParams); + return startPos != frame.Position; + } + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + void IClearable.Clear() + { + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)this).CommonSetterInstance(typeof(T))!).Clear(this); + } + + internal static StarfieldGroup GetNew() + { + return new StarfieldGroup(); + } + + } + #endregion + + #region Interface + public partial interface IStarfieldGroup : + IAssetLinkContainer, + IFormLinkContainer, + ILoquiObjectSetter>, + IMajorRecordEnumerable, + IStarfieldGroupGetter + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + new GroupTypeEnum Type { get; set; } + new Int32 LastModified { get; set; } + new Int32 Unknown { get; set; } + new ICache RecordCache { get; } + } + + public partial interface IStarfieldGroupGetter : + ILoquiObject, + IAssetLinkContainerGetter, + IBinaryItem, + IFormLinkContainerGetter, + ILoquiObject>, + IMajorRecordGetterEnumerable + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object CommonInstance(Type type0); + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object? CommonSetterInstance(Type type0); + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object CommonSetterTranslationInstance(); + static ILoquiRegistration StaticRegistration => StarfieldGroup_Registration.Instance; + GroupTypeEnum Type { get; } + Int32 LastModified { get; } + Int32 Unknown { get; } + IReadOnlyCache RecordCache { get; } + + } + + #endregion + + #region Common MixIn + public static partial class StarfieldGroupMixIn + { + public static void Clear(this IStarfieldGroup item) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)item).CommonSetterInstance(typeof(T))!).Clear(item: item); + } + + public static StarfieldGroup.Mask GetEqualsMask( + this IStarfieldGroupGetter item, + IStarfieldGroupGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + return ((StarfieldGroupCommon)((IStarfieldGroupGetter)item).CommonInstance(typeof(T))!).GetEqualsMask( + item: item, + rhs: rhs, + include: include); + } + + public static string Print( + this IStarfieldGroupGetter item, + string? name = null, + StarfieldGroup.Mask? printMask = null) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + return ((StarfieldGroupCommon)((IStarfieldGroupGetter)item).CommonInstance(typeof(T))!).Print( + item: item, + name: name, + printMask: printMask); + } + + public static void Print( + this IStarfieldGroupGetter item, + StructuredStringBuilder sb, + string? name = null, + StarfieldGroup.Mask? printMask = null) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + ((StarfieldGroupCommon)((IStarfieldGroupGetter)item).CommonInstance(typeof(T))!).Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + } + + public static bool Equals( + this IStarfieldGroupGetter item, + IStarfieldGroupGetter rhs) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + return ((StarfieldGroupCommon)((IStarfieldGroupGetter)item).CommonInstance(typeof(T))!).Equals( + lhs: item, + rhs: rhs, + equalsMask: null); + } + + public static bool Equals( + this IStarfieldGroupGetter item, + IStarfieldGroupGetter rhs, + StarfieldGroup.TranslationMask equalsMask) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + where T_TranslMask : StarfieldMajorRecord.TranslationMask, ITranslationMask + { + return ((StarfieldGroupCommon)((IStarfieldGroupGetter)item).CommonInstance(typeof(T))!).Equals( + lhs: item, + rhs: rhs, + equalsMask: equalsMask.GetCrystal()); + } + + public static void DeepCopyIn( + this IStarfieldGroup lhs, + IStarfieldGroupGetter rhs) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TGetter : class, IStarfieldMajorRecordGetter, IBinaryItem + { + ((StarfieldGroupSetterTranslationCommon)((IStarfieldGroupGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: default, + copyMask: default, + deepCopy: false); + } + + public static void DeepCopyIn( + this IStarfieldGroup lhs, + IStarfieldGroupGetter rhs, + StarfieldGroup.TranslationMask? copyMask = null) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TGetter : class, IStarfieldMajorRecordGetter, IBinaryItem + where T_TranslMask : StarfieldMajorRecord.TranslationMask, ITranslationMask + { + ((StarfieldGroupSetterTranslationCommon)((IStarfieldGroupGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: default, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + } + + public static void DeepCopyIn( + this IStarfieldGroup lhs, + IStarfieldGroupGetter rhs, + out StarfieldGroup.ErrorMask errorMask, + StarfieldGroup.TranslationMask? copyMask = null) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TGetter : class, IStarfieldMajorRecordGetter, IBinaryItem + where T_ErrMask : StarfieldMajorRecord.ErrorMask, IErrorMask + where T_TranslMask : StarfieldMajorRecord.TranslationMask, ITranslationMask + { + var errorMaskBuilder = new ErrorMaskBuilder(); + ((StarfieldGroupSetterTranslationCommon)((IStarfieldGroupGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + errorMask = StarfieldGroup.ErrorMask.Factory(errorMaskBuilder); + } + + public static void DeepCopyIn( + this IStarfieldGroup lhs, + IStarfieldGroupGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TGetter : class, IStarfieldMajorRecordGetter, IBinaryItem + { + ((StarfieldGroupSetterTranslationCommon)((IStarfieldGroupGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: false); + } + + public static StarfieldGroup DeepCopy( + this IStarfieldGroupGetter item, + StarfieldGroup.TranslationMask? copyMask = null) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TGetter : class, IStarfieldMajorRecordGetter, IBinaryItem + where T_TranslMask : StarfieldMajorRecord.TranslationMask, ITranslationMask + { + return ((StarfieldGroupSetterTranslationCommon)((IStarfieldGroupGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask); + } + + public static StarfieldGroup DeepCopy( + this IStarfieldGroupGetter item, + out StarfieldGroup.ErrorMask errorMask, + StarfieldGroup.TranslationMask? copyMask = null) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TGetter : class, IStarfieldMajorRecordGetter, IBinaryItem + where T_ErrMask : StarfieldMajorRecord.ErrorMask, IErrorMask + where T_TranslMask : StarfieldMajorRecord.TranslationMask, ITranslationMask + { + return ((StarfieldGroupSetterTranslationCommon)((IStarfieldGroupGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: out errorMask); + } + + public static StarfieldGroup DeepCopy( + this IStarfieldGroupGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TGetter : class, IStarfieldMajorRecordGetter, IBinaryItem + { + return ((StarfieldGroupSetterTranslationCommon)((IStarfieldGroupGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: errorMask); + } + + #region Mutagen + [DebuggerStepThrough] + public static IEnumerable EnumerateMajorRecords(this IStarfieldGroupGetter obj) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + return ((StarfieldGroupCommon)((IStarfieldGroupGetter)obj).CommonInstance(typeof(T))!).EnumerateMajorRecords(obj: obj); + } + + [DebuggerStepThrough] + public static IEnumerable EnumerateMajorRecords( + this IStarfieldGroupGetter obj, + bool throwIfUnknown = true) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + where TMajor : class, IMajorRecordQueryableGetter + { + return ((StarfieldGroupCommon)((IStarfieldGroupGetter)obj).CommonInstance(typeof(T))!).EnumerateMajorRecords( + obj: obj, + type: typeof(TMajor), + throwIfUnknown: throwIfUnknown) + .Select(m => (TMajor)m); + } + + [DebuggerStepThrough] + public static IEnumerable EnumerateMajorRecords( + this IStarfieldGroupGetter obj, + Type type, + bool throwIfUnknown = true) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + return ((StarfieldGroupCommon)((IStarfieldGroupGetter)obj).CommonInstance(typeof(T))!).EnumerateMajorRecords( + obj: obj, + type: type, + throwIfUnknown: throwIfUnknown) + .Select(m => (IMajorRecordGetter)m); + } + + [DebuggerStepThrough] + public static IEnumerable EnumerateMajorRecords(this IStarfieldGroup obj) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + return ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).EnumerateMajorRecords(obj: obj); + } + + [DebuggerStepThrough] + public static IEnumerable EnumerateMajorRecords(this IStarfieldGroup obj) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TMajor : class, IMajorRecordQueryable + { + return ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).EnumerateMajorRecords( + obj: obj, + type: typeof(TMajor), + throwIfUnknown: true) + .Select(m => (TMajor)m); + } + + [DebuggerStepThrough] + public static IEnumerable EnumerateMajorRecords( + this IStarfieldGroup obj, + Type? type, + bool throwIfUnknown = true) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + return ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).EnumeratePotentiallyTypedMajorRecords( + obj: obj, + type: type, + throwIfUnknown: throwIfUnknown) + .Select(m => (IMajorRecord)m); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldGroup obj, + FormKey key) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + var keys = new HashSet(); + keys.Add(key); + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).Remove( + obj: obj, + keys: keys); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldGroup obj, + IEnumerable keys) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).Remove( + obj: obj, + keys: keys.ToHashSet()); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldGroup obj, + HashSet keys) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).Remove( + obj: obj, + keys: keys); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldGroup obj, + FormKey key, + Type type, + bool throwIfUnknown = true) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + var keys = new HashSet(); + keys.Add(key); + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).Remove( + obj: obj, + keys: keys, + type: type, + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldGroup obj, + IEnumerable keys, + Type type, + bool throwIfUnknown = true) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).Remove( + obj: obj, + keys: keys.ToHashSet(), + type: type, + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldGroup obj, + HashSet keys, + Type type, + bool throwIfUnknown = true) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).Remove( + obj: obj, + keys: keys, + type: type, + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldGroup obj, + TMajor record, + bool throwIfUnknown = true) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TMajor : IMajorRecordGetter + { + var keys = new HashSet(); + keys.Add(record.FormKey); + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).Remove( + obj: obj, + keys: keys, + type: typeof(TMajor), + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldGroup obj, + IEnumerable records, + bool throwIfUnknown = true) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TMajor : IMajorRecordGetter + { + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).Remove( + obj: obj, + keys: records.Select(m => m.FormKey).ToHashSet(), + type: typeof(TMajor), + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldGroup obj, + FormKey key, + bool throwIfUnknown = true) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TMajor : IMajorRecordGetter + { + var keys = new HashSet(); + keys.Add(key); + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).Remove( + obj: obj, + keys: keys, + type: typeof(TMajor), + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldGroup obj, + IEnumerable keys, + bool throwIfUnknown = true) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TMajor : IMajorRecordGetter + { + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).Remove( + obj: obj, + keys: keys.ToHashSet(), + type: typeof(TMajor), + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldGroup obj, + HashSet keys, + bool throwIfUnknown = true) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TMajor : IMajorRecordGetter + { + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)obj).CommonSetterInstance(typeof(T))!).Remove( + obj: obj, + keys: keys, + type: typeof(TMajor), + throwIfUnknown: throwIfUnknown); + } + + #endregion + + #region Binary Translation + public static void CopyInFromBinary( + this IStarfieldGroup item, + MutagenFrame frame, + TypedParseParams translationParams = default) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + ((StarfieldGroupSetterCommon)((IStarfieldGroupGetter)item).CommonSetterInstance(typeof(T))!).CopyInFromBinary( + item: item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + #region Field Index + internal enum StarfieldGroup_FieldIndex + { + Type = 0, + LastModified = 1, + Unknown = 2, + RecordCache = 3, + } + #endregion + + #region Registration + internal partial class StarfieldGroup_Registration : ILoquiRegistration + { + public static readonly StarfieldGroup_Registration Instance = new StarfieldGroup_Registration(); + + public static ProtocolKey ProtocolKey => ProtocolDefinition_Starfield.ProtocolKey; + + public static readonly ObjectKey ObjectKey = new ObjectKey( + protocolKey: ProtocolDefinition_Starfield.ProtocolKey, + msgID: 62, + version: 0); + + public const string GUID = "bf12722f-f38f-429d-b80e-b055025380eb"; + + public const ushort AdditionalFieldCount = 4; + + public const ushort FieldCount = 4; + + public static readonly Type MaskType = typeof(StarfieldGroup.Mask<>); + + public static readonly Type ErrorMaskType = typeof(StarfieldGroup.ErrorMask<>); + + public static readonly Type ClassType = typeof(StarfieldGroup<>); + + public static readonly Type GetterType = typeof(IStarfieldGroupGetter<>); + + public static readonly Type? InternalGetterType = null; + + public static readonly Type SetterType = typeof(IStarfieldGroup<>); + + public static readonly Type? InternalSetterType = null; + + public const string FullName = "Mutagen.Bethesda.Starfield.StarfieldGroup"; + + public const string Name = "StarfieldGroup"; + + public const string Namespace = "Mutagen.Bethesda.Starfield"; + + public const byte GenericCount = 1; + + public static readonly Type? GenericRegistrationType = typeof(StarfieldGroup_Registration<>); + + public static readonly RecordType TriggeringRecordType = RecordTypes.GRUP; + public static readonly Type BinaryWriteTranslation = typeof(StarfieldGroupBinaryWriteTranslation); + #region Interface + ProtocolKey ILoquiRegistration.ProtocolKey => ProtocolKey; + ObjectKey ILoquiRegistration.ObjectKey => ObjectKey; + string ILoquiRegistration.GUID => GUID; + ushort ILoquiRegistration.FieldCount => FieldCount; + ushort ILoquiRegistration.AdditionalFieldCount => AdditionalFieldCount; + Type ILoquiRegistration.MaskType => MaskType; + Type ILoquiRegistration.ErrorMaskType => ErrorMaskType; + Type ILoquiRegistration.ClassType => ClassType; + Type ILoquiRegistration.SetterType => SetterType; + Type? ILoquiRegistration.InternalSetterType => InternalSetterType; + Type ILoquiRegistration.GetterType => GetterType; + Type? ILoquiRegistration.InternalGetterType => InternalGetterType; + string ILoquiRegistration.FullName => FullName; + string ILoquiRegistration.Name => Name; + string ILoquiRegistration.Namespace => Namespace; + byte ILoquiRegistration.GenericCount => GenericCount; + Type? ILoquiRegistration.GenericRegistrationType => GenericRegistrationType; + ushort? ILoquiRegistration.GetNameIndex(StringCaseAgnostic name) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsEnumerable(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsLoqui(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsSingleton(ushort index) => throw new NotImplementedException(); + string ILoquiRegistration.GetNthName(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsNthDerivative(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsProtected(ushort index) => throw new NotImplementedException(); + Type ILoquiRegistration.GetNthType(ushort index) => throw new NotImplementedException(); + #endregion + + } + + internal class StarfieldGroup_Registration : StarfieldGroup_Registration + where T : StarfieldMajorRecord, IBinaryItem + { + public static readonly StarfieldGroup_Registration GenericInstance = new StarfieldGroup_Registration(); + + } + #endregion + + #region Common + internal partial class StarfieldGroupSetterCommon + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + public static readonly StarfieldGroupSetterCommon Instance = new StarfieldGroupSetterCommon(); + + partial void ClearPartial(); + + public void Clear(IStarfieldGroup item) + { + ClearPartial(); + item.Type = default; + item.LastModified = default; + item.Unknown = default; + item.RecordCache.Clear(); + } + + #region Mutagen + public void RemapLinks(IStarfieldGroup obj, IReadOnlyDictionary mapping) + { + obj.RecordCache.RemapLinks(mapping); + } + + public IEnumerable EnumerateMajorRecords(IStarfieldGroup obj) + { + foreach (var item in StarfieldGroupCommon.Instance.EnumerateMajorRecords(obj)) + { + yield return (item as IMajorRecord)!; + } + } + + public IEnumerable EnumeratePotentiallyTypedMajorRecords( + IStarfieldGroup obj, + Type? type, + bool throwIfUnknown) + { + if (type == null) return EnumerateMajorRecords(obj); + return EnumerateMajorRecords(obj, type, throwIfUnknown); + } + + public IEnumerable EnumerateMajorRecords( + IStarfieldGroup obj, + Type type, + bool throwIfUnknown) + { + foreach (var item in StarfieldGroupCommon.Instance.EnumerateMajorRecords(obj, type, throwIfUnknown)) + { + yield return item; + } + } + + public void Remove( + IStarfieldGroup obj, + HashSet keys) + { + obj.RecordCache.Remove(keys); + } + + public void Remove( + IStarfieldGroup obj, + HashSet keys, + Type type, + bool throwIfUnknown) + { + switch (type.Name) + { + case "IMajorRecord": + case "MajorRecord": + case "IStarfieldMajorRecord": + case "StarfieldMajorRecord": + case "IMajorRecordGetter": + case "IStarfieldMajorRecordGetter": + if (!StarfieldGroup_Registration.SetterType.IsAssignableFrom(obj.GetType())) return; + this.Remove(obj, keys); + break; + default: + if (type.IsAssignableFrom(typeof(T))) + { + obj.RecordCache.Remove(keys); + } + foreach (var item in obj.RecordCache.Items) + { + item.Remove(keys, type, throwIfUnknown: false); + } + break; + } + } + + public IEnumerable EnumerateListedAssetLinks(IStarfieldGroup obj) + { + foreach (var item in obj.RecordCache.Items.WhereCastable() + .SelectMany((f) => f.EnumerateListedAssetLinks())) + { + yield return item; + } + yield break; + } + + public void RemapAssetLinks( + IStarfieldGroup obj, + IReadOnlyDictionary mapping, + IAssetLinkCache? linkCache, + AssetLinkQuery queryCategories) + { + obj.RecordCache.RemapAssetLinks(mapping, queryCategories, linkCache); + } + + #endregion + + #region Binary Translation + public virtual void CopyInFromBinary( + IStarfieldGroup item, + MutagenFrame frame, + TypedParseParams translationParams) + { + PluginUtilityTranslation.GroupParse, T>( + record: item, + frame: frame, + translationParams: translationParams, + expectedRecordType: StarfieldGroup.T_RecordType, + fillStructs: StarfieldGroupBinaryCreateTranslation.FillBinaryStructs); + } + + #endregion + + } + internal partial class StarfieldGroupCommon + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + public static readonly StarfieldGroupCommon Instance = new StarfieldGroupCommon(); + + public StarfieldGroup.Mask GetEqualsMask( + IStarfieldGroupGetter item, + IStarfieldGroupGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + var ret = new StarfieldGroup.Mask(false); + ((StarfieldGroupCommon)((IStarfieldGroupGetter)item).CommonInstance(typeof(T))!).FillEqualsMask( + item: item, + rhs: rhs, + ret: ret, + include: include); + return ret; + } + + public void FillEqualsMask( + IStarfieldGroupGetter item, + IStarfieldGroupGetter rhs, + StarfieldGroup.Mask ret, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + ret.Type = item.Type == rhs.Type; + ret.LastModified = item.LastModified == rhs.LastModified; + ret.Unknown = item.Unknown == rhs.Unknown; + ret.RecordCache = EqualsMaskHelper.CacheEqualsHelper( + lhs: item.RecordCache, + rhs: rhs.RecordCache, + maskGetter: (k, l, r) => l.GetEqualsMask(r, include), + include: include); + } + + public string Print( + IStarfieldGroupGetter item, + string? name = null, + StarfieldGroup.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + return sb.ToString(); + } + + public void Print( + IStarfieldGroupGetter item, + StructuredStringBuilder sb, + string? name = null, + StarfieldGroup.Mask? printMask = null) + { + if (name == null) + { + sb.AppendLine($"StarfieldGroup<{typeof(T).Name}> =>"); + } + else + { + sb.AppendLine($"{name} (StarfieldGroup<{typeof(T).Name}>) =>"); + } + using (sb.Brace()) + { + ToStringFields( + item: item, + sb: sb, + printMask: printMask); + } + } + + protected static void ToStringFields( + IStarfieldGroupGetter item, + StructuredStringBuilder sb, + StarfieldGroup.Mask? printMask = null) + { + if (printMask?.Type ?? true) + { + sb.AppendItem(item.Type, "Type"); + } + if (printMask?.LastModified ?? true) + { + sb.AppendItem(item.LastModified, "LastModified"); + } + if (printMask?.Unknown ?? true) + { + sb.AppendItem(item.Unknown, "Unknown"); + } + if (printMask?.RecordCache?.Overall ?? true) + { + sb.AppendLine("RecordCache =>"); + using (sb.Brace()) + { + foreach (var subItem in item.RecordCache) + { + using (sb.IncreaseDepth()) + using (sb.Brace()) + { + subItem.Value?.Print(sb, "Item"); + } + } + } + sb.AppendLine("]"); + } + } + + #region Equals and Hash + public virtual bool Equals( + IStarfieldGroupGetter? lhs, + IStarfieldGroupGetter? rhs, + TranslationCrystal? equalsMask) + { + if (!EqualsMaskHelper.RefEquality(lhs, rhs, out var isEqual)) return isEqual; + if ((equalsMask?.GetShouldTranslate((int)StarfieldGroup_FieldIndex.Type) ?? true)) + { + if (lhs.Type != rhs.Type) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldGroup_FieldIndex.LastModified) ?? true)) + { + if (lhs.LastModified != rhs.LastModified) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldGroup_FieldIndex.Unknown) ?? true)) + { + if (lhs.Unknown != rhs.Unknown) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldGroup_FieldIndex.RecordCache) ?? true)) + { + if (!lhs.RecordCache.SequenceEqualNullable(rhs.RecordCache)) return false; + } + return true; + } + + public virtual int GetHashCode(IStarfieldGroupGetter item) + { + var hash = new HashCode(); + hash.Add(item.Type); + hash.Add(item.LastModified); + hash.Add(item.Unknown); + hash.Add(item.RecordCache); + return hash.ToHashCode(); + } + + #endregion + + + public object GetNew() + where T_Setter : class, IStarfieldMajorRecordInternal, IBinaryItem + { + return StarfieldGroup.GetNew(); + } + + #region Mutagen + public IEnumerable EnumerateFormLinks(IStarfieldGroupGetter obj) + { + foreach (var item in obj.RecordCache.Items.WhereCastable() + .SelectMany((f) => f.EnumerateFormLinks())) + { + yield return item; + } + yield break; + } + + public IEnumerable EnumerateMajorRecords(IStarfieldGroupGetter obj) + { + foreach (var subItem in obj.RecordCache.Items) + { + yield return subItem; + foreach (var item in subItem.EnumerateMajorRecords()) + { + yield return item; + } + } + } + + public IEnumerable EnumeratePotentiallyTypedMajorRecords( + IStarfieldGroupGetter obj, + Type? type, + bool throwIfUnknown) + { + if (type == null) return EnumerateMajorRecords(obj); + return EnumerateMajorRecords(obj, type, throwIfUnknown); + } + + public IEnumerable EnumerateMajorRecords( + IStarfieldGroupGetter obj, + Type type, + bool throwIfUnknown) + { + switch (type.Name) + { + case "IMajorRecord": + case "MajorRecord": + case "IStarfieldMajorRecord": + case "StarfieldMajorRecord": + if (!StarfieldGroup_Registration.SetterType.IsAssignableFrom(obj.GetType())) yield break; + foreach (var item in this.EnumerateMajorRecords(obj)) + { + yield return item; + } + yield break; + case "IMajorRecordGetter": + case "IStarfieldMajorRecordGetter": + foreach (var item in this.EnumerateMajorRecords(obj)) + { + yield return item; + } + yield break; + default: + if (InterfaceEnumerationHelper.TryEnumerateInterfaceRecordsFor(GameCategory.Starfield, obj, type, out var linkInterfaces)) + { + foreach (var item in linkInterfaces) + { + yield return item; + } + yield break; + } + var assignable = type.IsAssignableFrom(typeof(T)); + foreach (var item in obj.RecordCache.Items) + { + if (assignable) + { + yield return item; + } + foreach (var subItem in item.EnumerateMajorRecords(type, throwIfUnknown: false)) + { + yield return subItem; + } + } + yield break; + } + } + + public IEnumerable EnumerateAssetLinks(IStarfieldGroupGetter obj, AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) + { + if (queryCategories.HasFlag(AssetLinkQuery.Listed)) + { + foreach (var item in obj.RecordCache.Items.WhereCastable() + .SelectMany((f) => f.EnumerateAssetLinks(queryCategories: queryCategories, linkCache: linkCache, assetType: assetType))) + { + yield return item; + } + } + yield break; + } + + #endregion + + } + internal partial class StarfieldGroupSetterTranslationCommon + { + public static readonly StarfieldGroupSetterTranslationCommon Instance = new StarfieldGroupSetterTranslationCommon(); + + #region DeepCopyIn + public void DeepCopyIn( + IStarfieldGroup item, + IStarfieldGroupGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TGetter : class, IStarfieldMajorRecordGetter, IBinaryItem + { + if ((copyMask?.GetShouldTranslate((int)StarfieldGroup_FieldIndex.Type) ?? true)) + { + item.Type = rhs.Type; + } + if ((copyMask?.GetShouldTranslate((int)StarfieldGroup_FieldIndex.LastModified) ?? true)) + { + item.LastModified = rhs.LastModified; + } + if ((copyMask?.GetShouldTranslate((int)StarfieldGroup_FieldIndex.Unknown) ?? true)) + { + item.Unknown = rhs.Unknown; + } + if ((copyMask?.GetShouldTranslate((int)StarfieldGroup_FieldIndex.RecordCache) ?? true)) + { + errorMask?.PushIndex((int)StarfieldGroup_FieldIndex.RecordCache); + try + { + item.RecordCache.SetTo( + rhs.RecordCache.Items + .Select((r) => + { + return (r.DeepCopy() as T)!; + })); + } + catch (Exception ex) + when (errorMask != null) + { + errorMask.ReportException(ex); + } + finally + { + errorMask?.PopIndex(); + } + } + } + + #endregion + + public StarfieldGroup DeepCopy( + IStarfieldGroupGetter item, + StarfieldGroup.TranslationMask? copyMask = null) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TGetter : class, IStarfieldMajorRecordGetter, IBinaryItem + where T_TranslMask : StarfieldMajorRecord.TranslationMask, ITranslationMask + { + StarfieldGroup ret = (StarfieldGroup)((StarfieldGroupCommon)((IStarfieldGroupGetter)item).CommonInstance(typeof(T))!).GetNew(); + ((StarfieldGroupSetterTranslationCommon)((IStarfieldGroupGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: null, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + return ret; + } + + public StarfieldGroup DeepCopy( + IStarfieldGroupGetter item, + out StarfieldGroup.ErrorMask errorMask, + StarfieldGroup.TranslationMask? copyMask = null) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TGetter : class, IStarfieldMajorRecordGetter, IBinaryItem + where T_ErrMask : StarfieldMajorRecord.ErrorMask, IErrorMask + where T_TranslMask : StarfieldMajorRecord.TranslationMask, ITranslationMask + { + var errorMaskBuilder = new ErrorMaskBuilder(); + StarfieldGroup ret = (StarfieldGroup)((StarfieldGroupCommon)((IStarfieldGroupGetter)item).CommonInstance(typeof(T))!).GetNew(); + ((StarfieldGroupSetterTranslationCommon)((IStarfieldGroupGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + ret, + item, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + errorMask = StarfieldGroup.ErrorMask.Factory(errorMaskBuilder); + return ret; + } + + public StarfieldGroup DeepCopy( + IStarfieldGroupGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + where TGetter : class, IStarfieldMajorRecordGetter, IBinaryItem + { + StarfieldGroup ret = (StarfieldGroup)((StarfieldGroupCommon)((IStarfieldGroupGetter)item).CommonInstance(typeof(T))!).GetNew(); + ((StarfieldGroupSetterTranslationCommon)((IStarfieldGroupGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: true); + return ret; + } + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + public partial class StarfieldGroup + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => StarfieldGroup_Registration.Instance; + public static ILoquiRegistration StaticRegistration => StarfieldGroup_Registration.Instance; + [DebuggerStepThrough] + protected object CommonInstance(Type type0) => GenericCommonInstanceGetter.Get(StarfieldGroupCommon.Instance, typeof(T), type0); + [DebuggerStepThrough] + protected object CommonSetterInstance(Type type0) + { + return GenericCommonInstanceGetter.Get(StarfieldGroupSetterCommon.Instance, typeof(T), type0); + } + [DebuggerStepThrough] + protected object CommonSetterTranslationInstance() => StarfieldGroupSetterTranslationCommon.Instance; + [DebuggerStepThrough] + object IStarfieldGroupGetter.CommonInstance(Type type0) => this.CommonInstance(type0); + [DebuggerStepThrough] + object IStarfieldGroupGetter.CommonSetterInstance(Type type0) => this.CommonSetterInstance(type0); + [DebuggerStepThrough] + object IStarfieldGroupGetter.CommonSetterTranslationInstance() => this.CommonSetterTranslationInstance(); + + #endregion + + } +} + +#region Modules +#region Binary Translation +namespace Mutagen.Bethesda.Starfield +{ + public partial class StarfieldGroupBinaryWriteTranslation : IBinaryWriteTranslator + { + public static readonly StarfieldGroupBinaryWriteTranslation Instance = new(); + + public static void WriteEmbedded( + IStarfieldGroupGetter item, + MutagenWriter writer) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + StarfieldGroupBinaryWriteTranslation.WriteBinaryContainedRecordTypeParse( + writer: writer, + item: item); + EnumBinaryTranslation.Instance.Write( + writer, + item.Type, + length: 4); + writer.Write(item.LastModified); + writer.Write(item.Unknown); + } + + public static void WriteRecordTypes( + IStarfieldGroupGetter item, + MutagenWriter writer, + TypedWriteParams translationParams) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + Mutagen.Bethesda.Plugins.Binary.Translations.ListBinaryTranslation.Instance.Write( + writer: writer, + items: item.RecordCache.Items, + transl: (MutagenWriter r, T dictSubItem) => + { + if (dictSubItem is {} Item) + { + ((StarfieldMajorRecordBinaryWriteTranslation)((IBinaryItem)Item).BinaryWriteTranslator).Write( + item: Item, + writer: r); + } + }); + } + + public static partial void WriteBinaryContainedRecordTypeParseCustom( + MutagenWriter writer, + IStarfieldGroupGetter item) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem; + + public static void WriteBinaryContainedRecordTypeParse( + MutagenWriter writer, + IStarfieldGroupGetter item) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + WriteBinaryContainedRecordTypeParseCustom( + writer: writer, + item: item); + } + + public void Write( + MutagenWriter writer, + IStarfieldGroupGetter item, + TypedWriteParams translationParams) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + using (HeaderExport.Group( + writer: writer, + record: translationParams.ConvertToCustom(RecordTypes.GRUP))) + { + WriteEmbedded( + item: item, + writer: writer); + WriteRecordTypes( + item: item, + writer: writer, + translationParams: translationParams); + } + } + + public void Write( + MutagenWriter writer, + object item, + TypedWriteParams translationParams = default) + { + throw new NotImplementedException(); + } + + } + + internal partial class StarfieldGroupBinaryCreateTranslation + where T : class, IStarfieldMajorRecordInternal, IBinaryItem + { + public static readonly StarfieldGroupBinaryCreateTranslation Instance = new StarfieldGroupBinaryCreateTranslation(); + + public static void FillBinaryStructs( + IStarfieldGroup item, + MutagenFrame frame) + { + StarfieldGroupBinaryCreateTranslation.FillBinaryContainedRecordTypeParseCustom( + frame: frame, + item: item); + item.Type = EnumBinaryTranslation.Instance.Parse( + reader: frame, + length: 4); + item.LastModified = frame.ReadInt32(); + item.Unknown = frame.ReadInt32(); + } + + public static partial void FillBinaryContainedRecordTypeParseCustom( + MutagenFrame frame, + IStarfieldGroup item); + + } + +} +namespace Mutagen.Bethesda.Starfield +{ + #region Binary Write Mixins + public static class StarfieldGroupBinaryTranslationMixIn + { + public static void WriteToBinary( + this IStarfieldGroupGetter item, + MutagenWriter writer, + TypedWriteParams translationParams = default) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + where T_ErrMask : StarfieldMajorRecord.ErrorMask, IErrorMask + { + ((StarfieldGroupBinaryWriteTranslation)item.BinaryWriteTranslator).Write( + item: item, + writer: writer, + translationParams: translationParams); + } + + } + #endregion + + +} +namespace Mutagen.Bethesda.Starfield +{ + internal partial class StarfieldGroupBinaryOverlay : IStarfieldGroupGetter + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => StarfieldGroup_Registration.Instance; + public static ILoquiRegistration StaticRegistration => StarfieldGroup_Registration.Instance; + [DebuggerStepThrough] + protected object CommonInstance(Type type0) => GenericCommonInstanceGetter.Get(StarfieldGroupCommon.Instance, typeof(T), type0); + [DebuggerStepThrough] + protected object CommonSetterTranslationInstance() => StarfieldGroupSetterTranslationCommon.Instance; + [DebuggerStepThrough] + object IStarfieldGroupGetter.CommonInstance(Type type0) => this.CommonInstance(type0); + [DebuggerStepThrough] + object? IStarfieldGroupGetter.CommonSetterInstance(Type type0) => null; + [DebuggerStepThrough] + object IStarfieldGroupGetter.CommonSetterTranslationInstance() => this.CommonSetterTranslationInstance(); + + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + public override IEnumerable EnumerateFormLinks() => StarfieldGroupCommon.Instance.EnumerateFormLinks(this); + public override IEnumerable EnumerateAssetLinks(AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) => StarfieldGroupCommon.Instance.EnumerateAssetLinks(this, queryCategories, linkCache, assetType); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords() => this.EnumerateMajorRecords(); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords(bool throwIfUnknown) => this.EnumerateMajorRecords(throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords(Type type, bool throwIfUnknown) => this.EnumerateMajorRecords(type: type, throwIfUnknown: throwIfUnknown); + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected object BinaryWriteTranslator => StarfieldGroupBinaryWriteTranslation.Instance; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + object IBinaryItem.BinaryWriteTranslator => this.BinaryWriteTranslator; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((StarfieldGroupBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + + #region ContainedRecordTypeParse + partial void ContainedRecordTypeParseCustomParse( + OverlayStream stream, + int offset); + #endregion + public GroupTypeEnum Type => (GroupTypeEnum)BinaryPrimitives.ReadInt32LittleEndian(_structData.Span.Slice(0x4, 0x4)); + public Int32 LastModified => BinaryPrimitives.ReadInt32LittleEndian(_structData.Slice(0x8, 0x4)); + public Int32 Unknown => BinaryPrimitives.ReadInt32LittleEndian(_structData.Slice(0xC, 0x4)); + partial void CustomFactoryEnd( + OverlayStream stream, + int finalPos, + int offset); + + partial void CustomCtor(); + protected StarfieldGroupBinaryOverlay( + MemoryPair memoryPair, + BinaryOverlayFactoryPackage package) + : base( + memoryPair: memoryPair, + package: package) + { + this.CustomCtor(); + } + + public static IStarfieldGroupGetter StarfieldGroupFactory( + IBinaryReadStream stream, + IReadOnlyList locs, + BinaryOverlayFactoryPackage package) + { + var subGroups = locs.Select(x => StarfieldGroupFactory( + new OverlayStream(LockExtractMemory(stream, x.Min, x.Max), package), + package)).ToArray(); + return new StarfieldGroupWrapper(new GroupMergeGetter, T>(subGroups)); + } + + public static IStarfieldGroupGetter StarfieldGroupFactory( + OverlayStream stream, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + stream = ExtractGroupMemory( + stream: stream, + meta: package.MetaData.Constants, + memoryPair: out var memoryPair, + offset: out var offset, + finalPos: out var finalPos); + var ret = new StarfieldGroupBinaryOverlay( + memoryPair: memoryPair, + package: package); + ret.CustomFactoryEnd( + stream: stream, + finalPos: finalPos, + offset: offset); + ret.FillMajorRecords( + stream: stream, + finalPos: finalPos, + offset: offset, + translationParams: translationParams, + fill: ret.FillRecordType); + return ret; + } + + public static IStarfieldGroupGetter StarfieldGroupFactory( + ReadOnlyMemorySlice slice, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + return StarfieldGroupFactory( + stream: new OverlayStream(slice, package), + package: package, + translationParams: translationParams); + } + + public ParseResult FillRecordType( + OverlayStream stream, + int finalPos, + int offset, + RecordType type, + PreviousParse lastParsed, + Dictionary? recordParseCount, + TypedParseParams translationParams = default) + { + type = translationParams.ConvertToStandard(type); + switch (type.TypeInt) + { + default: + return default(int?); + } + } + #region To String + + public void Print( + StructuredStringBuilder sb, + string? name = null) + { + StarfieldGroupMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is not IStarfieldGroupGetter rhs) return false; + return ((StarfieldGroupCommon)((IStarfieldGroupGetter)this).CommonInstance(typeof(T))!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IStarfieldGroupGetter? obj) + { + return ((StarfieldGroupCommon)((IStarfieldGroupGetter)this).CommonInstance(typeof(T))!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((StarfieldGroupCommon)((IStarfieldGroupGetter)this).CommonInstance(typeof(T))!).GetHashCode(this); + + #endregion + + } + +} +#endregion + +#endregion + +namespace Mutagen.Bethesda.Starfield +{ + public static class StarfieldGroup + { + public class Mask : + IEquatable>, + IMask + { + #region Ctors + public Mask(TItem initialValue) + { + this.Type = initialValue; + this.LastModified = initialValue; + this.Unknown = initialValue; + this.RecordCache = new MaskItem?>>?>(initialValue, null); + } + + public Mask( + TItem Type, + TItem LastModified, + TItem Unknown, + TItem RecordCache) + { + this.Type = Type; + this.LastModified = LastModified; + this.Unknown = Unknown; + this.RecordCache = new MaskItem?>>?>(RecordCache, null); + } + + #pragma warning disable CS8618 + protected Mask() + { + } + #pragma warning restore CS8618 + + #endregion + + #region Members + public TItem Type; + public TItem LastModified; + public TItem Unknown; + public MaskItem?>>?>? RecordCache; + #endregion + + #region Equals + public override bool Equals(object? obj) + { + if (!(obj is Mask rhs)) return false; + return Equals(rhs); + } + + public bool Equals(Mask? rhs) + { + if (rhs == null) return false; + if (!object.Equals(this.Type, rhs.Type)) return false; + if (!object.Equals(this.LastModified, rhs.LastModified)) return false; + if (!object.Equals(this.Unknown, rhs.Unknown)) return false; + if (!object.Equals(this.RecordCache, rhs.RecordCache)) return false; + return true; + } + public override int GetHashCode() + { + var hash = new HashCode(); + hash.Add(this.Type); + hash.Add(this.LastModified); + hash.Add(this.Unknown); + hash.Add(this.RecordCache); + return hash.ToHashCode(); + } + + #endregion + + #region All + public bool All(Func eval) + { + if (!eval(this.Type)) return false; + if (!eval(this.LastModified)) return false; + if (!eval(this.Unknown)) return false; + if (this.RecordCache != null) + { + if (!eval(this.RecordCache.Overall)) return false; + if (this.RecordCache.Specific != null) + { + foreach (var item in this.RecordCache.Specific) + { + if (!eval(item.Overall)) return false; + if (!item.Specific?.All(eval) ?? false) return false; + } + } + } + return true; + } + #endregion + + #region Any + public bool Any(Func eval) + { + if (eval(this.Type)) return true; + if (eval(this.LastModified)) return true; + if (eval(this.Unknown)) return true; + if (this.RecordCache != null) + { + if (eval(this.RecordCache.Overall)) return true; + if (this.RecordCache.Specific != null) + { + foreach (var item in this.RecordCache.Specific) + { + if (eval(item.Overall)) return true; + if (item.Specific?.Any(eval) ?? false) return true; + } + } + } + return false; + } + #endregion + + #region Translate + public Mask Translate(Func eval) + { + var ret = new StarfieldGroup.Mask(); + this.Translate_InternalFill(ret, eval); + return ret; + } + + protected void Translate_InternalFill(Mask obj, Func eval) + { + obj.Type = eval(this.Type); + obj.LastModified = eval(this.LastModified); + obj.Unknown = eval(this.Unknown); + if (RecordCache != null) + { + obj.RecordCache = new MaskItem?>>?>(eval(this.RecordCache.Overall), default); + if (RecordCache.Specific != null) + { + List?>> l = new List?>>(); + obj.RecordCache.Specific = l; + foreach (var item in RecordCache.Specific) + { + throw new NotImplementedException(); + } + } + } + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public string Print(StarfieldGroup.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print(sb, printMask); + return sb.ToString(); + } + + public void Print(StructuredStringBuilder sb, StarfieldGroup.Mask? printMask = null) + { + sb.AppendLine($"{nameof(StarfieldGroup.Mask)} =>"); + using (sb.Brace()) + { + if (printMask?.Type ?? true) + { + sb.AppendItem(Type, "Type"); + } + if (printMask?.LastModified ?? true) + { + sb.AppendItem(LastModified, "LastModified"); + } + if (printMask?.Unknown ?? true) + { + sb.AppendItem(Unknown, "Unknown"); + } + if (printMask?.RecordCache?.Overall ?? true) + { + sb.AppendLine("RecordCache =>"); + using (sb.Brace()) + { + if (RecordCache != null) + { + if (RecordCache.Overall != null) + { + sb.AppendLine(RecordCache.Overall.ToString()); + } + if (RecordCache.Specific != null) + { + foreach (var subItem in RecordCache.Specific) + { + using (sb.Brace()) + { + { + sb.AppendItem(subItem); + } + } + } + } + } + } + } + } + } + #endregion + + } + + public class ErrorMask : + IErrorMask, + IErrorMask> + where T_ErrMask : StarfieldMajorRecord.ErrorMask, IErrorMask + { + #region Members + public Exception? Overall { get; set; } + private List? _warnings; + public List Warnings + { + get + { + if (_warnings == null) + { + _warnings = new List(); + } + return _warnings; + } + } + public Exception? Type; + public Exception? LastModified; + public Exception? Unknown; + public MaskItem>?>? RecordCache; + #endregion + + #region IErrorMask + public object? GetNthMask(int index) + { + StarfieldGroup_FieldIndex enu = (StarfieldGroup_FieldIndex)index; + switch (enu) + { + case StarfieldGroup_FieldIndex.Type: + return Type; + case StarfieldGroup_FieldIndex.LastModified: + return LastModified; + case StarfieldGroup_FieldIndex.Unknown: + return Unknown; + case StarfieldGroup_FieldIndex.RecordCache: + return RecordCache; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public void SetNthException(int index, Exception ex) + { + StarfieldGroup_FieldIndex enu = (StarfieldGroup_FieldIndex)index; + switch (enu) + { + case StarfieldGroup_FieldIndex.Type: + this.Type = ex; + break; + case StarfieldGroup_FieldIndex.LastModified: + this.LastModified = ex; + break; + case StarfieldGroup_FieldIndex.Unknown: + this.Unknown = ex; + break; + case StarfieldGroup_FieldIndex.RecordCache: + this.RecordCache = new MaskItem>?>(ex, null); + break; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public void SetNthMask(int index, object obj) + { + StarfieldGroup_FieldIndex enu = (StarfieldGroup_FieldIndex)index; + switch (enu) + { + case StarfieldGroup_FieldIndex.Type: + this.Type = (Exception?)obj; + break; + case StarfieldGroup_FieldIndex.LastModified: + this.LastModified = (Exception?)obj; + break; + case StarfieldGroup_FieldIndex.Unknown: + this.Unknown = (Exception?)obj; + break; + case StarfieldGroup_FieldIndex.RecordCache: + this.RecordCache = (MaskItem>?>)obj; + break; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public bool IsInError() + { + if (Overall != null) return true; + if (Type != null) return true; + if (LastModified != null) return true; + if (Unknown != null) return true; + if (RecordCache != null) return true; + return false; + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public void Print(StructuredStringBuilder sb, string? name = null) + { + sb.AppendLine($"{(name ?? "ErrorMask")} =>"); + using (sb.Brace()) + { + if (this.Overall != null) + { + sb.AppendLine("Overall =>"); + using (sb.Brace()) + { + sb.AppendLine($"{this.Overall}"); + } + } + PrintFillInternal(sb); + } + } + protected void PrintFillInternal(StructuredStringBuilder sb) + { + { + sb.AppendItem(Type, "Type"); + } + { + sb.AppendItem(LastModified, "LastModified"); + } + { + sb.AppendItem(Unknown, "Unknown"); + } + { + sb.AppendLine("RecordCache =>"); + using (sb.Brace()) + { + if (RecordCache != null) + { + if (RecordCache.Overall != null) + { + sb.AppendLine(RecordCache.Overall.ToString()); + } + if (RecordCache.Specific != null) + { + foreach (var subItem in RecordCache.Specific) + { + using (sb.Brace()) + { + { + sb.AppendItem(subItem); + } + } + } + } + } + } + } + } + #endregion + + #region Combine + public ErrorMask Combine(ErrorMask? rhs) + { + if (rhs == null) return this; + var ret = new ErrorMask(); + ret.Type = this.Type.Combine(rhs.Type); + ret.LastModified = this.LastModified.Combine(rhs.LastModified); + ret.Unknown = this.Unknown.Combine(rhs.Unknown); + ret.RecordCache = new MaskItem>?>(Noggog.ExceptionExt.Combine(this.RecordCache?.Overall, rhs.RecordCache?.Overall), Noggog.ExceptionExt.Combine(this.RecordCache?.Specific, rhs.RecordCache?.Specific)); + return ret; + } + public static ErrorMask? Combine(ErrorMask? lhs, ErrorMask? rhs) + { + if (lhs != null && rhs != null) return lhs.Combine(rhs); + return lhs ?? rhs; + } + #endregion + + #region Factory + public static ErrorMask Factory(ErrorMaskBuilder errorMask) + { + return new ErrorMask(); + } + #endregion + + } + public class TranslationMask : ITranslationMask + where T_TranslMask : StarfieldMajorRecord.TranslationMask, ITranslationMask + { + #region Members + private TranslationCrystal? _crystal; + public readonly bool DefaultOn; + public bool OnOverall; + public bool Type; + public bool LastModified; + public bool Unknown; + public T_TranslMask? RecordCache; + #endregion + + #region Ctors + public TranslationMask( + bool defaultOn, + bool onOverall = true) + { + this.DefaultOn = defaultOn; + this.OnOverall = onOverall; + this.Type = defaultOn; + this.LastModified = defaultOn; + this.Unknown = defaultOn; + } + + #endregion + + public TranslationCrystal GetCrystal() + { + if (_crystal != null) return _crystal; + var ret = new List<(bool On, TranslationCrystal? SubCrystal)>(); + GetCrystal(ret); + _crystal = new TranslationCrystal(ret.ToArray()); + return _crystal; + } + + protected void GetCrystal(List<(bool On, TranslationCrystal? SubCrystal)> ret) + { + ret.Add((Type, null)); + ret.Add((LastModified, null)); + ret.Add((Unknown, null)); + ret.Add((RecordCache != null || DefaultOn, RecordCache?.GetCrystal())); + } + + public static implicit operator TranslationMask(bool defaultOn) + { + return new TranslationMask(defaultOn: defaultOn, onOverall: defaultOn); + } + + } + } +} diff --git a/Mutagen.Bethesda.Starfield/Records/StarfieldMajorRecord.cs b/Mutagen.Bethesda.Starfield/Records/StarfieldMajorRecord.cs new file mode 100644 index 0000000000..c39ce90014 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/StarfieldMajorRecord.cs @@ -0,0 +1,42 @@ +using Mutagen.Bethesda.Plugins.Records; + +namespace Mutagen.Bethesda.Starfield; + +public partial class StarfieldMajorRecord +{ + [Flags] + public enum StarfieldMajorRecordFlag + { + ESM = Mutagen.Bethesda.Plugins.Internals.Constants.MasterFlag, + NotPlayable = 0x0000_0004, + Deleted = Mutagen.Bethesda.Plugins.Internals.Constants.DeletedFlag, + InitiallyDisabled = Mutagen.Bethesda.Plugins.Internals.Constants.InitiallyDisabled, + Ignored = Mutagen.Bethesda.Plugins.Internals.Constants.Ignored, + VisibleWhenDistant = 0x00008000, + Dangerous_OffLimits_InteriorCell = 0x00020000, + Compressed = Mutagen.Bethesda.Plugins.Internals.Constants.CompressedFlag, + CantWait = 0x00080000, + } + + public StarfieldMajorRecordFlag StarfieldMajorRecordFlags + { + get => (StarfieldMajorRecordFlag)this.MajorRecordFlagsRaw; + set => this.MajorRecordFlagsRaw = (int)value; + } + + protected override ushort? FormVersionAbstract => this.FormVersion; +} + +public partial interface IStarfieldMajorRecord : IFormVersionSetter +{ +} + +partial class StarfieldMajorRecordBinaryOverlay +{ + protected override ushort? FormVersionAbstract => this.FormVersion; + + public StarfieldMajorRecord.StarfieldMajorRecordFlag StarfieldMajorRecordFlags + { + get => (StarfieldMajorRecord.StarfieldMajorRecordFlag)this.MajorRecordFlagsRaw; + } +} \ No newline at end of file diff --git a/Mutagen.Bethesda.Starfield/Records/StarfieldMajorRecord.xml b/Mutagen.Bethesda.Starfield/Records/StarfieldMajorRecord.xml new file mode 100644 index 0000000000..bb07f3ab90 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/StarfieldMajorRecord.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Mutagen.Bethesda.Starfield/Records/StarfieldMajorRecord_Generated.cs b/Mutagen.Bethesda.Starfield/Records/StarfieldMajorRecord_Generated.cs new file mode 100644 index 0000000000..a94863db13 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/StarfieldMajorRecord_Generated.cs @@ -0,0 +1,1425 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Autogenerated by Loqui. Do not manually change. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ +#region Usings +using Loqui; +using Loqui.Interfaces; +using Loqui.Internal; +using Mutagen.Bethesda.Assets; +using Mutagen.Bethesda.Binary; +using Mutagen.Bethesda.Plugins; +using Mutagen.Bethesda.Plugins.Assets; +using Mutagen.Bethesda.Plugins.Binary.Headers; +using Mutagen.Bethesda.Plugins.Binary.Overlay; +using Mutagen.Bethesda.Plugins.Binary.Streams; +using Mutagen.Bethesda.Plugins.Binary.Translations; +using Mutagen.Bethesda.Plugins.Cache; +using Mutagen.Bethesda.Plugins.Exceptions; +using Mutagen.Bethesda.Plugins.Internals; +using Mutagen.Bethesda.Plugins.Records; +using Mutagen.Bethesda.Plugins.Records.Internals; +using Mutagen.Bethesda.Plugins.Records.Mapping; +using Mutagen.Bethesda.Plugins.RecordTypeMapping; +using Mutagen.Bethesda.Plugins.Utility; +using Mutagen.Bethesda.Starfield.Internals; +using Mutagen.Bethesda.Translations.Binary; +using Noggog; +using Noggog.StructuredStrings; +using Noggog.StructuredStrings.CSharp; +using RecordTypeInts = Mutagen.Bethesda.Starfield.Internals.RecordTypeInts; +using RecordTypes = Mutagen.Bethesda.Starfield.Internals.RecordTypes; +using System.Buffers.Binary; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Reactive.Disposables; +using System.Reactive.Linq; +#endregion + +#nullable enable +namespace Mutagen.Bethesda.Starfield +{ + #region Class + /// + /// Implemented by: [Npc, Race, Weapon] + /// + public abstract partial class StarfieldMajorRecord : + MajorRecord, + IEquatable, + ILoquiObjectSetter, + IStarfieldMajorRecordInternal + { + #region Ctor + protected StarfieldMajorRecord() + { + CustomCtor(); + } + partial void CustomCtor(); + #endregion + + #region FormVersion + public UInt16 FormVersion { get; set; } = default; + #endregion + #region Version2 + public UInt16 Version2 { get; set; } = default; + #endregion + + #region To String + + public override void Print( + StructuredStringBuilder sb, + string? name = null) + { + StarfieldMajorRecordMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Mask + public new class Mask : + MajorRecord.Mask, + IEquatable>, + IMask + { + #region Ctors + public Mask(TItem initialValue) + : base(initialValue) + { + this.FormVersion = initialValue; + this.Version2 = initialValue; + this.StarfieldMajorRecordFlags = initialValue; + } + + public Mask( + TItem MajorRecordFlagsRaw, + TItem FormKey, + TItem VersionControl, + TItem EditorID, + TItem FormVersion, + TItem Version2, + TItem StarfieldMajorRecordFlags) + : base( + MajorRecordFlagsRaw: MajorRecordFlagsRaw, + FormKey: FormKey, + VersionControl: VersionControl, + EditorID: EditorID) + { + this.FormVersion = FormVersion; + this.Version2 = Version2; + this.StarfieldMajorRecordFlags = StarfieldMajorRecordFlags; + } + + #pragma warning disable CS8618 + protected Mask() + { + } + #pragma warning restore CS8618 + + #endregion + + #region Members + public TItem FormVersion; + public TItem Version2; + public TItem StarfieldMajorRecordFlags; + #endregion + + #region Equals + public override bool Equals(object? obj) + { + if (!(obj is Mask rhs)) return false; + return Equals(rhs); + } + + public bool Equals(Mask? rhs) + { + if (rhs == null) return false; + if (!base.Equals(rhs)) return false; + if (!object.Equals(this.FormVersion, rhs.FormVersion)) return false; + if (!object.Equals(this.Version2, rhs.Version2)) return false; + if (!object.Equals(this.StarfieldMajorRecordFlags, rhs.StarfieldMajorRecordFlags)) return false; + return true; + } + public override int GetHashCode() + { + var hash = new HashCode(); + hash.Add(this.FormVersion); + hash.Add(this.Version2); + hash.Add(this.StarfieldMajorRecordFlags); + hash.Add(base.GetHashCode()); + return hash.ToHashCode(); + } + + #endregion + + #region All + public override bool All(Func eval) + { + if (!base.All(eval)) return false; + if (!eval(this.FormVersion)) return false; + if (!eval(this.Version2)) return false; + if (!eval(this.StarfieldMajorRecordFlags)) return false; + return true; + } + #endregion + + #region Any + public override bool Any(Func eval) + { + if (base.Any(eval)) return true; + if (eval(this.FormVersion)) return true; + if (eval(this.Version2)) return true; + if (eval(this.StarfieldMajorRecordFlags)) return true; + return false; + } + #endregion + + #region Translate + public new Mask Translate(Func eval) + { + var ret = new StarfieldMajorRecord.Mask(); + this.Translate_InternalFill(ret, eval); + return ret; + } + + protected void Translate_InternalFill(Mask obj, Func eval) + { + base.Translate_InternalFill(obj, eval); + obj.FormVersion = eval(this.FormVersion); + obj.Version2 = eval(this.Version2); + obj.StarfieldMajorRecordFlags = eval(this.StarfieldMajorRecordFlags); + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public string Print(StarfieldMajorRecord.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print(sb, printMask); + return sb.ToString(); + } + + public void Print(StructuredStringBuilder sb, StarfieldMajorRecord.Mask? printMask = null) + { + sb.AppendLine($"{nameof(StarfieldMajorRecord.Mask)} =>"); + using (sb.Brace()) + { + if (printMask?.FormVersion ?? true) + { + sb.AppendItem(FormVersion, "FormVersion"); + } + if (printMask?.Version2 ?? true) + { + sb.AppendItem(Version2, "Version2"); + } + if (printMask?.StarfieldMajorRecordFlags ?? true) + { + sb.AppendItem(StarfieldMajorRecordFlags, "StarfieldMajorRecordFlags"); + } + } + } + #endregion + + } + + public new class ErrorMask : + MajorRecord.ErrorMask, + IErrorMask + { + #region Members + public Exception? FormVersion; + public Exception? Version2; + public Exception? StarfieldMajorRecordFlags; + #endregion + + #region IErrorMask + public override object? GetNthMask(int index) + { + StarfieldMajorRecord_FieldIndex enu = (StarfieldMajorRecord_FieldIndex)index; + switch (enu) + { + case StarfieldMajorRecord_FieldIndex.FormVersion: + return FormVersion; + case StarfieldMajorRecord_FieldIndex.Version2: + return Version2; + case StarfieldMajorRecord_FieldIndex.StarfieldMajorRecordFlags: + return StarfieldMajorRecordFlags; + default: + return base.GetNthMask(index); + } + } + + public override void SetNthException(int index, Exception ex) + { + StarfieldMajorRecord_FieldIndex enu = (StarfieldMajorRecord_FieldIndex)index; + switch (enu) + { + case StarfieldMajorRecord_FieldIndex.FormVersion: + this.FormVersion = ex; + break; + case StarfieldMajorRecord_FieldIndex.Version2: + this.Version2 = ex; + break; + case StarfieldMajorRecord_FieldIndex.StarfieldMajorRecordFlags: + this.StarfieldMajorRecordFlags = ex; + break; + default: + base.SetNthException(index, ex); + break; + } + } + + public override void SetNthMask(int index, object obj) + { + StarfieldMajorRecord_FieldIndex enu = (StarfieldMajorRecord_FieldIndex)index; + switch (enu) + { + case StarfieldMajorRecord_FieldIndex.FormVersion: + this.FormVersion = (Exception?)obj; + break; + case StarfieldMajorRecord_FieldIndex.Version2: + this.Version2 = (Exception?)obj; + break; + case StarfieldMajorRecord_FieldIndex.StarfieldMajorRecordFlags: + this.StarfieldMajorRecordFlags = (Exception?)obj; + break; + default: + base.SetNthMask(index, obj); + break; + } + } + + public override bool IsInError() + { + if (Overall != null) return true; + if (FormVersion != null) return true; + if (Version2 != null) return true; + if (StarfieldMajorRecordFlags != null) return true; + return false; + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public override void Print(StructuredStringBuilder sb, string? name = null) + { + sb.AppendLine($"{(name ?? "ErrorMask")} =>"); + using (sb.Brace()) + { + if (this.Overall != null) + { + sb.AppendLine("Overall =>"); + using (sb.Brace()) + { + sb.AppendLine($"{this.Overall}"); + } + } + PrintFillInternal(sb); + } + } + protected override void PrintFillInternal(StructuredStringBuilder sb) + { + base.PrintFillInternal(sb); + { + sb.AppendItem(FormVersion, "FormVersion"); + } + { + sb.AppendItem(Version2, "Version2"); + } + { + sb.AppendItem(StarfieldMajorRecordFlags, "StarfieldMajorRecordFlags"); + } + } + #endregion + + #region Combine + public ErrorMask Combine(ErrorMask? rhs) + { + if (rhs == null) return this; + var ret = new ErrorMask(); + ret.FormVersion = this.FormVersion.Combine(rhs.FormVersion); + ret.Version2 = this.Version2.Combine(rhs.Version2); + ret.StarfieldMajorRecordFlags = this.StarfieldMajorRecordFlags.Combine(rhs.StarfieldMajorRecordFlags); + return ret; + } + public static ErrorMask? Combine(ErrorMask? lhs, ErrorMask? rhs) + { + if (lhs != null && rhs != null) return lhs.Combine(rhs); + return lhs ?? rhs; + } + #endregion + + #region Factory + public static new ErrorMask Factory(ErrorMaskBuilder errorMask) + { + return new ErrorMask(); + } + #endregion + + } + public new class TranslationMask : + MajorRecord.TranslationMask, + ITranslationMask + { + #region Members + public bool FormVersion; + public bool Version2; + public bool StarfieldMajorRecordFlags; + #endregion + + #region Ctors + public TranslationMask( + bool defaultOn, + bool onOverall = true) + : base(defaultOn, onOverall) + { + this.FormVersion = defaultOn; + this.Version2 = defaultOn; + this.StarfieldMajorRecordFlags = defaultOn; + } + + #endregion + + protected override void GetCrystal(List<(bool On, TranslationCrystal? SubCrystal)> ret) + { + base.GetCrystal(ret); + ret.Add((FormVersion, null)); + ret.Add((Version2, null)); + ret.Add((StarfieldMajorRecordFlags, null)); + } + + public static implicit operator TranslationMask(bool defaultOn) + { + return new TranslationMask(defaultOn: defaultOn, onOverall: defaultOn); + } + + } + #endregion + + #region Mutagen + public override IEnumerable EnumerateFormLinks() => StarfieldMajorRecordCommon.Instance.EnumerateFormLinks(this); + public override void RemapLinks(IReadOnlyDictionary mapping) => StarfieldMajorRecordSetterCommon.Instance.RemapLinks(this, mapping); + public StarfieldMajorRecord(FormKey formKey) + { + this.FormKey = formKey; + this.FormVersion = GameRelease.Starfield.GetDefaultFormVersion()!.Value; + CustomCtor(); + } + + private StarfieldMajorRecord( + FormKey formKey, + GameRelease gameRelease) + { + this.FormKey = formKey; + this.FormVersion = gameRelease.GetDefaultFormVersion()!.Value; + CustomCtor(); + } + + internal StarfieldMajorRecord( + FormKey formKey, + ushort formVersion) + { + this.FormKey = formKey; + this.FormVersion = formVersion; + CustomCtor(); + } + + public StarfieldMajorRecord(IStarfieldMod mod) + : this(mod.GetNextFormKey()) + { + } + + public StarfieldMajorRecord(IStarfieldMod mod, string editorID) + : this(mod.GetNextFormKey(editorID)) + { + this.EditorID = editorID; + } + + public override string ToString() + { + return MajorRecordPrinter.ToString(this); + } + + public override IEnumerable EnumerateAssetLinks(AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) => StarfieldMajorRecordCommon.Instance.EnumerateAssetLinks(this, queryCategories, linkCache, assetType); + public override IEnumerable EnumerateListedAssetLinks() => StarfieldMajorRecordSetterCommon.Instance.EnumerateListedAssetLinks(this); + public override void RemapAssetLinks(IReadOnlyDictionary mapping, AssetLinkQuery queryCategories, IAssetLinkCache? linkCache) => StarfieldMajorRecordSetterCommon.Instance.RemapAssetLinks(this, mapping, linkCache, queryCategories); + public override void RemapListedAssetLinks(IReadOnlyDictionary mapping) => StarfieldMajorRecordSetterCommon.Instance.RemapAssetLinks(this, mapping, null, AssetLinkQuery.Listed); + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is IFormLinkGetter formLink) + { + return formLink.Equals(this); + } + if (obj is not IStarfieldMajorRecordGetter rhs) return false; + return ((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IStarfieldMajorRecordGetter? obj) + { + return ((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + #endregion + + #region Binary Translation + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected override object BinaryWriteTranslator => StarfieldMajorRecordBinaryWriteTranslation.Instance; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((StarfieldMajorRecordBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + void IClearable.Clear() + { + ((StarfieldMajorRecordSetterCommon)((IStarfieldMajorRecordGetter)this).CommonSetterInstance()!).Clear(this); + } + + internal static new StarfieldMajorRecord GetNew() + { + throw new ArgumentException("New called on an abstract class."); + } + + } + #endregion + + #region Interface + /// + /// Implemented by: [Npc, Race, Weapon] + /// + public partial interface IStarfieldMajorRecord : + IAssetLinkContainer, + IFormLinkContainer, + ILoquiObjectSetter, + IMajorRecordInternal, + IStarfieldMajorRecordGetter + { + new UInt16 FormVersion { get; set; } + new UInt16 Version2 { get; set; } + new StarfieldMajorRecord.StarfieldMajorRecordFlag StarfieldMajorRecordFlags { get; set; } + } + + public partial interface IStarfieldMajorRecordInternal : + IMajorRecordInternal, + IStarfieldMajorRecord, + IStarfieldMajorRecordGetter + { + } + + /// + /// Implemented by: [Npc, Race, Weapon] + /// + public partial interface IStarfieldMajorRecordGetter : + IMajorRecordGetter, + IAssetLinkContainerGetter, + IBinaryItem, + IFormLinkContainerGetter, + ILoquiObject + { + static new ILoquiRegistration StaticRegistration => StarfieldMajorRecord_Registration.Instance; + UInt16 FormVersion { get; } + UInt16 Version2 { get; } + StarfieldMajorRecord.StarfieldMajorRecordFlag StarfieldMajorRecordFlags { get; } + + } + + #endregion + + #region Common MixIn + public static partial class StarfieldMajorRecordMixIn + { + public static void Clear(this IStarfieldMajorRecordInternal item) + { + ((StarfieldMajorRecordSetterCommon)((IStarfieldMajorRecordGetter)item).CommonSetterInstance()!).Clear(item: item); + } + + public static StarfieldMajorRecord.Mask GetEqualsMask( + this IStarfieldMajorRecordGetter item, + IStarfieldMajorRecordGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + return ((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)item).CommonInstance()!).GetEqualsMask( + item: item, + rhs: rhs, + include: include); + } + + public static string Print( + this IStarfieldMajorRecordGetter item, + string? name = null, + StarfieldMajorRecord.Mask? printMask = null) + { + return ((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)item).CommonInstance()!).Print( + item: item, + name: name, + printMask: printMask); + } + + public static void Print( + this IStarfieldMajorRecordGetter item, + StructuredStringBuilder sb, + string? name = null, + StarfieldMajorRecord.Mask? printMask = null) + { + ((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)item).CommonInstance()!).Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + } + + public static bool Equals( + this IStarfieldMajorRecordGetter item, + IStarfieldMajorRecordGetter rhs, + StarfieldMajorRecord.TranslationMask? equalsMask = null) + { + return ((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)item).CommonInstance()!).Equals( + lhs: item, + rhs: rhs, + equalsMask: equalsMask?.GetCrystal()); + } + + public static void DeepCopyIn( + this IStarfieldMajorRecordInternal lhs, + IStarfieldMajorRecordGetter rhs, + out StarfieldMajorRecord.ErrorMask errorMask, + StarfieldMajorRecord.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + ((StarfieldMajorRecordSetterTranslationCommon)((IStarfieldMajorRecordGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + errorMask = StarfieldMajorRecord.ErrorMask.Factory(errorMaskBuilder); + } + + public static void DeepCopyIn( + this IStarfieldMajorRecordInternal lhs, + IStarfieldMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask) + { + ((StarfieldMajorRecordSetterTranslationCommon)((IStarfieldMajorRecordGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: false); + } + + public static StarfieldMajorRecord DeepCopy( + this IStarfieldMajorRecordGetter item, + StarfieldMajorRecord.TranslationMask? copyMask = null) + { + return ((StarfieldMajorRecordSetterTranslationCommon)((IStarfieldMajorRecordGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask); + } + + public static StarfieldMajorRecord DeepCopy( + this IStarfieldMajorRecordGetter item, + out StarfieldMajorRecord.ErrorMask errorMask, + StarfieldMajorRecord.TranslationMask? copyMask = null) + { + return ((StarfieldMajorRecordSetterTranslationCommon)((IStarfieldMajorRecordGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: out errorMask); + } + + public static StarfieldMajorRecord DeepCopy( + this IStarfieldMajorRecordGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + return ((StarfieldMajorRecordSetterTranslationCommon)((IStarfieldMajorRecordGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: errorMask); + } + + #region Mutagen + public static StarfieldMajorRecord Duplicate( + this IStarfieldMajorRecordGetter item, + FormKey formKey, + StarfieldMajorRecord.TranslationMask? copyMask = null) + { + return ((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)item).CommonInstance()!).Duplicate( + item: item, + formKey: formKey, + copyMask: copyMask?.GetCrystal()); + } + + public static StarfieldMajorRecord Duplicate( + this IStarfieldMajorRecordGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + return ((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)item).CommonInstance()!).Duplicate( + item: item, + formKey: formKey, + copyMask: copyMask); + } + + #endregion + + #region Binary Translation + public static void CopyInFromBinary( + this IStarfieldMajorRecordInternal item, + MutagenFrame frame, + TypedParseParams translationParams = default) + { + ((StarfieldMajorRecordSetterCommon)((IStarfieldMajorRecordGetter)item).CommonSetterInstance()!).CopyInFromBinary( + item: item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + #region Field Index + internal enum StarfieldMajorRecord_FieldIndex + { + MajorRecordFlagsRaw = 0, + FormKey = 1, + VersionControl = 2, + EditorID = 3, + FormVersion = 4, + Version2 = 5, + StarfieldMajorRecordFlags = 6, + } + #endregion + + #region Registration + internal partial class StarfieldMajorRecord_Registration : ILoquiRegistration + { + public static readonly StarfieldMajorRecord_Registration Instance = new StarfieldMajorRecord_Registration(); + + public static ProtocolKey ProtocolKey => ProtocolDefinition_Starfield.ProtocolKey; + + public static readonly ObjectKey ObjectKey = new ObjectKey( + protocolKey: ProtocolDefinition_Starfield.ProtocolKey, + msgID: 65, + version: 0); + + public const string GUID = "7fb2c257-4be7-4aaf-a3c8-4e7f76deaa60"; + + public const ushort AdditionalFieldCount = 3; + + public const ushort FieldCount = 7; + + public static readonly Type MaskType = typeof(StarfieldMajorRecord.Mask<>); + + public static readonly Type ErrorMaskType = typeof(StarfieldMajorRecord.ErrorMask); + + public static readonly Type ClassType = typeof(StarfieldMajorRecord); + + public static readonly Type GetterType = typeof(IStarfieldMajorRecordGetter); + + public static readonly Type? InternalGetterType = null; + + public static readonly Type SetterType = typeof(IStarfieldMajorRecord); + + public static readonly Type? InternalSetterType = typeof(IStarfieldMajorRecordInternal); + + public const string FullName = "Mutagen.Bethesda.Starfield.StarfieldMajorRecord"; + + public const string Name = "StarfieldMajorRecord"; + + public const string Namespace = "Mutagen.Bethesda.Starfield"; + + public const byte GenericCount = 0; + + public static readonly Type? GenericRegistrationType = null; + + public static readonly Type BinaryWriteTranslation = typeof(StarfieldMajorRecordBinaryWriteTranslation); + #region Interface + ProtocolKey ILoquiRegistration.ProtocolKey => ProtocolKey; + ObjectKey ILoquiRegistration.ObjectKey => ObjectKey; + string ILoquiRegistration.GUID => GUID; + ushort ILoquiRegistration.FieldCount => FieldCount; + ushort ILoquiRegistration.AdditionalFieldCount => AdditionalFieldCount; + Type ILoquiRegistration.MaskType => MaskType; + Type ILoquiRegistration.ErrorMaskType => ErrorMaskType; + Type ILoquiRegistration.ClassType => ClassType; + Type ILoquiRegistration.SetterType => SetterType; + Type? ILoquiRegistration.InternalSetterType => InternalSetterType; + Type ILoquiRegistration.GetterType => GetterType; + Type? ILoquiRegistration.InternalGetterType => InternalGetterType; + string ILoquiRegistration.FullName => FullName; + string ILoquiRegistration.Name => Name; + string ILoquiRegistration.Namespace => Namespace; + byte ILoquiRegistration.GenericCount => GenericCount; + Type? ILoquiRegistration.GenericRegistrationType => GenericRegistrationType; + ushort? ILoquiRegistration.GetNameIndex(StringCaseAgnostic name) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsEnumerable(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsLoqui(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsSingleton(ushort index) => throw new NotImplementedException(); + string ILoquiRegistration.GetNthName(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsNthDerivative(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsProtected(ushort index) => throw new NotImplementedException(); + Type ILoquiRegistration.GetNthType(ushort index) => throw new NotImplementedException(); + #endregion + + } + #endregion + + #region Common + internal partial class StarfieldMajorRecordSetterCommon : MajorRecordSetterCommon + { + public new static readonly StarfieldMajorRecordSetterCommon Instance = new StarfieldMajorRecordSetterCommon(); + + partial void ClearPartial(); + + public virtual void Clear(IStarfieldMajorRecordInternal item) + { + ClearPartial(); + item.FormVersion = default; + item.Version2 = default; + item.StarfieldMajorRecordFlags = default; + base.Clear(item); + } + + public override void Clear(IMajorRecordInternal item) + { + Clear(item: (IStarfieldMajorRecordInternal)item); + } + + #region Mutagen + public void RemapLinks(IStarfieldMajorRecord obj, IReadOnlyDictionary mapping) + { + base.RemapLinks(obj, mapping); + } + + public IEnumerable EnumerateListedAssetLinks(IStarfieldMajorRecord obj) + { + foreach (var item in base.EnumerateListedAssetLinks(obj)) + { + yield return item; + } + yield break; + } + + public void RemapAssetLinks( + IStarfieldMajorRecord obj, + IReadOnlyDictionary mapping, + IAssetLinkCache? linkCache, + AssetLinkQuery queryCategories) + { + base.RemapAssetLinks(obj, mapping, linkCache, queryCategories); + } + + #endregion + + #region Binary Translation + public virtual void CopyInFromBinary( + IStarfieldMajorRecordInternal item, + MutagenFrame frame, + TypedParseParams translationParams) + { + PluginUtilityTranslation.MajorRecordParse( + record: item, + frame: frame, + translationParams: translationParams, + fillStructs: StarfieldMajorRecordBinaryCreateTranslation.FillBinaryStructs, + fillTyped: StarfieldMajorRecordBinaryCreateTranslation.FillBinaryRecordTypes); + } + + public override void CopyInFromBinary( + IMajorRecordInternal item, + MutagenFrame frame, + TypedParseParams translationParams) + { + CopyInFromBinary( + item: (StarfieldMajorRecord)item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + internal partial class StarfieldMajorRecordCommon : MajorRecordCommon + { + public new static readonly StarfieldMajorRecordCommon Instance = new StarfieldMajorRecordCommon(); + + public StarfieldMajorRecord.Mask GetEqualsMask( + IStarfieldMajorRecordGetter item, + IStarfieldMajorRecordGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + var ret = new StarfieldMajorRecord.Mask(false); + ((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)item).CommonInstance()!).FillEqualsMask( + item: item, + rhs: rhs, + ret: ret, + include: include); + return ret; + } + + public void FillEqualsMask( + IStarfieldMajorRecordGetter item, + IStarfieldMajorRecordGetter rhs, + StarfieldMajorRecord.Mask ret, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + ret.FormVersion = item.FormVersion == rhs.FormVersion; + ret.Version2 = item.Version2 == rhs.Version2; + ret.StarfieldMajorRecordFlags = item.StarfieldMajorRecordFlags == rhs.StarfieldMajorRecordFlags; + base.FillEqualsMask(item, rhs, ret, include); + } + + public string Print( + IStarfieldMajorRecordGetter item, + string? name = null, + StarfieldMajorRecord.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + return sb.ToString(); + } + + public void Print( + IStarfieldMajorRecordGetter item, + StructuredStringBuilder sb, + string? name = null, + StarfieldMajorRecord.Mask? printMask = null) + { + if (name == null) + { + sb.AppendLine($"StarfieldMajorRecord =>"); + } + else + { + sb.AppendLine($"{name} (StarfieldMajorRecord) =>"); + } + using (sb.Brace()) + { + ToStringFields( + item: item, + sb: sb, + printMask: printMask); + } + } + + protected static void ToStringFields( + IStarfieldMajorRecordGetter item, + StructuredStringBuilder sb, + StarfieldMajorRecord.Mask? printMask = null) + { + MajorRecordCommon.ToStringFields( + item: item, + sb: sb, + printMask: printMask); + if (printMask?.FormVersion ?? true) + { + sb.AppendItem(item.FormVersion, "FormVersion"); + } + if (printMask?.Version2 ?? true) + { + sb.AppendItem(item.Version2, "Version2"); + } + if (printMask?.StarfieldMajorRecordFlags ?? true) + { + sb.AppendItem(item.StarfieldMajorRecordFlags, "StarfieldMajorRecordFlags"); + } + } + + public static StarfieldMajorRecord_FieldIndex ConvertFieldIndex(MajorRecord_FieldIndex index) + { + switch (index) + { + case MajorRecord_FieldIndex.MajorRecordFlagsRaw: + return (StarfieldMajorRecord_FieldIndex)((int)index); + case MajorRecord_FieldIndex.FormKey: + return (StarfieldMajorRecord_FieldIndex)((int)index); + case MajorRecord_FieldIndex.VersionControl: + return (StarfieldMajorRecord_FieldIndex)((int)index); + case MajorRecord_FieldIndex.EditorID: + return (StarfieldMajorRecord_FieldIndex)((int)index); + default: + throw new ArgumentException($"Index is out of range: {index.ToStringFast()}"); + } + } + + #region Equals and Hash + public virtual bool Equals( + IStarfieldMajorRecordGetter? lhs, + IStarfieldMajorRecordGetter? rhs, + TranslationCrystal? equalsMask) + { + if (!EqualsMaskHelper.RefEquality(lhs, rhs, out var isEqual)) return isEqual; + if (!base.Equals((IMajorRecordGetter)lhs, (IMajorRecordGetter)rhs, equalsMask)) return false; + if ((equalsMask?.GetShouldTranslate((int)StarfieldMajorRecord_FieldIndex.FormVersion) ?? true)) + { + if (lhs.FormVersion != rhs.FormVersion) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldMajorRecord_FieldIndex.Version2) ?? true)) + { + if (lhs.Version2 != rhs.Version2) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldMajorRecord_FieldIndex.StarfieldMajorRecordFlags) ?? true)) + { + if (lhs.StarfieldMajorRecordFlags != rhs.StarfieldMajorRecordFlags) return false; + } + return true; + } + + public override bool Equals( + IMajorRecordGetter? lhs, + IMajorRecordGetter? rhs, + TranslationCrystal? equalsMask) + { + return Equals( + lhs: (IStarfieldMajorRecordGetter?)lhs, + rhs: rhs as IStarfieldMajorRecordGetter, + equalsMask: equalsMask); + } + + public virtual int GetHashCode(IStarfieldMajorRecordGetter item) + { + var hash = new HashCode(); + hash.Add(item.FormVersion); + hash.Add(item.Version2); + hash.Add(item.StarfieldMajorRecordFlags); + hash.Add(base.GetHashCode()); + return hash.ToHashCode(); + } + + public override int GetHashCode(IMajorRecordGetter item) + { + return GetHashCode(item: (IStarfieldMajorRecordGetter)item); + } + + #endregion + + + public override object GetNew() + { + return StarfieldMajorRecord.GetNew(); + } + + #region Mutagen + public IEnumerable EnumerateFormLinks(IStarfieldMajorRecordGetter obj) + { + foreach (var item in base.EnumerateFormLinks(obj)) + { + yield return item; + } + yield break; + } + + public IEnumerable EnumerateAssetLinks(IStarfieldMajorRecordGetter obj, AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) + { + foreach (var item in base.EnumerateAssetLinks(obj, queryCategories, linkCache, assetType)) + { + yield return item; + } + yield break; + } + + #region Duplicate + public virtual StarfieldMajorRecord Duplicate( + IStarfieldMajorRecordGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + throw new NotImplementedException(); + } + + public override MajorRecord Duplicate( + IMajorRecordGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + return this.Duplicate( + item: (IStarfieldMajorRecordGetter)item, + formKey: formKey, + copyMask: copyMask); + } + + #endregion + + #endregion + + } + internal partial class StarfieldMajorRecordSetterTranslationCommon : MajorRecordSetterTranslationCommon + { + public new static readonly StarfieldMajorRecordSetterTranslationCommon Instance = new StarfieldMajorRecordSetterTranslationCommon(); + + #region DeepCopyIn + public virtual void DeepCopyIn( + IStarfieldMajorRecordInternal item, + IStarfieldMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + base.DeepCopyIn( + item, + rhs, + errorMask, + copyMask, + deepCopy: deepCopy); + } + + public virtual void DeepCopyIn( + IStarfieldMajorRecord item, + IStarfieldMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + base.DeepCopyIn( + (IMajorRecord)item, + (IMajorRecordGetter)rhs, + errorMask, + copyMask, + deepCopy: deepCopy); + if ((copyMask?.GetShouldTranslate((int)StarfieldMajorRecord_FieldIndex.FormVersion) ?? true)) + { + item.FormVersion = rhs.FormVersion; + } + if ((copyMask?.GetShouldTranslate((int)StarfieldMajorRecord_FieldIndex.Version2) ?? true)) + { + item.Version2 = rhs.Version2; + } + if ((copyMask?.GetShouldTranslate((int)StarfieldMajorRecord_FieldIndex.StarfieldMajorRecordFlags) ?? true)) + { + item.StarfieldMajorRecordFlags = rhs.StarfieldMajorRecordFlags; + } + } + + public override void DeepCopyIn( + IMajorRecordInternal item, + IMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (IStarfieldMajorRecordInternal)item, + rhs: (IStarfieldMajorRecordGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + public override void DeepCopyIn( + IMajorRecord item, + IMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (IStarfieldMajorRecord)item, + rhs: (IStarfieldMajorRecordGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + #endregion + + public StarfieldMajorRecord DeepCopy( + IStarfieldMajorRecordGetter item, + StarfieldMajorRecord.TranslationMask? copyMask = null) + { + StarfieldMajorRecord ret = (StarfieldMajorRecord)((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)item).CommonInstance()!).GetNew(); + ((StarfieldMajorRecordSetterTranslationCommon)((IStarfieldMajorRecordGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: null, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + return ret; + } + + public StarfieldMajorRecord DeepCopy( + IStarfieldMajorRecordGetter item, + out StarfieldMajorRecord.ErrorMask errorMask, + StarfieldMajorRecord.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + StarfieldMajorRecord ret = (StarfieldMajorRecord)((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)item).CommonInstance()!).GetNew(); + ((StarfieldMajorRecordSetterTranslationCommon)((IStarfieldMajorRecordGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + ret, + item, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + errorMask = StarfieldMajorRecord.ErrorMask.Factory(errorMaskBuilder); + return ret; + } + + public StarfieldMajorRecord DeepCopy( + IStarfieldMajorRecordGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + StarfieldMajorRecord ret = (StarfieldMajorRecord)((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)item).CommonInstance()!).GetNew(); + ((StarfieldMajorRecordSetterTranslationCommon)((IStarfieldMajorRecordGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: true); + return ret; + } + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + public partial class StarfieldMajorRecord + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => StarfieldMajorRecord_Registration.Instance; + public new static ILoquiRegistration StaticRegistration => StarfieldMajorRecord_Registration.Instance; + [DebuggerStepThrough] + protected override object CommonInstance() => StarfieldMajorRecordCommon.Instance; + [DebuggerStepThrough] + protected override object CommonSetterInstance() + { + return StarfieldMajorRecordSetterCommon.Instance; + } + [DebuggerStepThrough] + protected override object CommonSetterTranslationInstance() => StarfieldMajorRecordSetterTranslationCommon.Instance; + + #endregion + + } +} + +#region Modules +#region Binary Translation +namespace Mutagen.Bethesda.Starfield +{ + public partial class StarfieldMajorRecordBinaryWriteTranslation : + MajorRecordBinaryWriteTranslation, + IBinaryWriteTranslator + { + public new static readonly StarfieldMajorRecordBinaryWriteTranslation Instance = new(); + + public static void WriteEmbedded( + IStarfieldMajorRecordGetter item, + MutagenWriter writer) + { + MajorRecordBinaryWriteTranslation.WriteEmbedded( + item: item, + writer: writer); + writer.Write(item.FormVersion); + writer.Write(item.Version2); + } + + public virtual void Write( + MutagenWriter writer, + IStarfieldMajorRecordGetter item, + TypedWriteParams translationParams) + { + try + { + WriteEmbedded( + item: item, + writer: writer); + if (!item.IsDeleted) + { + MajorRecordBinaryWriteTranslation.WriteRecordTypes( + item: item, + writer: writer, + translationParams: translationParams); + } + } + catch (Exception ex) + { + throw RecordException.Enrich(ex, item); + } + } + + public override void Write( + MutagenWriter writer, + object item, + TypedWriteParams translationParams = default) + { + Write( + item: (IStarfieldMajorRecordGetter)item, + writer: writer, + translationParams: translationParams); + } + + public override void Write( + MutagenWriter writer, + IMajorRecordGetter item, + TypedWriteParams translationParams) + { + Write( + item: (IStarfieldMajorRecordGetter)item, + writer: writer, + translationParams: translationParams); + } + + } + + internal partial class StarfieldMajorRecordBinaryCreateTranslation : MajorRecordBinaryCreateTranslation + { + public new static readonly StarfieldMajorRecordBinaryCreateTranslation Instance = new StarfieldMajorRecordBinaryCreateTranslation(); + + public override RecordType RecordType => throw new ArgumentException(); + public static void FillBinaryStructs( + IStarfieldMajorRecordInternal item, + MutagenFrame frame) + { + MajorRecordBinaryCreateTranslation.FillBinaryStructs( + item: item, + frame: frame); + item.FormVersion = frame.ReadUInt16(); + item.Version2 = frame.ReadUInt16(); + } + + } + +} +namespace Mutagen.Bethesda.Starfield +{ + #region Binary Write Mixins + public static class StarfieldMajorRecordBinaryTranslationMixIn + { + } + #endregion + + +} +namespace Mutagen.Bethesda.Starfield +{ + internal abstract partial class StarfieldMajorRecordBinaryOverlay : + MajorRecordBinaryOverlay, + IStarfieldMajorRecordGetter + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => StarfieldMajorRecord_Registration.Instance; + public new static ILoquiRegistration StaticRegistration => StarfieldMajorRecord_Registration.Instance; + [DebuggerStepThrough] + protected override object CommonInstance() => StarfieldMajorRecordCommon.Instance; + [DebuggerStepThrough] + protected override object CommonSetterTranslationInstance() => StarfieldMajorRecordSetterTranslationCommon.Instance; + + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + public override IEnumerable EnumerateFormLinks() => StarfieldMajorRecordCommon.Instance.EnumerateFormLinks(this); + public override IEnumerable EnumerateAssetLinks(AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) => StarfieldMajorRecordCommon.Instance.EnumerateAssetLinks(this, queryCategories, linkCache, assetType); + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected override object BinaryWriteTranslator => StarfieldMajorRecordBinaryWriteTranslation.Instance; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((StarfieldMajorRecordBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + + public UInt16 FormVersion => BinaryPrimitives.ReadUInt16LittleEndian(_structData.Slice(0xC, 0x2)); + public UInt16 Version2 => BinaryPrimitives.ReadUInt16LittleEndian(_structData.Slice(0xE, 0x2)); + partial void CustomFactoryEnd( + OverlayStream stream, + int finalPos, + int offset); + + partial void CustomCtor(); + protected StarfieldMajorRecordBinaryOverlay( + MemoryPair memoryPair, + BinaryOverlayFactoryPackage package) + : base( + memoryPair: memoryPair, + package: package) + { + this.CustomCtor(); + } + + + #region To String + + public override void Print( + StructuredStringBuilder sb, + string? name = null) + { + StarfieldMajorRecordMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + public override string ToString() + { + return MajorRecordPrinter.ToString(this); + } + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is IFormLinkGetter formLink) + { + return formLink.Equals(this); + } + if (obj is not IStarfieldMajorRecordGetter rhs) return false; + return ((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IStarfieldMajorRecordGetter? obj) + { + return ((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((StarfieldMajorRecordCommon)((IStarfieldMajorRecordGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + } + +} +#endregion + +#endregion + diff --git a/Mutagen.Bethesda.Starfield/Records/StarfieldMod.cs b/Mutagen.Bethesda.Starfield/Records/StarfieldMod.cs new file mode 100644 index 0000000000..d4a3ae9033 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/StarfieldMod.cs @@ -0,0 +1,34 @@ +using Mutagen.Bethesda.Plugins.Assets; +using Mutagen.Bethesda.Plugins.Records; + +namespace Mutagen.Bethesda.Starfield; + +public partial class StarfieldMod : AMod +{ + public const uint DefaultInitialNextFormID = 0x800; + private uint GetDefaultInitialNextFormID() => DefaultInitialNextFormID; + + partial void CustomCtor() + { + this.ModHeader.FormVersion = GameRelease.Starfield.GetDefaultFormVersion()!.Value; + } +} + +partial class StarfieldModSetterCommon +{ + private static partial void RemapInferredAssetLinks( + IStarfieldMod obj, + IReadOnlyDictionary mapping, + AssetLinkQuery queryCategories) + { + // Nothing to do here, we can't change the name of the mod + } +} + +partial class StarfieldModCommon +{ + public static partial IEnumerable GetInferredAssetLinks(IStarfieldModGetter obj, Type? assetType) + { + yield break; + } +} \ No newline at end of file diff --git a/Mutagen.Bethesda.Starfield/Records/StarfieldMod.xml b/Mutagen.Bethesda.Starfield/Records/StarfieldMod.xml new file mode 100644 index 0000000000..cc86d4366d --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/StarfieldMod.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Mutagen.Bethesda.Starfield/Records/StarfieldModHeader.cs b/Mutagen.Bethesda.Starfield/Records/StarfieldModHeader.cs new file mode 100644 index 0000000000..4b759d48db --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/StarfieldModHeader.cs @@ -0,0 +1,80 @@ +using Mutagen.Bethesda.Plugins.Binary.Streams; +using Mutagen.Bethesda.Plugins.Binary.Translations; +using Mutagen.Bethesda.Plugins.Records; +using Mutagen.Bethesda.Plugins.Records.Internals; +using Noggog; +using System.Diagnostics; + +namespace Mutagen.Bethesda.Starfield; + +public partial class StarfieldModHeader +{ + [Flags] + public enum HeaderFlag + { + Master = 0x0000_0001, + Localized = 0x0000_0080, + LightMaster = 0x0000_0200, + } + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + int IModHeaderCommon.RawFlags + { + get => (int)this.Flags; + set => this.Flags = (HeaderFlag)value; + } + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + uint IModHeaderCommon.NumRecords + { + get => this.Stats.NumRecords; + set => this.Stats.NumRecords = value; + } + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + uint IModHeaderCommon.NextFormID + { + get => this.Stats.NextFormID; + set => this.Stats.NextFormID = value; + } + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + uint IModHeaderCommon.MinimumCustomFormID => StarfieldMod.DefaultInitialNextFormID; + + IExtendedList IModHeaderCommon.MasterReferences => this.MasterReferences; +} + +public partial interface IStarfieldModHeader : IModHeaderCommon +{ +} + +partial class StarfieldModHeaderBinaryCreateTranslation +{ + public static partial void FillBinaryMasterReferencesCustom(MutagenFrame frame, IStarfieldModHeader item) + { + item.MasterReferences.SetTo( + ListBinaryTranslation.Instance.Parse( + reader: frame.SpawnAll(), + triggeringRecord: RecordTypes.MAST, + transl: MasterReference.TryCreateFromBinary)); + frame.MetaData.MasterReferences.SetTo(item.MasterReferences); + } +} + +partial class StarfieldModHeaderBinaryWriteTranslation +{ + public static partial void WriteBinaryMasterReferencesCustom(MutagenWriter writer, IStarfieldModHeaderGetter item) + { + ListBinaryTranslation.Instance.Write( + writer: writer, + items: item.MasterReferences, + transl: (MutagenWriter subWriter, IMasterReferenceGetter subItem, TypedWriteParams conv) => + { + var Item = subItem; + ((MasterReferenceBinaryWriteTranslation)((IBinaryItem)Item).BinaryWriteTranslator).Write( + item: Item, + writer: subWriter, + translationParams: conv); + }); + } +} \ No newline at end of file diff --git a/Mutagen.Bethesda.Starfield/Records/StarfieldModHeader.xml b/Mutagen.Bethesda.Starfield/Records/StarfieldModHeader.xml new file mode 100644 index 0000000000..db6677dfdf --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/StarfieldModHeader.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mutagen.Bethesda.Starfield/Records/StarfieldModHeader_Generated.cs b/Mutagen.Bethesda.Starfield/Records/StarfieldModHeader_Generated.cs new file mode 100644 index 0000000000..136b95fca4 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/StarfieldModHeader_Generated.cs @@ -0,0 +1,2439 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Autogenerated by Loqui. Do not manually change. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ +#region Usings +using Loqui; +using Loqui.Interfaces; +using Loqui.Internal; +using Mutagen.Bethesda.Binary; +using Mutagen.Bethesda.Plugins; +using Mutagen.Bethesda.Plugins.Binary.Headers; +using Mutagen.Bethesda.Plugins.Binary.Overlay; +using Mutagen.Bethesda.Plugins.Binary.Streams; +using Mutagen.Bethesda.Plugins.Binary.Translations; +using Mutagen.Bethesda.Plugins.Cache; +using Mutagen.Bethesda.Plugins.Exceptions; +using Mutagen.Bethesda.Plugins.Internals; +using Mutagen.Bethesda.Plugins.Records; +using Mutagen.Bethesda.Plugins.Records.Internals; +using Mutagen.Bethesda.Plugins.Records.Mapping; +using Mutagen.Bethesda.Starfield; +using Mutagen.Bethesda.Starfield.Internals; +using Mutagen.Bethesda.Translations.Binary; +using Noggog; +using Noggog.StructuredStrings; +using Noggog.StructuredStrings.CSharp; +using RecordTypeInts = Mutagen.Bethesda.Starfield.Internals.RecordTypeInts; +using RecordTypes = Mutagen.Bethesda.Starfield.Internals.RecordTypes; +using System.Buffers.Binary; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Reactive.Disposables; +using System.Reactive.Linq; +#endregion + +#nullable enable +namespace Mutagen.Bethesda.Starfield +{ + #region Class + public partial class StarfieldModHeader : + IEquatable, + ILoquiObjectSetter, + IStarfieldModHeader + { + #region Ctor + public StarfieldModHeader() + { + CustomCtor(); + } + partial void CustomCtor(); + #endregion + + #region Flags + public StarfieldModHeader.HeaderFlag Flags { get; set; } = default; + #endregion + #region FormID + public UInt32 FormID { get; set; } = default; + #endregion + #region Version + public Int32 Version { get; set; } = default; + #endregion + #region FormVersion + public UInt16 FormVersion { get; set; } = default; + #endregion + #region Version2 + public UInt16 Version2 { get; set; } = default; + #endregion + #region Stats + public ModStats Stats { get; set; } = new ModStats(); + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IModStatsGetter IStarfieldModHeaderGetter.Stats => Stats; + #endregion + #region TypeOffsets + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected MemorySlice? _TypeOffsets; + public MemorySlice? TypeOffsets + { + get => this._TypeOffsets; + set => this._TypeOffsets = value; + } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ReadOnlyMemorySlice? IStarfieldModHeaderGetter.TypeOffsets => this.TypeOffsets; + #endregion + #region Deleted + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected MemorySlice? _Deleted; + public MemorySlice? Deleted + { + get => this._Deleted; + set => this._Deleted = value; + } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ReadOnlyMemorySlice? IStarfieldModHeaderGetter.Deleted => this.Deleted; + #endregion + #region Author + public String? Author { get; set; } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + String? IStarfieldModHeaderGetter.Author => this.Author; + #endregion + #region Description + public String? Description { get; set; } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + String? IStarfieldModHeaderGetter.Description => this.Description; + #endregion + #region MasterReferences + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private ExtendedList _MasterReferences = new ExtendedList(); + public ExtendedList MasterReferences + { + get => this._MasterReferences; + init => this._MasterReferences = value; + } + #region Interface Members + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IReadOnlyList IStarfieldModHeaderGetter.MasterReferences => _MasterReferences; + #endregion + + #endregion + #region OverriddenForms + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private ExtendedList>? _OverriddenForms; + public ExtendedList>? OverriddenForms + { + get => this._OverriddenForms; + set => this._OverriddenForms = value; + } + #region Interface Members + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IReadOnlyList>? IStarfieldModHeaderGetter.OverriddenForms => _OverriddenForms; + #endregion + + #endregion + #region INTV + public Int32? INTV { get; set; } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + Int32? IStarfieldModHeaderGetter.INTV => this.INTV; + #endregion + #region INCC + public Int32? INCC { get; set; } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + Int32? IStarfieldModHeaderGetter.INCC => this.INCC; + #endregion + + #region To String + + public void Print( + StructuredStringBuilder sb, + string? name = null) + { + StarfieldModHeaderMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is not IStarfieldModHeaderGetter rhs) return false; + return ((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IStarfieldModHeaderGetter? obj) + { + return ((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + #region Mask + public class Mask : + IEquatable>, + IMask + { + #region Ctors + public Mask(TItem initialValue) + { + this.Flags = initialValue; + this.FormID = initialValue; + this.Version = initialValue; + this.FormVersion = initialValue; + this.Version2 = initialValue; + this.Stats = new MaskItem?>(initialValue, new ModStats.Mask(initialValue)); + this.TypeOffsets = initialValue; + this.Deleted = initialValue; + this.Author = initialValue; + this.Description = initialValue; + this.MasterReferences = new MaskItem?>>?>(initialValue, Enumerable.Empty?>>()); + this.OverriddenForms = new MaskItem?>(initialValue, Enumerable.Empty<(int Index, TItem Value)>()); + this.INTV = initialValue; + this.INCC = initialValue; + } + + public Mask( + TItem Flags, + TItem FormID, + TItem Version, + TItem FormVersion, + TItem Version2, + TItem Stats, + TItem TypeOffsets, + TItem Deleted, + TItem Author, + TItem Description, + TItem MasterReferences, + TItem OverriddenForms, + TItem INTV, + TItem INCC) + { + this.Flags = Flags; + this.FormID = FormID; + this.Version = Version; + this.FormVersion = FormVersion; + this.Version2 = Version2; + this.Stats = new MaskItem?>(Stats, new ModStats.Mask(Stats)); + this.TypeOffsets = TypeOffsets; + this.Deleted = Deleted; + this.Author = Author; + this.Description = Description; + this.MasterReferences = new MaskItem?>>?>(MasterReferences, Enumerable.Empty?>>()); + this.OverriddenForms = new MaskItem?>(OverriddenForms, Enumerable.Empty<(int Index, TItem Value)>()); + this.INTV = INTV; + this.INCC = INCC; + } + + #pragma warning disable CS8618 + protected Mask() + { + } + #pragma warning restore CS8618 + + #endregion + + #region Members + public TItem Flags; + public TItem FormID; + public TItem Version; + public TItem FormVersion; + public TItem Version2; + public MaskItem?>? Stats { get; set; } + public TItem TypeOffsets; + public TItem Deleted; + public TItem Author; + public TItem Description; + public MaskItem?>>?>? MasterReferences; + public MaskItem?>? OverriddenForms; + public TItem INTV; + public TItem INCC; + #endregion + + #region Equals + public override bool Equals(object? obj) + { + if (!(obj is Mask rhs)) return false; + return Equals(rhs); + } + + public bool Equals(Mask? rhs) + { + if (rhs == null) return false; + if (!object.Equals(this.Flags, rhs.Flags)) return false; + if (!object.Equals(this.FormID, rhs.FormID)) return false; + if (!object.Equals(this.Version, rhs.Version)) return false; + if (!object.Equals(this.FormVersion, rhs.FormVersion)) return false; + if (!object.Equals(this.Version2, rhs.Version2)) return false; + if (!object.Equals(this.Stats, rhs.Stats)) return false; + if (!object.Equals(this.TypeOffsets, rhs.TypeOffsets)) return false; + if (!object.Equals(this.Deleted, rhs.Deleted)) return false; + if (!object.Equals(this.Author, rhs.Author)) return false; + if (!object.Equals(this.Description, rhs.Description)) return false; + if (!object.Equals(this.MasterReferences, rhs.MasterReferences)) return false; + if (!object.Equals(this.OverriddenForms, rhs.OverriddenForms)) return false; + if (!object.Equals(this.INTV, rhs.INTV)) return false; + if (!object.Equals(this.INCC, rhs.INCC)) return false; + return true; + } + public override int GetHashCode() + { + var hash = new HashCode(); + hash.Add(this.Flags); + hash.Add(this.FormID); + hash.Add(this.Version); + hash.Add(this.FormVersion); + hash.Add(this.Version2); + hash.Add(this.Stats); + hash.Add(this.TypeOffsets); + hash.Add(this.Deleted); + hash.Add(this.Author); + hash.Add(this.Description); + hash.Add(this.MasterReferences); + hash.Add(this.OverriddenForms); + hash.Add(this.INTV); + hash.Add(this.INCC); + return hash.ToHashCode(); + } + + #endregion + + #region All + public bool All(Func eval) + { + if (!eval(this.Flags)) return false; + if (!eval(this.FormID)) return false; + if (!eval(this.Version)) return false; + if (!eval(this.FormVersion)) return false; + if (!eval(this.Version2)) return false; + if (Stats != null) + { + if (!eval(this.Stats.Overall)) return false; + if (this.Stats.Specific != null && !this.Stats.Specific.All(eval)) return false; + } + if (!eval(this.TypeOffsets)) return false; + if (!eval(this.Deleted)) return false; + if (!eval(this.Author)) return false; + if (!eval(this.Description)) return false; + if (this.MasterReferences != null) + { + if (!eval(this.MasterReferences.Overall)) return false; + if (this.MasterReferences.Specific != null) + { + foreach (var item in this.MasterReferences.Specific) + { + if (!eval(item.Overall)) return false; + if (item.Specific != null && !item.Specific.All(eval)) return false; + } + } + } + if (this.OverriddenForms != null) + { + if (!eval(this.OverriddenForms.Overall)) return false; + if (this.OverriddenForms.Specific != null) + { + foreach (var item in this.OverriddenForms.Specific) + { + if (!eval(item.Value)) return false; + } + } + } + if (!eval(this.INTV)) return false; + if (!eval(this.INCC)) return false; + return true; + } + #endregion + + #region Any + public bool Any(Func eval) + { + if (eval(this.Flags)) return true; + if (eval(this.FormID)) return true; + if (eval(this.Version)) return true; + if (eval(this.FormVersion)) return true; + if (eval(this.Version2)) return true; + if (Stats != null) + { + if (eval(this.Stats.Overall)) return true; + if (this.Stats.Specific != null && this.Stats.Specific.Any(eval)) return true; + } + if (eval(this.TypeOffsets)) return true; + if (eval(this.Deleted)) return true; + if (eval(this.Author)) return true; + if (eval(this.Description)) return true; + if (this.MasterReferences != null) + { + if (eval(this.MasterReferences.Overall)) return true; + if (this.MasterReferences.Specific != null) + { + foreach (var item in this.MasterReferences.Specific) + { + if (!eval(item.Overall)) return false; + if (item.Specific != null && !item.Specific.All(eval)) return false; + } + } + } + if (this.OverriddenForms != null) + { + if (eval(this.OverriddenForms.Overall)) return true; + if (this.OverriddenForms.Specific != null) + { + foreach (var item in this.OverriddenForms.Specific) + { + if (!eval(item.Value)) return false; + } + } + } + if (eval(this.INTV)) return true; + if (eval(this.INCC)) return true; + return false; + } + #endregion + + #region Translate + public Mask Translate(Func eval) + { + var ret = new StarfieldModHeader.Mask(); + this.Translate_InternalFill(ret, eval); + return ret; + } + + protected void Translate_InternalFill(Mask obj, Func eval) + { + obj.Flags = eval(this.Flags); + obj.FormID = eval(this.FormID); + obj.Version = eval(this.Version); + obj.FormVersion = eval(this.FormVersion); + obj.Version2 = eval(this.Version2); + obj.Stats = this.Stats == null ? null : new MaskItem?>(eval(this.Stats.Overall), this.Stats.Specific?.Translate(eval)); + obj.TypeOffsets = eval(this.TypeOffsets); + obj.Deleted = eval(this.Deleted); + obj.Author = eval(this.Author); + obj.Description = eval(this.Description); + if (MasterReferences != null) + { + obj.MasterReferences = new MaskItem?>>?>(eval(this.MasterReferences.Overall), Enumerable.Empty?>>()); + if (MasterReferences.Specific != null) + { + var l = new List?>>(); + obj.MasterReferences.Specific = l; + foreach (var item in MasterReferences.Specific) + { + MaskItemIndexed?>? mask = item == null ? null : new MaskItemIndexed?>(item.Index, eval(item.Overall), item.Specific?.Translate(eval)); + if (mask == null) continue; + l.Add(mask); + } + } + } + if (OverriddenForms != null) + { + obj.OverriddenForms = new MaskItem?>(eval(this.OverriddenForms.Overall), Enumerable.Empty<(int Index, R Value)>()); + if (OverriddenForms.Specific != null) + { + var l = new List<(int Index, R Item)>(); + obj.OverriddenForms.Specific = l; + foreach (var item in OverriddenForms.Specific) + { + R mask = eval(item.Value); + l.Add((item.Index, mask)); + } + } + } + obj.INTV = eval(this.INTV); + obj.INCC = eval(this.INCC); + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public string Print(StarfieldModHeader.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print(sb, printMask); + return sb.ToString(); + } + + public void Print(StructuredStringBuilder sb, StarfieldModHeader.Mask? printMask = null) + { + sb.AppendLine($"{nameof(StarfieldModHeader.Mask)} =>"); + using (sb.Brace()) + { + if (printMask?.Flags ?? true) + { + sb.AppendItem(Flags, "Flags"); + } + if (printMask?.FormID ?? true) + { + sb.AppendItem(FormID, "FormID"); + } + if (printMask?.Version ?? true) + { + sb.AppendItem(Version, "Version"); + } + if (printMask?.FormVersion ?? true) + { + sb.AppendItem(FormVersion, "FormVersion"); + } + if (printMask?.Version2 ?? true) + { + sb.AppendItem(Version2, "Version2"); + } + if (printMask?.Stats?.Overall ?? true) + { + Stats?.Print(sb); + } + if (printMask?.TypeOffsets ?? true) + { + sb.AppendItem(TypeOffsets, "TypeOffsets"); + } + if (printMask?.Deleted ?? true) + { + sb.AppendItem(Deleted, "Deleted"); + } + if (printMask?.Author ?? true) + { + sb.AppendItem(Author, "Author"); + } + if (printMask?.Description ?? true) + { + sb.AppendItem(Description, "Description"); + } + if ((printMask?.MasterReferences?.Overall ?? true) + && MasterReferences is {} MasterReferencesItem) + { + sb.AppendLine("MasterReferences =>"); + using (sb.Brace()) + { + sb.AppendItem(MasterReferencesItem.Overall); + if (MasterReferencesItem.Specific != null) + { + foreach (var subItem in MasterReferencesItem.Specific) + { + using (sb.Brace()) + { + subItem?.Print(sb); + } + } + } + } + } + if ((printMask?.OverriddenForms?.Overall ?? true) + && OverriddenForms is {} OverriddenFormsItem) + { + sb.AppendLine("OverriddenForms =>"); + using (sb.Brace()) + { + sb.AppendItem(OverriddenFormsItem.Overall); + if (OverriddenFormsItem.Specific != null) + { + foreach (var subItem in OverriddenFormsItem.Specific) + { + using (sb.Brace()) + { + { + sb.AppendItem(subItem); + } + } + } + } + } + } + if (printMask?.INTV ?? true) + { + sb.AppendItem(INTV, "INTV"); + } + if (printMask?.INCC ?? true) + { + sb.AppendItem(INCC, "INCC"); + } + } + } + #endregion + + } + + public class ErrorMask : + IErrorMask, + IErrorMask + { + #region Members + public Exception? Overall { get; set; } + private List? _warnings; + public List Warnings + { + get + { + if (_warnings == null) + { + _warnings = new List(); + } + return _warnings; + } + } + public Exception? Flags; + public Exception? FormID; + public Exception? Version; + public Exception? FormVersion; + public Exception? Version2; + public MaskItem? Stats; + public Exception? TypeOffsets; + public Exception? Deleted; + public Exception? Author; + public Exception? Description; + public MaskItem>?>? MasterReferences; + public MaskItem?>? OverriddenForms; + public Exception? INTV; + public Exception? INCC; + #endregion + + #region IErrorMask + public object? GetNthMask(int index) + { + StarfieldModHeader_FieldIndex enu = (StarfieldModHeader_FieldIndex)index; + switch (enu) + { + case StarfieldModHeader_FieldIndex.Flags: + return Flags; + case StarfieldModHeader_FieldIndex.FormID: + return FormID; + case StarfieldModHeader_FieldIndex.Version: + return Version; + case StarfieldModHeader_FieldIndex.FormVersion: + return FormVersion; + case StarfieldModHeader_FieldIndex.Version2: + return Version2; + case StarfieldModHeader_FieldIndex.Stats: + return Stats; + case StarfieldModHeader_FieldIndex.TypeOffsets: + return TypeOffsets; + case StarfieldModHeader_FieldIndex.Deleted: + return Deleted; + case StarfieldModHeader_FieldIndex.Author: + return Author; + case StarfieldModHeader_FieldIndex.Description: + return Description; + case StarfieldModHeader_FieldIndex.MasterReferences: + return MasterReferences; + case StarfieldModHeader_FieldIndex.OverriddenForms: + return OverriddenForms; + case StarfieldModHeader_FieldIndex.INTV: + return INTV; + case StarfieldModHeader_FieldIndex.INCC: + return INCC; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public void SetNthException(int index, Exception ex) + { + StarfieldModHeader_FieldIndex enu = (StarfieldModHeader_FieldIndex)index; + switch (enu) + { + case StarfieldModHeader_FieldIndex.Flags: + this.Flags = ex; + break; + case StarfieldModHeader_FieldIndex.FormID: + this.FormID = ex; + break; + case StarfieldModHeader_FieldIndex.Version: + this.Version = ex; + break; + case StarfieldModHeader_FieldIndex.FormVersion: + this.FormVersion = ex; + break; + case StarfieldModHeader_FieldIndex.Version2: + this.Version2 = ex; + break; + case StarfieldModHeader_FieldIndex.Stats: + this.Stats = new MaskItem(ex, null); + break; + case StarfieldModHeader_FieldIndex.TypeOffsets: + this.TypeOffsets = ex; + break; + case StarfieldModHeader_FieldIndex.Deleted: + this.Deleted = ex; + break; + case StarfieldModHeader_FieldIndex.Author: + this.Author = ex; + break; + case StarfieldModHeader_FieldIndex.Description: + this.Description = ex; + break; + case StarfieldModHeader_FieldIndex.MasterReferences: + this.MasterReferences = new MaskItem>?>(ex, null); + break; + case StarfieldModHeader_FieldIndex.OverriddenForms: + this.OverriddenForms = new MaskItem?>(ex, null); + break; + case StarfieldModHeader_FieldIndex.INTV: + this.INTV = ex; + break; + case StarfieldModHeader_FieldIndex.INCC: + this.INCC = ex; + break; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public void SetNthMask(int index, object obj) + { + StarfieldModHeader_FieldIndex enu = (StarfieldModHeader_FieldIndex)index; + switch (enu) + { + case StarfieldModHeader_FieldIndex.Flags: + this.Flags = (Exception?)obj; + break; + case StarfieldModHeader_FieldIndex.FormID: + this.FormID = (Exception?)obj; + break; + case StarfieldModHeader_FieldIndex.Version: + this.Version = (Exception?)obj; + break; + case StarfieldModHeader_FieldIndex.FormVersion: + this.FormVersion = (Exception?)obj; + break; + case StarfieldModHeader_FieldIndex.Version2: + this.Version2 = (Exception?)obj; + break; + case StarfieldModHeader_FieldIndex.Stats: + this.Stats = (MaskItem?)obj; + break; + case StarfieldModHeader_FieldIndex.TypeOffsets: + this.TypeOffsets = (Exception?)obj; + break; + case StarfieldModHeader_FieldIndex.Deleted: + this.Deleted = (Exception?)obj; + break; + case StarfieldModHeader_FieldIndex.Author: + this.Author = (Exception?)obj; + break; + case StarfieldModHeader_FieldIndex.Description: + this.Description = (Exception?)obj; + break; + case StarfieldModHeader_FieldIndex.MasterReferences: + this.MasterReferences = (MaskItem>?>)obj; + break; + case StarfieldModHeader_FieldIndex.OverriddenForms: + this.OverriddenForms = (MaskItem?>)obj; + break; + case StarfieldModHeader_FieldIndex.INTV: + this.INTV = (Exception?)obj; + break; + case StarfieldModHeader_FieldIndex.INCC: + this.INCC = (Exception?)obj; + break; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public bool IsInError() + { + if (Overall != null) return true; + if (Flags != null) return true; + if (FormID != null) return true; + if (Version != null) return true; + if (FormVersion != null) return true; + if (Version2 != null) return true; + if (Stats != null) return true; + if (TypeOffsets != null) return true; + if (Deleted != null) return true; + if (Author != null) return true; + if (Description != null) return true; + if (MasterReferences != null) return true; + if (OverriddenForms != null) return true; + if (INTV != null) return true; + if (INCC != null) return true; + return false; + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public void Print(StructuredStringBuilder sb, string? name = null) + { + sb.AppendLine($"{(name ?? "ErrorMask")} =>"); + using (sb.Brace()) + { + if (this.Overall != null) + { + sb.AppendLine("Overall =>"); + using (sb.Brace()) + { + sb.AppendLine($"{this.Overall}"); + } + } + PrintFillInternal(sb); + } + } + protected void PrintFillInternal(StructuredStringBuilder sb) + { + { + sb.AppendItem(Flags, "Flags"); + } + { + sb.AppendItem(FormID, "FormID"); + } + { + sb.AppendItem(Version, "Version"); + } + { + sb.AppendItem(FormVersion, "FormVersion"); + } + { + sb.AppendItem(Version2, "Version2"); + } + Stats?.Print(sb); + { + sb.AppendItem(TypeOffsets, "TypeOffsets"); + } + { + sb.AppendItem(Deleted, "Deleted"); + } + { + sb.AppendItem(Author, "Author"); + } + { + sb.AppendItem(Description, "Description"); + } + if (MasterReferences is {} MasterReferencesItem) + { + sb.AppendLine("MasterReferences =>"); + using (sb.Brace()) + { + sb.AppendItem(MasterReferencesItem.Overall); + if (MasterReferencesItem.Specific != null) + { + foreach (var subItem in MasterReferencesItem.Specific) + { + using (sb.Brace()) + { + subItem?.Print(sb); + } + } + } + } + } + if (OverriddenForms is {} OverriddenFormsItem) + { + sb.AppendLine("OverriddenForms =>"); + using (sb.Brace()) + { + sb.AppendItem(OverriddenFormsItem.Overall); + if (OverriddenFormsItem.Specific != null) + { + foreach (var subItem in OverriddenFormsItem.Specific) + { + using (sb.Brace()) + { + { + sb.AppendItem(subItem); + } + } + } + } + } + } + { + sb.AppendItem(INTV, "INTV"); + } + { + sb.AppendItem(INCC, "INCC"); + } + } + #endregion + + #region Combine + public ErrorMask Combine(ErrorMask? rhs) + { + if (rhs == null) return this; + var ret = new ErrorMask(); + ret.Flags = this.Flags.Combine(rhs.Flags); + ret.FormID = this.FormID.Combine(rhs.FormID); + ret.Version = this.Version.Combine(rhs.Version); + ret.FormVersion = this.FormVersion.Combine(rhs.FormVersion); + ret.Version2 = this.Version2.Combine(rhs.Version2); + ret.Stats = this.Stats.Combine(rhs.Stats, (l, r) => l.Combine(r)); + ret.TypeOffsets = this.TypeOffsets.Combine(rhs.TypeOffsets); + ret.Deleted = this.Deleted.Combine(rhs.Deleted); + ret.Author = this.Author.Combine(rhs.Author); + ret.Description = this.Description.Combine(rhs.Description); + ret.MasterReferences = new MaskItem>?>(Noggog.ExceptionExt.Combine(this.MasterReferences?.Overall, rhs.MasterReferences?.Overall), Noggog.ExceptionExt.Combine(this.MasterReferences?.Specific, rhs.MasterReferences?.Specific)); + ret.OverriddenForms = new MaskItem?>(Noggog.ExceptionExt.Combine(this.OverriddenForms?.Overall, rhs.OverriddenForms?.Overall), Noggog.ExceptionExt.Combine(this.OverriddenForms?.Specific, rhs.OverriddenForms?.Specific)); + ret.INTV = this.INTV.Combine(rhs.INTV); + ret.INCC = this.INCC.Combine(rhs.INCC); + return ret; + } + public static ErrorMask? Combine(ErrorMask? lhs, ErrorMask? rhs) + { + if (lhs != null && rhs != null) return lhs.Combine(rhs); + return lhs ?? rhs; + } + #endregion + + #region Factory + public static ErrorMask Factory(ErrorMaskBuilder errorMask) + { + return new ErrorMask(); + } + #endregion + + } + public class TranslationMask : ITranslationMask + { + #region Members + private TranslationCrystal? _crystal; + public readonly bool DefaultOn; + public bool OnOverall; + public bool Flags; + public bool FormID; + public bool Version; + public bool FormVersion; + public bool Version2; + public ModStats.TranslationMask? Stats; + public bool TypeOffsets; + public bool Deleted; + public bool Author; + public bool Description; + public MasterReference.TranslationMask? MasterReferences; + public bool OverriddenForms; + public bool INTV; + public bool INCC; + #endregion + + #region Ctors + public TranslationMask( + bool defaultOn, + bool onOverall = true) + { + this.DefaultOn = defaultOn; + this.OnOverall = onOverall; + this.Flags = defaultOn; + this.FormID = defaultOn; + this.Version = defaultOn; + this.FormVersion = defaultOn; + this.Version2 = defaultOn; + this.TypeOffsets = defaultOn; + this.Deleted = defaultOn; + this.Author = defaultOn; + this.Description = defaultOn; + this.OverriddenForms = defaultOn; + this.INTV = defaultOn; + this.INCC = defaultOn; + } + + #endregion + + public TranslationCrystal GetCrystal() + { + if (_crystal != null) return _crystal; + var ret = new List<(bool On, TranslationCrystal? SubCrystal)>(); + GetCrystal(ret); + _crystal = new TranslationCrystal(ret.ToArray()); + return _crystal; + } + + protected void GetCrystal(List<(bool On, TranslationCrystal? SubCrystal)> ret) + { + ret.Add((Flags, null)); + ret.Add((FormID, null)); + ret.Add((Version, null)); + ret.Add((FormVersion, null)); + ret.Add((Version2, null)); + ret.Add((Stats != null ? Stats.OnOverall : DefaultOn, Stats?.GetCrystal())); + ret.Add((TypeOffsets, null)); + ret.Add((Deleted, null)); + ret.Add((Author, null)); + ret.Add((Description, null)); + ret.Add((MasterReferences == null ? DefaultOn : !MasterReferences.GetCrystal().CopyNothing, MasterReferences?.GetCrystal())); + ret.Add((OverriddenForms, null)); + ret.Add((INTV, null)); + ret.Add((INCC, null)); + } + + public static implicit operator TranslationMask(bool defaultOn) + { + return new TranslationMask(defaultOn: defaultOn, onOverall: defaultOn); + } + + } + #endregion + + #region Mutagen + public static readonly RecordType GrupRecordType = StarfieldModHeader_Registration.TriggeringRecordType; + public IEnumerable EnumerateFormLinks() => StarfieldModHeaderCommon.Instance.EnumerateFormLinks(this); + public void RemapLinks(IReadOnlyDictionary mapping) => StarfieldModHeaderSetterCommon.Instance.RemapLinks(this, mapping); + #endregion + + #region Binary Translation + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected object BinaryWriteTranslator => StarfieldModHeaderBinaryWriteTranslation.Instance; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + object IBinaryItem.BinaryWriteTranslator => this.BinaryWriteTranslator; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((StarfieldModHeaderBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + #region Binary Create + public static StarfieldModHeader CreateFromBinary( + MutagenFrame frame, + TypedParseParams translationParams = default) + { + var ret = new StarfieldModHeader(); + ((StarfieldModHeaderSetterCommon)((IStarfieldModHeaderGetter)ret).CommonSetterInstance()!).CopyInFromBinary( + item: ret, + frame: frame, + translationParams: translationParams); + return ret; + } + + #endregion + + public static bool TryCreateFromBinary( + MutagenFrame frame, + out StarfieldModHeader item, + TypedParseParams translationParams = default) + { + var startPos = frame.Position; + item = CreateFromBinary( + frame: frame, + translationParams: translationParams); + return startPos != frame.Position; + } + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + void IClearable.Clear() + { + ((StarfieldModHeaderSetterCommon)((IStarfieldModHeaderGetter)this).CommonSetterInstance()!).Clear(this); + } + + internal static StarfieldModHeader GetNew() + { + return new StarfieldModHeader(); + } + + } + #endregion + + #region Interface + public partial interface IStarfieldModHeader : + IFormLinkContainer, + ILoquiObjectSetter, + IStarfieldModHeaderGetter + { + new StarfieldModHeader.HeaderFlag Flags { get; set; } + new UInt32 FormID { get; set; } + new Int32 Version { get; set; } + new UInt16 FormVersion { get; set; } + new UInt16 Version2 { get; set; } + new ModStats Stats { get; set; } + new MemorySlice? TypeOffsets { get; set; } + new MemorySlice? Deleted { get; set; } + new String? Author { get; set; } + new String? Description { get; set; } + new ExtendedList MasterReferences { get; } + new ExtendedList>? OverriddenForms { get; set; } + new Int32? INTV { get; set; } + new Int32? INCC { get; set; } + } + + public partial interface IStarfieldModHeaderGetter : + ILoquiObject, + IBinaryItem, + IFormLinkContainerGetter, + ILoquiObject + { + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object CommonInstance(); + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object? CommonSetterInstance(); + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object CommonSetterTranslationInstance(); + static ILoquiRegistration StaticRegistration => StarfieldModHeader_Registration.Instance; + StarfieldModHeader.HeaderFlag Flags { get; } + UInt32 FormID { get; } + Int32 Version { get; } + UInt16 FormVersion { get; } + UInt16 Version2 { get; } + IModStatsGetter Stats { get; } + ReadOnlyMemorySlice? TypeOffsets { get; } + ReadOnlyMemorySlice? Deleted { get; } + String? Author { get; } + String? Description { get; } + IReadOnlyList MasterReferences { get; } + IReadOnlyList>? OverriddenForms { get; } + Int32? INTV { get; } + Int32? INCC { get; } + + } + + #endregion + + #region Common MixIn + public static partial class StarfieldModHeaderMixIn + { + public static void Clear(this IStarfieldModHeader item) + { + ((StarfieldModHeaderSetterCommon)((IStarfieldModHeaderGetter)item).CommonSetterInstance()!).Clear(item: item); + } + + public static StarfieldModHeader.Mask GetEqualsMask( + this IStarfieldModHeaderGetter item, + IStarfieldModHeaderGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + return ((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)item).CommonInstance()!).GetEqualsMask( + item: item, + rhs: rhs, + include: include); + } + + public static string Print( + this IStarfieldModHeaderGetter item, + string? name = null, + StarfieldModHeader.Mask? printMask = null) + { + return ((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)item).CommonInstance()!).Print( + item: item, + name: name, + printMask: printMask); + } + + public static void Print( + this IStarfieldModHeaderGetter item, + StructuredStringBuilder sb, + string? name = null, + StarfieldModHeader.Mask? printMask = null) + { + ((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)item).CommonInstance()!).Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + } + + public static bool Equals( + this IStarfieldModHeaderGetter item, + IStarfieldModHeaderGetter rhs, + StarfieldModHeader.TranslationMask? equalsMask = null) + { + return ((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)item).CommonInstance()!).Equals( + lhs: item, + rhs: rhs, + equalsMask: equalsMask?.GetCrystal()); + } + + public static void DeepCopyIn( + this IStarfieldModHeader lhs, + IStarfieldModHeaderGetter rhs) + { + ((StarfieldModHeaderSetterTranslationCommon)((IStarfieldModHeaderGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: default, + copyMask: default, + deepCopy: false); + } + + public static void DeepCopyIn( + this IStarfieldModHeader lhs, + IStarfieldModHeaderGetter rhs, + StarfieldModHeader.TranslationMask? copyMask = null) + { + ((StarfieldModHeaderSetterTranslationCommon)((IStarfieldModHeaderGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: default, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + } + + public static void DeepCopyIn( + this IStarfieldModHeader lhs, + IStarfieldModHeaderGetter rhs, + out StarfieldModHeader.ErrorMask errorMask, + StarfieldModHeader.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + ((StarfieldModHeaderSetterTranslationCommon)((IStarfieldModHeaderGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + errorMask = StarfieldModHeader.ErrorMask.Factory(errorMaskBuilder); + } + + public static void DeepCopyIn( + this IStarfieldModHeader lhs, + IStarfieldModHeaderGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask) + { + ((StarfieldModHeaderSetterTranslationCommon)((IStarfieldModHeaderGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: false); + } + + public static StarfieldModHeader DeepCopy( + this IStarfieldModHeaderGetter item, + StarfieldModHeader.TranslationMask? copyMask = null) + { + return ((StarfieldModHeaderSetterTranslationCommon)((IStarfieldModHeaderGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask); + } + + public static StarfieldModHeader DeepCopy( + this IStarfieldModHeaderGetter item, + out StarfieldModHeader.ErrorMask errorMask, + StarfieldModHeader.TranslationMask? copyMask = null) + { + return ((StarfieldModHeaderSetterTranslationCommon)((IStarfieldModHeaderGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: out errorMask); + } + + public static StarfieldModHeader DeepCopy( + this IStarfieldModHeaderGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + return ((StarfieldModHeaderSetterTranslationCommon)((IStarfieldModHeaderGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: errorMask); + } + + #region Binary Translation + public static void CopyInFromBinary( + this IStarfieldModHeader item, + MutagenFrame frame, + TypedParseParams translationParams = default) + { + ((StarfieldModHeaderSetterCommon)((IStarfieldModHeaderGetter)item).CommonSetterInstance()!).CopyInFromBinary( + item: item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + #region Field Index + internal enum StarfieldModHeader_FieldIndex + { + Flags = 0, + FormID = 1, + Version = 2, + FormVersion = 3, + Version2 = 4, + Stats = 5, + TypeOffsets = 6, + Deleted = 7, + Author = 8, + Description = 9, + MasterReferences = 10, + OverriddenForms = 11, + INTV = 12, + INCC = 13, + } + #endregion + + #region Registration + internal partial class StarfieldModHeader_Registration : ILoquiRegistration + { + public static readonly StarfieldModHeader_Registration Instance = new StarfieldModHeader_Registration(); + + public static ProtocolKey ProtocolKey => ProtocolDefinition_Starfield.ProtocolKey; + + public static readonly ObjectKey ObjectKey = new ObjectKey( + protocolKey: ProtocolDefinition_Starfield.ProtocolKey, + msgID: 63, + version: 0); + + public const string GUID = "5c10abbb-9600-4bd1-ba4c-8a244a69f0be"; + + public const ushort AdditionalFieldCount = 14; + + public const ushort FieldCount = 14; + + public static readonly Type MaskType = typeof(StarfieldModHeader.Mask<>); + + public static readonly Type ErrorMaskType = typeof(StarfieldModHeader.ErrorMask); + + public static readonly Type ClassType = typeof(StarfieldModHeader); + + public static readonly Type GetterType = typeof(IStarfieldModHeaderGetter); + + public static readonly Type? InternalGetterType = null; + + public static readonly Type SetterType = typeof(IStarfieldModHeader); + + public static readonly Type? InternalSetterType = null; + + public const string FullName = "Mutagen.Bethesda.Starfield.StarfieldModHeader"; + + public const string Name = "StarfieldModHeader"; + + public const string Namespace = "Mutagen.Bethesda.Starfield"; + + public const byte GenericCount = 0; + + public static readonly Type? GenericRegistrationType = null; + + public static readonly RecordType TriggeringRecordType = RecordTypes.TES4; + public static RecordTriggerSpecs TriggerSpecs => _recordSpecs.Value; + private static readonly Lazy _recordSpecs = new Lazy(() => + { + var triggers = RecordCollection.Factory(RecordTypes.TES4); + var all = RecordCollection.Factory( + RecordTypes.TES4, + RecordTypes.HEDR, + RecordTypes.OFST, + RecordTypes.DELE, + RecordTypes.CNAM, + RecordTypes.SNAM, + RecordTypes.MAST, + RecordTypes.DATA, + RecordTypes.ONAM, + RecordTypes.XXXX, + RecordTypes.INTV, + RecordTypes.INCC); + return new RecordTriggerSpecs(allRecordTypes: all, triggeringRecordTypes: triggers); + }); + public static readonly Type BinaryWriteTranslation = typeof(StarfieldModHeaderBinaryWriteTranslation); + #region Interface + ProtocolKey ILoquiRegistration.ProtocolKey => ProtocolKey; + ObjectKey ILoquiRegistration.ObjectKey => ObjectKey; + string ILoquiRegistration.GUID => GUID; + ushort ILoquiRegistration.FieldCount => FieldCount; + ushort ILoquiRegistration.AdditionalFieldCount => AdditionalFieldCount; + Type ILoquiRegistration.MaskType => MaskType; + Type ILoquiRegistration.ErrorMaskType => ErrorMaskType; + Type ILoquiRegistration.ClassType => ClassType; + Type ILoquiRegistration.SetterType => SetterType; + Type? ILoquiRegistration.InternalSetterType => InternalSetterType; + Type ILoquiRegistration.GetterType => GetterType; + Type? ILoquiRegistration.InternalGetterType => InternalGetterType; + string ILoquiRegistration.FullName => FullName; + string ILoquiRegistration.Name => Name; + string ILoquiRegistration.Namespace => Namespace; + byte ILoquiRegistration.GenericCount => GenericCount; + Type? ILoquiRegistration.GenericRegistrationType => GenericRegistrationType; + ushort? ILoquiRegistration.GetNameIndex(StringCaseAgnostic name) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsEnumerable(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsLoqui(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsSingleton(ushort index) => throw new NotImplementedException(); + string ILoquiRegistration.GetNthName(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsNthDerivative(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsProtected(ushort index) => throw new NotImplementedException(); + Type ILoquiRegistration.GetNthType(ushort index) => throw new NotImplementedException(); + #endregion + + } + #endregion + + #region Common + internal partial class StarfieldModHeaderSetterCommon + { + public static readonly StarfieldModHeaderSetterCommon Instance = new StarfieldModHeaderSetterCommon(); + + partial void ClearPartial(); + + public void Clear(IStarfieldModHeader item) + { + ClearPartial(); + item.Flags = default; + item.FormID = default; + item.Version = default; + item.FormVersion = default; + item.Version2 = default; + item.Stats.Clear(); + item.TypeOffsets = default; + item.Deleted = default; + item.Author = default; + item.Description = default; + item.MasterReferences.Clear(); + item.OverriddenForms = null; + item.INTV = default; + item.INCC = default; + } + + #region Mutagen + public void RemapLinks(IStarfieldModHeader obj, IReadOnlyDictionary mapping) + { + obj.OverriddenForms?.RemapLinks(mapping); + } + + #endregion + + #region Binary Translation + public virtual void CopyInFromBinary( + IStarfieldModHeader item, + MutagenFrame frame, + TypedParseParams translationParams) + { + frame = frame.SpawnWithFinalPosition(HeaderTranslation.ParseRecord( + frame.Reader, + translationParams.ConvertToCustom(RecordTypes.TES4))); + PluginUtilityTranslation.RecordParse( + record: item, + frame: frame, + translationParams: translationParams, + fillStructs: StarfieldModHeaderBinaryCreateTranslation.FillBinaryStructs, + fillTyped: StarfieldModHeaderBinaryCreateTranslation.FillBinaryRecordTypes); + } + + #endregion + + } + internal partial class StarfieldModHeaderCommon + { + public static readonly StarfieldModHeaderCommon Instance = new StarfieldModHeaderCommon(); + + public StarfieldModHeader.Mask GetEqualsMask( + IStarfieldModHeaderGetter item, + IStarfieldModHeaderGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + var ret = new StarfieldModHeader.Mask(false); + ((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)item).CommonInstance()!).FillEqualsMask( + item: item, + rhs: rhs, + ret: ret, + include: include); + return ret; + } + + public void FillEqualsMask( + IStarfieldModHeaderGetter item, + IStarfieldModHeaderGetter rhs, + StarfieldModHeader.Mask ret, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + ret.Flags = item.Flags == rhs.Flags; + ret.FormID = item.FormID == rhs.FormID; + ret.Version = item.Version == rhs.Version; + ret.FormVersion = item.FormVersion == rhs.FormVersion; + ret.Version2 = item.Version2 == rhs.Version2; + ret.Stats = MaskItemExt.Factory(item.Stats.GetEqualsMask(rhs.Stats, include), include); + ret.TypeOffsets = MemorySliceExt.SequenceEqual(item.TypeOffsets, rhs.TypeOffsets); + ret.Deleted = MemorySliceExt.SequenceEqual(item.Deleted, rhs.Deleted); + ret.Author = string.Equals(item.Author, rhs.Author); + ret.Description = string.Equals(item.Description, rhs.Description); + ret.MasterReferences = item.MasterReferences.CollectionEqualsHelper( + rhs.MasterReferences, + (loqLhs, loqRhs) => loqLhs.GetEqualsMask(loqRhs, include), + include); + ret.OverriddenForms = item.OverriddenForms.CollectionEqualsHelper( + rhs.OverriddenForms, + (l, r) => object.Equals(l, r), + include); + ret.INTV = item.INTV == rhs.INTV; + ret.INCC = item.INCC == rhs.INCC; + } + + public string Print( + IStarfieldModHeaderGetter item, + string? name = null, + StarfieldModHeader.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + return sb.ToString(); + } + + public void Print( + IStarfieldModHeaderGetter item, + StructuredStringBuilder sb, + string? name = null, + StarfieldModHeader.Mask? printMask = null) + { + if (name == null) + { + sb.AppendLine($"StarfieldModHeader =>"); + } + else + { + sb.AppendLine($"{name} (StarfieldModHeader) =>"); + } + using (sb.Brace()) + { + ToStringFields( + item: item, + sb: sb, + printMask: printMask); + } + } + + protected static void ToStringFields( + IStarfieldModHeaderGetter item, + StructuredStringBuilder sb, + StarfieldModHeader.Mask? printMask = null) + { + if (printMask?.Flags ?? true) + { + sb.AppendItem(item.Flags, "Flags"); + } + if (printMask?.FormID ?? true) + { + sb.AppendItem(item.FormID, "FormID"); + } + if (printMask?.Version ?? true) + { + sb.AppendItem(item.Version, "Version"); + } + if (printMask?.FormVersion ?? true) + { + sb.AppendItem(item.FormVersion, "FormVersion"); + } + if (printMask?.Version2 ?? true) + { + sb.AppendItem(item.Version2, "Version2"); + } + if (printMask?.Stats?.Overall ?? true) + { + item.Stats?.Print(sb, "Stats"); + } + if ((printMask?.TypeOffsets ?? true) + && item.TypeOffsets is {} TypeOffsetsItem) + { + sb.AppendLine($"TypeOffsets => {SpanExt.ToHexString(TypeOffsetsItem)}"); + } + if ((printMask?.Deleted ?? true) + && item.Deleted is {} DeletedItem) + { + sb.AppendLine($"Deleted => {SpanExt.ToHexString(DeletedItem)}"); + } + if ((printMask?.Author ?? true) + && item.Author is {} AuthorItem) + { + sb.AppendItem(AuthorItem, "Author"); + } + if ((printMask?.Description ?? true) + && item.Description is {} DescriptionItem) + { + sb.AppendItem(DescriptionItem, "Description"); + } + if (printMask?.MasterReferences?.Overall ?? true) + { + sb.AppendLine("MasterReferences =>"); + using (sb.Brace()) + { + foreach (var subItem in item.MasterReferences) + { + using (sb.Brace()) + { + subItem?.Print(sb, "Item"); + } + } + } + } + if ((printMask?.OverriddenForms?.Overall ?? true) + && item.OverriddenForms is {} OverriddenFormsItem) + { + sb.AppendLine("OverriddenForms =>"); + using (sb.Brace()) + { + foreach (var subItem in OverriddenFormsItem) + { + using (sb.Brace()) + { + sb.AppendItem(subItem.FormKey); + } + } + } + } + if ((printMask?.INTV ?? true) + && item.INTV is {} INTVItem) + { + sb.AppendItem(INTVItem, "INTV"); + } + if ((printMask?.INCC ?? true) + && item.INCC is {} INCCItem) + { + sb.AppendItem(INCCItem, "INCC"); + } + } + + #region Equals and Hash + public virtual bool Equals( + IStarfieldModHeaderGetter? lhs, + IStarfieldModHeaderGetter? rhs, + TranslationCrystal? equalsMask) + { + if (!EqualsMaskHelper.RefEquality(lhs, rhs, out var isEqual)) return isEqual; + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Flags) ?? true)) + { + if (lhs.Flags != rhs.Flags) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.FormID) ?? true)) + { + if (lhs.FormID != rhs.FormID) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Version) ?? true)) + { + if (lhs.Version != rhs.Version) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.FormVersion) ?? true)) + { + if (lhs.FormVersion != rhs.FormVersion) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Version2) ?? true)) + { + if (lhs.Version2 != rhs.Version2) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Stats) ?? true)) + { + if (EqualsMaskHelper.RefEquality(lhs.Stats, rhs.Stats, out var lhsStats, out var rhsStats, out var isStatsEqual)) + { + if (!((ModStatsCommon)((IModStatsGetter)lhsStats).CommonInstance()!).Equals(lhsStats, rhsStats, equalsMask?.GetSubCrystal((int)StarfieldModHeader_FieldIndex.Stats))) return false; + } + else if (!isStatsEqual) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.TypeOffsets) ?? true)) + { + if (!MemorySliceExt.SequenceEqual(lhs.TypeOffsets, rhs.TypeOffsets)) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Deleted) ?? true)) + { + if (!MemorySliceExt.SequenceEqual(lhs.Deleted, rhs.Deleted)) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Author) ?? true)) + { + if (!string.Equals(lhs.Author, rhs.Author)) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Description) ?? true)) + { + if (!string.Equals(lhs.Description, rhs.Description)) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.MasterReferences) ?? true)) + { + if (!lhs.MasterReferences.SequenceEqual(rhs.MasterReferences, (l, r) => ((MasterReferenceCommon)((IMasterReferenceGetter)l).CommonInstance()!).Equals(l, r, equalsMask?.GetSubCrystal((int)StarfieldModHeader_FieldIndex.MasterReferences)))) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.OverriddenForms) ?? true)) + { + if (!lhs.OverriddenForms.SequenceEqualNullable(rhs.OverriddenForms)) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.INTV) ?? true)) + { + if (lhs.INTV != rhs.INTV) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.INCC) ?? true)) + { + if (lhs.INCC != rhs.INCC) return false; + } + return true; + } + + public virtual int GetHashCode(IStarfieldModHeaderGetter item) + { + var hash = new HashCode(); + hash.Add(item.Flags); + hash.Add(item.FormID); + hash.Add(item.Version); + hash.Add(item.FormVersion); + hash.Add(item.Version2); + hash.Add(item.Stats); + if (item.TypeOffsets is {} TypeOffsetsItem) + { + hash.Add(TypeOffsetsItem); + } + if (item.Deleted is {} DeletedItem) + { + hash.Add(DeletedItem); + } + if (item.Author is {} Authoritem) + { + hash.Add(Authoritem); + } + if (item.Description is {} Descriptionitem) + { + hash.Add(Descriptionitem); + } + hash.Add(item.MasterReferences); + hash.Add(item.OverriddenForms); + if (item.INTV is {} INTVitem) + { + hash.Add(INTVitem); + } + if (item.INCC is {} INCCitem) + { + hash.Add(INCCitem); + } + return hash.ToHashCode(); + } + + #endregion + + + public object GetNew() + { + return StarfieldModHeader.GetNew(); + } + + #region Mutagen + public IEnumerable EnumerateFormLinks(IStarfieldModHeaderGetter obj) + { + if (obj.OverriddenForms is {} OverriddenFormsItem) + { + foreach (var item in OverriddenFormsItem) + { + yield return FormLinkInformation.Factory(item); + } + } + yield break; + } + + #endregion + + } + internal partial class StarfieldModHeaderSetterTranslationCommon + { + public static readonly StarfieldModHeaderSetterTranslationCommon Instance = new StarfieldModHeaderSetterTranslationCommon(); + + #region DeepCopyIn + public void DeepCopyIn( + IStarfieldModHeader item, + IStarfieldModHeaderGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Flags) ?? true)) + { + item.Flags = rhs.Flags; + } + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.FormID) ?? true)) + { + item.FormID = rhs.FormID; + } + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Version) ?? true)) + { + item.Version = rhs.Version; + } + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.FormVersion) ?? true)) + { + item.FormVersion = rhs.FormVersion; + } + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Version2) ?? true)) + { + item.Version2 = rhs.Version2; + } + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Stats) ?? true)) + { + errorMask?.PushIndex((int)StarfieldModHeader_FieldIndex.Stats); + try + { + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Stats) ?? true)) + { + item.Stats = rhs.Stats.DeepCopy( + copyMask: copyMask?.GetSubCrystal((int)StarfieldModHeader_FieldIndex.Stats), + errorMask: errorMask); + } + } + catch (Exception ex) + when (errorMask != null) + { + errorMask.ReportException(ex); + } + finally + { + errorMask?.PopIndex(); + } + } + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.TypeOffsets) ?? true)) + { + if(rhs.TypeOffsets is {} TypeOffsetsrhs) + { + item.TypeOffsets = TypeOffsetsrhs.ToArray(); + } + else + { + item.TypeOffsets = default; + } + } + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Deleted) ?? true)) + { + if(rhs.Deleted is {} Deletedrhs) + { + item.Deleted = Deletedrhs.ToArray(); + } + else + { + item.Deleted = default; + } + } + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Author) ?? true)) + { + item.Author = rhs.Author; + } + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.Description) ?? true)) + { + item.Description = rhs.Description; + } + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.MasterReferences) ?? true)) + { + errorMask?.PushIndex((int)StarfieldModHeader_FieldIndex.MasterReferences); + try + { + item.MasterReferences.SetTo( + rhs.MasterReferences + .Select(r => + { + return r.DeepCopy( + errorMask: errorMask, + default(TranslationCrystal)); + })); + } + catch (Exception ex) + when (errorMask != null) + { + errorMask.ReportException(ex); + } + finally + { + errorMask?.PopIndex(); + } + } + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.OverriddenForms) ?? true)) + { + errorMask?.PushIndex((int)StarfieldModHeader_FieldIndex.OverriddenForms); + try + { + if ((rhs.OverriddenForms != null)) + { + item.OverriddenForms = + rhs.OverriddenForms + .Select(r => (IFormLinkGetter)new FormLink(r.FormKey)) + .ToExtendedList>(); + } + else + { + item.OverriddenForms = null; + } + } + catch (Exception ex) + when (errorMask != null) + { + errorMask.ReportException(ex); + } + finally + { + errorMask?.PopIndex(); + } + } + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.INTV) ?? true)) + { + item.INTV = rhs.INTV; + } + if ((copyMask?.GetShouldTranslate((int)StarfieldModHeader_FieldIndex.INCC) ?? true)) + { + item.INCC = rhs.INCC; + } + } + + #endregion + + public StarfieldModHeader DeepCopy( + IStarfieldModHeaderGetter item, + StarfieldModHeader.TranslationMask? copyMask = null) + { + StarfieldModHeader ret = (StarfieldModHeader)((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)item).CommonInstance()!).GetNew(); + ((StarfieldModHeaderSetterTranslationCommon)((IStarfieldModHeaderGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: null, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + return ret; + } + + public StarfieldModHeader DeepCopy( + IStarfieldModHeaderGetter item, + out StarfieldModHeader.ErrorMask errorMask, + StarfieldModHeader.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + StarfieldModHeader ret = (StarfieldModHeader)((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)item).CommonInstance()!).GetNew(); + ((StarfieldModHeaderSetterTranslationCommon)((IStarfieldModHeaderGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + ret, + item, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + errorMask = StarfieldModHeader.ErrorMask.Factory(errorMaskBuilder); + return ret; + } + + public StarfieldModHeader DeepCopy( + IStarfieldModHeaderGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + StarfieldModHeader ret = (StarfieldModHeader)((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)item).CommonInstance()!).GetNew(); + ((StarfieldModHeaderSetterTranslationCommon)((IStarfieldModHeaderGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: true); + return ret; + } + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + public partial class StarfieldModHeader + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => StarfieldModHeader_Registration.Instance; + public static ILoquiRegistration StaticRegistration => StarfieldModHeader_Registration.Instance; + [DebuggerStepThrough] + protected object CommonInstance() => StarfieldModHeaderCommon.Instance; + [DebuggerStepThrough] + protected object CommonSetterInstance() + { + return StarfieldModHeaderSetterCommon.Instance; + } + [DebuggerStepThrough] + protected object CommonSetterTranslationInstance() => StarfieldModHeaderSetterTranslationCommon.Instance; + [DebuggerStepThrough] + object IStarfieldModHeaderGetter.CommonInstance() => this.CommonInstance(); + [DebuggerStepThrough] + object IStarfieldModHeaderGetter.CommonSetterInstance() => this.CommonSetterInstance(); + [DebuggerStepThrough] + object IStarfieldModHeaderGetter.CommonSetterTranslationInstance() => this.CommonSetterTranslationInstance(); + + #endregion + + } +} + +#region Modules +#region Binary Translation +namespace Mutagen.Bethesda.Starfield +{ + public partial class StarfieldModHeaderBinaryWriteTranslation : IBinaryWriteTranslator + { + public static readonly StarfieldModHeaderBinaryWriteTranslation Instance = new(); + + public static void WriteEmbedded( + IStarfieldModHeaderGetter item, + MutagenWriter writer) + { + EnumBinaryTranslation.Instance.Write( + writer, + item.Flags, + length: 4); + writer.Write(item.FormID); + writer.Write(item.Version); + writer.Write(item.FormVersion); + writer.Write(item.Version2); + } + + public static void WriteRecordTypes( + IStarfieldModHeaderGetter item, + MutagenWriter writer, + TypedWriteParams translationParams) + { + var StatsItem = item.Stats; + ((ModStatsBinaryWriteTranslation)((IBinaryItem)StatsItem).BinaryWriteTranslator).Write( + item: StatsItem, + writer: writer, + translationParams: translationParams); + ByteArrayBinaryTranslation.Instance.Write( + writer: writer, + item: item.TypeOffsets, + header: translationParams.ConvertToCustom(RecordTypes.OFST)); + ByteArrayBinaryTranslation.Instance.Write( + writer: writer, + item: item.Deleted, + header: translationParams.ConvertToCustom(RecordTypes.DELE)); + StringBinaryTranslation.Instance.WriteNullable( + writer: writer, + item: item.Author, + header: translationParams.ConvertToCustom(RecordTypes.CNAM), + binaryType: StringBinaryType.NullTerminate); + StringBinaryTranslation.Instance.WriteNullable( + writer: writer, + item: item.Description, + header: translationParams.ConvertToCustom(RecordTypes.SNAM), + binaryType: StringBinaryType.NullTerminate); + StarfieldModHeaderBinaryWriteTranslation.WriteBinaryMasterReferences( + writer: writer, + item: item); + Mutagen.Bethesda.Plugins.Binary.Translations.ListBinaryTranslation>.Instance.Write( + writer: writer, + items: item.OverriddenForms, + recordType: translationParams.ConvertToCustom(RecordTypes.ONAM), + overflowRecord: RecordTypes.XXXX, + transl: (MutagenWriter subWriter, IFormLinkGetter subItem, TypedWriteParams conv) => + { + FormLinkBinaryTranslation.Instance.Write( + writer: subWriter, + item: subItem); + }); + Int32BinaryTranslation.Instance.WriteNullable( + writer: writer, + item: item.INTV, + header: translationParams.ConvertToCustom(RecordTypes.INTV)); + Int32BinaryTranslation.Instance.WriteNullable( + writer: writer, + item: item.INCC, + header: translationParams.ConvertToCustom(RecordTypes.INCC)); + } + + public static partial void WriteBinaryMasterReferencesCustom( + MutagenWriter writer, + IStarfieldModHeaderGetter item); + + public static void WriteBinaryMasterReferences( + MutagenWriter writer, + IStarfieldModHeaderGetter item) + { + WriteBinaryMasterReferencesCustom( + writer: writer, + item: item); + } + + public void Write( + MutagenWriter writer, + IStarfieldModHeaderGetter item, + TypedWriteParams translationParams) + { + using (HeaderExport.Record( + writer: writer, + record: translationParams.ConvertToCustom(RecordTypes.TES4))) + { + WriteEmbedded( + item: item, + writer: writer); + WriteRecordTypes( + item: item, + writer: writer, + translationParams: translationParams); + } + } + + public void Write( + MutagenWriter writer, + object item, + TypedWriteParams translationParams = default) + { + Write( + item: (IStarfieldModHeaderGetter)item, + writer: writer, + translationParams: translationParams); + } + + } + + internal partial class StarfieldModHeaderBinaryCreateTranslation + { + public static readonly StarfieldModHeaderBinaryCreateTranslation Instance = new StarfieldModHeaderBinaryCreateTranslation(); + + public static void FillBinaryStructs( + IStarfieldModHeader item, + MutagenFrame frame) + { + item.Flags = EnumBinaryTranslation.Instance.Parse( + reader: frame, + length: 4); + item.FormID = frame.ReadUInt32(); + item.Version = frame.ReadInt32(); + item.FormVersion = frame.ReadUInt16(); + item.Version2 = frame.ReadUInt16(); + } + + public static ParseResult FillBinaryRecordTypes( + IStarfieldModHeader item, + MutagenFrame frame, + PreviousParse lastParsed, + Dictionary? recordParseCount, + RecordType nextRecordType, + int contentLength, + TypedParseParams translationParams = default) + { + nextRecordType = translationParams.ConvertToStandard(nextRecordType); + switch (nextRecordType.TypeInt) + { + case RecordTypeInts.HEDR: + { + item.Stats = Mutagen.Bethesda.Starfield.ModStats.CreateFromBinary(frame: frame); + return (int)StarfieldModHeader_FieldIndex.Stats; + } + case RecordTypeInts.OFST: + { + frame.Position += frame.MetaData.Constants.SubConstants.HeaderLength; + item.TypeOffsets = ByteArrayBinaryTranslation.Instance.Parse(reader: frame.SpawnWithLength(contentLength)); + return (int)StarfieldModHeader_FieldIndex.TypeOffsets; + } + case RecordTypeInts.DELE: + { + frame.Position += frame.MetaData.Constants.SubConstants.HeaderLength; + item.Deleted = ByteArrayBinaryTranslation.Instance.Parse(reader: frame.SpawnWithLength(contentLength)); + return (int)StarfieldModHeader_FieldIndex.Deleted; + } + case RecordTypeInts.CNAM: + { + frame.Position += frame.MetaData.Constants.SubConstants.HeaderLength; + item.Author = StringBinaryTranslation.Instance.Parse( + reader: frame.SpawnWithLength(contentLength), + stringBinaryType: StringBinaryType.NullTerminate); + return (int)StarfieldModHeader_FieldIndex.Author; + } + case RecordTypeInts.SNAM: + { + frame.Position += frame.MetaData.Constants.SubConstants.HeaderLength; + item.Description = StringBinaryTranslation.Instance.Parse( + reader: frame.SpawnWithLength(contentLength), + stringBinaryType: StringBinaryType.NullTerminate); + return (int)StarfieldModHeader_FieldIndex.Description; + } + case RecordTypeInts.MAST: + { + StarfieldModHeaderBinaryCreateTranslation.FillBinaryMasterReferencesCustom( + frame: frame.SpawnWithLength(frame.MetaData.Constants.SubConstants.HeaderLength + contentLength), + item: item); + return (int)StarfieldModHeader_FieldIndex.MasterReferences; + } + case RecordTypeInts.ONAM: + { + frame.Position += frame.MetaData.Constants.SubConstants.HeaderLength; + item.OverriddenForms = + Mutagen.Bethesda.Plugins.Binary.Translations.ListBinaryTranslation>.Instance.Parse( + reader: frame.SpawnWithLength(contentLength), + transl: FormLinkBinaryTranslation.Instance.Parse) + .CastExtendedList>(); + return (int)StarfieldModHeader_FieldIndex.OverriddenForms; + } + case RecordTypeInts.INTV: + { + frame.Position += frame.MetaData.Constants.SubConstants.HeaderLength; + item.INTV = frame.ReadInt32(); + return (int)StarfieldModHeader_FieldIndex.INTV; + } + case RecordTypeInts.INCC: + { + frame.Position += frame.MetaData.Constants.SubConstants.HeaderLength; + item.INCC = frame.ReadInt32(); + return (int)StarfieldModHeader_FieldIndex.INCC; + } + case RecordTypeInts.XXXX: + { + var overflowHeader = frame.ReadSubrecord(); + return ParseResult.OverrideLength(BinaryPrimitives.ReadUInt32LittleEndian(overflowHeader.Content)); + } + default: + frame.Position += contentLength + frame.MetaData.Constants.SubConstants.HeaderLength; + return default(int?); + } + } + + public static partial void FillBinaryMasterReferencesCustom( + MutagenFrame frame, + IStarfieldModHeader item); + + } + +} +namespace Mutagen.Bethesda.Starfield +{ + #region Binary Write Mixins + public static class StarfieldModHeaderBinaryTranslationMixIn + { + public static void WriteToBinary( + this IStarfieldModHeaderGetter item, + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((StarfieldModHeaderBinaryWriteTranslation)item.BinaryWriteTranslator).Write( + item: item, + writer: writer, + translationParams: translationParams); + } + + } + #endregion + + +} +namespace Mutagen.Bethesda.Starfield +{ + internal partial class StarfieldModHeaderBinaryOverlay : + PluginBinaryOverlay, + IStarfieldModHeaderGetter + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => StarfieldModHeader_Registration.Instance; + public static ILoquiRegistration StaticRegistration => StarfieldModHeader_Registration.Instance; + [DebuggerStepThrough] + protected object CommonInstance() => StarfieldModHeaderCommon.Instance; + [DebuggerStepThrough] + protected object CommonSetterTranslationInstance() => StarfieldModHeaderSetterTranslationCommon.Instance; + [DebuggerStepThrough] + object IStarfieldModHeaderGetter.CommonInstance() => this.CommonInstance(); + [DebuggerStepThrough] + object? IStarfieldModHeaderGetter.CommonSetterInstance() => null; + [DebuggerStepThrough] + object IStarfieldModHeaderGetter.CommonSetterTranslationInstance() => this.CommonSetterTranslationInstance(); + + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + public IEnumerable EnumerateFormLinks() => StarfieldModHeaderCommon.Instance.EnumerateFormLinks(this); + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected object BinaryWriteTranslator => StarfieldModHeaderBinaryWriteTranslation.Instance; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + object IBinaryItem.BinaryWriteTranslator => this.BinaryWriteTranslator; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((StarfieldModHeaderBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + + public StarfieldModHeader.HeaderFlag Flags => (StarfieldModHeader.HeaderFlag)BinaryPrimitives.ReadInt32LittleEndian(_structData.Span.Slice(0x0, 0x4)); + public UInt32 FormID => BinaryPrimitives.ReadUInt32LittleEndian(_structData.Slice(0x4, 0x4)); + public Int32 Version => BinaryPrimitives.ReadInt32LittleEndian(_structData.Slice(0x8, 0x4)); + public UInt16 FormVersion => BinaryPrimitives.ReadUInt16LittleEndian(_structData.Slice(0xC, 0x2)); + public UInt16 Version2 => BinaryPrimitives.ReadUInt16LittleEndian(_structData.Slice(0xE, 0x2)); + #region Stats + private RangeInt32? _StatsLocation; + private IModStatsGetter? _Stats => _StatsLocation.HasValue ? ModStatsBinaryOverlay.ModStatsFactory(_recordData.Slice(_StatsLocation!.Value.Min), _package) : default; + public IModStatsGetter Stats => _Stats ?? new ModStats(); + #endregion + #region TypeOffsets + private int? _TypeOffsetsLocation; + public ReadOnlyMemorySlice? TypeOffsets => _TypeOffsetsLocation.HasValue ? HeaderTranslation.ExtractSubrecordMemory(_recordData, _TypeOffsetsLocation.Value, _package.MetaData.Constants) : default(ReadOnlyMemorySlice?); + #endregion + #region Deleted + private int? _DeletedLocation; + public ReadOnlyMemorySlice? Deleted => _DeletedLocation.HasValue ? HeaderTranslation.ExtractSubrecordMemory(_recordData, _DeletedLocation.Value, _package.MetaData.Constants) : default(ReadOnlyMemorySlice?); + #endregion + #region Author + private int? _AuthorLocation; + public String? Author => _AuthorLocation.HasValue ? BinaryStringUtility.ProcessWholeToZString(HeaderTranslation.ExtractSubrecordMemory(_recordData, _AuthorLocation.Value, _package.MetaData.Constants), encoding: _package.MetaData.Encodings.NonTranslated) : default(string?); + #endregion + #region Description + private int? _DescriptionLocation; + public String? Description => _DescriptionLocation.HasValue ? BinaryStringUtility.ProcessWholeToZString(HeaderTranslation.ExtractSubrecordMemory(_recordData, _DescriptionLocation.Value, _package.MetaData.Constants), encoding: _package.MetaData.Encodings.NonTranslated) : default(string?); + #endregion + public IReadOnlyList MasterReferences { get; private set; } = Array.Empty(); + public IReadOnlyList>? OverriddenForms { get; private set; } + #region INTV + private int? _INTVLocation; + public Int32? INTV => _INTVLocation.HasValue ? BinaryPrimitives.ReadInt32LittleEndian(HeaderTranslation.ExtractSubrecordMemory(_recordData, _INTVLocation.Value, _package.MetaData.Constants)) : default(Int32?); + #endregion + #region INCC + private int? _INCCLocation; + public Int32? INCC => _INCCLocation.HasValue ? BinaryPrimitives.ReadInt32LittleEndian(HeaderTranslation.ExtractSubrecordMemory(_recordData, _INCCLocation.Value, _package.MetaData.Constants)) : default(Int32?); + #endregion + partial void CustomFactoryEnd( + OverlayStream stream, + int finalPos, + int offset); + + partial void CustomCtor(); + protected StarfieldModHeaderBinaryOverlay( + MemoryPair memoryPair, + BinaryOverlayFactoryPackage package) + : base( + memoryPair: memoryPair, + package: package) + { + this.CustomCtor(); + } + + public static IStarfieldModHeaderGetter StarfieldModHeaderFactory( + OverlayStream stream, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + stream = ExtractRecordMemory( + stream: stream, + meta: package.MetaData.Constants, + memoryPair: out var memoryPair, + offset: out var offset, + finalPos: out var finalPos); + var ret = new StarfieldModHeaderBinaryOverlay( + memoryPair: memoryPair, + package: package); + ret.CustomFactoryEnd( + stream: stream, + finalPos: finalPos, + offset: offset); + ret.FillSubrecordTypes( + stream: stream, + finalPos: finalPos, + offset: offset, + translationParams: translationParams, + fill: ret.FillRecordType); + return ret; + } + + public static IStarfieldModHeaderGetter StarfieldModHeaderFactory( + ReadOnlyMemorySlice slice, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + return StarfieldModHeaderFactory( + stream: new OverlayStream(slice, package), + package: package, + translationParams: translationParams); + } + + public ParseResult FillRecordType( + OverlayStream stream, + int finalPos, + int offset, + RecordType type, + PreviousParse lastParsed, + Dictionary? recordParseCount, + TypedParseParams translationParams = default) + { + type = translationParams.ConvertToStandard(type); + switch (type.TypeInt) + { + case RecordTypeInts.HEDR: + { + _StatsLocation = new RangeInt32((stream.Position - offset), finalPos - offset); + return (int)StarfieldModHeader_FieldIndex.Stats; + } + case RecordTypeInts.OFST: + { + _TypeOffsetsLocation = (stream.Position - offset); + return (int)StarfieldModHeader_FieldIndex.TypeOffsets; + } + case RecordTypeInts.DELE: + { + _DeletedLocation = (stream.Position - offset); + return (int)StarfieldModHeader_FieldIndex.Deleted; + } + case RecordTypeInts.CNAM: + { + _AuthorLocation = (stream.Position - offset); + return (int)StarfieldModHeader_FieldIndex.Author; + } + case RecordTypeInts.SNAM: + { + _DescriptionLocation = (stream.Position - offset); + return (int)StarfieldModHeader_FieldIndex.Description; + } + case RecordTypeInts.MAST: + { + this.MasterReferences = this.ParseRepeatedTypelessSubrecord( + stream: stream, + translationParams: translationParams, + trigger: MasterReference_Registration.TriggerSpecs, + factory: MasterReferenceBinaryOverlay.MasterReferenceFactory); + return (int)StarfieldModHeader_FieldIndex.MasterReferences; + } + case RecordTypeInts.ONAM: + { + var subMeta = stream.ReadSubrecordHeader(); + var subLen = finalPos - stream.Position; + this.OverriddenForms = BinaryOverlayList.FactoryByStartIndex>( + mem: stream.RemainingMemory.Slice(0, subLen), + package: _package, + itemLength: 4, + getter: (s, p) => new FormLink(FormKey.Factory(p.MetaData.MasterReferences!, BinaryPrimitives.ReadUInt32LittleEndian(s)))); + stream.Position += subLen; + return (int)StarfieldModHeader_FieldIndex.OverriddenForms; + } + case RecordTypeInts.INTV: + { + _INTVLocation = (stream.Position - offset); + return (int)StarfieldModHeader_FieldIndex.INTV; + } + case RecordTypeInts.INCC: + { + _INCCLocation = (stream.Position - offset); + return (int)StarfieldModHeader_FieldIndex.INCC; + } + case RecordTypeInts.XXXX: + { + var overflowHeader = stream.ReadSubrecord(); + return ParseResult.OverrideLength(BinaryPrimitives.ReadUInt32LittleEndian(overflowHeader.Content)); + } + default: + return default(int?); + } + } + #region To String + + public void Print( + StructuredStringBuilder sb, + string? name = null) + { + StarfieldModHeaderMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is not IStarfieldModHeaderGetter rhs) return false; + return ((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IStarfieldModHeaderGetter? obj) + { + return ((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + } + +} +#endregion + +#endregion + diff --git a/Mutagen.Bethesda.Starfield/Records/StarfieldMod_Generated.cs b/Mutagen.Bethesda.Starfield/Records/StarfieldMod_Generated.cs new file mode 100644 index 0000000000..ea8b95ff90 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/StarfieldMod_Generated.cs @@ -0,0 +1,2861 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Autogenerated by Loqui. Do not manually change. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ +#region Usings +using Loqui; +using Loqui.Interfaces; +using Loqui.Internal; +using Mutagen.Bethesda.Assets; +using Mutagen.Bethesda.Binary; +using Mutagen.Bethesda.Plugins; +using Mutagen.Bethesda.Plugins.Assets; +using Mutagen.Bethesda.Plugins.Binary; +using Mutagen.Bethesda.Plugins.Binary.Headers; +using Mutagen.Bethesda.Plugins.Binary.Overlay; +using Mutagen.Bethesda.Plugins.Binary.Parameters; +using Mutagen.Bethesda.Plugins.Binary.Streams; +using Mutagen.Bethesda.Plugins.Binary.Translations; +using Mutagen.Bethesda.Plugins.Cache; +using Mutagen.Bethesda.Plugins.Cache.Internals; +using Mutagen.Bethesda.Plugins.Exceptions; +using Mutagen.Bethesda.Plugins.Internals; +using Mutagen.Bethesda.Plugins.Masters; +using Mutagen.Bethesda.Plugins.Meta; +using Mutagen.Bethesda.Plugins.Records; +using Mutagen.Bethesda.Plugins.Records.Internals; +using Mutagen.Bethesda.Plugins.Records.Loqui; +using Mutagen.Bethesda.Plugins.Records.Mapping; +using Mutagen.Bethesda.Plugins.Utility; +using Mutagen.Bethesda.Starfield; +using Mutagen.Bethesda.Starfield.Internals; +using Mutagen.Bethesda.Strings; +using Mutagen.Bethesda.Strings.DI; +using Mutagen.Bethesda.Translations.Binary; +using Noggog; +using Noggog.StructuredStrings; +using Noggog.StructuredStrings.CSharp; +using RecordTypeInts = Mutagen.Bethesda.Starfield.Internals.RecordTypeInts; +using RecordTypes = Mutagen.Bethesda.Starfield.Internals.RecordTypes; +using System.Buffers.Binary; +using System.Collections.Concurrent; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.IO.Abstractions; +using System.Reactive.Disposables; +using System.Reactive.Linq; +using System.Threading.Tasks; +#endregion + +#nullable enable +namespace Mutagen.Bethesda.Starfield +{ + #region Class + public partial class StarfieldMod : + IEquatable, + ILoquiObjectSetter, + IStarfieldMod + { + #region Ctor + protected StarfieldMod() + { + _Npcs_Object = new StarfieldGroup(this); + _Races_Object = new StarfieldGroup(this); + _Weapons_Object = new StarfieldGroup(this); + CustomCtor(); + } + partial void CustomCtor(); + #endregion + + #region ModHeader + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly StarfieldModHeader _ModHeader_Object = new StarfieldModHeader(); + public StarfieldModHeader ModHeader => _ModHeader_Object; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IStarfieldModHeaderGetter IStarfieldModGetter.ModHeader => _ModHeader_Object; + #endregion + #region Npcs + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private StarfieldGroup _Npcs_Object; + public StarfieldGroup Npcs => _Npcs_Object; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IStarfieldGroupGetter IStarfieldModGetter.Npcs => _Npcs_Object; + #endregion + #region Races + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private StarfieldGroup _Races_Object; + public StarfieldGroup Races => _Races_Object; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IStarfieldGroupGetter IStarfieldModGetter.Races => _Races_Object; + #endregion + #region Weapons + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private StarfieldGroup _Weapons_Object; + public StarfieldGroup Weapons => _Weapons_Object; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IStarfieldGroupGetter IStarfieldModGetter.Weapons => _Weapons_Object; + #endregion + + #region To String + + public void Print( + StructuredStringBuilder sb, + string? name = null) + { + StarfieldModMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is not IStarfieldModGetter rhs) return false; + return ((StarfieldModCommon)((IStarfieldModGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IStarfieldModGetter? obj) + { + return ((StarfieldModCommon)((IStarfieldModGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((StarfieldModCommon)((IStarfieldModGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + #region Mask + public class Mask : + IEquatable>, + IMask + { + #region Ctors + public Mask(TItem initialValue) + { + this.ModHeader = new MaskItem?>(initialValue, new StarfieldModHeader.Mask(initialValue)); + this.Npcs = new MaskItem?>(initialValue, new StarfieldGroup.Mask(initialValue)); + this.Races = new MaskItem?>(initialValue, new StarfieldGroup.Mask(initialValue)); + this.Weapons = new MaskItem?>(initialValue, new StarfieldGroup.Mask(initialValue)); + } + + public Mask( + TItem ModHeader, + TItem Npcs, + TItem Races, + TItem Weapons) + { + this.ModHeader = new MaskItem?>(ModHeader, new StarfieldModHeader.Mask(ModHeader)); + this.Npcs = new MaskItem?>(Npcs, new StarfieldGroup.Mask(Npcs)); + this.Races = new MaskItem?>(Races, new StarfieldGroup.Mask(Races)); + this.Weapons = new MaskItem?>(Weapons, new StarfieldGroup.Mask(Weapons)); + } + + #pragma warning disable CS8618 + protected Mask() + { + } + #pragma warning restore CS8618 + + #endregion + + #region Members + public MaskItem?>? ModHeader { get; set; } + public MaskItem?>? Npcs { get; set; } + public MaskItem?>? Races { get; set; } + public MaskItem?>? Weapons { get; set; } + #endregion + + #region Equals + public override bool Equals(object? obj) + { + if (!(obj is Mask rhs)) return false; + return Equals(rhs); + } + + public bool Equals(Mask? rhs) + { + if (rhs == null) return false; + if (!object.Equals(this.ModHeader, rhs.ModHeader)) return false; + if (!object.Equals(this.Npcs, rhs.Npcs)) return false; + if (!object.Equals(this.Races, rhs.Races)) return false; + if (!object.Equals(this.Weapons, rhs.Weapons)) return false; + return true; + } + public override int GetHashCode() + { + var hash = new HashCode(); + hash.Add(this.ModHeader); + hash.Add(this.Npcs); + hash.Add(this.Races); + hash.Add(this.Weapons); + return hash.ToHashCode(); + } + + #endregion + + #region All + public bool All(Func eval) + { + if (ModHeader != null) + { + if (!eval(this.ModHeader.Overall)) return false; + if (this.ModHeader.Specific != null && !this.ModHeader.Specific.All(eval)) return false; + } + if (Npcs != null) + { + if (!eval(this.Npcs.Overall)) return false; + if (this.Npcs.Specific != null && !this.Npcs.Specific.All(eval)) return false; + } + if (Races != null) + { + if (!eval(this.Races.Overall)) return false; + if (this.Races.Specific != null && !this.Races.Specific.All(eval)) return false; + } + if (Weapons != null) + { + if (!eval(this.Weapons.Overall)) return false; + if (this.Weapons.Specific != null && !this.Weapons.Specific.All(eval)) return false; + } + return true; + } + #endregion + + #region Any + public bool Any(Func eval) + { + if (ModHeader != null) + { + if (eval(this.ModHeader.Overall)) return true; + if (this.ModHeader.Specific != null && this.ModHeader.Specific.Any(eval)) return true; + } + if (Npcs != null) + { + if (eval(this.Npcs.Overall)) return true; + if (this.Npcs.Specific != null && this.Npcs.Specific.Any(eval)) return true; + } + if (Races != null) + { + if (eval(this.Races.Overall)) return true; + if (this.Races.Specific != null && this.Races.Specific.Any(eval)) return true; + } + if (Weapons != null) + { + if (eval(this.Weapons.Overall)) return true; + if (this.Weapons.Specific != null && this.Weapons.Specific.Any(eval)) return true; + } + return false; + } + #endregion + + #region Translate + public Mask Translate(Func eval) + { + var ret = new StarfieldMod.Mask(); + this.Translate_InternalFill(ret, eval); + return ret; + } + + protected void Translate_InternalFill(Mask obj, Func eval) + { + obj.ModHeader = this.ModHeader == null ? null : new MaskItem?>(eval(this.ModHeader.Overall), this.ModHeader.Specific?.Translate(eval)); + obj.Npcs = this.Npcs == null ? null : new MaskItem?>(eval(this.Npcs.Overall), this.Npcs.Specific?.Translate(eval)); + obj.Races = this.Races == null ? null : new MaskItem?>(eval(this.Races.Overall), this.Races.Specific?.Translate(eval)); + obj.Weapons = this.Weapons == null ? null : new MaskItem?>(eval(this.Weapons.Overall), this.Weapons.Specific?.Translate(eval)); + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public string Print(StarfieldMod.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print(sb, printMask); + return sb.ToString(); + } + + public void Print(StructuredStringBuilder sb, StarfieldMod.Mask? printMask = null) + { + sb.AppendLine($"{nameof(StarfieldMod.Mask)} =>"); + using (sb.Brace()) + { + if (printMask?.ModHeader?.Overall ?? true) + { + ModHeader?.Print(sb); + } + if (printMask?.Npcs?.Overall ?? true) + { + Npcs?.Print(sb); + } + if (printMask?.Races?.Overall ?? true) + { + Races?.Print(sb); + } + if (printMask?.Weapons?.Overall ?? true) + { + Weapons?.Print(sb); + } + } + } + #endregion + + } + + public class ErrorMask : + IErrorMask, + IErrorMask + { + #region Members + public Exception? Overall { get; set; } + private List? _warnings; + public List Warnings + { + get + { + if (_warnings == null) + { + _warnings = new List(); + } + return _warnings; + } + } + public MaskItem? ModHeader; + public MaskItem?>? Npcs; + public MaskItem?>? Races; + public MaskItem?>? Weapons; + #endregion + + #region IErrorMask + public object? GetNthMask(int index) + { + StarfieldMod_FieldIndex enu = (StarfieldMod_FieldIndex)index; + switch (enu) + { + case StarfieldMod_FieldIndex.ModHeader: + return ModHeader; + case StarfieldMod_FieldIndex.Npcs: + return Npcs; + case StarfieldMod_FieldIndex.Races: + return Races; + case StarfieldMod_FieldIndex.Weapons: + return Weapons; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public void SetNthException(int index, Exception ex) + { + StarfieldMod_FieldIndex enu = (StarfieldMod_FieldIndex)index; + switch (enu) + { + case StarfieldMod_FieldIndex.ModHeader: + this.ModHeader = new MaskItem(ex, null); + break; + case StarfieldMod_FieldIndex.Npcs: + this.Npcs = new MaskItem?>(ex, null); + break; + case StarfieldMod_FieldIndex.Races: + this.Races = new MaskItem?>(ex, null); + break; + case StarfieldMod_FieldIndex.Weapons: + this.Weapons = new MaskItem?>(ex, null); + break; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public void SetNthMask(int index, object obj) + { + StarfieldMod_FieldIndex enu = (StarfieldMod_FieldIndex)index; + switch (enu) + { + case StarfieldMod_FieldIndex.ModHeader: + this.ModHeader = (MaskItem?)obj; + break; + case StarfieldMod_FieldIndex.Npcs: + this.Npcs = (MaskItem?>?)obj; + break; + case StarfieldMod_FieldIndex.Races: + this.Races = (MaskItem?>?)obj; + break; + case StarfieldMod_FieldIndex.Weapons: + this.Weapons = (MaskItem?>?)obj; + break; + default: + throw new ArgumentException($"Index is out of range: {index}"); + } + } + + public bool IsInError() + { + if (Overall != null) return true; + if (ModHeader != null) return true; + if (Npcs != null) return true; + if (Races != null) return true; + if (Weapons != null) return true; + return false; + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public void Print(StructuredStringBuilder sb, string? name = null) + { + sb.AppendLine($"{(name ?? "ErrorMask")} =>"); + using (sb.Brace()) + { + if (this.Overall != null) + { + sb.AppendLine("Overall =>"); + using (sb.Brace()) + { + sb.AppendLine($"{this.Overall}"); + } + } + PrintFillInternal(sb); + } + } + protected void PrintFillInternal(StructuredStringBuilder sb) + { + ModHeader?.Print(sb); + Npcs?.Print(sb); + Races?.Print(sb); + Weapons?.Print(sb); + } + #endregion + + #region Combine + public ErrorMask Combine(ErrorMask? rhs) + { + if (rhs == null) return this; + var ret = new ErrorMask(); + ret.ModHeader = this.ModHeader.Combine(rhs.ModHeader, (l, r) => l.Combine(r)); + ret.Npcs = this.Npcs.Combine(rhs.Npcs, (l, r) => l.Combine(r)); + ret.Races = this.Races.Combine(rhs.Races, (l, r) => l.Combine(r)); + ret.Weapons = this.Weapons.Combine(rhs.Weapons, (l, r) => l.Combine(r)); + return ret; + } + public static ErrorMask? Combine(ErrorMask? lhs, ErrorMask? rhs) + { + if (lhs != null && rhs != null) return lhs.Combine(rhs); + return lhs ?? rhs; + } + #endregion + + #region Factory + public static ErrorMask Factory(ErrorMaskBuilder errorMask) + { + return new ErrorMask(); + } + #endregion + + } + public class TranslationMask : ITranslationMask + { + #region Members + private TranslationCrystal? _crystal; + public readonly bool DefaultOn; + public bool OnOverall; + public StarfieldModHeader.TranslationMask? ModHeader; + public StarfieldGroup.TranslationMask? Npcs; + public StarfieldGroup.TranslationMask? Races; + public StarfieldGroup.TranslationMask? Weapons; + #endregion + + #region Ctors + public TranslationMask( + bool defaultOn, + bool onOverall = true) + { + this.DefaultOn = defaultOn; + this.OnOverall = onOverall; + } + + #endregion + + public TranslationCrystal GetCrystal() + { + if (_crystal != null) return _crystal; + var ret = new List<(bool On, TranslationCrystal? SubCrystal)>(); + GetCrystal(ret); + _crystal = new TranslationCrystal(ret.ToArray()); + return _crystal; + } + + protected void GetCrystal(List<(bool On, TranslationCrystal? SubCrystal)> ret) + { + ret.Add((ModHeader != null ? ModHeader.OnOverall : DefaultOn, ModHeader?.GetCrystal())); + ret.Add((Npcs != null ? Npcs.OnOverall : DefaultOn, Npcs?.GetCrystal())); + ret.Add((Races != null ? Races.OnOverall : DefaultOn, Races?.GetCrystal())); + ret.Add((Weapons != null ? Weapons.OnOverall : DefaultOn, Weapons?.GetCrystal())); + } + + public static implicit operator TranslationMask(bool defaultOn) + { + return new TranslationMask(defaultOn: defaultOn, onOverall: defaultOn); + } + + } + #endregion + + #region Mutagen + public override GameRelease GameRelease => GameRelease.Starfield; + IGroupGetter? IModGetter.TryGetTopLevelGroup() => this.TryGetTopLevelGroup(); + IGroupGetter? IModGetter.TryGetTopLevelGroup(Type type) => this.TryGetTopLevelGroup(type); + IGroup? IMod.TryGetTopLevelGroup() => this.TryGetTopLevelGroup(); + IGroup? IMod.TryGetTopLevelGroup(Type type) => this.TryGetTopLevelGroup(type); + void IModGetter.WriteToBinary(FilePath path, BinaryWriteParameters? param, IFileSystem? fileSystem) => this.WriteToBinary(path, importMask: null, param: param, fileSystem: fileSystem); + void IModGetter.WriteToBinaryParallel(FilePath path, BinaryWriteParameters? param, IFileSystem? fileSystem, ParallelWriteParameters? parallelWriteParams) => this.WriteToBinaryParallel(path, param, fileSystem: fileSystem, parallelParam: parallelWriteParams); + void IModGetter.WriteToBinary(Stream stream, BinaryWriteParameters? param) => this.WriteToBinary(stream, importMask: null, param: param); + void IModGetter.WriteToBinaryParallel(Stream stream, BinaryWriteParameters? param, ParallelWriteParameters? parallelWriteParams) => this.WriteToBinaryParallel(stream, param, parallelParam: parallelWriteParams); + IMask IEqualsMask.GetEqualsMask(object rhs, EqualsMaskHelper.Include include = EqualsMaskHelper.Include.OnlyFailures) => StarfieldModMixIn.GetEqualsMask(this, (IStarfieldModGetter)rhs, include); + public override bool CanUseLocalization => true; + public override bool UsingLocalization + { + get => this.ModHeader.Flags.HasFlag(StarfieldModHeader.HeaderFlag.Localized); + set => this.ModHeader.Flags = this.ModHeader.Flags.SetFlag(StarfieldModHeader.HeaderFlag.Localized, value); + } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IList IMod.MasterReferences => this.ModHeader.MasterReferences; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IReadOnlyList IModGetter.MasterReferences => this.ModHeader.MasterReferences; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + uint IMod.NextFormID + { + get => this.ModHeader.Stats.NextFormID; + set => this.ModHeader.Stats.NextFormID = value; + } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + uint IModGetter.NextFormID => this.ModHeader.Stats.NextFormID; + public StarfieldMod(ModKey modKey) + : base(modKey) + { + this.ModHeader.Stats.NextFormID = GetDefaultInitialNextFormID(); + _Npcs_Object = new StarfieldGroup(this); + _Races_Object = new StarfieldGroup(this); + _Weapons_Object = new StarfieldGroup(this); + CustomCtor(); + } + public void AddRecords( + StarfieldMod rhsMod, + GroupMask? mask = null) + { + if (mask?.Npcs ?? true) + { + this.Npcs.RecordCache.Set(rhsMod.Npcs.RecordCache.Items); + } + if (mask?.Races ?? true) + { + this.Races.RecordCache.Set(rhsMod.Races.RecordCache.Items); + } + if (mask?.Weapons ?? true) + { + this.Weapons.RecordCache.Set(rhsMod.Weapons.RecordCache.Items); + } + } + + public override void SyncRecordCount() + { + this.ModHeader.Stats.NumRecords = GetRecordCount(); + } + + public uint GetRecordCount() + { + uint count = (uint)this.EnumerateMajorRecords().Count(); + count += Npcs.RecordCache.Count > 0 ? 1 : default(uint); + count += Races.RecordCache.Count > 0 ? 1 : default(uint); + count += Weapons.RecordCache.Count > 0 ? 1 : default(uint); + GetCustomRecordCount((customCount) => count += customCount); + return count; + } + + partial void GetCustomRecordCount(Action setter); + + public IEnumerable EnumerateFormLinks() => StarfieldModCommon.Instance.EnumerateFormLinks(this); + public void RemapLinks(IReadOnlyDictionary mapping) => StarfieldModSetterCommon.Instance.RemapLinks(this, mapping); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords() => this.EnumerateMajorRecords(); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords(bool throwIfUnknown) => this.EnumerateMajorRecords(throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords(Type type, bool throwIfUnknown) => this.EnumerateMajorRecords(type: type, throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable IMajorRecordEnumerable.EnumerateMajorRecords() => this.EnumerateMajorRecords(); + [DebuggerStepThrough] + IEnumerable IMajorRecordEnumerable.EnumerateMajorRecords(bool throwIfUnknown) => this.EnumerateMajorRecords(throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable IMajorRecordEnumerable.EnumerateMajorRecords(Type? type, bool throwIfUnknown) => this.EnumerateMajorRecords(type: type, throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(FormKey formKey) => this.Remove(formKey); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(HashSet formKeys) => this.Remove(formKeys); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(IEnumerable formKeys) => this.Remove(formKeys); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(FormKey formKey, Type type, bool throwIfUnknown) => this.Remove(formKey, type, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(HashSet formKeys, Type type, bool throwIfUnknown) => this.Remove(formKeys, type, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(IEnumerable formKeys, Type type, bool throwIfUnknown) => this.Remove(formKeys, type, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(FormKey formKey, bool throwIfUnknown) => this.Remove(formKey, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(HashSet formKeys, bool throwIfUnknown) => this.Remove(formKeys, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(IEnumerable formKeys, bool throwIfUnknown) => this.Remove(formKeys, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(TMajor record, bool throwIfUnknown) => this.Remove(record, throwIfUnknown); + [DebuggerStepThrough] + void IMajorRecordEnumerable.Remove(IEnumerable records, bool throwIfUnknown) => this.Remove(records, throwIfUnknown); + [DebuggerStepThrough] + IEnumerable> IMajorRecordContextEnumerable.EnumerateMajorRecordContexts(ILinkCache linkCache, bool throwIfUnknown) => this.EnumerateMajorRecordContexts(linkCache, throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable> IMajorRecordContextEnumerable.EnumerateMajorRecordContexts(ILinkCache linkCache, Type type, bool throwIfUnknown) => this.EnumerateMajorRecordContexts(linkCache, type: type, throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable> IMajorRecordSimpleContextEnumerable.EnumerateMajorRecordSimpleContexts() => this.EnumerateMajorRecordContexts(); + [DebuggerStepThrough] + IEnumerable> IMajorRecordSimpleContextEnumerable.EnumerateMajorRecordSimpleContexts(bool throwIfUnknown) => this.EnumerateMajorRecordContexts(linkCache: null!, typeof(TMajor), throwIfUnknown: throwIfUnknown).Select(x => x.AsType()); + [DebuggerStepThrough] + IEnumerable> IMajorRecordSimpleContextEnumerable.EnumerateMajorRecordSimpleContexts(Type type, bool throwIfUnknown) => this.EnumerateMajorRecordContexts(linkCache: null!, type: type, throwIfUnknown: throwIfUnknown); + public IEnumerable EnumerateAssetLinks(AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) => StarfieldModCommon.Instance.EnumerateAssetLinks(this, queryCategories, linkCache, assetType); + public IEnumerable EnumerateListedAssetLinks() => StarfieldModSetterCommon.Instance.EnumerateListedAssetLinks(this); + public void RemapAssetLinks(IReadOnlyDictionary mapping, AssetLinkQuery queryCategories, IAssetLinkCache? linkCache) => StarfieldModSetterCommon.Instance.RemapAssetLinks(this, mapping, linkCache, queryCategories); + public void RemapListedAssetLinks(IReadOnlyDictionary mapping) => StarfieldModSetterCommon.Instance.RemapAssetLinks(this, mapping, null, AssetLinkQuery.Listed); + #endregion + + #region Binary Translation + #region Binary Create + public static StarfieldMod CreateFromBinary( + ModPath path, + GroupMask? importMask = null, + StringsReadParameters? stringsParam = null, + bool parallel = true, + IFileSystem? fileSystem = null) + { + try + { + using (var reader = new MutagenBinaryReadStream(path, GameRelease.Starfield, fileSystem: fileSystem)) + { + var frame = new MutagenFrame(reader); + frame.MetaData.RecordInfoCache = new RecordTypeInfoCacheReader(() => new MutagenBinaryReadStream(path, GameRelease.Starfield, fileSystem: fileSystem)); + frame.MetaData.Parallel = parallel; + frame.MetaData.ModKey = path.ModKey; + frame.MetaData.Absorb(stringsParam); + if (reader.Remaining < 12) + { + throw new ArgumentException("File stream was too short to parse flags"); + } + var flags = reader.GetInt32(offset: 8); + if (Enums.HasFlag(flags, (int)ModHeaderCommonFlag.Localized)) + { + frame.MetaData.StringsLookup = StringsFolderLookupOverlay.TypicalFactory(GameRelease.Starfield, path.ModKey, Path.GetDirectoryName(path.Path)!, stringsParam); + } + return CreateFromBinary( + importMask: importMask, + frame: frame); + } + } + catch (Exception ex) + { + throw RecordException.Enrich(ex, path.ModKey); + } + } + + public static StarfieldMod CreateFromBinary( + ModPath path, + ErrorMaskBuilder? errorMask, + GroupMask? importMask = null, + StringsReadParameters? stringsParam = null, + bool parallel = true, + IFileSystem? fileSystem = null) + { + try + { + using (var reader = new MutagenBinaryReadStream(path, GameRelease.Starfield, fileSystem: fileSystem)) + { + var frame = new MutagenFrame(reader); + frame.MetaData.RecordInfoCache = new RecordTypeInfoCacheReader(() => new MutagenBinaryReadStream(path, GameRelease.Starfield, fileSystem: fileSystem)); + frame.MetaData.Parallel = parallel; + frame.MetaData.ModKey = path.ModKey; + frame.MetaData.Absorb(stringsParam); + if (reader.Remaining < 12) + { + throw new ArgumentException("File stream was too short to parse flags"); + } + var flags = reader.GetInt32(offset: 8); + if (Enums.HasFlag(flags, (int)ModHeaderCommonFlag.Localized)) + { + frame.MetaData.StringsLookup = StringsFolderLookupOverlay.TypicalFactory(GameRelease.Starfield, path.ModKey, Path.GetDirectoryName(path.Path)!, stringsParam); + } + return CreateFromBinary( + importMask: importMask, + frame: frame); + } + } + catch (Exception ex) + { + throw RecordException.Enrich(ex, path.ModKey); + } + } + + public static StarfieldMod CreateFromBinary( + Stream stream, + ModKey modKey, + RecordTypeInfoCacheReader infoCache, + GroupMask? importMask = null, + bool parallel = true) + { + try + { + using (var reader = new MutagenBinaryReadStream(stream, modKey, GameRelease.Starfield)) + { + var frame = new MutagenFrame(reader); + frame.MetaData.RecordInfoCache = infoCache; + frame.MetaData.Parallel = parallel; + frame.MetaData.ModKey = modKey; + return CreateFromBinary( + importMask: importMask, + frame: frame); + } + } + catch (Exception ex) + { + throw RecordException.Enrich(ex, modKey); + } + } + + public static StarfieldMod CreateFromBinary( + Stream stream, + ModKey modKey, + RecordTypeInfoCacheReader infoCache, + ErrorMaskBuilder? errorMask, + GroupMask? importMask = null, + bool parallel = true) + { + try + { + using (var reader = new MutagenBinaryReadStream(stream, modKey, GameRelease.Starfield)) + { + var frame = new MutagenFrame(reader); + frame.MetaData.RecordInfoCache = infoCache; + frame.MetaData.Parallel = parallel; + frame.MetaData.ModKey = modKey; + return CreateFromBinary( + importMask: importMask, + frame: frame); + } + } + catch (Exception ex) + { + throw RecordException.Enrich(ex, modKey); + } + } + + #endregion + + public static IStarfieldModDisposableGetter CreateFromBinaryOverlay( + ModPath path, + StringsReadParameters? stringsParam = null, + IFileSystem? fileSystem = null) + { + return StarfieldModBinaryOverlay.StarfieldModFactory( + path: path, + stringsParam: stringsParam, + fileSystem: fileSystem); + } + + public static IStarfieldModDisposableGetter CreateFromBinaryOverlay( + Stream stream, + ModKey modKey) + { + return StarfieldModBinaryOverlay.StarfieldModFactory( + stream: new MutagenBinaryReadStream(stream, modKey, GameRelease.Starfield), + modKey: modKey, + shouldDispose: false); + } + + public static StarfieldMod CreateFromBinary( + MutagenFrame frame, + GroupMask? importMask = null) + { + try + { + var ret = new StarfieldMod(modKey: frame.MetaData.ModKey); + ((StarfieldModSetterCommon)((IStarfieldModGetter)ret).CommonSetterInstance()!).CopyInFromBinary( + item: ret, + frame: frame, + importMask: importMask); + return ret; + } + catch (Exception ex) + { + throw RecordException.Enrich(ex, frame.MetaData.ModKey); + } + } + + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + void IClearable.Clear() + { + ((StarfieldModSetterCommon)((IStarfieldModGetter)this).CommonSetterInstance()!).Clear(this); + } + + internal static StarfieldMod GetNew() + { + return new StarfieldMod(); + } + + } + #endregion + + #region Interface + public partial interface IStarfieldMod : + IAssetLinkContainer, + IContextMod, + IFormLinkContainer, + ILoquiObjectSetter, + IMajorRecordEnumerable, + IMod, + IStarfieldModGetter + { + new StarfieldModHeader ModHeader { get; } + new StarfieldGroup Npcs { get; } + new StarfieldGroup Races { get; } + new StarfieldGroup Weapons { get; } + } + + public partial interface IStarfieldModGetter : + ILoquiObject, + IAssetLinkContainerGetter, + IContextGetterMod, + IFormLinkContainerGetter, + ILoquiObject, + IMajorRecordContextEnumerable, + IMajorRecordGetterEnumerable, + IModGetter + { + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object CommonInstance(); + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object? CommonSetterInstance(); + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + object CommonSetterTranslationInstance(); + static ILoquiRegistration StaticRegistration => StarfieldMod_Registration.Instance; + IStarfieldModHeaderGetter ModHeader { get; } + IStarfieldGroupGetter Npcs { get; } + IStarfieldGroupGetter Races { get; } + IStarfieldGroupGetter Weapons { get; } + + } + + #endregion + + #region Common MixIn + public static partial class StarfieldModMixIn + { + public static void Clear(this IStarfieldMod item) + { + ((StarfieldModSetterCommon)((IStarfieldModGetter)item).CommonSetterInstance()!).Clear(item: item); + } + + public static StarfieldMod.Mask GetEqualsMask( + this IStarfieldModGetter item, + IStarfieldModGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + return ((StarfieldModCommon)((IStarfieldModGetter)item).CommonInstance()!).GetEqualsMask( + item: item, + rhs: rhs, + include: include); + } + + public static string Print( + this IStarfieldModGetter item, + string? name = null, + StarfieldMod.Mask? printMask = null) + { + return ((StarfieldModCommon)((IStarfieldModGetter)item).CommonInstance()!).Print( + item: item, + name: name, + printMask: printMask); + } + + public static void Print( + this IStarfieldModGetter item, + StructuredStringBuilder sb, + string? name = null, + StarfieldMod.Mask? printMask = null) + { + ((StarfieldModCommon)((IStarfieldModGetter)item).CommonInstance()!).Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + } + + public static bool Equals( + this IStarfieldModGetter item, + IStarfieldModGetter rhs, + StarfieldMod.TranslationMask? equalsMask = null) + { + return ((StarfieldModCommon)((IStarfieldModGetter)item).CommonInstance()!).Equals( + lhs: item, + rhs: rhs, + equalsMask: equalsMask?.GetCrystal()); + } + + public static void DeepCopyIn( + this IStarfieldMod lhs, + IStarfieldModGetter rhs) + { + ((StarfieldModSetterTranslationCommon)((IStarfieldModGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: default, + copyMask: default, + deepCopy: false); + } + + public static void DeepCopyIn( + this IStarfieldMod lhs, + IStarfieldModGetter rhs, + StarfieldMod.TranslationMask? copyMask = null) + { + ((StarfieldModSetterTranslationCommon)((IStarfieldModGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: default, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + } + + public static void DeepCopyIn( + this IStarfieldMod lhs, + IStarfieldModGetter rhs, + out StarfieldMod.ErrorMask errorMask, + StarfieldMod.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + ((StarfieldModSetterTranslationCommon)((IStarfieldModGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + errorMask = StarfieldMod.ErrorMask.Factory(errorMaskBuilder); + } + + public static void DeepCopyIn( + this IStarfieldMod lhs, + IStarfieldModGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask) + { + ((StarfieldModSetterTranslationCommon)((IStarfieldModGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: false); + } + + public static StarfieldMod DeepCopy( + this IStarfieldModGetter item, + StarfieldMod.TranslationMask? copyMask = null) + { + return ((StarfieldModSetterTranslationCommon)((IStarfieldModGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask); + } + + public static StarfieldMod DeepCopy( + this IStarfieldModGetter item, + out StarfieldMod.ErrorMask errorMask, + StarfieldMod.TranslationMask? copyMask = null) + { + return ((StarfieldModSetterTranslationCommon)((IStarfieldModGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: out errorMask); + } + + public static StarfieldMod DeepCopy( + this IStarfieldModGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + return ((StarfieldModSetterTranslationCommon)((IStarfieldModGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: errorMask); + } + + #region Mutagen + public static IGroupGetter? TryGetTopLevelGroup(this IStarfieldModGetter obj) + where T : IMajorRecordGetter + { + return (IGroupGetter?)((StarfieldModCommon)((IStarfieldModGetter)obj).CommonInstance()!).GetGroup( + obj: obj, + type: typeof(T)); + } + + public static IGroupGetter? TryGetTopLevelGroup( + this IStarfieldModGetter obj, + Type type) + { + return (IGroupGetter?)((StarfieldModCommon)((IStarfieldModGetter)obj).CommonInstance()!).GetGroup( + obj: obj, + type: type); + } + + public static IGroup? TryGetTopLevelGroup(this IStarfieldMod obj) + where T : IMajorRecord + { + return (IGroup?)((StarfieldModCommon)((IStarfieldModGetter)obj).CommonInstance()!).GetGroup( + obj: obj, + type: typeof(T)); + } + + public static IGroup? TryGetTopLevelGroup( + this IStarfieldMod obj, + Type type) + { + return (IGroup?)((StarfieldModCommon)((IStarfieldModGetter)obj).CommonInstance()!).GetGroup( + obj: obj, + type: type); + } + + public static void WriteToBinaryParallel( + this IStarfieldModGetter item, + Stream stream, + BinaryWriteParameters? param = null, + ParallelWriteParameters? parallelParam = null) + { + StarfieldModCommon.WriteParallel( + item: item, + stream: stream, + parallelParam: parallelParam ?? ParallelWriteParameters.Default, + param: param ?? BinaryWriteParameters.Default, + modKey: item.ModKey); + } + + public static void WriteToBinaryParallel( + this IStarfieldModGetter item, + string path, + BinaryWriteParameters? param = null, + ParallelWriteParameters? parallelParam = null, + IFileSystem? fileSystem = null) + { + param ??= BinaryWriteParameters.Default; + parallelParam ??= ParallelWriteParameters.Default; + var modKey = param.RunMasterMatch( + mod: item, + path: path); + param.StringsWriter ??= Enums.HasFlag((int)item.ModHeader.Flags, (int)ModHeaderCommonFlag.Localized) ? new StringsWriter(GameRelease.Starfield, modKey, Path.Combine(Path.GetDirectoryName(path)!, "Strings"), MutagenEncodingProvider.Instance) : null; + bool disposeStrings = param.StringsWriter != null; + using (var stream = fileSystem.GetOrDefault().FileStream.Create(path, FileMode.Create, FileAccess.Write)) + { + StarfieldModCommon.WriteParallel( + item: item, + stream: stream, + parallelParam: parallelParam, + param: param, + modKey: modKey); + } + if (disposeStrings) + { + param.StringsWriter?.Dispose(); + } + } + + [DebuggerStepThrough] + public static IEnumerable EnumerateMajorRecords(this IStarfieldModGetter obj) + { + return ((StarfieldModCommon)((IStarfieldModGetter)obj).CommonInstance()!).EnumerateMajorRecords(obj: obj).Catch(e => throw RecordException.Enrich(e, obj.ModKey)); + } + + [DebuggerStepThrough] + public static IEnumerable EnumerateMajorRecords( + this IStarfieldModGetter obj, + bool throwIfUnknown = true) + where TMajor : class, IMajorRecordQueryableGetter + { + return ((StarfieldModCommon)((IStarfieldModGetter)obj).CommonInstance()!).EnumerateMajorRecords( + obj: obj, + type: typeof(TMajor), + throwIfUnknown: throwIfUnknown) + .Select(m => (TMajor)m) + .Catch(e => throw RecordException.Enrich(e, obj.ModKey)); + } + + [DebuggerStepThrough] + public static IEnumerable EnumerateMajorRecords( + this IStarfieldModGetter obj, + Type type, + bool throwIfUnknown = true) + { + return ((StarfieldModCommon)((IStarfieldModGetter)obj).CommonInstance()!).EnumerateMajorRecords( + obj: obj, + type: type, + throwIfUnknown: throwIfUnknown) + .Select(m => (IMajorRecordGetter)m) + .Catch(e => throw RecordException.Enrich(e, obj.ModKey)); + } + + [DebuggerStepThrough] + public static IEnumerable EnumerateMajorRecords(this IStarfieldMod obj) + { + return ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).EnumerateMajorRecords(obj: obj).Catch(e => throw RecordException.Enrich(e, obj.ModKey)); + } + + [DebuggerStepThrough] + public static IEnumerable EnumerateMajorRecords(this IStarfieldMod obj) + where TMajor : class, IMajorRecordQueryable + { + return ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).EnumerateMajorRecords( + obj: obj, + type: typeof(TMajor), + throwIfUnknown: true) + .Select(m => (TMajor)m) + .Catch(e => throw RecordException.Enrich(e, obj.ModKey)); + } + + [DebuggerStepThrough] + public static IEnumerable EnumerateMajorRecords( + this IStarfieldMod obj, + Type? type, + bool throwIfUnknown = true) + { + return ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).EnumeratePotentiallyTypedMajorRecords( + obj: obj, + type: type, + throwIfUnknown: throwIfUnknown) + .Select(m => (IMajorRecord)m) + .Catch(e => throw RecordException.Enrich(e, obj.ModKey)); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldMod obj, + FormKey key) + { + var keys = new HashSet(); + keys.Add(key); + ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).Remove( + obj: obj, + keys: keys); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldMod obj, + IEnumerable keys) + { + ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).Remove( + obj: obj, + keys: keys.ToHashSet()); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldMod obj, + HashSet keys) + { + ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).Remove( + obj: obj, + keys: keys); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldMod obj, + FormKey key, + Type type, + bool throwIfUnknown = true) + { + var keys = new HashSet(); + keys.Add(key); + ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).Remove( + obj: obj, + keys: keys, + type: type, + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldMod obj, + IEnumerable keys, + Type type, + bool throwIfUnknown = true) + { + ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).Remove( + obj: obj, + keys: keys.ToHashSet(), + type: type, + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldMod obj, + HashSet keys, + Type type, + bool throwIfUnknown = true) + { + ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).Remove( + obj: obj, + keys: keys, + type: type, + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldMod obj, + TMajor record, + bool throwIfUnknown = true) + where TMajor : IMajorRecordGetter + { + var keys = new HashSet(); + keys.Add(record.FormKey); + ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).Remove( + obj: obj, + keys: keys, + type: typeof(TMajor), + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldMod obj, + IEnumerable records, + bool throwIfUnknown = true) + where TMajor : IMajorRecordGetter + { + ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).Remove( + obj: obj, + keys: records.Select(m => m.FormKey).ToHashSet(), + type: typeof(TMajor), + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldMod obj, + FormKey key, + bool throwIfUnknown = true) + where TMajor : IMajorRecordGetter + { + var keys = new HashSet(); + keys.Add(key); + ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).Remove( + obj: obj, + keys: keys, + type: typeof(TMajor), + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldMod obj, + IEnumerable keys, + bool throwIfUnknown = true) + where TMajor : IMajorRecordGetter + { + ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).Remove( + obj: obj, + keys: keys.ToHashSet(), + type: typeof(TMajor), + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static void Remove( + this IStarfieldMod obj, + HashSet keys, + bool throwIfUnknown = true) + where TMajor : IMajorRecordGetter + { + ((StarfieldModSetterCommon)((IStarfieldModGetter)obj).CommonSetterInstance()!).Remove( + obj: obj, + keys: keys, + type: typeof(TMajor), + throwIfUnknown: throwIfUnknown); + } + + [DebuggerStepThrough] + public static IEnumerable> EnumerateMajorRecordContexts( + this IStarfieldModGetter obj, + ILinkCache linkCache, + bool throwIfUnknown = true) + where TSetter : class, IMajorRecordQueryable, TGetter + where TGetter : class, IMajorRecordQueryableGetter + { + return ((StarfieldModCommon)((IStarfieldModGetter)obj).CommonInstance()!).EnumerateMajorRecordContexts( + obj: obj, + linkCache: linkCache, + type: typeof(TGetter), + throwIfUnknown: throwIfUnknown) + .Select(m => m.AsType()) + .Catch(e => throw RecordException.Enrich(e, obj.ModKey)); + } + + [DebuggerStepThrough] + public static IEnumerable> EnumerateMajorRecordContexts(this IStarfieldModGetter obj) + { + return ((StarfieldModCommon)((IStarfieldModGetter)obj).CommonInstance()!).EnumerateMajorRecordContexts( + obj: obj, + linkCache: null!); + } + + [DebuggerStepThrough] + public static IEnumerable> EnumerateMajorRecordContexts( + this IStarfieldModGetter obj, + ILinkCache linkCache, + Type type, + bool throwIfUnknown = true) + { + return ((StarfieldModCommon)((IStarfieldModGetter)obj).CommonInstance()!).EnumerateMajorRecordContexts( + obj: obj, + linkCache: linkCache, + type: type, + throwIfUnknown: throwIfUnknown); + } + + #endregion + + #region Binary Translation + public static void CopyInFromBinary( + this IStarfieldMod item, + MutagenFrame frame, + GroupMask? importMask = null) + { + ((StarfieldModSetterCommon)((IStarfieldModGetter)item).CommonSetterInstance()!).CopyInFromBinary( + item: item, + frame: frame, + importMask: importMask); + } + + public static void CopyInFromBinary( + this IStarfieldMod item, + ModPath path, + GroupMask? importMask = null, + StringsReadParameters? stringsParam = null, + bool parallel = true, + IFileSystem? fileSystem = null) + { + try + { + using (var reader = new MutagenBinaryReadStream(path, GameRelease.Starfield, fileSystem: fileSystem)) + { + var frame = new MutagenFrame(reader); + frame.MetaData.RecordInfoCache = new RecordTypeInfoCacheReader(() => new MutagenBinaryReadStream(path, GameRelease.Starfield, fileSystem: fileSystem)); + frame.MetaData.Parallel = parallel; + frame.MetaData.ModKey = path.ModKey; + frame.MetaData.Absorb(stringsParam); + if (reader.Remaining < 12) + { + throw new ArgumentException("File stream was too short to parse flags"); + } + var flags = reader.GetInt32(offset: 8); + if (Enums.HasFlag(flags, (int)ModHeaderCommonFlag.Localized)) + { + frame.MetaData.StringsLookup = StringsFolderLookupOverlay.TypicalFactory(GameRelease.Starfield, path.ModKey, Path.GetDirectoryName(path.Path)!, stringsParam); + } + CopyInFromBinary( + item: item, + importMask: importMask, + frame: frame); + } + } + catch (Exception ex) + { + throw RecordException.Enrich(ex, path.ModKey); + } + } + + public static void CopyInFromBinary( + this IStarfieldMod item, + Stream stream, + ModKey modKey, + RecordTypeInfoCacheReader infoCache, + GroupMask? importMask = null, + bool parallel = true) + { + try + { + using (var reader = new MutagenBinaryReadStream(stream, modKey, GameRelease.Starfield)) + { + var frame = new MutagenFrame(reader); + frame.MetaData.RecordInfoCache = infoCache; + frame.MetaData.Parallel = parallel; + frame.MetaData.ModKey = modKey; + CopyInFromBinary( + item: item, + importMask: importMask, + frame: frame); + } + } + catch (Exception ex) + { + throw RecordException.Enrich(ex, modKey); + } + } + + #endregion + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + #region Field Index + internal enum StarfieldMod_FieldIndex + { + ModHeader = 0, + Npcs = 1, + Races = 2, + Weapons = 3, + } + #endregion + + #region Registration + internal partial class StarfieldMod_Registration : ILoquiRegistration + { + public static readonly StarfieldMod_Registration Instance = new StarfieldMod_Registration(); + + public static ProtocolKey ProtocolKey => ProtocolDefinition_Starfield.ProtocolKey; + + public static readonly ObjectKey ObjectKey = new ObjectKey( + protocolKey: ProtocolDefinition_Starfield.ProtocolKey, + msgID: 66, + version: 0); + + public const string GUID = "9dcb1a8f-db0a-44bd-9a30-9427a9350e7a"; + + public const ushort AdditionalFieldCount = 4; + + public const ushort FieldCount = 4; + + public static readonly Type MaskType = typeof(StarfieldMod.Mask<>); + + public static readonly Type ErrorMaskType = typeof(StarfieldMod.ErrorMask); + + public static readonly Type ClassType = typeof(StarfieldMod); + + public static readonly Type GetterType = typeof(IStarfieldModGetter); + + public static readonly Type? InternalGetterType = null; + + public static readonly Type SetterType = typeof(IStarfieldMod); + + public static readonly Type? InternalSetterType = null; + + public const string FullName = "Mutagen.Bethesda.Starfield.StarfieldMod"; + + public const string Name = "StarfieldMod"; + + public const string Namespace = "Mutagen.Bethesda.Starfield"; + + public const byte GenericCount = 0; + + public static readonly Type? GenericRegistrationType = null; + + public static readonly RecordType TriggeringRecordType = RecordTypes.TES4; + public static readonly Type BinaryWriteTranslation = typeof(StarfieldModBinaryWriteTranslation); + #region Interface + ProtocolKey ILoquiRegistration.ProtocolKey => ProtocolKey; + ObjectKey ILoquiRegistration.ObjectKey => ObjectKey; + string ILoquiRegistration.GUID => GUID; + ushort ILoquiRegistration.FieldCount => FieldCount; + ushort ILoquiRegistration.AdditionalFieldCount => AdditionalFieldCount; + Type ILoquiRegistration.MaskType => MaskType; + Type ILoquiRegistration.ErrorMaskType => ErrorMaskType; + Type ILoquiRegistration.ClassType => ClassType; + Type ILoquiRegistration.SetterType => SetterType; + Type? ILoquiRegistration.InternalSetterType => InternalSetterType; + Type ILoquiRegistration.GetterType => GetterType; + Type? ILoquiRegistration.InternalGetterType => InternalGetterType; + string ILoquiRegistration.FullName => FullName; + string ILoquiRegistration.Name => Name; + string ILoquiRegistration.Namespace => Namespace; + byte ILoquiRegistration.GenericCount => GenericCount; + Type? ILoquiRegistration.GenericRegistrationType => GenericRegistrationType; + ushort? ILoquiRegistration.GetNameIndex(StringCaseAgnostic name) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsEnumerable(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsLoqui(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsSingleton(ushort index) => throw new NotImplementedException(); + string ILoquiRegistration.GetNthName(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsNthDerivative(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsProtected(ushort index) => throw new NotImplementedException(); + Type ILoquiRegistration.GetNthType(ushort index) => throw new NotImplementedException(); + #endregion + + } + #endregion + + #region Common + internal partial class StarfieldModSetterCommon + { + public static readonly StarfieldModSetterCommon Instance = new StarfieldModSetterCommon(); + + partial void ClearPartial(); + + public void Clear(IStarfieldMod item) + { + ClearPartial(); + item.Npcs.Clear(); + item.Races.Clear(); + item.Weapons.Clear(); + } + + #region Mutagen + public void RemapLinks(IStarfieldMod obj, IReadOnlyDictionary mapping) + { + obj.ModHeader.RemapLinks(mapping); + obj.Npcs.RemapLinks(mapping); + } + + public IEnumerable EnumerateMajorRecords(IStarfieldMod obj) + { + foreach (var item in StarfieldModCommon.Instance.EnumerateMajorRecords(obj)) + { + yield return (item as IMajorRecord)!; + } + } + + public IEnumerable EnumeratePotentiallyTypedMajorRecords( + IStarfieldMod obj, + Type? type, + bool throwIfUnknown) + { + if (type == null) return EnumerateMajorRecords(obj); + return EnumerateMajorRecords(obj, type, throwIfUnknown); + } + + public IEnumerable EnumerateMajorRecords( + IStarfieldMod obj, + Type type, + bool throwIfUnknown) + { + foreach (var item in StarfieldModCommon.Instance.EnumerateMajorRecords(obj, type, throwIfUnknown)) + { + yield return item; + } + } + + public void Remove( + IStarfieldMod obj, + HashSet keys) + { + obj.Npcs.Remove(keys); + obj.Races.Remove(keys); + obj.Weapons.Remove(keys); + } + + public void Remove( + IStarfieldMod obj, + HashSet keys, + Type type, + bool throwIfUnknown) + { + switch (type.Name) + { + case "IMajorRecord": + case "MajorRecord": + case "IStarfieldMajorRecord": + case "StarfieldMajorRecord": + case "IMajorRecordGetter": + case "IStarfieldMajorRecordGetter": + if (!StarfieldMod_Registration.SetterType.IsAssignableFrom(obj.GetType())) return; + this.Remove(obj, keys); + break; + case "Npc": + case "INpcGetter": + case "INpc": + case "INpcInternal": + obj.Npcs.Remove( + type: type, + keys: keys); + break; + case "Race": + case "IRaceGetter": + case "IRace": + case "IRaceInternal": + obj.Races.Remove( + type: type, + keys: keys); + break; + case "Weapon": + case "IWeaponGetter": + case "IWeapon": + case "IWeaponInternal": + obj.Weapons.Remove( + type: type, + keys: keys); + break; + default: + if (throwIfUnknown) + { + throw new ArgumentException($"Unknown major record type: {type}"); + } + else + { + break; + } + } + } + + public IEnumerable EnumerateListedAssetLinks(IStarfieldMod obj) + { + { + foreach (var item in obj.Weapons.EnumerateListedAssetLinks()) + { + yield return item; + } + } + yield break; + } + + private static partial void RemapInferredAssetLinks( + IStarfieldMod obj, + IReadOnlyDictionary mapping, + AssetLinkQuery queryCategories); + + public void RemapAssetLinks( + IStarfieldMod obj, + IReadOnlyDictionary mapping, + IAssetLinkCache? linkCache, + AssetLinkQuery queryCategories) + { + RemapInferredAssetLinks(obj, mapping, queryCategories); + obj.Weapons.RemapAssetLinks(mapping, queryCategories, linkCache); + } + + #endregion + + #region Binary Translation + public virtual void CopyInFromBinary( + IStarfieldMod item, + MutagenFrame frame, + GroupMask? importMask = null) + { + PluginUtilityTranslation.ModParse( + record: item, + frame: frame, + importMask: importMask, + fillTyped: StarfieldModBinaryCreateTranslation.FillBinaryRecordTypes); + } + + #endregion + + } + internal partial class StarfieldModCommon + { + public static readonly StarfieldModCommon Instance = new StarfieldModCommon(); + + public StarfieldMod.Mask GetEqualsMask( + IStarfieldModGetter item, + IStarfieldModGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + var ret = new StarfieldMod.Mask(false); + ((StarfieldModCommon)((IStarfieldModGetter)item).CommonInstance()!).FillEqualsMask( + item: item, + rhs: rhs, + ret: ret, + include: include); + return ret; + } + + public void FillEqualsMask( + IStarfieldModGetter item, + IStarfieldModGetter rhs, + StarfieldMod.Mask ret, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + ret.ModHeader = MaskItemExt.Factory(item.ModHeader.GetEqualsMask(rhs.ModHeader, include), include); + ret.Npcs = MaskItemExt.Factory(item.Npcs.GetEqualsMask(rhs.Npcs, include), include); + ret.Races = MaskItemExt.Factory(item.Races.GetEqualsMask(rhs.Races, include), include); + ret.Weapons = MaskItemExt.Factory(item.Weapons.GetEqualsMask(rhs.Weapons, include), include); + } + + public string Print( + IStarfieldModGetter item, + string? name = null, + StarfieldMod.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + return sb.ToString(); + } + + public void Print( + IStarfieldModGetter item, + StructuredStringBuilder sb, + string? name = null, + StarfieldMod.Mask? printMask = null) + { + if (name == null) + { + sb.AppendLine($"StarfieldMod =>"); + } + else + { + sb.AppendLine($"{name} (StarfieldMod) =>"); + } + using (sb.Brace()) + { + ToStringFields( + item: item, + sb: sb, + printMask: printMask); + } + } + + protected static void ToStringFields( + IStarfieldModGetter item, + StructuredStringBuilder sb, + StarfieldMod.Mask? printMask = null) + { + if (printMask?.ModHeader?.Overall ?? true) + { + item.ModHeader?.Print(sb, "ModHeader"); + } + if (printMask?.Npcs?.Overall ?? true) + { + item.Npcs?.Print(sb, "Npcs"); + } + if (printMask?.Races?.Overall ?? true) + { + item.Races?.Print(sb, "Races"); + } + if (printMask?.Weapons?.Overall ?? true) + { + item.Weapons?.Print(sb, "Weapons"); + } + } + + #region Equals and Hash + public virtual bool Equals( + IStarfieldModGetter? lhs, + IStarfieldModGetter? rhs, + TranslationCrystal? equalsMask) + { + if (!EqualsMaskHelper.RefEquality(lhs, rhs, out var isEqual)) return isEqual; + if ((equalsMask?.GetShouldTranslate((int)StarfieldMod_FieldIndex.ModHeader) ?? true)) + { + if (EqualsMaskHelper.RefEquality(lhs.ModHeader, rhs.ModHeader, out var lhsModHeader, out var rhsModHeader, out var isModHeaderEqual)) + { + if (!((StarfieldModHeaderCommon)((IStarfieldModHeaderGetter)lhsModHeader).CommonInstance()!).Equals(lhsModHeader, rhsModHeader, equalsMask?.GetSubCrystal((int)StarfieldMod_FieldIndex.ModHeader))) return false; + } + else if (!isModHeaderEqual) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldMod_FieldIndex.Npcs) ?? true)) + { + if (EqualsMaskHelper.RefEquality(lhs.Npcs, rhs.Npcs, out var lhsNpcs, out var rhsNpcs, out var isNpcsEqual)) + { + if (!object.Equals(lhsNpcs, rhsNpcs)) return false; + } + else if (!isNpcsEqual) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldMod_FieldIndex.Races) ?? true)) + { + if (EqualsMaskHelper.RefEquality(lhs.Races, rhs.Races, out var lhsRaces, out var rhsRaces, out var isRacesEqual)) + { + if (!object.Equals(lhsRaces, rhsRaces)) return false; + } + else if (!isRacesEqual) return false; + } + if ((equalsMask?.GetShouldTranslate((int)StarfieldMod_FieldIndex.Weapons) ?? true)) + { + if (EqualsMaskHelper.RefEquality(lhs.Weapons, rhs.Weapons, out var lhsWeapons, out var rhsWeapons, out var isWeaponsEqual)) + { + if (!object.Equals(lhsWeapons, rhsWeapons)) return false; + } + else if (!isWeaponsEqual) return false; + } + return true; + } + + public virtual int GetHashCode(IStarfieldModGetter item) + { + var hash = new HashCode(); + hash.Add(item.ModHeader); + hash.Add(item.Npcs); + hash.Add(item.Races); + hash.Add(item.Weapons); + return hash.ToHashCode(); + } + + #endregion + + + public object GetNew() + { + return StarfieldMod.GetNew(); + } + + #region Mutagen + public object? GetGroup( + IStarfieldModGetter obj, + Type type) + { + switch (type.Name) + { + case "Npc": + case "INpcGetter": + case "INpc": + case "INpcInternal": + return obj.Npcs; + case "Race": + case "IRaceGetter": + case "IRace": + case "IRaceInternal": + return obj.Races; + case "Weapon": + case "IWeaponGetter": + case "IWeapon": + case "IWeaponInternal": + return obj.Weapons; + default: + return null; + } + } + + public static void WriteParallel( + IStarfieldModGetter item, + Stream stream, + BinaryWriteParameters param, + ParallelWriteParameters parallelParam, + ModKey modKey) + { + var bundle = new WritingBundle(GameConstants.Starfield) + { + StringsWriter = param.StringsWriter, + TargetLanguageOverride = param.TargetLanguageOverride, + Encodings = param.Encodings ?? GameConstants.Starfield.Encodings, + }; + var writer = new MutagenWriter(stream, bundle); + ModHeaderWriteLogic.WriteHeader( + param: param, + writer: writer, + mod: item, + modHeader: item.ModHeader.DeepCopy(), + modKey: modKey); + Stream[] outputStreams = new Stream[3]; + List toDo = new List(); + toDo.Add(() => WriteGroupParallel(item.Npcs, 0, outputStreams, bundle, parallelParam)); + toDo.Add(() => WriteGroupParallel(item.Races, 1, outputStreams, bundle, parallelParam)); + toDo.Add(() => WriteGroupParallel(item.Weapons, 2, outputStreams, bundle, parallelParam)); + Parallel.Invoke(parallelParam.ParallelOptions, toDo.ToArray()); + PluginUtilityTranslation.CompileStreamsInto( + outputStreams.NotNull(), + stream); + } + + public static void WriteGroupParallel( + IStarfieldGroupGetter group, + int targetIndex, + Stream[] streamDepositArray, + WritingBundle bundle, + ParallelWriteParameters parallelParam) + where T : class, IStarfieldMajorRecordGetter, IBinaryItem + { + if (group.RecordCache.Count == 0) return; + var cuts = group.Cut(parallelParam.CutCount).ToArray(); + Stream[] subStreams = new Stream[cuts.Length + 1]; + byte[] groupBytes = new byte[bundle.Constants.GroupConstants.HeaderLength]; + BinaryPrimitives.WriteInt32LittleEndian(groupBytes.AsSpan(), RecordTypes.GRUP.TypeInt); + var groupByteStream = new MemoryStream(groupBytes); + using (var stream = new MutagenWriter(groupByteStream, bundle.Constants, dispose: false)) + { + stream.Position += 8; + StarfieldGroupBinaryWriteTranslation.WriteEmbedded(group, stream); + } + subStreams[0] = groupByteStream; + Parallel.ForEach(cuts, parallelParam.ParallelOptions, (cutItems, state, counter) => + { + MemoryTributary trib = new MemoryTributary(); + using (var stream = new MutagenWriter(trib, bundle with {}, dispose: false)) + { + foreach (var item in cutItems) + { + item.WriteToBinary(stream); + } + } + subStreams[(int)counter + 1] = trib; + }); + PluginUtilityTranslation.CompileSetGroupLength(subStreams, groupBytes); + streamDepositArray[targetIndex] = new CompositeReadStream(subStreams, resetPositions: true); + } + + public IEnumerable EnumerateFormLinks(IStarfieldModGetter obj) + { + foreach (var item in obj.ModHeader.EnumerateFormLinks()) + { + yield return item; + } + foreach (var item in obj.Npcs.EnumerateFormLinks()) + { + yield return item; + } + yield break; + } + + public IEnumerable EnumerateMajorRecords(IStarfieldModGetter obj) + { + foreach (var item in obj.Npcs.EnumerateMajorRecords()) + { + yield return item; + } + foreach (var item in obj.Races.EnumerateMajorRecords()) + { + yield return item; + } + foreach (var item in obj.Weapons.EnumerateMajorRecords()) + { + yield return item; + } + } + + public IEnumerable EnumeratePotentiallyTypedMajorRecords( + IStarfieldModGetter obj, + Type? type, + bool throwIfUnknown) + { + if (type == null) return EnumerateMajorRecords(obj); + return EnumerateMajorRecords(obj, type, throwIfUnknown); + } + + public IEnumerable EnumerateMajorRecords( + IStarfieldModGetter obj, + Type type, + bool throwIfUnknown) + { + switch (type.Name) + { + case "IMajorRecord": + case "MajorRecord": + case "IStarfieldMajorRecord": + case "StarfieldMajorRecord": + if (!StarfieldMod_Registration.SetterType.IsAssignableFrom(obj.GetType())) yield break; + foreach (var item in this.EnumerateMajorRecords(obj)) + { + yield return item; + } + yield break; + case "IMajorRecordGetter": + case "IStarfieldMajorRecordGetter": + foreach (var item in this.EnumerateMajorRecords(obj)) + { + yield return item; + } + yield break; + case "Npc": + case "INpcGetter": + case "INpc": + case "INpcInternal": + foreach (var item in obj.Npcs.EnumerateMajorRecords(type, throwIfUnknown: throwIfUnknown)) + { + yield return item; + } + yield break; + case "Race": + case "IRaceGetter": + case "IRace": + case "IRaceInternal": + foreach (var item in obj.Races.EnumerateMajorRecords(type, throwIfUnknown: throwIfUnknown)) + { + yield return item; + } + yield break; + case "Weapon": + case "IWeaponGetter": + case "IWeapon": + case "IWeaponInternal": + foreach (var item in obj.Weapons.EnumerateMajorRecords(type, throwIfUnknown: throwIfUnknown)) + { + yield return item; + } + yield break; + default: + if (InterfaceEnumerationHelper.TryEnumerateInterfaceRecordsFor(GameCategory.Starfield, obj, type, out var linkInterfaces)) + { + foreach (var item in linkInterfaces) + { + yield return item; + } + yield break; + } + if (throwIfUnknown) + { + throw new ArgumentException($"Unknown major record type: {type}"); + } + else + { + yield break; + } + } + } + + public IEnumerable> EnumerateMajorRecordContexts( + IStarfieldModGetter obj, + ILinkCache linkCache) + { + foreach (var item in InterfaceEnumerationHelper.EnumerateGroupContexts( + srcGroup: obj.Npcs, + type: typeof(INpcGetter), + modKey: obj.ModKey, + group: (m) => m.Npcs, + groupGetter: (m) => m.Npcs)) + { + yield return item; + } + foreach (var item in InterfaceEnumerationHelper.EnumerateGroupContexts( + srcGroup: obj.Races, + type: typeof(IRaceGetter), + modKey: obj.ModKey, + group: (m) => m.Races, + groupGetter: (m) => m.Races)) + { + yield return item; + } + foreach (var item in InterfaceEnumerationHelper.EnumerateGroupContexts( + srcGroup: obj.Weapons, + type: typeof(IWeaponGetter), + modKey: obj.ModKey, + group: (m) => m.Weapons, + groupGetter: (m) => m.Weapons)) + { + yield return item; + } + } + + public IEnumerable> EnumerateMajorRecordContexts( + IStarfieldModGetter obj, + ILinkCache linkCache, + Type type, + bool throwIfUnknown) + { + switch (type.Name) + { + case "IMajorRecord": + case "MajorRecord": + case "IStarfieldMajorRecord": + case "StarfieldMajorRecord": + if (!StarfieldMod_Registration.SetterType.IsAssignableFrom(obj.GetType())) yield break; + foreach (var item in this.EnumerateMajorRecordContexts( + obj, + linkCache: linkCache)) + { + yield return item; + } + yield break; + case "IMajorRecordGetter": + case "IStarfieldMajorRecordGetter": + foreach (var item in this.EnumerateMajorRecordContexts( + obj, + linkCache: linkCache)) + { + yield return item; + } + yield break; + case "Npc": + case "INpcGetter": + case "INpc": + case "INpcInternal": + foreach (var item in InterfaceEnumerationHelper.EnumerateGroupContexts( + srcGroup: obj.Npcs, + type: type, + modKey: obj.ModKey, + group: (m) => m.Npcs, + groupGetter: (m) => m.Npcs)) + { + yield return item; + } + yield break; + case "Race": + case "IRaceGetter": + case "IRace": + case "IRaceInternal": + foreach (var item in InterfaceEnumerationHelper.EnumerateGroupContexts( + srcGroup: obj.Races, + type: type, + modKey: obj.ModKey, + group: (m) => m.Races, + groupGetter: (m) => m.Races)) + { + yield return item; + } + yield break; + case "Weapon": + case "IWeaponGetter": + case "IWeapon": + case "IWeaponInternal": + foreach (var item in InterfaceEnumerationHelper.EnumerateGroupContexts( + srcGroup: obj.Weapons, + type: type, + modKey: obj.ModKey, + group: (m) => m.Weapons, + groupGetter: (m) => m.Weapons)) + { + yield return item; + } + yield break; + default: + if (InterfaceEnumerationHelper.TryEnumerateInterfaceContextsFor( + GameCategory.Starfield, + obj, + type, + linkCache, + out var linkInterfaces)) + { + foreach (var item in linkInterfaces) + { + yield return item; + } + yield break; + } + if (throwIfUnknown) + { + throw new ArgumentException($"Unknown major record type: {type}"); + } + else + { + yield break; + } + } + } + + public static partial IEnumerable GetInferredAssetLinks(IStarfieldModGetter obj, Type? assetType); + public IEnumerable EnumerateAssetLinks(IStarfieldModGetter obj, AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) + { + if (queryCategories.HasFlag(AssetLinkQuery.Inferred)) + { + foreach (var additional in GetInferredAssetLinks(obj, assetType)) + { + yield return additional; + } + } + if (queryCategories.HasFlag(AssetLinkQuery.Listed)) + { + foreach (var item in obj.Weapons.EnumerateAssetLinks(queryCategories: queryCategories, linkCache: linkCache, assetType: assetType)) + { + yield return item; + } + } + yield break; + } + + #endregion + + } + internal partial class StarfieldModSetterTranslationCommon + { + public static readonly StarfieldModSetterTranslationCommon Instance = new StarfieldModSetterTranslationCommon(); + + #region DeepCopyIn + public void DeepCopyIn( + IStarfieldMod item, + IStarfieldModGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + if ((copyMask?.GetShouldTranslate((int)StarfieldMod_FieldIndex.ModHeader) ?? true)) + { + errorMask?.PushIndex((int)StarfieldMod_FieldIndex.ModHeader); + try + { + item.ModHeader.DeepCopyIn( + rhs: rhs.ModHeader, + errorMask: errorMask, + copyMask: copyMask?.GetSubCrystal((int)StarfieldMod_FieldIndex.ModHeader)); + } + catch (Exception ex) + when (errorMask != null) + { + errorMask.ReportException(ex); + } + finally + { + errorMask?.PopIndex(); + } + } + if ((copyMask?.GetShouldTranslate((int)StarfieldMod_FieldIndex.Npcs) ?? true)) + { + errorMask?.PushIndex((int)StarfieldMod_FieldIndex.Npcs); + try + { + item.Npcs.DeepCopyIn( + rhs: rhs.Npcs, + errorMask: errorMask, + copyMask: copyMask?.GetSubCrystal((int)StarfieldMod_FieldIndex.Npcs)); + } + catch (Exception ex) + when (errorMask != null) + { + errorMask.ReportException(ex); + } + finally + { + errorMask?.PopIndex(); + } + } + if ((copyMask?.GetShouldTranslate((int)StarfieldMod_FieldIndex.Races) ?? true)) + { + errorMask?.PushIndex((int)StarfieldMod_FieldIndex.Races); + try + { + item.Races.DeepCopyIn( + rhs: rhs.Races, + errorMask: errorMask, + copyMask: copyMask?.GetSubCrystal((int)StarfieldMod_FieldIndex.Races)); + } + catch (Exception ex) + when (errorMask != null) + { + errorMask.ReportException(ex); + } + finally + { + errorMask?.PopIndex(); + } + } + if ((copyMask?.GetShouldTranslate((int)StarfieldMod_FieldIndex.Weapons) ?? true)) + { + errorMask?.PushIndex((int)StarfieldMod_FieldIndex.Weapons); + try + { + item.Weapons.DeepCopyIn( + rhs: rhs.Weapons, + errorMask: errorMask, + copyMask: copyMask?.GetSubCrystal((int)StarfieldMod_FieldIndex.Weapons)); + } + catch (Exception ex) + when (errorMask != null) + { + errorMask.ReportException(ex); + } + finally + { + errorMask?.PopIndex(); + } + } + } + + #endregion + + public StarfieldMod DeepCopy( + IStarfieldModGetter item, + StarfieldMod.TranslationMask? copyMask = null) + { + StarfieldMod ret = (StarfieldMod)((StarfieldModCommon)((IStarfieldModGetter)item).CommonInstance()!).GetNew(); + ((StarfieldModSetterTranslationCommon)((IStarfieldModGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: null, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + return ret; + } + + public StarfieldMod DeepCopy( + IStarfieldModGetter item, + out StarfieldMod.ErrorMask errorMask, + StarfieldMod.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + StarfieldMod ret = (StarfieldMod)((StarfieldModCommon)((IStarfieldModGetter)item).CommonInstance()!).GetNew(); + ((StarfieldModSetterTranslationCommon)((IStarfieldModGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + ret, + item, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + errorMask = StarfieldMod.ErrorMask.Factory(errorMaskBuilder); + return ret; + } + + public StarfieldMod DeepCopy( + IStarfieldModGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + StarfieldMod ret = (StarfieldMod)((StarfieldModCommon)((IStarfieldModGetter)item).CommonInstance()!).GetNew(); + ((StarfieldModSetterTranslationCommon)((IStarfieldModGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: true); + return ret; + } + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + public partial class StarfieldMod + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => StarfieldMod_Registration.Instance; + public static ILoquiRegistration StaticRegistration => StarfieldMod_Registration.Instance; + [DebuggerStepThrough] + protected object CommonInstance() => StarfieldModCommon.Instance; + [DebuggerStepThrough] + protected object CommonSetterInstance() + { + return StarfieldModSetterCommon.Instance; + } + [DebuggerStepThrough] + protected object CommonSetterTranslationInstance() => StarfieldModSetterTranslationCommon.Instance; + [DebuggerStepThrough] + object IStarfieldModGetter.CommonInstance() => this.CommonInstance(); + [DebuggerStepThrough] + object IStarfieldModGetter.CommonSetterInstance() => this.CommonSetterInstance(); + [DebuggerStepThrough] + object IStarfieldModGetter.CommonSetterTranslationInstance() => this.CommonSetterTranslationInstance(); + + #endregion + + } +} + +#region Modules +#region Mutagen +namespace Mutagen.Bethesda.Starfield +{ + public class GroupMask + { + public bool Npcs; + public bool Races; + public bool Weapons; + public GroupMask() + { + } + public GroupMask(bool defaultValue) + { + Npcs = defaultValue; + Races = defaultValue; + Weapons = defaultValue; + } + } + + public interface IStarfieldModDisposableGetter : IStarfieldModGetter, IModDisposeGetter + { + } + +} +namespace Mutagen.Bethesda.Starfield +{ + internal partial class StarfieldMod_Registration : IModRegistration + { + public GameCategory GameCategory => GameCategory.Starfield; + } + +} +#endregion + +#region Binary Translation +namespace Mutagen.Bethesda.Starfield +{ + public partial class StarfieldModBinaryWriteTranslation + { + public static readonly StarfieldModBinaryWriteTranslation Instance = new(); + + public static void WriteRecordTypes( + IStarfieldModGetter item, + MutagenWriter writer, + GroupMask? importMask, + TypedWriteParams translationParams = default) + { + if (importMask?.Npcs ?? true) + { + var NpcsItem = item.Npcs; + if (NpcsItem.RecordCache.Count > 0) + { + ((StarfieldGroupBinaryWriteTranslation)((IBinaryItem)NpcsItem).BinaryWriteTranslator).Write( + item: NpcsItem, + writer: writer, + translationParams: translationParams); + } + } + if (importMask?.Races ?? true) + { + var RacesItem = item.Races; + if (RacesItem.RecordCache.Count > 0) + { + ((StarfieldGroupBinaryWriteTranslation)((IBinaryItem)RacesItem).BinaryWriteTranslator).Write( + item: RacesItem, + writer: writer, + translationParams: translationParams); + } + } + if (importMask?.Weapons ?? true) + { + var WeaponsItem = item.Weapons; + if (WeaponsItem.RecordCache.Count > 0) + { + ((StarfieldGroupBinaryWriteTranslation)((IBinaryItem)WeaponsItem).BinaryWriteTranslator).Write( + item: WeaponsItem, + writer: writer, + translationParams: translationParams); + } + } + } + + public void Write( + MutagenWriter writer, + IStarfieldModGetter item, + ModKey modKey, + GroupMask? importMask = null, + BinaryWriteParameters? param = null) + { + ModHeaderWriteLogic.WriteHeader( + param: param, + writer: writer, + mod: item, + modHeader: item.ModHeader.DeepCopy(), + modKey: modKey); + WriteRecordTypes( + item: item, + writer: writer, + importMask: importMask); + } + + public void Write( + MutagenWriter writer, + object item, + ModKey modKey, + GroupMask? importMask = null, + BinaryWriteParameters? param = null) + { + Write( + item: (IStarfieldModGetter)item, + writer: writer, + importMask: importMask, + param: param, + modKey: modKey); + } + + } + + internal partial class StarfieldModBinaryCreateTranslation + { + public static readonly StarfieldModBinaryCreateTranslation Instance = new StarfieldModBinaryCreateTranslation(); + + public static ParseResult FillBinaryRecordTypes( + IStarfieldMod item, + MutagenFrame frame, + RecordType nextRecordType, + int contentLength, + GroupMask? importMask, + TypedParseParams translationParams = default) + { + nextRecordType = translationParams.ConvertToStandard(nextRecordType); + switch (nextRecordType.TypeInt) + { + case RecordTypeInts.TES4: + { + item.ModHeader.CopyInFromBinary( + frame: frame, + translationParams: null); + return (int)StarfieldMod_FieldIndex.ModHeader; + } + case RecordTypeInts.NPC_: + { + if (importMask?.Npcs ?? true) + { + item.Npcs.CopyInFromBinary( + frame: frame, + translationParams: null); + } + else + { + frame.Position += contentLength; + } + return (int)StarfieldMod_FieldIndex.Npcs; + } + case RecordTypeInts.RACE: + { + if (importMask?.Races ?? true) + { + item.Races.CopyInFromBinary( + frame: frame, + translationParams: null); + } + else + { + frame.Position += contentLength; + } + return (int)StarfieldMod_FieldIndex.Races; + } + case RecordTypeInts.WEAP: + { + if (importMask?.Weapons ?? true) + { + item.Weapons.CopyInFromBinary( + frame: frame, + translationParams: null); + } + else + { + frame.Position += contentLength; + } + return (int)StarfieldMod_FieldIndex.Weapons; + } + default: + frame.Position += contentLength; + return default(int?); + } + } + + } + +} +namespace Mutagen.Bethesda.Starfield +{ + #region Binary Write Mixins + public static class StarfieldModBinaryTranslationMixIn + { + public static void WriteToBinary( + this IStarfieldModGetter item, + MutagenWriter writer, + GroupMask? importMask = null, + BinaryWriteParameters? param = null) + { + var modKey = item.ModKey; + StarfieldModBinaryWriteTranslation.Instance.Write( + item: item, + writer: writer, + importMask: importMask, + param: param, + modKey: modKey); + } + + public static void WriteToBinary( + this IStarfieldModGetter item, + FilePath path, + BinaryWriteParameters? param = null, + GroupMask? importMask = null, + IFileSystem? fileSystem = null) + { + param ??= BinaryWriteParameters.Default; + var modKey = param.RunMasterMatch( + mod: item, + path: path); + param.StringsWriter ??= (Enums.HasFlag((int)item.ModHeader.Flags, (int)ModHeaderCommonFlag.Localized) ? new StringsWriter(GameRelease.Starfield, modKey, Path.Combine(Path.GetDirectoryName(path)!, "Strings"), MutagenEncodingProvider.Instance) : null); + bool disposeStrings = param.StringsWriter != null; + var bundle = new WritingBundle(GameRelease.Starfield) + { + StringsWriter = param.StringsWriter, + CleanNulls = param.CleanNulls, + TargetLanguageOverride = param.TargetLanguageOverride + }; + if (param.Encodings != null) + { + bundle.Encodings = param.Encodings; + } + using var memStream = new MemoryTributary(); + using (var writer = new MutagenWriter( + memStream, + bundle, + dispose: false)) + { + StarfieldModBinaryWriteTranslation.Instance.Write( + item: item, + importMask: importMask, + writer: writer, + param: param, + modKey: modKey); + } + using (var fs = fileSystem.GetOrDefault().FileStream.Create(path, FileMode.Create, FileAccess.Write)) + { + memStream.Position = 0; + memStream.CopyTo(fs); + } + if (disposeStrings) + { + param.StringsWriter?.Dispose(); + } + } + + public static void WriteToBinary( + this IStarfieldModGetter item, + Stream stream, + BinaryWriteParameters? param = null, + GroupMask? importMask = null) + { + var modKey = item.ModKey; + using (var writer = new MutagenWriter( + stream: stream, + new WritingBundle(GameRelease.Starfield), + dispose: false)) + { + StarfieldModBinaryWriteTranslation.Instance.Write( + item: item, + importMask: importMask, + writer: writer, + param: param, + modKey: modKey); + } + } + + } + #endregion + + +} +namespace Mutagen.Bethesda.Starfield +{ + [DebuggerDisplay("{GameRelease} {ModKey.ToString()}")] + internal partial class StarfieldModBinaryOverlay : IStarfieldModDisposableGetter + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => StarfieldMod_Registration.Instance; + public static ILoquiRegistration StaticRegistration => StarfieldMod_Registration.Instance; + [DebuggerStepThrough] + protected object CommonInstance() => StarfieldModCommon.Instance; + [DebuggerStepThrough] + protected object CommonSetterTranslationInstance() => StarfieldModSetterTranslationCommon.Instance; + [DebuggerStepThrough] + object IStarfieldModGetter.CommonInstance() => this.CommonInstance(); + [DebuggerStepThrough] + object? IStarfieldModGetter.CommonSetterInstance() => null; + [DebuggerStepThrough] + object IStarfieldModGetter.CommonSetterTranslationInstance() => this.CommonSetterTranslationInstance(); + + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + public GameRelease GameRelease => GameRelease.Starfield; + IGroupGetter? IModGetter.TryGetTopLevelGroup() => this.TryGetTopLevelGroup(); + IGroupGetter? IModGetter.TryGetTopLevelGroup(Type type) => this.TryGetTopLevelGroup(type); + void IModGetter.WriteToBinary(FilePath path, BinaryWriteParameters? param, IFileSystem? fileSystem) => this.WriteToBinary(path, importMask: null, param: param, fileSystem: fileSystem); + void IModGetter.WriteToBinaryParallel(FilePath path, BinaryWriteParameters? param, IFileSystem? fileSystem, ParallelWriteParameters? parallelWriteParams) => this.WriteToBinaryParallel(path, param: param, fileSystem: fileSystem, parallelParam: parallelWriteParams); + void IModGetter.WriteToBinary(Stream stream, BinaryWriteParameters? param) => this.WriteToBinary(stream, importMask: null, param: param); + void IModGetter.WriteToBinaryParallel(Stream stream, BinaryWriteParameters? param, ParallelWriteParameters? parallelWriteParams) => this.WriteToBinaryParallel(stream, param, parallelParam: parallelWriteParams); + IReadOnlyList IModGetter.MasterReferences => this.ModHeader.MasterReferences; + public bool CanUseLocalization => true; + public bool UsingLocalization => this.ModHeader.Flags.HasFlag(StarfieldModHeader.HeaderFlag.Localized); + public IEnumerable EnumerateFormLinks() => StarfieldModCommon.Instance.EnumerateFormLinks(this); + public IEnumerable EnumerateAssetLinks(AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) => StarfieldModCommon.Instance.EnumerateAssetLinks(this, queryCategories, linkCache, assetType); + [DebuggerStepThrough] + IEnumerable> IMajorRecordContextEnumerable.EnumerateMajorRecordContexts(ILinkCache linkCache, bool throwIfUnknown) => this.EnumerateMajorRecordContexts(linkCache, throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable> IMajorRecordContextEnumerable.EnumerateMajorRecordContexts(ILinkCache linkCache, Type type, bool throwIfUnknown) => this.EnumerateMajorRecordContexts(linkCache, type: type, throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable> IMajorRecordSimpleContextEnumerable.EnumerateMajorRecordSimpleContexts() => this.EnumerateMajorRecordContexts(); + [DebuggerStepThrough] + IEnumerable> IMajorRecordSimpleContextEnumerable.EnumerateMajorRecordSimpleContexts(bool throwIfUnknown) => this.EnumerateMajorRecordContexts(linkCache: null!, typeof(TMajor), throwIfUnknown: throwIfUnknown).Select(x => x.AsType()); + [DebuggerStepThrough] + IEnumerable> IMajorRecordSimpleContextEnumerable.EnumerateMajorRecordSimpleContexts(Type type, bool throwIfUnknown) => this.EnumerateMajorRecordContexts(linkCache: null!, type: type, throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords() => this.EnumerateMajorRecords(); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords(bool throwIfUnknown) => this.EnumerateMajorRecords(throwIfUnknown: throwIfUnknown); + [DebuggerStepThrough] + IEnumerable IMajorRecordGetterEnumerable.EnumerateMajorRecords(Type type, bool throwIfUnknown) => this.EnumerateMajorRecords(type: type, throwIfUnknown: throwIfUnknown); + uint IModGetter.NextFormID => ModHeader.Stats.NextFormID; + public ModKey ModKey { get; } + private readonly BinaryOverlayFactoryPackage _package; + private readonly IBinaryReadStream _stream; + private readonly bool _shouldDispose; + public void Dispose() + { + if (!_shouldDispose) return; + _stream.Dispose(); + } + + #region ModHeader + private RangeInt64? _ModHeaderLocation; + private IStarfieldModHeaderGetter? _ModHeader => _ModHeaderLocation.HasValue ? StarfieldModHeaderBinaryOverlay.StarfieldModHeaderFactory(PluginBinaryOverlay.LockExtractMemory(_stream, _ModHeaderLocation!.Value.Min, _ModHeaderLocation!.Value.Max), _package) : default; + public IStarfieldModHeaderGetter ModHeader => _ModHeader ?? new StarfieldModHeader(); + #endregion + #region Npcs + private List? _NpcsLocations; + private IStarfieldGroupGetter? _Npcs => _NpcsLocations != null ? StarfieldGroupBinaryOverlay.StarfieldGroupFactory(_stream, _NpcsLocations, _package) : default; + public IStarfieldGroupGetter Npcs => _Npcs ?? new StarfieldGroup(this); + #endregion + #region Races + private List? _RacesLocations; + private IStarfieldGroupGetter? _Races => _RacesLocations != null ? StarfieldGroupBinaryOverlay.StarfieldGroupFactory(_stream, _RacesLocations, _package) : default; + public IStarfieldGroupGetter Races => _Races ?? new StarfieldGroup(this); + #endregion + #region Weapons + private List? _WeaponsLocations; + private IStarfieldGroupGetter? _Weapons => _WeaponsLocations != null ? StarfieldGroupBinaryOverlay.StarfieldGroupFactory(_stream, _WeaponsLocations, _package) : default; + public IStarfieldGroupGetter Weapons => _Weapons ?? new StarfieldGroup(this); + #endregion + protected StarfieldModBinaryOverlay( + IMutagenReadStream stream, + ModKey modKey, + bool shouldDispose) + { + this.ModKey = modKey; + this._stream = stream; + this._package = new BinaryOverlayFactoryPackage(stream.MetaData); + this._shouldDispose = shouldDispose; + } + + public static StarfieldModBinaryOverlay StarfieldModFactory( + ModPath path, + StringsReadParameters? stringsParam = null, + IFileSystem? fileSystem = null) + { + var meta = new ParsingBundle(GameRelease.Starfield, new MasterReferenceCollection(path.ModKey)) + { + RecordInfoCache = new RecordTypeInfoCacheReader(() => new MutagenBinaryReadStream(path, GameRelease.Starfield, fileSystem: fileSystem)) + }; + var stream = new MutagenBinaryReadStream( + path: path.Path, + metaData: meta, + fileSystem: fileSystem); + try + { + meta.Absorb(stringsParam); + if (stream.Remaining < 12) + { + throw new ArgumentException("File stream was too short to parse flags"); + } + var flags = stream.GetInt32(offset: 8); + if (Enums.HasFlag(flags, (int)ModHeaderCommonFlag.Localized)) + { + meta.StringsLookup = StringsFolderLookupOverlay.TypicalFactory(GameRelease.Starfield, path.ModKey, Path.GetDirectoryName(path.Path)!, stringsParam); + } + return StarfieldModFactory( + stream: stream, + path.ModKey, + shouldDispose: true); + } + catch (Exception) + { + stream.Dispose(); + throw; + } + } + + public static StarfieldModBinaryOverlay StarfieldModFactory( + IMutagenReadStream stream, + ModKey modKey, + bool shouldDispose) + { + var ret = new StarfieldModBinaryOverlay( + stream: stream, + modKey: modKey, + shouldDispose: shouldDispose); + PluginBinaryOverlay.FillModTypes( + stream: stream, + package: ret._package, + fill: ret.FillRecordType); + return ret; + } + + + public ParseResult FillRecordType( + IBinaryReadStream stream, + long finalPos, + int offset, + RecordType type, + PreviousParse lastParsed, + TypedParseParams translationParams = default) + { + type = translationParams.ConvertToStandard(type); + switch (type.TypeInt) + { + case RecordTypeInts.TES4: + { + _ModHeaderLocation = new RangeInt64((stream.Position - offset), finalPos - offset); + _package.MetaData.MasterReferences!.SetTo( + this.ModHeader.MasterReferences.Select( + master => new MasterReference() + { + Master = master.Master, + FileSize = master.FileSize, + })); + return (int)StarfieldMod_FieldIndex.ModHeader; + } + case RecordTypeInts.NPC_: + { + _NpcsLocations ??= new(); + _NpcsLocations.Add(new RangeInt64((stream.Position - offset), finalPos - offset)); + return (int)StarfieldMod_FieldIndex.Npcs; + } + case RecordTypeInts.RACE: + { + _RacesLocations ??= new(); + _RacesLocations.Add(new RangeInt64((stream.Position - offset), finalPos - offset)); + return (int)StarfieldMod_FieldIndex.Races; + } + case RecordTypeInts.WEAP: + { + _WeaponsLocations ??= new(); + _WeaponsLocations.Add(new RangeInt64((stream.Position - offset), finalPos - offset)); + return (int)StarfieldMod_FieldIndex.Weapons; + } + default: + return default(int?); + } + } + #region To String + + public void Print( + StructuredStringBuilder sb, + string? name = null) + { + StarfieldModMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is not IStarfieldModGetter rhs) return false; + return ((StarfieldModCommon)((IStarfieldModGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IStarfieldModGetter? obj) + { + return ((StarfieldModCommon)((IStarfieldModGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((StarfieldModCommon)((IStarfieldModGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + IMask IEqualsMask.GetEqualsMask(object rhs, EqualsMaskHelper.Include include = EqualsMaskHelper.Include.OnlyFailures) => StarfieldModMixIn.GetEqualsMask(this, (IStarfieldModGetter)rhs, include); + } + +} +#endregion + +#endregion + diff --git a/Mutagen.Bethesda.Starfield/Records/TypeSolidifier_Generated.cs b/Mutagen.Bethesda.Starfield/Records/TypeSolidifier_Generated.cs new file mode 100644 index 0000000000..9ea12fb6bc --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/TypeSolidifier_Generated.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using Mutagen.Bethesda.Plugins.Cache; +using Mutagen.Bethesda.Plugins.Order; + +namespace Mutagen.Bethesda.Starfield +{ + public static class TypeOptionSolidifierMixIns + { + #region Normal + /// + /// Scope a load order query to Npc + /// + /// ModListings to query + /// A typed object to do further queries on Npc + public static TopLevelTypedLoadOrderAccess Npc(this IEnumerable> listings) + { + return new TopLevelTypedLoadOrderAccess( + (bool includeDeletedRecords) => listings.WinningOverrides(includeDeletedRecords: includeDeletedRecords), + (ILinkCache linkCache, bool includeDeletedRecords) => listings.WinningContextOverrides(linkCache, includeDeletedRecords: includeDeletedRecords)); + } + + /// + /// Scope a load order query to Npc + /// + /// Mods to query + /// A typed object to do further queries on Npc + public static TopLevelTypedLoadOrderAccess Npc(this IEnumerable mods) + { + return new TopLevelTypedLoadOrderAccess( + (bool includeDeletedRecords) => mods.WinningOverrides(includeDeletedRecords: includeDeletedRecords), + (ILinkCache linkCache, bool includeDeletedRecords) => mods.WinningContextOverrides(linkCache, includeDeletedRecords: includeDeletedRecords)); + } + + /// + /// Scope a load order query to Race + /// + /// ModListings to query + /// A typed object to do further queries on Race + public static TopLevelTypedLoadOrderAccess Race(this IEnumerable> listings) + { + return new TopLevelTypedLoadOrderAccess( + (bool includeDeletedRecords) => listings.WinningOverrides(includeDeletedRecords: includeDeletedRecords), + (ILinkCache linkCache, bool includeDeletedRecords) => listings.WinningContextOverrides(linkCache, includeDeletedRecords: includeDeletedRecords)); + } + + /// + /// Scope a load order query to Race + /// + /// Mods to query + /// A typed object to do further queries on Race + public static TopLevelTypedLoadOrderAccess Race(this IEnumerable mods) + { + return new TopLevelTypedLoadOrderAccess( + (bool includeDeletedRecords) => mods.WinningOverrides(includeDeletedRecords: includeDeletedRecords), + (ILinkCache linkCache, bool includeDeletedRecords) => mods.WinningContextOverrides(linkCache, includeDeletedRecords: includeDeletedRecords)); + } + + /// + /// Scope a load order query to StarfieldMajorRecord + /// + /// ModListings to query + /// A typed object to do further queries on StarfieldMajorRecord + public static TypedLoadOrderAccess StarfieldMajorRecord(this IEnumerable> listings) + { + return new TypedLoadOrderAccess( + (bool includeDeletedRecords) => listings.WinningOverrides(includeDeletedRecords: includeDeletedRecords), + (ILinkCache linkCache, bool includeDeletedRecords) => listings.WinningContextOverrides(linkCache, includeDeletedRecords: includeDeletedRecords)); + } + + /// + /// Scope a load order query to StarfieldMajorRecord + /// + /// Mods to query + /// A typed object to do further queries on StarfieldMajorRecord + public static TypedLoadOrderAccess StarfieldMajorRecord(this IEnumerable mods) + { + return new TypedLoadOrderAccess( + (bool includeDeletedRecords) => mods.WinningOverrides(includeDeletedRecords: includeDeletedRecords), + (ILinkCache linkCache, bool includeDeletedRecords) => mods.WinningContextOverrides(linkCache, includeDeletedRecords: includeDeletedRecords)); + } + + /// + /// Scope a load order query to Weapon + /// + /// ModListings to query + /// A typed object to do further queries on Weapon + public static TopLevelTypedLoadOrderAccess Weapon(this IEnumerable> listings) + { + return new TopLevelTypedLoadOrderAccess( + (bool includeDeletedRecords) => listings.WinningOverrides(includeDeletedRecords: includeDeletedRecords), + (ILinkCache linkCache, bool includeDeletedRecords) => listings.WinningContextOverrides(linkCache, includeDeletedRecords: includeDeletedRecords)); + } + + /// + /// Scope a load order query to Weapon + /// + /// Mods to query + /// A typed object to do further queries on Weapon + public static TopLevelTypedLoadOrderAccess Weapon(this IEnumerable mods) + { + return new TopLevelTypedLoadOrderAccess( + (bool includeDeletedRecords) => mods.WinningOverrides(includeDeletedRecords: includeDeletedRecords), + (ILinkCache linkCache, bool includeDeletedRecords) => mods.WinningContextOverrides(linkCache, includeDeletedRecords: includeDeletedRecords)); + } + + #endregion + + } +} diff --git a/Mutagen.Bethesda.Starfield/Records/Weapon.xml b/Mutagen.Bethesda.Starfield/Records/Weapon.xml new file mode 100644 index 0000000000..62bb625948 --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/Weapon.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Mutagen.Bethesda.Starfield/Records/Weapon_Generated.cs b/Mutagen.Bethesda.Starfield/Records/Weapon_Generated.cs new file mode 100644 index 0000000000..ae412a79ab --- /dev/null +++ b/Mutagen.Bethesda.Starfield/Records/Weapon_Generated.cs @@ -0,0 +1,1661 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Autogenerated by Loqui. Do not manually change. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ +#region Usings +using Loqui; +using Loqui.Interfaces; +using Loqui.Internal; +using Mutagen.Bethesda.Assets; +using Mutagen.Bethesda.Binary; +using Mutagen.Bethesda.Plugins; +using Mutagen.Bethesda.Plugins.Aspects; +using Mutagen.Bethesda.Plugins.Assets; +using Mutagen.Bethesda.Plugins.Binary.Headers; +using Mutagen.Bethesda.Plugins.Binary.Overlay; +using Mutagen.Bethesda.Plugins.Binary.Streams; +using Mutagen.Bethesda.Plugins.Binary.Translations; +using Mutagen.Bethesda.Plugins.Cache; +using Mutagen.Bethesda.Plugins.Exceptions; +using Mutagen.Bethesda.Plugins.Internals; +using Mutagen.Bethesda.Plugins.Records; +using Mutagen.Bethesda.Plugins.Records.Internals; +using Mutagen.Bethesda.Plugins.Records.Mapping; +using Mutagen.Bethesda.Plugins.RecordTypeMapping; +using Mutagen.Bethesda.Plugins.Utility; +using Mutagen.Bethesda.Starfield; +using Mutagen.Bethesda.Starfield.Internals; +using Mutagen.Bethesda.Translations.Binary; +using Noggog; +using Noggog.StructuredStrings; +using Noggog.StructuredStrings.CSharp; +using RecordTypeInts = Mutagen.Bethesda.Starfield.Internals.RecordTypeInts; +using RecordTypes = Mutagen.Bethesda.Starfield.Internals.RecordTypes; +using System.Buffers.Binary; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Reactive.Disposables; +using System.Reactive.Linq; +#endregion + +#nullable enable +namespace Mutagen.Bethesda.Starfield +{ + #region Class + public partial class Weapon : + StarfieldMajorRecord, + IEquatable, + ILoquiObjectSetter, + IWeaponInternal + { + #region Ctor + protected Weapon() + { + CustomCtor(); + } + partial void CustomCtor(); + #endregion + + #region Model + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private Model? _Model; + /// + /// Aspects: IModeled + /// + public Model? Model + { + get => _Model; + set => _Model = value; + } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IModelGetter? IWeaponGetter.Model => this.Model; + #region Aspects + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + IModelGetter? IModeledGetter.Model => this.Model; + #endregion + #endregion + + #region To String + + public override void Print( + StructuredStringBuilder sb, + string? name = null) + { + WeaponMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + #region Mask + public new class Mask : + StarfieldMajorRecord.Mask, + IEquatable>, + IMask + { + #region Ctors + public Mask(TItem initialValue) + : base(initialValue) + { + this.Model = new MaskItem?>(initialValue, new Model.Mask(initialValue)); + } + + public Mask( + TItem MajorRecordFlagsRaw, + TItem FormKey, + TItem VersionControl, + TItem EditorID, + TItem FormVersion, + TItem Version2, + TItem StarfieldMajorRecordFlags, + TItem Model) + : base( + MajorRecordFlagsRaw: MajorRecordFlagsRaw, + FormKey: FormKey, + VersionControl: VersionControl, + EditorID: EditorID, + FormVersion: FormVersion, + Version2: Version2, + StarfieldMajorRecordFlags: StarfieldMajorRecordFlags) + { + this.Model = new MaskItem?>(Model, new Model.Mask(Model)); + } + + #pragma warning disable CS8618 + protected Mask() + { + } + #pragma warning restore CS8618 + + #endregion + + #region Members + public MaskItem?>? Model { get; set; } + #endregion + + #region Equals + public override bool Equals(object? obj) + { + if (!(obj is Mask rhs)) return false; + return Equals(rhs); + } + + public bool Equals(Mask? rhs) + { + if (rhs == null) return false; + if (!base.Equals(rhs)) return false; + if (!object.Equals(this.Model, rhs.Model)) return false; + return true; + } + public override int GetHashCode() + { + var hash = new HashCode(); + hash.Add(this.Model); + hash.Add(base.GetHashCode()); + return hash.ToHashCode(); + } + + #endregion + + #region All + public override bool All(Func eval) + { + if (!base.All(eval)) return false; + if (Model != null) + { + if (!eval(this.Model.Overall)) return false; + if (this.Model.Specific != null && !this.Model.Specific.All(eval)) return false; + } + return true; + } + #endregion + + #region Any + public override bool Any(Func eval) + { + if (base.Any(eval)) return true; + if (Model != null) + { + if (eval(this.Model.Overall)) return true; + if (this.Model.Specific != null && this.Model.Specific.Any(eval)) return true; + } + return false; + } + #endregion + + #region Translate + public new Mask Translate(Func eval) + { + var ret = new Weapon.Mask(); + this.Translate_InternalFill(ret, eval); + return ret; + } + + protected void Translate_InternalFill(Mask obj, Func eval) + { + base.Translate_InternalFill(obj, eval); + obj.Model = this.Model == null ? null : new MaskItem?>(eval(this.Model.Overall), this.Model.Specific?.Translate(eval)); + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public string Print(Weapon.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print(sb, printMask); + return sb.ToString(); + } + + public void Print(StructuredStringBuilder sb, Weapon.Mask? printMask = null) + { + sb.AppendLine($"{nameof(Weapon.Mask)} =>"); + using (sb.Brace()) + { + if (printMask?.Model?.Overall ?? true) + { + Model?.Print(sb); + } + } + } + #endregion + + } + + public new class ErrorMask : + StarfieldMajorRecord.ErrorMask, + IErrorMask + { + #region Members + public MaskItem? Model; + #endregion + + #region IErrorMask + public override object? GetNthMask(int index) + { + Weapon_FieldIndex enu = (Weapon_FieldIndex)index; + switch (enu) + { + case Weapon_FieldIndex.Model: + return Model; + default: + return base.GetNthMask(index); + } + } + + public override void SetNthException(int index, Exception ex) + { + Weapon_FieldIndex enu = (Weapon_FieldIndex)index; + switch (enu) + { + case Weapon_FieldIndex.Model: + this.Model = new MaskItem(ex, null); + break; + default: + base.SetNthException(index, ex); + break; + } + } + + public override void SetNthMask(int index, object obj) + { + Weapon_FieldIndex enu = (Weapon_FieldIndex)index; + switch (enu) + { + case Weapon_FieldIndex.Model: + this.Model = (MaskItem?)obj; + break; + default: + base.SetNthMask(index, obj); + break; + } + } + + public override bool IsInError() + { + if (Overall != null) return true; + if (Model != null) return true; + return false; + } + #endregion + + #region To String + public override string ToString() => this.Print(); + + public override void Print(StructuredStringBuilder sb, string? name = null) + { + sb.AppendLine($"{(name ?? "ErrorMask")} =>"); + using (sb.Brace()) + { + if (this.Overall != null) + { + sb.AppendLine("Overall =>"); + using (sb.Brace()) + { + sb.AppendLine($"{this.Overall}"); + } + } + PrintFillInternal(sb); + } + } + protected override void PrintFillInternal(StructuredStringBuilder sb) + { + base.PrintFillInternal(sb); + Model?.Print(sb); + } + #endregion + + #region Combine + public ErrorMask Combine(ErrorMask? rhs) + { + if (rhs == null) return this; + var ret = new ErrorMask(); + ret.Model = this.Model.Combine(rhs.Model, (l, r) => l.Combine(r)); + return ret; + } + public static ErrorMask? Combine(ErrorMask? lhs, ErrorMask? rhs) + { + if (lhs != null && rhs != null) return lhs.Combine(rhs); + return lhs ?? rhs; + } + #endregion + + #region Factory + public static new ErrorMask Factory(ErrorMaskBuilder errorMask) + { + return new ErrorMask(); + } + #endregion + + } + public new class TranslationMask : + StarfieldMajorRecord.TranslationMask, + ITranslationMask + { + #region Members + public Model.TranslationMask? Model; + #endregion + + #region Ctors + public TranslationMask( + bool defaultOn, + bool onOverall = true) + : base(defaultOn, onOverall) + { + } + + #endregion + + protected override void GetCrystal(List<(bool On, TranslationCrystal? SubCrystal)> ret) + { + base.GetCrystal(ret); + ret.Add((Model != null ? Model.OnOverall : DefaultOn, Model?.GetCrystal())); + } + + public static implicit operator TranslationMask(bool defaultOn) + { + return new TranslationMask(defaultOn: defaultOn, onOverall: defaultOn); + } + + } + #endregion + + #region Mutagen + public static readonly RecordType GrupRecordType = Weapon_Registration.TriggeringRecordType; + public Weapon(FormKey formKey) + { + this.FormKey = formKey; + this.FormVersion = GameRelease.Starfield.GetDefaultFormVersion()!.Value; + CustomCtor(); + } + + private Weapon( + FormKey formKey, + GameRelease gameRelease) + { + this.FormKey = formKey; + this.FormVersion = gameRelease.GetDefaultFormVersion()!.Value; + CustomCtor(); + } + + internal Weapon( + FormKey formKey, + ushort formVersion) + { + this.FormKey = formKey; + this.FormVersion = formVersion; + CustomCtor(); + } + + public Weapon(IStarfieldMod mod) + : this(mod.GetNextFormKey()) + { + } + + public Weapon(IStarfieldMod mod, string editorID) + : this(mod.GetNextFormKey(editorID)) + { + this.EditorID = editorID; + } + + public override string ToString() + { + return MajorRecordPrinter.ToString(this); + } + + protected override Type LinkType => typeof(IWeapon); + + public override IEnumerable EnumerateAssetLinks(AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) => WeaponCommon.Instance.EnumerateAssetLinks(this, queryCategories, linkCache, assetType); + public override IEnumerable EnumerateListedAssetLinks() => WeaponSetterCommon.Instance.EnumerateListedAssetLinks(this); + public override void RemapAssetLinks(IReadOnlyDictionary mapping, AssetLinkQuery queryCategories, IAssetLinkCache? linkCache) => WeaponSetterCommon.Instance.RemapAssetLinks(this, mapping, linkCache, queryCategories); + public override void RemapListedAssetLinks(IReadOnlyDictionary mapping) => WeaponSetterCommon.Instance.RemapAssetLinks(this, mapping, null, AssetLinkQuery.Listed); + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is IFormLinkGetter formLink) + { + return formLink.Equals(this); + } + if (obj is not IWeaponGetter rhs) return false; + return ((WeaponCommon)((IWeaponGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IWeaponGetter? obj) + { + return ((WeaponCommon)((IWeaponGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((WeaponCommon)((IWeaponGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + #endregion + + #region Binary Translation + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected override object BinaryWriteTranslator => WeaponBinaryWriteTranslation.Instance; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((WeaponBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + #region Binary Create + public new static Weapon CreateFromBinary( + MutagenFrame frame, + TypedParseParams translationParams = default) + { + var ret = new Weapon(); + ((WeaponSetterCommon)((IWeaponGetter)ret).CommonSetterInstance()!).CopyInFromBinary( + item: ret, + frame: frame, + translationParams: translationParams); + return ret; + } + + #endregion + + public static bool TryCreateFromBinary( + MutagenFrame frame, + out Weapon item, + TypedParseParams translationParams = default) + { + var startPos = frame.Position; + item = CreateFromBinary( + frame: frame, + translationParams: translationParams); + return startPos != frame.Position; + } + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + void IClearable.Clear() + { + ((WeaponSetterCommon)((IWeaponGetter)this).CommonSetterInstance()!).Clear(this); + } + + internal static new Weapon GetNew() + { + return new Weapon(); + } + + } + #endregion + + #region Interface + public partial interface IWeapon : + IAssetLinkContainer, + ILoquiObjectSetter, + IModeled, + IStarfieldMajorRecordInternal, + IWeaponGetter + { + /// + /// Aspects: IModeled + /// + new Model? Model { get; set; } + } + + public partial interface IWeaponInternal : + IStarfieldMajorRecordInternal, + IWeapon, + IWeaponGetter + { + } + + [AssociatedRecordTypesAttribute(Mutagen.Bethesda.Starfield.Internals.RecordTypeInts.WEAP)] + public partial interface IWeaponGetter : + IStarfieldMajorRecordGetter, + IAssetLinkContainerGetter, + IBinaryItem, + ILoquiObject, + IMapsToGetter, + IModeledGetter + { + static new ILoquiRegistration StaticRegistration => Weapon_Registration.Instance; + #region Model + /// + /// Aspects: IModeledGetter + /// + IModelGetter? Model { get; } + #endregion + + } + + #endregion + + #region Common MixIn + public static partial class WeaponMixIn + { + public static void Clear(this IWeaponInternal item) + { + ((WeaponSetterCommon)((IWeaponGetter)item).CommonSetterInstance()!).Clear(item: item); + } + + public static Weapon.Mask GetEqualsMask( + this IWeaponGetter item, + IWeaponGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + return ((WeaponCommon)((IWeaponGetter)item).CommonInstance()!).GetEqualsMask( + item: item, + rhs: rhs, + include: include); + } + + public static string Print( + this IWeaponGetter item, + string? name = null, + Weapon.Mask? printMask = null) + { + return ((WeaponCommon)((IWeaponGetter)item).CommonInstance()!).Print( + item: item, + name: name, + printMask: printMask); + } + + public static void Print( + this IWeaponGetter item, + StructuredStringBuilder sb, + string? name = null, + Weapon.Mask? printMask = null) + { + ((WeaponCommon)((IWeaponGetter)item).CommonInstance()!).Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + } + + public static bool Equals( + this IWeaponGetter item, + IWeaponGetter rhs, + Weapon.TranslationMask? equalsMask = null) + { + return ((WeaponCommon)((IWeaponGetter)item).CommonInstance()!).Equals( + lhs: item, + rhs: rhs, + equalsMask: equalsMask?.GetCrystal()); + } + + public static void DeepCopyIn( + this IWeaponInternal lhs, + IWeaponGetter rhs, + out Weapon.ErrorMask errorMask, + Weapon.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + ((WeaponSetterTranslationCommon)((IWeaponGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: false); + errorMask = Weapon.ErrorMask.Factory(errorMaskBuilder); + } + + public static void DeepCopyIn( + this IWeaponInternal lhs, + IWeaponGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask) + { + ((WeaponSetterTranslationCommon)((IWeaponGetter)lhs).CommonSetterTranslationInstance()!).DeepCopyIn( + item: lhs, + rhs: rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: false); + } + + public static Weapon DeepCopy( + this IWeaponGetter item, + Weapon.TranslationMask? copyMask = null) + { + return ((WeaponSetterTranslationCommon)((IWeaponGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask); + } + + public static Weapon DeepCopy( + this IWeaponGetter item, + out Weapon.ErrorMask errorMask, + Weapon.TranslationMask? copyMask = null) + { + return ((WeaponSetterTranslationCommon)((IWeaponGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: out errorMask); + } + + public static Weapon DeepCopy( + this IWeaponGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + return ((WeaponSetterTranslationCommon)((IWeaponGetter)item).CommonSetterTranslationInstance()!).DeepCopy( + item: item, + copyMask: copyMask, + errorMask: errorMask); + } + + #region Mutagen + public static Weapon Duplicate( + this IWeaponGetter item, + FormKey formKey, + Weapon.TranslationMask? copyMask = null) + { + return ((WeaponCommon)((IWeaponGetter)item).CommonInstance()!).Duplicate( + item: item, + formKey: formKey, + copyMask: copyMask?.GetCrystal()); + } + + public static Weapon Duplicate( + this IWeaponGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + return ((WeaponCommon)((IWeaponGetter)item).CommonInstance()!).Duplicate( + item: item, + formKey: formKey, + copyMask: copyMask); + } + + #endregion + + #region Binary Translation + public static void CopyInFromBinary( + this IWeaponInternal item, + MutagenFrame frame, + TypedParseParams translationParams = default) + { + ((WeaponSetterCommon)((IWeaponGetter)item).CommonSetterInstance()!).CopyInFromBinary( + item: item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + #region Field Index + internal enum Weapon_FieldIndex + { + MajorRecordFlagsRaw = 0, + FormKey = 1, + VersionControl = 2, + EditorID = 3, + FormVersion = 4, + Version2 = 5, + StarfieldMajorRecordFlags = 6, + Model = 7, + } + #endregion + + #region Registration + internal partial class Weapon_Registration : ILoquiRegistration + { + public static readonly Weapon_Registration Instance = new Weapon_Registration(); + + public static ProtocolKey ProtocolKey => ProtocolDefinition_Starfield.ProtocolKey; + + public static readonly ObjectKey ObjectKey = new ObjectKey( + protocolKey: ProtocolDefinition_Starfield.ProtocolKey, + msgID: 69, + version: 0); + + public const string GUID = "28054fa6-f5f2-4fa5-965a-280c2ba06910"; + + public const ushort AdditionalFieldCount = 1; + + public const ushort FieldCount = 8; + + public static readonly Type MaskType = typeof(Weapon.Mask<>); + + public static readonly Type ErrorMaskType = typeof(Weapon.ErrorMask); + + public static readonly Type ClassType = typeof(Weapon); + + public static readonly Type GetterType = typeof(IWeaponGetter); + + public static readonly Type? InternalGetterType = null; + + public static readonly Type SetterType = typeof(IWeapon); + + public static readonly Type? InternalSetterType = typeof(IWeaponInternal); + + public const string FullName = "Mutagen.Bethesda.Starfield.Weapon"; + + public const string Name = "Weapon"; + + public const string Namespace = "Mutagen.Bethesda.Starfield"; + + public const byte GenericCount = 0; + + public static readonly Type? GenericRegistrationType = null; + + public static readonly RecordType TriggeringRecordType = RecordTypes.WEAP; + public static RecordTriggerSpecs TriggerSpecs => _recordSpecs.Value; + private static readonly Lazy _recordSpecs = new Lazy(() => + { + var triggers = RecordCollection.Factory(RecordTypes.WEAP); + var all = RecordCollection.Factory( + RecordTypes.WEAP, + RecordTypes.MODL); + return new RecordTriggerSpecs(allRecordTypes: all, triggeringRecordTypes: triggers); + }); + public static readonly Type BinaryWriteTranslation = typeof(WeaponBinaryWriteTranslation); + #region Interface + ProtocolKey ILoquiRegistration.ProtocolKey => ProtocolKey; + ObjectKey ILoquiRegistration.ObjectKey => ObjectKey; + string ILoquiRegistration.GUID => GUID; + ushort ILoquiRegistration.FieldCount => FieldCount; + ushort ILoquiRegistration.AdditionalFieldCount => AdditionalFieldCount; + Type ILoquiRegistration.MaskType => MaskType; + Type ILoquiRegistration.ErrorMaskType => ErrorMaskType; + Type ILoquiRegistration.ClassType => ClassType; + Type ILoquiRegistration.SetterType => SetterType; + Type? ILoquiRegistration.InternalSetterType => InternalSetterType; + Type ILoquiRegistration.GetterType => GetterType; + Type? ILoquiRegistration.InternalGetterType => InternalGetterType; + string ILoquiRegistration.FullName => FullName; + string ILoquiRegistration.Name => Name; + string ILoquiRegistration.Namespace => Namespace; + byte ILoquiRegistration.GenericCount => GenericCount; + Type? ILoquiRegistration.GenericRegistrationType => GenericRegistrationType; + ushort? ILoquiRegistration.GetNameIndex(StringCaseAgnostic name) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsEnumerable(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsLoqui(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.GetNthIsSingleton(ushort index) => throw new NotImplementedException(); + string ILoquiRegistration.GetNthName(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsNthDerivative(ushort index) => throw new NotImplementedException(); + bool ILoquiRegistration.IsProtected(ushort index) => throw new NotImplementedException(); + Type ILoquiRegistration.GetNthType(ushort index) => throw new NotImplementedException(); + #endregion + + } + #endregion + + #region Common + internal partial class WeaponSetterCommon : StarfieldMajorRecordSetterCommon + { + public new static readonly WeaponSetterCommon Instance = new WeaponSetterCommon(); + + partial void ClearPartial(); + + public void Clear(IWeaponInternal item) + { + ClearPartial(); + item.Model = null; + base.Clear(item); + } + + public override void Clear(IStarfieldMajorRecordInternal item) + { + Clear(item: (IWeaponInternal)item); + } + + public override void Clear(IMajorRecordInternal item) + { + Clear(item: (IWeaponInternal)item); + } + + #region Mutagen + public void RemapLinks(IWeapon obj, IReadOnlyDictionary mapping) + { + base.RemapLinks(obj, mapping); + } + + public IEnumerable EnumerateListedAssetLinks(IWeapon obj) + { + foreach (var item in base.EnumerateListedAssetLinks(obj)) + { + yield return item; + } + if (obj.Model is {} ModelItems) + { + foreach (var item in ModelItems.EnumerateListedAssetLinks()) + { + yield return item; + } + } + yield break; + } + + public void RemapAssetLinks( + IWeapon obj, + IReadOnlyDictionary mapping, + IAssetLinkCache? linkCache, + AssetLinkQuery queryCategories) + { + base.RemapAssetLinks(obj, mapping, linkCache, queryCategories); + obj.Model?.RemapAssetLinks(mapping, queryCategories, linkCache); + } + + #endregion + + #region Binary Translation + public virtual void CopyInFromBinary( + IWeaponInternal item, + MutagenFrame frame, + TypedParseParams translationParams) + { + PluginUtilityTranslation.MajorRecordParse( + record: item, + frame: frame, + translationParams: translationParams, + fillStructs: WeaponBinaryCreateTranslation.FillBinaryStructs, + fillTyped: WeaponBinaryCreateTranslation.FillBinaryRecordTypes); + } + + public override void CopyInFromBinary( + IStarfieldMajorRecordInternal item, + MutagenFrame frame, + TypedParseParams translationParams) + { + CopyInFromBinary( + item: (Weapon)item, + frame: frame, + translationParams: translationParams); + } + + public override void CopyInFromBinary( + IMajorRecordInternal item, + MutagenFrame frame, + TypedParseParams translationParams) + { + CopyInFromBinary( + item: (Weapon)item, + frame: frame, + translationParams: translationParams); + } + + #endregion + + } + internal partial class WeaponCommon : StarfieldMajorRecordCommon + { + public new static readonly WeaponCommon Instance = new WeaponCommon(); + + public Weapon.Mask GetEqualsMask( + IWeaponGetter item, + IWeaponGetter rhs, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + var ret = new Weapon.Mask(false); + ((WeaponCommon)((IWeaponGetter)item).CommonInstance()!).FillEqualsMask( + item: item, + rhs: rhs, + ret: ret, + include: include); + return ret; + } + + public void FillEqualsMask( + IWeaponGetter item, + IWeaponGetter rhs, + Weapon.Mask ret, + EqualsMaskHelper.Include include = EqualsMaskHelper.Include.All) + { + ret.Model = EqualsMaskHelper.EqualsHelper( + item.Model, + rhs.Model, + (loqLhs, loqRhs, incl) => loqLhs.GetEqualsMask(loqRhs, incl), + include); + base.FillEqualsMask(item, rhs, ret, include); + } + + public string Print( + IWeaponGetter item, + string? name = null, + Weapon.Mask? printMask = null) + { + var sb = new StructuredStringBuilder(); + Print( + item: item, + sb: sb, + name: name, + printMask: printMask); + return sb.ToString(); + } + + public void Print( + IWeaponGetter item, + StructuredStringBuilder sb, + string? name = null, + Weapon.Mask? printMask = null) + { + if (name == null) + { + sb.AppendLine($"Weapon =>"); + } + else + { + sb.AppendLine($"{name} (Weapon) =>"); + } + using (sb.Brace()) + { + ToStringFields( + item: item, + sb: sb, + printMask: printMask); + } + } + + protected static void ToStringFields( + IWeaponGetter item, + StructuredStringBuilder sb, + Weapon.Mask? printMask = null) + { + StarfieldMajorRecordCommon.ToStringFields( + item: item, + sb: sb, + printMask: printMask); + if ((printMask?.Model?.Overall ?? true) + && item.Model is {} ModelItem) + { + ModelItem?.Print(sb, "Model"); + } + } + + public static Weapon_FieldIndex ConvertFieldIndex(StarfieldMajorRecord_FieldIndex index) + { + switch (index) + { + case StarfieldMajorRecord_FieldIndex.MajorRecordFlagsRaw: + return (Weapon_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.FormKey: + return (Weapon_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.VersionControl: + return (Weapon_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.EditorID: + return (Weapon_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.FormVersion: + return (Weapon_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.Version2: + return (Weapon_FieldIndex)((int)index); + case StarfieldMajorRecord_FieldIndex.StarfieldMajorRecordFlags: + return (Weapon_FieldIndex)((int)index); + default: + throw new ArgumentException($"Index is out of range: {index.ToStringFast()}"); + } + } + + public static new Weapon_FieldIndex ConvertFieldIndex(MajorRecord_FieldIndex index) + { + switch (index) + { + case MajorRecord_FieldIndex.MajorRecordFlagsRaw: + return (Weapon_FieldIndex)((int)index); + case MajorRecord_FieldIndex.FormKey: + return (Weapon_FieldIndex)((int)index); + case MajorRecord_FieldIndex.VersionControl: + return (Weapon_FieldIndex)((int)index); + case MajorRecord_FieldIndex.EditorID: + return (Weapon_FieldIndex)((int)index); + default: + throw new ArgumentException($"Index is out of range: {index.ToStringFast()}"); + } + } + + #region Equals and Hash + public virtual bool Equals( + IWeaponGetter? lhs, + IWeaponGetter? rhs, + TranslationCrystal? equalsMask) + { + if (!EqualsMaskHelper.RefEquality(lhs, rhs, out var isEqual)) return isEqual; + if (!base.Equals((IStarfieldMajorRecordGetter)lhs, (IStarfieldMajorRecordGetter)rhs, equalsMask)) return false; + if ((equalsMask?.GetShouldTranslate((int)Weapon_FieldIndex.Model) ?? true)) + { + if (EqualsMaskHelper.RefEquality(lhs.Model, rhs.Model, out var lhsModel, out var rhsModel, out var isModelEqual)) + { + if (!((ModelCommon)((IModelGetter)lhsModel).CommonInstance()!).Equals(lhsModel, rhsModel, equalsMask?.GetSubCrystal((int)Weapon_FieldIndex.Model))) return false; + } + else if (!isModelEqual) return false; + } + return true; + } + + public override bool Equals( + IStarfieldMajorRecordGetter? lhs, + IStarfieldMajorRecordGetter? rhs, + TranslationCrystal? equalsMask) + { + return Equals( + lhs: (IWeaponGetter?)lhs, + rhs: rhs as IWeaponGetter, + equalsMask: equalsMask); + } + + public override bool Equals( + IMajorRecordGetter? lhs, + IMajorRecordGetter? rhs, + TranslationCrystal? equalsMask) + { + return Equals( + lhs: (IWeaponGetter?)lhs, + rhs: rhs as IWeaponGetter, + equalsMask: equalsMask); + } + + public virtual int GetHashCode(IWeaponGetter item) + { + var hash = new HashCode(); + if (item.Model is {} Modelitem) + { + hash.Add(Modelitem); + } + hash.Add(base.GetHashCode()); + return hash.ToHashCode(); + } + + public override int GetHashCode(IStarfieldMajorRecordGetter item) + { + return GetHashCode(item: (IWeaponGetter)item); + } + + public override int GetHashCode(IMajorRecordGetter item) + { + return GetHashCode(item: (IWeaponGetter)item); + } + + #endregion + + + public override object GetNew() + { + return Weapon.GetNew(); + } + + #region Mutagen + public IEnumerable EnumerateFormLinks(IWeaponGetter obj) + { + foreach (var item in base.EnumerateFormLinks(obj)) + { + yield return item; + } + yield break; + } + + public IEnumerable EnumerateAssetLinks(IWeaponGetter obj, AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) + { + foreach (var item in base.EnumerateAssetLinks(obj, queryCategories, linkCache, assetType)) + { + yield return item; + } + if (queryCategories.HasFlag(AssetLinkQuery.Listed)) + { + if (obj.Model is {} ModelItems) + { + foreach (var item in ModelItems.EnumerateAssetLinks(queryCategories: queryCategories, linkCache: linkCache, assetType: assetType)) + { + yield return item; + } + } + } + yield break; + } + + #region Duplicate + public Weapon Duplicate( + IWeaponGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + var newRec = new Weapon(formKey); + newRec.DeepCopyIn(item, default(ErrorMaskBuilder?), copyMask); + return newRec; + } + + public override StarfieldMajorRecord Duplicate( + IStarfieldMajorRecordGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + return this.Duplicate( + item: (IWeaponGetter)item, + formKey: formKey, + copyMask: copyMask); + } + + public override MajorRecord Duplicate( + IMajorRecordGetter item, + FormKey formKey, + TranslationCrystal? copyMask) + { + return this.Duplicate( + item: (IWeaponGetter)item, + formKey: formKey, + copyMask: copyMask); + } + + #endregion + + #endregion + + } + internal partial class WeaponSetterTranslationCommon : StarfieldMajorRecordSetterTranslationCommon + { + public new static readonly WeaponSetterTranslationCommon Instance = new WeaponSetterTranslationCommon(); + + #region DeepCopyIn + public void DeepCopyIn( + IWeaponInternal item, + IWeaponGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + base.DeepCopyIn( + item, + rhs, + errorMask, + copyMask, + deepCopy: deepCopy); + } + + public void DeepCopyIn( + IWeapon item, + IWeaponGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + base.DeepCopyIn( + (IStarfieldMajorRecord)item, + (IStarfieldMajorRecordGetter)rhs, + errorMask, + copyMask, + deepCopy: deepCopy); + if ((copyMask?.GetShouldTranslate((int)Weapon_FieldIndex.Model) ?? true)) + { + errorMask?.PushIndex((int)Weapon_FieldIndex.Model); + try + { + if(rhs.Model is {} rhsModel) + { + item.Model = rhsModel.DeepCopy( + errorMask: errorMask, + copyMask?.GetSubCrystal((int)Weapon_FieldIndex.Model)); + } + else + { + item.Model = default; + } + } + catch (Exception ex) + when (errorMask != null) + { + errorMask.ReportException(ex); + } + finally + { + errorMask?.PopIndex(); + } + } + } + + public override void DeepCopyIn( + IStarfieldMajorRecordInternal item, + IStarfieldMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (IWeaponInternal)item, + rhs: (IWeaponGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + public override void DeepCopyIn( + IStarfieldMajorRecord item, + IStarfieldMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (IWeapon)item, + rhs: (IWeaponGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + public override void DeepCopyIn( + IMajorRecordInternal item, + IMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (IWeaponInternal)item, + rhs: (IWeaponGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + public override void DeepCopyIn( + IMajorRecord item, + IMajorRecordGetter rhs, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask, + bool deepCopy) + { + this.DeepCopyIn( + item: (IWeapon)item, + rhs: (IWeaponGetter)rhs, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: deepCopy); + } + + #endregion + + public Weapon DeepCopy( + IWeaponGetter item, + Weapon.TranslationMask? copyMask = null) + { + Weapon ret = (Weapon)((WeaponCommon)((IWeaponGetter)item).CommonInstance()!).GetNew(); + ((WeaponSetterTranslationCommon)((IWeaponGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: null, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + return ret; + } + + public Weapon DeepCopy( + IWeaponGetter item, + out Weapon.ErrorMask errorMask, + Weapon.TranslationMask? copyMask = null) + { + var errorMaskBuilder = new ErrorMaskBuilder(); + Weapon ret = (Weapon)((WeaponCommon)((IWeaponGetter)item).CommonInstance()!).GetNew(); + ((WeaponSetterTranslationCommon)((IWeaponGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + ret, + item, + errorMask: errorMaskBuilder, + copyMask: copyMask?.GetCrystal(), + deepCopy: true); + errorMask = Weapon.ErrorMask.Factory(errorMaskBuilder); + return ret; + } + + public Weapon DeepCopy( + IWeaponGetter item, + ErrorMaskBuilder? errorMask, + TranslationCrystal? copyMask = null) + { + Weapon ret = (Weapon)((WeaponCommon)((IWeaponGetter)item).CommonInstance()!).GetNew(); + ((WeaponSetterTranslationCommon)((IWeaponGetter)ret).CommonSetterTranslationInstance()!).DeepCopyIn( + item: ret, + rhs: item, + errorMask: errorMask, + copyMask: copyMask, + deepCopy: true); + return ret; + } + + } + #endregion + +} + +namespace Mutagen.Bethesda.Starfield +{ + public partial class Weapon + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => Weapon_Registration.Instance; + public new static ILoquiRegistration StaticRegistration => Weapon_Registration.Instance; + [DebuggerStepThrough] + protected override object CommonInstance() => WeaponCommon.Instance; + [DebuggerStepThrough] + protected override object CommonSetterInstance() + { + return WeaponSetterCommon.Instance; + } + [DebuggerStepThrough] + protected override object CommonSetterTranslationInstance() => WeaponSetterTranslationCommon.Instance; + + #endregion + + } +} + +#region Modules +#region Binary Translation +namespace Mutagen.Bethesda.Starfield +{ + public partial class WeaponBinaryWriteTranslation : + StarfieldMajorRecordBinaryWriteTranslation, + IBinaryWriteTranslator + { + public new static readonly WeaponBinaryWriteTranslation Instance = new(); + + public static void WriteRecordTypes( + IWeaponGetter item, + MutagenWriter writer, + TypedWriteParams translationParams) + { + MajorRecordBinaryWriteTranslation.WriteRecordTypes( + item: item, + writer: writer, + translationParams: translationParams); + if (item.Model is {} ModelItem) + { + ((ModelBinaryWriteTranslation)((IBinaryItem)ModelItem).BinaryWriteTranslator).Write( + item: ModelItem, + writer: writer, + translationParams: translationParams); + } + } + + public void Write( + MutagenWriter writer, + IWeaponGetter item, + TypedWriteParams translationParams) + { + using (HeaderExport.Record( + writer: writer, + record: translationParams.ConvertToCustom(RecordTypes.WEAP))) + { + try + { + StarfieldMajorRecordBinaryWriteTranslation.WriteEmbedded( + item: item, + writer: writer); + if (!item.IsDeleted) + { + writer.MetaData.FormVersion = item.FormVersion; + WriteRecordTypes( + item: item, + writer: writer, + translationParams: translationParams); + writer.MetaData.FormVersion = null; + } + } + catch (Exception ex) + { + throw RecordException.Enrich(ex, item); + } + } + } + + public override void Write( + MutagenWriter writer, + object item, + TypedWriteParams translationParams = default) + { + Write( + item: (IWeaponGetter)item, + writer: writer, + translationParams: translationParams); + } + + public override void Write( + MutagenWriter writer, + IStarfieldMajorRecordGetter item, + TypedWriteParams translationParams) + { + Write( + item: (IWeaponGetter)item, + writer: writer, + translationParams: translationParams); + } + + public override void Write( + MutagenWriter writer, + IMajorRecordGetter item, + TypedWriteParams translationParams) + { + Write( + item: (IWeaponGetter)item, + writer: writer, + translationParams: translationParams); + } + + } + + internal partial class WeaponBinaryCreateTranslation : StarfieldMajorRecordBinaryCreateTranslation + { + public new static readonly WeaponBinaryCreateTranslation Instance = new WeaponBinaryCreateTranslation(); + + public override RecordType RecordType => RecordTypes.WEAP; + public static ParseResult FillBinaryRecordTypes( + IWeaponInternal item, + MutagenFrame frame, + PreviousParse lastParsed, + Dictionary? recordParseCount, + RecordType nextRecordType, + int contentLength, + TypedParseParams translationParams = default) + { + nextRecordType = translationParams.ConvertToStandard(nextRecordType); + switch (nextRecordType.TypeInt) + { + case RecordTypeInts.MODL: + { + item.Model = Mutagen.Bethesda.Starfield.Model.CreateFromBinary( + frame: frame, + translationParams: translationParams.DoNotShortCircuit()); + return (int)Weapon_FieldIndex.Model; + } + default: + return StarfieldMajorRecordBinaryCreateTranslation.FillBinaryRecordTypes( + item: item, + frame: frame, + lastParsed: lastParsed, + recordParseCount: recordParseCount, + nextRecordType: nextRecordType, + contentLength: contentLength, + translationParams: translationParams.WithNoConverter()); + } + } + + } + +} +namespace Mutagen.Bethesda.Starfield +{ + #region Binary Write Mixins + public static class WeaponBinaryTranslationMixIn + { + } + #endregion + + +} +namespace Mutagen.Bethesda.Starfield +{ + internal partial class WeaponBinaryOverlay : + StarfieldMajorRecordBinaryOverlay, + IWeaponGetter + { + #region Common Routing + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + ILoquiRegistration ILoquiObject.Registration => Weapon_Registration.Instance; + public new static ILoquiRegistration StaticRegistration => Weapon_Registration.Instance; + [DebuggerStepThrough] + protected override object CommonInstance() => WeaponCommon.Instance; + [DebuggerStepThrough] + protected override object CommonSetterTranslationInstance() => WeaponSetterTranslationCommon.Instance; + + #endregion + + void IPrintable.Print(StructuredStringBuilder sb, string? name) => this.Print(sb, name); + + public override IEnumerable EnumerateAssetLinks(AssetLinkQuery queryCategories, IAssetLinkCache? linkCache, Type? assetType) => WeaponCommon.Instance.EnumerateAssetLinks(this, queryCategories, linkCache, assetType); + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + protected override object BinaryWriteTranslator => WeaponBinaryWriteTranslation.Instance; + void IBinaryItem.WriteToBinary( + MutagenWriter writer, + TypedWriteParams translationParams = default) + { + ((WeaponBinaryWriteTranslation)this.BinaryWriteTranslator).Write( + item: this, + writer: writer, + translationParams: translationParams); + } + protected override Type LinkType => typeof(IWeapon); + + + public IModelGetter? Model { get; private set; } + partial void CustomFactoryEnd( + OverlayStream stream, + int finalPos, + int offset); + + partial void CustomCtor(); + protected WeaponBinaryOverlay( + MemoryPair memoryPair, + BinaryOverlayFactoryPackage package) + : base( + memoryPair: memoryPair, + package: package) + { + this.CustomCtor(); + } + + public static IWeaponGetter WeaponFactory( + OverlayStream stream, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + stream = Decompression.DecompressStream(stream); + stream = ExtractRecordMemory( + stream: stream, + meta: package.MetaData.Constants, + memoryPair: out var memoryPair, + offset: out var offset, + finalPos: out var finalPos); + var ret = new WeaponBinaryOverlay( + memoryPair: memoryPair, + package: package); + ret._package.FormVersion = ret; + ret.CustomFactoryEnd( + stream: stream, + finalPos: finalPos, + offset: offset); + ret.FillSubrecordTypes( + majorReference: ret, + stream: stream, + finalPos: finalPos, + offset: offset, + translationParams: translationParams, + fill: ret.FillRecordType); + return ret; + } + + public static IWeaponGetter WeaponFactory( + ReadOnlyMemorySlice slice, + BinaryOverlayFactoryPackage package, + TypedParseParams translationParams = default) + { + return WeaponFactory( + stream: new OverlayStream(slice, package), + package: package, + translationParams: translationParams); + } + + public override ParseResult FillRecordType( + OverlayStream stream, + int finalPos, + int offset, + RecordType type, + PreviousParse lastParsed, + Dictionary? recordParseCount, + TypedParseParams translationParams = default) + { + type = translationParams.ConvertToStandard(type); + switch (type.TypeInt) + { + case RecordTypeInts.MODL: + { + this.Model = ModelBinaryOverlay.ModelFactory( + stream: stream, + package: _package, + translationParams: translationParams.DoNotShortCircuit()); + return (int)Weapon_FieldIndex.Model; + } + default: + return base.FillRecordType( + stream: stream, + finalPos: finalPos, + offset: offset, + type: type, + lastParsed: lastParsed, + recordParseCount: recordParseCount, + translationParams: translationParams.WithNoConverter()); + } + } + #region To String + + public override void Print( + StructuredStringBuilder sb, + string? name = null) + { + WeaponMixIn.Print( + item: this, + sb: sb, + name: name); + } + + #endregion + + public override string ToString() + { + return MajorRecordPrinter.ToString(this); + } + + #region Equals and Hash + public override bool Equals(object? obj) + { + if (obj is IFormLinkGetter formLink) + { + return formLink.Equals(this); + } + if (obj is not IWeaponGetter rhs) return false; + return ((WeaponCommon)((IWeaponGetter)this).CommonInstance()!).Equals(this, rhs, equalsMask: null); + } + + public bool Equals(IWeaponGetter? obj) + { + return ((WeaponCommon)((IWeaponGetter)this).CommonInstance()!).Equals(this, obj, equalsMask: null); + } + + public override int GetHashCode() => ((WeaponCommon)((IWeaponGetter)this).CommonInstance()!).GetHashCode(this); + + #endregion + + } + +} +#endregion + +#endregion + diff --git a/Mutagen.Records.Starfield.sln b/Mutagen.Records.Starfield.sln new file mode 100644 index 0000000000..85731d4cbf --- /dev/null +++ b/Mutagen.Records.Starfield.sln @@ -0,0 +1,113 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32210.238 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mutagen.Bethesda.Core", "Mutagen.Bethesda.Core\Mutagen.Bethesda.Core.csproj", "{4D6DBB44-B89A-47A8-AB14-ACC8391C1A59}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mutagen.Bethesda.Kernel", "Mutagen.Bethesda.Kernel\Mutagen.Bethesda.Kernel.csproj", "{C9F9A3B4-7603-4D58-8D32-B92E5947EB66}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mutagen.Bethesda.Sqlite", "Mutagen.Bethesda.Sqlite\Mutagen.Bethesda.Sqlite.csproj", "{0AD320EB-A1B4-4471-8777-B1C5484E61CF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mutagen.Bethesda.Json", "Mutagen.Bethesda.Json\Mutagen.Bethesda.Json.csproj", "{3D1F4B15-2CB1-4AEE-BEDB-193930C3A2DE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mutagen.Bethesda.SourceGenerators", "Mutagen.Bethesda.SourceGenerators\Mutagen.Bethesda.SourceGenerators.csproj", "{8F260526-8074-4867-9332-8D86E9D9DB78}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mutagen.Bethesda.Autofac", "Mutagen.Bethesda.Autofac\Mutagen.Bethesda.Autofac.csproj", "{DD442F52-6F7B-452B-B1B4-5CB53262D662}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{B2ECDCA3-4F7F-4066-A5B8-339F7E96DCBD}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{5665EE3D-F3C2-4F07-B4EE-7FCC8D2BF6D2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mutagen.Bethesda.Testing", "Mutagen.Bethesda.Testing\Mutagen.Bethesda.Testing.csproj", "{930001F7-10D2-4E18-B900-D8AC1B9A9A73}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mutagen.Bethesda.Core.UnitTests", "Mutagen.Bethesda.Core.UnitTests\Mutagen.Bethesda.Core.UnitTests.csproj", "{3F86B4F2-ECDD-4C7B-8D57-4AAC4C22176A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mutagen.Bethesda.Generation", "Mutagen.Bethesda.Generation\Mutagen.Bethesda.Generation.csproj", "{8BBD0C4D-7B3A-4720-B97B-F8D5CF13C9C6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mutagen.Bethesda.WPF", "Mutagen.Bethesda.WPF\Mutagen.Bethesda.WPF.csproj", "{DA27CD55-F4A3-4535-AC79-E873748572DE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mutagen.Bethesda.Tests.GUI", "Mutagen.Bethesda.Tests.GUI\Mutagen.Bethesda.Tests.GUI.csproj", "{7665E601-FDD4-4494-8BE1-2B353A49034C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mutagen.Bethesda.Starfield", "Mutagen.Bethesda.Starfield\Mutagen.Bethesda.Starfield.csproj", "{A019017D-35E7-427D-A044-A141B8992144}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mutagen.Bethesda.Starfield.Generator", "Mutagen.Bethesda.Starfield.Generator\Mutagen.Bethesda.Starfield.Generator.csproj", "{77D5C441-10A5-4D36-BD34-A8ABAFECBB20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4D6DBB44-B89A-47A8-AB14-ACC8391C1A59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4D6DBB44-B89A-47A8-AB14-ACC8391C1A59}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4D6DBB44-B89A-47A8-AB14-ACC8391C1A59}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4D6DBB44-B89A-47A8-AB14-ACC8391C1A59}.Release|Any CPU.Build.0 = Release|Any CPU + {C9F9A3B4-7603-4D58-8D32-B92E5947EB66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9F9A3B4-7603-4D58-8D32-B92E5947EB66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9F9A3B4-7603-4D58-8D32-B92E5947EB66}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9F9A3B4-7603-4D58-8D32-B92E5947EB66}.Release|Any CPU.Build.0 = Release|Any CPU + {0AD320EB-A1B4-4471-8777-B1C5484E61CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0AD320EB-A1B4-4471-8777-B1C5484E61CF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0AD320EB-A1B4-4471-8777-B1C5484E61CF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0AD320EB-A1B4-4471-8777-B1C5484E61CF}.Release|Any CPU.Build.0 = Release|Any CPU + {3D1F4B15-2CB1-4AEE-BEDB-193930C3A2DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3D1F4B15-2CB1-4AEE-BEDB-193930C3A2DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3D1F4B15-2CB1-4AEE-BEDB-193930C3A2DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3D1F4B15-2CB1-4AEE-BEDB-193930C3A2DE}.Release|Any CPU.Build.0 = Release|Any CPU + {8F260526-8074-4867-9332-8D86E9D9DB78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8F260526-8074-4867-9332-8D86E9D9DB78}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F260526-8074-4867-9332-8D86E9D9DB78}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8F260526-8074-4867-9332-8D86E9D9DB78}.Release|Any CPU.Build.0 = Release|Any CPU + {DD442F52-6F7B-452B-B1B4-5CB53262D662}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD442F52-6F7B-452B-B1B4-5CB53262D662}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD442F52-6F7B-452B-B1B4-5CB53262D662}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD442F52-6F7B-452B-B1B4-5CB53262D662}.Release|Any CPU.Build.0 = Release|Any CPU + {930001F7-10D2-4E18-B900-D8AC1B9A9A73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {930001F7-10D2-4E18-B900-D8AC1B9A9A73}.Debug|Any CPU.Build.0 = Debug|Any CPU + {930001F7-10D2-4E18-B900-D8AC1B9A9A73}.Release|Any CPU.ActiveCfg = Release|Any CPU + {930001F7-10D2-4E18-B900-D8AC1B9A9A73}.Release|Any CPU.Build.0 = Release|Any CPU + {3F86B4F2-ECDD-4C7B-8D57-4AAC4C22176A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3F86B4F2-ECDD-4C7B-8D57-4AAC4C22176A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3F86B4F2-ECDD-4C7B-8D57-4AAC4C22176A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3F86B4F2-ECDD-4C7B-8D57-4AAC4C22176A}.Release|Any CPU.Build.0 = Release|Any CPU + {8BBD0C4D-7B3A-4720-B97B-F8D5CF13C9C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8BBD0C4D-7B3A-4720-B97B-F8D5CF13C9C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8BBD0C4D-7B3A-4720-B97B-F8D5CF13C9C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8BBD0C4D-7B3A-4720-B97B-F8D5CF13C9C6}.Release|Any CPU.Build.0 = Release|Any CPU + {DA27CD55-F4A3-4535-AC79-E873748572DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DA27CD55-F4A3-4535-AC79-E873748572DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DA27CD55-F4A3-4535-AC79-E873748572DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DA27CD55-F4A3-4535-AC79-E873748572DE}.Release|Any CPU.Build.0 = Release|Any CPU + {7665E601-FDD4-4494-8BE1-2B353A49034C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7665E601-FDD4-4494-8BE1-2B353A49034C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7665E601-FDD4-4494-8BE1-2B353A49034C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7665E601-FDD4-4494-8BE1-2B353A49034C}.Release|Any CPU.Build.0 = Release|Any CPU + {A019017D-35E7-427D-A044-A141B8992144}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A019017D-35E7-427D-A044-A141B8992144}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A019017D-35E7-427D-A044-A141B8992144}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A019017D-35E7-427D-A044-A141B8992144}.Release|Any CPU.Build.0 = Release|Any CPU + {77D5C441-10A5-4D36-BD34-A8ABAFECBB20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {77D5C441-10A5-4D36-BD34-A8ABAFECBB20}.Debug|Any CPU.Build.0 = Debug|Any CPU + {77D5C441-10A5-4D36-BD34-A8ABAFECBB20}.Release|Any CPU.ActiveCfg = Release|Any CPU + {77D5C441-10A5-4D36-BD34-A8ABAFECBB20}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {4D6DBB44-B89A-47A8-AB14-ACC8391C1A59} = {B2ECDCA3-4F7F-4066-A5B8-339F7E96DCBD} + {C9F9A3B4-7603-4D58-8D32-B92E5947EB66} = {B2ECDCA3-4F7F-4066-A5B8-339F7E96DCBD} + {0AD320EB-A1B4-4471-8777-B1C5484E61CF} = {B2ECDCA3-4F7F-4066-A5B8-339F7E96DCBD} + {3D1F4B15-2CB1-4AEE-BEDB-193930C3A2DE} = {B2ECDCA3-4F7F-4066-A5B8-339F7E96DCBD} + {8F260526-8074-4867-9332-8D86E9D9DB78} = {B2ECDCA3-4F7F-4066-A5B8-339F7E96DCBD} + {DD442F52-6F7B-452B-B1B4-5CB53262D662} = {B2ECDCA3-4F7F-4066-A5B8-339F7E96DCBD} + {930001F7-10D2-4E18-B900-D8AC1B9A9A73} = {5665EE3D-F3C2-4F07-B4EE-7FCC8D2BF6D2} + {3F86B4F2-ECDD-4C7B-8D57-4AAC4C22176A} = {5665EE3D-F3C2-4F07-B4EE-7FCC8D2BF6D2} + {8BBD0C4D-7B3A-4720-B97B-F8D5CF13C9C6} = {B2ECDCA3-4F7F-4066-A5B8-339F7E96DCBD} + {DA27CD55-F4A3-4535-AC79-E873748572DE} = {B2ECDCA3-4F7F-4066-A5B8-339F7E96DCBD} + {7665E601-FDD4-4494-8BE1-2B353A49034C} = {5665EE3D-F3C2-4F07-B4EE-7FCC8D2BF6D2} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3C76E1C6-5B27-4005-8051-03C82E3A4849} + EndGlobalSection +EndGlobal diff --git a/Mutagen.Records.sln b/Mutagen.Records.sln index 8bc6db7d96..c18f6663ee 100644 --- a/Mutagen.Records.sln +++ b/Mutagen.Records.sln @@ -71,6 +71,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mutagen.Bethesda.Starfield", "Mutagen.Bethesda.Starfield\Mutagen.Bethesda.Starfield.csproj", "{470374D2-B508-4A3D-8A87-B0FE31FFA82E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mutagen.Bethesda.Starfield.Generator", "Mutagen.Bethesda.Starfield.Generator\Mutagen.Bethesda.Starfield.Generator.csproj", "{13571737-2117-4708-9106-A2409678C655}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -177,6 +179,10 @@ Global {470374D2-B508-4A3D-8A87-B0FE31FFA82E}.Debug|Any CPU.Build.0 = Debug|Any CPU {470374D2-B508-4A3D-8A87-B0FE31FFA82E}.Release|Any CPU.ActiveCfg = Release|Any CPU {470374D2-B508-4A3D-8A87-B0FE31FFA82E}.Release|Any CPU.Build.0 = Release|Any CPU + {13571737-2117-4708-9106-A2409678C655}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {13571737-2117-4708-9106-A2409678C655}.Debug|Any CPU.Build.0 = Debug|Any CPU + {13571737-2117-4708-9106-A2409678C655}.Release|Any CPU.ActiveCfg = Release|Any CPU + {13571737-2117-4708-9106-A2409678C655}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,6 +212,7 @@ Global {F2EF14F7-CED7-4832-9CE4-5CD65F1B6550} = {5665EE3D-F3C2-4F07-B4EE-7FCC8D2BF6D2} {AB5B2624-FAB0-44A5-86C1-680D04A55B59} = {5665EE3D-F3C2-4F07-B4EE-7FCC8D2BF6D2} {470374D2-B508-4A3D-8A87-B0FE31FFA82E} = {181455C8-DDBD-40BE-8891-0950A3F62101} + {13571737-2117-4708-9106-A2409678C655} = {89AC8733-A707-495A-88B1-8F9570CDA329} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3C76E1C6-5B27-4005-8051-03C82E3A4849}