Skip to content
Permalink
Browse files

Ashley depends on gdx-core (1.2.0)

ImmutableArray and ImmutableIntMap are wrappers of gdx's Array and IntMap
  • Loading branch information
dsaltares committed Jul 12, 2014
1 parent 8b48cca commit 81d9a2e5f38df186f4b147b82ede274c950795b6
Showing with 317 additions and 4,949 deletions.
  1. +8 −7 build.gradle
  2. +3 −2 core/src/com/badlogic/ashley/core/ComponentType.java
  3. +11 −6 core/src/com/badlogic/ashley/core/Engine.java
  4. +8 −5 core/src/com/badlogic/ashley/core/Entity.java
  5. +17 −5 core/src/com/badlogic/ashley/core/Family.java
  6. +6 −7 core/src/com/badlogic/ashley/core/PooledEngine.java
  7. +2 −1 core/src/com/badlogic/ashley/signals/Signal.java
  8. +3 −5 core/src/com/badlogic/ashley/systems/IteratingSystem.java
  9. +0 −477 core/src/com/badlogic/ashley/utils/Array.java
  10. +0 −305 core/src/com/badlogic/ashley/utils/Bits.java
  11. +0 −797 core/src/com/badlogic/ashley/utils/ComparableTimSort.java
  12. +0 −19 core/src/com/badlogic/ashley/utils/Entry.java
  13. +63 −9 core/src/com/badlogic/ashley/utils/ImmutableArray.java
  14. +158 −43 core/src/com/badlogic/ashley/utils/ImmutableIntMap.java
  15. +0 −314 core/src/com/badlogic/ashley/utils/IntArray.java
  16. +0 −800 core/src/com/badlogic/ashley/utils/IntMap.java
  17. +0 −246 core/src/com/badlogic/ashley/utils/MathUtils.java
  18. +0 −49 core/src/com/badlogic/ashley/utils/NumberUtils.java
  19. +0 −682 core/src/com/badlogic/ashley/utils/ObjectMap.java
  20. +0 −92 core/src/com/badlogic/ashley/utils/Pool.java
  21. +0 −61 core/src/com/badlogic/ashley/utils/Pools.java
  22. +0 −63 core/src/com/badlogic/ashley/utils/ReflectionPool.java
  23. +0 −65 core/src/com/badlogic/ashley/utils/Sort.java
  24. +0 −835 core/src/com/badlogic/ashley/utils/TimSort.java
  25. +1 −2 core/tests/com/badlogic/ashley/core/EngineTests.java
  26. +8 −8 core/tests/com/badlogic/ashley/core/EntityTests.java
  27. +1 −1 core/tests/com/badlogic/ashley/signals/SignalTests.java
  28. +24 −35 core/tests/com/badlogic/ashley/utils/ImmutableIntMapTests.java
  29. +1 −1 tests/src/com/badlogic/ashley/tests/BasicTest.java
  30. +1 −1 tests/src/com/badlogic/ashley/tests/SpeedTest.java
  31. +1 −5 tests/src/com/badlogic/ashley/tests/systems/RenderSystem.java
  32. +1 −1 tests/src/com/badlogic/ashley/tests/utils/Timer.java
@@ -18,7 +18,10 @@ allprojects {
}
}

ext.projectGroup = "ashley"
ext {
projectGroup = "ashley"
gdxVersion = '1.2.0'
}

/** needed to disable Java 8 doclint which throws errors **/
allprojects {
@@ -29,17 +32,15 @@ allprojects {

project(":core") {
apply from : '../publish.gradle'

dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
}
}

project(":tests") {

ext {
gdxVersion = '1.2.0'
}

dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
}
@@ -16,8 +16,9 @@

package com.badlogic.ashley.core;

import com.badlogic.ashley.utils.Bits;
import com.badlogic.ashley.utils.ObjectMap;
import com.badlogic.gdx.utils.Bits;
import com.badlogic.gdx.utils.ObjectMap;


/**
* A {@link ComponentType} is used to uniquely identify a Component sub-class by assigning them an index. This is used
@@ -20,12 +20,12 @@

import com.badlogic.ashley.signals.Listener;
import com.badlogic.ashley.signals.Signal;
import com.badlogic.ashley.utils.Array;
import com.badlogic.ashley.utils.ImmutableIntMap;
import com.badlogic.ashley.utils.IntMap;
import com.badlogic.ashley.utils.ObjectMap;
import com.badlogic.ashley.utils.ObjectMap.Entries;
import com.badlogic.ashley.utils.ObjectMap.Entry;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.IntMap;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.ObjectMap.Entries;
import com.badlogic.gdx.utils.ObjectMap.Entry;

/**
* The Engine class is the heart of the Entity framework. It is responsible for keeping track of entities and
@@ -53,6 +53,8 @@
private ObjectMap<Class<?>, EntitySystem> systemsByClass;
/** A hashmap that organises all entities into family buckets */
private ObjectMap<Family, IntMap<Entity>> families;
/** A hashmap that organises all entities into immutable family buckets */
private ObjectMap<Family, ImmutableIntMap<Entity>> immutableFamilies;
/** A collection of entity added/removed event listeners */
private Array<EntityListener> listeners;
/** EntityListeners that await removal */
@@ -70,6 +72,7 @@ public Engine(){
systems = new Array<EntitySystem>();
systemsByClass = new ObjectMap<Class<?>, EntitySystem>();
families = new ObjectMap<Family, IntMap<Entity>>();
immutableFamilies = new ObjectMap<Family, ImmutableIntMap<Entity>>();
listeners = new Array<EntityListener>();
removalPendingListeners = new Array<EntityListener>();
notifying = false;
@@ -206,8 +209,10 @@ public void removeSystem(EntitySystem system){
}
}
families.put(family, entities);
immutableFamilies.put(family, new ImmutableIntMap<Entity>(entities));
}
return families.get(family);

