Parse singular consumes (#8466)
* Parse singular `Consume`s * Proper coolant parsing * Temporary manual update of ClassMap Does not include all consume types. I don't know what gradle command to run to update `ClassMap`. I've tried `tools:updateScripts` but that just cleared everything.
This commit is contained in:
@@ -459,6 +459,8 @@ public class ClassMap{
|
|||||||
classes.put("DrawTurret", mindustry.world.draw.DrawTurret.class);
|
classes.put("DrawTurret", mindustry.world.draw.DrawTurret.class);
|
||||||
classes.put("DrawWarmupRegion", mindustry.world.draw.DrawWarmupRegion.class);
|
classes.put("DrawWarmupRegion", mindustry.world.draw.DrawWarmupRegion.class);
|
||||||
classes.put("DrawWeave", mindustry.world.draw.DrawWeave.class);
|
classes.put("DrawWeave", mindustry.world.draw.DrawWeave.class);
|
||||||
|
classes.put("ConsumeCoolant", mindustry.world.consumers.ConsumeCoolant.class);
|
||||||
|
classes.put("ConsumeLiquidFlammable", mindustry.world.consumers.ConsumeLiquidFlammable.class);
|
||||||
classes.put("Block", mindustry.world.Block.class);
|
classes.put("Block", mindustry.world.Block.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,6 +296,20 @@ public class ContentParser{
|
|||||||
weapon.name = currentMod.name + "-" + weapon.name;
|
weapon.name = currentMod.name + "-" + weapon.name;
|
||||||
return weapon;
|
return weapon;
|
||||||
});
|
});
|
||||||
|
put(Consume.class, (type, data) -> {
|
||||||
|
var oc = resolve(data.getString("type", ""), Consume.class);
|
||||||
|
data.remove("type");
|
||||||
|
var consume = make(oc);
|
||||||
|
readFields(consume, data);
|
||||||
|
return consume;
|
||||||
|
});
|
||||||
|
put(ConsumeLiquidBase.class, (type, data) -> {
|
||||||
|
var oc = resolve(data.getString("type", ""), ConsumeLiquidBase.class);
|
||||||
|
data.remove("type");
|
||||||
|
var consume = make(oc);
|
||||||
|
readFields(consume, data);
|
||||||
|
return consume;
|
||||||
|
});
|
||||||
}};
|
}};
|
||||||
/** Stores things that need to be parsed fully, e.g. reading fields of content.
|
/** Stores things that need to be parsed fully, e.g. reading fields of content.
|
||||||
* This is done to accommodate binding of content names first.*/
|
* This is done to accommodate binding of content names first.*/
|
||||||
|
|||||||
@@ -925,6 +925,10 @@ 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 boolean hasConsumer(Consume cons){
|
||||||
|
return consumeBuilder.contains(cons);
|
||||||
|
}
|
||||||
|
|
||||||
public void removeConsumer(Consume cons){
|
public void removeConsumer(Consume cons){
|
||||||
if(consumers.length > 0){
|
if(consumers.length > 0){
|
||||||
throw new IllegalStateException("You can only remove consumers before init(). After init(), all consumers have already been initialized.");
|
throw new IllegalStateException("You can only remove consumers before init(). After init(), all consumers have already been initialized.");
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ public class BaseTurret extends Block{
|
|||||||
coolant.update = false;
|
coolant.update = false;
|
||||||
coolant.booster = true;
|
coolant.booster = true;
|
||||||
coolant.optional = true;
|
coolant.optional = true;
|
||||||
|
|
||||||
|
//json parsing does not add to consumes
|
||||||
|
if(!hasConsumer(coolant)) consume(coolant);
|
||||||
}
|
}
|
||||||
|
|
||||||
placeOverlapRange = Math.max(placeOverlapRange, range + placeOverlapMargin);
|
placeOverlapRange = Math.max(placeOverlapRange, range + placeOverlapMargin);
|
||||||
|
|||||||
Reference in New Issue
Block a user