mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
Merge branch 'mining-beam-weapon' of https://github.com/MEEPofFaith/Mindustry into MEEPofFaith-mining-beam-weapon
This commit is contained in:
commit
02d56d27db
@ -113,8 +113,10 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
buildSpeed = -1f,
|
||||
/** Minimum distance from this unit that weapons can target. Prevents units from firing "inside" the unit. */
|
||||
aimDst = -1f,
|
||||
/** Visual offset of build beam from front. */
|
||||
/** Visual offset of the build beam from the front. */
|
||||
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. */
|
||||
targetPriority = 0f,
|
||||
/** Elevation of shadow drawn under this (ground) unit. Visual only. */
|
||||
@ -236,6 +238,8 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
squareShape = false,
|
||||
/** if true, this unit will draw its building beam towards blocks. */
|
||||
drawBuildBeam = true,
|
||||
/** if true, this unit will draw its mining beam towards blocks */
|
||||
drawMineBeam = true,
|
||||
/** if false, the team indicator/cell is not drawn. */
|
||||
drawCell = true,
|
||||
/** if false, carried items are not drawn. */
|
||||
@ -803,6 +807,8 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
}).layer(Layer.debris);
|
||||
}
|
||||
|
||||
if(mineBeamOffset == Float.NEGATIVE_INFINITY) mineBeamOffset = hitSize / 2;
|
||||
|
||||
for(Ability ab : abilities){
|
||||
ab.init(this);
|
||||
}
|
||||
@ -1226,7 +1232,6 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
if(unit.inFogTo(Vars.player.team())) return;
|
||||
|
||||
unit.drawBuilding();
|
||||
|
||||
drawMining(unit);
|
||||
|
||||
boolean isPayload = !unit.isAdded();
|
||||
@ -1339,16 +1344,21 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
return shieldColor == null ? unit.team.color : shieldColor;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
float focusLen = unit.hitSize / 2f + Mathf.absin(Time.time, 1.1f, 0.5f);
|
||||
float swingScl = 12f, swingMag = tilesize / 8f;
|
||||
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 ey = unit.mineTile.worldy() + Mathf.sin(Time.time + 48, swingScl + 2f, swingMag);
|
||||
|
||||
@ -1356,8 +1366,7 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
|
||||
Draw.color(Color.lightGray, Color.white, 1f - flashScl + Mathf.absin(Time.time, 0.5f, flashScl));
|
||||
|
||||
Draw.alpha(Renderer.unitLaserOpacity);
|
||||
Drawf.laser(mineLaserRegion, mineLaserEndRegion, px, py, ex, ey, 0.75f);
|
||||
Drawf.laser(Core.atlas.find("minelaser"), Core.atlas.find("minelaser-end"), px, py, ex, ey, 0.75f);
|
||||
|
||||
if(unit.isLocal()){
|
||||
Lines.stroke(1f, Pal.accent);
|
||||
|
@ -11,7 +11,7 @@ import mindustry.type.*;
|
||||
public class BuildWeapon extends Weapon{
|
||||
|
||||
public BuildWeapon(){
|
||||
|
||||
super();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user