tested & fixed some bugs for ConfigArgs.kt
This commit is contained in:
@@ -201,11 +201,14 @@ fun emitterListArg(argName: String) : RequiredArgumentBuilder<ServerCommandSourc
|
||||
}
|
||||
|
||||
|
||||
fun curveListArg(argName: String) : RequiredArgumentBuilder<ServerCommandSource, String> {
|
||||
fun curveListArg(argName: String): RequiredArgumentBuilder<ServerCommandSource, String> {
|
||||
return CommandManager.argument(argName, StringArgumentType.string())
|
||||
.suggests { _, builder ->
|
||||
LerpCurves::class.nestedClasses.forEach { nestClass ->
|
||||
builder.suggest(nestClass.simpleName)
|
||||
LerpCurves.Companion::class.members
|
||||
.filterIsInstance<kotlin.reflect.KProperty1<LerpCurves.Companion, *>>()
|
||||
.filter { it.returnType.classifier == LerpCurves::class }
|
||||
.forEach { property ->
|
||||
builder.suggest(property.name)
|
||||
}
|
||||
CompletableFuture.completedFuture(builder.build())
|
||||
}
|
||||
|
||||
@@ -81,11 +81,14 @@ fun parseArgTypeToFunc(type: KType) : CommandArgumentBuilder? {
|
||||
ParamClasses.PairInt::class -> ::pairIntArg
|
||||
SpawningShape::class -> ::shapeArg
|
||||
ParamClasses.PairVec3f::class -> ::pairVec3fArg
|
||||
ParamClasses.PairFloat::class -> ::pairFloatArg
|
||||
ParamClasses.PairFloat::class -> ::pairFloatArg // unexpected error
|
||||
ParamClasses.TransformWithVel::class -> ::transformWithVelArg
|
||||
ParamClasses.StringCurve::class -> ::stringCurveArg
|
||||
ParamClasses.LerpVal::class -> ::lerpValArg
|
||||
ParamClasses.ForceFieldArray::class -> ::forceFieldArg
|
||||
ParamClasses.StringCurve::class -> ::stringCurveArg // curve suggestion is only "companion" (bypassing doesn't work)
|
||||
// doesn't add items (added items result with a space: "acacia boat" instead of "acacia_boat")
|
||||
// doesn't remove items
|
||||
ParamClasses.LerpVal::class -> ::lerpValArg // curve suggestion (see above)
|
||||
ParamClasses.ForceFieldArray::class -> ::forceFieldArg // doesn't add force fields
|
||||
// removing gives unexpected error (because index error)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@@ -272,12 +275,14 @@ fun shapeArgExec(paramName: String, access: KProperty1<EmitterParams, SpawningSh
|
||||
val radius = FloatArgumentType.getFloat(context, "Radius")
|
||||
val onEdge = BoolArgumentType.getBool(context, "Spawn On Edge")
|
||||
updateParam(id, access, SpawningShape.Circle(radius, onEdge))
|
||||
successText(access, "Circle", id, context)
|
||||
}
|
||||
"Rect" -> {
|
||||
val onEdge = BoolArgumentType.getBool(context, "Spawn On Edge")
|
||||
val x = FloatArgumentType.getFloat(context, "X")
|
||||
val y = FloatArgumentType.getFloat(context, "Y")
|
||||
updateParam(id, access, SpawningShape.Rect(Vector2f(x, y), onEdge))
|
||||
successText(access, "Rect", id, context)
|
||||
}
|
||||
"Cube" -> {
|
||||
val onEdge = BoolArgumentType.getBool(context, "Spawn On Edge")
|
||||
@@ -285,18 +290,19 @@ fun shapeArgExec(paramName: String, access: KProperty1<EmitterParams, SpawningSh
|
||||
val y = FloatArgumentType.getFloat(context, "Y")
|
||||
val z = FloatArgumentType.getFloat(context, "Z")
|
||||
updateParam(id, access, SpawningShape.Cube(Vector3f(x, y, z), onEdge))
|
||||
successText(access, "Cube", id, context)
|
||||
}
|
||||
"Sphere" -> {
|
||||
val radius = FloatArgumentType.getFloat(context, "Radius")
|
||||
val onEdge = BoolArgumentType.getBool(context, "Spawn On Edge")
|
||||
updateParam(id, access, SpawningShape.Sphere(radius, onEdge))
|
||||
successText(access, "Sphere", id, context)
|
||||
}
|
||||
"Point" -> {
|
||||
updateParam(id, access, SpawningShape.Point)
|
||||
successText(access, "Point", id, context)
|
||||
}
|
||||
}
|
||||
|
||||
successText(access, access::class.simpleName ?: "UNKNOWN", id, context)
|
||||
}
|
||||
|
||||
fun pairVec3fArg(access: KProperty1<EmitterParams,ParamClasses.PairVec3f>,
|
||||
|
||||
@@ -115,7 +115,20 @@ class ParticleEmitter(
|
||||
}
|
||||
|
||||
else if (params.spawnDuration is ParamClasses.Duration.InfiniteLoop) {
|
||||
return
|
||||
val loopDur = (params.spawnDuration as ParamClasses.Duration.InfiniteLoop).loopDur
|
||||
val loopDelay = (params.spawnDuration as ParamClasses.Duration.InfiniteLoop).loopDelay
|
||||
|
||||
if (timePaused >= loopDelay) {
|
||||
isPaused = false
|
||||
timePaused = 0
|
||||
}
|
||||
if (timeAlive >= loopDur && loopDelay > 0) {
|
||||
isPaused = true
|
||||
timeAlive = 0
|
||||
}
|
||||
|
||||
if (!isPaused) { timeAlive += 1 }
|
||||
else { timePaused += 1 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ sealed class SpawningShape() {
|
||||
}
|
||||
}
|
||||
|
||||
class Rect(private val size: Vector2f, val spawnOnEdge: Boolean) : SpawningShape() {
|
||||
class Rect(val size: Vector2f, val spawnOnEdge: Boolean) : SpawningShape() {
|
||||
fun randomWithin(): Vector3f {
|
||||
return Vector3f(randomFloatBetween(0.0f, size.x), 0.0f, randomFloatBetween(0.0f, size.y))
|
||||
}
|
||||
@@ -41,7 +41,7 @@ sealed class SpawningShape() {
|
||||
}
|
||||
}
|
||||
|
||||
class Cube(private val size: Vector3f, val spawnOnEdge: Boolean) : SpawningShape() {
|
||||
class Cube(val size: Vector3f, val spawnOnEdge: Boolean) : SpawningShape() {
|
||||
fun randomWithin(): Vector3f {
|
||||
return Vector3f(
|
||||
randomFloatBetween(0.0f, size.x),
|
||||
@@ -108,8 +108,8 @@ sealed class SpawningShape() {
|
||||
return when (shape) {
|
||||
is Circle -> if (!shape.spawnOnEdge) { shape.randomWithin() } else { shape.randomOnEdge() }
|
||||
is Sphere -> if (!shape.spawnOnEdge) { shape.randomWithin() } else { shape.randomOnEdge() }
|
||||
is Rect -> if (!shape.spawnOnEdge) { shape.randomWithin() } else { shape.randomOnEdge() }
|
||||
is Cube -> if (!shape.spawnOnEdge) { shape.randomWithin() } else { shape.randomOnEdge() }
|
||||
is Rect -> if (!shape.spawnOnEdge) { shape.randomWithin() } else { shape.randomOnEdge() }.sub(Vector3f(shape.size.x, 0.0f, shape.size.y).div(2.0f))
|
||||
is Cube -> if (!shape.spawnOnEdge) { shape.randomWithin() } else { shape.randomOnEdge() }.sub(Vector3f(shape.size.x, shape.size.y, shape.size.z).div(2.0f))
|
||||
is Point -> Vector3f(0.0f, 0.0f, 0.0f)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user