Re-organize all projects (#4166)

This commit is contained in:
DrSmugleaf
2021-06-09 22:19:39 +02:00
committed by GitHub
parent 9f50e4061b
commit ff1a2d97ea
1773 changed files with 5258 additions and 5508 deletions

View File

@@ -0,0 +1,39 @@
#nullable enable
using System;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Shared.Prototypes
{
[UsedImplicitly]
public static class EntityPrototypeHelpers
{
public static bool HasComponent<T>(this EntityPrototype prototype, IComponentFactory? componentFactory = null) where T : IComponent
{
return prototype.HasComponent(typeof(T), componentFactory);
}
public static bool HasComponent(this EntityPrototype prototype, Type component, IComponentFactory? componentFactory = null)
{
componentFactory ??= IoCManager.Resolve<IComponentFactory>();
var registration = componentFactory.GetRegistration(component);
return prototype.Components.ContainsKey(registration.Name);
}
public static bool HasComponent<T>(string prototype, IPrototypeManager? prototypeManager = null, IComponentFactory? componentFactory = null) where T : IComponent
{
return HasComponent(prototype, typeof(T), prototypeManager, componentFactory);
}
public static bool HasComponent(string prototype, Type component, IPrototypeManager? prototypeManager = null, IComponentFactory? componentFactory = null)
{
prototypeManager ??= IoCManager.Resolve<IPrototypeManager>();
return prototypeManager.TryIndex(prototype, out EntityPrototype? proto) && proto!.HasComponent(component, componentFactory);
}
}
}