Make ChildComp work with turrets (#9706)
This commit is contained in:
@@ -4,6 +4,7 @@ import arc.math.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
import mindustry.world.blocks.defense.turrets.BaseTurret.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
abstract class ChildComp implements Posc, Rotc{
|
abstract class ChildComp implements Posc, Rotc{
|
||||||
@@ -18,9 +19,14 @@ abstract class ChildComp implements Posc, Rotc{
|
|||||||
if(parent != null){
|
if(parent != null){
|
||||||
offsetX = x - parent.getX();
|
offsetX = x - parent.getX();
|
||||||
offsetY = y - parent.getY();
|
offsetY = y - parent.getY();
|
||||||
if(rotWithParent && parent instanceof Rotc r){
|
if(rotWithParent){
|
||||||
offsetPos = -r.rotation();
|
if(parent instanceof Rotc r){
|
||||||
offsetRot = rotation - r.rotation();
|
offsetPos = -r.rotation();
|
||||||
|
offsetRot = rotation - r.rotation();
|
||||||
|
}else if(parent instanceof BaseTurretBuild build){
|
||||||
|
offsetPos = -build.rotation;
|
||||||
|
offsetRot = rotation - build.rotation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,10 +34,16 @@ abstract class ChildComp implements Posc, Rotc{
|
|||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
if(parent != null){
|
if(parent != null){
|
||||||
if(rotWithParent && parent instanceof Rotc r){
|
if(rotWithParent){
|
||||||
x = parent.getX() + Angles.trnsx(r.rotation() + offsetPos, offsetX, offsetY);
|
if(parent instanceof Rotc r){
|
||||||
y = parent.getY() + Angles.trnsy(r.rotation() + offsetPos, offsetX, offsetY);
|
x = parent.getX() + Angles.trnsx(r.rotation() + offsetPos, offsetX, offsetY);
|
||||||
rotation = r.rotation() + offsetRot;
|
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{
|
}else{
|
||||||
x = parent.getX() + offsetX;
|
x = parent.getX() + offsetX;
|
||||||
y = parent.getY() + offsetY;
|
y = parent.getY() + offsetY;
|
||||||
|
|||||||
Reference in New Issue
Block a user