mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-16 18:54:45 +00:00
Support for custom uniforms (#902)
* wip backport of custom uniforms * Functioning custom uniforms maybe? * Workon separating dynamic/non-dynamic uniforms and making variables available to custom uniforms (currently the JVM dies horribly) * wip * It no longer crashes horrifically * star imports
This commit is contained in:
1 parent
6fa973dbc8
commit
bed724ba59
89 files changed
+4622
-266
No files matched your search
@@ -0,0 +1,36 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
import kroppeb.stareval.expression.VariableExpression;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class BasicFunctionContext implements FunctionContext {
|
||||
final private Map<String, Expression> variables = new Object2ObjectOpenHashMap<>();
|
||||
|
||||
public void setVariable(String name, Expression value) {
|
||||
variables.put(name, value);
|
||||
}
|
||||
|
||||
public void setIntVariable(String name, int value) {
|
||||
setVariable(name, (VariableExpression) (c, r) -> r.intReturn = value);
|
||||
}
|
||||
|
||||
public void setFloatVariable(String name, float value) {
|
||||
setVariable(name, (VariableExpression) (c, r) -> r.floatReturn = value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression getVariable(String name) {
|
||||
Expression expression = variables.get(name);
|
||||
if (expression == null)
|
||||
throw new RuntimeException("Variable hasn't been set: " + name);
|
||||
return expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasVariable(String name) {
|
||||
return variables.containsKey(name);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user