mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-11 11:17:11 +07:00
Merge branch 'circle-physics' of https://github.com/Anuken/Mindustry
# Conflicts: # core/src/io/anuke/mindustry/content/UnitTypes.java
This commit is contained in:
commit
561f566506
@ -27,7 +27,7 @@ allprojects {
|
||||
appName = 'Mindustry'
|
||||
gdxVersion = '1.9.8'
|
||||
roboVMVersion = '2.3.0'
|
||||
uCoreVersion = '1b74e58413f4885f204c441f88464d8c82c5433b'
|
||||
uCoreVersion = '00d05bd7d3e943c8a454ccf2cb69cdffb23afbb7'
|
||||
|
||||
getVersionString = {
|
||||
String buildVersion = getBuildVersion()
|
||||
|
@ -42,10 +42,10 @@ public class Mechs implements ContentList{
|
||||
{
|
||||
drillPower = 1;
|
||||
mineSpeed = 1.5f;
|
||||
mass = 1.2f;
|
||||
speed = 0.5f;
|
||||
boostSpeed = 0.85f;
|
||||
weapon = Weapons.blaster;
|
||||
maxSpeed = 4f;
|
||||
trailColorTo = Color.valueOf("ffd37f");
|
||||
armor = 20f;
|
||||
}
|
||||
@ -81,13 +81,13 @@ public class Mechs implements ContentList{
|
||||
speed = 0.75f;
|
||||
boostSpeed = 0.95f;
|
||||
itemCapacity = 15;
|
||||
mass = 0.9f;
|
||||
armor = 30f;
|
||||
weaponOffsetX = -1;
|
||||
itemCapacity = 15;
|
||||
weaponOffsetY = -1;
|
||||
weapon = Weapons.shockgun;
|
||||
trailColorTo = Color.valueOf("d3ddff");
|
||||
maxSpeed = 5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -115,11 +115,11 @@ public class Mechs implements ContentList{
|
||||
itemCapacity = 70;
|
||||
weaponOffsetY = -1;
|
||||
weaponOffsetX = 1;
|
||||
mass = 1.75f;
|
||||
speed = 0.44f;
|
||||
drag = 0.35f;
|
||||
boostSpeed = 0.8f;
|
||||
weapon = Weapons.healBlaster;
|
||||
maxSpeed = 5f;
|
||||
armor = 15f;
|
||||
trailColorTo = Palette.heal;
|
||||
}
|
||||
@ -157,12 +157,12 @@ public class Mechs implements ContentList{
|
||||
itemCapacity = 50;
|
||||
speed = 0.36f;
|
||||
boostSpeed = 0.6f;
|
||||
mass = 4f;
|
||||
shake = 4f;
|
||||
weaponOffsetX = 1;
|
||||
weaponOffsetY = 0;
|
||||
weapon = Weapons.swarmer;
|
||||
trailColorTo = Color.valueOf("feb380");
|
||||
maxSpeed = 3.5f;
|
||||
armor = 45f;
|
||||
}
|
||||
|
||||
@ -214,7 +214,6 @@ public class Mechs implements ContentList{
|
||||
drillPower = 1;
|
||||
mineSpeed = 0.9f;
|
||||
speed = 0.4f;
|
||||
maxSpeed = 10f;
|
||||
drag = 0.1f;
|
||||
armor = 10f;
|
||||
weapon = Weapons.blasterSmall;
|
||||
@ -231,8 +230,8 @@ public class Mechs implements ContentList{
|
||||
{
|
||||
drillPower = -1;
|
||||
speed = 0.11f;
|
||||
maxSpeed = 10f;
|
||||
drag = 0.01f;
|
||||
mass = 2f;
|
||||
armor = 5f;
|
||||
weapon = Weapons.missiles;
|
||||
trailColor = Color.valueOf("d3ddff");
|
||||
@ -285,8 +284,8 @@ public class Mechs implements ContentList{
|
||||
{
|
||||
drillPower = 2;
|
||||
speed = 0.12f;
|
||||
maxSpeed = 10f;
|
||||
drag = 0.035f;
|
||||
mass = 2.5f;
|
||||
turnCursor = false;
|
||||
armor = 20f;
|
||||
itemCapacity = 30;
|
||||
@ -307,8 +306,8 @@ public class Mechs implements ContentList{
|
||||
drillPower = 4;
|
||||
mineSpeed = 1.3f;
|
||||
speed = 0.32f;
|
||||
maxSpeed = 10f;
|
||||
drag = 0.06f;
|
||||
mass = 3f;
|
||||
armor = 30f;
|
||||
itemCapacity = 60;
|
||||
trailColor = Color.valueOf("feb380");
|
||||
|
@ -24,6 +24,8 @@ public class UnitTypes implements ContentList{
|
||||
maxVelocity = 1.7f;
|
||||
range = 40f;
|
||||
health = 45;
|
||||
hitsize = 4f;
|
||||
mass = 0.1f;
|
||||
weapon = Weapons.droneBlaster;
|
||||
trailColor = Color.valueOf("ffd37f");
|
||||
}
|
||||
@ -48,6 +50,8 @@ public class UnitTypes implements ContentList{
|
||||
maxVelocity = 1.1f;
|
||||
speed = 0.2f;
|
||||
drag = 0.4f;
|
||||
hitsize = 8f;
|
||||
mass = 1.75f;
|
||||
range = 40f;
|
||||
weapon = Weapons.chainBlaster;
|
||||
health = 130;
|
||||
@ -57,7 +61,9 @@ public class UnitTypes implements ContentList{
|
||||
maxVelocity = 0.8f;
|
||||
speed = 0.18f;
|
||||
drag = 0.4f;
|
||||
mass = 3.5f;
|
||||
range = 10f;
|
||||
hitsize = 9f;
|
||||
rotatespeed = 0.1f;
|
||||
weapon = Weapons.flamethrower;
|
||||
health = 440;
|
||||
@ -67,6 +73,8 @@ public class UnitTypes implements ContentList{
|
||||
maxVelocity = 0.8f;
|
||||
speed = 0.15f;
|
||||
drag = 0.4f;
|
||||
mass = 5f;
|
||||
hitsize = 10f;
|
||||
range = 10f;
|
||||
rotatespeed = 0.06f;
|
||||
weaponOffsetX = 1;
|
||||
@ -79,6 +87,7 @@ public class UnitTypes implements ContentList{
|
||||
speed = 0.3f;
|
||||
maxVelocity = 1.9f;
|
||||
drag = 0.01f;
|
||||
mass = 1.5f;
|
||||
weapon = Weapons.chainBlaster;
|
||||
isFlying = true;
|
||||
health = 70;
|
||||
@ -88,6 +97,7 @@ public class UnitTypes implements ContentList{
|
||||
health = 250;
|
||||
speed = 0.2f;
|
||||
maxVelocity = 1.4f;
|
||||
mass = 3f;
|
||||
drag = 0.01f;
|
||||
isFlying = true;
|
||||
targetAir = false;
|
||||
@ -96,10 +106,9 @@ public class UnitTypes implements ContentList{
|
||||
|
||||
revenant = new UnitType("revenant", Revenant.class, Revenant::new){{
|
||||
health = 250;
|
||||
mass = 4f;
|
||||
speed = 0.14f*mass;
|
||||
mass = 5f;
|
||||
hitsize = 12f;
|
||||
maxVelocity = 1.4f;
|
||||
speed = 0.14f;
|
||||
drag = 0.01f;
|
||||
isFlying = true;
|
||||
weapon = Weapons.laserBurster;
|
||||
@ -108,6 +117,7 @@ public class UnitTypes implements ContentList{
|
||||
phantom = new UnitType("phantom", Phantom.class, Phantom::new){{
|
||||
isFlying = true;
|
||||
drag = 0.01f;
|
||||
mass = 2f;
|
||||
speed = 0.2f;
|
||||
maxVelocity = 0.9f;
|
||||
range = 70f;
|
||||
|
@ -190,8 +190,8 @@ public class TurretBlocks extends BlockList implements ContentList{
|
||||
cyclone = new ItemTurret("cyclone"){{
|
||||
ammoTypes = new AmmoType[]{AmmoTypes.flakExplosive, AmmoTypes.flakPlastic, AmmoTypes.flakSurge};
|
||||
xRand = 4f;
|
||||
reload = 10f;
|
||||
range = 140f;
|
||||
reload = 8f;
|
||||
range = 145f;
|
||||
size = 3;
|
||||
recoil = 3f;
|
||||
rotatespeed = 10f;
|
||||
|
@ -10,9 +10,9 @@ import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.game.Unlocks;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.Saves;
|
||||
import io.anuke.mindustry.game.Unlocks;
|
||||
import io.anuke.mindustry.input.DefaultKeybinds;
|
||||
import io.anuke.mindustry.input.DesktopInput;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
@ -24,7 +24,7 @@ import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.EntityPhysics;
|
||||
import io.anuke.ucore.entities.EntityQuery;
|
||||
import io.anuke.ucore.modules.Module;
|
||||
import io.anuke.ucore.util.Atlas;
|
||||
|
||||
@ -302,7 +302,7 @@ public class Control extends Module{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
EntityPhysics.initPhysics();
|
||||
EntityQuery.init();
|
||||
|
||||
Platform.instance.updateRPC();
|
||||
|
||||
|
@ -17,7 +17,7 @@ import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.EntityPhysics;
|
||||
import io.anuke.ucore.entities.EntityQuery;
|
||||
import io.anuke.ucore.modules.Module;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
@ -39,8 +39,8 @@ public class Logic extends Module{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
EntityPhysics.initPhysics();
|
||||
EntityPhysics.collisions().setCollider(tilesize, world::solid);
|
||||
EntityQuery.init();
|
||||
EntityQuery.collisions().setCollider(tilesize, world::solid);
|
||||
}
|
||||
|
||||
public void play(){
|
||||
@ -166,12 +166,19 @@ public class Logic extends Module{
|
||||
}
|
||||
|
||||
for(EntityGroup group : unitGroups){
|
||||
if(!group.isEmpty()){
|
||||
EntityPhysics.collideGroups(bulletGroup, group);
|
||||
if(group.isEmpty()) continue;
|
||||
|
||||
EntityQuery.collideGroups(bulletGroup, group);
|
||||
EntityQuery.collideGroups(group, playerGroup);
|
||||
|
||||
for(EntityGroup other : unitGroups){
|
||||
if(other.isEmpty()) continue;
|
||||
EntityQuery.collideGroups(group, other);
|
||||
}
|
||||
}
|
||||
|
||||
EntityPhysics.collideGroups(bulletGroup, playerGroup);
|
||||
EntityQuery.collideGroups(bulletGroup, playerGroup);
|
||||
EntityQuery.collideGroups(playerGroup, playerGroup);
|
||||
|
||||
world.pathfinder().update();
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.EntityPhysics;
|
||||
import io.anuke.ucore.entities.EntityQuery;
|
||||
import io.anuke.ucore.entities.trait.Entity;
|
||||
import io.anuke.ucore.io.ByteBufferOutput;
|
||||
import io.anuke.ucore.io.CountableByteArrayOutputStream;
|
||||
@ -508,7 +508,7 @@ public class NetServer extends Module{
|
||||
|
||||
returnArray.clear();
|
||||
if(represent.isClipped()){
|
||||
EntityPhysics.getNearby(group, viewport, entity -> {
|
||||
EntityQuery.getNearby(group, viewport, entity -> {
|
||||
if(((SyncTrait) entity).isSyncing() && viewport.contains(entity.getX(), entity.getY())){
|
||||
returnArray.add(entity);
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.ObjectIntMap;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
@ -31,7 +30,6 @@ import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.impl.EffectEntity;
|
||||
import io.anuke.ucore.entities.trait.DrawTrait;
|
||||
import io.anuke.ucore.entities.trait.Entity;
|
||||
import io.anuke.ucore.entities.trait.SolidTrait;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.function.Predicate;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
@ -340,45 +338,7 @@ public class Renderer extends RendererModule{
|
||||
}
|
||||
|
||||
public <T extends DrawTrait> void drawAndInterpolate(EntityGroup<T> group, Predicate<T> toDraw, Consumer<T> drawer){
|
||||
EntityDraw.drawWith(group, toDraw, t -> {
|
||||
float lastx = t.getX(), lasty = t.getY(), lastrot = 0f;
|
||||
|
||||
if(threads.doInterpolate() && threads.isEnabled() && t instanceof SolidTrait){
|
||||
SolidTrait s = (SolidTrait) t;
|
||||
|
||||
lastrot = s.getRotation();
|
||||
|
||||
if(s.lastUpdated() != 0){
|
||||
float timeSinceUpdate = TimeUtils.timeSinceMillis(s.lastUpdated());
|
||||
float alpha = Math.min(timeSinceUpdate / s.updateSpacing(), 1f);
|
||||
|
||||
tmpVector1.set(s.lastPosition().x, s.lastPosition().y)
|
||||
.lerp(tmpVector2.set(lastx, lasty), alpha);
|
||||
s.setRotation(Mathf.slerp(s.lastPosition().z, lastrot, alpha));
|
||||
|
||||
s.setX(tmpVector1.x);
|
||||
s.setY(tmpVector1.y);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO extremely hacky
|
||||
if(t instanceof Player && ((Player) t).getCarry() != null && ((Player) t).getCarry() instanceof Player && ((Player) ((Player) t).getCarry()).isLocal){
|
||||
((Player) t).x = ((Player) t).getCarry().getX();
|
||||
((Player) t).y = ((Player) t).getCarry().getY();
|
||||
}
|
||||
|
||||
drawer.accept(t);
|
||||
|
||||
t.setX(lastx);
|
||||
t.setY(lasty);
|
||||
|
||||
if(threads.doInterpolate() && threads.isEnabled()){
|
||||
|
||||
if(t instanceof SolidTrait){
|
||||
((SolidTrait) t).setRotation(lastrot);
|
||||
}
|
||||
}
|
||||
});
|
||||
EntityDraw.drawWith(group, toDraw, drawer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,7 +18,7 @@ import io.anuke.mindustry.maps.generation.WorldGenerator;
|
||||
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||
import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.EntityPhysics;
|
||||
import io.anuke.ucore.entities.EntityQuery;
|
||||
import io.anuke.ucore.modules.Module;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
@ -222,7 +222,7 @@ public class World extends Module{
|
||||
}
|
||||
}
|
||||
|
||||
EntityPhysics.resizeTree(0, 0, tiles.length * tilesize, tiles[0].length * tilesize);
|
||||
EntityQuery.resizeTree(0, 0, tiles.length * tilesize, tiles[0].length * tilesize);
|
||||
|
||||
generating = false;
|
||||
Events.fire(new WorldLoadEvent());
|
||||
@ -251,7 +251,7 @@ public class World extends Module{
|
||||
Map map = new Map("Sector " + sector.x + ", " + sector.y, new MapMeta(0, new ObjectMap<>(), width, height, null), true, () -> null);
|
||||
setMap(map);
|
||||
|
||||
EntityPhysics.resizeTree(0, 0, width * tilesize, height * tilesize);
|
||||
EntityQuery.resizeTree(0, 0, width * tilesize, height * tilesize);
|
||||
|
||||
generator.generateMap(tiles, sector);
|
||||
|
||||
@ -267,7 +267,7 @@ public class World extends Module{
|
||||
|
||||
createTiles(width, height);
|
||||
|
||||
EntityPhysics.resizeTree(0, 0, width * tilesize, height * tilesize);
|
||||
EntityQuery.resizeTree(0, 0, width * tilesize, height * tilesize);
|
||||
|
||||
try{
|
||||
generator.loadTileData(tiles, MapIO.readTileData(map, true), map.meta.hasOreGen(), 0);
|
||||
|
@ -98,7 +98,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
|
||||
@Override
|
||||
public void getHitbox(Rectangle rectangle){
|
||||
rectangle.setSize(5).setCenter(x, y);
|
||||
rectangle.setSize(mech.hitsize).setCenter(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -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();
|
||||
@ -487,10 +503,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);
|
||||
@ -574,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();
|
||||
@ -648,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);
|
||||
@ -738,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
|
||||
|
@ -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;
|
||||
@ -24,7 +23,6 @@ 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;
|
||||
@ -40,7 +38,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;
|
||||
@ -51,24 +48,18 @@ 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
|
||||
public boolean movable(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnitInventory getInventory(){
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRotation(){
|
||||
return rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotation(float rotation){
|
||||
this.rotation = rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarryTrait getCarrier(){
|
||||
return carrier;
|
||||
@ -109,8 +100,13 @@ 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();
|
||||
if(isDead()) return true;
|
||||
|
||||
if(other instanceof DamageTrait){
|
||||
return other instanceof TeamTrait && state.teams.areEnemies((((TeamTrait) other).getTeam()), team);
|
||||
}else{
|
||||
return other instanceof Unit && ((Unit) other).isFlying() == isFlying();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -193,22 +189,10 @@ 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){
|
||||
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());
|
||||
@ -219,11 +203,11 @@ 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();
|
||||
y += velocity.y / getMass() * Timers.delta();
|
||||
x += velocity.x * Timers.delta();
|
||||
y += velocity.y * Timers.delta();
|
||||
}else{
|
||||
boolean onLiquid = floor.isLiquid;
|
||||
|
||||
@ -267,12 +251,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){
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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.set(x - bullet.velocity.x * Timers.delta(), y - bullet.velocity.y * Timers.delta());
|
||||
bullet.add();
|
||||
|
||||
return bullet;
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,8 @@ public class Lightning extends SolidEntity implements Poolable, DrawTrait, SyncT
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void getHitbox(Rectangle rectangle){}
|
||||
|
||||
|
@ -16,18 +16,16 @@ public interface TargetTrait extends PosTrait, VelocityTrait{
|
||||
|
||||
default float getTargetVelocityX(){
|
||||
if(this instanceof SolidTrait){
|
||||
return getX() - ((SolidTrait) this).lastPosition().x;
|
||||
}else{
|
||||
return getVelocity().x;
|
||||
return ((SolidTrait) this).getDeltaX();
|
||||
}
|
||||
return getVelocity().x;
|
||||
}
|
||||
|
||||
default float getTargetVelocityY(){
|
||||
if(this instanceof SolidTrait){
|
||||
return getY() - ((SolidTrait) this).lastPosition().y;
|
||||
}else{
|
||||
return getVelocity().y;
|
||||
return ((SolidTrait) this).getDeltaY();
|
||||
}
|
||||
return getVelocity().y;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
@ -320,7 +319,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
updateTargeting();
|
||||
|
||||
state.update();
|
||||
updateVelocityStatus(type.drag, type.maxVelocity);
|
||||
updateVelocityStatus();
|
||||
|
||||
if(target != null) behavior();
|
||||
|
||||
@ -345,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,12 +119,16 @@ 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 = !vec.set(x, y).sub(lastPosition()).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);
|
||||
}
|
||||
|
||||
if(!velocity.isZero()){
|
||||
baseRotation = Mathf.slerpDelta(baseRotation, velocity.angle(), 0.05f);
|
||||
}
|
||||
|
||||
if(stuckTime < 1f){
|
||||
walkTime += Timers.delta();
|
||||
}
|
||||
@ -268,10 +272,7 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
|
||||
if(tile == targetTile) return;
|
||||
|
||||
vec.trns(baseRotation, type.speed);
|
||||
|
||||
baseRotation = Mathf.slerpDelta(baseRotation, angleTo(targetTile), 0.05f);
|
||||
velocity.add(vec);
|
||||
velocity.add(vec.trns(angleTo(targetTile), type.speed));
|
||||
}
|
||||
|
||||
protected void moveAwayFromCore(){
|
||||
@ -292,9 +293,6 @@ public abstract class GroundUnit extends BaseUnit{
|
||||
|
||||
if(tile == targetTile || core == null || distanceTo(core) < 90f) return;
|
||||
|
||||
vec.trns(baseRotation, type.speed);
|
||||
|
||||
baseRotation = Mathf.slerpDelta(baseRotation, angleTo(targetTile), 0.05f);
|
||||
velocity.add(vec);
|
||||
velocity.add(vec.trns(angleTo(targetTile), type.speed));
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class UnitType extends UnlockableContent{
|
||||
public final String name;
|
||||
public final String description;
|
||||
public float health = 60;
|
||||
public float hitsize = 5f;
|
||||
public float hitsize = 7f;
|
||||
public float hitsizeTile = 4f;
|
||||
public float speed = 0.4f;
|
||||
public float range = 160;
|
||||
|
@ -20,13 +20,14 @@ public class Mech extends UnlockableContent{
|
||||
|
||||
public boolean flying;
|
||||
public float speed = 1.1f;
|
||||
public float maxSpeed = 1.1f;
|
||||
public float maxSpeed = 10f;
|
||||
public float boostSpeed = 0.75f;
|
||||
public float drag = 0.4f;
|
||||
public float mass = 1f;
|
||||
public float shake = 0f;
|
||||
public float armor = 1f;
|
||||
|
||||
public float hitsize = 6f;
|
||||
public float cellTrnsY = 0f;
|
||||
public float mineSpeed = 1f;
|
||||
public int drillPower = -1;
|
||||
|
@ -57,7 +57,7 @@ public class DeflectorWall extends Wall{
|
||||
|
||||
bullet.getHitbox(rect2);
|
||||
|
||||
Vector2 position = Physics.raycastRect(bullet.lastPosition().x, bullet.lastPosition().y, bullet.x, bullet.y,
|
||||
Vector2 position = Physics.raycastRect(bullet.x, bullet.y, bullet.x + bullet.getVelocity().x, bullet.y + bullet.getVelocity().y,
|
||||
rect.setCenter(entity.x, entity.y).setSize(size * tilesize + rect2.width + rect2.height));
|
||||
|
||||
if(position != null){
|
||||
@ -70,7 +70,7 @@ public class DeflectorWall extends Wall{
|
||||
bullet.getVelocity().y *= -1;
|
||||
}
|
||||
|
||||
bullet.updateVelocity(0f);
|
||||
bullet.updateVelocity();
|
||||
bullet.resetOwner(entity, Team.none);
|
||||
bullet.scaleTime(1f);
|
||||
bullet.supress();
|
||||
|
@ -16,7 +16,7 @@ import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.EntityPhysics;
|
||||
import io.anuke.ucore.entities.EntityQuery;
|
||||
import io.anuke.ucore.entities.impl.BaseEntity;
|
||||
import io.anuke.ucore.entities.trait.DrawTrait;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
@ -127,7 +127,7 @@ public class ForceProjector extends Block {
|
||||
float realRadius = realRadius(entity);
|
||||
|
||||
if(!entity.broken){
|
||||
EntityPhysics.getNearby(bulletGroup, tile.drawx(), tile.drawy(), realRadius*2f, bullet -> {
|
||||
EntityQuery.getNearby(bulletGroup, tile.drawx(), tile.drawy(), realRadius*2f, bullet -> {
|
||||
AbsorbTrait trait = (AbsorbTrait)bullet;
|
||||
if(trait.canBeAbsorbed() && trait.getTeam() != tile.getTeam() && isInsideHexagon(trait.getX(), trait.getY(), realRadius * 2f, tile.drawx(), tile.drawy())){
|
||||
trait.absorb();
|
||||
|
Loading…
Reference in New Issue
Block a user