summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 476b659)
raw | patch | inline | side by side (parent: 476b659)
author | fredboy <fredboy@protonmail.com> | |
Sat, 20 Apr 2024 10:25:15 +0000 (17:25 +0700) | ||
committer | fredboy <fredboy@protonmail.com> | |
Sat, 20 Apr 2024 10:25:15 +0000 (17:25 +0700) |
diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameInput.java b/core/src/ru/deadsoftware/cavedroid/game/GameInput.java
index fd225742fadbe16affe54246965bb40c9cff9e0d..bab16fd0533b3733701e803a7f944fc84fe3dba3 100644 (file)
break;
case Input.Keys.G:
- mMobsController.addMob(new Pig(mCurX * 16, mCurY * 16));
+ final Mob pig = new Pig(mCurX * 16, mCurY * 16);
+ pig.attachToController(mMobsController);
break;
case Input.Keys.Q:
diff --git a/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateGravelAction.kt b/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateGravelAction.kt
index 53fcd62fa9112b21aefadf01e1eb9c14bf480103..4d39acf778b4cd2cc616c62385c78e1cb6aa969e 100644 (file)
import ru.deadsoftware.cavedroid.game.GameScope
import ru.deadsoftware.cavedroid.game.mobs.FallingGravel
-import ru.deadsoftware.cavedroid.game.mobs.FallingSand
import ru.deadsoftware.cavedroid.game.mobs.MobsController
import ru.deadsoftware.cavedroid.game.world.GameWorld
import javax.inject.Inject
if (shouldFall) {
gameWorld.setForeMap(x, y, 0)
- mobsController.addMob(FallingGravel(x * 16f, y * 16f))
+ FallingGravel(x * 16f, y * 16f)
+ .apply { attachToController(mobsController) }
}
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateSandAction.kt b/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateSandAction.kt
index 26fb97827c6ed30898977232e0496828bbd201a4..c90899c75af7ecf3e91d2714a3638528b079de0d 100644 (file)
if (shouldFall) {
gameWorld.setForeMap(x, y, 0)
- mobsController.addMob(FallingSand(x * 16f, y * 16f))
+ FallingSand(x * 16f, y * 16f)
+ .apply { attachToController(mobsController) }
}
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java
index 592f78da7afc56dae4fbbab3c6670938d2e29673..feb5ceb08a0165f58c00538678dbcc982e4a6812 100644 (file)
return mHealth;
}
+ public final void attachToController(MobsController controller) {
+ controller.addMob(this);
+ }
+
public void damage(int damage) {
if (damage < 0) {
Gdx.app.error(this.getClass().getSimpleName(), "Damage cant be negative!");