From 13003a63d3c39ae2a598ec60c6b52b6371f3ed52 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Mon, 28 Feb 2022 17:54:07 +0900 Subject: [PATCH] moving platform wip --- .../sprites/movables/test_platform.tga | 3 ++ .../gameactors/ActorMovingPlatform.kt | 29 +++++++++++++++++++ .../modulebasegame/gameactors/FixtureBase.kt | 5 +++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 assets/mods/basegame/sprites/movables/test_platform.tga create mode 100644 src/net/torvald/terrarum/modulebasegame/gameactors/ActorMovingPlatform.kt diff --git a/assets/mods/basegame/sprites/movables/test_platform.tga b/assets/mods/basegame/sprites/movables/test_platform.tga new file mode 100644 index 000000000..0753bbbc7 --- /dev/null +++ b/assets/mods/basegame/sprites/movables/test_platform.tga @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd1131125afce895f581c8711b02dad2543b89e3862c2a4d543eeb42f243b487 +size 3090 diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/ActorMovingPlatform.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/ActorMovingPlatform.kt new file mode 100644 index 000000000..3b8d247c3 --- /dev/null +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/ActorMovingPlatform.kt @@ -0,0 +1,29 @@ +package net.torvald.terrarum.modulebasegame.gameactors + +import net.torvald.terrarum.gameactors.ActorID +import net.torvald.terrarum.gameactors.ActorWithBody + +/** + * Created by minjaesong on 2022-02-28. + */ +class ActorMovingPlatform() : ActorWithBody() { + + private val tilewiseLength = 3 + + private val actorsRiding = ArrayList() // saving actorID due to serialisation issues + + /** + * Make the actor its externalV controlled by this platform + */ + fun mount(actor: ActorWithBody) { + actorsRiding.add(actor.referenceID) + } + + /** + * Make the actor its externalV no longer controlled by this platform + */ + fun dismount(actor: ActorWithBody) { + actorsRiding.remove(actor.referenceID) + } + +} \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureBase.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureBase.kt index a4015a9e1..9fadbd600 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureBase.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureBase.kt @@ -130,7 +130,10 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange { } } - if (hasCollision) return false + if (hasCollision) { + printdbg(this, "cannot spawn fixture ${nameFun()}, has tile collision; tilewise dim: (${blockBox.width}, ${blockBox.height}) ") + return false + } printdbg(this, "spawn fixture ${nameFun()}, tilewise dim: (${blockBox.width}, ${blockBox.height})")