Movement
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user