Skip to content

Commit

Permalink
Merge pull request #111 from DaanVanYperen/develop
Browse files Browse the repository at this point in the history
Ludum dare release
  • Loading branch information
DaanVanYperen committed Dec 10, 2016
2 parents f9e2b8f + 2ec4256 commit 6c9f7cc
Show file tree
Hide file tree
Showing 96 changed files with 1,346 additions and 537 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ with all fancy features, check out these instead:
- [playn-artemis-quickstart](https://github.com/DaanVanYperen/playn-artemis-quickstart)

### Library Versions
Artemis-odb 2.0.x, (Optional) LibGDX 1.9+, tested with 1.9.4.
Artemis-odb 2.1.x, (Optional) LibGDX 1.9.0-1.9.4, tested with 1.9.4.

### License
The primary license for this code is MIT.
Expand All @@ -32,21 +32,21 @@ Some stubs from LibGDX are licensed under Apache 2.0.
<dependency>
<groupId>net.mostlyoriginal.artemis-odb</groupId>
<artifactId>contrib-core</artifactId>
<version>1.2.1</version>
<version>2.1</version>
</dependency>

<dependency>
<groupId>net.mostlyoriginal.artemis-odb</groupId>
<artifactId>contrib-eventbus</artifactId>
<version>1.2.1</version>
<version>2.1</version>
</dependency>
```

#### Gradle

```groovy
dependencies {
compile "net.mostlyoriginal.artemis-odb:contrib-core:1.2.1"
compile "net.mostlyoriginal.artemis-odb:contrib-eventbus:1.2.1"
compile "net.mostlyoriginal.artemis-odb:contrib-core:2.1"
compile "net.mostlyoriginal.artemis-odb:contrib-eventbus:2.1"
}
```
2 changes: 1 addition & 1 deletion contrib-benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>net.mostlyoriginal.artemis-odb</groupId>
<artifactId>contrib-parent</artifactId>
<version>1.2.1</version>
<version>2.1.0</version>
</parent>
<artifactId>contrib-benchmark</artifactId>
<packaging>jar</packaging>
Expand Down
23 changes: 21 additions & 2 deletions contrib-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>net.mostlyoriginal.artemis-odb</groupId>
<artifactId>contrib-parent</artifactId>
<version>1.2.1</version>
<version>2.1.0</version>
</parent>
<artifactId>contrib-core</artifactId>
<packaging>jar</packaging>
Expand All @@ -27,6 +27,25 @@
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx</artifactId>
<scope>test</scope>
<version>${libgdx.version}</version>
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-lwjgl</artifactId>
<scope>test</scope>
<version>${libgdx.version}</version>
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-platform</artifactId>
<classifier>natives-desktop</classifier>
<scope>test</scope>
<version>${libgdx.version}</version>
</dependency>
</dependencies>

<build>
Expand All @@ -47,4 +66,4 @@
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.mostlyoriginal.api.component.common;

import com.artemis.PooledComponent;
import com.artemis.annotations.Fluid;

import java.io.Serializable;

Expand All @@ -13,6 +14,7 @@
*
* @author Daan van Yperen
*/
@Fluid(swallowGettersWithParameters = true)
public abstract class ExtendedComponent<T extends ExtendedComponent> extends PooledComponent
implements Serializable, Mirrorable<T> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ public interface Mirrorable<T extends Component & Mirrorable> {
* @param t component to mirror
* @return {@code this}
*/
T set(T t);
void set(T t);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public interface Tweenable<T extends Component & Tweenable<T>> {
* @param value tween (0..1)
* @return {@code this}
*/
T tween(T a, T b, float value);
void tween(T a, T b, float value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public boolean isMirrorable() {
* @return the instance of the component
*/
public A getSafe(int entityId, A fallback) {
final A c = getSafe(entityId);
final A c = get(entityId);
return (c != null) ? c : fallback;
}

Expand Down Expand Up @@ -96,9 +96,11 @@ public A mirror(int targetId, int sourceId) {
throw new RuntimeException("Component does not extend ExtendedComponent<T> or just Mirrorable<T>, required for #set.");
}

final A source = getSafe(sourceId);
final A source = get(sourceId);
if ( source != null ) {
return (A) ((Mirrorable)create(targetId)).set(source);
Mirrorable mirrorable = (Mirrorable) create(targetId);
mirrorable.set(source);
return (A) mirrorable;
} else {
remove(targetId);
return null;
Expand Down Expand Up @@ -169,17 +171,6 @@ public A get(Entity e) throws ArrayIndexOutOfBoundsException {
return mapper.get(e);
}

@Deprecated
public A getSafe(Entity e, boolean forceNewInstance) {
A component = mapper.get(e);

if(component == null && forceNewInstance) {
component = mapper.create(e);
}

return component;
}

public A get(int entityId) throws ArrayIndexOutOfBoundsException {
return mapper.get(entityId);
}
Expand All @@ -196,21 +187,21 @@ public boolean has(Entity e) throws ArrayIndexOutOfBoundsException {
return mapper.has(e);
}

/**
* @deprecated as of odb version 2.0.0 {@see #get} is as safe as getSafe.
*/
public A getSafe(Entity e) {
return mapper.get(e);
}

public boolean has(int entityId) {
return mapper.has(entityId);
}

/** Get instance of M for passed component type. moderately efficient. */
public static <T extends Component> M<T> getFor(Class<T> type, World world) {
return world.getSystem(ExtendedComponentMapperManager.class).getFor(type);
}

/** Get instance of M for passed component. moderately efficient. */
@SuppressWarnings("unchecked")
public static <T extends Component> M<T> getFor(T component, World world) {
return getFor((Class<T>)component.getClass(), world);
}

public A get(Entity e, boolean forceNewInstance) throws ArrayIndexOutOfBoundsException {
A component = mapper.get(e);

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,28 @@ protected void process(Entity e) {
createAndProcessWorld(new TestSystem());
}

@Test
public void Regression_When_superMapper_plugin_in_use_Should_not_break_regular_object_inection() {

class Injectable {}
class TestSystem extends BaseSystem {

private M<TestMarker> mTest;
@Wire Injectable injectable;

@Override
protected void processSystem() {
Assert.assertNotNull(injectable);
}
}

WorldConfiguration configuration = new WorldConfigurationBuilder()
.dependsOn(ExtendedComponentMapperPlugin.class)
.with(new TestSystem())
.build();

configuration.register(new Injectable());

new World(configuration).process();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ protected void reset() {
}

@Override
public Pos set(Pos pos) {
public void set(Pos pos) {
x = pos.x;
y = pos.y;
return this;
}
}
Loading

0 comments on commit 6c9f7cc

Please sign in to comment.