Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features
This commit is contained in:
@@ -7,6 +7,7 @@ import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
@@ -40,6 +41,7 @@ public class UnitSpawnAbility extends Ability{
|
||||
Unit u = this.unit.create(unit.team);
|
||||
u.set(x, y);
|
||||
u.rotation = unit.rotation;
|
||||
Events.fire(new UnitCreateEvent(u, null, unit));
|
||||
if(!Vars.net.client()){
|
||||
u.add();
|
||||
}
|
||||
|
||||
@@ -76,6 +76,17 @@ abstract class MechComp implements Posc, Flyingc, Hitboxc, Unitc, Mechc, Elevati
|
||||
return raw;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Replace
|
||||
public void rotateMove(Vec2 vec){
|
||||
//mechs use baseRotation to rotate, not rotation.
|
||||
moveAt(Tmp.v2.trns(baseRotation, vec.len()));
|
||||
|
||||
if(!vec.isZero()){
|
||||
baseRotation = Angles.moveToward(baseRotation, vec.angle(), type.rotateSpeed * Math.max(Time.delta, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveAt(Vec2 vector, float acceleration){
|
||||
//mark walking state when moving in a controlled manner
|
||||
|
||||
@@ -51,6 +51,15 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
private transient boolean wasPlayer;
|
||||
private transient boolean wasHealed;
|
||||
|
||||
/** Move based on preferred unit movement type. */
|
||||
public void movePref(Vec2 movement){
|
||||
if(type.omniMovement){
|
||||
moveAt(movement);
|
||||
}else{
|
||||
rotateMove(movement);
|
||||
}
|
||||
}
|
||||
|
||||
public void moveAt(Vec2 vector){
|
||||
moveAt(vector, type.accel);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,23 @@ public class AIController implements UnitController{
|
||||
}
|
||||
}
|
||||
|
||||
/** For ground units: Looks at the target, or the movement position. Does not apply to non-omni units. */
|
||||
public void faceTarget(){
|
||||
if(unit.type.omniMovement || unit instanceof Mechc){
|
||||
if(!Units.invalidateTarget(target, unit, unit.range()) && unit.type.rotateShooting && unit.type.hasWeapons()){
|
||||
unit.lookAt(Predict.intercept(unit, target, unit.type.weapons.first().bullet.speed));
|
||||
}else if(unit.moving()){
|
||||
unit.lookAt(unit.vel().angle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void faceMovement(){
|
||||
if((unit.type.omniMovement || unit instanceof Mechc) && unit.moving()){
|
||||
unit.lookAt(unit.vel().angle());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean invalid(Teamc target){
|
||||
return Units.invalidateTarget(target, unit.team, unit.x, unit.y);
|
||||
}
|
||||
@@ -89,7 +106,7 @@ public class AIController implements UnitController{
|
||||
|
||||
if(tile == targetTile || (costType == Pathfinder.costNaval && !targetTile.floor().isLiquid)) return;
|
||||
|
||||
unit.moveAt(vec.trns(unit.angleTo(targetTile.worldx(), targetTile.worldy()), unit.speed()));
|
||||
unit.movePref(vec.trns(unit.angleTo(targetTile.worldx(), targetTile.worldy()), unit.speed()));
|
||||
}
|
||||
|
||||
public void updateWeapons(){
|
||||
|
||||
25
core/src/mindustry/entities/units/UnitDecal.java
Normal file
25
core/src/mindustry/entities/units/UnitDecal.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package mindustry.entities.units;
|
||||
|
||||
import arc.graphics.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
/** A sprite drawn in addition to the base unit sprites. */
|
||||
public class UnitDecal{
|
||||
public String region = "error";
|
||||
public float x, y, rotation;
|
||||
public float layer = Layer.flyingUnit + 1f;
|
||||
public float xScale = 1f, yScale = 1f;
|
||||
public Color color = Color.white;
|
||||
|
||||
public UnitDecal(String region, float x, float y, float rotation, float layer, Color color){
|
||||
this.region = region;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.rotation = rotation;
|
||||
this.layer = layer;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public UnitDecal(){
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user