diff --git a/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java b/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java index ab4d9ad1fe..d6ce2ad8a0 100644 --- a/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java +++ b/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java @@ -442,6 +442,8 @@ public class EntityProcess extends BaseProcessor{ if(!method.isVoid()){ if(method.name().equals("isNull")){ builder.addStatement("return true"); + }else if(method.name().equals("id")){ + builder.addStatement("return -1"); }else{ Svar variable = compType == null || method.params().size > 0 ? null : compType.fields().find(v -> v.name().equals(method.name())); if(variable == null || !varInitializers.containsKey(variable)){ diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 963227c1bc..cf71e2b85b 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -1,6 +1,7 @@ package mindustry.content; import mindustry.ctype.*; +import mindustry.gen.*; import mindustry.type.*; public class UnitTypes implements ContentList{ @@ -14,6 +15,20 @@ public class UnitTypes implements ContentList{ @Override public void load(){ + dagger = new UnitDef("dagger", GenericUnitEntity::create){{ + speed = 0.2f; + drag = 0.4f; + hitsize = 8f; + mass = 1.75f; + health = 130; + weapons.add(new Weapon("chain-blaster"){{ + reload = 28f; + alternate = true; + ejectEffect = Fx.shellEjectSmall; + bullet = Bullets.standardCopper; + }}); + }}; + /* draug = new UnitDef("draug", MinerDrone::new){{ flying = true; diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index 851e47b77c..195290308b 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -221,6 +221,8 @@ public class Logic implements ApplicationListener{ runWave(); } + Groups.all.update(); + //TODO update groups /* if(!headless){ diff --git a/core/src/mindustry/entities/EntityGroup.java b/core/src/mindustry/entities/EntityGroup.java index bb520e99e0..fa381b2110 100644 --- a/core/src/mindustry/entities/EntityGroup.java +++ b/core/src/mindustry/entities/EntityGroup.java @@ -13,6 +13,8 @@ import static mindustry.Vars.collisions; /** Represents a group of a certain type of entity.*/ @SuppressWarnings("unchecked") public class EntityGroup implements Iterable{ + private static int lastId = 0; + private final Array array; private final Array intersectArray = new Array<>(); private final Rect viewport = new Rect(); @@ -23,6 +25,10 @@ public class EntityGroup implements Iterable{ private int index; + public static int nextId(){ + return lastId++; + } + public EntityGroup(Class type, boolean spatial, boolean mapping){ array = new Array<>(false, 32, type); diff --git a/core/src/mindustry/entities/def/DrawShadowComp.java b/core/src/mindustry/entities/def/DrawShadowComp.java index 9f0638ff4f..b1c99b216f 100644 --- a/core/src/mindustry/entities/def/DrawShadowComp.java +++ b/core/src/mindustry/entities/def/DrawShadowComp.java @@ -6,7 +6,7 @@ import mindustry.annotations.Annotations.*; import mindustry.gen.*; @Component -abstract class DrawShadowComp implements Drawc, Rotc, Flyingc, DrawLayerFlyingShadowsc, DrawLayerGroundShadowsc{ +abstract class DrawShadowComp implements Drawc, Rotc, Flyingc, DrawLayerFlyingShadowsc{ static final float shadowTX = -12, shadowTY = -13, shadowColor = Color.toFloatBits(0, 0, 0, 0.22f); transient float x, y, rotation; @@ -16,19 +16,6 @@ abstract class DrawShadowComp implements Drawc, Rotc, Flyingc, DrawLayerFlyingSh @Override public void drawFlyingShadows(){ if(isFlying()){ - drawShadow(); - } - } - - @Override - public void drawGroundShadows(){ - if(isGrounded()){ - drawShadow(); - } - } - - void drawShadow(){ - if(!isGrounded()){ Draw.color(shadowColor); Draw.rect(getShadowRegion(), x + shadowTX * elevation(), y + shadowTY * elevation(), rotation - 90); Draw.color(); diff --git a/core/src/mindustry/entities/def/EntityComp.java b/core/src/mindustry/entities/def/EntityComp.java index 46e7fce919..1ffab2ee7a 100644 --- a/core/src/mindustry/entities/def/EntityComp.java +++ b/core/src/mindustry/entities/def/EntityComp.java @@ -2,6 +2,7 @@ package mindustry.entities.def; import arc.func.*; import mindustry.annotations.Annotations.*; +import mindustry.entities.*; import mindustry.gen.*; import java.io.*; @@ -12,7 +13,7 @@ import static mindustry.Vars.player; @BaseComponent abstract class EntityComp{ private boolean added; - int id; + int id = EntityGroup.nextId(); boolean isAdded(){ return added; diff --git a/core/src/mindustry/entities/def/PosComp.java b/core/src/mindustry/entities/def/PosComp.java index 11408b0edb..00b143acc4 100644 --- a/core/src/mindustry/entities/def/PosComp.java +++ b/core/src/mindustry/entities/def/PosComp.java @@ -19,6 +19,10 @@ abstract class PosComp implements Position{ this.y = y; } + void set(Position pos){ + set(pos.getX(), pos.getY()); + } + void trns(float x, float y){ set(this.x + x, this.y + y); } diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index 2ed33e4ceb..25071374bd 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -138,7 +138,7 @@ public class DesktopInput extends InputHandler{ ui.listfrag.toggle(); } - if(((player.closestCore() == null && player.dead()) || state.isPaused()) && !ui.chatfrag.shown()){ + if(((player.dead()) || state.isPaused()) && !ui.chatfrag.shown()){ //move camera around float camSpeed = !Core.input.keyDown(Binding.dash) ? 3f : 8f; Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(Time.delta() * camSpeed));