mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-25 10:25:42 +07:00
Unit status cleanup
This commit is contained in:
parent
f6bf229b0a
commit
2f3c098b50
@ -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<String, Selement> usedNames = new ObjectMap<>();
|
||||
ObjectMap<Selement, ObjectSet<String>> 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());
|
||||
|
||||
|
@ -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<T extends Element>{
|
||||
this.e = e;
|
||||
}
|
||||
|
||||
public String doc(){
|
||||
public @Nullable String doc(){
|
||||
return BaseProcessor.elementu.getDocComment(e);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
mindustry.type.Weather.WeatherComp=9
|
||||
phantom=10
|
||||
vanguard=11
|
||||
wraith=12
|
@ -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}]}
|
||||
{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}]}
|
@ -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}]}
|
@ -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}]}
|
@ -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}]}
|
||||
{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}]}
|
@ -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}]}
|
@ -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}]}
|
||||
{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}]}
|
@ -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}]}
|
@ -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}]}
|
@ -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}]}
|
||||
{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}]}
|
@ -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}]}
|
@ -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}]}
|
||||
{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}]}
|
@ -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}]}
|
@ -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");
|
||||
|
@ -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(){
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=1a08af7c65c887436d305a69928d9845ccfa3874
|
||||
archash=c3020adc9f3b6180662a1b8f9f3046b9266fe012
|
||||
|
Loading…
Reference in New Issue
Block a user