mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-22 02:07:20 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
1144871b29
@ -4,7 +4,7 @@ import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.blocks.defense.turrets.BaseTurret.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
@Component
|
||||
abstract class ChildComp implements Posc, Rotc{
|
||||
@ -23,9 +23,9 @@ abstract class ChildComp implements Posc, Rotc{
|
||||
if(parent instanceof Rotc r){
|
||||
offsetPos = -r.rotation();
|
||||
offsetRot = rotation - r.rotation();
|
||||
}else if(parent instanceof BaseTurretBuild build){
|
||||
offsetPos = -build.rotation;
|
||||
offsetRot = rotation - build.rotation;
|
||||
}else if(parent instanceof RotBlock rot){
|
||||
offsetPos = -rot.buildRotation();
|
||||
offsetRot = rotation - rot.buildRotation();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -39,10 +39,10 @@ abstract class ChildComp implements Posc, Rotc{
|
||||
x = parent.getX() + Angles.trnsx(r.rotation() + offsetPos, offsetX, offsetY);
|
||||
y = parent.getY() + Angles.trnsy(r.rotation() + offsetPos, offsetX, offsetY);
|
||||
rotation = r.rotation() + offsetRot;
|
||||
}else if(parent instanceof BaseTurretBuild build){
|
||||
x = parent.getX() + Angles.trnsx(build.rotation + offsetPos, offsetX, offsetY);
|
||||
y = parent.getY() + Angles.trnsy(build.rotation + offsetPos, offsetX, offsetY);
|
||||
rotation = build.rotation + offsetRot;
|
||||
}else if(parent instanceof RotBlock rot){
|
||||
x = parent.getX() + Angles.trnsx(rot.buildRotation() + offsetPos, offsetX, offsetY);
|
||||
y = parent.getY() + Angles.trnsy(rot.buildRotation() + offsetPos, offsetX, offsetY);
|
||||
rotation = rot.buildRotation() + offsetRot;
|
||||
}
|
||||
}else{
|
||||
x = parent.getX() + offsetX;
|
||||
|
@ -1270,6 +1270,7 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
DrawPart.params.life = s.fin();
|
||||
}
|
||||
|
||||
applyColor(unit);
|
||||
part.draw(DrawPart.params);
|
||||
}
|
||||
}
|
||||
|
@ -228,6 +228,7 @@ public class Weapon implements Cloneable{
|
||||
var part = parts.get(i);
|
||||
DrawPart.params.setRecoil(part.recoilIndex >= 0 && mount.recoils != null ? mount.recoils[part.recoilIndex] : mount.recoil);
|
||||
if(part.under){
|
||||
unit.type.applyColor(unit);
|
||||
part.draw(DrawPart.params);
|
||||
}
|
||||
}
|
||||
@ -262,6 +263,7 @@ public class Weapon implements Cloneable{
|
||||
var part = parts.get(i);
|
||||
DrawPart.params.setRecoil(part.recoilIndex >= 0 && mount.recoils != null ? mount.recoils[part.recoilIndex] : mount.recoil);
|
||||
if(!part.under){
|
||||
unit.type.applyColor(unit);
|
||||
part.draw(DrawPart.params);
|
||||
}
|
||||
}
|
||||
|
6
core/src/mindustry/world/blocks/RotBlock.java
Normal file
6
core/src/mindustry/world/blocks/RotBlock.java
Normal file
@ -0,0 +1,6 @@
|
||||
package mindustry.world.blocks;
|
||||
|
||||
/** Any block that has 360-degree rotation */
|
||||
public interface RotBlock{
|
||||
float buildRotation();
|
||||
}
|
@ -77,7 +77,7 @@ public class BuildTurret extends BaseTurret{
|
||||
return new TextureRegion[]{baseRegion, region};
|
||||
}
|
||||
|
||||
public class BuildTurretBuild extends BaseTurretBuild implements ControlBlock{
|
||||
public class BuildTurretBuild extends BaseTurretBuild implements ControlBlock, RotBlock{
|
||||
public BlockUnitc unit = (BlockUnitc)unitType.create(team);
|
||||
public @Nullable Unit following;
|
||||
public @Nullable BlockPlan lastPlan;
|
||||
@ -92,6 +92,11 @@ public class BuildTurret extends BaseTurret{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float buildRotation(){
|
||||
return unit.rotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Unit unit(){
|
||||
//make sure stats are correct
|
||||
|
@ -9,6 +9,7 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
@ -79,7 +80,7 @@ public class BaseTurret extends Block{
|
||||
stats.add(Stat.shootRange, range / tilesize, StatUnit.blocks);
|
||||
}
|
||||
|
||||
public class BaseTurretBuild extends Building implements Ranged{
|
||||
public class BaseTurretBuild extends Building implements Ranged, RotBlock{
|
||||
public float rotation = 90;
|
||||
|
||||
@Override
|
||||
@ -87,6 +88,11 @@ public class BaseTurret extends Block{
|
||||
return range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float buildRotation(){
|
||||
return rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
Drawf.dashCircle(x, y, range(), team.color);
|
||||
|
@ -18,6 +18,7 @@ import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@ -104,7 +105,7 @@ public class MassDriver extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
public class MassDriverBuild extends Building{
|
||||
public class MassDriverBuild extends Building implements RotBlock{
|
||||
public int link = -1;
|
||||
public float rotation = 90;
|
||||
public float reloadCounter = 0f;
|
||||
@ -112,6 +113,11 @@ public class MassDriver extends Block{
|
||||
//TODO use queue? this array usually holds about 3 shooters max anyway
|
||||
public OrderedSet<Building> waitingShooters = new OrderedSet<>();
|
||||
|
||||
@Override
|
||||
public float buildRotation(){
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public Building currentShooter(){
|
||||
return waitingShooters.isEmpty() ? null : waitingShooters.first();
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@ -126,7 +127,7 @@ public class PayloadMassDriver extends PayloadBlock{
|
||||
return new TextureRegion[]{leftRegion, rightRegion, capRegion};
|
||||
}
|
||||
|
||||
public class PayloadDriverBuild extends PayloadBlockBuild<Payload>{
|
||||
public class PayloadDriverBuild extends PayloadBlockBuild<Payload> implements RotBlock{
|
||||
public int link = -1;
|
||||
public float turretRotation = 90;
|
||||
public float reloadCounter = 0f, charge = 0f;
|
||||
@ -143,6 +144,11 @@ public class PayloadMassDriver extends PayloadBlock{
|
||||
return waitingShooters.isEmpty() ? null : waitingShooters.first();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float buildRotation(){
|
||||
return rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
super.updateTile();
|
||||
|
@ -16,6 +16,7 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
@ -147,11 +148,16 @@ public class RepairTurret extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
public class RepairPointBuild extends Building implements Ranged{
|
||||
public class RepairPointBuild extends Building implements Ranged, RotBlock{
|
||||
public Unit target;
|
||||
public Vec2 offset = new Vec2(), lastEnd = new Vec2();
|
||||
public float strength, rotation = 90;
|
||||
|
||||
@Override
|
||||
public float buildRotation(){
|
||||
return rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(baseRegion, x, y);
|
||||
|
Loading…
Reference in New Issue
Block a user