Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features
Conflicts: core/src/mindustry/type/UnitType.java gradle.properties
This commit is contained in:
@@ -461,11 +461,12 @@ public class Damage{
|
||||
}
|
||||
|
||||
private static void completeDamage(Team team, float x, float y, float radius, float damage){
|
||||
|
||||
int trad = (int)(radius / tilesize);
|
||||
for(int dx = -trad; dx <= trad; dx++){
|
||||
for(int dy = -trad; dy <= trad; dy++){
|
||||
Tile tile = world.tile(Math.round(x / tilesize) + dx, Math.round(y / tilesize) + dy);
|
||||
if(tile != null && tile.build != null && (team == null ||team.isEnemy(tile.team())) && dx*dx + dy*dy <= trad){
|
||||
if(tile != null && tile.build != null && (team == null ||team.isEnemy(tile.team())) && dx*dx + dy*dy <= trad*trad){
|
||||
tile.build.damage(team, damage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,5 @@ class GroupDefs<G>{
|
||||
@GroupDef(value = Firec.class) G fire;
|
||||
@GroupDef(value = Puddlec.class) G puddle;
|
||||
@GroupDef(value = WeatherStatec.class) G weather;
|
||||
@GroupDef(value = WorldLabelc.class, mapping = true) G label;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -81,6 +81,12 @@ public class Units{
|
||||
return Math.max(0, state.rules.unitCapVariable ? state.rules.unitCap + team.data().unitCap : state.rules.unitCap);
|
||||
}
|
||||
|
||||
/** @return unit cap as a string, substituting the infinity symbol instead of MAX_VALUE */
|
||||
public static String getStringCap(Team team){
|
||||
int cap = getCap(team);
|
||||
return cap >= Integer.MAX_VALUE - 1 ? "∞" : cap + "";
|
||||
}
|
||||
|
||||
/** @return whether this player can interact with a specific tile. if either of these are null, returns true.*/
|
||||
public static boolean canInteract(Player player, Building tile){
|
||||
return player == null || tile == null || tile.interactable(player.team());
|
||||
|
||||
@@ -61,6 +61,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
transient boolean updateFlow;
|
||||
transient byte cdump;
|
||||
transient int rotation;
|
||||
transient float payloadRotation;
|
||||
transient boolean enabled = true;
|
||||
transient float enabledControlTime;
|
||||
transient String lastAccessed;
|
||||
@@ -1293,16 +1294,18 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Called right before this building is picked up. */
|
||||
public void pickedUp(){
|
||||
|
||||
}
|
||||
|
||||
/** Called right after this building is picked up. */
|
||||
public void afterPickedUp(){
|
||||
if(power != null){
|
||||
if(power.graph != null){
|
||||
power.graph.removeList(self());
|
||||
power.graph = new PowerGraph();
|
||||
}
|
||||
power.graph = new PowerGraph();
|
||||
power.links.clear();
|
||||
power.status = 0f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void removeFromProximity(){
|
||||
|
||||
@@ -93,6 +93,7 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc, Unitc{
|
||||
void pickup(Building tile){
|
||||
tile.pickedUp();
|
||||
tile.tile.remove();
|
||||
tile.afterPickedUp();
|
||||
addPayload(new BuildPayload(tile));
|
||||
Fx.unitPickup.at(tile);
|
||||
Events.fire(new PickupEvent(self(), tile));
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package mindustry.entities.comp;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
/** Component/entity for labels in world space. Useful for servers. Does not save in files - create only on world load. */
|
||||
@EntityDef(value = {WorldLabelc.class}, serialize = false)
|
||||
@Component(base = true)
|
||||
public abstract class WorldLabelComp implements Posc, Drawc, Syncc{
|
||||
@Import int id;
|
||||
@Import float x, y;
|
||||
|
||||
public static final byte flagBackground = 1, flagOutline = 2;
|
||||
|
||||
public String text = "sample text";
|
||||
public float fontSize = 1f, z = Layer.playerName + 1;
|
||||
/** Flags are packed into a byte for sync efficiency; see the flag static values. */
|
||||
public byte flags = flagBackground | flagOutline;
|
||||
|
||||
@Replace
|
||||
public float clipSize(){
|
||||
return text.length() * 10f * fontSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.z(z);
|
||||
float z = Drawf.text();
|
||||
|
||||
Font font = (flags & flagOutline) != 0 ? Fonts.outline : Fonts.def;
|
||||
GlyphLayout layout = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
|
||||
|
||||
boolean ints = font.usesIntegerPositions();
|
||||
font.setUseIntegerPositions(false);
|
||||
font.getData().setScale(0.25f / Scl.scl(1f) * fontSize);
|
||||
layout.setText(font, text);
|
||||
|
||||
if((flags & flagBackground) != 0){
|
||||
Draw.color(0f, 0f, 0f, 0.3f);
|
||||
Fill.rect(x, y - layout.height / 2, layout.width + 2, layout.height + 3);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
font.setColor(Color.white);
|
||||
font.draw(text, x, y, 0, Align.center, false);
|
||||
|
||||
Draw.reset();
|
||||
Pools.free(layout);
|
||||
font.getData().setScale(1f);
|
||||
font.setColor(Color.white);
|
||||
font.setUseIntegerPositions(ints);
|
||||
|
||||
Draw.z(z);
|
||||
}
|
||||
|
||||
/** This MUST be called instead of remove()! */
|
||||
public void hide(){
|
||||
remove();
|
||||
Call.removeWorldLabel(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user