mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Expose CompFactory to systems (#5941)
This commit is contained in:
@@ -166,7 +166,7 @@ namespace Robust.Client.Player
|
||||
{
|
||||
if (_client.RunLevel != ClientRunLevel.SinglePlayerGame)
|
||||
Sawmill.Warning($"Attaching local player to an entity {EntManager.ToPrettyString(uid)} without an eye. This eye will not be netsynced and may cause issues.");
|
||||
var eye = (EyeComponent) Factory.GetComponent(typeof(EyeComponent));
|
||||
var eye = Factory.GetComponent<EyeComponent>();
|
||||
eye.NetSyncEnabled = false;
|
||||
EntManager.AddComponent(uid.Value, eye);
|
||||
}
|
||||
|
||||
@@ -273,11 +273,11 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
public IComponent GetComponent(Type componentType)
|
||||
{
|
||||
if (!_types.ContainsKey(componentType))
|
||||
if (!_types.TryGetValue(componentType, out var value))
|
||||
{
|
||||
throw new InvalidOperationException($"{componentType} is not a registered component.");
|
||||
}
|
||||
return _typeFactory.CreateInstanceUnchecked<IComponent>(_types[componentType].Type);
|
||||
return _typeFactory.CreateInstanceUnchecked<IComponent>(value.Type);
|
||||
}
|
||||
|
||||
public IComponent GetComponent(CompIdx componentType)
|
||||
@@ -287,11 +287,11 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
public T GetComponent<T>() where T : IComponent, new()
|
||||
{
|
||||
if (!_types.ContainsKey(typeof(T)))
|
||||
if (!_types.TryGetValue(typeof(T), out var reg))
|
||||
{
|
||||
throw new InvalidOperationException($"{typeof(T)} is not a registered component.");
|
||||
}
|
||||
return _typeFactory.CreateInstanceUnchecked<T>(_types[typeof(T)].Type);
|
||||
return _typeFactory.CreateInstanceUnchecked<T>(reg.Type);
|
||||
}
|
||||
|
||||
public IComponent GetComponent(ComponentRegistration reg)
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace Robust.Shared.GameObjects
|
||||
[Dependency] private readonly IReplayRecordingManager _replayMan = default!;
|
||||
[Dependency] protected readonly ILocalizationManager Loc = default!;
|
||||
|
||||
protected IComponentFactory Factory => EntityManager.ComponentFactory;
|
||||
|
||||
public ISawmill Log { get; private set; } = default!;
|
||||
|
||||
protected virtual string SawmillName
|
||||
|
||||
Reference in New Issue
Block a user