mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using AssetRipper.AssemblyDumper.Types;
|
|
using AssetRipper.Assets;
|
|
|
|
namespace AssetRipper.AssemblyDumper.Passes;
|
|
|
|
internal static class Pass045_AddMarkerInterfaces
|
|
{
|
|
public static void DoPass()
|
|
{
|
|
foreach (ClassGroup group in SharedState.Instance.ClassGroups.Values)
|
|
{
|
|
if (group.UniformlyNamed)
|
|
{
|
|
group.Interface.AddInterfaceImplementation(GetOrAddMarkerInterface(group.Name));
|
|
}
|
|
else
|
|
{
|
|
foreach (GeneratedClassInstance instance in group.Instances)
|
|
{
|
|
instance.Type.AddInterfaceImplementation(GetOrAddMarkerInterface(instance.Name));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private static string GetInterfaceName(string className) => $"I{className}Marker";
|
|
|
|
private static TypeDefinition GetOrAddMarkerInterface(string className)
|
|
{
|
|
string interfaceName = GetInterfaceName(className);
|
|
if (!SharedState.Instance.MarkerInterfaces.TryGetValue(className, out TypeDefinition? result))
|
|
{
|
|
result = InterfaceCreator.CreateEmptyInterface(SharedState.Instance.Module, SharedState.MarkerInterfacesNamespace, interfaceName);
|
|
result.AddInterfaceImplementation<IUnityObjectBase>(SharedState.Instance.Importer);
|
|
SharedState.Instance.MarkerInterfaces.Add(className, result);
|
|
}
|
|
return result;
|
|
}
|
|
}
|