phys arguments are now single PhysProperties object

This commit is contained in:
minjaesong
2020-07-15 21:58:44 +09:00
parent d89e0d30da
commit c0db310a66
16 changed files with 60 additions and 22 deletions

View File

@@ -31,7 +31,7 @@ import java.util.*
*
* Created by minjaesong on 2016-01-13.
*/
open class ActorWithBody(renderOrder: RenderOrder, val immobileBody: Boolean = false, var usePhysics: Boolean = true) :
open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties) :
Actor(renderOrder) {
@@ -389,7 +389,7 @@ open class ActorWithBody(renderOrder: RenderOrder, val immobileBody: Boolean = f
isNoSubjectToFluidResistance = isNoClip
}
if (!usePhysics) {
if (!physProp.usePhysics) {
isNoCollideWorld = true
isNoSubjectToFluidResistance = true
isNoSubjectToGrav = true
@@ -1154,7 +1154,7 @@ open class ActorWithBody(renderOrder: RenderOrder, val immobileBody: Boolean = f
}
private fun getTileFriction(tile: Int) =
if (immobileBody && tile == Block.AIR)
if (physProp.immobileBody && tile == Block.AIR)
BlockCodex[Block.AIR].friction.frictionToMult().div(500)
.times(if (!grounded) elasticity else 1.0)
else

View File

@@ -0,0 +1,33 @@
package net.torvald.terrarum.gameactors
data class PhysProperties(
val immobileBody: Boolean,
var usePhysics: Boolean,
val useStairs: Boolean
) {
companion object {
val HUMANOID_DEFAULT = PhysProperties(
immobileBody = false,
usePhysics = true,
useStairs = true
)
/** e.g. dropped items, balls */
val PHYSICS_OBJECT = PhysProperties(
immobileBody = false,
usePhysics = true,
useStairs = false
)
/** e.g. voice maker */
val IMMOBILE = PhysProperties(
immobileBody = true,
usePhysics = false,
useStairs = false
)
/** e.g. camera */
val MOBILE_OBJECT = PhysProperties(
immobileBody = false,
usePhysics = false,
useStairs = false
)
}
}