1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-17 11:27:35 +03:00
This commit is contained in:
Anuken 2020-04-26 21:59:49 -04:00
parent 1941b0fa8a
commit f6bf229b0a
21 changed files with 2997 additions and 2877 deletions

View File

@ -93,6 +93,8 @@ public class EntityProcess extends BaseProcessor{
TypeSpec.Builder inter = TypeSpec.interfaceBuilder(interfaceName(component))
.addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class);
inter.addJavadoc("Interface for {@link $L}", component.fullName());
//implement extra interfaces these components may have, e.g. position
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
@ -130,6 +132,7 @@ public class EntityProcess extends BaseProcessor{
if(!signatures.contains(cname + "()")){
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
.addAnnotations(Array.with(field.annotations()).select(a -> a.toString().contains("Null")).map(AnnotationSpec::get))
.addJavadoc(field.doc() == null ? "" : field.doc())
.returns(field.tname()).build());
}
@ -137,6 +140,7 @@ public class EntityProcess extends BaseProcessor{
if(!field.is(Modifier.FINAL) && !signatures.contains(cname + "(" + field.mirror().toString() + ")") &&
!field.annotations().contains(f -> f.toString().equals("@mindustry.annotations.Annotations.ReadOnly"))){
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
.addJavadoc(field.doc() == null ? "" : field.doc())
.addParameter(ParameterSpec.builder(field.tname(), field.name())
.addAnnotations(Array.with(field.annotations())
.select(a -> a.toString().contains("Null")).map(AnnotationSpec::get)).build()).build());

View File

@ -18,6 +18,10 @@ public class Selement<T extends Element>{
this.e = e;
}
public String doc(){
return BaseProcessor.elementu.getDocComment(e);
}
public Array<Selement<?>> enclosed(){
return Array.with(e.getEnclosedElements()).map(Selement::new);
}

View File

@ -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}]}

View File

@ -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}]}

View File

@ -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}]}

View File

@ -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}]}

View File

@ -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}]}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 715 KiB

After

Width:  |  Height:  |  Size: 708 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 KiB

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 828 KiB

After

Width:  |  Height:  |  Size: 279 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 KiB

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 252 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 KiB

After

Width:  |  Height:  |  Size: 828 KiB

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

View File

@ -24,6 +24,8 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
private UnitController controller;
private UnitType type;
int level;
public void moveAt(Vec2 vector){
moveAt(vector, type.accel);
}

View File

@ -331,22 +331,25 @@ public class ContentParser{
}
private void readBundle(ContentType type, String name, JsonValue value){
UnlockableContent cont = locate(type, name) instanceof UnlockableContent ?
locate(type, name) : null;
UnlockableContent cont = locate(type, name) instanceof UnlockableContent ? locate(type, name) : null;
String entryName = cont == null ? type + "." + currentMod.name + "-" + name + "." : type + "." + cont.name + ".";
I18NBundle bundle = Core.bundle;
while(bundle.getParent() != null) bundle = bundle.getParent();
if(value.has("name")){
bundle.getProperties().put(entryName + "name", value.getString("name"));
if(cont != null) cont.localizedName = value.getString("name");
if(!Core.bundle.has(entryName + "name")){
bundle.getProperties().put(entryName + "name", value.getString("name"));
if(cont != null) cont.localizedName = value.getString("name");
}
value.remove("name");
}
if(value.has("description")){
bundle.getProperties().put(entryName + "description", value.getString("description"));
if(cont != null) cont.description = value.getString("description");
if(!Core.bundle.has(entryName + "description")){
bundle.getProperties().put(entryName + "description", value.getString("description"));
if(cont != null) cont.description = value.getString("description");
}
value.remove("description");
}
}

View File

@ -55,7 +55,6 @@ public class ContentDisplay{
inset.add().size(10f);
}
//map.get(stat).display(inset);
}).fillX().padLeft(10);
table.row();
}

View File

@ -67,7 +67,6 @@ public class CoreBlock extends StorageBlock{
}
public class CoreEntity extends TileEntity{
// protected Playerc spawnPlayer;
protected float time, heat, progress;
protected int storageCapacity;
protected boolean shouldBuild;

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

View File

@ -228,7 +228,7 @@ public class Generators{
Image baseCell = ImagePacker.get(type.cellRegion);
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);