mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-19 15:51:54 +00:00
PluginSide from AssemblyMetadataAttribute
This commit is contained in:
2 files changed
+20
-2
No files matched your search
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using BepInEx.IL2CPP;
|
||||
|
||||
namespace Reactor.Networking
|
||||
@@ -32,7 +31,7 @@ namespace Reactor.Networking
|
||||
i++,
|
||||
plugin.Metadata.GUID,
|
||||
plugin.Metadata.Version.Clean(),
|
||||
plugin.Instance.GetType().GetCustomAttribute<ReactorPluginSideAttribute>()?.Side ?? PluginSide.Both
|
||||
ReactorPluginSideAttribute.GetPluginSide(plugin.Instance.GetType())
|
||||
))
|
||||
.ToHashSet();
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Reactor
|
||||
{
|
||||
@@ -14,5 +16,22 @@ namespace Reactor
|
||||
{
|
||||
Side = side;
|
||||
}
|
||||
|
||||
public static PluginSide GetPluginSide(Type type)
|
||||
{
|
||||
var attribute = type.GetCustomAttribute<ReactorPluginSideAttribute>();
|
||||
if (attribute != null)
|
||||
{
|
||||
return attribute.Side;
|
||||
}
|
||||
|
||||
var metadataAttribute = type.Assembly.GetCustomAttributes<AssemblyMetadataAttribute>().SingleOrDefault(x => x.Key == "Reactor.PluginSide");
|
||||
if (metadataAttribute != null)
|
||||
{
|
||||
return Enum.Parse<PluginSide>(metadataAttribute.Value, true);
|
||||
}
|
||||
|
||||
return PluginSide.Both;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user