Circle collision initial commit
This commit is contained in:
@@ -487,10 +487,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
updateMech();
|
||||
}
|
||||
|
||||
if(isLocal){
|
||||
avoidOthers(8f);
|
||||
}
|
||||
|
||||
updateBuilding(this);
|
||||
|
||||
x = Mathf.clamp(x, 0, world.width() * tilesize);
|
||||
|
||||
@@ -15,7 +15,6 @@ import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.EntityPhysics;
|
||||
import io.anuke.ucore.entities.impl.DestructibleEntity;
|
||||
import io.anuke.ucore.entities.trait.DamageTrait;
|
||||
import io.anuke.ucore.entities.trait.DrawTrait;
|
||||
@@ -193,17 +192,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
return tile == null ? (Floor) Blocks.air : tile.floor();
|
||||
}
|
||||
|
||||
public void avoidOthers(float avoidRange){
|
||||
|
||||
EntityPhysics.getNearby(getGroup(), x, y, avoidRange * 2f, t -> {
|
||||
if(t == this || (t instanceof Unit && (((Unit) t).isDead() || (((Unit) t).isFlying() != isFlying()) || ((Unit) t).getCarrier() == this) || getCarrier() == t))
|
||||
return;
|
||||
float dst = distanceTo(t);
|
||||
if(dst > avoidRange) return;
|
||||
velocity.add(moveVector.set(x, y).sub(t.getX(), t.getY()).setLength(1f * (1f - (dst / avoidRange)) / getMass()));
|
||||
});
|
||||
}
|
||||
|
||||
/**Updates velocity and status effects.*/
|
||||
public void updateVelocityStatus(float drag, float maxVelocity){
|
||||
Floor floor = getFloorOn();
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.EntityPhysics;
|
||||
import io.anuke.ucore.entities.EntityQuery;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.function.Predicate;
|
||||
import io.anuke.ucore.util.EnumSet;
|
||||
@@ -213,11 +213,11 @@ public class Units{
|
||||
|
||||
EntityGroup<BaseUnit> group = unitGroups[team.ordinal()];
|
||||
if(!group.isEmpty()){
|
||||
EntityPhysics.getNearby(group, rect, entity -> cons.accept((Unit) entity));
|
||||
EntityQuery.getNearby(group, rect, entity -> cons.accept((Unit) entity));
|
||||
}
|
||||
|
||||
//now check all players
|
||||
EntityPhysics.getNearby(playerGroup, rect, player -> {
|
||||
EntityQuery.getNearby(playerGroup, rect, player -> {
|
||||
if(((Unit) player).team == team) cons.accept((Unit) player);
|
||||
});
|
||||
}
|
||||
@@ -230,7 +230,7 @@ public class Units{
|
||||
|
||||
EntityGroup<BaseUnit> group = unitGroups[team.ordinal()];
|
||||
if(!group.isEmpty()){
|
||||
EntityPhysics.getNearby(group, rect, entity -> {
|
||||
EntityQuery.getNearby(group, rect, entity -> {
|
||||
if(entity.distanceTo(x, y) <= radius){
|
||||
cons.accept((Unit) entity);
|
||||
}
|
||||
@@ -238,7 +238,7 @@ public class Units{
|
||||
}
|
||||
|
||||
//now check all players
|
||||
EntityPhysics.getNearby(playerGroup, rect, player -> {
|
||||
EntityQuery.getNearby(playerGroup, rect, player -> {
|
||||
if(((Unit) player).team == team && player.distanceTo(x, y) <= radius){
|
||||
cons.accept((Unit) player);
|
||||
}
|
||||
@@ -253,12 +253,12 @@ public class Units{
|
||||
for(Team team : Team.all){
|
||||
EntityGroup<BaseUnit> group = unitGroups[team.ordinal()];
|
||||
if(!group.isEmpty()){
|
||||
EntityPhysics.getNearby(group, rect, entity -> cons.accept((Unit) entity));
|
||||
EntityQuery.getNearby(group, rect, entity -> cons.accept((Unit) entity));
|
||||
}
|
||||
}
|
||||
|
||||
//now check all enemy players
|
||||
EntityPhysics.getNearby(playerGroup, rect, player -> cons.accept((Unit) player));
|
||||
EntityQuery.getNearby(playerGroup, rect, player -> cons.accept((Unit) player));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,12 +270,12 @@ public class Units{
|
||||
for(Team other : targets){
|
||||
EntityGroup<BaseUnit> group = unitGroups[other.ordinal()];
|
||||
if(!group.isEmpty()){
|
||||
EntityPhysics.getNearby(group, rect, entity -> cons.accept((Unit) entity));
|
||||
EntityQuery.getNearby(group, rect, entity -> cons.accept((Unit) entity));
|
||||
}
|
||||
}
|
||||
|
||||
//now check all enemy players
|
||||
EntityPhysics.getNearby(playerGroup, rect, player -> {
|
||||
EntityQuery.getNearby(playerGroup, rect, player -> {
|
||||
if(targets.contains(((Player) player).team)){
|
||||
cons.accept((Unit) player);
|
||||
}
|
||||
|
||||
@@ -306,7 +306,6 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
}
|
||||
|
||||
if(!Net.client()){
|
||||
avoidOthers(4f + type.hitsize);
|
||||
|
||||
if(spawner != -1 && (world.tile(spawner) == null || world.tile(spawner).entity == null)){
|
||||
damage(health);
|
||||
|
||||
Reference in New Issue
Block a user