Skip to content

Commit

Permalink
Fix a few simple nullability issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jvbsl committed Dec 19, 2021
1 parent 6586b8a commit 9f76ddb
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using OctoAwesome.Components;
using OctoAwesome.EntityComponents;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;

Expand Down Expand Up @@ -134,7 +136,7 @@ public void Draw(GameTime gameTime, RenderTarget2D shadowMap, Matrix view, Matri
if (!success)
continue;

SetTransforms(chunkOffset, planetSize, entity, rendercomp, modelinfo);
SetTransforms(chunkOffset, planetSize, entity, rendercomp!, modelinfo);
modelinfo.model.Draw(effect);
}

Expand Down Expand Up @@ -218,6 +220,7 @@ private void SetShadowTransforms<T>(Index3 chunkOffset, Index2 planetSize, Compo
private static Matrix GetWorldMatrix<T>(Index3 chunkOffset, Index2 planetSize, ComponentContainer<T> componentContainer, RenderComponent rendercomp, float zOffset = 0.0f) where T : IComponent
{
var positioncomp = componentContainer.Components.GetComponent<PositionComponent>();
Debug.Assert(positioncomp != null, nameof(positioncomp) + " != null");
var position = positioncomp.Position;
var body = componentContainer.Components.GetComponent<BodyComponent>();

Expand All @@ -233,7 +236,7 @@ private static Matrix GetWorldMatrix<T>(Index3 chunkOffset, Index2 planetSize, C
return world;
}

private bool TryGetRenderInfo<T>(ComponentContainer<T> componentContainer, out RenderComponent rendercomp, out ModelInfo modelinfo) where T : IComponent
private bool TryGetRenderInfo<T>(ComponentContainer<T> componentContainer, [MaybeNullWhen(false)] out RenderComponent rendercomp, out ModelInfo modelinfo) where T : IComponent
{
rendercomp = null;
modelinfo = default;
Expand All @@ -244,6 +247,7 @@ private bool TryGetRenderInfo<T>(ComponentContainer<T> componentContainer, out R

rendercomp = componentContainer.Components.GetComponent<RenderComponent>();

Debug.Assert(rendercomp != null, nameof(rendercomp) + " != null");
if (!models.TryGetValue(rendercomp.Name, out modelinfo))
{
modelinfo = new ModelInfo()
Expand Down

0 comments on commit 9f76ddb

Please sign in to comment.