This commit is contained in:
Anuken
2019-10-22 20:17:43 -04:00
parent 1f5e639fb2
commit 56e5705ed6
7 changed files with 49 additions and 32 deletions

View File

@@ -38,7 +38,7 @@ public class Mechs implements ContentList{
weapon = new Weapon("blaster"){{ weapon = new Weapon("blaster"){{
length = 1.5f; length = 1.5f;
reload = 14f; reload = 14f;
roundrobin = true; alternate = true;
ejectEffect = Fx.shellEjectSmall; ejectEffect = Fx.shellEjectSmall;
bullet = Bullets.standardMechSmall; bullet = Bullets.standardMechSmall;
}}; }};
@@ -71,7 +71,7 @@ public class Mechs implements ContentList{
length = 1f; length = 1f;
reload = 55f; reload = 55f;
shotDelay = 3f; shotDelay = 3f;
roundrobin = true; alternate = true;
shots = 2; shots = 2;
inaccuracy = 0f; inaccuracy = 0f;
ejectEffect = Fx.none; ejectEffect = Fx.none;
@@ -116,7 +116,7 @@ public class Mechs implements ContentList{
weapon = new Weapon("heal-blaster"){{ weapon = new Weapon("heal-blaster"){{
length = 1.5f; length = 1.5f;
reload = 24f; reload = 24f;
roundrobin = false; alternate = false;
ejectEffect = Fx.none; ejectEffect = Fx.none;
recoil = 2f; recoil = 2f;
bullet = Bullets.healBullet; bullet = Bullets.healBullet;
@@ -168,7 +168,7 @@ public class Mechs implements ContentList{
shots = 4; shots = 4;
spacing = 8f; spacing = 8f;
inaccuracy = 8f; inaccuracy = 8f;
roundrobin = true; alternate = true;
ejectEffect = Fx.none; ejectEffect = Fx.none;
shake = 3f; shake = 3f;
bullet = Bullets.missileSwarm; bullet = Bullets.missileSwarm;
@@ -232,7 +232,7 @@ public class Mechs implements ContentList{
weapon = new Weapon("blaster"){{ weapon = new Weapon("blaster"){{
length = 1.5f; length = 1.5f;
reload = 15f; reload = 15f;
roundrobin = true; alternate = true;
ejectEffect = Fx.shellEjectSmall; ejectEffect = Fx.shellEjectSmall;
bullet = Bullets.standardCopper; bullet = Bullets.standardCopper;
}}; }};
@@ -262,7 +262,7 @@ public class Mechs implements ContentList{
reload = 70f; reload = 70f;
shots = 4; shots = 4;
inaccuracy = 2f; inaccuracy = 2f;
roundrobin = true; alternate = true;
ejectEffect = Fx.none; ejectEffect = Fx.none;
velocityRnd = 0.2f; velocityRnd = 0.2f;
spacing = 1f; spacing = 1f;
@@ -327,7 +327,7 @@ public class Mechs implements ContentList{
shots = 2; shots = 2;
shotDelay = 1f; shotDelay = 1f;
shots = 8; shots = 8;
roundrobin = true; alternate = true;
ejectEffect = Fx.none; ejectEffect = Fx.none;
velocityRnd = 1f; velocityRnd = 1f;
inaccuracy = 20f; inaccuracy = 20f;
@@ -365,7 +365,7 @@ public class Mechs implements ContentList{
weapon = new Weapon("bomber"){{ weapon = new Weapon("bomber"){{
length = 1.5f; length = 1.5f;
reload = 13f; reload = 13f;
roundrobin = true; alternate = true;
ejectEffect = Fx.shellEjectSmall; ejectEffect = Fx.shellEjectSmall;
bullet = Bullets.standardGlaive; bullet = Bullets.standardGlaive;
shootSound = Sounds.shootSnap; shootSound = Sounds.shootSnap;

View File

@@ -41,11 +41,11 @@ public class UnitTypes implements ContentList{
health = 100; health = 100;
engineSize = 1.8f; engineSize = 1.8f;
engineOffset = 5.7f; engineOffset = 5.7f;
weapon = new Weapon("heal-blaster"){{ weapon = new Weapon(){{
length = 1.5f; length = 1.5f;
reload = 40f; reload = 40f;
width = 0.5f; width = 0.5f;
roundrobin = true; alternate = true;
ejectEffect = Fx.none; ejectEffect = Fx.none;
recoil = 2f; recoil = 2f;
bullet = Bullets.healBulletBig; bullet = Bullets.healBulletBig;
@@ -65,11 +65,11 @@ public class UnitTypes implements ContentList{
buildPower = 0.4f; buildPower = 0.4f;
engineOffset = 6.5f; engineOffset = 6.5f;
toMine = ObjectSet.with(Items.lead, Items.copper, Items.titanium); toMine = ObjectSet.with(Items.lead, Items.copper, Items.titanium);
weapon = new Weapon("heal-blaster"){{ weapon = new Weapon(){{
length = 1.5f; length = 1.5f;
reload = 20f; reload = 20f;
width = 0.5f; width = 0.5f;
roundrobin = true; alternate = true;
ejectEffect = Fx.none; ejectEffect = Fx.none;
recoil = 2f; recoil = 2f;
bullet = Bullets.healBullet; bullet = Bullets.healBullet;
@@ -86,7 +86,7 @@ public class UnitTypes implements ContentList{
weapon = new Weapon("chain-blaster"){{ weapon = new Weapon("chain-blaster"){{
length = 1.5f; length = 1.5f;
reload = 28f; reload = 28f;
roundrobin = true; alternate = true;
ejectEffect = Fx.shellEjectSmall; ejectEffect = Fx.shellEjectSmall;
bullet = Bullets.standardCopper; bullet = Bullets.standardCopper;
}}; }};
@@ -99,7 +99,7 @@ public class UnitTypes implements ContentList{
hitsize = 8f; hitsize = 8f;
mass = 1.75f; mass = 1.75f;
health = 120; health = 120;
weapon = new Weapon("bomber"){{ weapon = new Weapon(){{
reload = 12f; reload = 12f;
ejectEffect = Fx.none; ejectEffect = Fx.none;
shootSound = Sounds.explosion; shootSound = Sounds.explosion;
@@ -138,7 +138,7 @@ public class UnitTypes implements ContentList{
length = 1f; length = 1f;
reload = 14f; reload = 14f;
range = 30f; range = 30f;
roundrobin = true; alternate = true;
recoil = 1f; recoil = 1f;
ejectEffect = Fx.none; ejectEffect = Fx.none;
bullet = Bullets.basicFlame; bullet = Bullets.basicFlame;
@@ -158,7 +158,7 @@ public class UnitTypes implements ContentList{
length = 1f; length = 1f;
reload = 60f; reload = 60f;
width = 10f; width = 10f;
roundrobin = true; alternate = true;
recoil = 4f; recoil = 4f;
shake = 2f; shake = 2f;
ejectEffect = Fx.shellEjectMedium; ejectEffect = Fx.shellEjectMedium;
@@ -180,7 +180,7 @@ public class UnitTypes implements ContentList{
weapon = new Weapon("eruption"){{ weapon = new Weapon("eruption"){{
length = 3f; length = 3f;
reload = 10f; reload = 10f;
roundrobin = true; alternate = true;
ejectEffect = Fx.none; ejectEffect = Fx.none;
bullet = Bullets.eruptorShot; bullet = Bullets.eruptorShot;
recoil = 1f; recoil = 1f;
@@ -201,7 +201,7 @@ public class UnitTypes implements ContentList{
length = 8f; length = 8f;
reload = 50f; reload = 50f;
width = 17f; width = 17f;
roundrobin = true; alternate = true;
recoil = 3f; recoil = 3f;
shake = 2f; shake = 2f;
shots = 4; shots = 4;
@@ -225,7 +225,7 @@ public class UnitTypes implements ContentList{
length = 13f; length = 13f;
reload = 30f; reload = 30f;
width = 22f; width = 22f;
roundrobin = true; alternate = true;
recoil = 3f; recoil = 3f;
shake = 2f; shake = 2f;
inaccuracy = 3f; inaccuracy = 3f;
@@ -247,10 +247,10 @@ public class UnitTypes implements ContentList{
health = 75; health = 75;
engineOffset = 5.5f; engineOffset = 5.5f;
range = 140f; range = 140f;
weapon = new Weapon("chain-blaster"){{ weapon = new Weapon(){{
length = 1.5f; length = 1.5f;
reload = 28f; reload = 28f;
roundrobin = true; alternate = true;
ejectEffect = Fx.shellEjectSmall; ejectEffect = Fx.shellEjectSmall;
bullet = Bullets.standardCopper; bullet = Bullets.standardCopper;
shootSound = Sounds.shoot; shootSound = Sounds.shoot;
@@ -267,11 +267,11 @@ public class UnitTypes implements ContentList{
targetAir = false; targetAir = false;
engineOffset = 7.8f; engineOffset = 7.8f;
range = 140f; range = 140f;
weapon = new Weapon("bomber"){{ weapon = new Weapon(){{
length = 0f; length = 0f;
width = 2f; width = 2f;
reload = 12f; reload = 12f;
roundrobin = true; alternate = true;
ejectEffect = Fx.none; ejectEffect = Fx.none;
velocityRnd = 1f; velocityRnd = 1f;
inaccuracy = 40f; inaccuracy = 40f;
@@ -303,7 +303,7 @@ public class UnitTypes implements ContentList{
width = 10f; width = 10f;
shots = 2; shots = 2;
inaccuracy = 2f; inaccuracy = 2f;
roundrobin = true; alternate = true;
ejectEffect = Fx.none; ejectEffect = Fx.none;
velocityRnd = 0.2f; velocityRnd = 0.2f;
spacing = 1f; spacing = 1f;
@@ -336,7 +336,7 @@ public class UnitTypes implements ContentList{
shootCone = 100f; shootCone = 100f;
shotDelay = 2; shotDelay = 2;
inaccuracy = 10f; inaccuracy = 10f;
roundrobin = true; alternate = true;
ejectEffect = Fx.none; ejectEffect = Fx.none;
velocityRnd = 0.2f; velocityRnd = 0.2f;
spacing = 1f; spacing = 1f;
@@ -369,7 +369,7 @@ public class UnitTypes implements ContentList{
shake = 1f; shake = 1f;
inaccuracy = 3f; inaccuracy = 3f;
roundrobin = true; alternate = true;
ejectEffect = Fx.none; ejectEffect = Fx.none;
bullet = new BasicBulletType(7f, 42, "bullet"){ bullet = new BasicBulletType(7f, 42, "bullet"){
{ {

View File

@@ -440,7 +440,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
control.input.drawBreaking(request); control.input.drawBreaking(request);
}else{ }else{
request.block.drawRequest(request, control.input.allRequests(), request.block.drawRequest(request, control.input.allRequests(),
Build.validPlace(getTeam(), request.x, request.y, request.block, request.rotation)); Build.validPlace(getTeam(), request.x, request.y, request.block, request.rotation) || control.input.requestMatches(request));
} }
} }

View File

@@ -151,7 +151,13 @@ public class FlyingUnit extends BaseUnit{
} }
public void drawWeapons(){ public void drawWeapons(){
for(int i : Mathf.signs){
float tra = rotation - 90, trY = -type.weapon.getRecoil(this, i > 0) + type.weaponOffsetY;
float w = -i * type.weapon.region.getWidth() * Draw.scl;
Draw.rect(type.weapon.region,
x + Angles.trnsx(tra, getWeapon().width * i, trY),
y + Angles.trnsy(tra, getWeapon().width * i, trY), w, type.weapon.region.getHeight() * Draw.scl, rotation - 90);
}
} }
public void drawEngine(){ public void drawEngine(){

View File

@@ -30,6 +30,8 @@ import io.anuke.mindustry.net.*;
import io.anuke.mindustry.type.*; import io.anuke.mindustry.type.*;
import io.anuke.mindustry.ui.fragments.*; import io.anuke.mindustry.ui.fragments.*;
import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.blocks.*;
import io.anuke.mindustry.world.blocks.BuildBlock.*;
import java.util.*; import java.util.*;
@@ -214,6 +216,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
} }
} }
public boolean requestMatches(BuildRequest request){
Tile tile = world.tile(request.x, request.y);
return tile != null && tile.block() instanceof BuildBlock && tile.<BuildEntity>entity().cblock == request.block;
}
public void drawBreaking(int x, int y){ public void drawBreaking(int x, int y){
Tile tile = world.ltile(x, y); Tile tile = world.ltile(x, y);
if(tile == null) return; if(tile == null) return;

View File

@@ -78,6 +78,7 @@ public class ContentParser{
* This is done to accomodate binding of content names first.*/ * This is done to accomodate binding of content names first.*/
private Array<Runnable> reads = new Array<>(); private Array<Runnable> reads = new Array<>();
private Array<Runnable> postreads = new Array<>(); private Array<Runnable> postreads = new Array<>();
private ObjectSet<Object> toBeParsed = new ObjectSet<>();
private LoadedMod currentMod; private LoadedMod currentMod;
private Content currentContent; private Content currentContent;
@@ -298,6 +299,7 @@ public class ContentParser{
} }
reads.clear(); reads.clear();
postreads.clear(); postreads.clear();
toBeParsed.clear();
} }
/** /**
@@ -321,6 +323,7 @@ public class ContentParser{
currentMod = mod; currentMod = mod;
boolean exists = Vars.content.getByName(type, name) != null; boolean exists = Vars.content.getByName(type, name) != null;
Content c = parsers.get(type).parse(mod.name, name, value); Content c = parsers.get(type).parse(mod.name, name, value);
toBeParsed.add(c);
if(!exists){ if(!exists){
c.sourceFile = file; c.sourceFile = file;
c.mod = mod; c.mod = mod;
@@ -387,7 +390,7 @@ public class ContentParser{
} }
private void checkNullFields(Object object){ private void checkNullFields(Object object){
if(object instanceof Number || object instanceof String) return; if(object instanceof Number || object instanceof String || toBeParsed.contains(object)) return;
parser.getFields(object.getClass()).values().toArray().each(field -> { parser.getFields(object.getClass()).values().toArray().each(field -> {
try{ try{
@@ -408,6 +411,7 @@ public class ContentParser{
} }
private void readFields(Object object, JsonValue jsonMap){ private void readFields(Object object, JsonValue jsonMap){
toBeParsed.remove(object);
Class type = object.getClass(); Class type = object.getClass();
ObjectMap<String, FieldMetadata> fields = parser.getFields(type); ObjectMap<String, FieldMetadata> fields = parser.getFields(type);
for(JsonValue child = jsonMap.child; child != null; child = child.next){ for(JsonValue child = jsonMap.child; child != null; child = child.next){

View File

@@ -48,7 +48,7 @@ public class Weapon{
/** fraction of velocity that is random */ /** fraction of velocity that is random */
public float velocityRnd = 0f; public float velocityRnd = 0f;
/** whether to shoot the weapons in different arms one after another, rather than all at once */ /** whether to shoot the weapons in different arms one after another, rather than all at once */
public boolean roundrobin = false; public boolean alternate = false;
/** randomization of shot length */ /** randomization of shot length */
public float lengthRand = 0f; public float lengthRand = 0f;
/** delay in ticks between shots */ /** delay in ticks between shots */
@@ -124,7 +124,7 @@ public class Weapon{
} }
public void load(){ public void load(){
region = Core.atlas.find(name + "-equip", Core.atlas.find("clear")); region = Core.atlas.find(name + "-equip", Core.atlas.find(name, Core.atlas.find("clear")));
} }
public void update(ShooterTrait shooter, float pointerX, float pointerY){ public void update(ShooterTrait shooter, float pointerX, float pointerY){
@@ -143,7 +143,7 @@ public class Weapon{
public void update(ShooterTrait shooter, float mountX, float mountY, float angle, boolean left){ public void update(ShooterTrait shooter, float mountX, float mountY, float angle, boolean left){
if(shooter.getTimer().get(shooter.getShootTimer(left), reload)){ if(shooter.getTimer().get(shooter.getShootTimer(left), reload)){
if(roundrobin){ if(alternate){
shooter.getTimer().reset(shooter.getShootTimer(!left), reload / 2f); shooter.getTimer().reset(shooter.getShootTimer(!left), reload / 2f);
} }