Skip to content

Commit

Permalink
all renderers moved over into their own systems
Browse files Browse the repository at this point in the history
  • Loading branch information
sreich committed Apr 14, 2017
1 parent 9cc8056 commit 38d0f33
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
4 changes: 4 additions & 0 deletions core/src/com/ore/infinium/OreWorld.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/ore/infinium/systems/SystemProfiler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class DebugTextRenderSystem(camera: OrthographicCamera,
font.color = Color.ORANGE

fontGenerator.dispose()

}

override fun processSystem() {
Expand Down
25 changes: 12 additions & 13 deletions core/src/com/ore/infinium/systems/client/LiquidRenderSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,39 @@ 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
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
var debugTilesInViewCount: Int = 0

private val batch: SpriteBatch = SpriteBatch(MAX_SPRITES_PER_BATCH)

private lateinit var mSprite: ComponentMapper<SpriteComponent>
private val mSprite by mapper<SpriteComponent>()

private lateinit var clientNetworkSystem: ClientNetworkSystem
private lateinit var tagManager: TagManager
private val clientNetworkSystem by system<ClientNetworkSystem>()
private val tileRenderSystem by system<TileRenderSystem>()
private val tagManager by system<TagManager>()

override fun processSystem() {
if (!debugRenderTiles) {
if (!debugRenderTiles || !clientNetworkSystem.connected) {
return
}

Expand Down Expand Up @@ -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) {
Expand Down
22 changes: 9 additions & 13 deletions core/src/com/ore/infinium/systems/client/SpriteRenderSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<SpriteComponent>
private lateinit var mItem: ComponentMapper<ItemComponent>
private val mSprite by mapper<SpriteComponent>()
private val mItem by mapper<ItemComponent>()

private lateinit var tagManager: TagManager
private val tagManager by system<TagManager>()
private val tileRenderSystem by system<TileRenderSystem>()
private lateinit var tweenManager: TweenManager

private lateinit var defaultShader: ShaderProgram
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 38d0f33

Please sign in to comment.