Merge branch 'MEEPofFaith-mining-beam-weapon'
This commit is contained in:
@@ -113,8 +113,10 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
buildSpeed = -1f,
|
buildSpeed = -1f,
|
||||||
/** Minimum distance from this unit that weapons can target. Prevents units from firing "inside" the unit. */
|
/** Minimum distance from this unit that weapons can target. Prevents units from firing "inside" the unit. */
|
||||||
aimDst = -1f,
|
aimDst = -1f,
|
||||||
/** Visual offset of build beam from front. */
|
/** Visual offset of the build beam from the front. */
|
||||||
buildBeamOffset = 3.8f,
|
buildBeamOffset = 3.8f,
|
||||||
|
/** Visual offset of the mining beam from the front. Defaults to half the hitsize. */
|
||||||
|
mineBeamOffset = Float.NEGATIVE_INFINITY,
|
||||||
/** WIP: Units of low priority will always be ignored in favor of those with higher priority, regardless of distance. */
|
/** WIP: Units of low priority will always be ignored in favor of those with higher priority, regardless of distance. */
|
||||||
targetPriority = 0f,
|
targetPriority = 0f,
|
||||||
/** Elevation of shadow drawn under this (ground) unit. Visual only. */
|
/** Elevation of shadow drawn under this (ground) unit. Visual only. */
|
||||||
@@ -236,6 +238,8 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
squareShape = false,
|
squareShape = false,
|
||||||
/** if true, this unit will draw its building beam towards blocks. */
|
/** if true, this unit will draw its building beam towards blocks. */
|
||||||
drawBuildBeam = true,
|
drawBuildBeam = true,
|
||||||
|
/** if true, this unit will draw its mining beam towards blocks */
|
||||||
|
drawMineBeam = true,
|
||||||
/** if false, the team indicator/cell is not drawn. */
|
/** if false, the team indicator/cell is not drawn. */
|
||||||
drawCell = true,
|
drawCell = true,
|
||||||
/** if false, carried items are not drawn. */
|
/** if false, carried items are not drawn. */
|
||||||
@@ -803,6 +807,8 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
}).layer(Layer.debris);
|
}).layer(Layer.debris);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mineBeamOffset == Float.NEGATIVE_INFINITY) mineBeamOffset = hitSize / 2;
|
||||||
|
|
||||||
for(Ability ab : abilities){
|
for(Ability ab : abilities){
|
||||||
ab.init(this);
|
ab.init(this);
|
||||||
}
|
}
|
||||||
@@ -1226,7 +1232,6 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
if(unit.inFogTo(Vars.player.team())) return;
|
if(unit.inFogTo(Vars.player.team())) return;
|
||||||
|
|
||||||
unit.drawBuilding();
|
unit.drawBuilding();
|
||||||
|
|
||||||
drawMining(unit);
|
drawMining(unit);
|
||||||
|
|
||||||
boolean isPayload = !unit.isAdded();
|
boolean isPayload = !unit.isAdded();
|
||||||
@@ -1339,16 +1344,21 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
return shieldColor == null ? unit.team.color : shieldColor;
|
return shieldColor == null ? unit.team.color : shieldColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void drawMining(Unit unit){
|
public void drawMining(Unit unit){
|
||||||
|
if(drawMineBeam){
|
||||||
|
float focusLen = mineBeamOffset + Mathf.absin(Time.time, 1.1f, 0.5f);
|
||||||
|
float px = unit.x + Angles.trnsx(unit.rotation, focusLen);
|
||||||
|
float py = unit.y + Angles.trnsy(unit.rotation, focusLen);
|
||||||
|
|
||||||
|
drawMiningBeam(unit, px, py);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawMiningBeam(Unit unit, float px, float py){
|
||||||
if(!unit.mining()) return;
|
if(!unit.mining()) return;
|
||||||
float focusLen = unit.hitSize / 2f + Mathf.absin(Time.time, 1.1f, 0.5f);
|
|
||||||
float swingScl = 12f, swingMag = tilesize / 8f;
|
float swingScl = 12f, swingMag = tilesize / 8f;
|
||||||
float flashScl = 0.3f;
|
float flashScl = 0.3f;
|
||||||
|
|
||||||
float px = unit.x + Angles.trnsx(unit.rotation, focusLen);
|
|
||||||
float py = unit.y + Angles.trnsy(unit.rotation, focusLen);
|
|
||||||
|
|
||||||
float ex = unit.mineTile.worldx() + Mathf.sin(Time.time + 48, swingScl, swingMag);
|
float ex = unit.mineTile.worldx() + Mathf.sin(Time.time + 48, swingScl, swingMag);
|
||||||
float ey = unit.mineTile.worldy() + Mathf.sin(Time.time + 48, swingScl + 2f, swingMag);
|
float ey = unit.mineTile.worldy() + Mathf.sin(Time.time + 48, swingScl + 2f, swingMag);
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import mindustry.type.*;
|
|||||||
public class BuildWeapon extends Weapon{
|
public class BuildWeapon extends Weapon{
|
||||||
|
|
||||||
public BuildWeapon(){
|
public BuildWeapon(){
|
||||||
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BuildWeapon(String name){
|
public BuildWeapon(String name){
|
||||||
|
|||||||
67
core/src/mindustry/type/weapons/MineWeapon.java
Normal file
67
core/src/mindustry/type/weapons/MineWeapon.java
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
package mindustry.type.weapons;
|
||||||
|
|
||||||
|
import arc.graphics.g2d.*;
|
||||||
|
import arc.math.*;
|
||||||
|
import arc.util.*;
|
||||||
|
import mindustry.entities.bullet.*;
|
||||||
|
import mindustry.entities.units.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.type.*;
|
||||||
|
|
||||||
|
public class MineWeapon extends Weapon{
|
||||||
|
public MineWeapon(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MineWeapon(String name){
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
rotate = true;
|
||||||
|
noAttack = true;
|
||||||
|
predictTarget = false;
|
||||||
|
display = false;
|
||||||
|
bullet = new BulletType();
|
||||||
|
useAttackRange = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Unit unit, WeaponMount mount){
|
||||||
|
mount.shoot = false;
|
||||||
|
mount.rotate = true;
|
||||||
|
|
||||||
|
//always aim at build plan
|
||||||
|
if(unit.mining()){
|
||||||
|
mount.aimX = unit.mineTile().drawx();
|
||||||
|
mount.aimY = unit.mineTile().drawy();
|
||||||
|
}else{
|
||||||
|
//aim for front
|
||||||
|
float weaponRotation = unit.rotation - 90 + baseRotation;
|
||||||
|
mount.aimX = unit.x + Angles.trnsx(unit.rotation - 90, x, y) + Angles.trnsx(weaponRotation, this.shootX, this.shootY);
|
||||||
|
mount.aimY = unit.y + Angles.trnsy(unit.rotation - 90, x, y) + Angles.trnsy(weaponRotation, this.shootX, this.shootY);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.update(unit, mount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Unit unit, WeaponMount mount){
|
||||||
|
super.draw(unit, mount);
|
||||||
|
|
||||||
|
if(unit.mining()){
|
||||||
|
float
|
||||||
|
z = Draw.z(),
|
||||||
|
rotation = unit.rotation - 90,
|
||||||
|
weaponRotation = rotation + (rotate ? mount.rotation : 0),
|
||||||
|
wx = unit.x + Angles.trnsx(rotation, x, y) + Angles.trnsx(weaponRotation, 0, -mount.recoil),
|
||||||
|
wy = unit.y + Angles.trnsy(rotation, x, y) + Angles.trnsy(weaponRotation, 0, -mount.recoil),
|
||||||
|
sY = shootY + Mathf.absin(Time.time, 1.1f, 0.5f),
|
||||||
|
px = wx + Angles.trnsx(weaponRotation, shootX, sY),
|
||||||
|
py = wy + Angles.trnsy(weaponRotation, shootX, sY);
|
||||||
|
|
||||||
|
unit.type.drawMiningBeam(unit, px, py);
|
||||||
|
Draw.z(z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user