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

View File

@ -188,7 +188,7 @@ public class ErekirTechTree{
node(cliffCrusher, () -> {
node(siliconArcFurnace, () -> {
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(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.avert);
node(UnitTypes.locus);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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();

View File

@ -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();
}

View File

@ -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;

View File

@ -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{

View File

@ -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();
}

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -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

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();