mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-08 23:07:33 +07:00
Some logic stuff
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
@ -6,7 +6,10 @@ public interface Senseable{
|
|||||||
Object noSensed = new Object();
|
Object noSensed = new Object();
|
||||||
|
|
||||||
double sense(LAccess sensor);
|
double sense(LAccess sensor);
|
||||||
double sense(Content content);
|
|
||||||
|
default double sense(Content content){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
default Object senseObject(LAccess sensor){
|
default Object senseObject(LAccess sensor){
|
||||||
return noSensed;
|
return noSensed;
|
||||||
|
@ -9,12 +9,13 @@ import mindustry.ctype.*;
|
|||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.graphics.MultiPacker.*;
|
import mindustry.graphics.MultiPacker.*;
|
||||||
|
import mindustry.logic.*;
|
||||||
import mindustry.world.blocks.environment.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class Item extends UnlockableContent{
|
public class Item extends UnlockableContent implements Senseable{
|
||||||
public Color color;
|
public Color color;
|
||||||
|
|
||||||
/** how explosive this item is. */
|
/** how explosive this item is. */
|
||||||
@ -129,6 +130,18 @@ public class Item extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double sense(LAccess sensor){
|
||||||
|
if(sensor == LAccess.color) return color.toFloatBits();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object senseObject(LAccess sensor){
|
||||||
|
if(sensor == LAccess.name) return name;
|
||||||
|
return noSensed;
|
||||||
|
}
|
||||||
|
|
||||||
/** Allocates a new array containing all items that generate ores. */
|
/** Allocates a new array containing all items that generate ores. */
|
||||||
public static Seq<Item> getAllOres(){
|
public static Seq<Item> getAllOres(){
|
||||||
return content.blocks().select(b -> b instanceof OreBlock).map(b -> b.itemDrop);
|
return content.blocks().select(b -> b instanceof OreBlock).map(b -> b.itemDrop);
|
||||||
|
@ -10,12 +10,13 @@ import mindustry.entities.*;
|
|||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.logic.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import static mindustry.entities.Puddles.*;
|
import static mindustry.entities.Puddles.*;
|
||||||
|
|
||||||
/** A better name for this class would be "fluid", but it's too late for that. */
|
/** A better name for this class would be "fluid", but it's too late for that. */
|
||||||
public class Liquid extends UnlockableContent{
|
public class Liquid extends UnlockableContent implements Senseable{
|
||||||
//must be static and global so conduits don't conflict - DO NOT INTERACT WITH THESE IN MODS OR I WILL PERSONALLY YELL AT YOU
|
//must be static and global so conduits don't conflict - DO NOT INTERACT WITH THESE IN MODS OR I WILL PERSONALLY YELL AT YOU
|
||||||
public static final int animationFrames = 50;
|
public static final int animationFrames = 50;
|
||||||
public static float animationScaleGas = 190f, animationScaleLiquid = 230f;
|
public static float animationScaleGas = 190f, animationScaleLiquid = 230f;
|
||||||
@ -147,6 +148,18 @@ public class Liquid extends UnlockableContent{
|
|||||||
stats.addPercent(Stat.viscosity, viscosity);
|
stats.addPercent(Stat.viscosity, viscosity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double sense(LAccess sensor){
|
||||||
|
if(sensor == LAccess.color) return color.toFloatBits();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object senseObject(LAccess sensor){
|
||||||
|
if(sensor == LAccess.name) return name;
|
||||||
|
return noSensed;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return localizedName;
|
return localizedName;
|
||||||
|
@ -1153,7 +1153,7 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
@Override
|
@Override
|
||||||
public double sense(LAccess sensor){
|
public double sense(LAccess sensor){
|
||||||
return switch(sensor){
|
return switch(sensor){
|
||||||
case color -> Color.toDoubleBits(mapColor.r, mapColor.g, mapColor.b, mapColor.a);
|
case color -> mapColor.toDoubleBits();
|
||||||
case health, maxHealth -> health;
|
case health, maxHealth -> health;
|
||||||
case size -> size * tilesize;
|
case size -> size * tilesize;
|
||||||
case itemCapacity -> itemCapacity;
|
case itemCapacity -> itemCapacity;
|
||||||
|
@ -24,4 +24,4 @@ android.useAndroidX=true
|
|||||||
#used for slow jitpack builds; TODO see if this actually works
|
#used for slow jitpack builds; TODO see if this actually works
|
||||||
org.gradle.internal.http.socketTimeout=100000
|
org.gradle.internal.http.socketTimeout=100000
|
||||||
org.gradle.internal.http.connectionTimeout=100000
|
org.gradle.internal.http.connectionTimeout=100000
|
||||||
archash=f95111f269
|
archash=df5b4b832c
|
||||||
|
Reference in New Issue
Block a user