//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by Entitas.CodeGeneration.Plugins.ComponentContextApiGenerator.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public partial class TestContext {

    public TestEntity uniqueFlagEntity { get { return GetGroup(TestMatcher.UniqueFlag).GetSingleEntity(); } }

    public bool isUniqueFlag {
        get { return uniqueFlagEntity != null; }
        set {
            var entity = uniqueFlagEntity;
            if (value != (entity != null)) {
                if (value) {
                    CreateEntity().isUniqueFlag = true;
                } else {
                    entity.Destroy();
                }
            }
        }
    }
}

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public partial class TestEntity {

    static readonly UniqueFlagComponent uniqueFlagComponent = new UniqueFlagComponent();

    public bool isUniqueFlag {
        get { return HasComponent(TestComponentsLookup.UniqueFlag); }
        set {
            if (value != isUniqueFlag) {
                var index = TestComponentsLookup.UniqueFlag;
                if (value) {
                    var componentPool = GetComponentPool(index);
                    var component = componentPool.Count > 0
                            ? componentPool.Pop()
                            : uniqueFlagComponent;

                    AddComponent(index, component);
                } else {
                    RemoveComponent(index);
                }
            }
        }
    }
}

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public sealed partial class TestMatcher {

    static Entitas.IMatcher<TestEntity> _matcherUniqueFlag;

    public static Entitas.IMatcher<TestEntity> UniqueFlag {
        get {
            if (_matcherUniqueFlag == null) {
                var matcher = (Entitas.Matcher<TestEntity>)Entitas.Matcher<TestEntity>.AllOf(TestComponentsLookup.UniqueFlag);
                matcher.componentNames = TestComponentsLookup.componentNames;
                _matcherUniqueFlag = matcher;
            }

            return _matcherUniqueFlag;
        }
    }
}
