diff --git a/Robust.Shared/Prototypes/PrototypeManager.cs b/Robust.Shared/Prototypes/PrototypeManager.cs
index e7e0a8a8a..6c6687c92 100644
--- a/Robust.Shared/Prototypes/PrototypeManager.cs
+++ b/Robust.Shared/Prototypes/PrototypeManager.cs
@@ -72,6 +72,13 @@ namespace Robust.Shared.Prototypes
///
void RegisterIgnore(string name);
+ ///
+ /// Loads a single prototype class type into the manager.
+ ///
+ /// A prototype class type that implements IPrototype. This type also
+ /// requires a with a non-empty class string.
+ void RegisterType(Type protoClass);
+
event Action? LoadedData;
}
@@ -281,24 +288,7 @@ namespace Robust.Shared.Prototypes
Clear();
foreach (var type in ReflectionManager.GetAllChildren())
{
- var attribute = (PrototypeAttribute?)Attribute.GetCustomAttribute(type, typeof(PrototypeAttribute));
- if (attribute == null)
- {
- throw new InvalidImplementationException(type, typeof(IPrototype), "No " + nameof(PrototypeAttribute) + " to give it a type string.");
- }
-
- if (prototypeTypes.ContainsKey(attribute.Type))
- {
- throw new InvalidImplementationException(type, typeof(IPrototype),
- $"Duplicate prototype type ID: {attribute.Type}. Current: {prototypeTypes[attribute.Type]}");
- }
-
- prototypeTypes[attribute.Type] = type;
- prototypes[type] = new List();
- if (typeof(IIndexedPrototype).IsAssignableFrom(type))
- {
- indexedPrototypes[type] = new Dictionary();
- }
+ RegisterType(type);
}
}
@@ -359,6 +349,37 @@ namespace Robust.Shared.Prototypes
IgnoredPrototypeTypes.Add(name);
}
+ ///
+ public void RegisterType(Type type)
+ {
+ if(!(typeof(IPrototype).IsAssignableFrom(type)))
+ throw new InvalidOperationException("Type must implement IPrototype.");
+
+ var attribute = (PrototypeAttribute?)Attribute.GetCustomAttribute(type, typeof(PrototypeAttribute));
+
+ if (attribute == null)
+ {
+ throw new InvalidImplementationException(type,
+ typeof(IPrototype),
+ "No " + nameof(PrototypeAttribute) + " to give it a type string.");
+ }
+
+ if (prototypeTypes.ContainsKey(attribute.Type))
+ {
+ throw new InvalidImplementationException(type,
+ typeof(IPrototype),
+ $"Duplicate prototype type ID: {attribute.Type}. Current: {prototypeTypes[attribute.Type]}");
+ }
+
+ prototypeTypes[attribute.Type] = type;
+ prototypes[type] = new List();
+
+ if (typeof(IIndexedPrototype).IsAssignableFrom(type))
+ {
+ indexedPrototypes[type] = new Dictionary();
+ }
+ }
+
public event Action? LoadedData;
}