mostly reindents

This commit is contained in:
2024-11-24 01:55:45 +01:00
parent dfea72f9a2
commit a2e18730a2
8 changed files with 377 additions and 319 deletions
@@ -34,10 +34,11 @@ object GiveEmitterTool {
} }
dispatcher.register( dispatcher.register(
command.then( command
itemNameArg.then( .then(itemNameArg
itemTypeArg.then( .then(itemTypeArg
emitterIdSuggestion.executes { context -> .then(emitterIdSuggestion
.executes { context ->
val name = StringArgumentType.getString(context, "Item Name") val name = StringArgumentType.getString(context, "Item Name")
val item = ItemStackArgumentType.getItemStackArgument(context, "Item Type") val item = ItemStackArgumentType.getItemStackArgument(context, "Item Type")
val emitterId = StringArgumentType.getString(context, "Emitter ID") val emitterId = StringArgumentType.getString(context, "Emitter ID")
@@ -15,8 +15,7 @@ object KillAllEmitters {
.requires { source -> source.hasPermissionLevel(4) } .requires { source -> source.hasPermissionLevel(4) }
dispatcher.register( dispatcher.register(
command command.executes { context ->
.executes { context ->
for (emitter in ALL_PARTICLE_EMITTERS) { for (emitter in ALL_PARTICLE_EMITTERS) {
emitter.kill() emitter.kill()
} }
@@ -1,8 +1,7 @@
package com.bytedice.bde_particles.commands package com.bytedice.bde_particles.commands
import com.bytedice.bde_particles.InterpolationCurves import com.bytedice.bde_particles.InterpolationCurves
import com.bytedice.bde_particles.particles.SpawningShape import com.bytedice.bde_particles.particles.*
import com.bytedice.bde_particles.particles.updateSingleParam
import com.mojang.brigadier.Command import com.mojang.brigadier.Command
import com.mojang.brigadier.arguments.BoolArgumentType import com.mojang.brigadier.arguments.BoolArgumentType
import com.mojang.brigadier.arguments.FloatArgumentType import com.mojang.brigadier.arguments.FloatArgumentType
@@ -125,50 +124,41 @@ class ArgConfigEmitterKeys {
class ArgConfigParticleKeys { class ArgConfigParticleKeys {
fun shape() : LiteralArgumentBuilder<ServerCommandSource> { fun shape() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("shape") return CommandManager.literal("shape")
.then( .then(CommandManager.literal("circle")
CommandManager.literal("circle") .then(CommandManager.argument("Radius", FloatArgumentType.floatArg())
.then(
CommandManager.argument("Radius", FloatArgumentType.floatArg())
.executes { context -> .executes { context ->
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index") val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val radius = FloatArgumentType.getFloat(context, "Radius") val radius = FloatArgumentType.getFloat(context, "Radius")
val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.Circle(radius)) val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.CIRCLE(radius))
context.source.sendFeedback( { feedback }, false) context.source.sendFeedback( { feedback }, false)
Command.SINGLE_SUCCESS Command.SINGLE_SUCCESS
} }
) )
) )
.then( .then(CommandManager.literal("rect")
CommandManager.literal("rect") .then(CommandManager.argument("Width", FloatArgumentType.floatArg())
.then( .then(CommandManager.argument("Height", FloatArgumentType.floatArg())
CommandManager.argument("Width", FloatArgumentType.floatArg())
.then(
CommandManager.argument("Height", FloatArgumentType.floatArg())
.executes { context -> .executes { context ->
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index") val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val w = FloatArgumentType.getFloat(context, "Width") val w = FloatArgumentType.getFloat(context, "Width")
val h = FloatArgumentType.getFloat(context, "Height") val h = FloatArgumentType.getFloat(context, "Height")
val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.Rect(Vector2f(w, h))) val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.RECT(Vector2f(w, h)))
context.source.sendFeedback( { feedback }, false) context.source.sendFeedback( { feedback }, false)
Command.SINGLE_SUCCESS Command.SINGLE_SUCCESS
} }
) )
) )
) )
.then( .then(CommandManager.literal("cube")
CommandManager.literal("cube") .then(CommandManager.argument("X", FloatArgumentType.floatArg())
.then( .then(CommandManager.argument("Y", FloatArgumentType.floatArg())
CommandManager.argument("X", FloatArgumentType.floatArg()) .then(CommandManager.argument("Z", FloatArgumentType.floatArg())
.then(
CommandManager.argument("Y", FloatArgumentType.floatArg())
.then(
CommandManager.argument("Z", FloatArgumentType.floatArg())
.executes { context -> .executes { context ->
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index") val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val x = FloatArgumentType.getFloat(context, "X") val x = FloatArgumentType.getFloat(context, "X")
val y = FloatArgumentType.getFloat(context, "Y") val y = FloatArgumentType.getFloat(context, "Y")
val z = FloatArgumentType.getFloat(context, "Z") val z = FloatArgumentType.getFloat(context, "Z")
val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.Cube(Vector3f(x, y, z))) val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.CUBE(Vector3f(x, y, z)))
context.source.sendFeedback( { feedback }, false) context.source.sendFeedback( { feedback }, false)
Command.SINGLE_SUCCESS Command.SINGLE_SUCCESS
} }
@@ -176,14 +166,12 @@ class ArgConfigParticleKeys {
) )
) )
) )
.then( .then(CommandManager.literal("sphere")
CommandManager.literal("sphere") .then(CommandManager.argument("Radius", FloatArgumentType.floatArg())
.then(
CommandManager.argument("Radius", FloatArgumentType.floatArg())
.executes { context -> .executes { context ->
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index") val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val radius = FloatArgumentType.getFloat(context, "Radius") val radius = FloatArgumentType.getFloat(context, "Radius")
val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.Sphere(radius)) val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.SPHERE(radius))
context.source.sendFeedback( { feedback }, false) context.source.sendFeedback( { feedback }, false)
Command.SINGLE_SUCCESS Command.SINGLE_SUCCESS
} }
@@ -192,8 +180,7 @@ class ArgConfigParticleKeys {
} }
fun blockCurve() : LiteralArgumentBuilder<ServerCommandSource> { fun blockCurve() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("blockCurve") return CommandManager.literal("blockCurve")
.then( .then(CommandManager.argument("Array (separate by comma)", StringArgumentType.string())
CommandManager.argument("Array (separate by comma)", StringArgumentType.string())
.executes { context -> .executes { context ->
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index") val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val typeValue = StringArgumentType.getString(context, "Array (separate by comma)") val typeValue = StringArgumentType.getString(context, "Array (separate by comma)")
@@ -206,8 +193,7 @@ class ArgConfigParticleKeys {
} }
fun rotRandom() : LiteralArgumentBuilder<ServerCommandSource> { fun rotRandom() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("rotRandom") return CommandManager.literal("rotRandom")
.then( .then(argPairVector3f()
argPairVector3f()
.executes { context -> .executes { context ->
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index") val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val vectors = x1x2ToPairVector3f(context) val vectors = x1x2ToPairVector3f(context)
@@ -220,8 +206,7 @@ class ArgConfigParticleKeys {
} }
fun rotVelRandom() : LiteralArgumentBuilder<ServerCommandSource> { fun rotVelRandom() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("rotVelRandom") return CommandManager.literal("rotVelRandom")
.then( .then(argPairVector3f()
argPairVector3f()
.executes { context -> .executes { context ->
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index") val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val vectors = x1x2ToPairVector3f(context) val vectors = x1x2ToPairVector3f(context)
@@ -234,8 +219,7 @@ class ArgConfigParticleKeys {
} }
fun sizeRandom() : LiteralArgumentBuilder<ServerCommandSource> { fun sizeRandom() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("sizeRandom") return CommandManager.literal("sizeRandom")
.then( .then(argPairVector3f()
argPairVector3f()
.executes { context -> .executes { context ->
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index") val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val vectors = x1x2ToPairVector3f(context) val vectors = x1x2ToPairVector3f(context)
@@ -248,8 +232,7 @@ class ArgConfigParticleKeys {
} }
fun uniformSize() : LiteralArgumentBuilder<ServerCommandSource> { fun uniformSize() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("uniformSize") return CommandManager.literal("uniformSize")
.then( .then(CommandManager.argument("Bool", BoolArgumentType.bool())
CommandManager.argument("Bool", BoolArgumentType.bool())
.executes { context -> .executes { context ->
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index") val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val uniform = BoolArgumentType.getBool(context, "Bool") val uniform = BoolArgumentType.getBool(context, "Bool")
@@ -261,8 +244,7 @@ class ArgConfigParticleKeys {
} }
fun velRandom() : LiteralArgumentBuilder<ServerCommandSource> { fun velRandom() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("velRandom") return CommandManager.literal("velRandom")
.then( .then(argPairVector3f()
argPairVector3f()
.executes { context -> .executes { context ->
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index") val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val vectors = x1x2ToPairVector3f(context) val vectors = x1x2ToPairVector3f(context)
@@ -273,16 +255,15 @@ class ArgConfigParticleKeys {
} }
) )
} }
fun forceFields() {} // TODO: how? fun forceFields() {} // TODO
fun gravity() : LiteralArgumentBuilder<ServerCommandSource> { fun gravity() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("gravity") return CommandManager.literal("gravity")
.then( .then(argVector3f("X", "Y", "Z")
argVector3f()
.executes { context -> .executes { context ->
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index") val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val x1 = FloatArgumentType.getFloat(context, "Min X") val x1 = FloatArgumentType.getFloat(context, "X")
val y1 = FloatArgumentType.getFloat(context, "Min Y") val y1 = FloatArgumentType.getFloat(context, "Y")
val z1 = FloatArgumentType.getFloat(context, "Min Z") val z1 = FloatArgumentType.getFloat(context, "Z")
val feedback = argUpdateParticleParam(context, particleIndex, "gravity", Vector3f(x1, y1, z1)) val feedback = argUpdateParticleParam(context, particleIndex, "gravity", Vector3f(x1, y1, z1))
context.source.sendFeedback({ feedback }, false) context.source.sendFeedback({ feedback }, false)
@@ -292,8 +273,7 @@ class ArgConfigParticleKeys {
} }
fun drag() : LiteralArgumentBuilder<ServerCommandSource> { fun drag() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("drag") return CommandManager.literal("drag")
.then( .then(CommandManager.argument("Float", FloatArgumentType.floatArg())
CommandManager.argument("Float", FloatArgumentType.floatArg())
.executes { context -> .executes { context ->
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index") val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val value = FloatArgumentType.getFloat(context, "Float") val value = FloatArgumentType.getFloat(context, "Float")
@@ -305,8 +285,7 @@ class ArgConfigParticleKeys {
} }
fun minVel() : LiteralArgumentBuilder<ServerCommandSource> { fun minVel() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("minVel") return CommandManager.literal("minVel")
.then( .then(CommandManager.argument("Float", FloatArgumentType.floatArg())
CommandManager.argument("Float", FloatArgumentType.floatArg())
.executes { context -> .executes { context ->
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index") val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val value = FloatArgumentType.getFloat(context, "Float") val value = FloatArgumentType.getFloat(context, "Float")
@@ -386,10 +365,10 @@ fun argPairVector3f() : RequiredArgumentBuilder<ServerCommandSource, Float> {
} }
fun argVector3f() : RequiredArgumentBuilder<ServerCommandSource, Float> { fun argVector3f(xName: String, yName: String, zName: String) : RequiredArgumentBuilder<ServerCommandSource, Float> {
return CommandManager.argument("Min X", FloatArgumentType.floatArg()) return CommandManager.argument(xName, FloatArgumentType.floatArg())
.then(CommandManager.argument("Min Y", FloatArgumentType.floatArg()) .then(CommandManager.argument(yName, FloatArgumentType.floatArg())
.then(CommandManager.argument("Min Z", FloatArgumentType.floatArg())) .then(CommandManager.argument(zName, FloatArgumentType.floatArg()))
) )
} }
@@ -398,8 +377,7 @@ val curves = arrayOf("LINEAR", "SQRT", "EXPONENT", "CUBIC", "SINE", "COSINE", "I
fun argCurve() : RequiredArgumentBuilder<ServerCommandSource, Float> { fun argCurve() : RequiredArgumentBuilder<ServerCommandSource, Float> {
return argPairVector3f() return argPairVector3f()
.then( .then(CommandManager.argument("Curve", StringArgumentType.string())
CommandManager.argument("Curve", StringArgumentType.string())
.suggests { _, builder -> .suggests { _, builder ->
curves.forEach { builder.suggest(it) } curves.forEach { builder.suggest(it) }
CompletableFuture.completedFuture(builder.build()) CompletableFuture.completedFuture(builder.build())
@@ -434,3 +412,100 @@ fun x1x2ToPairVector3f(context: CommandContext<ServerCommandSource>) : Pair<Vect
val z2 = FloatArgumentType.getFloat(context, "Max Z") val z2 = FloatArgumentType.getFloat(context, "Max Z")
return Pair(Vector3f(x1, y1, z1), Vector3f(x2, y2, z2)) return Pair(Vector3f(x1, y1, z1), Vector3f(x2, y2, z2))
} }
fun argAddForceField() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("add")
.then(CommandManager.argument("Name", StringArgumentType.string())
.then(argVector3f("X Pos", "Y Pos", "Z Pos")
.then(CommandManager.argument("Min Force", FloatArgumentType.floatArg())
.then(CommandManager.argument("Max Force", FloatArgumentType.floatArg())
.then(CommandManager.literal("Sphere")
.then(CommandManager.argument("Radius", FloatArgumentType.floatArg())
.executes { context -> forceFieldAddSphereExec(context) }
)
)
.then(CommandManager.literal("cube")
.then(argVector3f("X Size", "Y Size", "Z Size")
.then(argVector3f("X Force", "Y Force", "Z Force")
.executes { context -> forceFieldAddCubeExec(context) }
)
)
)
)
)
)
)
}
fun forceFieldAddSphereExec(context: CommandContext<ServerCommandSource>) : Int {
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val radius = FloatArgumentType.getFloat(context, "Radius")
val emitterIdVal = StringArgumentType.getString(context, "Registered Emitter ID")
val shape = ForceFieldShape.SPHERE(radius)
val forceField = forceFieldGenericParams(context, shape)
val currentParams = getEmitterParams(emitterIdVal)
val forceFields = currentParams!!.particleTypes[particleIndex].forceFields
val feedback = argUpdateParticleParam(
context,
particleIndex,
"forceFields",
forceFields.toMutableList().add(forceField)
)
context.source.sendFeedback({ feedback }, false)
Command.SINGLE_SUCCESS
return Command.SINGLE_SUCCESS
}
fun forceFieldAddCubeExec(context: CommandContext<ServerCommandSource>) : Int {
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
val xSize = FloatArgumentType.getFloat(context, "X Size")
val ySize = FloatArgumentType.getFloat(context, "Y Size")
val zSize = FloatArgumentType.getFloat(context, "Z Size")
val xForce = FloatArgumentType.getFloat(context, "X Force")
val yForce = FloatArgumentType.getFloat(context, "Y Force")
val zForce = FloatArgumentType.getFloat(context, "Z Force")
val emitterIdVal = StringArgumentType.getString(context, "Registered Emitter ID")
val shape = ForceFieldShape.CUBE(Vector3f(xSize, ySize, zSize), Vector3f(xForce, yForce, zForce))
val forceField = forceFieldGenericParams(context, shape)
val currentParams = getEmitterParams(emitterIdVal)
val forceFields = currentParams!!.particleTypes[particleIndex].forceFields
val feedback = argUpdateParticleParam(
context,
particleIndex,
"forceFields",
forceFields.toMutableList().add(forceField)
)
context.source.sendFeedback({ feedback }, false)
Command.SINGLE_SUCCESS
return Command.SINGLE_SUCCESS
}
fun forceFieldGenericParams(context: CommandContext<ServerCommandSource>, shape: ForceFieldShape) : ForceField {
val name = StringArgumentType.getString(context, "Name")
val posX = FloatArgumentType.getFloat(context, "X Pos")
val posY = FloatArgumentType.getFloat(context, "Y Pos")
val posZ = FloatArgumentType.getFloat(context, "Z Pos")
val minForce = FloatArgumentType.getFloat(context, "Min Force")
val maxForce = FloatArgumentType.getFloat(context, "Max Force")
return ForceField(
name,
Vector3f(posX, posY, posZ),
Pair(minForce, maxForce),
shape
)
}
@@ -88,12 +88,8 @@ val particleConfigKeys = ArgConfigParticleKeys()
// output -> register new emitter with a preset // output -> register new emitter with a preset
fun argCreate() : LiteralArgumentBuilder<ServerCommandSource> { fun argCreate() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("create") return CommandManager.literal("create")
.then( .then(CommandManager.argument("Emitter ID", StringArgumentType.string())
// [emitter id] .then(emitterIdSuggestion
CommandManager.argument("Emitter ID", StringArgumentType.string())
.then(
// [preset emitter id]
emitterIdSuggestion
.executes { context -> .executes { context ->
val emitterIdVal = StringArgumentType.getString(context, "Emitter ID") val emitterIdVal = StringArgumentType.getString(context, "Emitter ID")
val emitterPresetVal = StringArgumentType.getString(context, "Registered Emitter ID") ?: "DEFAULT" val emitterPresetVal = StringArgumentType.getString(context, "Registered Emitter ID") ?: "DEFAULT"
@@ -136,9 +132,7 @@ fun argCreate() : LiteralArgumentBuilder<ServerCommandSource> {
// output -> removes the particle with that id // output -> removes the particle with that id
fun argRemove() : LiteralArgumentBuilder<ServerCommandSource> { fun argRemove() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("remove") return CommandManager.literal("remove")
.then( .then(emitterIdSuggestion
// [emitter id]
emitterIdSuggestion
.executes { context -> .executes { context ->
val emitterIdVal = StringArgumentType.getString(context, "Registered Emitter ID") ?: "NULL" val emitterIdVal = StringArgumentType.getString(context, "Registered Emitter ID") ?: "NULL"
val isRemoved = removeFromEmitterRegister(emitterIdVal) val isRemoved = removeFromEmitterRegister(emitterIdVal)
@@ -184,9 +178,7 @@ fun argList() : LiteralArgumentBuilder<ServerCommandSource> {
// output -> give player a command block with the particle params (should be paste-able in kotlin) // output -> give player a command block with the particle params (should be paste-able in kotlin)
fun argCopy() : LiteralArgumentBuilder<ServerCommandSource> { fun argCopy() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("copy") return CommandManager.literal("copy")
.then( .then(emitterIdSuggestion
// [emitter id]
emitterIdSuggestion
.executes { context -> .executes { context ->
val emitterIdVal = StringArgumentType.getString(context, "Registered Emitter ID") val emitterIdVal = StringArgumentType.getString(context, "Registered Emitter ID")
val commandBlock = makeCommandBlock( val commandBlock = makeCommandBlock(
@@ -226,18 +218,15 @@ fun argCopy() : LiteralArgumentBuilder<ServerCommandSource> {
// output -> update the selected parameter of the selected emitter id to the new value // output -> update the selected parameter of the selected emitter id to the new value
fun argConfig() : LiteralArgumentBuilder<ServerCommandSource> { fun argConfig() : LiteralArgumentBuilder<ServerCommandSource> {
return CommandManager.literal("config") return CommandManager.literal("config")
.then( .then(emitterIdSuggestion
emitterIdSuggestion .then(CommandManager.literal("EMITTER")
.then(
CommandManager.literal("EMITTER")
.then(emitterConfigKeys.maxCount()) .then(emitterConfigKeys.maxCount())
.then(emitterConfigKeys.spawnsPerTick()) .then(emitterConfigKeys.spawnsPerTick())
.then(emitterConfigKeys.loopDur()) .then(emitterConfigKeys.loopDur())
.then(emitterConfigKeys.loopDelay()) .then(emitterConfigKeys.loopDelay())
.then(emitterConfigKeys.loopCount()) .then(emitterConfigKeys.loopCount())
) )
.then( .then(CommandManager.argument("Particle Index", IntegerArgumentType.integer())
CommandManager.argument("Particle Index", IntegerArgumentType.integer())
.suggests { context, builder -> .suggests { context, builder ->
val emitterId = StringArgumentType.getString(context, "Registered Emitter ID") val emitterId = StringArgumentType.getString(context, "Registered Emitter ID")
@@ -1,11 +1,10 @@
package com.bytedice.bde_particles.particles package com.bytedice.bde_particles.particles
data class ForceField ( import org.joml.Vector3f
val x: Float = 0.0f,
val y: Float = 0.0f,
val z: Float = 0.0f,
val minForce: Float = 0.0f,
val maxForce: Float = 0.0f,
val shape: ForceFieldShape = ForceFieldShape.Sphere()
)
data class ForceField (
val name: String = "DEFAULT",
val pos: Vector3f = Vector3f(0.0f, 0.0f, 0.0f),
val force: Pair<Float, Float> = Pair(0.0f, 1.0f),
val shape: ForceFieldShape = ForceFieldShape.SPHERE()
)
@@ -42,21 +42,21 @@ class Particle(private val particleParams: ParticleParams) {
val newSpawnPos: Vector3f val newSpawnPos: Vector3f
when (shape) { when (shape) {
is SpawningShape.Circle -> { is SpawningShape.CIRCLE -> {
val posInCircle = randomInCircle(shape.radius) val posInCircle = randomInCircle(shape.radius)
newSpawnPos = Vector3f(posInCircle.x, 0.0f, posInCircle.y) newSpawnPos = Vector3f(posInCircle.x, 0.0f, posInCircle.y)
} }
is SpawningShape.Sphere -> { is SpawningShape.SPHERE -> {
newSpawnPos = randomInSphere(shape.radius) newSpawnPos = randomInSphere(shape.radius)
} }
is SpawningShape.Rect -> { is SpawningShape.RECT -> {
val posInRect = randomInRect(shape.size) val posInRect = randomInRect(shape.size)
newSpawnPos = Vector3f(posInRect.x, 0.0f, posInRect.y) newSpawnPos = Vector3f(posInRect.x, 0.0f, posInRect.y)
} }
is SpawningShape.Cube -> { is SpawningShape.CUBE -> {
newSpawnPos = randomInCube(shape.size) newSpawnPos = randomInCube(shape.size)
} }
@@ -22,7 +22,7 @@ import org.joml.Vector3f
* @param sizeCurve A curve which the size gets multiplied by during the particle's lifetime. * @param sizeCurve A curve which the size gets multiplied by during the particle's lifetime.
*/ */
data class ParticleParams ( data class ParticleParams (
var shape: SpawningShape? = SpawningShape.Circle(3.0f), var shape: SpawningShape? = SpawningShape.CIRCLE(3.0f),
var blockCurve: Array<String> = arrayOf("minecraft:shroomlight", "minecraft:orange_concrete", "minecraft:orange_stained_glass", "minecraft:gray_stained_glass", "minecraft:light_gray_stained_glass"), var blockCurve: Array<String> = arrayOf("minecraft:shroomlight", "minecraft:orange_concrete", "minecraft:orange_stained_glass", "minecraft:gray_stained_glass", "minecraft:light_gray_stained_glass"),
var rotRandom: Pair<Vector3f, Vector3f> = Pair(Vector3f(0.0f, 0.0f, 0.0f), Vector3f(360.0f, 360.0f, 360.0f)), var rotRandom: Pair<Vector3f, Vector3f> = Pair(Vector3f(0.0f, 0.0f, 0.0f), Vector3f(360.0f, 360.0f, 360.0f)),
var rotVelRandom: Pair<Vector3f, Vector3f> = Pair(Vector3f(-0.2f, -0.2f, -0.2f), Vector3f(0.2f, 0.2f, 0.2f)), var rotVelRandom: Pair<Vector3f, Vector3f> = Pair(Vector3f(-0.2f, -0.2f, -0.2f), Vector3f(0.2f, 0.2f, 0.2f)),
@@ -4,20 +4,15 @@ import org.joml.Vector2f
import org.joml.Vector3f import org.joml.Vector3f
sealed class SpawningShape { sealed class SpawningShape {
data class Circle(val radius: Float = 1.0f) : SpawningShape() data class CIRCLE(val radius: Float = 1.0f) : SpawningShape()
data class Rect (val size: Vector2f = Vector2f(1.0f, 1.0f)) : SpawningShape() data class RECT (val size: Vector2f = Vector2f(1.0f, 1.0f)) : SpawningShape()
data class Cube (val size: Vector3f = Vector3f(1.0f, 1.0f, 1.0f)) : SpawningShape() data class CUBE (val size: Vector3f = Vector3f(1.0f, 1.0f, 1.0f)) : SpawningShape()
data class Sphere(val radius: Float = 1.0f) : SpawningShape() data class SPHERE(val radius: Float = 1.0f) : SpawningShape()
} }
sealed class ForceFieldShape { sealed class ForceFieldShape {
data class Sphere( data class SPHERE(val radius: Float = 1.0f) : ForceFieldShape()
val pos: Vector3f = Vector3f(0.0f, 0.0f, 0.0f), data class CUBE(
val radius: Float = 1.0f
) : ForceFieldShape()
data class Rect(
val pos: Vector3f = Vector3f(0.0f, 0.0f, 0.0f),
val size: Vector3f = Vector3f(1.0f, 1.0f, 1.0f), val size: Vector3f = Vector3f(1.0f, 1.0f, 1.0f),
val forceDir: Vector3f = Vector3f(0.0f, 0.0f, 0.0f) // 0.0 on all means from center val forceDir: Vector3f = Vector3f(0.0f, 0.0f, 0.0f) // 0.0 on all means from center
) : ForceFieldShape() ) : ForceFieldShape()