mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-08 00:36:15 +00:00
drastically optimise terrascript scoping
This commit is contained in:
@@ -2,13 +2,12 @@ package com.dfsek.terra.addons.terrascript.sampler;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.variables.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
||||
@@ -38,17 +37,17 @@ public class SamplerFunction implements Function<Number> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public Number apply(ImplementationArguments implementationArguments, Scope scope) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
double x = this.x.apply(implementationArguments, variableMap).doubleValue();
|
||||
double x = this.x.apply(implementationArguments, scope).doubleValue();
|
||||
|
||||
double z = this.z.apply(implementationArguments, variableMap).doubleValue();
|
||||
double z = this.z.apply(implementationArguments, scope).doubleValue();
|
||||
|
||||
NoiseSampler sampler = samplerFunction.apply(() -> function.apply(implementationArguments, variableMap));
|
||||
NoiseSampler sampler = samplerFunction.apply(() -> function.apply(implementationArguments, scope));
|
||||
if(twoD) {
|
||||
return sampler.noise(arguments.getWorld().getSeed(), x, z);
|
||||
} else {
|
||||
double y = this.y.apply(implementationArguments, variableMap).doubleValue();
|
||||
double y = this.y.apply(implementationArguments, scope).doubleValue();
|
||||
return sampler.noise(arguments.getWorld().getSeed(), x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user