return immutableFamilies.get(family);
}

/**
@@ -17,11 +17,11 @@
package com.badlogic.ashley.core;

import com.badlogic.ashley.signals.Signal;
import com.badlogic.ashley.utils.Array;
import com.badlogic.ashley.utils.Bits;
import com.badlogic.ashley.utils.ImmutableArray;
import com.badlogic.ashley.utils.ObjectMap;
import com.badlogic.ashley.utils.ObjectMap.Keys;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Bits;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.ObjectMap.Keys;

/**
* Entities are simple containers. They can hold components that give them "data". The component's data
@@ -42,6 +42,8 @@
private ObjectMap<Class<? extends Component>, Component> components;
/** An auxiliary array for quick access to all the components of an entity */
private Array<Component> componentsArray;
/** A wrapper around componentsArray so users cannot modify it */
private ImmutableArray<Component> immutableComponentsArray;
/** A Bits describing all the components in this entity. For quick matching. */
private Bits componentBits;
/** A Bits describing all the systems this entity was matched with. */
@@ -60,6 +62,7 @@
public Entity(){
components = new ObjectMap<Class<? extends Component>, Component>();
componentsArray = new Array<Component>();
immutableComponentsArray = new ImmutableArray<Component>(componentsArray);
componentBits = new Bits();
familyBits = new Bits();
flags = 0;
@@ -159,7 +162,7 @@ public Bits getComponentBits(){
* @return immutable array with all the entity components
*/
public ImmutableArray<Component> getComponents() {
return componentsArray;
return immutableComponentsArray;
}

/**
@@ -16,8 +16,9 @@

package com.badlogic.ashley.core;

import com.badlogic.ashley.utils.Bits;
import com.badlogic.ashley.utils.ObjectMap;
import com.badlogic.gdx.utils.Bits;
import com.badlogic.gdx.utils.ObjectMap;


/**
* A family represents a group of components. It is used to describe what entities a system
@@ -160,11 +161,22 @@ public boolean equals(Object obj) {
private static String getFamilyHash(Bits all, Bits one, Bits exclude) {
StringBuilder builder = new StringBuilder();
builder.append("all:");
builder.append(all.toString());
builder.append(getBitsString(all));
builder.append(",one:");
builder.append(one.toString());
builder.append(getBitsString(one));
builder.append(",exclude:");
builder.append(exclude.toString());
builder.append(getBitsString(exclude));
return builder.toString();
}

private static String getBitsString(Bits bits) {
StringBuilder builder = new StringBuilder();

int numBits = bits.length();
for (int i = 0; i < numBits; ++i) {
builder.append(bits.get(i) ? "1" : "0");
}

return builder.toString();
}
}
@@ -16,9 +16,10 @@

package com.badlogic.ashley.core;

import com.badlogic.ashley.utils.Pool;
import com.badlogic.ashley.utils.Pools;
import com.badlogic.ashley.utils.Pool.Poolable;
import com.badlogic.gdx.utils.Pool;
import com.badlogic.gdx.utils.Pool.Poolable;
import com.badlogic.gdx.utils.Pools;


/**
* Engine derived class adding Entity and Component pooling. This improves performance in environments
@@ -33,13 +34,11 @@
public class PooledEngine extends Engine {

private EntityPool entityPool;
private Pools componentPools;

public PooledEngine() {
super();

entityPool = new EntityPool();
componentPools = new Pools();
}

/**
@@ -74,15 +73,15 @@ public void removeEntity(Entity entity){
* @return obtains an available pooled component of the required type
*/
public <T extends Component> T createComponent(Class<T> componentType) {
return componentPools.obtain(componentType);
return Pools.obtain(componentType);
}

private class PooledEntity extends Entity implements Poolable {

@Override
public Component remove(Class<? extends Component> componentType){
Component component = super.remove(componentType);
componentPools.free(component);
Pools.free(component);
return component;
}

@@ -16,7 +16,8 @@

package com.badlogic.ashley.signals;

import com.badlogic.ashley.utils.Array;
import com.badlogic.gdx.utils.Array;


/**
* A Signal is a basic event class then can dispatch an event to multiple listeners. It uses
@@ -21,7 +21,7 @@
import com.badlogic.ashley.core.EntitySystem;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.utils.ImmutableIntMap;
import com.badlogic.ashley.utils.ImmutableIntMap.Keys;
import com.badlogic.gdx.utils.IntMap.Entry;

/**
* A simple EntitySystem that iterates over each entity and calls processEntity() for each entity every time
@@ -68,10 +68,8 @@ public void removedFromEngine(Engine engine) {

@Override
public void update(float deltaTime) {
Keys keys = entities.immutableKeys();

while(keys.hasNext()){
processEntity(entities.get(keys.next()), deltaTime);
for (Entry<Entity> entry : entities) {
processEntity(entry.value, deltaTime);
}
}

0 comments on commit 81d9a2e

Please sign in to comment.
You can’t perform that action at this time.