当前位置: 首页>>代码示例>>C#>>正文


C# Pool.CreateEntity方法代码示例

本文整理汇总了C#中Entitas.Pool.CreateEntity方法的典型用法代码示例。如果您正苦于以下问题:C# Pool.CreateEntity方法的具体用法?C# Pool.CreateEntity怎么用?C# Pool.CreateEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entitas.Pool的用法示例。


在下文中一共展示了Pool.CreateEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ensures_same_deterministic_order_when_getting_entities_after_DestroyAllEntities

	public void ensures_same_deterministic_order_when_getting_entities_after_DestroyAllEntities() {
		var pool = new Pool(1);

		const int numEntities = 10;
		for (int i = 0; i < numEntities; i++) {
			pool.CreateEntity();
		}

		var order1 = new int[numEntities];
		var entities1 = pool.GetEntities();
		for (int i = 0; i < numEntities; i++) {
			order1[i] = entities1[i].creationIndex;
		}

		pool.DestroyAllEntities();
		pool.ResetCreationIndex();

		for (int i = 0; i < numEntities; i++) {
			pool.CreateEntity();
		}

		var order2 = new int[numEntities];
		var entities2 = pool.GetEntities();
		for (int i = 0; i < numEntities; i++) {
			order2[i] = entities2[i].creationIndex;
		}

		for (int i = 0; i < numEntities; i++) {
			var index1 = order1[i];
			var index2 = order2[i];

			Assert.AreEqual(index1, index2);
		}
	}
开发者ID:Cotoff,项目名称:Entitas-CSharp,代码行数:34,代码来源:PoolTests.cs

示例2: Before

 public void Before() {
     _pool = Helper.CreatePool();
     for (int i = 0; i < n; i++) {
         _pool.CreateEntity();
     }
     _e = _pool.CreateEntity();
 }
开发者ID:ChicK00o,项目名称:Entitas-CSharp,代码行数:7,代码来源:PoolHasEntity.cs

示例3: Start

 void Start() {
     _pool = new Pool(ComponentIds.TotalComponents, 0, new PoolMetaData("Systems Pool", ComponentIds.componentNames));
     new PoolObserver(_pool, ComponentIds.componentTypes);
     _systems = createNestedSystems();
     _systems.Initialize();
     _pool.CreateEntity().AddMyString("");
 }
开发者ID:ChicK00o,项目名称:Entitas-CSharp,代码行数:7,代码来源:SystemsController.cs

示例4: Before

 public void Before() {
     _pool = new Pool(CP.NumComponents);
     _pool.GetGroup(Matcher.AllOf(new [] { CP.ComponentA }));
     _pool.GetGroup(Matcher.AllOf(new [] { CP.ComponentB }));
     _pool.GetGroup(Matcher.AllOf(new [] { CP.ComponentC }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentA,
         CP.ComponentB
     }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentA,
         CP.ComponentC
     }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentB,
         CP.ComponentC
     }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentA,
         CP.ComponentB,
         CP.ComponentC
     }));
     _e = _pool.CreateEntity();
     _e.AddComponent(CP.ComponentA, new ComponentA());
 }
开发者ID:ntl92bk,项目名称:Entitas-CSharp,代码行数:25,代码来源:EntityRemoveAddComponent.cs

示例5: Start

 void Start() {
     _pool = new Pool(ComponentIds.TotalComponents);
     new PoolObserver(_pool, ComponentIds.componentNames, ComponentIds.componentTypes, "Systems Pool");
     _systems = createSystems();
     _systems.Initialize();
     _pool.CreateEntity().AddMyString("");
 }
开发者ID:ntl92bk,项目名称:Entitas-CSharp,代码行数:7,代码来源:SystemsController.cs

示例6: Start

 void Start()
 {
     _pool = new Pool(ComponentIds.TotalComponents);
     _systems = createSystems();
     _systems.Start();
     _pool.CreateEntity().AddMyString("");
 }
开发者ID:mihail-georgiev,项目名称:Entitas-CSharp,代码行数:7,代码来源:SystemsController.cs

