com.artemis.Component Java Examples
The following examples show how to use
com.artemis.Component.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityDeleterSystem.java From entity-system-benchmarks with Apache License 2.0 | 5 votes |
public EntityDeleterSystem(long seed, int entityCount, Class<? extends Component> c1, Class<? extends Component> c2) { this.c1 = c1; this.c2 = c2; Random rng = new Random(seed); ENTITY_COUNT = entityCount; ids = new int[ENTITY_COUNT]; for (int i = 0; ids.length > i; i++) ids[i] = (int)(rng.nextFloat() * ENTITY_COUNT); }
Example #2
Source File: EntityManglerSystem.java From entity-system-benchmarks with Apache License 2.0 | 5 votes |
@Override public void initialize() { for (int i = 0; permutations.length > i; i++) { Array<Class<? extends Component>> components = new Array<Class<? extends Component>>(); for (int classIndex = 0, s = (int)(rng.nextFloat() * 7) + 3; s > classIndex; classIndex++) { components.add(types.get((int)(rng.nextFloat() * types.size))); } permutations[i] = components; } for (int i = 0; ENTITY_COUNT > i; i++) createEntity(); }
Example #3
Source File: EntityManglerSystem.java From entity-system-benchmarks with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private final void createEntity() { Entity e = world.createEntity(); Array<Class<? extends Component>> components = permutations[cmp[cmpIndex++]]; if (cmpIndex == cmp.length) cmpIndex = 0; Object[] data = components.items; for (int i = 0, s = components.size; s > i; i++) { e.addComponent(world.createComponent((Class<Component>) data[i])); } e.addToWorld(); }
Example #4
Source File: EntityDeleterSystem.java From entity-system-benchmarks with Apache License 2.0 | 5 votes |
public EntityDeleterSystem(long seed, int entityCount, Class<? extends Component> c1, Class<? extends Component> c2) { this.c1 = c1; this.c2 = c2; Random rng = new Random(seed); ENTITY_COUNT = entityCount; ids = new int[ENTITY_COUNT]; for (int i = 0; ids.length > i; i++) ids[i] = (int)(rng.nextFloat() * ENTITY_COUNT); }
Example #5
Source File: EntityManglerSystem.java From entity-system-benchmarks with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public EntityManglerSystem(long seed, int entityCount) { // 4096 entities = 256 compositions, 262144 = 2048 entityPermutations = (int)Math.sqrt(entityCount * 16); rng = new Random(seed); ENTITY_COUNT = entityCount; RENEW = ENTITY_COUNT / 4; ArrayList<Integer> idsList = new ArrayList<Integer>(); for (int i = 0; ENTITY_COUNT > i; i++) idsList.add(i); Collections.shuffle(idsList); ids = new int[ENTITY_COUNT]; for (int i = 0; ids.length > i; i++) ids[i] = idsList.get(i); types = new Bag<Class<? extends Component>>(); types.add(Comp1.class); types.add(Comp2.class); types.add(Comp3.class); types.add(Comp4.class); types.add(Comp5.class); types.add(Comp6.class); types.add(Comp7.class); types.add(Comp8.class); types.add(Comp9.class); types.add(Comp10.class); types.add(Comp11.class); types.add(Comp12.class); permutations = new Bag[entityPermutations]; cmp = new int[ENTITY_COUNT * 4]; for (int i = 0; cmp.length > i; i++) cmp[i] = (int)(rng.nextFloat() * permutations.length); }
Example #6
Source File: EntityManglerSystem.java From entity-system-benchmarks with Apache License 2.0 | 5 votes |
@Override protected void initialize() { for (int i = 0; permutations.length > i; i++) { Bag<Class<? extends Component>> components = new Bag<Class<? extends Component>>(); for (int classIndex = 0, s = (int)(rng.nextFloat() * 7) + 3; s > classIndex; classIndex++) { components.add(types.get((int)(rng.nextFloat() * types.size()))); } permutations[i] = components; } for (int i = 0; ENTITY_COUNT > i; i++) createEntity(); }
Example #7
Source File: EntityManglerSystem.java From entity-system-benchmarks with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private final void createEntity() { Entity e = world.createEntity(); Bag<Class<? extends Component>> components = permutations[cmp[cmpIndex++]]; if (cmpIndex == cmp.length) cmpIndex = 0; Object[] data = components.getData(); for (int i = 0, s = components.size(); s > i; i++) { e.addComponent(newInstance(data[i])); } e.addToWorld(); }
Example #8
Source File: EntityDeleterSystem.java From entity-system-benchmarks with Apache License 2.0 | 5 votes |
public EntityDeleterSystem(long seed, int entityCount, Class<? extends Component> c1, Class<? extends Component> c2) { this.c1 = c1; this.c2 = c2; Random rng = new Random(seed); ENTITY_COUNT = entityCount; ids = new int[ENTITY_COUNT]; for (int i = 0; ids.length > i; i++) ids[i] = (int)(rng.nextFloat() * ENTITY_COUNT); }
Example #9
Source File: EntityManglerSystem.java From entity-system-benchmarks with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public EntityManglerSystem(long seed, int entityCount) { // 4096 entities = 256 compositions, 262144 = 2048 int entityPermutations = (int)Math.sqrt(entityCount * 16); rng = new Random(seed); ENTITY_COUNT = entityCount; RENEW = ENTITY_COUNT / 4; ArrayList<Integer> idsList = new ArrayList<Integer>(); for (int i = 0; ENTITY_COUNT > i; i++) idsList.add(i); Collections.shuffle(idsList); ids = new int[ENTITY_COUNT]; for (int i = 0; ids.length > i; i++) ids[i] = idsList.get(i); // ids[i] = (int)(rng.nextFloat() * ENTITY_COUNT); types = new Bag<Class<? extends Component>>(); types.add(Comp1.class); types.add(Comp2.class); types.add(Comp3.class); types.add(Comp4.class); types.add(Comp5.class); types.add(Comp6.class); types.add(Comp7.class); types.add(Comp8.class); types.add(Comp9.class); types.add(Comp10.class); types.add(Comp11.class); types.add(Comp12.class); permutations = new Archetype[entityPermutations]; cmp = new int[ENTITY_COUNT * 4]; for (int i = 0; cmp.length > i; i++) cmp[i] = (int)(rng.nextFloat() * permutations.length); }
Example #10
Source File: SerializationManager.java From riiablo with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("unchecked") protected void initialize() { serializers = new ObjectMap<>(); // serializers.put(com.riiablo.engine.server.component.Class.class, new ClassSerializer()); serializers.put(CofComponents.class, new CofComponentsSerializer()); serializers.put(CofTransforms.class, new CofTransformsSerializer()); serializers.put(CofAlphas.class, new CofAlphasSerializer()); serializers.put(Position.class, new PositionSerializer()); serializers.put(Velocity.class, new VelocitySerializer()); serializers.put(Angle.class, new AngleSerializer()); serializers.put(Player.class, new PlayerSerializer()); serializers.put(DS1ObjectWrapper.class, new DS1ObjectWrapperSerializer()); serializers.put(Warp.class, new WarpSerializer()); serializers.put(Monster.class, new MonsterSerializer()); serializers.put(Item.class, new ItemSerializer()); deserializers = (Class<? extends Component>[]) new Class[ComponentP.names.length]; // deserializers[SyncData.ClassP] = com.riiablo.engine.server.component.Class.class; deserializers[ComponentP.CofComponentsP] = CofComponents.class; deserializers[ComponentP.CofTransformsP] = CofTransforms.class; deserializers[ComponentP.CofAlphasP] = CofAlphas.class; deserializers[ComponentP.PositionP] = Position.class; deserializers[ComponentP.VelocityP] = Velocity.class; deserializers[ComponentP.AngleP] = Angle.class; deserializers[ComponentP.PlayerP] = Player.class; deserializers[ComponentP.DS1ObjectWrapperP] = DS1ObjectWrapper.class; deserializers[ComponentP.WarpP] = Warp.class; deserializers[ComponentP.MonsterP] = Monster.class; deserializers[ComponentP.ItemP] = Item.class; cm = new ComponentMapper[ComponentP.names.length]; cm[ComponentP.ClassP] = null; //mClass; cm[ComponentP.CofComponentsP] = null; cm[ComponentP.CofTransformsP] = null; cm[ComponentP.CofAlphasP] = null; cm[ComponentP.PositionP] = mPosition; cm[ComponentP.VelocityP] = mVelocity; cm[ComponentP.AngleP] = mAngle; cm[ComponentP.PlayerP] = null; cm[ComponentP.DS1ObjectWrapperP] = mDS1ObjectWrapper; cm[ComponentP.WarpP] = null; cm[ComponentP.MonsterP] = null; cm[ComponentP.ItemP] = null; }
Example #11
Source File: EntityManglerSystem.java From entity-system-benchmarks with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public EntityManglerSystem(long seed, int entityCount) { // 4096 entities = 256 compositions, 262144 = 2048 entityPermutations = (int)Math.sqrt(entityCount * 16); rng = new Random(seed); ENTITY_COUNT = entityCount; RENEW = ENTITY_COUNT / 4; ArrayList<Integer> idsList = new ArrayList<Integer>(); for (int i = 0; ENTITY_COUNT > i; i++) idsList.add(i); Collections.shuffle(idsList); ids = new int[ENTITY_COUNT]; for (int i = 0; ids.length > i; i++) ids[i] = idsList.get(i); // ids[i] = (int)(rng.nextFloat() * ENTITY_COUNT); types = new Array<Class<? extends Component>>(); types.add(Comp1.class); types.add(Comp2.class); types.add(Comp3.class); types.add(Comp4.class); types.add(Comp5.class); types.add(Comp6.class); types.add(Comp7.class); types.add(Comp8.class); types.add(Comp9.class); types.add(Comp10.class); types.add(Comp11.class); types.add(Comp12.class); permutations = new Array[entityPermutations]; // for (int i = 0; permutations.length > i; i++) { // Bag<Class<? extends Component>> components = new Bag<Class<? extends Component>>(); // for (int classIndex = 0, s = (int)(rng.nextFloat() * 7); s > classIndex; classIndex++) { // components.add(types.get((int)(rng.nextFloat() * types.size()))); // } // permutations[i] = components; // } // permutations = new Archetype[entityPermutations]; cmp = new int[ENTITY_COUNT * 4]; for (int i = 0; cmp.length > i; i++) cmp[i] = (int)(rng.nextFloat() * permutations.length); }