Some logic stuff

This commit is contained in:
Anuken 2022-02-10 12:33:18 -05:00
parent 414d07a843
commit 8f676cf6c3
6 changed files with 34 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -6,7 +6,10 @@ public interface Senseable{
Object noSensed = new Object();
double sense(LAccess sensor);
double sense(Content content);
default double sense(Content content){
return 0;
}
default Object senseObject(LAccess sensor){
return noSensed;

View File

@ -9,12 +9,13 @@ import mindustry.ctype.*;
import mindustry.game.EventType.*;
import mindustry.graphics.*;
import mindustry.graphics.MultiPacker.*;
import mindustry.logic.*;
import mindustry.world.blocks.environment.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class Item extends UnlockableContent{
public class Item extends UnlockableContent implements Senseable{
public Color color;
/** 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. */
public static Seq<Item> getAllOres(){
return content.blocks().select(b -> b instanceof OreBlock).map(b -> b.itemDrop);

View File

@ -10,12 +10,13 @@ import mindustry.entities.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.logic.*;
import mindustry.world.meta.*;
import static mindustry.entities.Puddles.*;
/** 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
public static final int animationFrames = 50;
public static float animationScaleGas = 190f, animationScaleLiquid = 230f;
@ -147,6 +148,18 @@ public class Liquid extends UnlockableContent{
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
public String toString(){
return localizedName;

View File

@ -1153,7 +1153,7 @@ public class Block extends UnlockableContent implements Senseable{
@Override
public double sense(LAccess 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 size -> size * tilesize;
case itemCapacity -> itemCapacity;

View File

@ -24,4 +24,4 @@ android.useAndroidX=true
#used for slow jitpack builds; TODO see if this actually works
org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000
archash=f95111f269
archash=df5b4b832c