Modding API-related tweaks
This commit is contained in:
@@ -142,6 +142,8 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
public boolean noUpdateDisabled = false;
|
||||
/** if true, this block updates when it's a payload in a unit. */
|
||||
public boolean updateInUnits = true;
|
||||
/** if true, this block updates in payloads in units regardless of the experimental game rule */
|
||||
public boolean alwaysUpdateInUnits = false;
|
||||
/** Whether to use this block's color in the minimap. Only used for overlays. */
|
||||
public boolean useColor = true;
|
||||
/** item that drops from this block, used for drills */
|
||||
@@ -827,6 +829,10 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
return buildType.get();
|
||||
}
|
||||
|
||||
public void updateClipRadius(float size){
|
||||
clipSize = Math.max(clipSize, size * tilesize + size * 2f);
|
||||
}
|
||||
|
||||
public Rect bounds(int x, int y, Rect rect){
|
||||
return rect.setSize(size * tilesize).setCenter(x * tilesize + offset, y * tilesize + offset);
|
||||
}
|
||||
@@ -890,6 +896,13 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
return consumers.length == 0 ? (T)consumeBuilder.find(filter) : (T)Structs.find(consumers, filter);
|
||||
}
|
||||
|
||||
public void removeConsumer(Consume cons){
|
||||
if(consumers.length > 0){
|
||||
throw new IllegalStateException("You can only remove consumers before init(). After init(), all consumers have already been initialized.");
|
||||
}
|
||||
consumeBuilder.remove(cons);
|
||||
}
|
||||
|
||||
public ConsumeLiquid consumeLiquid(Liquid liquid, float amount){
|
||||
return consume(new ConsumeLiquid(liquid, amount));
|
||||
}
|
||||
@@ -937,6 +950,10 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
return consume(new ConsumeItems(items));
|
||||
}
|
||||
|
||||
public ConsumeCoolant consumeCoolant(float amount){
|
||||
return consume(new ConsumeCoolant(amount));
|
||||
}
|
||||
|
||||
public <T extends Consume> T consume(T consume){
|
||||
if(consume instanceof ConsumePower){
|
||||
//there can only be one power consumer
|
||||
@@ -1244,7 +1261,7 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
var gen = icons();
|
||||
|
||||
if(outlineIcon){
|
||||
PixmapRegion region = Core.atlas.getPixmap(gen[outlinedIcon >= 0 ? outlinedIcon : gen.length -1]);
|
||||
PixmapRegion region = Core.atlas.getPixmap(gen[outlinedIcon >= 0 ? Math.min(outlinedIcon, gen.length - 1) : gen.length -1]);
|
||||
Pixmap out = last = Pixmaps.outline(region, outlineColor, outlineRadius);
|
||||
if(Core.settings.getBool("linear", true)){
|
||||
Pixmaps.bleed(out);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class BaseShield extends Block{
|
||||
public void init(){
|
||||
super.init();
|
||||
|
||||
clipSize = Math.max(clipSize, radius * 2f + 8f);
|
||||
updateClipRadius(radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -71,7 +71,7 @@ public class DirectionalForceProjector extends Block{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
clipSize = Math.max(clipSize, (width + 3f) * 2f);
|
||||
updateClipRadius((width + 3f));
|
||||
|
||||
super.init();
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class ForceProjector extends Block{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
clipSize = Math.max(clipSize, (radius + phaseRadiusBoost + 3f) * 2f);
|
||||
updateClipRadius(radius + phaseRadiusBoost + 3f);
|
||||
super.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@ import mindustry.world.meta.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
//TODO visuals!
|
||||
public class PayloadTurret extends Turret{
|
||||
public class PayloadAmmoTurret extends Turret{
|
||||
public ObjectMap<UnlockableContent, BulletType> ammoTypes = new ObjectMap<>();
|
||||
|
||||
protected UnlockableContent[] ammoKeys;
|
||||
|
||||
public PayloadTurret(String name){
|
||||
public PayloadAmmoTurret(String name){
|
||||
super(name);
|
||||
|
||||
maxAmmo = 3;
|
||||
@@ -65,7 +65,7 @@ public class TractorBeamTurret extends BaseTurret{
|
||||
public void init(){
|
||||
super.init();
|
||||
|
||||
clipSize = Math.max(clipSize, (range + tilesize) * 2);
|
||||
updateClipRadius(range + tilesize);
|
||||
}
|
||||
|
||||
public class TractorBeamBuild extends BaseTurretBuild{
|
||||
|
||||
@@ -45,7 +45,7 @@ public class DirectionBridge extends Block{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
clipSize = Math.max(clipSize, (range + 0.5f) * 2 * tilesize);
|
||||
updateClipRadius((range + 0.5f) * tilesize);
|
||||
super.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ public class ItemBridge extends Block{
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
clipSize = Math.max(clipSize, (range + 0.5f) * tilesize * 2);
|
||||
updateClipRadius((range + 0.5f) * tilesize);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,7 +44,7 @@ public class BuildPayload implements Payload{
|
||||
|
||||
@Override
|
||||
public void update(boolean inUnit){
|
||||
if(inUnit && !build.block.updateInUnits) return;
|
||||
if(inUnit && (!build.block.updateInUnits || (!state.rules.unitPayloadUpdate && !build.block.alwaysUpdateInUnits))) return;
|
||||
|
||||
build.tile = emptyTile;
|
||||
build.update();
|
||||
|
||||
@@ -71,7 +71,7 @@ public class PayloadMassDriver extends PayloadBlock{
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
clipSize = Math.max(clipSize, range*2f + tilesize*size);
|
||||
updateClipRadius(range);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,7 +52,7 @@ public class BeamNode extends PowerBlock{
|
||||
public void init(){
|
||||
super.init();
|
||||
|
||||
clipSize = Math.max(clipSize, tilesize*size + (range+1)*tilesize*2);
|
||||
updateClipRadius((range + 1) * tilesize);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -65,7 +65,7 @@ public class BeamDrill extends Block{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
clipSize = Math.max(clipSize, size * tilesize + (range + 2) * tilesize);
|
||||
updateClipRadius((range + 2) * tilesize);
|
||||
super.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public class RepairTurret extends Block{
|
||||
}
|
||||
|
||||
consumePowerCond(powerUse, (RepairPointBuild entity) -> entity.target != null);
|
||||
clipSize = Math.max(clipSize, (repairRadius + tilesize) * 2);
|
||||
updateClipRadius(repairRadius);
|
||||
super.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public class UnitAssembler extends PayloadBlock{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
clipSize = Math.max(clipSize, (areaSize + size) * tilesize * 2);
|
||||
updateClipRadius(areaSize * tilesize);
|
||||
consume(consPayload = new ConsumePayloadDynamic((UnitAssemblerBuild build) -> build.plan().requirements));
|
||||
|
||||
super.init();
|
||||
|
||||
Reference in New Issue
Block a user