Drownable legged units
This commit is contained in:
@@ -25,6 +25,7 @@ abstract class CrawlComp implements Posc, Rotc, Hitboxc, Unitc{
|
||||
@Import Team team;
|
||||
@Import Vec2 vel;
|
||||
|
||||
transient Floor lastDeepFloor;
|
||||
//TODO segments
|
||||
transient float lastCrawlSlowdown = 1f;
|
||||
transient float segmentRot, crawlTime;
|
||||
@@ -55,13 +56,20 @@ abstract class CrawlComp implements Posc, Rotc, Hitboxc, Unitc{
|
||||
segmentRot = rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Replace
|
||||
public Floor drownFloor(){
|
||||
return lastDeepFloor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
if(moving()){
|
||||
segmentRot = Angles.moveToward(segmentRot, rotation, type.segmentRotSpeed);
|
||||
|
||||
int radius = (int)Math.max(0, hitSize / tilesize);
|
||||
int count = 0, solids = 0;
|
||||
int count = 0, solids = 0, deeps = 0;
|
||||
lastDeepFloor = null;
|
||||
|
||||
//calculate tiles under this unit, and apply slowdown + particle effects
|
||||
for(int cx = -radius; cx <= radius; cx++){
|
||||
@@ -75,6 +83,11 @@ abstract class CrawlComp implements Posc, Rotc, Hitboxc, Unitc{
|
||||
solids ++;
|
||||
}
|
||||
|
||||
if(t.floor().isDeep()){
|
||||
deeps ++;
|
||||
lastDeepFloor = t.floor();
|
||||
}
|
||||
|
||||
if(t.build != null && t.build.team != team){
|
||||
t.build.damage(team, type.crawlDamage * Time.delta);
|
||||
}
|
||||
@@ -89,6 +102,11 @@ abstract class CrawlComp implements Posc, Rotc, Hitboxc, Unitc{
|
||||
}
|
||||
}
|
||||
|
||||
//when most blocks under this unit cannot be drowned in, do not drown
|
||||
if((float)deeps / count < 0.75f){
|
||||
lastDeepFloor = null;
|
||||
}
|
||||
|
||||
lastCrawlSlowdown = Mathf.lerp(1f, type.crawlSlowdown, Mathf.clamp((float)solids / count / type.crawlSlowdownFrac));
|
||||
}
|
||||
segmentRot = Angles.clampRange(segmentRot, rotation, type.segmentMaxRot);
|
||||
|
||||
Reference in New Issue
Block a user