Basic unitsorts for hjson (#6280)
* Create some basic unitSorts * Set as defaults * add to ContentParser
This commit is contained in:
@@ -5,6 +5,7 @@ import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
@@ -1839,7 +1840,7 @@ public class Blocks implements ContentList{
|
||||
size = 4;
|
||||
shootCone = 2f;
|
||||
shootSound = Sounds.railgun;
|
||||
unitSort = (u, x, y) -> -u.maxHealth + Mathf.dst2(u.x, u.y, x, y) / 6400f;
|
||||
unitSort = UnitSorts.strongest;
|
||||
|
||||
coolantMultiplier = 0.4f;
|
||||
|
||||
@@ -2287,4 +2288,4 @@ public class Blocks implements ContentList{
|
||||
|
||||
//endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
14
core/src/mindustry/entities/UnitSorts.java
Normal file
14
core/src/mindustry/entities/UnitSorts.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package mindustry.entities;
|
||||
|
||||
import arc.math.*;
|
||||
import mindustry.entities.Units.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class UnitSorts{
|
||||
public static Sortf
|
||||
|
||||
closest = Unit::dst2,
|
||||
farthest = (u, x, y) -> -u.dst2(x, y),
|
||||
strongest = (u, x, y) -> -u.maxHealth + Mathf.dst2(u.x, u.y, x, y) / 6400f,
|
||||
weakest = (u, x, y) -> u.maxHealth + Mathf.dst2(u.x, u.y, x, y) / 6400f;
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import mindustry.content.*;
|
||||
import mindustry.content.TechTree.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.Units.*;
|
||||
import mindustry.entities.abilities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.entities.effect.*;
|
||||
@@ -61,6 +62,7 @@ public class ContentParser{
|
||||
readFields(result, data);
|
||||
return result;
|
||||
});
|
||||
put(Sortf.class, (type, data) -> field(UnitSorts.class, data));
|
||||
put(Interp.class, (type, data) -> field(Interp.class, data));
|
||||
put(CacheLayer.class, (type, data) -> field(CacheLayer.class, data));
|
||||
put(Attribute.class, (type, data) -> Attribute.get(data.asString()));
|
||||
@@ -826,4 +828,4 @@ public class ContentParser{
|
||||
void parsed(Class<?> type, JsonValue jsonData, Object result);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class Turret extends ReloadTurret{
|
||||
public Effect chargeBeginEffect = Fx.none;
|
||||
public Sound chargeSound = Sounds.none;
|
||||
|
||||
public Sortf unitSort = Unit::dst2;
|
||||
public Sortf unitSort = UnitSorts.closest;
|
||||
|
||||
protected Vec2 tr = new Vec2();
|
||||
protected Vec2 tr2 = new Vec2();
|
||||
@@ -508,4 +508,4 @@ public class Turret extends ReloadTurret{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user