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();
|
||||
|
||||
@@ -153,13 +153,20 @@ namespace Content.Server.GameObjects.EntitySystems.Atmos
|
||||
private bool TryRefreshTile(GridAtmosphereComponent gam, GasOverlayData oldTile, MapIndices indices, out GasOverlayData overlayData)
|
||||
{
|
||||
var tile = gam.GetTile(indices);
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
overlayData = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
var tileData = new List<GasData>();
|
||||
|
||||
for (byte i = 0; i < Atmospherics.TotalNumberOfGases; i++)
|
||||
{
|
||||
var gas = Atmospherics.GetGas(i);
|
||||
var overlay = Atmospherics.GetOverlay(i);
|
||||
if (overlay == null || tile.Air == null) continue;
|
||||
if (overlay == null || tile?.Air == null) continue;
|
||||
|
||||
var moles = tile.Air.Gases[i];
|
||||
|
||||
@@ -169,7 +176,7 @@ namespace Content.Server.GameObjects.EntitySystems.Atmos
|
||||
tileData.Add(data);
|
||||
}
|
||||
|
||||
overlayData = new GasOverlayData(tile.Hotspot.State, tile.Hotspot.Temperature, tileData.Count == 0 ? null : tileData.ToArray());
|
||||
overlayData = new GasOverlayData(tile!.Hotspot.State, tile.Hotspot.Temperature, tileData.Count == 0 ? null : tileData.ToArray());
|
||||
|
||||
if (overlayData.Equals(oldTile))
|
||||
{
|
||||
|
||||
@@ -30,13 +30,11 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
[UsedImplicitly]
|
||||
internal class MoverSystem : SharedMoverSystem
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IPauseManager _pauseManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
#pragma warning restore 649
|
||||
|
||||
private AudioSystem _audioSystem = default!;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user