Skip to content

Commit

Permalink
Removed IL2CPP Submodules & R5 files dependency
Browse files Browse the repository at this point in the history
Rundown 5 dlls are no longer required for building the project.
R5 Booster Converters have been re-implemented using reflection
Moved Rundown- and Build-Constraint checks into Utils
  • Loading branch information
AuriRex committed Mar 22, 2023
1 parent 43133ac commit 2de883e
Show file tree
Hide file tree
Showing 43 changed files with 816 additions and 824 deletions.
5 changes: 4 additions & 1 deletion BuildHelper/BuildHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@

<Message Importance="High" Text="[#0.1] Building Core Mod" />
<MSBuild Projects="$(MSBuildProjectDirectory)\..\TheArchive.Core\TheArchive.Core.csproj" ContinueOnError="false" BuildInParallel="false" />

<!--
<Message Importance="High" Text="[#0.2] Building IL2CPP Support-Module ..." />
<MSBuild Projects="$(MSBuildProjectDirectory)\..\TheArchive.IL2CPP\TheArchive.IL2CPP.csproj" ContinueOnError="false" BuildInParallel="false" />

<Message Importance="High" Text="[#1] Building Sub-Modules ..." />
<Message Importance="High" Text="[#1.1] Building R5 Sub-Module ..." Condition="'$(Configuration)' == 'R_ML'" />
Expand All @@ -46,6 +48,7 @@
<Message Importance="High" Text="[#1.2] Building R6 Sub-Module ..." />
<MSBuild Projects="$(MSBuildProjectDirectory)\..\TheArchive.IL2CPP.R6\TheArchive.IL2CPP.R6.csproj" ContinueOnError="false" BuildInParallel="false" />
-->

