mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
get operator on Tile/ItemPropCodex
Former-commit-id: f6c4ecbad8c0ce2486524be70e68292d6aae799e Former-commit-id: 9738a693eb55861d1292e59d8df2bec7f5603c40
This commit is contained in:
@@ -26,16 +26,16 @@ open class ActorWithBody : Actor() {
|
|||||||
@Transient internal var sprite: SpriteAnimation? = null
|
@Transient internal var sprite: SpriteAnimation? = null
|
||||||
@Transient internal var spriteGlow: SpriteAnimation? = null
|
@Transient internal var spriteGlow: SpriteAnimation? = null
|
||||||
|
|
||||||
internal var drawMode: DrawMode = DrawMode.NORMAL
|
protected var drawMode: DrawMode = DrawMode.NORMAL
|
||||||
|
|
||||||
@Transient private val world: GameWorld = Terrarum.ingame.world
|
@Transient private val world: GameWorld = Terrarum.ingame.world
|
||||||
|
|
||||||
var hitboxTranslateX: Double = 0.0// relative to spritePosX
|
protected var hitboxTranslateX: Double = 0.0// relative to spritePosX
|
||||||
var hitboxTranslateY: Double = 0.0// relative to spritePosY
|
protected var hitboxTranslateY: Double = 0.0// relative to spritePosY
|
||||||
var baseHitboxW: Int = 0
|
protected var baseHitboxW: Int = 0
|
||||||
var baseHitboxH: Int = 0
|
protected var baseHitboxH: Int = 0
|
||||||
internal var baseSpriteWidth: Int = 0
|
protected var baseSpriteWidth: Int = 0
|
||||||
internal var baseSpriteHeight: Int = 0
|
protected var baseSpriteHeight: Int = 0
|
||||||
/**
|
/**
|
||||||
* * Position: top-left point
|
* * Position: top-left point
|
||||||
* * Unit: pixel
|
* * Unit: pixel
|
||||||
@@ -228,6 +228,11 @@ open class ActorWithBody : Actor() {
|
|||||||
internal @Volatile var walledLeft = false
|
internal @Volatile var walledLeft = false
|
||||||
internal @Volatile var walledRight = false
|
internal @Volatile var walledRight = false
|
||||||
|
|
||||||
|
protected val gameContainer: GameContainer
|
||||||
|
get() = Terrarum.appgc
|
||||||
|
protected val updateDelta: Int
|
||||||
|
get() = Terrarum.ingame.UPDATE_DELTA
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* true: This actor had just made collision
|
* true: This actor had just made collision
|
||||||
*/
|
*/
|
||||||
@@ -292,7 +297,7 @@ open class ActorWithBody : Actor() {
|
|||||||
val feetPosition: Vector2
|
val feetPosition: Vector2
|
||||||
get() = Vector2(hitbox.centeredX, hitbox.posY + hitbox.height)
|
get() = Vector2(hitbox.centeredX, hitbox.posY + hitbox.height)
|
||||||
|
|
||||||
override fun run() = update(Terrarum.appgc, Terrarum.ingame.UPDATE_DELTA)
|
override fun run() = update(gameContainer, updateDelta)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add vector value to the velocity, in the time unit of single frame.
|
* Add vector value to the velocity, in the time unit of single frame.
|
||||||
@@ -681,7 +686,7 @@ open class ActorWithBody : Actor() {
|
|||||||
for (y in tyStart..tyEnd) {
|
for (y in tyStart..tyEnd) {
|
||||||
for (x in txStart..txEnd) {
|
for (x in txStart..txEnd) {
|
||||||
val tile = world.getTileFromTerrain(x, y)
|
val tile = world.getTileFromTerrain(x, y)
|
||||||
if (TilePropCodex.getProp(tile).isSolid)
|
if (TilePropCodex[tile].isSolid)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -723,7 +728,7 @@ open class ActorWithBody : Actor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// evaluate
|
// evaluate
|
||||||
if (TilePropCodex.getProp(world.getTileFromTerrain(tileX, tileY)).isFluid) {
|
if (TilePropCodex[world.getTileFromTerrain(tileX, tileY)].isFluid) {
|
||||||
contactAreaCounter += 1
|
contactAreaCounter += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -733,7 +738,7 @@ open class ActorWithBody : Actor() {
|
|||||||
|
|
||||||
private fun setHorizontalFriction() {
|
private fun setHorizontalFriction() {
|
||||||
val friction = if (isPlayerNoClip)
|
val friction = if (isPlayerNoClip)
|
||||||
BASE_FRICTION * TilePropCodex.getProp(TileNameCode.STONE).friction.tileFrictionToMult()
|
BASE_FRICTION * TilePropCodex[TileNameCode.STONE].friction.tileFrictionToMult()
|
||||||
else
|
else
|
||||||
BASE_FRICTION * bodyFriction.tileFrictionToMult()
|
BASE_FRICTION * bodyFriction.tileFrictionToMult()
|
||||||
|
|
||||||
@@ -760,7 +765,7 @@ open class ActorWithBody : Actor() {
|
|||||||
|
|
||||||
private fun setVerticalFriction() {
|
private fun setVerticalFriction() {
|
||||||
val friction = if (isPlayerNoClip)
|
val friction = if (isPlayerNoClip)
|
||||||
BASE_FRICTION * TilePropCodex.getProp(TileNameCode.STONE).friction.tileFrictionToMult()
|
BASE_FRICTION * TilePropCodex[TileNameCode.STONE].friction.tileFrictionToMult()
|
||||||
else
|
else
|
||||||
BASE_FRICTION * bodyFriction.tileFrictionToMult()
|
BASE_FRICTION * bodyFriction.tileFrictionToMult()
|
||||||
|
|
||||||
@@ -835,7 +840,7 @@ open class ActorWithBody : Actor() {
|
|||||||
|
|
||||||
for (x in tilePosXStart..tilePosXEnd) {
|
for (x in tilePosXStart..tilePosXEnd) {
|
||||||
val tile = world.getTileFromTerrain(x, tilePosY)
|
val tile = world.getTileFromTerrain(x, tilePosY)
|
||||||
val thisFriction = TilePropCodex.getProp(tile).friction
|
val thisFriction = TilePropCodex[tile].friction
|
||||||
|
|
||||||
if (thisFriction > friction) friction = thisFriction
|
if (thisFriction > friction) friction = thisFriction
|
||||||
}
|
}
|
||||||
@@ -860,7 +865,7 @@ open class ActorWithBody : Actor() {
|
|||||||
for (y in tilePosXStart..tilePosYEnd) {
|
for (y in tilePosXStart..tilePosYEnd) {
|
||||||
for (x in tilePosXStart..tilePosXEnd) {
|
for (x in tilePosXStart..tilePosXEnd) {
|
||||||
val tile = world.getTileFromTerrain(x, y)
|
val tile = world.getTileFromTerrain(x, y)
|
||||||
val prop = TilePropCodex.getProp(tile)
|
val prop = TilePropCodex[tile]
|
||||||
|
|
||||||
if (prop.isFluid && prop.density > density)
|
if (prop.isFluid && prop.density > density)
|
||||||
density = prop.density
|
density = prop.density
|
||||||
@@ -885,7 +890,7 @@ open class ActorWithBody : Actor() {
|
|||||||
for (y in tilePosYStart..tilePosYEnd) {
|
for (y in tilePosYStart..tilePosYEnd) {
|
||||||
for (x in tilePosXStart..tilePosXEnd) {
|
for (x in tilePosXStart..tilePosXEnd) {
|
||||||
val tile = world.getTileFromTerrain(x, y)
|
val tile = world.getTileFromTerrain(x, y)
|
||||||
val thisFluidDensity = TilePropCodex.getProp(tile).density
|
val thisFluidDensity = TilePropCodex[tile].density
|
||||||
|
|
||||||
if (thisFluidDensity > density) density = thisFluidDensity
|
if (thisFluidDensity > density) density = thisFluidDensity
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,17 +12,17 @@ import org.newdawn.slick.Graphics
|
|||||||
class DroppedItem(private val item: InventoryItem) : ActorWithBody() {
|
class DroppedItem(private val item: InventoryItem) : ActorWithBody() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (item.itemID >= ItemPropCodex.ITEM_COUNT_MAX)
|
if (item.id >= ItemPropCodex.ITEM_COUNT_MAX)
|
||||||
throw RuntimeException("Attempted to create DroppedItem actor of a real actor; the real actor must be dropped instead.")
|
throw RuntimeException("Attempted to create DroppedItem actor of a real actor; the real actor must be dropped instead.")
|
||||||
|
|
||||||
isVisible = true
|
isVisible = true
|
||||||
|
|
||||||
mass = if (item.itemID < TilePropCodex.TILE_UNIQUE_MAX)
|
mass = if (item.id < TilePropCodex.TILE_UNIQUE_MAX)
|
||||||
TilePropCodex.getProp(item.itemID).density / 1000.0
|
TilePropCodex[item.id].density / 1000.0
|
||||||
else
|
else
|
||||||
ItemPropCodex.getProp(item.itemID).mass
|
ItemPropCodex[item.id].mass
|
||||||
|
|
||||||
scale = ItemPropCodex.getProp(item.itemID).scale
|
scale = ItemPropCodex[item.id].scale
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun update(gc: GameContainer, delta: Int) {
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.*
|
|||||||
class FixtureTikiTorch : FixtureBase(), Luminous {
|
class FixtureTikiTorch : FixtureBase(), Luminous {
|
||||||
|
|
||||||
override var luminosity: Int
|
override var luminosity: Int
|
||||||
get() = TilePropCodex.getProp(TileNameCode.TORCH).luminosity
|
get() = TilePropCodex[TileNameCode.TORCH].luminosity
|
||||||
set(value) {
|
set(value) {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
@@ -35,6 +35,6 @@ class FixtureTikiTorch : FixtureBase(), Luminous {
|
|||||||
|
|
||||||
actorValue[AVKey.BASEMASS] = 1.0
|
actorValue[AVKey.BASEMASS] = 1.0
|
||||||
|
|
||||||
luminosity = TilePropCodex.getProp(TileNameCode.TORCH).luminosity
|
luminosity = TilePropCodex[TileNameCode.TORCH].luminosity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@ package net.torvald.terrarum.gameactors
|
|||||||
import net.torvald.terrarum.gameactors.ActorHumanoid
|
import net.torvald.terrarum.gameactors.ActorHumanoid
|
||||||
import net.torvald.terrarum.gameitem.EquipPosition
|
import net.torvald.terrarum.gameitem.EquipPosition
|
||||||
import net.torvald.terrarum.gameitem.InventoryItem
|
import net.torvald.terrarum.gameitem.InventoryItem
|
||||||
import net.torvald.terrarum.gameitem.InventoryItemAdapter
|
|
||||||
import org.luaj.vm2.Globals
|
import org.luaj.vm2.Globals
|
||||||
import org.luaj.vm2.LoadState
|
import org.luaj.vm2.LoadState
|
||||||
import org.luaj.vm2.LuaError
|
import org.luaj.vm2.LuaError
|
||||||
@@ -41,8 +40,8 @@ open class HumanoidNPC(aiFile: String, born: GameDate) : ActorHumanoid(born), AI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we're having InventoryItem data so that this class could be somewhat universal
|
// we're having InventoryItem data so that this class could be somewhat universal
|
||||||
override var itemData: InventoryItem = object : InventoryItemAdapter() {
|
override var itemData: InventoryItem = object : InventoryItem() {
|
||||||
override var itemID = referenceID
|
override var id = referenceID
|
||||||
override val equipPosition: Int = EquipPosition.HAND_GRIP
|
override val equipPosition: Int = EquipPosition.HAND_GRIP
|
||||||
|
|
||||||
override var mass: Double
|
override var mass: Double
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ object PlayerBuilderSigrid {
|
|||||||
|
|
||||||
// Test fill up inventory
|
// Test fill up inventory
|
||||||
p.inventory.add(16)
|
p.inventory.add(16)
|
||||||
p.itemEquipped[EquipPosition.HAND_GRIP] = ItemPropCodex.getProp(16)
|
p.equipItem(ItemPropCodex[16])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import org.newdawn.slick.GameContainer
|
|||||||
* Created by minjaesong on 16-09-08.
|
* Created by minjaesong on 16-09-08.
|
||||||
*/
|
*/
|
||||||
open class DynamicItem(val baseItemID: Int?, newMass: Double? = null, newScale: Double? = null)
|
open class DynamicItem(val baseItemID: Int?, newMass: Double? = null, newScale: Double? = null)
|
||||||
: InventoryItemAdapter() {
|
: InventoryItem() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal ID of an Item, Long
|
* Internal ID of an Item, Long
|
||||||
@@ -22,11 +22,11 @@ open class DynamicItem(val baseItemID: Int?, newMass: Double? = null, newScale:
|
|||||||
* 32768-16777215: Dynamic items
|
* 32768-16777215: Dynamic items
|
||||||
* >= 16777216: Actor RefID
|
* >= 16777216: Actor RefID
|
||||||
*/
|
*/
|
||||||
override val itemID: Int = generateUniqueDynamicItemID()
|
override val id: Int = generateUniqueDynamicItemID()
|
||||||
|
|
||||||
override val equipPosition: Int = // default to HAND_GRIP if no baseItemID given
|
override val equipPosition: Int = // default to HAND_GRIP if no baseItemID given
|
||||||
if (baseItemID != null)
|
if (baseItemID != null)
|
||||||
ItemPropCodex.getProp(baseItemID).equipPosition
|
ItemPropCodex[baseItemID].equipPosition
|
||||||
else
|
else
|
||||||
EquipPosition.HAND_GRIP
|
EquipPosition.HAND_GRIP
|
||||||
|
|
||||||
@@ -67,14 +67,14 @@ open class DynamicItem(val baseItemID: Int?, newMass: Double? = null, newScale:
|
|||||||
mass = newMass!!
|
mass = newMass!!
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mass = newMass ?: ItemPropCodex.getProp(baseItemID).mass
|
mass = newMass ?: ItemPropCodex[baseItemID].mass
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseItemID == null) {
|
if (baseItemID == null) {
|
||||||
scale = newScale!!
|
scale = newScale!!
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scale = newScale ?: ItemPropCodex.getProp(baseItemID).scale
|
scale = newScale ?: ItemPropCodex[baseItemID].scale
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,13 +206,13 @@ object WorldSimulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Int.isFluid() = TilePropCodex.getProp(this).isFluid
|
fun Int.isFluid() = TilePropCodex[this].isFluid
|
||||||
fun Int.isSolid() = this.fluidLevel() == FLUID_MAX || TilePropCodex.getProp(this).isSolid
|
fun Int.isSolid() = this.fluidLevel() == FLUID_MAX || TilePropCodex[this].isSolid
|
||||||
//fun Int.viscosity() = TilePropCodex.getProp(this).
|
//fun Int.viscosity() = TilePropCodex[this].
|
||||||
fun Int.fluidLevel() = if (!this.isFluid()) 0 else (this % FLUID_MAX) + 1
|
fun Int.fluidLevel() = if (!this.isFluid()) 0 else (this % FLUID_MAX) + 1
|
||||||
fun Int.fluidType() = this / FLUID_MAX
|
fun Int.fluidType() = this / FLUID_MAX
|
||||||
fun Int.isEven() = (this and 0x01) == 0
|
fun Int.isEven() = (this and 0x01) == 0
|
||||||
fun Int.isFallable() = TilePropCodex.getProp(this).isFallable
|
fun Int.isFallable() = TilePropCodex[this].isFallable
|
||||||
|
|
||||||
private fun placeFluid(world: GameWorld, x: Int, y: Int, fluidType: Byte, amount: Int) {
|
private fun placeFluid(world: GameWorld, x: Int, y: Int, fluidType: Byte, amount: Int) {
|
||||||
if (world.layerTerrain.isInBound(x, y)) {
|
if (world.layerTerrain.isInBound(x, y)) {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import net.torvald.terrarum.gameactors.AVKey
|
|||||||
import net.torvald.terrarum.gamecontroller.mouseTileX
|
import net.torvald.terrarum.gamecontroller.mouseTileX
|
||||||
import net.torvald.terrarum.gamecontroller.mouseTileY
|
import net.torvald.terrarum.gamecontroller.mouseTileY
|
||||||
import net.torvald.terrarum.gameitem.EquipPosition
|
import net.torvald.terrarum.gameitem.EquipPosition
|
||||||
import net.torvald.terrarum.gameitem.InventoryItemAdapter
|
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
import net.torvald.terrarum.tileproperties.TileProp
|
import net.torvald.terrarum.tileproperties.TileProp
|
||||||
import net.torvald.terrarum.tileproperties.TilePropCodex
|
import net.torvald.terrarum.tileproperties.TilePropCodex
|
||||||
@@ -39,12 +38,11 @@ object ItemPropCodex {
|
|||||||
init {
|
init {
|
||||||
// tile items
|
// tile items
|
||||||
for (i in 0..ITEM_TILE_MAX) {
|
for (i in 0..ITEM_TILE_MAX) {
|
||||||
itemCodex[i] = object : InventoryItemAdapter() {
|
itemCodex[i] = object : InventoryItem() {
|
||||||
override val itemID: Int = i
|
override val id: Int = i
|
||||||
override val equipPosition = EquipPosition.HAND_GRIP
|
override val equipPosition = EquipPosition.HAND_GRIP
|
||||||
override var mass: Double = TilePropCodex.getProp(i).density / 1000.0
|
override var mass: Double = TilePropCodex[i].density / 1000.0
|
||||||
// no need to set setter as scale would not change
|
override var scale: Double = 1.0 // no need to set setter as scale would not change
|
||||||
override var scale: Double = 1.0
|
|
||||||
|
|
||||||
override fun primaryUse(gc: GameContainer, delta: Int) {
|
override fun primaryUse(gc: GameContainer, delta: Int) {
|
||||||
// TODO base punch attack
|
// TODO base punch attack
|
||||||
@@ -67,7 +65,7 @@ object ItemPropCodex {
|
|||||||
// read from save (if applicable) and fill dynamicItemDescription
|
// read from save (if applicable) and fill dynamicItemDescription
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getProp(code: Int): InventoryItem {
|
operator fun get(code: Int): InventoryItem {
|
||||||
if (code < ITEM_STATIC_MAX) // generic item
|
if (code < ITEM_STATIC_MAX) // generic item
|
||||||
return itemCodex[code]!! // from CSV
|
return itemCodex[code]!! // from CSV
|
||||||
else if (code < ITEM_DYNAMIC_MAX) {
|
else if (code < ITEM_DYNAMIC_MAX) {
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import java.util.*
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
object LightmapRenderer {
|
object LightmapRenderer {
|
||||||
val overscan_open: Int = Math.min(32, 256f.div(TilePropCodex.getProp(TileNameCode.AIR).opacity and 0xFF).toFloat().ceil())
|
val overscan_open: Int = Math.min(32, 256f.div(TilePropCodex[TileNameCode.AIR].opacity and 0xFF).toFloat().ceil())
|
||||||
val overscan_opaque: Int = Math.min(8, 256f.div(TilePropCodex.getProp(TileNameCode.STONE).opacity and 0xFF).toFloat().ceil())
|
val overscan_opaque: Int = Math.min(8, 256f.div(TilePropCodex[TileNameCode.STONE].opacity and 0xFF).toFloat().ceil())
|
||||||
|
|
||||||
private val LIGHTMAP_WIDTH = Terrarum.ingame.ZOOM_MIN.inv().times(Terrarum.WIDTH)
|
private val LIGHTMAP_WIDTH = Terrarum.ingame.ZOOM_MIN.inv().times(Terrarum.WIDTH)
|
||||||
.div(MapDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
|
.div(MapDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||||
@@ -152,7 +152,7 @@ object LightmapRenderer {
|
|||||||
for (i in 0..rect_size) {
|
for (i in 0..rect_size) {
|
||||||
val point = edgeToMaskNum(i)
|
val point = edgeToMaskNum(i)
|
||||||
val tile = Terrarum.ingame.world.getTileFromTerrain(point.first, point.second) ?: TileNameCode.NULL
|
val tile = Terrarum.ingame.world.getTileFromTerrain(point.first, point.second) ?: TileNameCode.NULL
|
||||||
val isSolid = TilePropCodex.getProp(tile).isSolid
|
val isSolid = TilePropCodex[tile].isSolid
|
||||||
|
|
||||||
noop_mask.set(i, isSolid)
|
noop_mask.set(i, isSolid)
|
||||||
}
|
}
|
||||||
@@ -237,8 +237,8 @@ object LightmapRenderer {
|
|||||||
var lightLevelThis: Int = 0
|
var lightLevelThis: Int = 0
|
||||||
val thisTerrain = Terrarum.ingame.world.getTileFromTerrain(x, y)
|
val thisTerrain = Terrarum.ingame.world.getTileFromTerrain(x, y)
|
||||||
val thisWall = Terrarum.ingame.world.getTileFromWall(x, y)
|
val thisWall = Terrarum.ingame.world.getTileFromWall(x, y)
|
||||||
val thisTileLuminosity = TilePropCodex.getProp(thisTerrain).luminosity
|
val thisTileLuminosity = TilePropCodex[thisTerrain].luminosity
|
||||||
val thisTileOpacity = TilePropCodex.getProp(thisTerrain).opacity
|
val thisTileOpacity = TilePropCodex[thisTerrain].opacity
|
||||||
val sunLight = Terrarum.ingame.world.globalLight
|
val sunLight = Terrarum.ingame.world.globalLight
|
||||||
|
|
||||||
// MIX TILE
|
// MIX TILE
|
||||||
|
|||||||
@@ -387,8 +387,8 @@ object MapCamera {
|
|||||||
var ret = 0
|
var ret = 0
|
||||||
for (i in 0..3) {
|
for (i in 0..3) {
|
||||||
try {
|
try {
|
||||||
if (!TilePropCodex.getProp(nearbyTiles[i]).isSolid &&
|
if (!TilePropCodex[nearbyTiles[i]].isSolid &&
|
||||||
!TilePropCodex.getProp(nearbyTiles[i]).isFluid) {
|
!TilePropCodex[nearbyTiles[i]].isFluid) {
|
||||||
ret += (1 shl i) // add 1, 2, 4, 8 for i = 0, 1, 2, 3
|
ret += (1 shl i) // add 1, 2, 4, 8 for i = 0, 1, 2, 3
|
||||||
}
|
}
|
||||||
} catch (e: ArrayIndexOutOfBoundsException) {
|
} catch (e: ArrayIndexOutOfBoundsException) {
|
||||||
@@ -408,26 +408,26 @@ object MapCamera {
|
|||||||
nearbyTiles[NEARBY_TILE_KEY_BACK] = WORLD.getTileFrom(WALL, x , y) ?: 4096
|
nearbyTiles[NEARBY_TILE_KEY_BACK] = WORLD.getTileFrom(WALL, x , y) ?: 4096
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_DOWN]).isSolid)
|
if (TilePropCodex[nearbyTiles[NEARBY_TILE_KEY_DOWN]].isSolid)
|
||||||
// has tile on the bottom
|
// has tile on the bottom
|
||||||
return 3
|
return 3
|
||||||
else if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_RIGHT]).isSolid
|
else if (TilePropCodex[nearbyTiles[NEARBY_TILE_KEY_RIGHT]].isSolid
|
||||||
&& TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_LEFT]).isSolid)
|
&& TilePropCodex[nearbyTiles[NEARBY_TILE_KEY_LEFT]].isSolid)
|
||||||
// has tile on both sides
|
// has tile on both sides
|
||||||
return 0
|
return 0
|
||||||
else if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_RIGHT]).isSolid)
|
else if (TilePropCodex[nearbyTiles[NEARBY_TILE_KEY_RIGHT]].isSolid)
|
||||||
// has tile on the right
|
// has tile on the right
|
||||||
return 2
|
return 2
|
||||||
else if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_LEFT]).isSolid)
|
else if (TilePropCodex[nearbyTiles[NEARBY_TILE_KEY_LEFT]].isSolid)
|
||||||
// has tile on the left
|
// has tile on the left
|
||||||
return 1
|
return 1
|
||||||
else if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_BACK]).isSolid)
|
else if (TilePropCodex[nearbyTiles[NEARBY_TILE_KEY_BACK]].isSolid)
|
||||||
// has tile on the back
|
// has tile on the back
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 3
|
return 3
|
||||||
} catch (e: ArrayIndexOutOfBoundsException) {
|
} catch (e: ArrayIndexOutOfBoundsException) {
|
||||||
return if (TilePropCodex.getProp(nearbyTiles[NEARBY_TILE_KEY_DOWN]).isSolid)
|
return if (TilePropCodex[nearbyTiles[NEARBY_TILE_KEY_DOWN]].isSolid)
|
||||||
// has tile on the bottom
|
// has tile on the bottom
|
||||||
3 else 0
|
3 else 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ object TilePropCodex {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getProp(index: Int, damage: Int): TileProp {
|
fun get(index: Int, damage: Int): TileProp {
|
||||||
try {
|
try {
|
||||||
tileProps[idDamageToIndex(index, damage)].id
|
tileProps[idDamageToIndex(index, damage)].id
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ object TilePropCodex {
|
|||||||
return tileProps[idDamageToIndex(index, damage)]
|
return tileProps[idDamageToIndex(index, damage)]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getProp(rawIndex: Int?): TileProp {
|
operator fun get(rawIndex: Int?): TileProp {
|
||||||
try {
|
try {
|
||||||
tileProps[rawIndex ?: TileNameCode.NULL].id
|
tileProps[rawIndex ?: TileNameCode.NULL].id
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import java.util.*
|
|||||||
* Created by minjaesong on 16-09-08.
|
* Created by minjaesong on 16-09-08.
|
||||||
*/
|
*/
|
||||||
object ComputerPartsCodex {
|
object ComputerPartsCodex {
|
||||||
val rams = HashMap<Int, Int>() // itemID, capacity in bytes (0 bytes - 8 GBytes)
|
val rams = HashMap<Int, Int>() // id, capacity in bytes (0 bytes - 8 GBytes)
|
||||||
val processors = HashMap<Int, Int>() // itemID, cycles
|
val processors = HashMap<Int, Int>() // id, cycles
|
||||||
val harddisks = HashMap<Int, Int>() // itemID, capacity in bytes
|
val harddisks = HashMap<Int, Int>() // id, capacity in bytes
|
||||||
val diskettes = HashMap<Int, Int>() // itemID, capacity in bytes
|
val diskettes = HashMap<Int, Int>() // id, capacity in bytes
|
||||||
val opticaldiscs = HashMap<Int, Int>() // itemID, capacity in bytes
|
val opticaldiscs = HashMap<Int, Int>() // id, capacity in bytes
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// in kilobytes
|
// in kilobytes
|
||||||
|
|||||||
Reference in New Issue
Block a user