Skip to content

Commit

Permalink
A baseline of Starfield records
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggog committed Sep 1, 2023
1 parent adb01cb commit e05ea8d
Show file tree
Hide file tree
Showing 50 changed files with 18,753 additions and 34 deletions.
7 changes: 6 additions & 1 deletion Mutagen.Bethesda.Core/Extensions/GameCategoryExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand All @@ -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(),
};
}
Expand All @@ -42,6 +43,9 @@ public static IEnumerable<GameRelease> 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();
}
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions Mutagen.Bethesda.Core/InternalsPermissions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
72 changes: 72 additions & 0 deletions Mutagen.Bethesda.Core/Plugins/Meta/GameConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,76 @@ public GameConstants(
},
encodings: new(NonTranslated: MutagenEncodingProvider._1252, NonLocalized: MutagenEncodingProvider._1252));


/// <summary>
/// Readonly singleton of Starfield game constants
/// </summary>
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));

/// <summary>
/// Returns record constants related to a certain ObjectType
/// </summary>
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 4 additions & 0 deletions Mutagen.Bethesda.Kernel/GameCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public enum GameCategory
Skyrim,
[Description("Fallout4")]
Fallout4,
[Description("Starfield")]
Starfield,
}

public static class GameReleaseKernelExt
Expand All @@ -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(),
};
}
Expand All @@ -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(),
};
}
Expand Down
2 changes: 2 additions & 0 deletions Mutagen.Bethesda.Kernel/GameRelease.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ public enum GameRelease
Fallout4 = 4,
[Description("Skyrim Special Edition GOG")]
SkyrimSEGog = 7,
[Description("Starfield")]
Starfield = 8,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Autofac" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Mutagen.Bethesda.Generation\Mutagen.Bethesda.Generation.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="Program.cs">
<CodeLanguage>cs</CodeLanguage>
<DefaultPackFolder>content</DefaultPackFolder>
<BuildAction>Compile</BuildAction>
</Compile>
<Compile Update="SkyrimGenerationConstructor.cs">
<CodeLanguage>cs</CodeLanguage>
<DefaultPackFolder>content</DefaultPackFolder>
<BuildAction>Compile</BuildAction>
</Compile>
</ItemGroup>
</Project>
21 changes: 21 additions & 0 deletions Mutagen.Bethesda.Starfield.Generator/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Autofac;
using Mutagen.Bethesda.Generation.Generator;
using System.Diagnostics;

ContainerBuilder builder = new();
builder.RegisterModule<GeneratorAutofacModule>();
builder.RegisterAssemblyTypes(typeof(Program).Assembly)
.AsSelf()
.AsImplementedInterfaces();
var cont = builder.Build();
var runner = cont.Resolve<GenerationRunner>();

#if DEBUG
var detector = cont.Resolve<GenerationLineDetector>();
detector.LineDetected.Subscribe(x =>
{
Debugger.Break();
});
#endif

await runner.Generate();
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Mutagen.Bethesda.Generation.Generator;

namespace Mutagen.Bethesda.Starfield.Generator;

public class StarfieldGenerationConstructor : IRecordGeneration
{
public string Name => "Starfield";
}
10 changes: 10 additions & 0 deletions Mutagen.Bethesda.Starfield/.editorconfig
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions Mutagen.Bethesda.Starfield/Assets/StarfieldModelAssetType.cs
Original file line number Diff line number Diff line change
@@ -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<string> FileExtensions => new []{".nif"};
}
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions Mutagen.Bethesda.Starfield/Enums/GroupTypeEnum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Mutagen.Bethesda.Starfield;

/// <summary>
/// Different categories of Group records
/// </summary>
public enum GroupTypeEnum
{
Type = 0,
}
17 changes: 17 additions & 0 deletions Mutagen.Bethesda.Starfield/GameEnvironmentMixIn_Generated.cs
Original file line number Diff line number Diff line change
@@ -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<IStarfieldMod, IStarfieldModGetter> Starfield(
this GameEnvironment env,
LinkCachePreferences? linkCachePrefs = null)
{
return env.Construct<IStarfieldMod, IStarfieldModGetter>(GameRelease.Starfield, linkCachePrefs);
}

}
}
25 changes: 25 additions & 0 deletions Mutagen.Bethesda.Starfield/ImplicitsMixIn_Generated.cs
Original file line number Diff line number Diff line change
@@ -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<ModKey> Starfield(this ImplicitBaseMasters _)
{
return Implicits.Get(GameRelease.Starfield).BaseMasters;
}

public static IReadOnlyCollection<ModKey> Starfield(this ImplicitListings _)
{
return Implicits.Get(GameRelease.Starfield).Listings;
}

public static IReadOnlyCollection<FormKey> Starfield(this ImplicitRecordFormKeys _)
{
return Implicits.Get(GameRelease.Starfield).RecordFormKeys;
}
}
}
Original file line number Diff line number Diff line change
@@ -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<Type, InterfaceMappingResult> InterfaceToObjectTypes { get; }

public GameCategory GameCategory => GameCategory.Starfield;

public StarfieldAspectInterfaceMapping()
{
var dict = new Dictionary<Type, InterfaceMappingResult>();
dict[typeof(IModeled)] = new InterfaceMappingResult(true, new ILoquiRegistration[]
{
Weapon_Registration.Instance,
});
dict[typeof(IModeledGetter)] = dict[typeof(IModeled)] with { Setter = false };
InterfaceToObjectTypes = dict;
}
}
}

19 changes: 19 additions & 0 deletions Mutagen.Bethesda.Starfield/Interfaces/Aspect/IModeled.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Mutagen.Bethesda.Plugins.Records;

namespace Mutagen.Bethesda.Starfield;

/// <summary>
/// Common interface for records that have a model
/// </summary>
public interface IModeled : IModeledGetter, IMajorRecordQueryable
{
new Model? Model { get; set; }
}

/// <summary>
/// Common interface for records that have a model
/// </summary>
public interface IModeledGetter : IMajorRecordQueryableGetter
{
IModelGetter? Model { get; }
}
Original file line number Diff line number Diff line change
@@ -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<Type, InterfaceMappingResult> InterfaceToObjectTypes { get; }

public GameCategory GameCategory => GameCategory.Starfield;

public StarfieldInheritingInterfaceMapping()
{
var dict = new Dictionary<Type, InterfaceMappingResult>();
InterfaceToObjectTypes = dict;
}
}

Loading

0 comments on commit e05ea8d

Please sign in to comment.