mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-10-01 18:50:27 +03:00
Naval unit collisions + ramming with conveyors
This commit is contained in:
@@ -8,6 +8,7 @@ import arc.struct.*;
|
||||
import arc.util.TaskQueue;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
@@ -262,7 +263,7 @@ public class Pathfinder implements Runnable{
|
||||
tile.build == null || !solid || tile.block() instanceof CoreBlock ? 0 : Math.min((int)(tile.build.health / 40), 80),
|
||||
tid == 0 && tile.build != null && state.rules.coreCapture ? 255 : tid, //use teamid = 255 when core capture is enabled to mark out derelict structures
|
||||
solid,
|
||||
tile.floor().isLiquid && !tile.block().solid,
|
||||
tile.floor().isLiquid && tile.block() == Blocks.air,
|
||||
tile.legSolid(),
|
||||
nearLiquid,
|
||||
nearGround,
|
||||
|
||||
@@ -1583,6 +1583,7 @@ public class UnitTypes{
|
||||
accel = 0.4f;
|
||||
rotateSpeed = 3.3f;
|
||||
faceTarget = false;
|
||||
crushDamage = 6f;
|
||||
|
||||
trailLength = 20;
|
||||
waveTrailX = 4f;
|
||||
@@ -1644,6 +1645,9 @@ public class UnitTypes{
|
||||
accel = 0.3f;
|
||||
rotateSpeed = 2.6f;
|
||||
faceTarget = false;
|
||||
crushDamage = 8f;
|
||||
crushRadX = 1;
|
||||
crushRadY = 2;
|
||||
|
||||
moveSoundVolume = 0.55f;
|
||||
moveSoundPitchMin = moveSoundPitchMax = 0.9f;
|
||||
@@ -1706,6 +1710,9 @@ public class UnitTypes{
|
||||
hitSize = 20f;
|
||||
armor = 7f;
|
||||
faceTarget = false;
|
||||
crushDamage = 12f;
|
||||
crushRadX = 1;
|
||||
crushRadY = 2;
|
||||
|
||||
moveSoundVolume = 0.7f;
|
||||
moveSoundPitchMin = moveSoundPitchMax = 0.77f;
|
||||
@@ -1805,6 +1812,9 @@ public class UnitTypes{
|
||||
accel = 0.2f;
|
||||
rotateSpeed = 1.3f;
|
||||
faceTarget = false;
|
||||
crushDamage = 15f;
|
||||
crushRadX = 2;
|
||||
crushRadY = 3;
|
||||
|
||||
moveSoundVolume = 1f;
|
||||
moveSound = Sounds.shipMoveBig;
|
||||
@@ -1898,6 +1908,9 @@ public class UnitTypes{
|
||||
accel = 0.19f;
|
||||
rotateSpeed = 0.9f;
|
||||
faceTarget = false;
|
||||
crushDamage = 17f;
|
||||
crushRadX = 2;
|
||||
crushRadY = 5;
|
||||
|
||||
moveSoundVolume = 1.1f;
|
||||
moveSound = Sounds.shipMoveBig;
|
||||
@@ -1953,6 +1966,7 @@ public class UnitTypes{
|
||||
faceTarget = false;
|
||||
range = 100f;
|
||||
armor = 3f;
|
||||
crushDamage = 6f;
|
||||
|
||||
moveSoundVolume = 0.4f;
|
||||
moveSound = Sounds.shipMove;
|
||||
@@ -2057,6 +2071,7 @@ public class UnitTypes{
|
||||
accel = 0.4f;
|
||||
rotateSpeed = 4f;
|
||||
faceTarget = false;
|
||||
crushDamage = 8f;
|
||||
|
||||
moveSoundVolume = 0.55f;
|
||||
moveSoundPitchMin = moveSoundPitchMax = 0.9f;
|
||||
@@ -2138,6 +2153,8 @@ public class UnitTypes{
|
||||
hitSize = 20f;
|
||||
armor = 6f;
|
||||
faceTarget = false;
|
||||
crushDamage = 12f;
|
||||
crushRadY = 2;
|
||||
|
||||
moveSoundVolume = 0.7f;
|
||||
moveSoundPitchMin = moveSoundPitchMax = 0.77f;
|
||||
@@ -2273,6 +2290,7 @@ public class UnitTypes{
|
||||
aegires = new UnitType("aegires"){{
|
||||
health = 12000;
|
||||
armor = 12f;
|
||||
crushDamage = 15f;
|
||||
|
||||
speed = 0.7f;
|
||||
drag = 0.17f;
|
||||
@@ -2280,6 +2298,8 @@ public class UnitTypes{
|
||||
accel = 0.2f;
|
||||
rotateSpeed = 1.4f;
|
||||
faceTarget = false;
|
||||
crushRadX = 2;
|
||||
crushRadY = 3;
|
||||
|
||||
moveSoundVolume = 1f;
|
||||
moveSound = Sounds.shipMoveBig;
|
||||
@@ -2331,6 +2351,9 @@ public class UnitTypes{
|
||||
accel = 0.2f;
|
||||
rotateSpeed = 1.1f;
|
||||
faceTarget = false;
|
||||
crushDamage = 17f;
|
||||
crushRadX = 3;
|
||||
crushRadY = 5;
|
||||
|
||||
moveSoundVolume = 1.1f;
|
||||
moveSound = Sounds.shipMoveBig;
|
||||
|
||||
@@ -5,6 +5,7 @@ import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
@@ -133,7 +134,7 @@ public class EntityCollisions{
|
||||
|
||||
public static boolean waterSolid(int x, int y){
|
||||
Tile tile = world.tile(x, y);
|
||||
return tile == null || tile.solid() || !tile.floor().isLiquid;
|
||||
return tile == null || tile.solid() || !tile.floor().isLiquid || tile.block() != Blocks.air;
|
||||
}
|
||||
|
||||
public static boolean solid(int x, int y){
|
||||
|
||||
@@ -4,10 +4,12 @@ import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.EntityCollisions.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
@@ -18,11 +20,16 @@ import static mindustry.Vars.*;
|
||||
|
||||
@Component
|
||||
abstract class WaterMoveComp implements Posc, Velc, Hitboxc, Unitc{
|
||||
private static final float crushInterval = 5f;
|
||||
|
||||
@Import Team team;
|
||||
@Import boolean disarmed;
|
||||
@Import float x, y, rotation, speedMultiplier;
|
||||
@Import UnitType type;
|
||||
|
||||
private transient Trail tleft = new Trail(1), tright = new Trail(1);
|
||||
private transient Color trailColor = Blocks.water.mapColor.cpy().mul(1.5f);
|
||||
private transient float crushTimer = Mathf.random(crushInterval);
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
@@ -35,6 +42,22 @@ abstract class WaterMoveComp implements Posc, Velc, Hitboxc, Unitc{
|
||||
float cx = Angles.trnsx(rotation - 90, type.waveTrailX * sign, type.waveTrailY) + x, cy = Angles.trnsy(rotation - 90, type.waveTrailX * sign, type.waveTrailY) + y;
|
||||
t.update(cx, cy, world.floorWorld(cx, cy).isLiquid && !flying ? 1 : 0);
|
||||
}
|
||||
|
||||
if(type.crushDamage > 0 && !disarmed){
|
||||
if((crushTimer += Time.delta) >= crushInterval){
|
||||
crushTimer %= crushInterval;
|
||||
|
||||
for(int cx = -type.crushRadX; cx <= type.crushRadX; cx++){
|
||||
for(int cy = -type.crushRadY; cy <= type.crushRadY; cy++){
|
||||
Tmp.v1.trns(rotation - 90f, cx * tilesize, cy * tilesize);
|
||||
var other = Vars.world.buildWorld(x + Tmp.v1.x, y + Tmp.v1.y);
|
||||
if(other != null && other.team != team && other.floor().isLiquid && !other.block.solid){
|
||||
other.damage(team, type.crushFragile && other.block.crushFragile ? 99999999f : type.crushDamage * crushInterval);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -499,6 +499,9 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
/** the fraction of solids under this block necessary for it to reach crawlSlowdown. */
|
||||
crawlSlowdownFrac = 0.55f;
|
||||
|
||||
/** for naval units only: crush rectangle half-extents, rotated with the unit */
|
||||
public int crushRadX = 1, crushRadY = 1;
|
||||
|
||||
//MISSILE UNITS
|
||||
|
||||
/** lifetime of this missile. */
|
||||
|
||||
Reference in New Issue
Block a user