Skip to content

Commit

Permalink
upgrade to artemis 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sreich committed Apr 15, 2017
1 parent 4dabe6b commit 67fa601
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 15 deletions.
5 changes: 1 addition & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {

aiVersion = '1.8.1'

artemisVersion = '1.4.0'
artemisVersion = '2.1.0'
artemisContribVersion = '1.2.1'
kryonetVersion = '2.22.0-RC1'

Expand Down Expand Up @@ -309,9 +309,6 @@ project(":desktop") {

// Artemis-odb bonus functionality (systems, events, components).
compile "net.mostlyoriginal.artemis-odb:contrib-core:$artemisContribVersion"
compile "net.mostlyoriginal.artemis-odb:contrib-jam:$artemisContribVersion"
compile "net.mostlyoriginal.artemis-odb:contrib-eventbus:$artemisContribVersion"
compile "net.mostlyoriginal.artemis-odb:contrib-plugin-operations:$artemisContribVersion"

// jcommander for command line parsing
compile "com.beust:jcommander:$jcommanderVersion"
Expand Down
6 changes: 4 additions & 2 deletions core/src/com/ore/infinium/Inventory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ open class Inventory
}

class InventorySlot(var entityId: Int,
val slotType: InventorySlotType) {
}
val slotType: InventorySlotType)

var slots = mutableListOf<InventorySlot>()
private set
Expand Down Expand Up @@ -197,6 +196,9 @@ open class Inventory
private fun canCombineItems(itemId: Int, itemInSlotId: Int): Boolean {
val itemComp1 = mItem.get(itemId)
val itemComp2 = mItem.get(itemInSlotId)
if (itemComp2 == null) {
println()
}
if (!itemComp1.canCombineWith(itemComp2)) {
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class GameLoopSystemInvocationStrategy
profiler.counter.tick()
}

override fun process(systems: Bag<BaseSystem>) {
override fun process() {
if (!isServer) {
// frameProfiler.start()
}
Expand Down
1 change: 0 additions & 1 deletion core/src/com/ore/infinium/systems/SpatialSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class SpatialSystem(private val oreWorld: OreWorld) : IteratingSystem(Aspect.all
var quadTree: QuadTree

init {

quadTree = QuadTree(0f, 0f, oreWorld.worldSize.width.toFloat(), oreWorld.worldSize.height.toFloat())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ class ClientNetworkSystem(private val oreWorld: OreWorld) : BaseSystem() {

val cItem = mItem.get(spawnedItemEntityId)

require(cItem.inventoryIndex != -1) { "told to spawn item at invalid index" }

//fixme this indirection isn't so hot...
inventory.setSlot(cItem.inventoryIndex, spawnedItemEntityId)
}
Expand Down Expand Up @@ -470,7 +472,7 @@ class ClientNetworkSystem(private val oreWorld: OreWorld) : BaseSystem() {
sprite.setPosition(spawn.pos.x, spawn.pos.y)
}

val cGenerator = mGenerator.getSafe(localEntityId)?.let {
val cGenerator = mGenerator.opt(localEntityId)?.let {
//recreate this on our end. since it is transient
it.fuelSources = GeneratorInventory(GeneratorInventory.MAX_SLOTS)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,16 @@ class ServerNetworkSystem(private val oreWorld: OreWorld, private val oreServer:
owningPlayerEntityId: Int,
inventoryType: Network.Shared.InventoryType,
causedByPickedUpItem: Boolean = false) {
//assert(entityIdsToSpawn.size > 0) { "entities to spawn in inventory should be non 0" }
require(entityIdsToSpawn.isNotEmpty()) { "entities to spawn in inventory should be non 0" }

val spawn = Network.Server.SpawnInventoryItems()
spawn.causedByPickedUpItem = causedByPickedUpItem
spawn.typeOfInventory = inventoryType

for (entityId in entityIdsToSpawn) {
val cItem = mItem.get(entityId)
require(cItem.inventoryIndex != -1) { "attempting to send invalid inventory index item spawn" }

val entitySpawn = serializeInventoryEntitySpawn(entityId)

spawn.entitiesToSpawn.add(entitySpawn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class ServerPowerSystem(private val oreWorld: OreWorld) : IteratingSystem(anyOf(
}

private fun updateDevice(entityId: Int) {
val cGen = mPowerGenerator.getSafe(entityId)
val cGen = mPowerGenerator.opt(entityId)

cGen?.let {
when (cGen.type) {
Expand Down
4 changes: 0 additions & 4 deletions core/src/com/ore/infinium/util/ArtemisExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ interface CopyableComponent<T : CopyableComponent<T>> {
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.PROPERTY_GETTER)
annotation class DoNotPrint

fun TagManager.getEntityId(tag: String): Int {
return this.getEntity(tag)!!.id
}

fun World.entities(aspect: Aspect.Builder): IntBag =
this.aspectSubscriptionManager.get(aspect).entities

Expand Down

0 comments on commit 67fa601

Please sign in to comment.