Leg collision bugfixes
This commit is contained in:
@@ -195,6 +195,7 @@ public class WaveSpawner{
|
||||
unit.apply(StatusEffects.unmoving, 30f);
|
||||
unit.apply(StatusEffects.invincible, 60f);
|
||||
unit.add();
|
||||
unit.unloaded();
|
||||
|
||||
Call.spawnEffect(unit.x, unit.y, unit.rotation, unit.type);
|
||||
}
|
||||
|
||||
@@ -50,10 +50,18 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc{
|
||||
resetLegs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unloaded(){
|
||||
resetLegs(1f);
|
||||
}
|
||||
|
||||
public void resetLegs(){
|
||||
resetLegs(type.legLength);
|
||||
}
|
||||
|
||||
public void resetLegs(float legLength){
|
||||
float rot = baseRotation;
|
||||
int count = type.legCount;
|
||||
float legLength = type.legLength;
|
||||
|
||||
this.legs = new Leg[count];
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc, Unitc{
|
||||
//decrement count to prevent double increment
|
||||
if(!u.isAdded()) u.team.data().updateCount(u.type, -1);
|
||||
u.add();
|
||||
u.unloaded();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,11 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
private transient boolean wasPlayer;
|
||||
private transient boolean wasHealed;
|
||||
|
||||
/** Called when this unit was unloaded from a factory or spawn point. */
|
||||
public void unloaded(){
|
||||
|
||||
}
|
||||
|
||||
/** Move based on preferred unit movement type. */
|
||||
public void movePref(Vec2 movement){
|
||||
if(type.omniMovement){
|
||||
|
||||
@@ -72,7 +72,7 @@ public class UnitType extends UnlockableContent{
|
||||
public float commandRadius = 150f;
|
||||
public float visualElevation = -1f;
|
||||
/** If true and this is a legged unit, this unit can walk over blocks. */
|
||||
public boolean allowLegStep = true;
|
||||
public boolean allowLegStep = false;
|
||||
/** If true, this unit cannot drown, and will not be affected by the floor under it. */
|
||||
public boolean hovering = false;
|
||||
public boolean omniMovement = true;
|
||||
@@ -327,6 +327,8 @@ public class UnitType extends UnlockableContent{
|
||||
|
||||
Unit example = constructor.get();
|
||||
|
||||
allowLegStep = example instanceof Legsc;
|
||||
|
||||
//water preset
|
||||
if(example instanceof WaterMovec){
|
||||
canDrown = false;
|
||||
|
||||
@@ -105,7 +105,7 @@ public class UnitPayload implements Payload{
|
||||
if(solid.solid(tx, ty)) return false;
|
||||
}
|
||||
|
||||
//cannnot dump when there's a lot of overlap going on
|
||||
//cannot dump when there's a lot of overlap going on
|
||||
if(!unit.type.flying && Units.count(unit.x, unit.y, unit.physicSize(), o -> o.isGrounded() && (o.type.allowLegStep == unit.type.allowLegStep)) > 0){
|
||||
return false;
|
||||
}
|
||||
@@ -116,6 +116,7 @@ public class UnitPayload implements Payload{
|
||||
//prevents stacking
|
||||
unit.vel.add(Mathf.range(0.5f), Mathf.range(0.5f));
|
||||
unit.add();
|
||||
unit.unloaded();
|
||||
Events.fire(new UnitUnloadEvent(unit));
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user