Better Duplicate Op Support (json/hjson) + 1 more op (#7355)

* Better support for duplicate ops

* 'Mathf.curve' op
This commit is contained in:
MEEPofFaith 2022-08-13 03:52:46 -07:00 committed by GitHub
parent f9748b2d69
commit 25388ffe5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -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);
}

View File

@ -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.");
};
});