mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
ScriptCore: Cleanup and refactoring
A bit of nullable stuff
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using GlitchyEngine.Core;
|
||||
|
||||
namespace GlitchyEngine.Extensions;
|
||||
|
||||
@@ -49,4 +50,20 @@ public static class ActivatorExtension
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of the given component type and sets it's entities id.
|
||||
/// </summary>
|
||||
/// <param name="componentType">The type of the component.</param>
|
||||
/// <param name="entityId">The entities id.</param>
|
||||
/// <returns>An instance of the component type; or <see langword="null"/> if the creation failed.</returns>
|
||||
internal static Component? CreateComponent(Type componentType, UUID entityId)
|
||||
{
|
||||
Component? component = (Component?)CreateInstanceSafe(componentType);
|
||||
|
||||
if (component != null)
|
||||
component._uuid = entityId;
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user