Skip to content

Commit cdb618c

Browse files
committed
fix: Only set system group when DOTS world is available.
1 parent bdebb67 commit cdb618c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

VisualPinball.Unity/VisualPinball.Unity/VPT/CollidableApi.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ public abstract class CollidableApi<TComponent, TCollidableComponent, TData> : I
2828
where TData : ItemData
2929
{
3030
public bool IsCollidable {
31-
get => _simulateCycleSystemGroup.ItemsColliding[Entity];
32-
set => _simulateCycleSystemGroup.ItemsColliding[Entity] = value;
31+
get => _simulateCycleSystemGroup != null && _simulateCycleSystemGroup.ItemsColliding[Entity];
32+
set {
33+
if (_simulateCycleSystemGroup != null) {
34+
_simulateCycleSystemGroup.ItemsColliding[Entity] = value;
35+
}
36+
}
3337
}
34-
38+
3539
protected readonly Entity Entity;
3640
protected readonly TCollidableComponent ColliderComponent;
3741

@@ -40,7 +44,9 @@ public bool IsCollidable {
4044

4145
protected CollidableApi(GameObject go, Entity entity, Player player) : base(go, player)
4246
{
43-
_simulateCycleSystemGroup = World.DefaultGameObjectInjectionWorld.GetOrCreateSystem<SimulateCycleSystemGroup>();
47+
if (World.DefaultGameObjectInjectionWorld != null) {
48+
_simulateCycleSystemGroup = World.DefaultGameObjectInjectionWorld.GetOrCreateSystem<SimulateCycleSystemGroup>();
49+
}
4450
EntityManager = World.DefaultGameObjectInjectionWorld != null ? World.DefaultGameObjectInjectionWorld.EntityManager : default;
4551
Entity = entity;
4652

0 commit comments

Comments
 (0)