Modding API-related tweaks

This commit is contained in:
Anuken
2022-05-06 13:45:43 -04:00
parent 9da97c4d3c
commit 55f729565b
23 changed files with 85 additions and 72 deletions

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -142,7 +142,7 @@ public class Blocks{
tankFabricator, shipFabricator, mechFabricator, tankFabricator, shipFabricator, mechFabricator,
//TODO names //TODO names
basicReconstructor, refabricator,
advancedReconstructor, advancedReconstructor,
tankAssembler, shipAssembler, mechAssembler, tankAssembler, shipAssembler, mechAssembler,
@@ -2883,7 +2883,7 @@ public class Blocks{
scaledHealth = 200; scaledHealth = 200;
shootSound = Sounds.shootSnap; shootSound = Sounds.shootSnap;
coolant = consume(new ConsumeCoolant(0.2f)); coolant = consumeCoolant(0.2f);
limitRange(2); limitRange(2);
}}; }};
@@ -2928,7 +2928,7 @@ public class Blocks{
ammoUseEffect = Fx.none; ammoUseEffect = Fx.none;
health = 400; health = 400;
shootSound = Sounds.flame; shootSound = Sounds.flame;
coolant = consume(new ConsumeCoolant(0.1f)); coolant = consumeCoolant(0.1f);
}}; }};
hail = new ItemTurret("hail"){{ hail = new ItemTurret("hail"){{
@@ -2979,7 +2979,7 @@ public class Blocks{
shootCone = 10f; shootCone = 10f;
health = 260; health = 260;
shootSound = Sounds.bang; shootSound = Sounds.bang;
coolant = consume(new ConsumeCoolant(0.1f)); coolant = consumeCoolant(0.1f);
limitRange(0f); limitRange(0f);
}}; }};
@@ -3033,7 +3033,7 @@ public class Blocks{
moveWhileCharging = false; moveWhileCharging = false;
accurateDelay = false; accurateDelay = false;
shootSound = Sounds.laser; shootSound = Sounds.laser;
coolant = consume(new ConsumeCoolant(0.2f)); coolant = consumeCoolant(0.2f);
consumePower(6f); consumePower(6f);
@@ -3089,7 +3089,7 @@ public class Blocks{
health = 260; health = 260;
shootSound = Sounds.spark; shootSound = Sounds.spark;
consumePower(3.3f); consumePower(3.3f);
coolant = consume(new ConsumeCoolant(0.1f)); coolant = consumeCoolant(0.1f);
}}; }};
parallax = new TractorBeamTurret("parallax"){{ parallax = new TractorBeamTurret("parallax"){{
@@ -3169,7 +3169,7 @@ public class Blocks{
envEnabled |= Env.space; envEnabled |= Env.space;
limitRange(5f); limitRange(5f);
coolant = consume(new ConsumeCoolant(0.3f)); coolant = consumeCoolant(0.3f);
}}; }};
salvo = new ItemTurret("salvo"){{ salvo = new ItemTurret("salvo"){{
@@ -3238,7 +3238,7 @@ public class Blocks{
shootSound = Sounds.shootBig; shootSound = Sounds.shootBig;
limitRange(); limitRange();
coolant = consume(new ConsumeCoolant(0.2f)); coolant = consumeCoolant(0.2f);
}}; }};
segment = new PointDefenseTurret("segment"){{ segment = new PointDefenseTurret("segment"){{
@@ -3326,10 +3326,7 @@ public class Blocks{
range = 90f; range = 90f;
recoilAmount = 5f; recoilAmount = 5f;
shoot = new ShootSpread(){{ shoot = new ShootSpread(3, 20f);
shots = 3;
spread = 20f;
}};
restitution = 0.1f; restitution = 0.1f;
shootCone = 30; shootCone = 30;
@@ -3338,7 +3335,7 @@ public class Blocks{
scaledHealth = 220; scaledHealth = 220;
shootSound = Sounds.shotgun; shootSound = Sounds.shotgun;
coolant = consume(new ConsumeCoolant(0.3f)); coolant = consumeCoolant(0.3f);
float brange = range + 10f; float brange = range + 10f;
@@ -3452,7 +3449,7 @@ public class Blocks{
shootShake = 2f; shootShake = 2f;
range = 290f; range = 290f;
minRange = 50f; minRange = 50f;
coolant = consume(new ConsumeCoolant(0.3f)); coolant = consumeCoolant(0.3f);
scaledHealth = 130; scaledHealth = 130;
shootSound = Sounds.artillery; shootSound = Sounds.artillery;
@@ -3540,7 +3537,7 @@ public class Blocks{
inaccuracy = 10f; inaccuracy = 10f;
shootCone = 30f; shootCone = 30f;
shootSound = Sounds.shootSnap; shootSound = Sounds.shootSnap;
coolant = consume(new ConsumeCoolant(0.3f)); coolant = consumeCoolant(0.3f);
scaledHealth = 145; scaledHealth = 145;
limitRange(); limitRange();
@@ -3584,7 +3581,7 @@ public class Blocks{
coolantMultiplier = 0.4f; coolantMultiplier = 0.4f;
scaledHealth = 150; scaledHealth = 150;
coolant = consume(new ConsumeCoolant(1f)); coolant = consumeCoolant(1f);
consumePower(10f); consumePower(10f);
}}; }};
@@ -3643,7 +3640,7 @@ public class Blocks{
shootSound = Sounds.shootBig; shootSound = Sounds.shootBig;
scaledHealth = 160; scaledHealth = 160;
coolant = consume(new ConsumeCoolant(1f)); coolant = consumeCoolant(1f);
limitRange(); limitRange();
}}; }};
@@ -3678,7 +3675,7 @@ public class Blocks{
}}; }};
scaledHealth = 200; scaledHealth = 200;
coolant = consume(new ConsumeCoolant(0.5f)); coolant = consumeCoolant(0.5f);
consumePower(17f); consumePower(17f);
}}; }};
@@ -3769,10 +3766,7 @@ public class Blocks{
}} }}
); );
shoot = new ShootSpread(){{ shoot = new ShootSpread(15, 4f);
shots = 15;
spread = 4f;
}};
coolantMultiplier = 6f; coolantMultiplier = 6f;
@@ -4226,7 +4220,7 @@ public class Blocks{
consumePower(2f); consumePower(2f);
}}; }};
basicReconstructor = new Reconstructor("basic-reconstructor"){{ refabricator = new Reconstructor("refabricator"){{
requirements(Category.units, with(Items.beryllium, 250, Items.tungsten, 120, Items.silicon, 150)); requirements(Category.units, with(Items.beryllium, 250, Items.tungsten, 120, Items.silicon, 150));
regionSuffix = "-dark"; regionSuffix = "-dark";

View File

@@ -188,7 +188,7 @@ public class ErekirTechTree{
node(cliffCrusher, () -> { node(cliffCrusher, () -> {
node(siliconArcFurnace, () -> { node(siliconArcFurnace, () -> {
node(electrolyzer, Seq.with(new OnSector(three)), () -> { node(electrolyzer, Seq.with(new OnSector(three)), () -> {
node(oxidationChamber, Seq.with(new Research(basicReconstructor), new OnSector(four)), () -> { node(oxidationChamber, Seq.with(new Research(refabricator), new OnSector(four)), () -> {
node(electricHeater, Seq.with(new OnSector(four)), () -> { node(electricHeater, Seq.with(new OnSector(four)), () -> {
node(heatRedirector, () -> { node(heatRedirector, () -> {
@@ -293,7 +293,7 @@ public class ErekirTechTree{
}); });
node(basicReconstructor, Seq.with(new OnSector(three)), () -> { node(refabricator, Seq.with(new OnSector(three)), () -> {
node(UnitTypes.cleroi); node(UnitTypes.cleroi);
node(UnitTypes.avert); node(UnitTypes.avert);
node(UnitTypes.locus); node(UnitTypes.locus);

View File

@@ -887,10 +887,7 @@ public class UnitTypes{
shadow = 12f; shadow = 12f;
recoil = 3f; recoil = 3f;
shoot = new ShootSpread(){{ shoot = new ShootSpread(2, 17f);
shots = 2;
spread = 17f;
}};
bullet = new ShrapnelBulletType(){{ bullet = new ShrapnelBulletType(){{
length = 90f; length = 90f;
@@ -3520,10 +3517,7 @@ public class UnitTypes{
baseRotation = -35f; baseRotation = -35f;
shootCone = 360f; shootCone = 360f;
shoot = new ShootSpread(){{ shoot = new ShootSpread(2, 11f);
shots = 2;
spread = 11f;
}};
bullet = new BasicBulletType(5f, 24){{ bullet = new BasicBulletType(5f, 24){{
homingPower = 0.19f; homingPower = 0.19f;

View File

@@ -31,33 +31,31 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc, Unitc{
@Override @Override
public void update(){ public void update(){
if(Vars.state.rules.unitPayloadUpdate){ if(payloadPower != null){
if(payloadPower != null){ payloadPower.clear();
payloadPower.clear(); }
}
//update power graph first, resolve everything //update power graph first, resolve everything
for(Payload pay : payloads){ for(Payload pay : payloads){
if(pay instanceof BuildPayload pb && pb.build.power != null){ if(pay instanceof BuildPayload pb && pb.build.power != null){
if(payloadPower == null) payloadPower = new PowerGraph(); if(payloadPower == null) payloadPower = new PowerGraph();
pb.build.team = team; pb.build.team = team;
pb.build.power.graph = null; pb.build.power.graph = null;
payloadPower.add(pb.build); payloadPower.add(pb.build);
}
} }
}
if(payloadPower != null){ if(payloadPower != null){
payloadPower.update(); payloadPower.update();
} }
for(Payload pay : payloads){ for(Payload pay : payloads){
if(pay instanceof BuildPayload build){ if(pay instanceof BuildPayload build){
build.build.team = team; build.build.team = team;
}
pay.set(x, y, rotation);
pay.update(true);
} }
pay.set(x, y, rotation);
pay.update(true);
} }
} }

View File

@@ -4,6 +4,14 @@ public class ShootSpread extends ShootPattern{
/** spread between bullets, in degrees. */ /** spread between bullets, in degrees. */
public float spread = 5f; public float spread = 5f;
public ShootSpread(int shots, float spread){
this.shots = shots;
this.spread = spread;
}
public ShootSpread(){
}
@Override @Override
public void shoot(int totalShots, BulletHandler handler){ public void shoot(int totalShots, BulletHandler handler){
for(int i = 0; i < shots; i++){ for(int i = 0; i < shots; i++){

View File

@@ -63,7 +63,8 @@ public abstract class SaveFileReader{
"thermal-pump", "impulse-pump", "thermal-pump", "impulse-pump",
"alloy-smelter", "surge-smelter", "alloy-smelter", "surge-smelter",
"steam-vent", "rhyolite-vent", "steam-vent", "rhyolite-vent",
"fabricator", "tank-fabricator" "fabricator", "tank-fabricator",
"basic-reconstructor", "refabricator"
); );
public static final ObjectMap<String, String> modContentNameMap = ObjectMap.of( public static final ObjectMap<String, String> modContentNameMap = ObjectMap.of(

View File

@@ -1,6 +1,7 @@
package mindustry.mod; package mindustry.mod;
import arc.struct.*; import arc.struct.*;
import mindustry.world.blocks.defense.turrets.*;
import mindustry.world.blocks.units.*; import mindustry.world.blocks.units.*;
import mindustry.world.draw.*; import mindustry.world.draw.*;
@@ -166,8 +167,8 @@ public class ClassMap{
classes.put("LaserTurretBuild", mindustry.world.blocks.defense.turrets.LaserTurret.LaserTurretBuild.class); classes.put("LaserTurretBuild", mindustry.world.blocks.defense.turrets.LaserTurret.LaserTurretBuild.class);
classes.put("LiquidTurret", mindustry.world.blocks.defense.turrets.LiquidTurret.class); classes.put("LiquidTurret", mindustry.world.blocks.defense.turrets.LiquidTurret.class);
classes.put("LiquidTurretBuild", mindustry.world.blocks.defense.turrets.LiquidTurret.LiquidTurretBuild.class); classes.put("LiquidTurretBuild", mindustry.world.blocks.defense.turrets.LiquidTurret.LiquidTurretBuild.class);
classes.put("PayloadTurret", mindustry.world.blocks.defense.turrets.PayloadTurret.class); classes.put("PayloadTurret", PayloadAmmoTurret.class);
classes.put("PayloadTurretBuild", mindustry.world.blocks.defense.turrets.PayloadTurret.PayloadTurretBuild.class); classes.put("PayloadTurretBuild", PayloadAmmoTurret.PayloadTurretBuild.class);
classes.put("PointDefenseTurret", mindustry.world.blocks.defense.turrets.PointDefenseTurret.class); classes.put("PointDefenseTurret", mindustry.world.blocks.defense.turrets.PointDefenseTurret.class);
classes.put("PointDefenseBuild", mindustry.world.blocks.defense.turrets.PointDefenseTurret.PointDefenseBuild.class); classes.put("PointDefenseBuild", mindustry.world.blocks.defense.turrets.PointDefenseTurret.PointDefenseBuild.class);
classes.put("PowerTurret", mindustry.world.blocks.defense.turrets.PowerTurret.class); classes.put("PowerTurret", mindustry.world.blocks.defense.turrets.PowerTurret.class);

View File

@@ -142,6 +142,8 @@ public class Block extends UnlockableContent implements Senseable{
public boolean noUpdateDisabled = false; public boolean noUpdateDisabled = false;
/** if true, this block updates when it's a payload in a unit. */ /** if true, this block updates when it's a payload in a unit. */
public boolean updateInUnits = true; 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. */ /** Whether to use this block's color in the minimap. Only used for overlays. */
public boolean useColor = true; public boolean useColor = true;
/** item that drops from this block, used for drills */ /** item that drops from this block, used for drills */
@@ -827,6 +829,10 @@ public class Block extends UnlockableContent implements Senseable{
return buildType.get(); 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){ public Rect bounds(int x, int y, Rect rect){
return rect.setSize(size * tilesize).setCenter(x * tilesize + offset, y * tilesize + offset); 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); 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){ public ConsumeLiquid consumeLiquid(Liquid liquid, float amount){
return consume(new ConsumeLiquid(liquid, amount)); return consume(new ConsumeLiquid(liquid, amount));
} }
@@ -937,6 +950,10 @@ public class Block extends UnlockableContent implements Senseable{
return consume(new ConsumeItems(items)); return consume(new ConsumeItems(items));
} }
public ConsumeCoolant consumeCoolant(float amount){
return consume(new ConsumeCoolant(amount));
}
public <T extends Consume> T consume(T consume){ public <T extends Consume> T consume(T consume){
if(consume instanceof ConsumePower){ if(consume instanceof ConsumePower){
//there can only be one power consumer //there can only be one power consumer
@@ -1244,7 +1261,7 @@ public class Block extends UnlockableContent implements Senseable{
var gen = icons(); var gen = icons();
if(outlineIcon){ 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); Pixmap out = last = Pixmaps.outline(region, outlineColor, outlineRadius);
if(Core.settings.getBool("linear", true)){ if(Core.settings.getBool("linear", true)){
Pixmaps.bleed(out); Pixmaps.bleed(out);

View File

@@ -66,7 +66,7 @@ public class BaseShield extends Block{
public void init(){ public void init(){
super.init(); super.init();
clipSize = Math.max(clipSize, radius * 2f + 8f); updateClipRadius(radius);
} }
@Override @Override

View File

@@ -71,7 +71,7 @@ public class DirectionalForceProjector extends Block{
@Override @Override
public void init(){ public void init(){
clipSize = Math.max(clipSize, (width + 3f) * 2f); updateClipRadius((width + 3f));
super.init(); super.init();

View File

@@ -71,7 +71,7 @@ public class ForceProjector extends Block{
@Override @Override
public void init(){ public void init(){
clipSize = Math.max(clipSize, (radius + phaseRadiusBoost + 3f) * 2f); updateClipRadius(radius + phaseRadiusBoost + 3f);
super.init(); super.init();
} }

View File

@@ -18,12 +18,12 @@ import mindustry.world.meta.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
//TODO visuals! //TODO visuals!
public class PayloadTurret extends Turret{ public class PayloadAmmoTurret extends Turret{
public ObjectMap<UnlockableContent, BulletType> ammoTypes = new ObjectMap<>(); public ObjectMap<UnlockableContent, BulletType> ammoTypes = new ObjectMap<>();
protected UnlockableContent[] ammoKeys; protected UnlockableContent[] ammoKeys;
public PayloadTurret(String name){ public PayloadAmmoTurret(String name){
super(name); super(name);
maxAmmo = 3; maxAmmo = 3;

View File

@@ -65,7 +65,7 @@ public class TractorBeamTurret extends BaseTurret{
public void init(){ public void init(){
super.init(); super.init();
clipSize = Math.max(clipSize, (range + tilesize) * 2); updateClipRadius(range + tilesize);
} }
public class TractorBeamBuild extends BaseTurretBuild{ public class TractorBeamBuild extends BaseTurretBuild{

View File

@@ -45,7 +45,7 @@ public class DirectionBridge extends Block{
@Override @Override
public void init(){ public void init(){
clipSize = Math.max(clipSize, (range + 0.5f) * 2 * tilesize); updateClipRadius((range + 0.5f) * tilesize);
super.init(); super.init();
} }

View File

@@ -160,7 +160,7 @@ public class ItemBridge extends Block{
@Override @Override
public void init(){ public void init(){
super.init(); super.init();
clipSize = Math.max(clipSize, (range + 0.5f) * tilesize * 2); updateClipRadius((range + 0.5f) * tilesize);
} }
@Override @Override

View File

@@ -44,7 +44,7 @@ public class BuildPayload implements Payload{
@Override @Override
public void update(boolean inUnit){ 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.tile = emptyTile;
build.update(); build.update();

View File

@@ -71,7 +71,7 @@ public class PayloadMassDriver extends PayloadBlock{
@Override @Override
public void init(){ public void init(){
super.init(); super.init();
clipSize = Math.max(clipSize, range*2f + tilesize*size); updateClipRadius(range);
} }
@Override @Override

View File

@@ -52,7 +52,7 @@ public class BeamNode extends PowerBlock{
public void init(){ public void init(){
super.init(); super.init();
clipSize = Math.max(clipSize, tilesize*size + (range+1)*tilesize*2); updateClipRadius((range + 1) * tilesize);
} }
@Override @Override

View File

@@ -65,7 +65,7 @@ public class BeamDrill extends Block{
@Override @Override
public void init(){ public void init(){
clipSize = Math.max(clipSize, size * tilesize + (range + 2) * tilesize); updateClipRadius((range + 2) * tilesize);
super.init(); super.init();
} }

View File

@@ -82,7 +82,7 @@ public class RepairTurret extends Block{
} }
consumePowerCond(powerUse, (RepairPointBuild entity) -> entity.target != null); consumePowerCond(powerUse, (RepairPointBuild entity) -> entity.target != null);
clipSize = Math.max(clipSize, (repairRadius + tilesize) * 2); updateClipRadius(repairRadius);
super.init(); super.init();
} }

View File

@@ -119,7 +119,7 @@ public class UnitAssembler extends PayloadBlock{
@Override @Override
public void init(){ public void init(){
clipSize = Math.max(clipSize, (areaSize + size) * tilesize * 2); updateClipRadius(areaSize * tilesize);
consume(consPayload = new ConsumePayloadDynamic((UnitAssemblerBuild build) -> build.plan().requirements)); consume(consPayload = new ConsumePayloadDynamic((UnitAssemblerBuild build) -> build.plan().requirements));
super.init(); super.init();