mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
Made various fields/methods public
This commit is contained in:
parent
ada6ef229c
commit
e4742133ca
@ -87,7 +87,7 @@ public class Vars implements Loadable{
|
|||||||
public static final int maxNameLength = 40;
|
public static final int maxNameLength = 40;
|
||||||
/** displayed item size when ingame. */
|
/** displayed item size when ingame. */
|
||||||
public static final float itemSize = 5f;
|
public static final float itemSize = 5f;
|
||||||
/** units outside of this bound will die instantly */
|
/** units outside this bound will die instantly */
|
||||||
public static final float finalWorldBounds = 250;
|
public static final float finalWorldBounds = 250;
|
||||||
/** range for building */
|
/** range for building */
|
||||||
public static final float buildingRange = 220f;
|
public static final float buildingRange = 220f;
|
||||||
|
@ -16,9 +16,9 @@ public class BuilderAI extends AIController{
|
|||||||
public static float buildRadius = 1500, retreatDst = 110f, fleeRange = 370f, retreatDelay = Time.toSeconds * 2f;
|
public static float buildRadius = 1500, retreatDst = 110f, fleeRange = 370f, retreatDelay = Time.toSeconds * 2f;
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
float retreatTimer;
|
||||||
@Nullable Unit following;
|
@Nullable Unit following;
|
||||||
@Nullable Teamc enemy;
|
@Nullable Teamc enemy;
|
||||||
float retreatTimer;
|
|
||||||
@Nullable BlockPlan lastPlan;
|
@Nullable BlockPlan lastPlan;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,12 +21,12 @@ public class DefenderAI extends AIController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateTargeting(){
|
public void updateTargeting(){
|
||||||
if(retarget()) target = findTarget(unit.x, unit.y, unit.range(), true, true);
|
if(retarget()) target = findTarget(unit.x, unit.y, unit.range(), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Teamc findTarget(float x, float y, float range, boolean air, boolean ground){
|
public Teamc findTarget(float x, float y, float range, boolean air, boolean ground){
|
||||||
|
|
||||||
//find unit to follow if not in rally mode
|
//find unit to follow if not in rally mode
|
||||||
if(command() != UnitCommand.rally){
|
if(command() != UnitCommand.rally){
|
||||||
|
@ -32,7 +32,7 @@ public class FlyingAI extends AIController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Teamc findTarget(float x, float y, float range, boolean air, boolean ground){
|
public Teamc findTarget(float x, float y, float range, boolean air, boolean ground){
|
||||||
var result = findMainTarget(x, y, range, air, ground);
|
var result = findMainTarget(x, y, range, air, ground);
|
||||||
|
|
||||||
//if the main target is in range, use it, otherwise target whatever is closest
|
//if the main target is in range, use it, otherwise target whatever is closest
|
||||||
@ -40,7 +40,7 @@ public class FlyingAI extends AIController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Teamc findMainTarget(float x, float y, float range, boolean air, boolean ground){
|
public Teamc findMainTarget(float x, float y, float range, boolean air, boolean ground){
|
||||||
var core = targetFlag(x, y, BlockFlag.core, true);
|
var core = targetFlag(x, y, BlockFlag.core, true);
|
||||||
|
|
||||||
if(core != null && Mathf.within(x, y, core.getX(), core.getY(), range)){
|
if(core != null && Mathf.within(x, y, core.getX(), core.getY(), range)){
|
||||||
|
@ -44,7 +44,7 @@ public class LogicAI extends AIController{
|
|||||||
private ObjectSet<Object> radars = new ObjectSet<>();
|
private ObjectSet<Object> radars = new ObjectSet<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateMovement(){
|
public void updateMovement(){
|
||||||
if(itemTimer >= 0) itemTimer -= Time.delta;
|
if(itemTimer >= 0) itemTimer -= Time.delta;
|
||||||
if(payTimer >= 0) payTimer -= Time.delta;
|
if(payTimer >= 0) payTimer -= Time.delta;
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ public class LogicAI extends AIController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void moveTo(Position target, float circleLength, float smooth){
|
public void moveTo(Position target, float circleLength, float smooth){
|
||||||
if(target == null) return;
|
if(target == null) return;
|
||||||
|
|
||||||
vec.set(target).sub(unit);
|
vec.set(target).sub(unit);
|
||||||
@ -141,29 +141,29 @@ public class LogicAI extends AIController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean checkTarget(Teamc target, float x, float y, float range){
|
public boolean checkTarget(Teamc target, float x, float y, float range){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//always retarget
|
//always retarget
|
||||||
@Override
|
@Override
|
||||||
protected boolean retarget(){
|
public boolean retarget(){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean invalid(Teamc target){
|
public boolean invalid(Teamc target){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldShoot(){
|
public boolean shouldShoot(){
|
||||||
return shoot && !(unit.type.canBoost && boost);
|
return shoot && !(unit.type.canBoost && boost);
|
||||||
}
|
}
|
||||||
|
|
||||||
//always aim for the main target
|
//always aim for the main target
|
||||||
@Override
|
@Override
|
||||||
protected Teamc target(float x, float y, float range, boolean air, boolean ground){
|
public Teamc target(float x, float y, float range, boolean air, boolean ground){
|
||||||
return switch(aimControl){
|
return switch(aimControl){
|
||||||
case target -> posTarget;
|
case target -> posTarget;
|
||||||
case targetp -> mainTarget;
|
case targetp -> mainTarget;
|
||||||
|
@ -14,7 +14,7 @@ public class MinerAI extends AIController{
|
|||||||
Tile ore;
|
Tile ore;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateMovement(){
|
public void updateMovement(){
|
||||||
Building core = unit.closestCore();
|
Building core = unit.closestCore();
|
||||||
|
|
||||||
if(!(unit.canMine()) || core == null) return;
|
if(!(unit.canMine()) || core == null) return;
|
||||||
|
@ -13,7 +13,7 @@ public class RepairAI extends AIController{
|
|||||||
float retreatTimer;
|
float retreatTimer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateMovement(){
|
public void updateMovement(){
|
||||||
if(target instanceof Building){
|
if(target instanceof Building){
|
||||||
boolean shoot = false;
|
boolean shoot = false;
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ public class RepairAI extends AIController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateTargeting(){
|
public void updateTargeting(){
|
||||||
Building target = Units.findDamagedTile(unit.team, unit.x, unit.y);
|
Building target = Units.findDamagedTile(unit.team, unit.x, unit.y);
|
||||||
|
|
||||||
if(target instanceof ConstructBuild) target = null;
|
if(target instanceof ConstructBuild) target = null;
|
||||||
|
@ -111,7 +111,7 @@ public class SuicideAI extends GroundAI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Teamc target(float x, float y, float range, boolean air, boolean ground){
|
public Teamc target(float x, float y, float range, boolean air, boolean ground){
|
||||||
return Units.closestTarget(unit.team, x, y, range, u -> u.checkTarget(air, ground), t -> ground &&
|
return Units.closestTarget(unit.team, x, y, range, u -> u.checkTarget(air, ground), t -> ground &&
|
||||||
!(t.block instanceof Conveyor || t.block instanceof Conduit)); //do not target conveyors/conduits
|
!(t.block instanceof Conveyor || t.block instanceof Conduit)); //do not target conveyors/conduits
|
||||||
}
|
}
|
||||||
|
@ -393,12 +393,6 @@ public class Fx{
|
|||||||
Lines.circle(e.x, e.y, 2f + e.finpow() * 7f);
|
Lines.circle(e.x, e.y, 2f + e.finpow() * 7f);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
healDenamic = new Effect(11, e -> {
|
|
||||||
color(Pal.heal);
|
|
||||||
stroke(e.fout() * 2f);
|
|
||||||
Lines.circle(e.x, e.y, 2f + e.finpow() * e.rotation);
|
|
||||||
}),
|
|
||||||
|
|
||||||
shieldWave = new Effect(22, e -> {
|
shieldWave = new Effect(22, e -> {
|
||||||
color(e.color, 0.7f);
|
color(e.color, 0.7f);
|
||||||
stroke(e.fout() * 2f);
|
stroke(e.fout() * 2f);
|
||||||
@ -1000,7 +994,9 @@ public class Fx{
|
|||||||
float length = 20f * e.finpow();
|
float length = 20f * e.finpow();
|
||||||
float size = 7f * e.fout();
|
float size = 7f * e.fout();
|
||||||
|
|
||||||
rect(((Item)e.data).fullIcon, e.x + trnsx(e.rotation, length), e.y + trnsy(e.rotation, length), size, size);
|
if(!(e.data instanceof Item item)) return;
|
||||||
|
|
||||||
|
rect(item.fullIcon, e.x + trnsx(e.rotation, length), e.y + trnsy(e.rotation, length), size, size);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
shockwave = new Effect(10f, 80f, e -> {
|
shockwave = new Effect(10f, 80f, e -> {
|
||||||
|
@ -19,7 +19,8 @@ import static mindustry.Vars.*;
|
|||||||
public class Effect{
|
public class Effect{
|
||||||
private static final float shakeFalloff = 10000f;
|
private static final float shakeFalloff = 10000f;
|
||||||
private static final EffectContainer container = new EffectContainer();
|
private static final EffectContainer container = new EffectContainer();
|
||||||
private static final Seq<Effect> all = new Seq<>();
|
|
||||||
|
public static final Seq<Effect> all = new Seq<>();
|
||||||
|
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
|
|
||||||
|
@ -46,19 +46,19 @@ public class AIController implements UnitController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
protected AIController fallback(){
|
public AIController fallback(){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean useFallback(){
|
public boolean useFallback(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UnitCommand command(){
|
public UnitCommand command(){
|
||||||
return unit.team.data().command;
|
return unit.team.data().command;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateVisuals(){
|
public void updateVisuals(){
|
||||||
if(unit.isFlying()){
|
if(unit.isFlying()){
|
||||||
unit.wobble();
|
unit.wobble();
|
||||||
|
|
||||||
@ -66,21 +66,21 @@ public class AIController implements UnitController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateMovement(){
|
public void updateMovement(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateTargeting(){
|
public void updateTargeting(){
|
||||||
if(unit.hasWeapons()){
|
if(unit.hasWeapons()){
|
||||||
updateWeapons();
|
updateWeapons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean invalid(Teamc target){
|
public boolean invalid(Teamc target){
|
||||||
return Units.invalidateTarget(target, unit.team, unit.x, unit.y);
|
return Units.invalidateTarget(target, unit.team, unit.x, unit.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void pathfind(int pathTarget){
|
public void pathfind(int pathTarget){
|
||||||
int costType = unit.pathType();
|
int costType = unit.pathType();
|
||||||
|
|
||||||
Tile tile = unit.tileOn();
|
Tile tile = unit.tileOn();
|
||||||
@ -92,7 +92,7 @@ public class AIController implements UnitController{
|
|||||||
unit.moveAt(vec.trns(unit.angleTo(targetTile.worldx(), targetTile.worldy()), unit.speed()));
|
unit.moveAt(vec.trns(unit.angleTo(targetTile.worldx(), targetTile.worldy()), unit.speed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateWeapons(){
|
public void updateWeapons(){
|
||||||
float rotation = unit.rotation - 90;
|
float rotation = unit.rotation - 90;
|
||||||
boolean ret = retarget();
|
boolean ret = retarget();
|
||||||
|
|
||||||
@ -146,45 +146,45 @@ public class AIController implements UnitController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean checkTarget(Teamc target, float x, float y, float range){
|
public boolean checkTarget(Teamc target, float x, float y, float range){
|
||||||
return Units.invalidateTarget(target, unit.team, x, y, range);
|
return Units.invalidateTarget(target, unit.team, x, y, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean shouldShoot(){
|
public boolean shouldShoot(){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Teamc targetFlag(float x, float y, BlockFlag flag, boolean enemy){
|
public Teamc targetFlag(float x, float y, BlockFlag flag, boolean enemy){
|
||||||
if(unit.team == Team.derelict) return null;
|
if(unit.team == Team.derelict) return null;
|
||||||
Tile target = Geometry.findClosest(x, y, enemy ? indexer.getEnemy(unit.team, flag) : indexer.getAllied(unit.team, flag));
|
Tile target = Geometry.findClosest(x, y, enemy ? indexer.getEnemy(unit.team, flag) : indexer.getAllied(unit.team, flag));
|
||||||
return target == null ? null : target.build;
|
return target == null ? null : target.build;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Teamc target(float x, float y, float range, boolean air, boolean ground){
|
public Teamc target(float x, float y, float range, boolean air, boolean ground){
|
||||||
return Units.closestTarget(unit.team, x, y, range, u -> u.checkTarget(air, ground), t -> ground);
|
return Units.closestTarget(unit.team, x, y, range, u -> u.checkTarget(air, ground), t -> ground);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean retarget(){
|
public boolean retarget(){
|
||||||
return timer.get(timerTarget, target == null ? 40 : 90);
|
return timer.get(timerTarget, target == null ? 40 : 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Teamc findMainTarget(float x, float y, float range, boolean air, boolean ground){
|
public Teamc findMainTarget(float x, float y, float range, boolean air, boolean ground){
|
||||||
return findTarget(x, y, range, air, ground);
|
return findTarget(x, y, range, air, ground);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Teamc findTarget(float x, float y, float range, boolean air, boolean ground){
|
public Teamc findTarget(float x, float y, float range, boolean air, boolean ground){
|
||||||
return target(x, y, range, air, ground);
|
return target(x, y, range, air, ground);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void init(){
|
public void init(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected @Nullable Tile getClosestSpawner(){
|
public @Nullable Tile getClosestSpawner(){
|
||||||
return Geometry.findClosest(unit.x, unit.y, Vars.spawner.getSpawns());
|
return Geometry.findClosest(unit.x, unit.y, Vars.spawner.getSpawns());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void unloadPayloads(){
|
public void unloadPayloads(){
|
||||||
if(unit instanceof Payloadc pay && pay.hasPayload() && target instanceof Building && pay.payloads().peek() instanceof UnitPayload){
|
if(unit instanceof Payloadc pay && pay.hasPayload() && target instanceof Building && pay.payloads().peek() instanceof UnitPayload){
|
||||||
if(target.within(unit, Math.max(unit.type().range + 1f, 75f))){
|
if(target.within(unit, Math.max(unit.type().range + 1f, 75f))){
|
||||||
pay.dropLastPayload();
|
pay.dropLastPayload();
|
||||||
@ -192,11 +192,11 @@ public class AIController implements UnitController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void circle(Position target, float circleLength){
|
public void circle(Position target, float circleLength){
|
||||||
circle(target, circleLength, unit.speed());
|
circle(target, circleLength, unit.speed());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void circle(Position target, float circleLength, float speed){
|
public void circle(Position target, float circleLength, float speed){
|
||||||
if(target == null) return;
|
if(target == null) return;
|
||||||
|
|
||||||
vec.set(target).sub(unit);
|
vec.set(target).sub(unit);
|
||||||
@ -210,11 +210,11 @@ public class AIController implements UnitController{
|
|||||||
unit.moveAt(vec);
|
unit.moveAt(vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveTo(Position target, float circleLength){
|
public void moveTo(Position target, float circleLength){
|
||||||
moveTo(target, circleLength, 100f);
|
moveTo(target, circleLength, 100f);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveTo(Position target, float circleLength, float smooth){
|
public void moveTo(Position target, float circleLength, float smooth){
|
||||||
if(target == null) return;
|
if(target == null) return;
|
||||||
|
|
||||||
vec.set(target).sub(unit);
|
vec.set(target).sub(unit);
|
||||||
|
@ -38,8 +38,8 @@ public class LaserTurret extends PowerTurret{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class LaserTurretBuild extends PowerTurretBuild{
|
public class LaserTurretBuild extends PowerTurretBuild{
|
||||||
Bullet bullet;
|
public Bullet bullet;
|
||||||
float bulletLife;
|
public float bulletLife;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateCooling(){
|
protected void updateCooling(){
|
||||||
|
Loading…
Reference in New Issue
Block a user