ScriptCore: Cleanup and refactoring

A bit of nullable stuff
This commit is contained in:
Simon Lübeß
2024-01-07 23:56:44 +01:00
parent bfc9d4a0a5
commit 86139f870c
7 changed files with 216 additions and 214 deletions
@@ -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;
}
}