Skip to content

Commit

Permalink
Added e1.7.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Dec 10, 2021
1 parent 6d18473 commit 3ec6861
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void Enable()
#if e143 || e150 || e151 || e152 || e153
Patches.CharacterCreationContentApplyCulturePatch.Enable(_harmony);
Patches.ClanInitializeClanPatch.Enable(_harmony);
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
#else
#error ConstGameVersionWithPrefix is not handled!
#endif
Expand All @@ -41,7 +41,7 @@ public void Disable()
#if e143 || e150 || e151 || e152 || e153
//CharacterCreationContentApplyCulturePatch.Disable(_harmony);
//ClanInitializeClanPatch.Disable(_harmony);
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
#else
#error ConstGameVersionWithPrefix is not handled!
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal sealed partial class CampaignExtensionsImplementation : ICampaignExtens
return campaign.GameStarted && campaign.GetCampaignBehavior<CampaignIdentifierBehavior>() is { } identifierBehavior
? identifierBehavior.CampaignId
: null;
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
return Campaign.Current.UniqueGameId;
#else
#error ConstGameVersionWithPrefix is not handled!
Expand All @@ -30,7 +30,7 @@ internal sealed partial class CampaignExtensionsImplementation : ICampaignExtens
return campaign.GameStarted && campaign.GetCampaignBehavior<CampaignIdentifierBehavior>() is { } identifierBehavior
? identifierBehavior.CampaignDescriptor
: null;
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
return new BlankCampaignDescriptor(Campaign.Current);
#else
#error ConstGameVersionWithPrefix is not handled!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private Dictionary<ulong, float> CalculateDistanceMatrix()
{
#if e143 || e150 || e151 || e152 || e153 || e154 || e155 || e156 || e157 || e158 || e159 || e1510
var activeHeroes = Hero.All
#elif e160 || e161 || e162 || e163 || e164 || e165
#elif e160 || e161 || e162 || e163 || e164 || e165 || e170
var activeHeroes = Hero.AllAliveHeroes
#else
#error ConstGameVersionWithPrefix is not handled!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override IReadOnlyList<HotKeyBase> Build()
var hotKeyCategoryContainer = new HotKeyCategoryContainer(_subModName, _hotKeys);
#if e143 || e150 || e151 || e152 || e153 || e154 || e155 || e156 || e157 || e158 || e159
TWHotKeyManager.Initialize("Bannerlord", Utilities.GetConfigsPath() + "BannerlordGameKeys.xml", new List<GameKeyContext> { hotKeyCategoryContainer }, true);
#elif e1510 || e160 || e161 || e162 || e163 || e164 || e165
#elif e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
TWHotKeyManager.Initialize(new PlatformFilePath(EngineFilePaths.ConfigsPath, "BannerlordGameKeys.xml"), new List<GameKeyContext> { hotKeyCategoryContainer }, true);
#else
#error ConstGameVersionWithPrefix is not handled!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static void OnApplicationTick(float dt)
hotKey.OnPressedInternal();
if (hotKey.GameKey.PrimaryKey.InputKey.IsReleased())
hotKey.OnReleasedInternal();
#elif e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165
#elif e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
if (hotKey.GameKey.KeyboardKey?.InputKey.IsDown() == true || hotKey.GameKey.ControllerKey?.InputKey.IsDown() == true)
hotKey.IsDownInternal();
if (hotKey.GameKey.KeyboardKey?.InputKey.IsPressed() == true || hotKey.GameKey.ControllerKey?.InputKey.IsPressed() == true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,22 @@ public void RenderDebugText(float screenX, float screenY, string text, uint colo

public Vec3 GetDebugVector() => OriginalDebugManager.GetDebugVector();

#if e143 || e150 || e151 || e152 || e153 || e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163
#elif e164
#if e164 || e165 || e170
public void ShowError(string message)
{
_debugManagerLogger.LogError("{message}", message);
OriginalDebugManager.ShowError(message);
}
#elif e165
public void ShowError(string message)
{
_debugManagerLogger.LogError("{message}", message);
OriginalDebugManager.ShowError(message);
}

#endif
#if e165 || e170
public void BeginTelemetryScopeBaseLevel(TelemetryLevelMask levelMask, string scopeName) => OriginalDebugManager.BeginTelemetryScopeBaseLevel(levelMask, scopeName);
public void EndTelemetryScopeBaseLevel() => OriginalDebugManager.EndTelemetryScopeBaseLevel();
#else
#error ConstGameVersionWithPrefix is not handled!
#endif
#if e170
public void RenderDebugText3D(Vec3 position, string text, uint color = uint.MaxValue, int screenPosOffsetX = 0, int screenPosOffsetY = 0, float time = 0)
{
throw new NotImplementedException();
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class MBObjectFinder : IMBObjectFinder
return null;
}
}
#elif e160 || e161 || e162 || e163 || e164 || e165
#elif e160 || e161 || e162 || e163 || e164 || e165 || e170

private static readonly AccessTools.FieldRef<CampaignObjectManager, object[]>? CampaignObjectTypeObjects =
AccessTools2.FieldRefAccess<CampaignObjectManager, object[]>("_objects");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class MBObjectKeeper : IMBObjectKeeper

public void Keep(MBObjectBase mbObject)
{
if (mbObject is null!) return;
if (mbObject is null) return;

_references[mbObject.Id] = mbObject;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Bannerlord.ButterLib.Implementation/SubModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void OnServiceRegistration()
services.AddSingleton<ICampaignExtensions, CampaignExtensionsImplementation>();
#if e143 || e150 || e151 || e152 || e153
services.AddTransient<ICampaignDescriptorProvider, JsonCampaignDescriptorProvider>();
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165
#elif e154 || e155 || e156 || e157 || e158 || e159 || e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
services.AddTransient<ICampaignDescriptorProvider, BlankCampaignDescriptorProvider>();
#else
#error ConstGameVersionWithPrefix is not handled!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static class MBObjectBaseExtensions
/// <param name="name">The variable's name.</param>
internal static bool HasVariable(this MBObjectBase @object, string name)
{
if (name is null!)
if (name is null)
throw new ArgumentNullException(nameof(name));
else if (name.Length == 0)
throw new ArgumentException("Variable name cannot be empty.", nameof(name));
Expand Down Expand Up @@ -67,7 +67,7 @@ internal static bool HasVariable(this MBObjectBase @object, string name)
/// <param name="value">The variable value or <see langword="default"/> if nonexistent.</param>
internal static bool TryGetVariable<T>(this MBObjectBase @object, string name, out T value)
{
if (name is null!)
if (name is null)
throw new ArgumentNullException(nameof(name));
else if (name.Length == 0)
throw new ArgumentException("Variable name cannot be empty.", nameof(name));
Expand Down Expand Up @@ -144,7 +144,7 @@ internal static bool TryGetVariable<T>(this MBObjectBase @object, string name, o
/// <param name="data">The variable's value.</param>
internal static void SetVariable<T>(this MBObjectBase @object, string name, T data)
{
if (name is null!)
if (name is null)
throw new ArgumentNullException(nameof(name));
else if (name.Length == 0)
throw new ArgumentException("Variable name cannot be empty.", nameof(name));
Expand All @@ -168,7 +168,7 @@ internal static void SetVariable<T>(this MBObjectBase @object, string name, T da
/// <param name="name">The variable's name.</param>
internal static void RemoveVariable(this MBObjectBase @object, string name)
{
if (name is null!)
if (name is null)
throw new ArgumentNullException(nameof(name));
else if (name.Length == 0)
throw new ArgumentException("Variable name cannot be empty.", nameof(name));
Expand All @@ -193,7 +193,7 @@ internal static void RemoveVariable(this MBObjectBase @object, string name)
/// <param name="name">A string flag.</param>
public static bool HasFlag(this MBObjectBase @object, string name)
{
if (name is null!)
if (name is null)
throw new ArgumentNullException(nameof(name));
else if (name.Length == 0)
throw new ArgumentException("Flag name cannot be empty.", nameof(name));
Expand All @@ -211,7 +211,7 @@ public static bool HasFlag(this MBObjectBase @object, string name)
/// <param name="name">A string flag.</param>
public static void SetFlag(this MBObjectBase @object, string name)
{
if (name is null!)
if (name is null)
throw new ArgumentNullException(nameof(name));
else if (name.Length == 0)
throw new ArgumentException("Flag name cannot be empty.", nameof(name));
Expand All @@ -230,7 +230,7 @@ public static void SetFlag(this MBObjectBase @object, string name)
/// <param name="name">A string flag.</param>
public static void RemoveFlag(this MBObjectBase @object, string name)
{
if (name is null!)
if (name is null)
throw new ArgumentNullException(nameof(name));
else if (name.Length == 0)
throw new ArgumentException("Flag name cannot be empty.", nameof(name));
Expand Down
1 change: 1 addition & 0 deletions supported-game-versions.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
e1.7.0
e1.6.5
e1.6.4
e1.6.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void CampaignDescriptor_Test()
var hero = (Hero) FormatterServices.GetUninitializedObject(typeof(Hero));
#if e143 || e150 || e151 || e152 || e153 || e154 || e155 || e156 || e157 || e158 || e159
AccessTools.Field(typeof(Hero), "Name").SetValue(hero, new TextObject("TestHero"));
#elif e1510 || e160 || e161 || e162 || e163 || e164 || e165
#elif e1510 || e160 || e161 || e162 || e163 || e164 || e165 || e170
AccessTools.Property(typeof(Hero), "Name").SetValue(hero, new TextObject("TestHero"));
#else
#error ConstGameVersionWithPrefix is not handled!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void OnBeforeSave()

#if e143 || e150 || e151 || e152 || e153 || e154 || e155 || e156 || e157 || e158 || e159 || e1510
foreach (var h in Hero.All)
#elif e160 || e161 || e162 || e163 || e164 || e165
#elif e160 || e161 || e162 || e163 || e164 || e165 || e170
foreach (var h in Hero.AllAliveHeroes)
#else
#error ConstGameVersionWithPrefix is not handled!
Expand Down Expand Up @@ -88,7 +88,7 @@ private void OnGameLoaded(CampaignGameStarter starter)

#if e143 || e150 || e151 || e152 || e153 || e154 || e155 || e156 || e157 || e158 || e159 || e1510
foreach (var h in Hero.All)
#elif e160 || e161 || e162 || e163 || e164 || e165
#elif e160 || e161 || e162 || e163 || e164 || e165 || e170
foreach (var h in Hero.AllAliveHeroes)
#else
#error ConstGameVersionWithPrefix is not handled!
Expand Down

0 comments on commit 3ec6861

Please sign in to comment.