Add a test that puts all components on an entity and checks for no exceptions (#1815)
* Add test that puts all components on an entity and checks for no exceptions Also fix all the exceptions that happened because of this * Add comments to the test * Fix nullable errors * Fix more nullable errors * More nullable error fixes * Unignore basic actor component * Fix more nullable errors * NULLABLE ERROR * Add string interpolation * Merge if checks * Remove redundant pragma warning disable 649 * Address reviews * Remove null wrappers around TryGetComponent * Merge conflict fixes * APC battery component error fix * Fix power test * Fix atmos mapgrid usages
This commit is contained in:
@@ -24,17 +24,17 @@ namespace Content.Server.GameObjects.EntitySystems.AI
|
||||
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
|
||||
|
||||
private readonly Dictionary<string, Type> _processorTypes = new Dictionary<string, Type>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// To avoid iterating over dead AI continuously they can wake and sleep themselves when necessary.
|
||||
/// </summary>
|
||||
private readonly HashSet<AiLogicProcessor> _awakeAi = new HashSet<AiLogicProcessor>();
|
||||
|
||||
|
||||
// To avoid modifying awakeAi while iterating over it.
|
||||
private readonly List<SleepAiMessage> _queuedSleepMessages = new List<SleepAiMessage>();
|
||||
|
||||
public bool IsAwake(AiLogicProcessor processor) => _awakeAi.Contains(processor);
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -66,9 +66,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_queuedSleepMessages.Clear();
|
||||
|
||||
|
||||
foreach (var processor in _awakeAi)
|
||||
{
|
||||
processor.Update(frameTime);
|
||||
@@ -87,7 +87,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI
|
||||
/// <param name="controller"></param>
|
||||
public void ProcessorInitialize(AiControllerComponent controller)
|
||||
{
|
||||
if (controller.Processor != null) return;
|
||||
if (controller.Processor != null || controller.LogicName == null) return;
|
||||
controller.Processor = CreateProcessor(controller.LogicName);
|
||||
controller.Processor.SelfEntity = controller.Owner;
|
||||
controller.Processor.Setup();
|
||||
|
||||
Reference in New Issue
Block a user