diff --git a/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java b/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java index 81fdd12208..4b146c2cb3 100644 --- a/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java +++ b/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java @@ -118,6 +118,7 @@ public class EntityProcess extends BaseProcessor{ signatures.add(method.e.toString()); inter.addMethod(MethodSpec.methodBuilder(method.name()) + .addJavadoc(method.doc() == null ? "" : method.doc()) .addExceptions(method.thrownt()) .addTypeVariables(method.typeVariables().map(TypeVariableName::get)) .returns(method.ret().toString().equals("void") ? TypeName.VOID : method.retn()) @@ -165,18 +166,6 @@ public class EntityProcess extends BaseProcessor{ Log.debug(""); } - /* - //generate special render layer interfaces - for(DrawLayer layer : DrawLayer.values()){ - //create the DrawLayer interface that entities need to implement - String name = "DrawLayer" + Strings.capitalize(layer.name()) + "c"; - TypeSpec.Builder inter = TypeSpec.interfaceBuilder(name) - .addSuperinterface(tname(packageName + ".Entityc")) - .addSuperinterface(tname(packageName + ".Drawc")) - .addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class); - inter.addMethod(MethodSpec.methodBuilder("draw" + Strings.capitalize(layer.name())).addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT).build()); - write(inter); - }*/ }else if(round == 2){ //round 2: get component classes and generate interfaces for them //parse groups @@ -187,17 +176,6 @@ public class EntityProcess extends BaseProcessor{ groupDefs.add(new GroupDefinition(group.name(), ClassName.bestGuess(packageName + "." + interfaceName(types.first())), types, an.spatial(), an.mapping(), collides)); } - /* - //add special generated groups - for(DrawLayer layer : DrawLayer.values()){ - String name = "DrawLayer" + Strings.capitalize(layer.name()) + "c"; - //create group definition with no components directly - GroupDefinition def = new GroupDefinition(layer.name(), ClassName.bestGuess(packageName + "." + name), Array.with(), false, false, new Array<>(0)); - //add manual inclusions of entities to be added to this group - def.manualInclusions.addAll(allDefs.select(s -> allComponents(s).contains(comp -> comp.interfaces().contains(in -> in.name().equals(name))))); - groupDefs.add(def); - }*/ - ObjectMap usedNames = new ObjectMap<>(); ObjectMap> extraNames = new ObjectMap<>(); @@ -424,7 +402,6 @@ public class EntityProcess extends BaseProcessor{ TypeSpec.Builder groupsBuilder = TypeSpec.classBuilder("Groups").addModifiers(Modifier.PUBLIC); MethodSpec.Builder groupInit = MethodSpec.methodBuilder("init").addModifiers(Modifier.PUBLIC, Modifier.STATIC); for(GroupDefinition group : groupDefs){ - //Stype ctype = group.components.first(); //class names for interface/group ClassName itype = group.baseType; ClassName groupc = ClassName.bestGuess("mindustry.entities.EntityGroup"); @@ -463,14 +440,6 @@ public class EntityProcess extends BaseProcessor{ } } - /* - for(DrawLayer layer : DrawLayer.values()){ - MethodSpec.Builder groupDraw = MethodSpec.methodBuilder("draw" + Strings.capitalize(layer.name())) - .addModifiers(Modifier.PUBLIC, Modifier.STATIC); - groupDraw.addStatement("$L.draw($L::$L)", layer.name(), "DrawLayer" + Strings.capitalize(layer.name()) + "c", "draw" + Strings.capitalize(layer.name())); - groupsBuilder.addMethod(groupDraw.build()); - }*/ - groupsBuilder.addMethod(groupResize.build()); groupsBuilder.addMethod(groupUpdate.build()); diff --git a/annotations/src/main/java/mindustry/annotations/util/Selement.java b/annotations/src/main/java/mindustry/annotations/util/Selement.java index 3916fe3fd9..0bd4b81ed5 100644 --- a/annotations/src/main/java/mindustry/annotations/util/Selement.java +++ b/annotations/src/main/java/mindustry/annotations/util/Selement.java @@ -1,6 +1,7 @@ package mindustry.annotations.util; import arc.struct.Array; +import arc.util.ArcAnnotate.*; import com.squareup.javapoet.*; import com.sun.tools.javac.code.Attribute.*; import mindustry.annotations.*; @@ -18,7 +19,7 @@ public class Selement{ this.e = e; } - public String doc(){ + public @Nullable String doc(){ return BaseProcessor.elementu.getDocComment(e); } diff --git a/annotations/src/main/resources/classids.properties b/annotations/src/main/resources/classids.properties index 676138b813..df634a82aa 100644 --- a/annotations/src/main/resources/classids.properties +++ b/annotations/src/main/resources/classids.properties @@ -1,18 +1,15 @@ #Maps entity names to IDs. Autogenerated. dagger=0 -draug=10 -mindustry.entities.def.BulletComp=1 -mindustry.entities.def.DecalComp=2 -mindustry.entities.def.EffectComp=15 -mindustry.entities.def.FireComp=3 -mindustry.entities.def.GroundEffectComp=4 -mindustry.entities.def.PlayerComp=5 -mindustry.entities.def.PuddleComp=6 -mindustry.entities.def.StandardEffectComp=7 +draug=1 +mindustry.entities.def.BulletComp=2 +mindustry.entities.def.DecalComp=3 +mindustry.entities.def.EffectComp=4 +mindustry.entities.def.FireComp=5 +mindustry.entities.def.PlayerComp=6 +mindustry.entities.def.PuddleComp=7 mindustry.entities.def.TileComp=8 -mindustry.type.Weather.WeatherComp=13 -phantom=11 -spirit=12 -vanguard=9 -wraith=14 \ No newline at end of file +mindustry.type.Weather.WeatherComp=9 +phantom=10 +vanguard=11 +wraith=12 \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderUnitEntity/0.json b/annotations/src/main/resources/revisions/BuilderUnitEntity/0.json index a3e717b9b7..010ca755c5 100644 --- a/annotations/src/main/resources/revisions/BuilderUnitEntity/0.json +++ b/annotations/src/main/resources/revisions/BuilderUnitEntity/0.json @@ -1 +1 @@ -{fields:[{name:drownTime,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,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}]} \ No newline at end of file +{fields:[{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:rotation,type:float,size:4},{name:shield,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}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/BuilderUnitEntity/1.json b/annotations/src/main/resources/revisions/BuilderUnitEntity/1.json deleted file mode 100644 index 66f7e0ee4a..0000000000 --- a/annotations/src/main/resources/revisions/BuilderUnitEntity/1.json +++ /dev/null @@ -1 +0,0 @@ -{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}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/GroundEffectEntity/0.json b/annotations/src/main/resources/revisions/GroundEffectEntity/0.json deleted file mode 100644 index 4e23d76400..0000000000 --- a/annotations/src/main/resources/revisions/GroundEffectEntity/0.json +++ /dev/null @@ -1 +0,0 @@ -{fields:[{name:color,type:arc.graphics.Color,size:-1},{name:data,type:java.lang.Object,size:-1},{name:lifetime,type:float,size:4},{name:offsetX,type:float,size:4},{name:offsetY,type:float,size:4},{name:rotation,type:float,size:4},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/LegsUnitEntity/0.json b/annotations/src/main/resources/revisions/LegsUnitEntity/0.json index 8946f13fa4..40c3cdbcdf 100644 --- a/annotations/src/main/resources/revisions/LegsUnitEntity/0.json +++ b/annotations/src/main/resources/revisions/LegsUnitEntity/0.json @@ -1 +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: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}]} \ No newline at end of file +{fields:[{name:baseRotation,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:rotation,type:float,size:4},{name:shield,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}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/LegsUnitEntity/1.json b/annotations/src/main/resources/revisions/LegsUnitEntity/1.json deleted file mode 100644 index 23e904cbcf..0000000000 --- a/annotations/src/main/resources/revisions/LegsUnitEntity/1.json +++ /dev/null @@ -1 +0,0 @@ -{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}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/MinerUnitEntity/0.json b/annotations/src/main/resources/revisions/MinerUnitEntity/0.json index d8ae40cd01..0f5535c862 100644 --- a/annotations/src/main/resources/revisions/MinerUnitEntity/0.json +++ b/annotations/src/main/resources/revisions/MinerUnitEntity/0.json @@ -1 +1 @@ -{fields:[{name:drownTime,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,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}]} \ No newline at end of file +{fields:[{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:rotation,type:float,size:4},{name:shield,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}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/MinerUnitEntity/1.json b/annotations/src/main/resources/revisions/MinerUnitEntity/1.json deleted file mode 100644 index fcd712c373..0000000000 --- a/annotations/src/main/resources/revisions/MinerUnitEntity/1.json +++ /dev/null @@ -1 +0,0 @@ -{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}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/StandardEffectEntity/0.json b/annotations/src/main/resources/revisions/StandardEffectEntity/0.json deleted file mode 100644 index 4e23d76400..0000000000 --- a/annotations/src/main/resources/revisions/StandardEffectEntity/0.json +++ /dev/null @@ -1 +0,0 @@ -{fields:[{name:color,type:arc.graphics.Color,size:-1},{name:data,type:java.lang.Object,size:-1},{name:lifetime,type:float,size:4},{name:offsetX,type:float,size:4},{name:offsetY,type:float,size:4},{name:rotation,type:float,size:4},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/UnitEntity/0.json b/annotations/src/main/resources/revisions/UnitEntity/0.json index a3e717b9b7..010ca755c5 100644 --- a/annotations/src/main/resources/revisions/UnitEntity/0.json +++ b/annotations/src/main/resources/revisions/UnitEntity/0.json @@ -1 +1 @@ -{fields:[{name:drownTime,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,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}]} \ No newline at end of file +{fields:[{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:rotation,type:float,size:4},{name:shield,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}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/UnitEntity/1.json b/annotations/src/main/resources/revisions/UnitEntity/1.json deleted file mode 100644 index 66f7e0ee4a..0000000000 --- a/annotations/src/main/resources/revisions/UnitEntity/1.json +++ /dev/null @@ -1 +0,0 @@ -{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}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/UnitWaterMoveEntity/0.json b/annotations/src/main/resources/revisions/UnitWaterMoveEntity/0.json index a3e717b9b7..010ca755c5 100644 --- a/annotations/src/main/resources/revisions/UnitWaterMoveEntity/0.json +++ b/annotations/src/main/resources/revisions/UnitWaterMoveEntity/0.json @@ -1 +1 @@ -{fields:[{name:drownTime,type:float,size:4},{name:elevation,type:float,size:4},{name:health,type:float,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}]} \ No newline at end of file +{fields:[{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:rotation,type:float,size:4},{name:shield,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}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/UnitWaterMoveEntity/1.json b/annotations/src/main/resources/revisions/UnitWaterMoveEntity/1.json deleted file mode 100644 index 66f7e0ee4a..0000000000 --- a/annotations/src/main/resources/revisions/UnitWaterMoveEntity/1.json +++ /dev/null @@ -1 +0,0 @@ -{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}]} \ No newline at end of file diff --git a/core/src/mindustry/content/StatusEffects.java b/core/src/mindustry/content/StatusEffects.java index a925a77be4..45264275b3 100644 --- a/core/src/mindustry/content/StatusEffects.java +++ b/core/src/mindustry/content/StatusEffects.java @@ -85,6 +85,7 @@ public class StatusEffects implements ContentList{ damageMultiplier = 1.4f; damage = -0.01f; effect = Fx.overdriven; + permanent = true; }}; shielded = new StatusEffect("shielded"){{ @@ -92,9 +93,7 @@ public class StatusEffects implements ContentList{ }}; boss = new StatusEffect("boss"){{ - armorMultiplier = 3f; - damageMultiplier = 3f; - speedMultiplier = 1.1f; + permanent = true; }}; shocked = new StatusEffect("shocked"); diff --git a/core/src/mindustry/entities/def/FlyingComp.java b/core/src/mindustry/entities/def/FlyingComp.java index 0662d0dfa6..0ca6b54b03 100644 --- a/core/src/mindustry/entities/def/FlyingComp.java +++ b/core/src/mindustry/entities/def/FlyingComp.java @@ -18,7 +18,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{ @Import Vec2 vel; float elevation; - float drownTime; + transient float drownTime; transient float splashTimer; boolean isGrounded(){ diff --git a/core/src/mindustry/entities/def/StatusComp.java b/core/src/mindustry/entities/def/StatusComp.java index e158904a04..5fd937469b 100644 --- a/core/src/mindustry/entities/def/StatusComp.java +++ b/core/src/mindustry/entities/def/StatusComp.java @@ -29,6 +29,12 @@ abstract class StatusComp implements Posc, Flyingc{ return amount * Mathf.clamp(1f - armorMultiplier / 100f); } + /** Apply a status effect for 1 tick (for permanent effects) **/ + void apply(StatusEffect effect){ + apply(effect, 1); + } + + /** Adds a status effect to this unit. */ void apply(StatusEffect effect, float duration){ if(effect == StatusEffects.none || effect == null || isImmune(effect)) return; //don't apply empty or immune effects @@ -61,6 +67,17 @@ abstract class StatusComp implements Posc, Flyingc{ statuses.add(entry); } + /** Removes a status effect. */ + void unapply(StatusEffect effect){ + statuses.remove(e -> { + if(e.effect == effect){ + Pools.free(e); + return true; + } + return false; + }); + } + boolean isBoss(){ return hasEffect(StatusEffects.boss); } @@ -87,7 +104,7 @@ abstract class StatusComp implements Posc, Flyingc{ @Override public void update(){ Floor floor = floorOn(); - if(isGrounded() && floor.status != null){ + if(isGrounded()){ //apply effect apply(floor.status, floor.statusDuration); } @@ -105,7 +122,7 @@ abstract class StatusComp implements Posc, Flyingc{ entry.time = Math.max(entry.time - Time.delta(), 0); applied.set(entry.effect.id); - if(entry.time <= 0){ + if(entry.time <= 0 && !entry.effect.permanent){ Pools.free(entry); index --; statuses.remove(index); @@ -119,6 +136,12 @@ abstract class StatusComp implements Posc, Flyingc{ } } + public void draw(){ + for(StatusEntry e : statuses){ + e.effect.draw((Unitc)this); + } + } + boolean hasEffect(StatusEffect effect){ return applied.get(effect.id); } diff --git a/core/src/mindustry/entities/def/UnitComp.java b/core/src/mindustry/entities/def/UnitComp.java index 3de7c0459f..95c5d5f8a9 100644 --- a/core/src/mindustry/entities/def/UnitComp.java +++ b/core/src/mindustry/entities/def/UnitComp.java @@ -18,14 +18,12 @@ import mindustry.world.blocks.environment.*; import static mindustry.Vars.*; @Component -abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc, Drawc, Boundedc, Syncc{ - @Import float x, y, rotation, elevation; +abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc, Drawc, Boundedc, Syncc, Shieldc{ + @Import float x, y, rotation, elevation, maxHealth; private UnitController controller; private UnitType type; - int level; - public void moveAt(Vec2 vector){ moveAt(vector, type.accel); } @@ -92,7 +90,7 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox @Override public void type(UnitType type){ this.type = type; - maxHealth(type.health); + this.maxHealth = type.health; heal(); drag(type.drag); hitSize(type.hitsize); diff --git a/core/src/mindustry/type/StatusEffect.java b/core/src/mindustry/type/StatusEffect.java index e7aacc1c41..0f7048b152 100644 --- a/core/src/mindustry/type/StatusEffect.java +++ b/core/src/mindustry/type/StatusEffect.java @@ -19,6 +19,8 @@ public class StatusEffect extends MappableContent{ public float speedMultiplier = 1f; /** Damage per frame. */ public float damage; + /** If true, the effect never disappears. */ + public boolean permanent; /** Tint color of effect. */ public Color color = Color.white.cpy(); /** Effect that happens randomly on top of the affected unit. */ @@ -71,6 +73,10 @@ public class StatusEffect extends MappableContent{ } } + public void draw(Unitc unit){ + + } + public boolean reactsWith(StatusEffect effect){ return transitions.containsKey(effect); } diff --git a/gradle.properties b/gradle.properties index b3ae2b151f..57a7b13075 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=1a08af7c65c887436d305a69928d9845ccfa3874 +archash=c3020adc9f3b6180662a1b8f9f3046b9266fe012