mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-06 02:40:23 -08:00
More disallowed patcher fields / Continuous liquid turret minimum ammo amount firing threshold
This commit is contained in:
parent
a305ac31e6
commit
472cacbb3b
4 changed files with 38 additions and 1 deletions
|
|
@ -62,8 +62,10 @@ public abstract class UnlockableContent extends MappableContent{
|
|||
* */
|
||||
public ObjectSet<UnlockableContent> databaseTabs = new ObjectSet<>();
|
||||
/** The tech tree node for this content, if applicable. Null if not part of a tech tree. */
|
||||
@NoPatch
|
||||
public @Nullable TechNode techNode;
|
||||
/** Tech nodes for all trees that this content is part of. */
|
||||
@NoPatch
|
||||
public Seq<TechNode> techNodes = new Seq<>();
|
||||
/** Unlock state. Loaded from settings. Do not modify outside the constructor. */
|
||||
@NoPatch
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import mindustry.gen.*;
|
|||
import mindustry.graphics.*;
|
||||
import mindustry.graphics.MultiPacker.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.mod.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
|
@ -205,6 +206,7 @@ public class Block extends UnlockableContent implements Senseable{
|
|||
/** whether this block can be placed on edges of liquids. */
|
||||
public boolean floating = false;
|
||||
/** multiblock size */
|
||||
@NoPatch //changing size often leads to catastrophic issues, so don't allow that
|
||||
public int size = 1;
|
||||
/** multiblock offset */
|
||||
public float offset = 0f;
|
||||
|
|
@ -372,21 +374,29 @@ public class Block extends UnlockableContent implements Senseable{
|
|||
/** Scroll position for certain blocks. */
|
||||
public float selectScroll;
|
||||
/** Building that is created for this block. Initialized in init() via reflection. Set manually if modded. */
|
||||
@NoPatch
|
||||
public Prov<Building> buildType = null;
|
||||
/** Configuration handlers by type. */
|
||||
@NoPatch
|
||||
public ObjectMap<Class<?>, Cons2> configurations = new ObjectMap<>();
|
||||
/** Consumption filters. */
|
||||
@NoPatch
|
||||
public boolean[] itemFilter = {}, liquidFilter = {};
|
||||
/** Array of consumers used by this block. Only populated after init(). */
|
||||
@NoPatch
|
||||
public Consume[] consumers = {}, optionalConsumers = {}, nonOptionalConsumers = {}, updateConsumers = {};
|
||||
/** Set to true if this block has any consumers in its array. */
|
||||
@NoPatch
|
||||
public boolean hasConsumers;
|
||||
/** The single power consumer, if applicable. */
|
||||
@NoPatch
|
||||
public @Nullable ConsumePower consPower;
|
||||
|
||||
/** Map of bars by name. */
|
||||
@NoPatch
|
||||
protected OrderedMap<String, Func<Building, Bar>> barMap = new OrderedMap<>();
|
||||
/** List for building up consumption before init(). */
|
||||
@NoPatch
|
||||
protected Seq<Consume> consumeBuilder = new Seq<>();
|
||||
|
||||
protected TextureRegion[] generatedIcons;
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ public class ContinuousLiquidTurret extends ContinuousTurret{
|
|||
}
|
||||
|
||||
public class ContinuousLiquidTurretBuild extends ContinuousTurretBuild{
|
||||
boolean activated;
|
||||
|
||||
@Override
|
||||
public boolean shouldActiveSound(){
|
||||
|
|
@ -71,6 +72,13 @@ public class ContinuousLiquidTurret extends ContinuousTurret{
|
|||
super.updateTile();
|
||||
|
||||
unit.ammo(unit.type().ammoCapacity * liquids.currentAmount() / liquidCapacity);
|
||||
|
||||
//only allow the turret to begin firing when it can fire for 4 continuous updates
|
||||
if(liquids.currentAmount() >= liquidConsumed * 4f){
|
||||
activated = true;
|
||||
}else if(liquids.currentAmount() < liquidConsumed){
|
||||
activated = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -86,6 +94,11 @@ public class ContinuousLiquidTurret extends ContinuousTurret{
|
|||
return hasCorrectAmmo() && super.canConsume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldConsume(){
|
||||
return super.shouldConsume() && activated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BulletType useAmmo(){
|
||||
//does not consume ammo upon firing
|
||||
|
|
@ -99,7 +112,7 @@ public class ContinuousLiquidTurret extends ContinuousTurret{
|
|||
|
||||
@Override
|
||||
public boolean hasAmmo(){
|
||||
return hasCorrectAmmo() && ammoTypes.get(liquids.current()) != null && liquids.currentAmount() > 0f;
|
||||
return hasCorrectAmmo() && ammoTypes.get(liquids.current()) != null && liquids.currentAmount() > 0f && activated;
|
||||
}
|
||||
|
||||
public boolean hasCorrectAmmo(){
|
||||
|
|
|
|||
|
|
@ -197,11 +197,22 @@ public class PatcherTests{
|
|||
assertEquals(oldLength, UnitTypes.dagger.targetFlags.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCannotPatch() throws Exception{
|
||||
Vars.state.patcher.apply(Seq.with("""
|
||||
block.conveyor.size: 2
|
||||
"""));
|
||||
|
||||
assertEquals(1, Vars.state.patcher.patches.first().warnings.size);
|
||||
assertEquals(1, Blocks.conveyor.size);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBigPatch() throws Exception{
|
||||
Vars.state.patcher.apply(Seq.with("""
|
||||
item: {
|
||||
fissile-matter: {
|
||||
localizedName: Duo
|
||||
hidden: false
|
||||
fullIcon: duo-preview
|
||||
uiIcon: block-duo-ui
|
||||
|
|
@ -209,6 +220,7 @@ public class PatcherTests{
|
|||
}
|
||||
block: {
|
||||
pulverizer: {
|
||||
localizedName: Duo Factory
|
||||
consumes: {
|
||||
remove: all
|
||||
item: copper
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue