throwable cherry bomb (no explosion yet)

This commit is contained in:
minjaesong
2024-02-14 03:54:14 +09:00
parent d2acacb531
commit c66f5cbb54
31 changed files with 306 additions and 78 deletions

View File

@@ -29,9 +29,13 @@ import kotlin.math.pow
*/
open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, LandHolder, HistoricalFigure {
init {
this.physProp = PhysProperties.HUMANOID_DEFAULT()
}
protected constructor()
constructor(birth: Long, death: Long? = null, physProp: PhysProperties = PhysProperties.HUMANOID_DEFAULT) : super() {
constructor(birth: Long, death: Long? = null, physProp: PhysProperties = PhysProperties.HUMANOID_DEFAULT()) : super() {
actorValue[AVKey.__HISTORICAL_BORNTIME] = birth
death?.let { actorValue[AVKey.__HISTORICAL_DEADTIME] = death }
this.physProp = physProp

View File

@@ -1,33 +1,29 @@
package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.spriteanimation.SingleImageSprite
import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.INGAME
import net.torvald.terrarum.Second
import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.gameactors.PhysProperties
import net.torvald.terrarum.modulebasegame.ExplosionManager
import org.dyn4j.geometry.Vector2
/**
* Created by minjaesong on 2024-02-13.
*/
open class ActorPrimedBomb : ActorWithBody {
open class ActorPrimedBomb(
private var explosionPower: Float = 1f,
private var fuse: Second = 1f,
) : ActorWithBody() {
protected constructor() {
init {
renderOrder = RenderOrder.MIDTOP
physProp = PhysProperties.PHYSICS_OBJECT()
}
private var explosionPower: Float = 1f
private var fuse: Second = 1f
constructor(
initialPos: Vector2,
initialVelo: Vector2,
power: Float,
fuse: Second
) {
protected constructor() : this(1f, 1f) {
renderOrder = RenderOrder.MIDTOP
this.explosionPower = power
this.fuse = fuse
physProp = PhysProperties.PHYSICS_OBJECT()
}
override fun updateImpl(delta: Float) {
@@ -41,4 +37,24 @@ open class ActorPrimedBomb : ActorWithBody {
flagDespawn()
}
}
}
/**
* Created by minjaesong on 2024-02-14.
*/
class ActorCherryBomb : ActorPrimedBomb(500f, 4.5f) {
init {
val itemImage = CommonResourcePool.getAsItemSheet("basegame.items").get(0,13)
setHitboxDimension(7, 7, 2, -2)
sprite = SingleImageSprite(this, itemImage)
avBaseMass = 1.0
density = 1400.0
}
}

View File

@@ -17,7 +17,7 @@ object CreatureBuilder {
* @Param jsonFileName with extension
*/
operator fun invoke(module: String, jsonFileName: String): ActorWithBody {
val actor = ActorWithBody(Actor.RenderOrder.MIDDLE, physProp = PhysProperties.HUMANOID_DEFAULT)
val actor = ActorWithBody(Actor.RenderOrder.MIDDLE, physProp = PhysProperties.HUMANOID_DEFAULT())
InjectCreatureRaw(actor.actorValue, module, jsonFileName)

View File

@@ -33,7 +33,7 @@ open class DroppedItem : ActorWithBody {
var itemCount = 1L
protected constructor() : super(RenderOrder.OVERLAY, PhysProperties.PHYSICS_OBJECT)
protected constructor() : super(RenderOrder.OVERLAY, PhysProperties.PHYSICS_OBJECT())
private var timeSinceSpawned = 0f
@@ -51,7 +51,7 @@ open class DroppedItem : ActorWithBody {
* @param topLeftX world-wise coord
* @param topLeftY world-wise coord
*/
constructor(itemID: ItemID, centreX: Double, bottomY: Double, spawnVelo: Vector2? = null) : super(RenderOrder.OVERLAY, PhysProperties.PHYSICS_OBJECT) {
constructor(itemID: ItemID, centreX: Double, bottomY: Double, spawnVelo: Vector2? = null) : super(RenderOrder.OVERLAY, PhysProperties.PHYSICS_OBJECT()) {
this.itemID = itemID
if (itemID.isActor())

View File

@@ -39,7 +39,7 @@ open class Electric : FixtureBase {
mainUI: UICanvas? = null,
inventory: FixtureInventory? = null,
id: ActorID? = null
) : super(renderOrder, PhysProperties.IMMOBILE, id) {
) : super(renderOrder, PhysProperties.IMMOBILE(), id) {
blockBox = blockBox0
setHitboxDimension(TILE_SIZE * blockBox.width, TILE_SIZE * blockBox.height, 0, 0)
this.blockBoxProps = blockBoxProps
@@ -162,7 +162,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
internal var actorThatInstalledThisFixture: UUID? = null
protected constructor() : super(RenderOrder.BEHIND, PhysProperties.IMMOBILE, null)
protected constructor() : super(RenderOrder.BEHIND, PhysProperties.IMMOBILE(), null)
protected constructor(renderOrder: RenderOrder, physProp: PhysProperties, id: ActorID?) : super(renderOrder, physProp, id)
/**
@@ -186,7 +186,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
mainUI: UICanvas? = null,
inventory: FixtureInventory? = null,
id: ActorID? = null
) : super(renderOrder, PhysProperties.IMMOBILE, id) {
) : super(renderOrder, PhysProperties.IMMOBILE(), id) {
blockBox = blockBox0
setHitboxDimension(TILE_SIZE * blockBox.width, TILE_SIZE * blockBox.height, 0, 0)
this.blockBoxProps = blockBoxProps

View File

@@ -13,7 +13,7 @@ class ItemCarrying : ActorWithBody {
private constructor()
constructor(itemID: ItemID) : super(RenderOrder.MIDTOP, PhysProperties.IMMOBILE) {
constructor(itemID: ItemID) : super(RenderOrder.MIDTOP, PhysProperties.IMMOBILE()) {
this.itemID = itemID
}

View File

@@ -12,7 +12,7 @@ import net.torvald.terrarum.modulebasegame.worldgenerator.RoguelikeRandomiser
/**
* Created by minjaesong on 2016-03-05.
*/
class PhysTestBall : ActorWithBody(RenderOrder.MIDDLE, PhysProperties.PHYSICS_OBJECT) {
class PhysTestBall : ActorWithBody(RenderOrder.MIDDLE, PhysProperties.PHYSICS_OBJECT()) {
private var color = Color.GOLD

View File

@@ -11,7 +11,7 @@ import net.torvald.terrarum.gameactors.*
/**
* Created by minjaesong on 2018-01-17.
*/
class PhysTestLuarLander : ActorWithBody(RenderOrder.MIDTOP, PhysProperties.PHYSICS_OBJECT), Controllable {
class PhysTestLuarLander : ActorWithBody(RenderOrder.MIDTOP, PhysProperties.PHYSICS_OBJECT()), Controllable {
@Transient private val texture = Texture(ModMgr.getGdxFile("basegame", "sprites/phystest_lunarlander.tga"))

View File

@@ -52,7 +52,7 @@ open class ProjectileSimple : ActorWithBody, Projectile {
constructor(type: Int,
fromPoint: Vector2, // projected coord
toPoint: Vector2 // arriving coord
) : super(RenderOrder.MIDTOP, PhysProperties.PHYSICS_OBJECT) {
) : super(RenderOrder.MIDTOP, PhysProperties.PHYSICS_OBJECT()) {
this.type = type