From 11dc6631bc7ce4e79dee6ff93018c8a94ecc7918 Mon Sep 17 00:00:00 2001 From: DaanVanYperen Date: Sun, 11 Sep 2016 21:11:59 +0200 Subject: [PATCH] Fluid entity support. --- build.gradle | 10 ++++++++- components/build.gradle | 8 +++++++ core/build.gradle | 21 ++++++++++++++++++- .../game/screen/GameScreen.java | 2 ++ .../screen/detection/OdbFeatureScreen.java | 2 ++ .../system/view/GameScreenSetupSystem.java | 7 +++++++ settings.gradle | 2 +- 7 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 components/build.gradle diff --git a/build.gradle b/build.gradle index f6ea94c..12b06af 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { appVersion = '1.5' gdxVersion = '1.9.4' - artemisVersion = '2.0.0' + artemisVersion = '2.1.0-SNAPSHOT' artemisContribVersion = '1.2.1' roboVMVersion = '2.2.0' //box2DLightsVersion = '1.4' @@ -27,6 +27,9 @@ buildscript { // lib for artemis-odb weaving. // see https://github.com/junkdog/artemis-odb/wiki/Bytecode-weaving classpath "net.onedaybeard.artemis:artemis-odb-gradle-plugin:$artemisVersion" + + // lib for artemis-odb fluid. + classpath "net.onedaybeard.artemis:artemis-fluid-gradle-plugin:$artemisVersion" } } @@ -160,6 +163,10 @@ project(":html") { } } +project(":components") { + apply plugin: "java" +} + project(":core") { apply plugin: "java" @@ -173,6 +180,7 @@ project(":core") { } dependencies { + compile project(":components") compile "com.badlogicgames.gdx:gdx:$gdxVersion" // Optional LibGDX Modules diff --git a/components/build.gradle b/components/build.gradle new file mode 100644 index 0000000..62d9601 --- /dev/null +++ b/components/build.gradle @@ -0,0 +1,8 @@ +apply plugin: "java" + +sourceCompatibility = 1.7 +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' +sourceSets.main.java.srcDirs = ["src/"] +eclipse.project { + name = appName + "-components" +} \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle index 019e348..56bc49b 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,9 +1,14 @@ apply plugin: "java" apply plugin: "artemis" +apply plugin: "artemis-fluid" + +ext { + fluidOutputDir = file("$buildDir/generated-sources/fluid/") +} sourceCompatibility = 1.7 [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' -sourceSets.main.java.srcDirs = ["src/"] +sourceSets.main.java.srcDirs = ["src/",fluidOutputDir] eclipse.project { name = appName + "-core" } @@ -16,6 +21,20 @@ weave { classesDir = sourceSets.main.output.classesDir } +fluid { + generatedSourcesDirectory = fluidOutputDir; + classpath = sourceSets.main.compileClasspath +} +compileJava.dependsOn fluid + +idea.module { + excludeDirs -= file("$buildDir") + excludeDirs += file("$buildDir/classes") + excludeDirs += file("$buildDir/dependency-cache") + excludeDirs += file("$buildDir/libs") + excludeDirs += file("$buildDir/tmp") +} + classes.finalizedBy weave dependencies { diff --git a/core/src/net/mostlyoriginal/game/screen/GameScreen.java b/core/src/net/mostlyoriginal/game/screen/GameScreen.java index 9a754e8..a090bc1 100644 --- a/core/src/net/mostlyoriginal/game/screen/GameScreen.java +++ b/core/src/net/mostlyoriginal/game/screen/GameScreen.java @@ -1,5 +1,6 @@ package net.mostlyoriginal.game.screen; +import com.artemis.SuperMapper; import com.artemis.World; import com.artemis.WorldConfigurationBuilder; import com.badlogic.gdx.graphics.Color; @@ -28,6 +29,7 @@ protected World createWorld() { .dependsOn(OperationsPlugin.class) .with( // Replace with your own systems! + new SuperMapper(), new CameraSystem(1), new ClearScreenSystem(Color.valueOf(BACKGROUND_COLOR_HEX)), new GameScreenAssetSystem(), diff --git a/core/src/net/mostlyoriginal/game/screen/detection/OdbFeatureScreen.java b/core/src/net/mostlyoriginal/game/screen/detection/OdbFeatureScreen.java index b766d2b..56caf9a 100644 --- a/core/src/net/mostlyoriginal/game/screen/detection/OdbFeatureScreen.java +++ b/core/src/net/mostlyoriginal/game/screen/detection/OdbFeatureScreen.java @@ -1,5 +1,6 @@ package net.mostlyoriginal.game.screen.detection; +import com.artemis.SuperMapper; import com.artemis.World; import com.artemis.WorldConfigurationBuilder; import com.artemis.managers.TagManager; @@ -31,6 +32,7 @@ protected World createWorld() { .dependsOn(OperationsPlugin.class) .with(WorldConfigurationBuilder.Priority.HIGH, // supportive + new SuperMapper(), new TagManager(), new CameraSystem(1), new FeatureScreenAssetSystem(), diff --git a/core/src/net/mostlyoriginal/game/system/view/GameScreenSetupSystem.java b/core/src/net/mostlyoriginal/game/system/view/GameScreenSetupSystem.java index 612a501..779538e 100644 --- a/core/src/net/mostlyoriginal/game/system/view/GameScreenSetupSystem.java +++ b/core/src/net/mostlyoriginal/game/system/view/GameScreenSetupSystem.java @@ -5,6 +5,8 @@ import net.mostlyoriginal.api.system.core.PassiveSystem; import net.mostlyoriginal.game.util.Anims; +import static com.artemis.E.E; + /** * @author Daan van Yperen */ @@ -16,6 +18,11 @@ public class GameScreenSetupSystem extends PassiveSystem { @Override protected void initialize() { + E(world.create()) + .pos() + .anim() + .renderable(); + Anims.createCenteredAt(world, GameScreenAssetSystem.DANCING_MAN_WIDTH, GameScreenAssetSystem.DANCING_MAN_HEIGHT, diff --git a/settings.gradle b/settings.gradle index 5502d7d..8967e37 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include 'desktop', 'android', 'ios', 'html', 'matrix', 'core' \ No newline at end of file +include 'desktop', 'android', 'ios', 'html', 'matrix', 'core','components' \ No newline at end of file