diff --git a/core/src/me/srikavin/fbla/game/map/MapLoader.kt b/core/src/me/srikavin/fbla/game/map/MapLoader.kt index e221059..4266e16 100644 --- a/core/src/me/srikavin/fbla/game/map/MapLoader.kt +++ b/core/src/me/srikavin/fbla/game/map/MapLoader.kt @@ -179,6 +179,23 @@ class MapLoader { createCoin(world, mapObject.rectangle.getPosition(pos).scl(MAP_SCALE_FACTOR)) info { "Making coin at $pos" } } + TriggerType.values().any { it.name == type.toUpperCase() } -> { + val rect = mapObject.rectangle + + world.createEntity().edit() + .add(Transform().apply { position = rect.getCenter(recycledVector2).scl(MAP_SCALE_FACTOR).cpy() }) + .add(PhysicsBody().apply { + shape = PolygonShape().apply { + setAsBox(rect.width * MAP_SCALE_FACTOR * .5f, rect.height * MAP_SCALE_FACTOR * .5f, + recycledVector2.setZero(), 0f) + } + this.type = BodyDef.BodyType.StaticBody + }) + .add(MapTrigger().apply { + this.type = TriggerType.valueOf(type.toUpperCase()) + properties = mapObject.properties + }) + } type == "damage" -> { // val rect = mapObject.rectangle @@ -297,4 +314,4 @@ class MapLoader { return mapEntity } -} \ No newline at end of file +}