mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
Closes Anuken/Mindustry-Suggestions/issues/4608
This commit is contained in:
parent
398a6f6a42
commit
fb4787ba52
@ -2237,7 +2237,7 @@ lst.operation = Perform an operation on 1-2 variables.
|
||||
lst.end = Jump to the top of the instruction stack.
|
||||
lst.wait = Wait a certain number of seconds.
|
||||
lst.stop = Halt execution of this processor.
|
||||
lst.lookup = Look up an item/liquid/unit/block type by ID.\nTotal counts of each type can be accessed with:\n[accent]@unitCount[] / [accent]@itemCount[] / [accent]@liquidCount[] / [accent]@blockCount[]
|
||||
lst.lookup = Look up an item/liquid/unit/block type by ID.\nTotal counts of each type can be accessed with:\n[accent]@unitCount[] / [accent]@itemCount[] / [accent]@liquidCount[] / [accent]@blockCount[]\nFor the inverse operation, sense [accent]@id[] of the object.
|
||||
lst.jump = Conditionally jump to another statement.
|
||||
lst.unitbind = Bind to the next unit of a type, and store it in [accent]@unit[].
|
||||
lst.unitcontrol = Control the currently bound unit.
|
||||
@ -2275,6 +2275,7 @@ laccess.dead = Whether a unit/building is dead or no longer valid.
|
||||
laccess.controlled = Returns:\n[accent]@ctrlProcessor[] if unit controller is processor\n[accent]@ctrlPlayer[] if unit/building controller is player\n[accent]@ctrlCommand[] if unit controller is a player command\nOtherwise, 0.
|
||||
laccess.progress = Action progress, 0 to 1.\nReturns production, turret reload or construction progress.
|
||||
laccess.speed = Top speed of a unit, in tiles/sec.
|
||||
laccess.id = ID of a unit/block/item/liquid.\nThis is the inverse of the lookup operation.
|
||||
|
||||
lcategory.unknown = Unknown
|
||||
lcategory.unknown.description = Uncategorized instructions.
|
||||
|
@ -68,6 +68,10 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
uiIcon = Core.atlas.find(getContentType().name() + "-" + name + "-ui", fullIcon);
|
||||
}
|
||||
|
||||
public int getLogicId(){
|
||||
return logicVars.lookupLogicId(this);
|
||||
}
|
||||
|
||||
public String displayDescription(){
|
||||
return minfo.mod == null ? description : description + "\n" + Core.bundle.format("mod.display", minfo.mod.meta.displayName);
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ public enum LAccess{
|
||||
name,
|
||||
payloadCount,
|
||||
payloadType,
|
||||
id,
|
||||
|
||||
//values with parameters are considered controllable
|
||||
enabled("to"), //"to" is standard for single parameter access
|
||||
|
@ -1143,7 +1143,6 @@ public class LExecutor{
|
||||
}
|
||||
}
|
||||
|
||||
//TODO inverse lookup
|
||||
public static class LookupI implements LInstruction{
|
||||
public int dest;
|
||||
public int from;
|
||||
|
@ -153,8 +153,9 @@ public class Item extends UnlockableContent implements Senseable{
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor){
|
||||
if(sensor == LAccess.color) return color.toFloatBits();
|
||||
return 0;
|
||||
if(sensor == LAccess.color) return color.toDoubleBits();
|
||||
if(sensor == LAccess.id) return getLogicId();
|
||||
return Float.NaN;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -171,8 +171,9 @@ public class Liquid extends UnlockableContent implements Senseable{
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor){
|
||||
if(sensor == LAccess.color) return color.toFloatBits();
|
||||
return 0;
|
||||
if(sensor == LAccess.color) return color.toDoubleBits();
|
||||
if(sensor == LAccess.id) return getLogicId();
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,6 +28,7 @@ import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.graphics.MultiPacker.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.type.ammo.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
@ -40,7 +41,7 @@ import mindustry.world.meta.*;
|
||||
import static arc.graphics.g2d.Draw.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class UnitType extends UnlockableContent{
|
||||
public class UnitType extends UnlockableContent implements Senseable{
|
||||
public static final float shadowTX = -12, shadowTY = -13;
|
||||
private static final Vec2 legOffset = new Vec2();
|
||||
|
||||
@ -1124,6 +1125,24 @@ public class UnitType extends UnlockableContent{
|
||||
return super.researchRequirements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor){
|
||||
return switch(sensor){
|
||||
case health, maxHealth -> health;
|
||||
case size -> hitSize / tilesize;
|
||||
case itemCapacity -> itemCapacity;
|
||||
case speed -> speed * 60f / tilesize;
|
||||
case id -> getLogicId();
|
||||
default -> Double.NaN;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object senseObject(LAccess sensor){
|
||||
if(sensor == LAccess.name) return name;
|
||||
return noSensed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentType getContentType(){
|
||||
return ContentType.unit;
|
||||
|
@ -1374,6 +1374,7 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
case itemCapacity -> itemCapacity;
|
||||
case liquidCapacity -> liquidCapacity;
|
||||
case powerCapacity -> consPower != null && consPower.buffered ? consPower.capacity : 0f;
|
||||
case id -> getLogicId();
|
||||
default -> Double.NaN;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user