Actual updating and rendering

This commit is contained in:
Anuken
2020-02-06 13:40:07 -05:00
parent 6fe5663f79
commit ddecb2d831
8 changed files with 33 additions and 16 deletions

View File

@@ -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;

View File

@@ -221,6 +221,8 @@ public class Logic implements ApplicationListener{
runWave();
}
Groups.all.update();
//TODO update groups
/*
if(!headless){

View File

@@ -13,6 +13,8 @@ import static mindustry.Vars.collisions;
/** Represents a group of a certain type of entity.*/
@SuppressWarnings("unchecked")
public class EntityGroup<T extends Entityc> implements Iterable<T>{
private static int lastId = 0;
private final Array<T> array;
private final Array<T> intersectArray = new Array<>();
private final Rect viewport = new Rect();
@@ -23,6 +25,10 @@ public class EntityGroup<T extends Entityc> implements Iterable<T>{
private int index;
public static int nextId(){
return lastId++;
}
public EntityGroup(Class<T> type, boolean spatial, boolean mapping){
array = new Array<>(false, 32, type);

View File

@@ -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();

View File

@@ -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;

View File

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

View File

@@ -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));