From 79ae458b47229377a515d1188305642e0514ae62 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Thu, 23 Nov 2023 09:08:52 -0800 Subject: [PATCH] Fix leftover nullability warnings (#175) * Fix leftover nullability warnings * Another fix --- src/Arch/Core/EntityInfo.cs | 2 +- src/Arch/Core/Extensions/EntityExtensions.cs | 2 +- src/Arch/Core/Extensions/WorldExtensions.cs | 4 ++-- src/Arch/Core/Utils/CompileTimeStatics.cs | 2 +- src/Arch/Core/Utils/EntityDebugView.cs | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Arch/Core/EntityInfo.cs b/src/Arch/Core/EntityInfo.cs index 1007c6ca..76b8adf7 100644 --- a/src/Arch/Core/EntityInfo.cs +++ b/src/Arch/Core/EntityInfo.cs @@ -109,7 +109,7 @@ internal EntityInfoStorage() ); EntitySlots = new JaggedArray( cpuL1CacheSize / Unsafe.SizeOf(), - new EntitySlot(null, new Slot(-1,-1)), + new EntitySlot(null!, new Slot(-1,-1)), 256 ); } diff --git a/src/Arch/Core/Extensions/EntityExtensions.cs b/src/Arch/Core/Extensions/EntityExtensions.cs index 066a0aae..7acf5bb1 100644 --- a/src/Arch/Core/Extensions/EntityExtensions.cs +++ b/src/Arch/Core/Extensions/EntityExtensions.cs @@ -314,7 +314,7 @@ public static bool HasRange(this in Entity entity, params ComponentType[] types) /// A reference to the component. [MethodImpl(MethodImplOptions.AggressiveInlining)] [Pure] - public static void GetRange(this in Entity entity, ComponentType[] types, IList components) + public static void GetRange(this in Entity entity, ComponentType[] types, IList components) { var world = World.Worlds[entity.WorldId]; world.GetRange(entity, types, components); diff --git a/src/Arch/Core/Extensions/WorldExtensions.cs b/src/Arch/Core/Extensions/WorldExtensions.cs index 9ebb5290..5b7df391 100644 --- a/src/Arch/Core/Extensions/WorldExtensions.cs +++ b/src/Arch/Core/Extensions/WorldExtensions.cs @@ -112,7 +112,7 @@ public static bool HasRange(this World world, Entity entity, params ComponentTyp /// The component . /// A reference to the component. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static object[] GetRange(this World world, Entity entity, params ComponentType[] types) + public static object?[] GetRange(this World world, Entity entity, params ComponentType[] types) { return world.GetRange(entity, types); } @@ -126,7 +126,7 @@ public static object[] GetRange(this World world, Entity entity, params Componen /// A where the components are put it. /// A reference to the component. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void GetRange(this World world, Entity entity, ComponentType[] types, IList components) + public static void GetRange(this World world, Entity entity, ComponentType[] types, IList components) { var entitySlot = world.EntityInfo.GetEntitySlot(entity.Id); for (var index = 0; index < types.Length; index++) diff --git a/src/Arch/Core/Utils/CompileTimeStatics.cs b/src/Arch/Core/Utils/CompileTimeStatics.cs index 29b12b08..0ff83e76 100644 --- a/src/Arch/Core/Utils/CompileTimeStatics.cs +++ b/src/Arch/Core/Utils/CompileTimeStatics.cs @@ -41,7 +41,7 @@ public ComponentType(int id, int byteSize) public Type Type { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => ComponentRegistry.Types[Id]; + get => ComponentRegistry.Types[Id]!; } /// diff --git a/src/Arch/Core/Utils/EntityDebugView.cs b/src/Arch/Core/Utils/EntityDebugView.cs index 63ae4153..f2c76b5b 100644 --- a/src/Arch/Core/Utils/EntityDebugView.cs +++ b/src/Arch/Core/Utils/EntityDebugView.cs @@ -43,17 +43,17 @@ public EntityDebugView(Entity entity) /// /// The s components. /// - public object[] Components { get; } + public object[]? Components { get; } /// /// The this lives in. /// - public World World => IsAlive ? World.Worlds[_entity.WorldId] : null; + public World? World => IsAlive ? World.Worlds[_entity.WorldId] : null; /// /// The this lives in. /// - public Archetype Archetype => IsAlive ? World.Worlds[_entity.WorldId].GetArchetype(_entity) : null; + public Archetype? Archetype => IsAlive ? World.Worlds[_entity.WorldId].GetArchetype(_entity) : null; /// /// The this lives in. @@ -63,7 +63,7 @@ public EntityDebugView(Entity entity) /// /// The stored for this . /// - public EntityInfo EntityInfo => IsAlive ? World.EntityInfo[_entity.Id] : new EntityInfo(); + public EntityInfo EntityInfo => IsAlive ? World?.EntityInfo[_entity.Id] ?? new EntityInfo() : new EntityInfo(); } #endif