Skip to content

Commit

Permalink
DLC2 initial fixes (#527)
Browse files Browse the repository at this point in the history
* netstandard2.1, update ass refs

* netstandard2.0 for those still

* fix(ass ref): bump to properly publicized packages

* fix(sound): MusicController changed a bit, same for wwise init class

* things are getting coroutined

* don't think this was a good piece of code anyway

* damageapi: just make it compile for now

* fix(sound): fix wrong typeof for hook

* fix(skin): fix BulletAttack.FireSingle ilhook

* bump gamebuildid

* fix(elite): update eliteramp addressable path

* fix(r2apitest): comment out reflection tests cause one of the test hard crash to desktop the game

* r2api test stuff

* fix(elite): update to current CombatDirector.Init

* log and try catch inside loop

* fix prefab api holder getting cleaned up for some reason

* bump ver and changelog
  • Loading branch information
xiaoxiao921 authored Aug 28, 2024
1 parent e56a7cd commit 4ab123e
Show file tree
Hide file tree
Showing 32 changed files with 226 additions and 200 deletions.
2 changes: 1 addition & 1 deletion BuildCI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void CopyAllR2APIDllsToUniqueFolder()
var allR2apiModulesDirectoryPath = Path.Join(r2apiSolutionFolder.FullName, "All R2API Modules");
Directory.CreateDirectory(allR2apiModulesDirectoryPath);
foreach (var dll in Directory.GetFiles(r2apiSolutionFolder.FullName, "R2API*.dll", SearchOption.AllDirectories).Concat(Directory.GetFiles(r2apiSolutionFolder.FullName, "R2API*.pdb", SearchOption.AllDirectories)))
if (dll.Contains("\\bin\\Debug\\netstandard2.0\\"))
if (dll.Contains("\\bin\\Debug\\netstandard2.1\\"))
{
var outputPath = Path.Combine(allR2apiModulesDirectoryPath, Path.GetFileName(dll));
Console.WriteLine(dll);
Expand Down
2 changes: 1 addition & 1 deletion R2API.Analyzer/R2API.Analyzer/R2API.Analyzer.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Expand Down
32 changes: 16 additions & 16 deletions R2API.AutoVersionGen/R2API.AutoVersionGen.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
</PropertyGroup>

<ItemGroup>
<CompilerVisibleProperty Include="MSBuildProjectDirectory" />
</ItemGroup>
<ItemGroup>
<CompilerVisibleProperty Include="MSBuildProjectDirectory" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
66 changes: 9 additions & 57 deletions R2API.ContentManagement/R2APIContentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,69 +221,14 @@ internal static void SetHooks()
return;
}

On.RoR2.ContentManagement.ContentManager.SetContentPacks += EnsureUniqueNames;

_hooksEnabled = true;
}

internal static void UnsetHooks()
{
On.RoR2.ContentManagement.ContentManager.SetContentPacks -= EnsureUniqueNames;

_hooksEnabled = false;
}

private static void EnsureUniqueNames(On.RoR2.ContentManagement.ContentManager.orig_SetContentPacks orig, List<ReadOnlyContentPack> newContentPacks)
{
if (newContentPacks.Count > 1)
{
IEnumerable<PropertyInfo> allReadOnlyNamedAssetCollectionProperty = GetAllAssetCollectionPropertiesOfAReadOnlyContentPack();

// Compare each content pack with each others for any potential duplicate asset names
for (int i = 0; i < newContentPacks.Count - 1; i++)
{
for (int j = i + 1; j < newContentPacks.Count; j++)
{

var firstContentPack = newContentPacks[i];
var secondContentPack = newContentPacks[j];

var isFirstContentPackVanilla = firstContentPack.IsVanillaContentPack();
var isSecondContentPackVanilla = secondContentPack.IsVanillaContentPack();

foreach (var assetCollectionProperty in allReadOnlyNamedAssetCollectionProperty)
{
var firstAssetCollection = ((IEnumerable)assetCollectionProperty.GetValue(firstContentPack)).Cast<UnityObject>();
var secondAssetCollection = ((IEnumerable)assetCollectionProperty.GetValue(secondContentPack)).Cast<UnityObject>();

var firstAssetIndex = 0;
foreach (var firstAsset in firstAssetCollection)
{
var secondAssetIndex = 0;
foreach (var secondAsset in secondAssetCollection)
{
var differentReferences = firstAsset != secondAsset;
if (differentReferences)
{
ChangeAssetNameIfNeeded(firstContentPack, firstAsset, ref firstAssetIndex,
secondContentPack, secondAsset, ref secondAssetIndex,
isFirstContentPackVanilla, isSecondContentPackVanilla);
}
else
{
ContentManagementPlugin.Logger.LogError($"The exact same asset {firstAsset} is being added by two different content packs : {firstContentPack.identifier} and {secondContentPack.identifier}");
// Todo, try removing it from the non-vanilla contentPack, lot of annoying code to write that I cant bother writing right now
}
}
}
}
}
}
}

orig(newContentPacks);
}

