Cleanup
@@ -93,6 +93,8 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
TypeSpec.Builder inter = TypeSpec.interfaceBuilder(interfaceName(component))
|
TypeSpec.Builder inter = TypeSpec.interfaceBuilder(interfaceName(component))
|
||||||
.addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class);
|
.addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class);
|
||||||
|
|
||||||
|
inter.addJavadoc("Interface for {@link $L}", component.fullName());
|
||||||
|
|
||||||
//implement extra interfaces these components may have, e.g. position
|
//implement extra interfaces these components may have, e.g. position
|
||||||
for(Stype extraInterface : component.interfaces().select(i -> !isCompInterface(i))){
|
for(Stype extraInterface : component.interfaces().select(i -> !isCompInterface(i))){
|
||||||
//javapoet completely chokes on this if I add `addSuperInterface` or create the type name with TypeName.get
|
//javapoet completely chokes on this if I add `addSuperInterface` or create the type name with TypeName.get
|
||||||
@@ -130,6 +132,7 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
if(!signatures.contains(cname + "()")){
|
if(!signatures.contains(cname + "()")){
|
||||||
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
|
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
|
||||||
.addAnnotations(Array.with(field.annotations()).select(a -> a.toString().contains("Null")).map(AnnotationSpec::get))
|
.addAnnotations(Array.with(field.annotations()).select(a -> a.toString().contains("Null")).map(AnnotationSpec::get))
|
||||||
|
.addJavadoc(field.doc() == null ? "" : field.doc())
|
||||||
.returns(field.tname()).build());
|
.returns(field.tname()).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +140,7 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
if(!field.is(Modifier.FINAL) && !signatures.contains(cname + "(" + field.mirror().toString() + ")") &&
|
if(!field.is(Modifier.FINAL) && !signatures.contains(cname + "(" + field.mirror().toString() + ")") &&
|
||||||
!field.annotations().contains(f -> f.toString().equals("@mindustry.annotations.Annotations.ReadOnly"))){
|
!field.annotations().contains(f -> f.toString().equals("@mindustry.annotations.Annotations.ReadOnly"))){
|
||||||
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
|
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
|
||||||
|
.addJavadoc(field.doc() == null ? "" : field.doc())
|
||||||
.addParameter(ParameterSpec.builder(field.tname(), field.name())
|
.addParameter(ParameterSpec.builder(field.tname(), field.name())
|
||||||
.addAnnotations(Array.with(field.annotations())
|
.addAnnotations(Array.with(field.annotations())
|
||||||
.select(a -> a.toString().contains("Null")).map(AnnotationSpec::get)).build()).build());
|
.select(a -> a.toString().contains("Null")).map(AnnotationSpec::get)).build()).build());
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ public class Selement<T extends Element>{
|
|||||||
this.e = e;
|
this.e = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String doc(){
|
||||||
|
return BaseProcessor.elementu.getDocComment(e);
|
||||||
|
}
|
||||||
|
|
||||||
public Array<Selement<?>> enclosed(){
|
public Array<Selement<?>> enclosed(){
|
||||||
return Array.with(e.getEnclosedElements()).map(Selement::new);
|
return Array.with(e.getEnclosedElements()).map(Selement::new);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
{version:1,fields:[{name:drownTime,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:level,type:int,size:4},{name:rotation,type:float,size:4},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{version:1,fields:[{name:baseRotation,type:float,size:4},{name:drownTime,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:level,type:int,size:4},{name:rotation,type:float,size:4},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{version:1,fields:[{name:drownTime,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:level,type:int,size:4},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:rotation,type:float,size:4},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{version:1,fields:[{name:drownTime,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:level,type:int,size:4},{name:rotation,type:float,size:4},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{version:1,fields:[{name:drownTime,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:level,type:int,size:4},{name:rotation,type:float,size:4},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
||||||
|
Before Width: | Height: | Size: 715 KiB After Width: | Height: | Size: 708 KiB |
|
Before Width: | Height: | Size: 279 KiB After Width: | Height: | Size: 128 KiB |
|
Before Width: | Height: | Size: 828 KiB After Width: | Height: | Size: 279 KiB |
|
Before Width: | Height: | Size: 252 KiB After Width: | Height: | Size: 226 KiB |
|
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 252 KiB |
|
Before Width: | Height: | Size: 226 KiB After Width: | Height: | Size: 828 KiB |
30
core/src/mindustry/entities/def/ShieldComp.java
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package mindustry.entities.def;
|
||||||
|
|
||||||
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
abstract class ShieldComp implements Healthc{
|
||||||
|
@Import float health, hitTime;
|
||||||
|
@Import boolean dead;
|
||||||
|
|
||||||
|
/** Absorbs health damage. */
|
||||||
|
float shield;
|
||||||
|
|
||||||
|
@Replace
|
||||||
|
@Override
|
||||||
|
public void damage(float amount){
|
||||||
|
hitTime = 1f;
|
||||||
|
|
||||||
|
float shieldDamage = Math.min(shield, amount);
|
||||||
|
shield -= shieldDamage;
|
||||||
|
amount -= shieldDamage;
|
||||||
|
|
||||||
|
if(amount > 0){
|
||||||
|
health -= amount;
|
||||||
|
if(health <= 0 && !dead){
|
||||||
|
kill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,8 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
|||||||
private UnitController controller;
|
private UnitController controller;
|
||||||
private UnitType type;
|
private UnitType type;
|
||||||
|
|
||||||
|
int level;
|
||||||
|
|
||||||
public void moveAt(Vec2 vector){
|
public void moveAt(Vec2 vector){
|
||||||
moveAt(vector, type.accel);
|
moveAt(vector, type.accel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -331,22 +331,25 @@ public class ContentParser{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void readBundle(ContentType type, String name, JsonValue value){
|
private void readBundle(ContentType type, String name, JsonValue value){
|
||||||
UnlockableContent cont = locate(type, name) instanceof UnlockableContent ?
|
UnlockableContent cont = locate(type, name) instanceof UnlockableContent ? locate(type, name) : null;
|
||||||
locate(type, name) : null;
|
|
||||||
|
|
||||||
String entryName = cont == null ? type + "." + currentMod.name + "-" + name + "." : type + "." + cont.name + ".";
|
String entryName = cont == null ? type + "." + currentMod.name + "-" + name + "." : type + "." + cont.name + ".";
|
||||||
I18NBundle bundle = Core.bundle;
|
I18NBundle bundle = Core.bundle;
|
||||||
while(bundle.getParent() != null) bundle = bundle.getParent();
|
while(bundle.getParent() != null) bundle = bundle.getParent();
|
||||||
|
|
||||||
if(value.has("name")){
|
if(value.has("name")){
|
||||||
bundle.getProperties().put(entryName + "name", value.getString("name"));
|
if(!Core.bundle.has(entryName + "name")){
|
||||||
if(cont != null) cont.localizedName = value.getString("name");
|
bundle.getProperties().put(entryName + "name", value.getString("name"));
|
||||||
|
if(cont != null) cont.localizedName = value.getString("name");
|
||||||
|
}
|
||||||
value.remove("name");
|
value.remove("name");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(value.has("description")){
|
if(value.has("description")){
|
||||||
bundle.getProperties().put(entryName + "description", value.getString("description"));
|
if(!Core.bundle.has(entryName + "description")){
|
||||||
if(cont != null) cont.description = value.getString("description");
|
bundle.getProperties().put(entryName + "description", value.getString("description"));
|
||||||
|
if(cont != null) cont.description = value.getString("description");
|
||||||
|
}
|
||||||
value.remove("description");
|
value.remove("description");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ public class ContentDisplay{
|
|||||||
inset.add().size(10f);
|
inset.add().size(10f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//map.get(stat).display(inset);
|
|
||||||
}).fillX().padLeft(10);
|
}).fillX().padLeft(10);
|
||||||
table.row();
|
table.row();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ public class CoreBlock extends StorageBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class CoreEntity extends TileEntity{
|
public class CoreEntity extends TileEntity{
|
||||||
// protected Playerc spawnPlayer;
|
|
||||||
protected float time, heat, progress;
|
protected float time, heat, progress;
|
||||||
protected int storageCapacity;
|
protected int storageCapacity;
|
||||||
protected boolean shouldBuild;
|
protected boolean shouldBuild;
|
||||||
|
|||||||
88
tools/src/mindustry/tools/Edgifier.java
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
package mindustry.tools;
|
||||||
|
|
||||||
|
import arc.files.*;
|
||||||
|
import arc.graphics.*;
|
||||||
|
import arc.struct.*;
|
||||||
|
import arc.util.*;
|
||||||
|
|
||||||
|
public class Edgifier{
|
||||||
|
|
||||||
|
public static void main(String[] args){
|
||||||
|
ArcNativesLoader.load();
|
||||||
|
|
||||||
|
Pixmap pixmap = new Pixmap(Fi.get("/home/anuke/Projects/Mindustry/core/assets-raw/sprites/units/reaper.png"));
|
||||||
|
|
||||||
|
Fi.get("/home/anuke/out.png").writePNG(edgify(pixmap, 5));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Pixmap edgify(Pixmap in, int chunk){
|
||||||
|
Pixmap out = new Pixmap(in.getWidth(), in.getHeight());
|
||||||
|
IntArray side1 = new IntArray(), side2 = new IntArray();
|
||||||
|
|
||||||
|
for(int x = 0; x < in.getWidth(); x += chunk){
|
||||||
|
for(int y = 0; y < in.getHeight(); y += chunk){
|
||||||
|
int bestErrors = Integer.MAX_VALUE;
|
||||||
|
int bestRotation = 0;
|
||||||
|
int bestSide1 = 0, bestSide2 = 0;
|
||||||
|
|
||||||
|
for(int rotation = 0; rotation < 8; rotation++){
|
||||||
|
side1.clear();
|
||||||
|
side2.clear();
|
||||||
|
|
||||||
|
//assign pixels present on each side
|
||||||
|
for(int cx = 0; cx < chunk; cx++){
|
||||||
|
for(int cy = 0; cy < chunk; cy++){
|
||||||
|
boolean side = classify(rotation, cx, cy, chunk);
|
||||||
|
|
||||||
|
int pixel = in.getPixel(x + cx, y + cy);
|
||||||
|
if(Pixmaps.empty(pixel)) pixel = 0; //all alpha=0 pixels are treated as 0
|
||||||
|
|
||||||
|
(side ? side1 : side2).add(pixel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//find most popular element here
|
||||||
|
int mode1 = side1.mode(), mode2 = side2.mode();
|
||||||
|
//total errors; 'incorrect' pixels
|
||||||
|
int errors = (side1.size - side1.count(mode1)) + (side2.size - side2.count(mode2));
|
||||||
|
|
||||||
|
//Log.info("errors for rotation={0}: {1}", rotation, errors);
|
||||||
|
|
||||||
|
//update if better
|
||||||
|
if(errors < bestErrors){
|
||||||
|
bestRotation = rotation;
|
||||||
|
bestSide1 = mode1;
|
||||||
|
bestSide2 = mode2;
|
||||||
|
bestErrors = errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Log.info("Best result for {0},{1}: rotation={2} 1={3} 2={4} errors={5}", x, y, bestRotation, bestSide1, bestSide2, bestErrors);
|
||||||
|
|
||||||
|
//draw with the best result
|
||||||
|
for(int cx = 0; cx < chunk; cx++){
|
||||||
|
for(int cy = 0; cy < chunk; cy++){
|
||||||
|
boolean side = classify(bestRotation, cx, cy, chunk);
|
||||||
|
out.draw(x + cx, y + cy, side ? bestSide1 : bestSide2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean classify(int rotation, int x, int y, int chunk){
|
||||||
|
switch(rotation){
|
||||||
|
case 0: //return y >= chunk / 2;
|
||||||
|
case 1: return y < x;
|
||||||
|
case 2: //return x <= chunk / 2;
|
||||||
|
case 3: return (chunk - 1 - y) < x;
|
||||||
|
case 4: //return (y > chunk / 2);
|
||||||
|
case 5: return (y <= x);
|
||||||
|
case 6: //return (x < chunk / 2);
|
||||||
|
case 7: return ((chunk - 1 - y) <= x);
|
||||||
|
default: throw new IllegalArgumentException("Invalid rotation: " + rotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -228,7 +228,7 @@ public class Generators{
|
|||||||
|
|
||||||
Image baseCell = ImagePacker.get(type.cellRegion);
|
Image baseCell = ImagePacker.get(type.cellRegion);
|
||||||
Image cell = new Image(type.cellRegion.getWidth(), type.cellRegion.getHeight());
|
Image cell = new Image(type.cellRegion.getWidth(), type.cellRegion.getHeight());
|
||||||
cell.each((x, y) -> cell.draw(x, y, baseCell.getColor(x, y).mul(Color.gray)));
|
cell.each((x, y) -> cell.draw(x, y, baseCell.getColor(x, y).mul(Color.valueOf("ffa665"))));
|
||||||
|
|
||||||
image.draw(cell, image.width/2 - cell.width/2, image.height/2 - cell.height/2);
|
image.draw(cell, image.width/2 - cell.width/2, image.height/2 - cell.height/2);
|
||||||
|
|
||||||
|
|||||||