Fixed a crash

This commit is contained in:
Anuken
2020-02-15 15:55:37 -05:00
parent 8b4fcf99a6
commit e677538c53
6 changed files with 21 additions and 13 deletions

View File

@@ -5,15 +5,15 @@ import arc.func.*;
import arc.struct.*;
import arc.util.*;
import arc.util.io.*;
import arc.util.pooling.*;
import arc.util.pooling.Pool.*;
import arc.util.pooling.*;
import com.squareup.javapoet.*;
import com.squareup.javapoet.TypeSpec.*;
import com.sun.source.tree.*;
import mindustry.annotations.Annotations.*;
import mindustry.annotations.*;
import mindustry.annotations.util.TypeIOResolver.*;
import mindustry.annotations.util.*;
import mindustry.annotations.util.TypeIOResolver.*;
import javax.annotation.processing.*;
import javax.lang.model.element.*;
@@ -325,6 +325,8 @@ public class EntityProcess extends BaseProcessor{
//SPECIAL CASE: inject group add/remove code
if(first.name().equals("add") || first.name().equals("remove")){
mbuilder.addStatement("if(added == $L) return", first.name().equals("add"));
for(GroupDefinition def : groups){
//remove/add from each group, assume imported
mbuilder.addStatement("Groups.$L.$L(this)", def.name, first.name());
@@ -367,7 +369,7 @@ public class EntityProcess extends BaseProcessor{
if(writeBlock) mbuilder.addCode("}\n");
}
//add free code to remove methods
//add free code to remove methods - always at the end
if(first.name().equals("remove") && ann.pooled()){
mbuilder.addStatement("$T.free(this)", Pools.class);
}
@@ -375,7 +377,7 @@ public class EntityProcess extends BaseProcessor{
builder.addMethod(mbuilder.build());
}
//add pool reset method and implment Poolable
//add pool reset method and implement Poolable
if(ann.pooled()){
builder.addSuperinterface(Poolable.class);
//implement reset()

View File

@@ -1,5 +1,6 @@
package mindustry.content;
import arc.struct.*;
import mindustry.annotations.Annotations.*;
import mindustry.ctype.*;
import mindustry.gen.*;
@@ -44,6 +45,7 @@ public class UnitTypes implements ContentList{
hitsize = 8f;
mass = 1.75f;
health = 130;
immunities = ObjectSet.with(StatusEffects.wet);
weapons.add(new Weapon("chain-blaster"){{
reload = 10f;
x = 1.25f;

View File

@@ -17,7 +17,7 @@ import mindustry.world.*;
import static mindustry.Vars.*;
@Component
abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc{
abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, DrawLayerGroundc{
@Import float x, y, rotation;
transient float mineTimer;
@@ -79,7 +79,8 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc{
}
}
void drawOver(){
@Override
public void drawGround(){
if(!mining()) return;
float focusLen = 4f + Mathf.absin(Time.time(), 1.1f, 0.5f);
float swingScl = 12f, swingMag = tilesize / 8f;

View File

@@ -171,6 +171,11 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
if(isGrounded()) draw();
}
@Override
public boolean isPlayer(){
return controller instanceof Playerc;
}
@Override
public void killed(){
float explosiveness = 2f + item().explosiveness * stack().amount;
@@ -189,20 +194,17 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
}
}
//TODO this is bad
public boolean isPlayer(){
return controller instanceof Playerc;
}
@Override
public boolean canMine(Item item){
return type.drillTier >= item.hardness;
}
@Override
public float miningSpeed(){
return type.mineSpeed;
}
@Override
public boolean offloadImmediately(){
return false;
}

View File

@@ -53,6 +53,7 @@ public class TestPlanetGenerator implements PlanetGenerator{
@Override
public void generate(Vec3 position, TileGen tile){
tile.floor = getBlock(position);
tile.overlay = Mathf.chance(0.01) ? Blocks.oreCopper : Blocks.air;
}
Block getBlock(Vec3 position){

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=f1178ca09b4d0b29e23f6443e73f8daf4a4b7329
archash=d5eb3f0c3df12ba6f6b20c1c95952bc22d4250b3