Created
December 26, 2018 09:13
-
-
Save Leopotam/f3c963d3dbfb495c7f134787c9775020 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
namespace Leopotam.Ecs.Tests { | |
#if !LEOECS_DISABLE_INJECT | |
[EcsInject] | |
#endif | |
public class Test1 : MonoBehaviour, IEcsInitSystem { | |
EcsWorld _world; | |
class C1_1 { | |
public int Number; | |
} | |
[EcsIgnoreInFilter] | |
class C1_2 { } | |
class C1_3 { } | |
class C1_4 { } | |
class C1_5 { public int Counter; } | |
EcsFilter<C1_1> _filter1 = null; | |
EcsFilter<C1_1, C1_2> _filter2 = null; | |
EcsFilter<C1_1, C1_2>.Exclude<C1_3> _filter3 = null; | |
CustomEcsFilter<C1_4> _customFilter = null; | |
void IEcsInitSystem.Initialize () { | |
#if LEOECS_DISABLE_INJECT | |
_filter1 = _world.GetFilter<EcsFilter<C1_1>> (); | |
_filter2 = _world.GetFilter<EcsFilter<C1_1, C1_2>> (); | |
_filter3 = _world.GetFilter<EcsFilter<C1_1, C1_2>.Exclude<C1_3>> (); | |
#endif | |
Debug.LogFormat ("custom-filter: {0}", _customFilter != null); | |
Debug.LogFormat ("{0} / {1} / {2}", _filter1.EntitiesCount, _filter2.EntitiesCount, _filter3.EntitiesCount); | |
C1_1 c11; | |
var entity = _world.CreateEntityWith<C1_1> (out c11); | |
_world.ProcessDelayedUpdates (); | |
_filter1.Components1[0].Number++; | |
Debug.LogFormat ("{0} / {1} / {2}", _filter1.EntitiesCount, _filter2.EntitiesCount, _filter3.EntitiesCount); | |
_world.AddComponent<C1_2> (entity); | |
_world.ProcessDelayedUpdates (); | |
_filter1.Components1[0].Number++; | |
Debug.LogFormat ("{0} / {1} / {2}", _filter1.EntitiesCount, _filter2.EntitiesCount, _filter3.EntitiesCount); | |
_world.AddComponent<C1_3> (entity); | |
_world.ProcessDelayedUpdates (); | |
_filter1.Components1[0].Number++; | |
Debug.LogFormat ("{0} / {1} / {2}", _filter1.EntitiesCount, _filter2.EntitiesCount, _filter3.EntitiesCount); | |
Debug.LogFormat ("Number: {0}", _filter1.Components1[0].Number); | |
Debug.LogFormat ("_filter2.Component2[0]: {0}", _filter2.Components2 != null); | |
C1_1 c1out; | |
C1_2 c2out; | |
C1_3 c3out; | |
_world.CreateEntityWith<C1_1, C1_2, C1_3> (out c1out, out c2out, out c3out); | |
Debug.LogFormat ("{0}, {1}, {2}", c1out != null, c2out != null, c3out != null); | |
} | |
void IEcsInitSystem.Destroy () { | |
_filter1 = null; | |
_filter2 = null; | |
_filter3 = null; | |
_world = null; | |
} | |
void OnEnable () { | |
var world = new EcsWorld (); | |
var systems = new EcsSystems (world); | |
systems.Add (this); | |
systems.Initialize (); | |
systems.Run (); | |
systems.Dispose (); | |
world.Dispose (); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment