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