#9706 done smarter (#9723)

* Convert from explicit check to interface

* Apply the interface to other turret-like blocks
This commit is contained in:
MEEPofFaith
2024-04-09 08:16:49 -07:00
committed by GitHub
parent 17913f8949
commit fd303524e9
7 changed files with 48 additions and 13 deletions

View File

@@ -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;