mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Aquire engine data in expressions
This commit is contained in:
parent
ffa5fd5b2a
commit
4b8cfd9fdd
@ -19,6 +19,7 @@
|
||||
package com.volmit.iris.core.project.loader;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.*;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
@ -47,6 +48,7 @@ public class IrisData {
|
||||
private KMap<Class<? extends IrisRegistrant>, ResourceLoader<? extends IrisRegistrant>> loaders = new KMap<>();
|
||||
private boolean closed;
|
||||
private final File dataFolder;
|
||||
private Engine engine;
|
||||
private final int id;
|
||||
|
||||
public IrisData(File dataFolder) {
|
||||
@ -54,6 +56,7 @@ public class IrisData {
|
||||
}
|
||||
|
||||
public IrisData(File dataFolder, boolean oneshot) {
|
||||
this.engine = null;
|
||||
this.dataFolder = dataFolder;
|
||||
this.id = RNG.r.imax();
|
||||
closed = false;
|
||||
|
@ -101,6 +101,7 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
||||
Iris.info("Initializing Engine: " + target.getWorld().name() + "/" + target.getDimension().getLoadKey() + " (" + target.getHeight() + " height)");
|
||||
metrics = new EngineMetrics(32);
|
||||
this.target = target;
|
||||
getData().setEngine(this);
|
||||
getEngineData();
|
||||
this.framework = new IrisEngineFramework(this);
|
||||
worldManager = new IrisWorldManager(this);
|
||||
|
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.framework.EngineFramework;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.stream.ProceduralStream;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@Desc("Represents a stream from the engine")
|
||||
public enum IrisEngineStreamType
|
||||
{
|
||||
@Desc("Represents the given slope at the x, z coordinates")
|
||||
SLOPE((f) -> f.getComplex().getSlopeStream()),
|
||||
|
||||
@Desc("Represents the real terrain height ignoring fluid, this includes carving, caves & noise features into this stream.")
|
||||
TRUE_HEIGHT((f) -> f.getComplex().getTrueHeightStream().forceDouble()),
|
||||
|
||||
@Desc("Represents the real terrain height including fluid, this includes carving, caves & noise features into this stream.")
|
||||
TRUE_HEIGHT_OR_FLUID((f) -> f.getComplex().getTrueHeightStream().forceDouble().max(f.getComplex().getFluidHeight())),
|
||||
|
||||
@Desc("Represents the base generator height at the given position. This includes only the biome generators / interpolation and noise features but does not include carving, caves.")
|
||||
HEIGHT((f) -> f.getComplex().getHeightStream()),
|
||||
|
||||
@Desc("Represents the base generator height at the given position. This includes only the biome generators / interpolation and noise features but does not include carving, caves. with Max(height, fluidHeight).")
|
||||
HEIGHT_OR_FLUID((f) -> f.getComplex().getHeightFluidStream()),
|
||||
|
||||
@Desc("Represents the overlay noise generators summed (dimension setting)")
|
||||
OVERLAY_NOISE((f) -> f.getComplex().getOverlayStream()),
|
||||
|
||||
@Desc("Represents the overlay noise generators summed (dimension setting)")
|
||||
HEIGHT_NO_FEATURES((f) -> f.getComplex().getHeightStreamNoFeatures()),
|
||||
|
||||
@Desc("Represents the object chance clip. If a noise feature alters the object chance in this area this number will drop below 1. (100%)")
|
||||
OBJECT_CHANCE_CLIP((f) -> f.getComplex().getObjectChanceStream()),
|
||||
|
||||
@Desc("Represents the noise style of regions")
|
||||
REGION_STYLE((f) -> f.getComplex().getRegionStyleStream()),
|
||||
|
||||
@Desc("Represents the identity of regions. Each region has a unique number (very large numbers)")
|
||||
REGION_IDENTITY((f) -> f.getComplex().getRegionIdentityStream());
|
||||
|
||||
private Function<EngineFramework, ProceduralStream<Double>> getter;
|
||||
|
||||
private IrisEngineStreamType(Function<EngineFramework, ProceduralStream<Double>> getter)
|
||||
{
|
||||
this.getter = getter;
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> get(EngineFramework engine)
|
||||
{
|
||||
return getter.apply(engine);
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.framework.EngineFramework;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
|
||||
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())),
|
||||
|
||||
@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())),
|
||||
|
||||
@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())),
|
||||
|
||||
@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())),
|
||||
|
||||
@Desc("The fluid height defined in the dimension file")
|
||||
FLUID_HEIGHT((f) -> Double.valueOf(f.getComplex().getFluidHeight())),
|
||||
;
|
||||
|
||||
private Function<EngineFramework, Double> getter;
|
||||
|
||||
private IrisEngineValueType(Function<EngineFramework, Double> getter)
|
||||
{
|
||||
this.getter = getter;
|
||||
}
|
||||
|
||||
public Double get(EngineFramework engine)
|
||||
{
|
||||
return getter.apply(engine);
|
||||
}
|
||||
}
|
@ -19,8 +19,10 @@
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -43,10 +45,29 @@ public class IrisExpressionLoad {
|
||||
@Desc("If the style value is not defined, this value will be used")
|
||||
private double staticValue = -1;
|
||||
|
||||
@Desc("If defined, this variable will use a generator style as it's result")
|
||||
@Desc("If defined, this variable will use a generator style as it's value")
|
||||
private IrisGeneratorStyle styleValue = null;
|
||||
|
||||
@Desc("If defined, iris will use an internal stream from the engine as it's value")
|
||||
private IrisEngineStreamType engineStreamValue = null;
|
||||
|
||||
@Desc("If defined, iris will use an internal value from the engine as it's value")
|
||||
private IrisEngineValueType engineValue = null;
|
||||
|
||||
private transient AtomicCache<ProceduralStream<Double>> streamCache = new AtomicCache<>();
|
||||
private transient AtomicCache<Double> valueCache = new AtomicCache<>();
|
||||
|
||||
public double getValue(RNG rng, IrisData data, double x, double z) {
|
||||
if(engineValue != null)
|
||||
{
|
||||
return valueCache.aquire(() -> engineValue.get(data.getEngine().getFramework()));
|
||||
}
|
||||
|
||||
if(engineStreamValue != null)
|
||||
{
|
||||
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine().getFramework())).get(x, z);
|
||||
}
|
||||
|
||||
if (styleValue != null) {
|
||||
return styleValue.create(rng, data).noise(x, z);
|
||||
}
|
||||
@ -55,6 +76,16 @@ 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()));
|
||||
}
|
||||
|
||||
if(engineStreamValue != null)
|
||||
{
|
||||
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine().getFramework())).get(x, z);
|
||||
}
|
||||
|
||||
if (styleValue != null) {
|
||||
return styleValue.create(rng, data).noise(x, y, z);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user