Skip to content

Commit

Permalink
UNITY_2022_2_OR_NEWER instead of VCONTAINER_ECS_INTEGRATION_1_0 p…
Browse files Browse the repository at this point in the history
…reprocessor symbol.
  • Loading branch information
steven.lee committed Feb 1, 2023
1 parent 40a92d3 commit 8f434a1
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 29 deletions.
Expand Up @@ -175,7 +175,7 @@ public NewWorldBuilder(IContainerBuilder containerBuilder, string worldName, Lif

public SystemRegistrationBuilder Add<T>() where T : ComponentSystemBase
=> containerBuilder.RegisterSystemIntoWorld<T>(worldName);
#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
public UnmanagedSystemRegistrationBuilder AddUnmanaged<T>(T system) where T : unmanaged, ISystem
=> containerBuilder.RegisterUnmanagedSystemIntoWorld<T>(worldName);
#endif
Expand All @@ -192,7 +192,7 @@ public DefaultWorldBuilder(IContainerBuilder containerBuilder)

public RegistrationBuilder Add<T>() where T : ComponentSystemBase
=> containerBuilder.RegisterSystemFromDefaultWorld<T>();
#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
public RegistrationBuilder AddUnmanaged<T>() where T : unmanaged, ISystem
=> containerBuilder.RegisterUnmanagedSystemFromDefaultWorld<T>();
#endif
Expand All @@ -209,15 +209,15 @@ public static void UseDefaultWorld(this IContainerBuilder builder, Action<Defaul
public static RegistrationBuilder RegisterSystemFromDefaultWorld<T>(this IContainerBuilder builder)
where T : ComponentSystemBase
=> RegisterSystemFromWorld<T>(builder, World.DefaultGameObjectInjectionWorld);
#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
public static RegistrationBuilder RegisterUnmanagedSystemFromDefaultWorld<T>(this IContainerBuilder builder)
where T : unmanaged, ISystem
=> RegisterUnmanagedSystemFromWorld<T>(builder, World.DefaultGameObjectInjectionWorld);
#endif
public static RegistrationBuilder RegisterSystemFromWorld<T>(this IContainerBuilder builder, World world)
where T : ComponentSystemBase
{
#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
var system = world.GetExistingSystemManaged<T>();
#else
var system = world.GetExistingSystem<T>();
Expand All @@ -228,7 +228,7 @@ public static RegistrationBuilder RegisterSystemFromWorld<T>(this IContainerBuil
return builder.RegisterComponent(system)
.As(typeof(ComponentSystemBase), typeof(T));
}
#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
public static RegistrationBuilder RegisterUnmanagedSystemFromWorld<T>(this IContainerBuilder builder, World world)
where T : unmanaged, ISystem
{
Expand Down Expand Up @@ -289,7 +289,7 @@ public static RegistrationBuilder RegisterUnmanagedSystemFromWorld<T>(this ICont
return builder.Register(registrationBuilder);
}

#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
public static UnmanagedSystemRegistrationBuilder RegisterUnmanagedSystemIntoWorld<T>(
this IContainerBuilder builder,
string worldName)
Expand Down Expand Up @@ -332,7 +332,7 @@ public static SystemRegistrationBuilder RegisterSystemIntoDefaultWorld<T>(this I
return builder.Register(registrationBuilder);
}

#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
public static UnmanagedSystemRegistrationBuilder RegisterUnmanagedSystemIntoDefaultWorld<T>(this IContainerBuilder builder)
where T : unmanaged, ISystem
{
Expand Down
Expand Up @@ -38,15 +38,15 @@ public object SpawnInstance(IObjectResolver resolver)
if (instance is null)
{
instance = (ComponentSystemBase)injector.CreateInstance(resolver, customParameters);
#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
world.AddSystemManaged(instance);
#else
world.AddSystem(instance);
#endif

if (systemGroupType != null)
{
#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
var systemGroup = (ComponentSystemGroup)world.GetOrCreateSystemManaged(systemGroupType);
#else
var systemGroup = (ComponentSystemGroup)world.GetOrCreateSystem(systemGroupType);
Expand All @@ -56,7 +56,7 @@ public object SpawnInstance(IObjectResolver resolver)

return instance;
}
#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
return world.GetExistingSystemManaged(systemType);
#else
return world.GetExistingSystem(systemType);
Expand Down
@@ -1,4 +1,4 @@
#if VCONTAINER_ECS_INTEGRATION_1_0
#if VCONTAINER_ECS_INTEGRATION && UNITY_2022_2_OR_NEWER
using System;
using System.Collections.Generic;
using Unity.Entities;
Expand Down
Expand Up @@ -25,7 +25,7 @@ public object SpawnInstance(IObjectResolver resolver)
}
else
{
#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
world.CreateSystemManaged<InitializationSystemGroup>();
world.CreateSystemManaged<SimulationSystemGroup>();
world.CreateSystemManaged<PresentationSystemGroup>();
Expand Down
@@ -1,4 +1,4 @@
#if VCONTAINER_ECS_INTEGRATION_1_0
#if VCONTAINER_ECS_INTEGRATION && UNITY_2022_2_OR_NEWER
using System;
using Unity.Entities;

Expand Down
@@ -1,4 +1,4 @@
#if VCONTAINER_ECS_INTEGRATION_1_0
#if VCONTAINER_ECS_INTEGRATION && UNITY_2022_2_OR_NEWER
using System;
using System.Collections.Generic;
using Unity.Entities;
Expand Down
5 changes: 0 additions & 5 deletions VContainer/Assets/VContainer/Runtime/VContainer.asmdef
Expand Up @@ -18,11 +18,6 @@
"expression": "",
"define": "VCONTAINER_ECS_INTEGRATION"
},
{
"name": "com.unity.entities",
"expression": "(0.20,999)",
"define": "VCONTAINER_ECS_INTEGRATION_1_0"
},
{
"name": "com.cysharp.unitask",
"expression": "",
Expand Down
10 changes: 5 additions & 5 deletions VContainer/Assets/VContainer/Tests/Unity/EcsTest.cs
Expand Up @@ -30,7 +30,7 @@ class SystemB : ComponentSystemBase, IDisposable
public override void Update() => UpdateCalled = true;
public void Dispose() => Disposed = true;
}
#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER


[DisableAutoCreation]
Expand Down Expand Up @@ -92,7 +92,7 @@ public void RegisterSystemFromDefaultWorld()
Assert.That(system, Is.InstanceOf<SystemA>());
Assert.That(system.Service, Is.InstanceOf<I2>());
}
#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
[Test]
public void RegisterUnmanagedSystemFromDefaultWorld()
{
Expand Down Expand Up @@ -121,7 +121,7 @@ public void RegisterSystemIntoDefaultWorld()
Assert.That(system.World, Is.EqualTo(World.DefaultGameObjectInjectionWorld));
}

#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
[Test]
public void RegisterUnmanagedSystemIntoDefaultWorld()
{
Expand Down Expand Up @@ -172,7 +172,7 @@ public void RegisterSystemIntoWorld()

Assert.That(world.IsCreated, Is.True);
Assert.That(system.World, Is.EqualTo(world));
#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
Assert.That(world.GetExistingSystemManaged<SystemB>(), Is.EqualTo(system));
#else
Assert.That(world.GetExistingSystem<SystemB>(), Is.EqualTo(system));
Expand All @@ -182,7 +182,7 @@ public void RegisterSystemIntoWorld()
Assert.That(world.IsCreated, Is.False);
Assert.That(system.Disposed, Is.True);
}
#if VCONTAINER_ECS_INTEGRATION_1_0
#if UNITY_2022_2_OR_NEWER
[Test]
public void RegisterUnManagedSystemIntoWorld()
{
Expand Down
5 changes: 0 additions & 5 deletions VContainer/Assets/VContainer/Tests/VContainer.Tests.asmdef
Expand Up @@ -31,11 +31,6 @@
"name": "com.unity.entities",
"expression": "",
"define": "VCONTAINER_ECS_INTEGRATION"
},
{
"name": "com.unity.entities",
"expression": "(0.20,999)",
"define": "VCONTAINER_ECS_INTEGRATION_1_0"
}
],
"noEngineReferences": false
Expand Down

0 comments on commit 8f434a1

Please sign in to comment.