Fix IEntity.TryGetComponent nullability signatures.

This means all invocations of TryGetComponent now need a nullable parameter because, well, the result can be null. that's the point.
This commit is contained in:
Pieter-Jan Briers
2020-08-20 15:31:18 +02:00
parent 1513389fc1
commit d4fc0517c4
17 changed files with 36 additions and 35 deletions
@@ -55,7 +55,7 @@ namespace Robust.Client.GameObjects.EntitySystems
private static void UpdateEntity(IEntity entity)
{
if (entity.TryGetComponent(out SpriteComponent sprite))
if (entity.TryGetComponent(out SpriteComponent? sprite))
{
sprite.ContainerOccluded = false;
@@ -73,7 +73,7 @@ namespace Robust.Client.GameObjects.EntitySystems
}
}
if (entity.TryGetComponent(out PointLightComponent light))
if (entity.TryGetComponent(out PointLightComponent? light))
{
light.ContainerOccluded = false;
@@ -126,7 +126,7 @@ namespace Robust.Client.GameObjects.EntitySystems
if(entity == null || !entity.IsValid())
throw new ArgumentNullException(nameof(entity));
if (!entity.TryGetComponent(out InputComponent inputComp))
if (!entity.TryGetComponent(out InputComponent? inputComp))
{
Logger.DebugS("input.context", $"AttachedEnt has no InputComponent: entId={entity.Uid}, entProto={entity.Prototype}");
return;
@@ -40,7 +40,7 @@ namespace Robust.Client.GameObjects.EntitySystems
while (_dirtyEntities.TryDequeue(out var entity))
{
if (!entity.Deleted
&& entity.TryGetComponent(out ClientOccluderComponent occluder)
&& entity.TryGetComponent(out ClientOccluderComponent? occluder)
&& occluder.UpdateGeneration != _updateGeneration)
{
occluder.Update();
@@ -54,7 +54,7 @@ namespace Robust.Client.GameObjects.EntitySystems
{
var sender = ev.Sender;
if (sender.IsValid() &&
sender.TryGetComponent(out ClientOccluderComponent iconSmooth)
sender.TryGetComponent(out ClientOccluderComponent? iconSmooth)
&& iconSmooth.Running)
{
var snapGrid = sender.GetComponent<SnapGridComponent>();
@@ -105,7 +105,7 @@ namespace Robust.Client.GameObjects.EntitySystems
private void UpdateEntity(IEntity entity)
{
if (entity.TryGetComponent(out SpriteComponent spriteComponent))
if (entity.TryGetComponent(out SpriteComponent? spriteComponent))
{
if (!spriteComponent.TreeUpdateQueued)
{
@@ -115,12 +115,12 @@ namespace Robust.Client.GameObjects.EntitySystems
}
}
if (entity.TryGetComponent(out ClientOccluderComponent occluder))
if (entity.TryGetComponent(out ClientOccluderComponent? occluder))
{
QueueUpdateOccluder(occluder);
}
if (entity.TryGetComponent(out PointLightComponent light))
if (entity.TryGetComponent(out PointLightComponent? light))
{
QueueUpdateLight(light);
}
@@ -158,21 +158,21 @@ namespace Robust.Client.GameObjects.EntitySystems
var oldMapTrees = _mapTrees.GetValueOrDefault(ev.OldMapId);
var newMapTrees = _mapTrees.GetValueOrDefault(ev.Entity.Transform.MapID);
if (ev.Entity.TryGetComponent(out SpriteComponent sprite))
if (ev.Entity.TryGetComponent(out SpriteComponent? sprite))
{
oldMapTrees?.SpriteTree.Remove(sprite);
newMapTrees?.SpriteTree.AddOrUpdate(sprite);
}
if (ev.Entity.TryGetComponent(out ClientOccluderComponent occluder))
if (ev.Entity.TryGetComponent(out ClientOccluderComponent? occluder))
{
oldMapTrees?.OccluderTree.Remove(occluder);
newMapTrees?.OccluderTree.AddOrUpdate(occluder);
}
if (ev.Entity.TryGetComponent(out PointLightComponent light))
if (ev.Entity.TryGetComponent(out PointLightComponent? light))
{
oldMapTrees?.LightTree.Remove(light);