Skip to content

Commit

Permalink
feat: add submodule for testing purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeFwd committed Oct 20, 2024
1 parent 4783fa7 commit 2b49f24
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 26 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ ipch/
AssetPackages/
Shaders/

#DADG
/config/nlog.config

#Project
/SubModule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bannerlord.ReferenceAssemblies.Core" Version="$(BannerlordVersion).*-*" PrivateAssets="All" />
<PackageReference Include="Bannerlord.ReferenceAssemblies.Core" Version="$(GameVersion).*-*" PrivateAssets="All"/>

<ProjectReference Include="..\Bannerlord.ExpandedTemplate.Integration\Bannerlord.ExpandedTemplate.Integration.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ namespace Bannerlord.ExpandedTemplate.API;

public class BannerlordExpandedTemplateApi
{
private ExpandedTemplateSubModule _subModule = new ();
private SubModule _subModule = new();

public BannerlordExpandedTemplateApi UseLoggerFactory(ILoggerFactory loggerFactory)
{
_subModule = new ExpandedTemplateSubModule(new LoggerFactoryAdapter(loggerFactory));
_subModule = new SubModule(new LoggerFactoryAdapter(loggerFactory));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
</PropertyGroup>

<PropertyGroup>
<HarmonyVersion>2.3.0</HarmonyVersion>
<IsExternalInitVersion>1.0.3</IsExternalInitVersion>
<NLogVersion>5.3.4</NLogVersion>
<SafeFluentXPathVersion>1.0.0</SafeFluentXPathVersion>
</PropertyGroup>

Expand All @@ -27,10 +25,7 @@

<ItemGroup>
<PackageReference Include="IsExternalInit" Version="$(IsExternalInitVersion)" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"/>

<PackageReference Include="SafeFluentXPath.Implementation" Version="$(SafeFluentXPathVersion)" />
<PackageReference Include="NLog" Version="$(NLogVersion)"/>

<ProjectReference Include="..\Bannerlord.ExpandedTemplate.Domain\Bannerlord.ExpandedTemplate.Domain.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@
</PropertyGroup>

<PropertyGroup>
<HarmonyVersion>2.3.0</HarmonyVersion>
<DeepClonerVersion>0.10.4</DeepClonerVersion>
</PropertyGroup>

<PropertyGroup>
<ModuleId>Bannerlord.ExpandedTemplate</ModuleId>
<ModuleName>Bannerlord.ExpandedTemplate</ModuleName>
<GameVersionWithPrefix>v$(GameVersion)</GameVersionWithPrefix>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DeepCloner" Version="$(DeepClonerVersion)" />
<PackageReference Include="Bannerlord.BuildResources" Version="1.1.0.108" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"/>

<PackageReference Include="Bannerlord.Lib.Harmony" Version="$(HarmonyVersion)" IncludeAssets="compile" />
<PackageReference Include="DeepCloner" Version="$(DeepClonerVersion)" />

<PackageReference Include="Bannerlord.ReferenceAssemblies.Core" Version="$(BannerlordVersion).*-*" PrivateAssets="All" />
<PackageReference Include="Bannerlord.ReferenceAssemblies.Sandbox" Version="$(BannerlordVersion).*-*" PrivateAssets="All" />
<PackageReference Include="Bannerlord.ReferenceAssemblies.Core" Version="$(GameVersion).*-*" PrivateAssets="All"/>
<PackageReference Include="Bannerlord.ReferenceAssemblies.Native" Version="$(GameVersion).*-*" PrivateAssets="All"/>
<PackageReference Include="Bannerlord.ReferenceAssemblies.Sandbox" Version="$(GameVersion).*-*" PrivateAssets="All"/>

<ProjectReference Include="..\Bannerlord.ExpandedTemplate.Domain\Bannerlord.ExpandedTemplate.Domain.csproj" />
<ProjectReference Include="..\Bannerlord.ExpandedTemplate.Infrastructure\Bannerlord.ExpandedTemplate.Infrastructure.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"profiles": {
"Launcher": {
"commandName": "Executable",
"executablePath": "$(GameFolder)\\bin\\Win64_Shipping_Client\\TaleWorlds.MountAndBlade.Launcher.exe",
"workingDirectory": "$(GameFolder)\\bin\\Win64_Shipping_Client"
},
"Launcher.BLSE": {
"commandName": "Executable",
"executablePath": "$(GameFolder)\\bin\\Win64_Shipping_Client\\Bannerlord.BLSE.Launcher.exe",
"workingDirectory": "$(GameFolder)\\bin\\Win64_Shipping_Client"
}
}
}
25 changes: 17 additions & 8 deletions ....Integration/ExpandedTemplateSubModule.cs → ...ExpandedTemplate.Integration/SubModule.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,23 @@

