mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-03-09 08:20:55 -07:00
Fixed #11320
This commit is contained in:
parent
ecd10623fe
commit
04bc7b1f22
4 changed files with 46 additions and 20 deletions
|
|
@ -363,7 +363,7 @@ public class ContentPatcher{
|
|||
|
||||
try{
|
||||
if(value instanceof JsonValue jsv){ //setting values from object
|
||||
if(prevValue == null || !jsv.isObject() || jsv.has("type") || (metadata != null && metadata.type == Attributes.class)){
|
||||
if(prevValue == null || !jsv.isObject() || (jsv.has("type") && metadata.type != MappableContent.class) || (metadata != null && metadata.type == Attributes.class)){
|
||||
if(UnlockableContent.class.isAssignableFrom(metadata.type) && jsv.isObject()){
|
||||
warn("New content must not be instantiated: @", jsv);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -829,6 +829,28 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||
}
|
||||
}
|
||||
|
||||
void initPathType(){
|
||||
if(flowfieldPathType == -1){
|
||||
flowfieldPathType =
|
||||
naval ? Pathfinder.costNaval :
|
||||
allowLegStep ? Pathfinder.costLegs :
|
||||
flying ? Pathfinder.costNone :
|
||||
hovering ? Pathfinder.costHover :
|
||||
Pathfinder.costGround;
|
||||
}
|
||||
|
||||
if(pathCost == null){
|
||||
pathCost =
|
||||
naval ? ControlPathfinder.costNaval :
|
||||
allowLegStep ? ControlPathfinder.costLegs :
|
||||
hovering ? ControlPathfinder.costHover :
|
||||
ControlPathfinder.costGround;
|
||||
}
|
||||
|
||||
pathCostId = ControlPathfinder.costTypes.indexOf(pathCost);
|
||||
if(pathCostId == -1) pathCostId = 0;
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
public void init(){
|
||||
|
|
@ -852,25 +874,7 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||
}
|
||||
}
|
||||
|
||||
if(flowfieldPathType == -1){
|
||||
flowfieldPathType =
|
||||
naval ? Pathfinder.costNaval :
|
||||
allowLegStep ? Pathfinder.costLegs :
|
||||
flying ? Pathfinder.costNone :
|
||||
hovering ? Pathfinder.costHover :
|
||||
Pathfinder.costGround;
|
||||
}
|
||||
|
||||
if(pathCost == null){
|
||||
pathCost =
|
||||
naval ? ControlPathfinder.costNaval :
|
||||
allowLegStep ? ControlPathfinder.costLegs :
|
||||
hovering ? ControlPathfinder.costHover :
|
||||
ControlPathfinder.costGround;
|
||||
}
|
||||
|
||||
pathCostId = ControlPathfinder.costTypes.indexOf(pathCost);
|
||||
if(pathCostId == -1) pathCostId = 0;
|
||||
initPathType();
|
||||
|
||||
if(flying){
|
||||
envEnabled |= Env.space;
|
||||
|
|
@ -1232,6 +1236,12 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||
public void afterPatch(){
|
||||
super.afterPatch();
|
||||
totalRequirements = cachedRequirements = firstRequirements = null;
|
||||
|
||||
//this will technically reset any assigned values, but in vanilla, they're not reassigned anyway
|
||||
flowfieldPathType = -1;
|
||||
pathCost = null;
|
||||
pathCostId = -1;
|
||||
initPathType();
|
||||
}
|
||||
|
||||
/** @return the time required to build this unit, as a value that takes into account reconstructors */
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import mindustry.entities.*;
|
|||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.mod.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.liquid.Conduit.*;
|
||||
|
|
@ -43,6 +44,7 @@ public class GenericCrafter extends Block{
|
|||
public float updateEffectSpread = 4f;
|
||||
public float warmupSpeed = 0.019f;
|
||||
/** Only used for legacy cultivator blocks. */
|
||||
@NoPatch
|
||||
public boolean legacyReadWarmup = false;
|
||||
|
||||
public DrawBlock drawer = new DrawDefault();
|
||||
|
|
|
|||
|
|
@ -165,6 +165,20 @@ public class PatcherTests{
|
|||
assertEquals(0, UnitTypes.dagger.abilities.size);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnitTypeObject() throws Exception{
|
||||
Vars.state.patcher.apply(Seq.with("""
|
||||
{
|
||||
"name": "object syntax",
|
||||
"unit.dagger": {
|
||||
"type": "legs"
|
||||
}
|
||||
}
|
||||
"""));
|
||||
|
||||
assertEquals(new Seq<>(), Vars.state.patcher.patches.first().warnings);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnitFlagsArray() throws Exception{
|
||||
int oldLength = UnitTypes.dagger.targetFlags.length;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue