-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
253 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/.idea | ||
/.gradle | ||
/build | ||
/build.gradle | ||
/build.gradle |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
korge-ldtk/src/commonMain/kotlin/korlibs/korge/ldtk/LDTKJsonExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package korlibs.korge.ldtk | ||
|
||
import korlibs.datastructure.Extra | ||
import korlibs.math.geom.Anchor | ||
import korlibs.math.geom.PointInt | ||
import kotlinx.serialization.json.jsonPrimitive | ||
|
||
val EntityInstance.gridPos: PointInt get() = PointInt(grid[0], grid[1]) | ||
val EntityInstance.pivotAnchor: Anchor get() = Anchor(pivot[0], pivot[1]) | ||
val EntityDefinition.fieldDefsByName by Extra.PropertyThis { this.fieldDefs.associateBy { it.identifier } } | ||
val Definitions.entitiesByUid by Extra.PropertyThis { this.entities.associateBy { it.uid } } | ||
operator fun EntityDefinition.get(name: String): FieldDefinition? = fieldDefsByName[name] | ||
fun FieldInstance.definition(ldtk: LDTKJson): FieldDefinition { | ||
return ldtk.defs.levelFields[this.defUid] | ||
} | ||
data class FieldInfo(val def: FieldDefinition, val instance: FieldInstance) { | ||
val identifier = def.identifier | ||
|
||
val valueString: String? get() = instance.value?.jsonPrimitive?.content | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters