The engine is the framework

This commit is contained in:
Daniel Mills
2021-08-08 04:53:14 -04:00
parent 70d8b8a88a
commit f50ac49ede
42 changed files with 289 additions and 543 deletions

View File

@@ -21,20 +21,17 @@ package com.volmit.iris.engine.object.common;
import com.volmit.iris.core.project.loader.IrisRegistrant;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.bukkit.Bukkit;
@EqualsAndHashCode(callSuper = true)
@Data
public class IrisScript extends IrisRegistrant {
private final String source;
public IrisScript()
{
public IrisScript() {
this("");
}
public IrisScript(String source)
{
public IrisScript(String source) {
this.source = source;
}
@@ -48,8 +45,7 @@ public class IrisScript extends IrisRegistrant {
return "Script";
}
public String toString()
{
public String toString() {
return source;
}
}

View File

@@ -169,26 +169,19 @@ public class IrisEntity extends IrisRegistrant {
public Entity spawn(Engine gen, Location at, RNG rng) {
Entity ee = doSpawn(at);
if(!spawnerScript.isEmpty() && ee == null)
{
synchronized (this)
{
if (!spawnerScript.isEmpty() && ee == null) {
synchronized (this) {
gen.getExecution().getAPI().setLocation(at);
try
{
try {
ee = (Entity) gen.getExecution().evaluate(spawnerScript);
}
catch(Throwable ex)
{
} catch (Throwable ex) {
Iris.error("You must return an Entity in your scripts to use entity scripts!");
ex.printStackTrace();
}
}
}
if(ee == null)
{
if (ee == null) {
return null;
}
@@ -313,15 +306,12 @@ public class IrisEntity extends IrisRegistrant {
spawnEffect.apply(e);
}
if(postSpawnScripts.isNotEmpty())
{
synchronized (this)
{
if (postSpawnScripts.isNotEmpty()) {
synchronized (this) {
gen.getExecution().getAPI().setLocation(at);
gen.getExecution().getAPI().setEntity(ee);
for(String i : postSpawnScripts)
{
for (String i : postSpawnScripts) {
gen.getExecution().execute(i);
}
}
@@ -331,8 +321,7 @@ public class IrisEntity extends IrisRegistrant {
}
private Entity doSpawn(Location at) {
if(type.equals(EntityType.UNKNOWN))
{
if (type.equals(EntityType.UNKNOWN)) {
return null;
}

View File

@@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineFramework;
import com.volmit.iris.engine.modifier.IrisCaveModifier;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MinNumber;
@@ -86,12 +85,11 @@ public class IrisEntitySpawn implements IRare {
Location l = switch (getReferenceSpawner().getGroup()) {
case NORMAL -> new Location(c.getWorld(), x, hf + 1, z);
case CAVE -> {
IrisComplex comp = gen.getFramework().getComplex();
EngineFramework frame = gen.getFramework();
IrisComplex comp = gen.getComplex();
IrisBiome cave = comp.getCaveBiomeStream().get(x, z);
KList<Location> r = new KList<>();
if (cave != null) {
for (CaveResult i : ((IrisCaveModifier) frame.getCaveModifier()).genCaves(x, z)) {
for (CaveResult i : ((IrisCaveModifier) gen.getCaveModifier()).genCaves(x, z)) {
if (i.getCeiling() >= gen.getHeight() || i.getFloor() < 0 || i.getCeiling() - 2 <= i.getFloor()) {
continue;
}

View File

@@ -18,7 +18,7 @@
package com.volmit.iris.engine.object.noise;
import com.volmit.iris.engine.framework.EngineFramework;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.util.stream.ProceduralStream;
@@ -56,13 +56,13 @@ public enum IrisEngineStreamType {
@Desc("Represents the identity of regions. Each region has a unique number (very large numbers)")
REGION_IDENTITY((f) -> f.getComplex().getRegionIdentityStream());
private final Function<EngineFramework, ProceduralStream<Double>> getter;
private final Function<Engine, ProceduralStream<Double>> getter;
IrisEngineStreamType(Function<EngineFramework, ProceduralStream<Double>> getter) {
IrisEngineStreamType(Function<Engine, ProceduralStream<Double>> getter) {
this.getter = getter;
}
public ProceduralStream<Double> get(EngineFramework engine) {
public ProceduralStream<Double> get(Engine engine) {
return getter.apply(engine);
}
}

View File

@@ -18,7 +18,7 @@
package com.volmit.iris.engine.object.noise;
import com.volmit.iris.engine.framework.EngineFramework;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.Desc;
import java.util.function.Function;
@@ -26,28 +26,28 @@ import java.util.function.Function;
@Desc("Represents a value from the engine")
public enum IrisEngineValueType {
@Desc("Represents actual height of the engine")
ENGINE_HEIGHT((f) -> Double.valueOf(f.getEngine().getHeight())),
ENGINE_HEIGHT((f) -> Double.valueOf(f.getHeight())),
@Desc("Represents virtual bottom of the engine in the compound. If this engine is on top of another engine, it's min height would be at the maxHeight of the previous engine + 1")
ENGINE_MIN_HEIGHT((f) -> Double.valueOf(f.getEngine().getMinHeight())),
ENGINE_MIN_HEIGHT((f) -> Double.valueOf(f.getMinHeight())),
@Desc("Represents virtual top of the engine in the compound. If this engine is below another engine, it's max height would be at the minHeight of the next engine - 1")
ENGINE_MAX_HEIGHT((f) -> Double.valueOf(f.getEngine().getMaxHeight())),
ENGINE_MAX_HEIGHT((f) -> Double.valueOf(f.getMaxHeight())),
@Desc("Represents the position of the engine in the dimensional compound. The bottom (first) dimension stasts at 0. Each new dimension added stacks on top with n+1 for the id.")
ENGINE_INDEX((f) -> Double.valueOf(f.getEngine().getIndex())),
ENGINE_INDEX((f) -> Double.valueOf(f.getIndex())),
@Desc("The fluid height defined in the dimension file")
FLUID_HEIGHT((f) -> Double.valueOf(f.getComplex().getFluidHeight())),
;
private final Function<EngineFramework, Double> getter;
private final Function<Engine, Double> getter;
IrisEngineValueType(Function<EngineFramework, Double> getter) {
IrisEngineValueType(Function<Engine, Double> getter) {
this.getter = getter;
}
public Double get(EngineFramework engine) {
public Double get(Engine engine) {
return getter.apply(engine);
}
}

View File

@@ -59,11 +59,11 @@ public class IrisExpressionLoad {
public double getValue(RNG rng, IrisData data, double x, double z) {
if (engineValue != null) {
return valueCache.aquire(() -> engineValue.get(data.getEngine().getFramework()));
return valueCache.aquire(() -> engineValue.get(data.getEngine()));
}
if (engineStreamValue != null) {
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine().getFramework())).get(x, z);
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine())).get(x, z);
}
if (styleValue != null) {
@@ -75,11 +75,11 @@ public class IrisExpressionLoad {
public double getValue(RNG rng, IrisData data, double x, double y, double z) {
if (engineValue != null) {
return valueCache.aquire(() -> engineValue.get(data.getEngine().getFramework()));
return valueCache.aquire(() -> engineValue.get(data.getEngine()));
}
if (engineStreamValue != null) {
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine().getFramework())).get(x, z);
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine())).get(x, z);
}
if (styleValue != null) {