This commit is contained in:
Anuken
2020-02-10 10:47:21 -05:00
parent 0ad8408ba9
commit 6c6861a97a
10 changed files with 40 additions and 250 deletions

View File

@@ -57,6 +57,23 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
controller(controller);
}
@Override
public void collision(Hitboxc other, float x, float y){
if(!(other instanceof Unitc)) return;
Unitc unit = (Unitc)other;
if(isGrounded() != unit.isGrounded()) return;
float scale = 2f;
hitbox(Tmp.r1);
other.hitbox(Tmp.r2);
Vec2 v = Geometry.overlap(Tmp.r1, Tmp.r2, true);
float tm = mass() + unit.mass();
float s1 = mass() / tm, s2 = unit.mass() / tm;
move(v.x*s2/scale, v.y*s2/scale);
unit.move(-v.x*s1/scale, -v.y*s1/scale);
}
@Override
public void type(UnitDef type){
this.type = type;