<!--<Message Importance="High" Text="[#2] Building IL2CPP/MONO Support-Modules ..." />
Expand Down
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,6 @@ The location of this `SaveData` folder can be customized by editing `TheArchive_
* Latest Game Version
* Install [MelonLoader](https://github.com/LavaGang/MelonLoader) and run the game once
* Copy the `MelonLoader` folder from the game directory into `_R_LATEST/`
* R5 (steam manifest: `2154682358008197814`)
* Obtain the last Rundown 5 build, install [MelonLoader](https://github.com/LavaGang/MelonLoader) and run the game once.
* Copy the `MelonLoader` folder from the game directory into `_R_RD005/`
* R3 (steam manifest: `1993854016152145129`)
* Obtain the last Rundown 3 build, install [MelonLoader](https://github.com/LavaGang/MelonLoader) and run the game once.
* Copy the `MelonLoader` folder from the game directory into `_R_RD003/`
Expand All @@ -216,13 +213,6 @@ The location of this `SaveData` folder can be customized by editing `TheArchive_
│ │ └── ...
│ └── MelonLoader/
│ └── MelonLoader.dll
├── _R_RD005/ # Rundown 5 Assemblies go here
│ └── MelonLoader/
│ ├── Managed/
│ │ ├── Accessibility.dll
│ │ ├── Addons-ASM.dll
│ │ └── ...
│ └── MelonLoader.dll
└── .../ # Other Project Folders / Files
```

Expand Down
35 changes: 1 addition & 34 deletions TheArchive.Core/Core/FeaturesAPI/FeatureInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using TheArchive.Interfaces;
using TheArchive.Loader;
using TheArchive.Utilities;
using static TheArchive.Utilities.Utils;

namespace TheArchive.Core.FeaturesAPI
{
Expand Down Expand Up @@ -810,40 +811,6 @@ private void InternalyDisableFeature(InternalDisabledReason reason)
FeatureManager.Instance.DisableFeature(_feature);
}

private bool AnyRundownConstraintMatches(MemberInfo memberInfo)
{
var constraints = memberInfo.GetCustomAttributes<RundownConstraint>().ToArray();

if (constraints.Length == 0)
return true;

var rundown = BuildInfo.Rundown;
foreach (var constraint in constraints)
{
if (constraint.Matches(rundown))
return true;
}

return false;
}

private bool AnyBuildConstraintMatches(MemberInfo memberInfo)
{
var constraints = memberInfo.GetCustomAttributes<BuildConstraint>().ToArray();

if (constraints.Length == 0)
return true;

int buildNumber = BuildInfo.BuildNumber;
foreach (var constraint in constraints)
{
if (constraint.Matches(buildNumber))
return true;
}

return false;
}

[Flags]
internal enum InternalDisabledReason
{
Expand Down
13 changes: 11 additions & 2 deletions TheArchive.Core/Core/Managers/ImplementationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Reflection;
using TheArchive.Interfaces;
using TheArchive.Utilities;
using static TheArchive.Utilities.Utils;

namespace TheArchive.Core.Managers
{
Expand Down Expand Up @@ -80,7 +81,10 @@ public static T GetOrFindImplementation<T>()
var asm = module.GetType().Assembly;
foreach (Type type in asm.GetTypes())
{
if (typeof(T).IsAssignableFrom(type) && typeof(T) != type)
if (typeof(T).IsAssignableFrom(type)
&& typeof(T) != type
&& AnyRundownConstraintMatches(type)
&& AnyBuildConstraintMatches(type))
{
ArchiveLogger.Debug($"Found implementation \"{type.FullName}\" for \"{typeof(T).FullName}\"!");
var instance = Activator.CreateInstance(type);
Expand All @@ -95,7 +99,12 @@ public static T GetOrFindImplementation<T>()
ArchiveLogger.Error($"{nameof(ReflectionTypeLoadException)} was thrown! This should not happen! Falling back to loaded types ... (Ignore stack trace if no {nameof(ArgumentException)} is thrown afterwards)");
ArchiveLogger.Exception(tlex);

var type = tlex.Types.FirstOrDefault(type => typeof(T).IsAssignableFrom(type) && typeof(T) != type);
var type = tlex.Types.FirstOrDefault(type =>
typeof(T).IsAssignableFrom(type)
&& typeof(T) != type
&& AnyRundownConstraintMatches(type)
&& AnyBuildConstraintMatches(type));

if (type != null)
{
ArchiveLogger.Debug($"Found implementation \"{type.FullName}\" for \"{typeof(T).FullName}\"!");
Expand Down
38 changes: 37 additions & 1 deletion TheArchive.Core/Utilities/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using MelonLoader;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
Expand All @@ -7,6 +8,7 @@
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using TheArchive.Core.Attributes;
using TheArchive.Core.Managers;
using TheArchive.Loader;

Expand Down Expand Up @@ -424,6 +426,40 @@ public static RundownFlags FlagsFromTo(RundownFlags from, RundownFlags to)
return flags.Value;
}

public static bool AnyRundownConstraintMatches(MemberInfo memberInfo)
{
var constraints = memberInfo.GetCustomAttributes<RundownConstraint>();

if (constraints.Count() == 0)
return true;

var rundown = ArchiveMod.CurrentBuildInfo.Rundown;
foreach (var constraint in constraints)
{
if (constraint.Matches(rundown))
return true;
}

return false;
}

public static bool AnyBuildConstraintMatches(MemberInfo memberInfo)
{
var constraints = memberInfo.GetCustomAttributes<BuildConstraint>();

if (constraints.Count() == 0)
return true;

int buildNumber = ArchiveMod.CurrentBuildInfo.BuildNumber;
foreach (var constraint in constraints)
{
if (constraint.Matches(buildNumber))
return true;
}

return false;
}

public static bool TryGetMethodByName(Type type, string name, out MethodInfo methodInfo)
{
if (type.GetMethods(AnyBindingFlagss).Any(x => x.Name.Equals(name)))
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 2de883e

Please sign in to comment.