Repair beam weapon snap

This commit is contained in:
Anuken
2022-02-08 14:49:31 -05:00
parent fc3f17ba97
commit b4a9d546aa
2 changed files with 15 additions and 7 deletions

View File

@@ -3154,7 +3154,7 @@ public class UnitTypes{
weapons.add(new RepairBeamWeapon(){{
widthSinMag = 0.11f;
reload = 25f;
reload = 20f;
x = 0f;
y = 6.5f;
rotate = false;
@@ -3211,7 +3211,7 @@ public class UnitTypes{
weapons.add(new RepairBeamWeapon(){{
widthSinMag = 0.11f;
reload = 25f;
reload = 20f;
x = 0f;
y = 7.5f;
rotate = false;
@@ -3280,7 +3280,7 @@ public class UnitTypes{
weapons.add(new RepairBeamWeapon(){{
widthSinMag = 0.11f;
reload = 25f;
reload = 20f;
x = 19f/4f;
y = 19f/4f;
rotate = false;

View File

@@ -17,6 +17,8 @@ import mindustry.type.*;
import mindustry.world.blocks.units.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
/**
* Note that this weapon requires a bullet with a positive maxRange.
* Rotation must be set to true. Fixed repair points are not supported.
@@ -122,10 +124,16 @@ public class RepairBeamWeapon extends Weapon{
heal.lastEnd.sub(wx, wy).limit(range()).add(wx, wy);
if(targetBuildings){
var build = Vars.world.buildWorld(mount.aimX, mount.aimY);
if(build != null && build.team == unit.team){
heal.target = build;
}
//snap to closest building
Vars.world.raycastEachWorld(wx, wy, mount.aimX, mount.aimY, (x, y) -> {
var build = Vars.world.build(x, y);
if(build != null && build.team == unit.team && build.damaged()){
heal.target = build;
heal.lastEnd.set(x * tilesize, y * tilesize);
return true;
}
return false;
});
}
if(targetUnits){
//TODO does not support healing units manually yet