This commit is contained in:
Anuken
2020-02-07 13:02:24 -05:00
parent 861b3ac3f4
commit 4265d40024
6 changed files with 29 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
package mindustry.entities.def;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
@@ -9,6 +10,14 @@ abstract class LegsComp implements Posc, Flyingc, Hitboxc, DrawLayerGroundUnderc
float baseRotation, walkTime;
@Override
public void update(){
if(vel().len() > 0.5f){
baseRotation = vel().angle();
walkTime += Time.delta()*vel().len()/1f;
}
}
@Override
public void drawGroundUnder(){
type().drawLegs(this);

View File

@@ -96,6 +96,10 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
public void unit(Unitc unit){
if(unit == null) throw new IllegalArgumentException("Unit cannot be null. Use clearUnit() instead.");
if(this.unit != Nulls.unit){
//un-control the old unit
this.unit.controller(this.unit.type().createController());
}
this.unit = unit;
if(unit != Nulls.unit){
unit.team(team);

View File

@@ -1,6 +1,8 @@
package mindustry.entities.def;
import arc.*;
import arc.math.*;
import arc.math.geom.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
@@ -71,6 +73,14 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
return type;
}
public void lookAt(float angle){
rotation = Angles.moveToward(rotation, angle, type.rotateSpeed);
}
public void lookAt(Position pos){
lookAt(angleTo(pos));
}
@Override
public void update(){
//apply knockback based on spawns