namespace Bannerlord.ExpandedTemplate.Integration
{
public class ExpandedTemplateSubModule : MBSubModuleBase
public class SubModule : MBSubModuleBase
{
private readonly ILoggerFactory _loggerFactory;
private readonly ICacheProvider _cacheProvider;

private ForceCivilianEquipmentSetter _forceCivilianEquipmentSetter;
private MissionSpawnEquipmentPoolSetter _missionSpawnEquipmentPoolSetter;

public ExpandedTemplateSubModule(ILoggerFactory? loggerFactory = null)
public SubModule()
{
_loggerFactory = loggerFactory ?? new ConsoleLoggerFactory();
_cacheProvider = new CacheCampaignBehaviour();
_loggerFactory = new ConsoleLoggerFactory();
}

public SubModule(ILoggerFactory loggerFactory)
{
_loggerFactory = loggerFactory;
}

public override void OnBeforeMissionBehaviorInitialize(Mission mission)
Expand Down Expand Up @@ -62,10 +67,10 @@ private void HandleEquipmentSpawnDependencies()
var npcCharacterRepository = new NpcCharacterRepository(xmlProcessor, _cacheProvider, _loggerFactory);
var equipmentPoolRoster = new EquipmentSetMapper();
var equipmentRosterRepository = new EquipmentRosterRepository(xmlProcessor, _cacheProvider, _loggerFactory);
var equipmentPoolMapper =
var npcCharacterMapper =
new NpcCharacterMapper(equipmentRosterRepository, equipmentPoolRoster, _loggerFactory);
var characterEquipmentPoolRepository =
new NpcCharacterEquipmentPoolsProvider(npcCharacterRepository, equipmentPoolMapper);
new NpcCharacterEquipmentPoolsProvider(npcCharacterRepository, npcCharacterMapper);
var civilianEquipmentRepository =
new CivilianEquipmentPoolProvider(_loggerFactory, _cacheProvider, characterEquipmentPoolRepository);
var siegeEquipmentRepository =
Expand All @@ -85,14 +90,18 @@ private void HandleEquipmentSpawnDependencies()
var random = new Random();
var equipmentPicker = new EquipmentPoolPoolPicker(random);

var equipmentMapper =
new EquipmentPoolsMapper(MBObjectManager.Instance, _loggerFactory);
var equipmentMapper = new EquipmentMapper(MBObjectManager.Instance, _loggerFactory);
var equipmentPoolMapper =
new EquipmentPoolsMapper(equipmentMapper, _loggerFactory);
var getEquipmentPool = new GetEquipmentPool(encounterTypeProvider, troopBattleEquipmentProvider,
troopSiegeEquipmentProvider, troopCivilianEquipmentProvider, equipmentPicker, _loggerFactory);
var getEquipment = new GetEquipment(random);

_forceCivilianEquipmentSetter = new ForceCivilianEquipmentSetter();
_missionSpawnEquipmentPoolSetter =
new MissionSpawnEquipmentPoolSetter(getEquipmentPool, equipmentMapper, _loggerFactory);
new MissionSpawnEquipmentPoolSetter(getEquipmentPool, getEquipment, equipmentPoolMapper,
equipmentMapper,
_loggerFactory);
}

private void AddEquipmentSpawnMissionBehaviour(Mission mission)
Expand Down
30 changes: 30 additions & 0 deletions Bannerlord.ExpandedTemplate.Integration/_Module/SubModule.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is SubModule.xml file is for testing purposes -->
<Module>
<Id value="$moduleid$" />
<Name value="$modulename$" />
<Version value="v$version$" />
<DefaultModule value="false" />
<ModuleCategory value="Singleplayer"/>
<ModuleType value="Community" />
<!-- Community Dependency Metadata -->
<DependedModules>
<DependedModule Id="Native" DependentVersion="$gameversion$"/>
<DependedModule Id="Sandbox" DependentVersion="$gameversion$"/>
</DependedModules>
<!-- Community Dependency Metadata -->
<!-- https://github.com/BUTR/Bannerlord.BLSE#community-dependency-metadata -->
<DependedModuleMetadatas>
<DependedModuleMetadata id="Native" order="LoadBeforeThis" version="$gameversion$.*"/>
<DependedModuleMetadata id="Sandbox" order="LoadBeforeThis" version="$gameversion$.*"/>
</DependedModuleMetadatas>
<SubModules>
<SubModule>
<Name value="Bannerlord.ExpandedTemplate" />
<DLLName value="Bannerlord.ExpandedTemplate.Integration.dll" />
<SubModuleClassType value="Bannerlord.ExpandedTemplate.Integration.SubModule" />
<Tags />
</SubModule>
</SubModules>
<Xmls/>
</Module>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This method leverages Bannerlord's ability to load multiple `SubModules` from a
<SubModule>
<Name value="Bannerlord.ExpandedTemplate" />
<DLLName value="Bannerlord.ExpandedTemplate.Integration.dll" />
<SubModuleClassType value="Bannerlord.ExpandedTemplate.Integration.ExpandedTemplateSubModule" />
<SubModuleClassType value="Bannerlord.ExpandedTemplate.Integration.SubModule" />
<Tags/>
</SubModule>
```
Expand Down
26 changes: 24 additions & 2 deletions build/common.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
<Project>
<PropertyGroup>
<BuildVersion>1.0.0</BuildVersion>
<BannerlordVersion>1.2.11</BannerlordVersion>
<BuildVersion>1.1.0</BuildVersion>
<GameVersion>1.2.11</GameVersion>
</PropertyGroup>

<!-- Game Folder(s) -->
<PropertyGroup>
<!--
Bannerlord's Root Folder. Leave empty if you want to try autoresolution. Recommended setup is to set, as an
environment variable, BANNERLORD_GAME_DIR in the common case that you have only one game folder. If you have
separate game folders for the stable and beta versions of the game, likewise set BANNERLORD_STABLE_DIR and
BANNERLORD_BETA_DIR.
-->
<GameFolder Condition="$(GameFolder) == ''">$(BANNERLORD_GAME_DIR)</GameFolder>
</PropertyGroup>

<!-- Automatic Game Folder Resolution -->
<PropertyGroup>
<!--Windows-->
<!--Get from Registry (not working with dotnet right now)-->
<GameFolder Condition="!Exists($(GameFolder)) AND $(OS) == 'Windows_NT'">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 261550@InstallLocation)</GameFolder>
<!--Set a default value if registry value is missing-->
<GameFolder Condition="!Exists($(GameFolder)) AND $(OS) == 'Windows_NT'">C:\Program Files (x86)\Steam\steamapps\common\Mount &amp; Blade II Bannerlord</GameFolder>
<!--Unix-->
<GameFolder Condition="!Exists($(GameFolder)) AND $(OS) == 'Unix'">~/.steam/root/steamapps/common/Mount &amp; Blade II Bannerlord</GameFolder>
</PropertyGroup>
</Project>

0 comments on commit 2b49f24

Please sign in to comment.