Changes:
- use toggle tile for all toggling entities (transient, switch, door) - get rod of hard coded sprites (exception: particle class, to be fixed later) - changed switch sprite (rect instead of elipse)
This commit is contained in:
48
util/ldtkhelpers.go
Normal file
48
util/ldtkhelpers.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"openquell/config"
|
||||
|
||||
"github.com/solarlune/ldtkgo"
|
||||
)
|
||||
|
||||
type TileSetSubRect struct {
|
||||
X, Y, W, H int
|
||||
}
|
||||
|
||||
func Map2Subrect(raw map[string]any) *TileSetSubRect {
|
||||
|
||||
// we need to translate this map for less typing
|
||||
return &TileSetSubRect{
|
||||
W: int(raw["w"].(float64)),
|
||||
H: int(raw["h"].(float64)),
|
||||
X: int(raw["x"].(float64)),
|
||||
Y: int(raw["y"].(float64)),
|
||||
}
|
||||
}
|
||||
|
||||
func GetPropertyRef(entity *ldtkgo.Entity) string {
|
||||
ref := entity.PropertyByIdentifier(config.LDTK_Entity_Ref)
|
||||
if ref != nil {
|
||||
if ref.Value != nil {
|
||||
refid := ref.Value.(map[string]interface{})
|
||||
ref := refid["entityIid"].(string)
|
||||
|
||||
if ref != "" {
|
||||
return ref
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func GetPropertyToggleTile(entity *ldtkgo.Entity) *TileSetSubRect {
|
||||
|
||||
ref := entity.PropertyByIdentifier(config.LDTK_Toggle_Tile)
|
||||
if ref != nil {
|
||||
return Map2Subrect(ref.AsMap())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user