private static void ChangeAssetNameIfNeeded(ReadOnlyContentPack firstContentPack, UnityObject firstAsset, ref int firstAssetIndex,
ReadOnlyContentPack secondContentPack, UnityObject secondAsset, ref int secondAssetIndex,
bool isFirstContentPackVanilla, bool isSecondContentPackVanilla)
Expand Down Expand Up @@ -443,8 +388,15 @@ internal static void CreateContentPacks()
List<ManagedReadOnlyContentPack> managedReadOnlyContentPacks = new List<ManagedReadOnlyContentPack>();
foreach (var (modName, managedSCP) in BepInModNameToSerializableContentPack)
{
managedReadOnlyContentPacks.Add(new ManagedReadOnlyContentPack(managedSCP.serializableContentPack, managedSCP.AutoCreateIContentPackProvider, managedSCP.AssemblyThatCreatedContentPack));
ContentPackToAssembly.Add(managedSCP.serializableContentPack.GetOrCreateContentPack(), managedSCP.AssemblyThatCreatedContentPack);
try
{
managedReadOnlyContentPacks.Add(new ManagedReadOnlyContentPack(managedSCP.serializableContentPack, managedSCP.AutoCreateIContentPackProvider, managedSCP.AssemblyThatCreatedContentPack));
ContentPackToAssembly.Add(managedSCP.serializableContentPack.GetOrCreateContentPack(), managedSCP.AssemblyThatCreatedContentPack);
}
catch (Exception e)
{
Debug.LogError($"[R2API CreateContentPacks] {modName} {e}");
}
}
_contentPacksCreated = true;
_managedContentPacks = new ReadOnlyArray<ManagedReadOnlyContentPack>(managedReadOnlyContentPacks.ToArray());
Expand Down
5 changes: 2 additions & 3 deletions R2API.ContentManagement/R2APISerializableContentPack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,13 @@ private void EnsureNoFieldsAreNull()
RemoveNullFields(ref miscPickupDefs);

RemoveNullFields(ref entityStateConfigurations);
RemoveNullFields(ref entityStateTypes);

RemoveNullFields(ref expansionDefs);
RemoveNullFields(ref entitlementDefs);

void RemoveNullFields<T>(ref T[] array)
void RemoveNullFields<T>(ref T[] array) where T : UnityEngine.Object
{
IEnumerable<T> nonNullValues = array.Where(obj => obj != null);
IEnumerable<T> nonNullValues = array.Where(obj => obj);
array = nonNullValues.ToArray();
}
}
Expand Down
3 changes: 3 additions & 0 deletions R2API.ContentManagement/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ R2API.ContentManaged is used for mods that would like to have R2API handle the c

## Changelog

### '1.0.5'
* Initial fixes for SOTS DLC2 Release.

### '1.0.4'
* Fix content getting erroneously attributed to R2API's contentpack.

Expand Down
2 changes: 1 addition & 1 deletion R2API.ContentManagement/thunderstore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ schemaVersion = "0.0.1"
[package]
namespace = "RiskofThunder"
name = "R2API_ContentManagement"
versionNumber = "1.0.4"
versionNumber = "1.0.5"
description = "API for adding content to the game"
websiteUrl = "https://github.com/risk-of-thunder/R2API"
containsNsfwContent = false
Expand Down
2 changes: 1 addition & 1 deletion R2API.Core/R2API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public partial class R2API : BaseUnityPlugin

public const string PluginName = "R2API";

private const string GameBuildId = "1.2.4.4";
private const string GameBuildId = "1.3.1";

internal static new ManualLogSource Logger { get; set; }

Expand Down
3 changes: 3 additions & 0 deletions R2API.Core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Do not hesitate to ask in [the modding discord](https://discord.gg/5MbXZvd) too!

## Changelog

### '5.1.1'
* Initial fixes for SOTS DLC2 Release.

### '5.1.0'
* Add Array to Array operations to CompressedFlagArrayUtilities

Expand Down
2 changes: 1 addition & 1 deletion R2API.Core/thunderstore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ schemaVersion = "0.0.1"
[package]
namespace = "RiskofThunder"
name = "R2API_Core"
versionNumber = "5.1.0"
versionNumber = "5.1.1"
description = "Core R2API module"
websiteUrl = "https://github.com/risk-of-thunder/R2API"
containsNsfwContent = false
Expand Down
Loading

0 comments on commit 4ab123e

Please sign in to comment.