示例7: Before

 public void Before() {
     _pool = Helper.CreatePool();
     _pool.GetGroup(Matcher.AllOf(new [] { CP.ComponentA }));
     _pool.GetGroup(Matcher.AllOf(new [] { CP.ComponentB }));
     _pool.GetGroup(Matcher.AllOf(new [] { CP.ComponentC }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentA,
         CP.ComponentB
     }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentA,
         CP.ComponentC
     }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentB,
         CP.ComponentC
     }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentA,
         CP.ComponentB,
         CP.ComponentC
     }));
     _e = _pool.CreateEntity();
     _componentA = new ComponentA();
     _e.AddComponent(CP.ComponentA, _componentA);
 }
开发者ID:ChicK00o,项目名称:Entitas-CSharp,代码行数:26,代码来源:EntityRemoveAddComponent.cs

示例8: Before

 public void Before()
 {
     _pool = new Pool(CP.NumComponents);
     for (int i = 0; i < n; i++) {
         _pool.CreateEntity();
     }
 }
开发者ID:fversnel,项目名称:Entitas-CSharp,代码行数:7,代码来源:PoolDestroyAllEntites.cs

示例9: EditorServices

 public EditorServices(IController controller)
 {
     this.controller = controller;
     pool = Pools.pool;
     createServices();
     pool.CreateEntity()
         .AddMaterialReference(controller.MaterialStorage);
 }
开发者ID:kicholen,项目名称:SpaceShooter,代码行数:8,代码来源:EditorServices.cs

示例10: Before

    public void Before() {
        var pool = new Pool(CP.NumComponents);
        var group = pool.GetGroup(Matcher.AllOf(new [] { CP.ComponentA }));
        _observer = group.CreateObserver();

        for (int i = 0; i < 1000; i++) {
            var e = pool.CreateEntity();
            e.AddComponent(CP.ComponentA, new ComponentA());
        }
    }
开发者ID:ntl92bk,项目名称:Entitas-CSharp,代码行数:10,代码来源:ObserverIterateCollectedEntities.cs

示例11: createReactiveSystem

    static ReactiveSystem createReactiveSystem(Pool pool) {
        var subSystem = new ReactiveSubSystemSpy(Matcher.AllOf(new[] {
            CID.ComponentA
        }), GroupEventType.OnEntityAdded);

        var reactiveSystem = new ReactiveSystem(pool, subSystem);
        pool.CreateEntity().AddComponentA();

        return reactiveSystem;
    }
开发者ID:ntl92bk,项目名称:Entitas-CSharp,代码行数:10,代码来源:describe_Systems.cs

示例12: Before

    public void Before()
    {
        _pool = Helper.CreatePool();

        var e = _pool.CreateEntity();
        var component = new NameAgeComponent();
        component.name = "Max";
        component.age = 42;
        e.AddComponent(CP.ComponentA, component);

        _blueprint = new Blueprint(string.Empty, string.Empty, e);
    }
开发者ID:Cotoff,项目名称:Entitas-CSharp,代码行数:12,代码来源:PoolCreateBlueprint.cs

示例13: createTestEntityWithNullValues

    void createTestEntityWithNullValues(Pool pool)
    {
        var e = pool.CreateEntity();

        // Unity's builtIn
        AnimationCurve animationCurve = null;
        e.AddAnimationCurve(animationCurve);
        String myString = null;
        e.AddMyString(myString);
        UnityEngine.Object unityObject = null;
        e.AddUnityObject(unityObject);
        GameObject go = null;
        e.AddGameObject(go);
        Texture texture = null;
        e.AddTexture(texture);
        Texture2D texture2D = null;
        e.AddTexture2D(texture2D);

        // Custom
        MonoBehaviourSubClass monoBehaviourSubClass = null;
        e.AddMonoBehaviourSubClass(monoBehaviourSubClass);
        CustomObject customObject = null;
        e.AddCustomObject(customObject);
        object systemObject = null;
        e.AddSystemObject(systemObject);
        string[] array = null;
        e.AddAnArray(array);
        string[,] array2d = null;
        e.AddArray2D(array2d);
        string[,,] array3d = null;
        e.AddArray3D(array3d);
        string[][] jaggedArray = null;
        e.AddJaggedArray(jaggedArray);
        List<string>[] listArray = null;
        e.AddListArray(listArray);
        List<string> list = null;
        e.AddList(list);
        Dictionary<string, string> dict = null;
        e.AddDictionary(dict);
        Dictionary<int, string[]> dict2 = null;
        Dictionary<int, string[]>[] dictArray = null;
        e.AddDictArray(dict2, dictArray);
        HashSet<string> hashset = null;
        e.AddHashSet(hashset);
        UnsupportedObject unsupportedObject = null;
        e.AddUnsupportedObject(unsupportedObject);
    }
