mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
actor AI from Lua script
Former-commit-id: 184160efc59c4f846f1cc154fe3e60d21b301ee3 Former-commit-id: 4e228542975ea52945a597b7ca1bc06b407c3be7
This commit is contained in:
@@ -44,7 +44,12 @@ open class KVHashMap {
|
||||
if (value is JsonPrimitive)
|
||||
return value.asInt
|
||||
|
||||
return get(key) as Int?
|
||||
try {
|
||||
return value as Int
|
||||
}
|
||||
catch (e: ClassCastException) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun getAsDouble(key: String): Double? {
|
||||
@@ -56,13 +61,12 @@ open class KVHashMap {
|
||||
return value.asDouble
|
||||
|
||||
try {
|
||||
return value as Double?
|
||||
return value as Double
|
||||
}
|
||||
catch (e: ClassCastException) {
|
||||
System.err.println("[KVHashMap] ClassCastException for key '$key'")
|
||||
e.printStackTrace(System.err)
|
||||
return null
|
||||
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun getAsString(key: String): String? {
|
||||
@@ -71,7 +75,12 @@ open class KVHashMap {
|
||||
if (value is JsonPrimitive)
|
||||
return value.asString
|
||||
|
||||
return value as String?
|
||||
try {
|
||||
return value as String
|
||||
}
|
||||
catch (e: ClassCastException) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun getAsBoolean(key: String): Boolean? {
|
||||
@@ -80,12 +89,15 @@ open class KVHashMap {
|
||||
if (value is JsonPrimitive)
|
||||
return value.asBoolean
|
||||
|
||||
return value as Boolean?
|
||||
try {
|
||||
return value as Boolean
|
||||
}
|
||||
catch (e: ClassCastException) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun hasKey(key: String): Boolean {
|
||||
return hashMap.containsKey(key)
|
||||
}
|
||||
fun hasKey(key: String) = hashMap.containsKey(key)
|
||||
|
||||
val keySet: Set<Any>
|
||||
get() = hashMap.keys
|
||||
|
||||
Reference in New Issue
Block a user