From 38d0f33d2a09f9f08b80be2e7505a288624dca0d Mon Sep 17 00:00:00 2001 From: Shaun Reich Date: Fri, 14 Apr 2017 15:52:06 -0400 Subject: [PATCH] all renderers moved over into their own systems --- core/src/com/ore/infinium/OreWorld.kt | 4 +++ .../ore/infinium/systems/SystemProfiler.kt | 2 +- .../systems/client/DebugTextRenderSystem.kt | 1 - .../systems/client/LiquidRenderSystem.kt | 25 +++++++++---------- .../systems/client/SpriteRenderSystem.kt | 22 +++++++--------- 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/core/src/com/ore/infinium/OreWorld.kt b/core/src/com/ore/infinium/OreWorld.kt index 94af6ea..b464f64 100644 --- a/core/src/com/ore/infinium/OreWorld.kt +++ b/core/src/com/ore/infinium/OreWorld.kt @@ -197,6 +197,10 @@ class OreWorld .with(TileRenderSystem(camera = camera, fullscreenCamera = client!!.viewport.camera, oreWorld = this)) + + .with(SpriteRenderSystem(camera = camera, + oreWorld = this)) + .with(LiquidRenderSystem(camera=camera,oreWorld=this)) .with(DebugTextRenderSystem(camera, this)) .with(PowerOverlayRenderSystem(oreWorld = this, fullscreenCamera = client!!.viewport.camera, diff --git a/core/src/com/ore/infinium/systems/SystemProfiler.kt b/core/src/com/ore/infinium/systems/SystemProfiler.kt index 4af0902..b9b5ee7 100644 --- a/core/src/com/ore/infinium/systems/SystemProfiler.kt +++ b/core/src/com/ore/infinium/systems/SystemProfiler.kt @@ -29,7 +29,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -class SystemProfiler() : ArtemisProfiler { +class SystemProfiler : ArtemisProfiler { val counterWindowSize = 5 diff --git a/core/src/com/ore/infinium/systems/client/DebugTextRenderSystem.kt b/core/src/com/ore/infinium/systems/client/DebugTextRenderSystem.kt index b13aa3a..edd011c 100644 --- a/core/src/com/ore/infinium/systems/client/DebugTextRenderSystem.kt +++ b/core/src/com/ore/infinium/systems/client/DebugTextRenderSystem.kt @@ -124,7 +124,6 @@ class DebugTextRenderSystem(camera: OrthographicCamera, font.color = Color.ORANGE fontGenerator.dispose() - } override fun processSystem() { diff --git a/core/src/com/ore/infinium/systems/client/LiquidRenderSystem.kt b/core/src/com/ore/infinium/systems/client/LiquidRenderSystem.kt index 0b0b85e..11820a9 100644 --- a/core/src/com/ore/infinium/systems/client/LiquidRenderSystem.kt +++ b/core/src/com/ore/infinium/systems/client/LiquidRenderSystem.kt @@ -24,8 +24,7 @@ SOFTWARE. package com.ore.infinium.systems.client -import com.artemis.ComponentMapper -import com.artemis.World +import com.artemis.BaseSystem import com.artemis.annotations.Wire import com.artemis.managers.TagManager import com.badlogic.gdx.graphics.OrthographicCamera @@ -33,17 +32,16 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.ore.infinium.OreBlock import com.ore.infinium.OreWorld import com.ore.infinium.components.SpriteComponent -import com.ore.infinium.systems.OreSubSystem import com.ore.infinium.systems.server.TileLightingSystem import com.ore.infinium.util.MAX_SPRITES_PER_BATCH +import com.ore.infinium.util.RenderSystemMarker +import com.ore.infinium.util.mapper +import com.ore.infinium.util.system @Wire class LiquidRenderSystem(private val camera: OrthographicCamera, - private val oreWorld: OreWorld, - private val world: World, - val tileRenderSystem: TileRenderSystem - ) -: OreSubSystem() { + private val oreWorld: OreWorld) + : BaseSystem(), RenderSystemMarker { //indicates if tiles should be drawn, is a debug flag. var debugRenderTiles = true //false if lighting should be disabled/ignored @@ -51,13 +49,14 @@ class LiquidRenderSystem(private val camera: OrthographicCamera, private val batch: SpriteBatch = SpriteBatch(MAX_SPRITES_PER_BATCH) - private lateinit var mSprite: ComponentMapper + private val mSprite by mapper() - private lateinit var clientNetworkSystem: ClientNetworkSystem - private lateinit var tagManager: TagManager + private val clientNetworkSystem by system() + private val tileRenderSystem by system() + private val tagManager by system() override fun processSystem() { - if (!debugRenderTiles) { + if (!debugRenderTiles || !clientNetworkSystem.connected) { return } @@ -141,7 +140,7 @@ class LiquidRenderSystem(private val camera: OrthographicCamera, blockType: Byte, blockMeshType: Byte, liquidLevel: Byte): String { - var textureName: String ? = null + var textureName: String? = null when (blockType) { OreBlock.BlockType.Water.oreValue -> { if (liquidLevel.toInt() == 0) { diff --git a/core/src/com/ore/infinium/systems/client/SpriteRenderSystem.kt b/core/src/com/ore/infinium/systems/client/SpriteRenderSystem.kt index b505b5e..2f319cc 100644 --- a/core/src/com/ore/infinium/systems/client/SpriteRenderSystem.kt +++ b/core/src/com/ore/infinium/systems/client/SpriteRenderSystem.kt @@ -29,8 +29,7 @@ import aurelienribon.tweenengine.Tween import aurelienribon.tweenengine.TweenEquations import aurelienribon.tweenengine.TweenManager import aurelienribon.tweenengine.equations.Sine -import com.artemis.ComponentMapper -import com.artemis.World +import com.artemis.BaseSystem import com.artemis.annotations.Wire import com.artemis.managers.TagManager import com.artemis.utils.IntBag @@ -40,29 +39,26 @@ import com.badlogic.gdx.graphics.GL20 import com.badlogic.gdx.graphics.OrthographicCamera import com.badlogic.gdx.graphics.g2d.Sprite import com.badlogic.gdx.graphics.g2d.SpriteBatch -import com.badlogic.gdx.graphics.glutils.FrameBuffer import com.badlogic.gdx.graphics.glutils.ShaderProgram import com.ore.infinium.OreWorld import com.ore.infinium.SpriteTween import com.ore.infinium.components.ItemComponent import com.ore.infinium.components.SpriteComponent -import com.ore.infinium.systems.OreSubSystem import com.ore.infinium.util.* import ktx.assets.file @Wire -class SpriteRenderSystem(private val world: World, - private val oreWorld: OreWorld, - private val camera: OrthographicCamera, - private val tileLightMapFbo: FrameBuffer) - : OreSubSystem() { +class SpriteRenderSystem(private val oreWorld: OreWorld, + private val camera: OrthographicCamera) + : BaseSystem(), RenderSystemMarker { private lateinit var batch: SpriteBatch - private lateinit var mSprite: ComponentMapper - private lateinit var mItem: ComponentMapper + private val mSprite by mapper() + private val mItem by mapper() - private lateinit var tagManager: TagManager + private val tagManager by system() + private val tileRenderSystem by system() private lateinit var tweenManager: TweenManager private lateinit var defaultShader: ShaderProgram @@ -109,7 +105,7 @@ class SpriteRenderSystem(private val world: World, batch.shader = spriteLightMapBlendShader Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE0 + 1) - tileLightMapFbo.colorBufferTexture.bind(1) + tileRenderSystem.tileLightMapFbo.colorBufferTexture.bind(1) Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE0) batch.begin()