开发者ID:robinryf,项目名称:Entitas-CSharp,代码行数:47,代码来源:GameController.cs

示例14: poolExample

        static void poolExample()
        {
            // Total components is kindly generated for you by the code generator
            var pool = new Pool(ComponentIds.TotalComponents);
            var entity = pool.CreateEntity();
            entity.isMovable = true;

            // Returns all entities having MovableComponent and PositionComponent.
            // Matchers are also generated for you.
            var entities = pool.GetEntities(Matcher.AllOf(Matcher.Movable, Matcher.Position));
            foreach (var e in entities) {
                // do something
            }
        }
开发者ID:fversnel,项目名称:Entitas-CSharp,代码行数:14,代码来源:ReadmeSnippets.cs

示例15: when_throwing

    void when_throwing()
    {
        Pool pool = null;
        Entity entity = null;
        before = () => {
            var componentNames = new [] { "Health", "Position", "View" };
            var metaData = new PoolMetaData("My Pool", componentNames, null);
            pool = new Pool(componentNames.Length, 42, metaData);
            entity = pool.CreateEntity();
        };

        it["creates exception with hint separated by newLine"] = () => {
            var msg = "Message";
            var hint = "Hint";
            var ex = new EntitasException(msg, hint);
            ex.Message.should_be(msg + "\n" + hint);
        };

        it["ignores hint when null"] = () => {
            var msg = "Message";
            string hint = null;
            var ex = new EntitasException(msg, hint);
            ex.Message.should_be(msg);
        };

        context["Entity"] = () => {

            context["when not enabled"] = () => {

                before = () => {
                    pool.DestroyEntity(entity);
                };

                it["add a component"] = () => printErrorMessage(() => entity.AddComponentA());
                it["remove a component"] = () => printErrorMessage(() => entity.RemoveComponentA());
                it["replace a component"] = () => printErrorMessage(() => entity.ReplaceComponentA(Component.A));
            };

            context["when enabled"] = () => {
                it["add a component twice"] = () => printErrorMessage(() => {
                    entity.AddComponentA();
                    entity.AddComponentA();
                });

                it["remove a component that doesn't exist"] = () => printErrorMessage(() => {
                    entity.RemoveComponentA();
                });

                it["get a component that doesn't exist"] = () => printErrorMessage(() => {
                    entity.GetComponentA();
                });

                it["retain an entity twice"] = () => printErrorMessage(() => {
                    var owner = new object();
                    entity.Retain(owner);
                    entity.Retain(owner);
                });

                it["release an entity with wrong owner"] = () => printErrorMessage(() => {
                    var owner = new object();
                    entity.Release(owner);
                });
            };
        };

        context["Group"] = () => {

            it["get single entity when multiple exist"] = () => printErrorMessage(() => {
                pool.CreateEntity().AddComponentA();
                pool.CreateEntity().AddComponentA();
                var matcher = (Matcher)Matcher.AllOf(CID.ComponentA);
                matcher.componentNames = new [] { "Health", "Position", "View" };
                var group = pool.GetGroup(matcher);
                group.GetSingleEntity();
            });
        };

        context["GroupObserver"] = () => {

            it["unbalanced goups"] = () => printErrorMessage(() => {
                var g1 = new Group(Matcher.AllOf(CID.ComponentA));
                var g2 = new Group(Matcher.AllOf(CID.ComponentB));
                var e1 = GroupEventType.OnEntityAdded;

                new GroupObserver(new [] { g1, g2 }, new [] { e1 });
            });
        };

        context["Pool"] = () => {

            it["wrong PoolMetaData componentNames count"] = () => printErrorMessage(() => {
                var componentNames = new [] { "Health", "Position", "View" };
                var metaData = new PoolMetaData("My Pool", componentNames, null);
                new Pool(1, 0, metaData);
            });

            it["destroy entity which is not in pool"] = () => printErrorMessage(() => {
                pool.DestroyEntity(new Entity(0, null));
            });

//.........这里部分代码省略.........
开发者ID:Cotoff,项目名称:Entitas-CSharp,代码行数:101,代码来源:describe_EntitasErrorMessages.cs


注:本文中的Entitas.Pool.CreateEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。