本文整理汇总了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);
}
}
示例2: Before
public void Before() {
_pool = Helper.CreatePool();
for (int i = 0; i < n; i++) {
_pool.CreateEntity();
}
_e = _pool.CreateEntity();
}
示例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("");
}
示例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());
}
示例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("");
}
示例6: Start
void Start()
{
_pool = new Pool(ComponentIds.TotalComponents);
_systems = createSystems();
_systems.Start();
_pool.CreateEntity().AddMyString("");
}
示例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);
}
示例8: Before
public void Before()
{
_pool = new Pool(CP.NumComponents);
for (int i = 0; i < n; i++) {
_pool.CreateEntity();
}
}
示例9: EditorServices
public EditorServices(IController controller)
{
this.controller = controller;
pool = Pools.pool;
createServices();
pool.CreateEntity()
.AddMaterialReference(controller.MaterialStorage);
}
示例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());
}
}
示例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;
}
示例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);
}
示例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);
}
示例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
}
}
示例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));
});
//.........这里部分代码省略.........