Bugfixes, cleanup

This commit is contained in:
Anuken
2020-02-16 22:22:10 -05:00
parent e71230755d
commit 6d68e10804
5 changed files with 17 additions and 8 deletions

View File

@@ -343,6 +343,7 @@ public class TechTree implements ContentList{
public static class TechNode{ public static class TechNode{
static TechNode context; static TechNode context;
public TechNode parent;
public final Block block; public final Block block;
public final ItemStack[] requirements; public final ItemStack[] requirements;
public final Array<TechNode> children = new Array<>(); public final Array<TechNode> children = new Array<>();
@@ -352,6 +353,7 @@ public class TechTree implements ContentList{
ccontext.children.add(this); ccontext.children.add(this);
} }
this.parent = ccontext;
this.block = block; this.block = block;
this.requirements = requirements; this.requirements = requirements;

View File

@@ -78,7 +78,6 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
float rotation = this.rotation - 90; float rotation = this.rotation - 90;
//shoot if applicable //shoot if applicable
//TODO only shoot if angle is reached, don't shoot inaccurately
if(mount.reload <= 0.0001f && Angles.within(mount.rotation, mount.targetRotation, 1.5f)){ if(mount.reload <= 0.0001f && Angles.within(mount.rotation, mount.targetRotation, 1.5f)){
for(int i : (weapon.mirror && !weapon.alternate ? Mathf.signs : Mathf.one)){ for(int i : (weapon.mirror && !weapon.alternate ? Mathf.signs : Mathf.one)){
i *= Mathf.sign(weapon.flipped) * Mathf.sign(mount.side); i *= Mathf.sign(weapon.flipped) * Mathf.sign(mount.side);
@@ -91,7 +90,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
shootY = mountY + Angles.trnsy(weaponRotation, weapon.shootX * i, weapon.shootY); shootY = mountY + Angles.trnsy(weaponRotation, weapon.shootX * i, weapon.shootY);
float shootAngle = weapon.rotate ? weaponRotation + 90 : Angles.angle(shootX, shootY, mount.aimX, mount.aimY) + (this.rotation - angleTo(mount.aimX, mount.aimY)); float shootAngle = weapon.rotate ? weaponRotation + 90 : Angles.angle(shootX, shootY, mount.aimX, mount.aimY) + (this.rotation - angleTo(mount.aimX, mount.aimY));
shoot(weapon, shootX, shootY, shootAngle); shoot(weapon, shootX, shootY, shootAngle, -i);
} }
mount.side = !mount.side; mount.side = !mount.side;
@@ -101,7 +100,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
} }
} }
private void shoot(Weapon weapon, float x, float y, float rotation){ private void shoot(Weapon weapon, float x, float y, float rotation, int side){
float baseX = this.x, baseY = this.y; float baseX = this.x, baseY = this.y;
weapon.shootSound.at(x, y, Mathf.random(0.8f, 1.0f)); weapon.shootSound.at(x, y, Mathf.random(0.8f, 1.0f));
@@ -129,7 +128,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc{
boolean parentize = ammo.keepVelocity; boolean parentize = ammo.keepVelocity;
Effects.shake(weapon.shake, weapon.shake, x, y); Effects.shake(weapon.shake, weapon.shake, x, y);
weapon.ejectEffect.at(x, y, rotation); weapon.ejectEffect.at(x, y, rotation * side);
ammo.shootEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? this : null); ammo.shootEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? this : null);
ammo.smokeEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? this : null); ammo.smokeEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? this : null);
} }

View File

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

View File

@@ -6,7 +6,7 @@ import arc.audio.*;
import arc.files.*; import arc.files.*;
import arc.func.*; import arc.func.*;
import arc.graphics.*; import arc.graphics.*;
import arc.mock.MockSound; import arc.mock.*;
import arc.struct.Array; import arc.struct.Array;
import arc.struct.*; import arc.struct.*;
import arc.util.ArcAnnotate.*; import arc.util.ArcAnnotate.*;
@@ -173,9 +173,11 @@ public class ContentParser{
readBundle(ContentType.block, name, value); readBundle(ContentType.block, name, value);
Block block; Block block;
boolean exists;
if(locate(ContentType.block, name) != null){ if(locate(ContentType.block, name) != null){
block = locate(ContentType.block, name); block = locate(ContentType.block, name);
exists = true;
if(value.has("type")){ if(value.has("type")){
throw new IllegalArgumentException("When defining properties for an existing block, you must not re-declare its type. The original type will be used. Block: " + name); throw new IllegalArgumentException("When defining properties for an existing block, you must not re-declare its type. The original type will be used. Block: " + name);
@@ -183,6 +185,7 @@ public class ContentParser{
}else{ }else{
//TODO generate dynamically instead of doing.. this //TODO generate dynamically instead of doing.. this
Class<? extends Block> type; Class<? extends Block> type;
exists = false;
try{ try{
type = resolve(getType(value), type = resolve(getType(value),
@@ -249,13 +252,17 @@ public class ContentParser{
//add research tech node //add research tech node
if(research[0] != null){ if(research[0] != null){
Block parent = find(ContentType.block, research[0]); Block parent = find(ContentType.block, research[0]);
TechNode baseNode = TechTree.create(parent, block); TechNode baseNode = exists && TechTree.all.contains(t -> t.block == block) ? TechTree.all.find(t -> t.block == block) : TechTree.create(parent, block);
LoadedMod cur = currentMod; LoadedMod cur = currentMod;
postreads.add(() -> { postreads.add(() -> {
currentContent = block; currentContent = block;
currentMod = cur; currentMod = cur;
if(baseNode.parent != null){
baseNode.parent.children.remove(baseNode);
}
TechNode parnode = TechTree.all.find(t -> t.block == parent); TechNode parnode = TechTree.all.find(t -> t.block == parent);
if(parnode == null){ if(parnode == null){
throw new IllegalArgumentException("Block '" + parent.name + "' isn't in the tech tree, but '" + block.name + "' requires it to be researched."); throw new IllegalArgumentException("Block '" + parent.name + "' isn't in the tech tree, but '" + block.name + "' requires it to be researched.");
@@ -263,7 +270,9 @@ public class ContentParser{
if(!parnode.children.contains(baseNode)){ if(!parnode.children.contains(baseNode)){
parnode.children.add(baseNode); parnode.children.add(baseNode);
} }
baseNode.parent = parnode;
}); });
} }
//make block visible by default if there are requirements and no visibility set //make block visible by default if there are requirements and no visibility set

View File

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