Skip to content

Commit

Permalink
Added AshleyEngineJson class to support component pooling
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin.sciesinski committed Feb 1, 2021
1 parent a6ddf7a commit dba1278
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ allprojects {
apply plugin: "maven-publish"

group = "com.gempukku.libgdx.lib"
version = '0.1.12-SNAPSHOT'
version = '0.1.12'
ext {
appName = "Libgdx Graph"
gdxVersion = '1.9.12'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.gempukku.libgdx.lib.template.ashley;

import com.badlogic.ashley.core.Component;
import com.badlogic.ashley.core.Engine;
import com.badlogic.gdx.utils.Json;
import com.badlogic.gdx.utils.JsonWriter;
import com.badlogic.gdx.utils.reflect.ClassReflection;

public class AshleyEngineJson extends Json {
private Engine engine;

public AshleyEngineJson(Engine engine) {
this.engine = engine;
}

public AshleyEngineJson(JsonWriter.OutputType outputType, Engine engine) {
super(outputType);
this.engine = engine;
}

@Override
protected Object newInstance(Class type) {
if (ClassReflection.isAssignableFrom(Component.class, type))
return engine.createComponent(type);
return super.newInstance(type);
}
}

0 comments on commit dba1278

Please sign in to comment.