Fixed #11320
This commit is contained in:
@@ -363,7 +363,7 @@ public class ContentPatcher{
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
if(value instanceof JsonValue jsv){ //setting values from object
|
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()){
|
if(UnlockableContent.class.isAssignableFrom(metadata.type) && jsv.isObject()){
|
||||||
warn("New content must not be instantiated: @", jsv);
|
warn("New content must not be instantiated: @", jsv);
|
||||||
return;
|
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
|
@CallSuper
|
||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void init(){
|
||||||
@@ -852,25 +874,7 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flowfieldPathType == -1){
|
initPathType();
|
||||||
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;
|
|
||||||
|
|
||||||
if(flying){
|
if(flying){
|
||||||
envEnabled |= Env.space;
|
envEnabled |= Env.space;
|
||||||
@@ -1232,6 +1236,12 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
public void afterPatch(){
|
public void afterPatch(){
|
||||||
super.afterPatch();
|
super.afterPatch();
|
||||||
totalRequirements = cachedRequirements = firstRequirements = null;
|
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 */
|
/** @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.entities.units.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.logic.*;
|
import mindustry.logic.*;
|
||||||
|
import mindustry.mod.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.liquid.Conduit.*;
|
import mindustry.world.blocks.liquid.Conduit.*;
|
||||||
@@ -43,6 +44,7 @@ public class GenericCrafter extends Block{
|
|||||||
public float updateEffectSpread = 4f;
|
public float updateEffectSpread = 4f;
|
||||||
public float warmupSpeed = 0.019f;
|
public float warmupSpeed = 0.019f;
|
||||||
/** Only used for legacy cultivator blocks. */
|
/** Only used for legacy cultivator blocks. */
|
||||||
|
@NoPatch
|
||||||
public boolean legacyReadWarmup = false;
|
public boolean legacyReadWarmup = false;
|
||||||
|
|
||||||
public DrawBlock drawer = new DrawDefault();
|
public DrawBlock drawer = new DrawDefault();
|
||||||
|
|||||||
@@ -165,6 +165,20 @@ public class PatcherTests{
|
|||||||
assertEquals(0, UnitTypes.dagger.abilities.size);
|
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
|
@Test
|
||||||
void testUnitFlagsArray() throws Exception{
|
void testUnitFlagsArray() throws Exception{
|
||||||
int oldLength = UnitTypes.dagger.targetFlags.length;
|
int oldLength = UnitTypes.dagger.targetFlags.length;
|
||||||
|
|||||||
Reference in New Issue
Block a user