From 16795871c37f622d0e0a11d09214d2c71c2d9af3 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Tue, 21 Sep 2021 20:44:31 +0200 Subject: [PATCH] Run commands in effects --- .../volmit/iris/engine/object/IrisEffect.java | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/volmit/iris/engine/object/IrisEffect.java b/src/main/java/com/volmit/iris/engine/object/IrisEffect.java index ac2040957..ed7c45449 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisEffect.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisEffect.java @@ -150,6 +150,33 @@ public class IrisEffect { @ArrayType(min = 1, type = IrisCommand.class) @Desc("Run commands, at the exact location of the player") private KList rawCommands = new KList<>(); + @DependsOn({"rawCommands"}) + @MinNumber(-8) + @MaxNumber(8) + @Desc("The alt x, usually represents motion if the particle count is zero. Otherwise an offset.") + private double commandOffsetX = 0; + @DependsOn({"rawCommands"}) + @MinNumber(-8) + @MaxNumber(8) + @Desc("The alt y, usually represents motion if the particle count is zero. Otherwise an offset.") + private double commandOffsetY = 0; + @DependsOn({"rawCommands"}) + @MinNumber(-8) + @MaxNumber(8) + @Desc("The alt z, usually represents motion if the particle count is zero. Otherwise an offset.") + private double commandOffsetZ = 0; + @DependsOn({"rawCommands"}) + @Desc("Randomize the altX from -altX to altX") + private boolean commandRandomAltX = true; + @DependsOn({"rawCommands"}) + @Desc("Randomize the altY from -altY to altY") + private boolean commandRandomAltY = false; + @DependsOn({"rawCommands"}) + @Desc("Randomize the altZ from -altZ to altZ") + private boolean commandRandomAltZ = true; + @DependsOn({"rawCommands"}) + @Desc("Randomize location for all separate commands (true), or run all on the same location (false)") + private boolean commandAllRandomLocations = true; public boolean canTick() { return latch.aquire(() -> new ChronoLatch(interval)).flip(); @@ -221,10 +248,18 @@ public class IrisEffect { } if (rawCommands.isNotEmpty()) { - Location part = p.getLocation().clone(); - + Location part = p.getLocation().clone().add( + commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX, + commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY, + commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ); for (IrisCommand rawCommand : rawCommands) { rawCommand.run(part); + if (commandAllRandomLocations) { + part = p.getLocation().clone().add( + commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX, + commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY, + commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ); + } } }