Skip to content

Commit 20fb823

Browse files
committed
💚 Experimental net7 builder for net6
1 parent b1d2e84 commit 20fb823

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

‎.github/workflows/build.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup .NET
1717
uses: actions/setup-dotnet@v2
1818
with:
19-
dotnet-version: 6.0.x
19+
dotnet-version: 7.0.x
2020

2121
- name: Install GitVersion
2222
uses: gittools/actions/gitversion/[email protected]

‎ECSExtensions.cs‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11

2+
using System;
23
using Bloodstone.API;
34
using Il2CppInterop.Runtime;
45
using Unity.Entities;
56

67

78
/// <remarks>
89
/// Copying these around is an anti-pattern - they should live in Bloodstone. I've put them here for now to uncouple things.
10+
/// CS8500
911
/// </remarks>
12+
#pragma warning disable CS8500
1013
internal static class ECSExtensions
1114
{
1215
internal static void With<T>(this Entity entity, VExtensions.ActionRef<T> action) where T : struct
@@ -16,24 +19,33 @@ internal static void With<T>(this Entity entity, VExtensions.ActionRef<T> action
1619
VWorld.Game.EntityManager.SetComponentData(entity, item);
1720
}
1821

19-
internal static bool Has<T>(this Entity entity)
22+
internal static bool Has<T>(this Entity entity) where T : struct
2023
{
2124
int typeIndex = TypeManager.GetTypeIndex(Il2CppType.Of<T>());
2225

2326
return VWorld.Game.EntityManager.HasComponentRaw(entity, typeIndex);
2427
}
2528

26-
internal unsafe static T RW<T>(this Entity entity)
29+
internal unsafe static T RW<T>(this Entity entity) where T: struct
2730
{
2831
int typeIndex = TypeManager.GetTypeIndex(Il2CppType.Of<T>());
2932
T* componentDataRawRW = (T*)VWorld.Game.EntityManager.GetComponentDataRawRW(entity, typeIndex);
33+
if (componentDataRawRW == null)
34+
{
35+
throw new InvalidOperationException($"Failure to access ReadWrite <{typeof(T).Name}> typeIndex({typeIndex}) on entity({entity}).");
36+
}
3037
return *componentDataRawRW;
3138
}
3239

33-
internal unsafe static T Read<T>(this Entity entity)
40+
internal unsafe static T Read<T>(this Entity entity) where T : struct
3441
{
3542
int typeIndex = TypeManager.GetTypeIndex(Il2CppType.Of<T>());
3643
T* componentDataRawRO = (T*)VWorld.Game.EntityManager.GetComponentDataRawRO(entity, typeIndex);
44+
if(componentDataRawRO == null)
45+
{
46+
throw new InvalidOperationException($"Failure to access ReadOnly <{typeof(T).Name}> typeIndex({typeIndex}) on entity({entity}).");
47+
}
3748
return *componentDataRawRO;
3849
}
3950
}
51+
#pragma warning restore CS8500

0 commit comments

Comments
 (0)