circles were a mistake
This commit is contained in:
@@ -232,6 +232,21 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxVelocity(){
|
||||
return mech.maxSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Queue<BuildRequest> getPlaceQueue(){
|
||||
return placeQueue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Player{" + id + ", mech=" + mech.name + ", local=" + isLocal + ", " + x + ", " + y + "}\n";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed(){
|
||||
dropCarryLocal();
|
||||
@@ -440,10 +455,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
hitTime -= Timers.delta();
|
||||
|
||||
if(Float.isNaN(x) || Float.isNaN(y)){
|
||||
TileEntity core = getClosestCore();
|
||||
if(core != null){
|
||||
set(core.x, core.y);
|
||||
}
|
||||
//throw new RuntimeException("NaN found!");
|
||||
velocity.set(0f, 0f);
|
||||
x = 0;
|
||||
y = 0;
|
||||
setDead(true);
|
||||
}
|
||||
|
||||
if(isDead()){
|
||||
@@ -465,7 +481,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
interpolate();
|
||||
updateBuilding(this); //building happens even with non-locals
|
||||
status.update(this); //status effect updating also happens with non locals for effect purposes
|
||||
updateVelocityStatus(mech.drag, mech.maxSpeed); //velocity too, for visual purposes
|
||||
updateVelocityStatus(); //velocity too, for visual purposes
|
||||
|
||||
if(getCarrier() != null){
|
||||
x = getCarrier().getX();
|
||||
@@ -570,7 +586,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
velocity.add(movement);
|
||||
}
|
||||
float prex = x, prey = y;
|
||||
updateVelocityStatus(mech.drag, mech.maxSpeed);
|
||||
updateVelocityStatus();
|
||||
moved = distanceTo(prex, prey) > 0.01f;
|
||||
}else{
|
||||
velocity.setZero();
|
||||
@@ -644,7 +660,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
rotation = Mathf.slerpDelta(rotation, velocity.angle(), velocity.len() / 10f);
|
||||
}
|
||||
|
||||
updateVelocityStatus(mech.drag, mech.maxSpeed);
|
||||
updateVelocityStatus();
|
||||
|
||||
//hovering effect
|
||||
x += Mathf.sin(Timers.time() + id * 999, 25f, 0.08f);
|
||||
@@ -734,16 +750,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
this.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Queue<BuildRequest> getPlaceQueue(){
|
||||
return placeQueue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Player{" + id + ", mech=" + mech.name + ", local=" + isLocal + ", " + x + ", " + y + "}\n";
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
//region read and write methods
|
||||
|
||||
@@ -16,14 +16,12 @@ import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.impl.DestructibleEntity;
|
||||
import io.anuke.ucore.entities.trait.DamageTrait;
|
||||
import io.anuke.ucore.entities.trait.DrawTrait;
|
||||
import io.anuke.ucore.entities.trait.SolidTrait;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Translator;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@@ -39,7 +37,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
public static final float velocityPercision = 8f;
|
||||
/**Maximum absolute value of a velocity vector component.*/
|
||||
public static final float maxAbsVelocity = 127f / velocityPercision;
|
||||
private static final Vector2 moveVector = new Vector2();
|
||||
|
||||
public UnitInventory inventory = new UnitInventory(this);
|
||||
public float rotation;
|
||||
@@ -50,7 +47,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
protected Team team = Team.blue;
|
||||
|
||||
protected CarryTrait carrier;
|
||||
protected Vector2 velocity = new Translator(0f, 0.0001f);
|
||||
protected float drownTime;
|
||||
|
||||
@Override
|
||||
@@ -58,16 +54,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRotation(){
|
||||
return rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotation(float rotation){
|
||||
this.rotation = rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarryTrait getCarrier(){
|
||||
return carrier;
|
||||
@@ -108,8 +94,8 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
|
||||
@Override
|
||||
public boolean collides(SolidTrait other){
|
||||
return other instanceof DamageTrait && other
|
||||
instanceof TeamTrait && state.teams.areEnemies((((TeamTrait) other).getTeam()), team) && !isDead();
|
||||
return true;//other instanceof DamageTrait && other
|
||||
// instanceof TeamTrait && state.teams.areEnemies((((TeamTrait) other).getTeam()), team) && !isDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,10 +179,9 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
}
|
||||
|
||||
/**Updates velocity and status effects.*/
|
||||
public void updateVelocityStatus(float drag, float maxVelocity){
|
||||
public void updateVelocityStatus(){
|
||||
Floor floor = getFloorOn();
|
||||
|
||||
|
||||
if(isCarried()){ //carried units do not take into account velocity normally
|
||||
set(carrier.getX(), carrier.getY());
|
||||
velocity.set(carrier.getVelocity());
|
||||
@@ -207,7 +192,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
|
||||
status.update(this);
|
||||
|
||||
velocity.limit(maxVelocity).scl(status.getSpeedMultiplier());
|
||||
velocity.limit(getMaxVelocity()).scl(status.getSpeedMultiplier());
|
||||
|
||||
if(isFlying()){
|
||||
x += velocity.x / getMass() * Timers.delta();
|
||||
@@ -255,12 +240,12 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
}
|
||||
|
||||
float px = x, py = y;
|
||||
move(velocity.x / getMass() * floor.speedMultiplier * Timers.delta(), velocity.y / getMass() * floor.speedMultiplier * Timers.delta());
|
||||
move(velocity.x * floor.speedMultiplier * Timers.delta(), velocity.y * floor.speedMultiplier * Timers.delta());
|
||||
if(Math.abs(px - x) <= 0.0001f) velocity.x = 0f;
|
||||
if(Math.abs(py - y) <= 0.0001f) velocity.y = 0f;
|
||||
}
|
||||
|
||||
velocity.scl(Mathf.clamp(1f - drag * (isFlying() ? 1f : floor.dragMultiplier) * Timers.delta()));
|
||||
velocity.scl(Mathf.clamp(1f - getDrag() * (isFlying() ? 1f : floor.dragMultiplier) * Timers.delta()));
|
||||
}
|
||||
|
||||
public void applyEffect(StatusEffect effect, float intensity){
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
@@ -69,15 +68,9 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
bullet.type = type;
|
||||
bullet.lifeScl = lifetimeScl;
|
||||
|
||||
//translate bullets backwards, purely for visual reasons
|
||||
float backDelta = Timers.delta();
|
||||
|
||||
bullet.lastPosition().set(x - bullet.velocity.x * backDelta, y - bullet.velocity.y * backDelta, bullet.angle());
|
||||
bullet.setLastUpdated(TimeUtils.millis());
|
||||
bullet.setUpdateSpacing((long) ((Timers.delta() / 60f) * 1000));
|
||||
bullet.set(x, y);
|
||||
|
||||
bullet.add();
|
||||
|
||||
return bullet;
|
||||
}
|
||||
|
||||
@@ -199,7 +192,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
super.update();
|
||||
|
||||
if(type.hitTiles && collidesTiles() && !supressCollision && initialized){
|
||||
world.raycastEach(world.toTile(lastPosition().x), world.toTile(lastPosition().y), world.toTile(x), world.toTile(y), (x, y) -> {
|
||||
world.raycastEach(world.toTile(x), world.toTile(y), world.toTile(x + velocity.x), world.toTile(y + velocity.y), (x, y) -> {
|
||||
|
||||
Tile tile = world.tile(x, y);
|
||||
if(tile == null) return false;
|
||||
|
||||
@@ -114,6 +114,8 @@ public class Lightning extends SolidEntity implements Poolable, DrawTrait, SyncT
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void getHitbox(Rectangle rectangle){}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.anuke.mindustry.entities.traits;
|
||||
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.ucore.entities.trait.PosTrait;
|
||||
import io.anuke.ucore.entities.trait.SolidTrait;
|
||||
import io.anuke.ucore.entities.trait.VelocityTrait;
|
||||
|
||||
/**
|
||||
@@ -15,19 +14,11 @@ public interface TargetTrait extends PosTrait, VelocityTrait{
|
||||
Team getTeam();
|
||||
|
||||
default float getTargetVelocityX(){
|
||||
if(this instanceof SolidTrait){
|
||||
return getX() - ((SolidTrait) this).lastPosition().x;
|
||||
}else{
|
||||
return getVelocity().x;
|
||||
}
|
||||
return getVelocity().x;
|
||||
}
|
||||
|
||||
default float getTargetVelocityY(){
|
||||
if(this instanceof SolidTrait){
|
||||
return getY() - ((SolidTrait) this).lastPosition().y;
|
||||
}else{
|
||||
return getVelocity().y;
|
||||
}
|
||||
return getVelocity().y;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -319,7 +319,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
updateTargeting();
|
||||
|
||||
state.update();
|
||||
updateVelocityStatus(type.drag, type.maxVelocity);
|
||||
updateVelocityStatus();
|
||||
|
||||
if(target != null) behavior();
|
||||
|
||||
@@ -344,6 +344,11 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxVelocity(){
|
||||
return type.maxVelocity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed(){
|
||||
spawner = -1;
|
||||
|
||||
@@ -119,7 +119,7 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
public void update(){
|
||||
super.update();
|
||||
|
||||
stuckTime = !vec.set(x, y).sub(lastPosition().x, lastPosition().y).isZero(0.0001f) ? 0f : stuckTime + Timers.delta();
|
||||
stuckTime = !getVelocity().isZero(0.0001f) ? 0f : stuckTime + Timers.delta();
|
||||
|
||||
if(!velocity.isZero(0.0001f) && (Units.invalidateTarget(target, this) || (distanceTo(target) > getWeapon().getAmmo().getRange()))){
|
||||
rotation = Mathf.slerpDelta(rotation, velocity.angle(), type.rotatespeed);
|
||||
|
||||
Reference in New Issue
Block a user