mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-21 12:08:34 +07:00
Better Duplicate Op Support (json/hjson) + 1 more op (#7355)
* Better support for duplicate ops * 'Mathf.curve' op
This commit is contained in:
parent
f9748b2d69
commit
25388ffe5f
@ -124,6 +124,10 @@ public abstract class DrawPart{
|
||||
return p -> get(p) / (1f - amount);
|
||||
}
|
||||
|
||||
default PartProgress compress(float start, float end){
|
||||
return p -> Mathf.curve(get(p), start, end);
|
||||
}
|
||||
|
||||
default PartProgress blend(PartProgress other, float amount){
|
||||
return p -> Mathf.lerp(get(p), other.get(p), amount);
|
||||
}
|
||||
|
@ -201,13 +201,14 @@ public class ContentParser{
|
||||
case "delay" -> base.delay(data.getFloat("amount"));
|
||||
case "sustain" -> base.sustain(data.getFloat("offset", 0f), data.getFloat("grow", 0f), data.getFloat("sustain"));
|
||||
case "shorten" -> base.shorten(data.getFloat("amount"));
|
||||
case "compress" -> base.compress(data.getFloat("start"), data.getFloat("end"));
|
||||
case "add" -> data.has("amount") ? base.add(data.getFloat("amount")) : base.add(parser.readValue(PartProgress.class, data.get("other")));
|
||||
case "blend" -> base.blend(parser.readValue(PartProgress.class, data.get("other")), data.getFloat("amount"));
|
||||
case "mul" -> base.mul(parser.readValue(PartProgress.class, data.get("other")));
|
||||
case "mul" -> data.has("amount") ? base.mul(data.getFloat("amount")) : base.mul(parser.readValue(PartProgress.class, data.get("other")));
|
||||
case "min" -> base.min(parser.readValue(PartProgress.class, data.get("other")));
|
||||
case "sin" -> base.sin(data.getFloat("scl"), data.getFloat("mag"));
|
||||
case "sin" -> base.sin(data.has("offset") ? data.getFloat("offset") : 0f, data.getFloat("scl"), data.getFloat("mag"));
|
||||
case "absin" -> base.absin(data.getFloat("scl"), data.getFloat("mag"));
|
||||
case "curve" -> base.curve(parser.readValue(Interp.class, data.get("interp")));
|
||||
case "curve" -> data.has("interp") ? base.curve(parser.readValue(Interp.class, data.get("interp"))) : base.curve(data.getFloat("offset"), data.getFloat("duration"));
|
||||
default -> throw new RuntimeException("Unknown operation '" + op + "', check PartProgress class for a list of methods.");
|
||||
};
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user