mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
24 lines
724 B
C#
24 lines
724 B
C#
namespace Robust.Shared.GameObjects
|
|
{
|
|
public static class EntityManagerExt
|
|
{
|
|
public static T? GetComponentOrNull<T>(this IEntityManager entityManager, EntityUid entityUid)
|
|
where T : class, IComponent
|
|
{
|
|
if (entityManager.TryGetComponent(entityUid, out T? component))
|
|
return component;
|
|
|
|
return null;
|
|
}
|
|
|
|
public static T? GetComponentOrNull<T>(this IEntityManager entityManager, EntityUid? entityUid)
|
|
where T : class, IComponent
|
|
{
|
|
if (entityUid.HasValue && entityManager.TryGetComponent(entityUid.Value, out T? component))
|
|
return component;
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|