-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add repeat action & tweak untrigger filter (#1411)
Signed-off-by: Pablo Herrera <[email protected]>
- Loading branch information
1 parent
24b6769
commit 852bf3d
Showing
3 changed files
with
52 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
core/src/main/java/tc/oc/pgm/action/actions/RepeatAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package tc.oc.pgm.action.actions; | ||
|
||
import tc.oc.pgm.action.Action; | ||
import tc.oc.pgm.filters.Filterable; | ||
import tc.oc.pgm.util.math.Formula; | ||
|
||
public class RepeatAction<B extends Filterable<?>> extends AbstractAction<B> { | ||
|
||
protected final Action<? super B> action; | ||
protected final Formula<B> formula; | ||
|
||
public RepeatAction(Class<B> scope, Action<? super B> action, Formula<B> formula) { | ||
super(scope); | ||
this.action = action; | ||
this.formula = formula; | ||
} | ||
|
||
@Override | ||
public void trigger(B t) { | ||
for (int i = (int) formula.applyAsDouble(t); i > 0; i--) { | ||
action.trigger(t); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters