mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 10:34:06 +09:00
using kotlin's newfangled 'x in xs.indices' instead of 'x in 0 until xs.size'
This commit is contained in:
@@ -407,7 +407,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
// scan for the one with non-null UI.
|
||||
// what if there's multiple of such fixtures? whatever, you are supposed to DISALLOW such situation.
|
||||
for (kk in 0 until actorsUnderMouse.size) {
|
||||
for (kk in actorsUnderMouse.indices) {
|
||||
actorsUnderMouse[kk].mainUI?.let {
|
||||
uiOpened = true
|
||||
|
||||
|
||||
@@ -378,8 +378,8 @@ object WorldSimulator {
|
||||
private val FALLABLE_MAX_FALL_SPEED = 2
|
||||
|
||||
private fun monitorIllegalFluidSetup() {
|
||||
for (y in 0 until fluidMap.size) {
|
||||
for (x in 0 until fluidMap[0].size) {
|
||||
for (y in fluidMap.indices) {
|
||||
for (x in fluidMap[0].indices) {
|
||||
val fluidData = world.getFluid(x + updateXFrom, y + updateYFrom)
|
||||
if (fluidData.amount < 0f) {
|
||||
throw InternalError("Negative amount of fluid at (${x + updateXFrom},${y + updateYFrom}): $fluidData")
|
||||
@@ -391,8 +391,8 @@ object WorldSimulator {
|
||||
private fun makeFluidMapFromWorld() {
|
||||
//printdbg(this, "Scan area: ($updateXFrom,$updateYFrom)..(${updateXFrom + fluidMap[0].size},${updateYFrom + fluidMap.size})")
|
||||
|
||||
for (y in 0 until fluidMap.size) {
|
||||
for (x in 0 until fluidMap[0].size) {
|
||||
for (y in fluidMap.indices) {
|
||||
for (x in fluidMap[0].indices) {
|
||||
val fluidData = world.getFluid(x + updateXFrom, y + updateYFrom)
|
||||
fluidMap[y][x] = fluidData.amount
|
||||
fluidTypeMap[y][x] = fluidData.type
|
||||
@@ -407,8 +407,8 @@ object WorldSimulator {
|
||||
}
|
||||
|
||||
private fun fluidmapToWorld() {
|
||||
for (y in 0 until fluidMap.size) {
|
||||
for (x in 0 until fluidMap[0].size) {
|
||||
for (y in fluidMap.indices) {
|
||||
for (x in fluidMap[0].indices) {
|
||||
world.setFluid(x + updateXFrom, y + updateYFrom, fluidNewTypeMap[y][x], fluidNewMap[y][x])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ package net.torvald.terrarum.modulebasegame.ui
|
||||
inventorySortList.sortBy { it.item.name }
|
||||
|
||||
// map sortList to item list
|
||||
for (k in 0 until items.size) {
|
||||
for (k in items.indices) {
|
||||
// we have an item
|
||||
try {
|
||||
val sortListItem = inventorySortList[k + itemPage * items.size]
|
||||
|
||||
@@ -353,7 +353,7 @@ class UIItemInventoryDynamicList(
|
||||
inventorySortList.sortBy { ItemCodex[it.item]!!.name }
|
||||
|
||||
// map sortList to item list
|
||||
for (k in 0 until items.size) {
|
||||
for (k in items.indices) {
|
||||
// we have an item
|
||||
try {
|
||||
val sortListItem = inventorySortList[k + itemPage * items.size]
|
||||
@@ -372,7 +372,7 @@ class UIItemInventoryDynamicList(
|
||||
}
|
||||
|
||||
// set equippedslot number
|
||||
for (eq in 0 until inventory.itemEquipped.size) {
|
||||
for (eq in inventory.itemEquipped.indices) {
|
||||
if (eq < inventory.itemEquipped.size) {
|
||||
if (inventory.itemEquipped[eq] == items[k].item?.dynamicID) {
|
||||
items[k].equippedSlot = eq
|
||||
|
||||
@@ -118,7 +118,7 @@ class UIItemInventoryEquippedView(
|
||||
// sort by equip position
|
||||
|
||||
// fill the grid from fastest index, make no gap in-between of slots
|
||||
for (k in 0 until itemGrid.size) {
|
||||
for (k in itemGrid.indices) {
|
||||
val item = inventory.itemEquipped[k]
|
||||
|
||||
if (item == null) {
|
||||
|
||||
Reference in New Issue
Block a user