mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-25 22:17:59 +07:00
Some logic stuff
This commit is contained in:
parent
414d07a843
commit
8f676cf6c3
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();
|
||||
|
||||
double sense(LAccess sensor);
|
||||
double sense(Content content);
|
||||
|
||||
default double sense(Content content){
|
||||
return 0;
|
||||
}
|
||||
|
||||
default Object senseObject(LAccess sensor){
|
||||
return noSensed;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user