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