Basic unitsorts for hjson (#6280)

* Create some basic unitSorts

* Set as defaults

* add to ContentParser
This commit is contained in:
Matthew Peng
2021-10-31 18:30:35 -07:00
committed by GitHub
parent e1bf1a1b92
commit 223fb8d6f5
4 changed files with 22 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ import arc.math.*;
import arc.struct.*; import arc.struct.*;
import mindustry.*; import mindustry.*;
import mindustry.ctype.*; import mindustry.ctype.*;
import mindustry.entities.*;
import mindustry.entities.bullet.*; import mindustry.entities.bullet.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
@@ -1839,7 +1840,7 @@ public class Blocks implements ContentList{
size = 4; size = 4;
shootCone = 2f; shootCone = 2f;
shootSound = Sounds.railgun; shootSound = Sounds.railgun;
unitSort = (u, x, y) -> -u.maxHealth + Mathf.dst2(u.x, u.y, x, y) / 6400f; unitSort = UnitSorts.strongest;
coolantMultiplier = 0.4f; coolantMultiplier = 0.4f;

View 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;
}

View File

@@ -20,6 +20,7 @@ import mindustry.content.*;
import mindustry.content.TechTree.*; import mindustry.content.TechTree.*;
import mindustry.ctype.*; import mindustry.ctype.*;
import mindustry.entities.*; import mindustry.entities.*;
import mindustry.entities.Units.*;
import mindustry.entities.abilities.*; import mindustry.entities.abilities.*;
import mindustry.entities.bullet.*; import mindustry.entities.bullet.*;
import mindustry.entities.effect.*; import mindustry.entities.effect.*;
@@ -61,6 +62,7 @@ public class ContentParser{
readFields(result, data); readFields(result, data);
return result; return result;
}); });
put(Sortf.class, (type, data) -> field(UnitSorts.class, data));
put(Interp.class, (type, data) -> field(Interp.class, data)); put(Interp.class, (type, data) -> field(Interp.class, data));
put(CacheLayer.class, (type, data) -> field(CacheLayer.class, data)); put(CacheLayer.class, (type, data) -> field(CacheLayer.class, data));
put(Attribute.class, (type, data) -> Attribute.get(data.asString())); put(Attribute.class, (type, data) -> Attribute.get(data.asString()));

View File

@@ -76,7 +76,7 @@ public class Turret extends ReloadTurret{
public Effect chargeBeginEffect = Fx.none; public Effect chargeBeginEffect = Fx.none;
public Sound chargeSound = Sounds.none; public Sound chargeSound = Sounds.none;
public Sortf unitSort = Unit::dst2; public Sortf unitSort = UnitSorts.closest;
protected Vec2 tr = new Vec2(); protected Vec2 tr = new Vec2();
protected Vec2 tr2 = new Vec2(); protected Vec2 tr2 = new Vec2();