Removed useless hitbox rects
This commit is contained in:
@@ -27,7 +27,7 @@ allprojects {
|
|||||||
appName = 'Mindustry'
|
appName = 'Mindustry'
|
||||||
gdxVersion = '1.9.8'
|
gdxVersion = '1.9.8'
|
||||||
roboVMVersion = '2.3.0'
|
roboVMVersion = '2.3.0'
|
||||||
uCoreVersion = '99b7a3af00a1fa7e48a494515bf6b137774e114b'
|
uCoreVersion = '115a42ff7d5bca0a6073b5f1e0b67cc4464c560e'
|
||||||
|
|
||||||
getVersionString = {
|
getVersionString = {
|
||||||
String buildVersion = getBuildVersion()
|
String buildVersion = getBuildVersion()
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.anuke.mindustry.entities;
|
|||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.utils.Queue;
|
import com.badlogic.gdx.utils.Queue;
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
@@ -28,7 +29,6 @@ import io.anuke.mindustry.world.blocks.Floor;
|
|||||||
import io.anuke.mindustry.world.blocks.storage.CoreBlock.CoreEntity;
|
import io.anuke.mindustry.world.blocks.storage.CoreBlock.CoreEntity;
|
||||||
import io.anuke.ucore.core.*;
|
import io.anuke.ucore.core.*;
|
||||||
import io.anuke.ucore.entities.EntityGroup;
|
import io.anuke.ucore.entities.EntityGroup;
|
||||||
import io.anuke.ucore.entities.trait.SolidTrait;
|
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.graphics.Hue;
|
import io.anuke.ucore.graphics.Hue;
|
||||||
import io.anuke.ucore.graphics.Lines;
|
import io.anuke.ucore.graphics.Lines;
|
||||||
@@ -47,7 +47,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
private static final int timerShootRight = 1;
|
private static final int timerShootRight = 1;
|
||||||
private static final float liftoffBoost = 0.2f;
|
private static final float liftoffBoost = 0.2f;
|
||||||
|
|
||||||
//region instance variables, constructor
|
//region instance variables
|
||||||
|
|
||||||
public float baseRotation;
|
public float baseRotation;
|
||||||
public float pointerX, pointerY;
|
public float pointerX, pointerY;
|
||||||
@@ -75,11 +75,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
private Vector2 movement = new Translator();
|
private Vector2 movement = new Translator();
|
||||||
private boolean moved;
|
private boolean moved;
|
||||||
|
|
||||||
public Player(){
|
|
||||||
hitbox.setSize(5);
|
|
||||||
hitboxTile.setSize(4f);
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region unit and event overrides, utility methods
|
//region unit and event overrides, utility methods
|
||||||
@@ -101,6 +96,16 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
player.onDeath();
|
player.onDeath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getHitbox(Rectangle rectangle){
|
||||||
|
rectangle.setSize(5).setCenter(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getHitboxTile(Rectangle rectangle){
|
||||||
|
rectangle.setSize(4).setCenter(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getDrag(){
|
public float getDrag(){
|
||||||
return mech.drag;
|
return mech.drag;
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
public static final float velocityPercision = 8f;
|
public static final float velocityPercision = 8f;
|
||||||
/**Maximum absolute value of a velocity vector component.*/
|
/**Maximum absolute value of a velocity vector component.*/
|
||||||
public static final float maxAbsVelocity = 127f / velocityPercision;
|
public static final float maxAbsVelocity = 127f / velocityPercision;
|
||||||
|
|
||||||
private static final Vector2 moveVector = new Vector2();
|
private static final Vector2 moveVector = new Vector2();
|
||||||
|
|
||||||
public UnitInventory inventory = new UnitInventory(this);
|
public UnitInventory inventory = new UnitInventory(this);
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
if(type.keepVelocity){
|
if(type.keepVelocity){
|
||||||
bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait) owner).getVelocity() : Vector2.Zero);
|
bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait) owner).getVelocity() : Vector2.Zero);
|
||||||
}
|
}
|
||||||
bullet.hitbox.setSize(type.hitsize);
|
|
||||||
|
|
||||||
bullet.team = team;
|
bullet.team = team;
|
||||||
bullet.type = type;
|
bullet.type = type;
|
||||||
|
|||||||
@@ -114,6 +114,12 @@ public class Lightning extends SolidEntity implements Poolable, DrawTrait, SyncT
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getHitbox(Rectangle rectangle){}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getHitboxTile(Rectangle rectangle){}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void absorb(){
|
public void absorb(){
|
||||||
activeFrame = 99;
|
activeFrame = 99;
|
||||||
@@ -183,7 +189,7 @@ public class Lightning extends SolidEntity implements Poolable, DrawTrait, SyncT
|
|||||||
Units.getNearbyEnemies(team, rect, unit -> {
|
Units.getNearbyEnemies(team, rect, unit -> {
|
||||||
unit.getHitbox(hitrect);
|
unit.getHitbox(hitrect);
|
||||||
if(rect.overlaps(hitrect)){
|
if(rect.overlaps(hitrect)){
|
||||||
unit.damage(damage * (unit.hasEffect(StatusEffects.wet) ? 2f : 1f));
|
unit.damage(damage * (unit.hasEffect(StatusEffects.wet) ? wetDamageMultiplier : 1f));
|
||||||
Effects.effect(effect, vec.x, vec.y, 0f);
|
Effects.effect(effect, vec.x, vec.y, 0f);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.anuke.mindustry.entities.traits;
|
package io.anuke.mindustry.entities.traits;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import io.anuke.mindustry.net.Interpolator;
|
import io.anuke.mindustry.net.Interpolator;
|
||||||
import io.anuke.ucore.entities.trait.Entity;
|
import io.anuke.ucore.entities.trait.Entity;
|
||||||
|
|
||||||
@@ -8,15 +7,8 @@ import java.io.DataInput;
|
|||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.threads;
|
|
||||||
|
|
||||||
public interface SyncTrait extends Entity, TypeTrait{
|
public interface SyncTrait extends Entity, TypeTrait{
|
||||||
|
|
||||||
/**Whether smoothing of entities is enabled when using multithreading; not yet implemented.*/
|
|
||||||
static boolean isSmoothing(){
|
|
||||||
return threads.isEnabled() && threads.getTPS() <= Gdx.graphics.getFramesPerSecond() / 2f;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**Sets the position of this entity and updated the interpolator.*/
|
/**Sets the position of this entity and updated the interpolator.*/
|
||||||
default void setNet(float x, float y){
|
default void setNet(float x, float y){
|
||||||
set(x, y);
|
set(x, y);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.entities.units;
|
package io.anuke.mindustry.entities.units;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
@@ -43,7 +44,6 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
protected static int timerIndex = 0;
|
protected static int timerIndex = 0;
|
||||||
|
|
||||||
protected static final int timerTarget = timerIndex++;
|
protected static final int timerTarget = timerIndex++;
|
||||||
|
|
||||||
protected static final int timerShootLeft = timerIndex++;
|
protected static final int timerShootLeft = timerIndex++;
|
||||||
protected static final int timerShootRight = timerIndex++;
|
protected static final int timerShootRight = timerIndex++;
|
||||||
|
|
||||||
@@ -364,8 +364,6 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void added(){
|
public void added(){
|
||||||
hitbox.setSize(type.hitsize);
|
|
||||||
hitboxTile.setSize(type.hitsizeTile);
|
|
||||||
state.set(getStartState());
|
state.set(getStartState());
|
||||||
|
|
||||||
health(maxHealth());
|
health(maxHealth());
|
||||||
@@ -375,6 +373,16 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getHitbox(Rectangle rectangle){
|
||||||
|
rectangle.setSize(type.hitsize).setCenter(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getHitboxTile(Rectangle rectangle){
|
||||||
|
rectangle.setSize(type.hitsizeTile).setCenter(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityGroup targetGroup(){
|
public EntityGroup targetGroup(){
|
||||||
return unitGroups[team.ordinal()];
|
return unitGroups[team.ordinal()];
|
||||||
|
|||||||
@@ -112,9 +112,9 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
|||||||
@Override
|
@Override
|
||||||
public void onCommand(UnitCommand command){
|
public void onCommand(UnitCommand command){
|
||||||
state.set(command == UnitCommand.retreat ? retreat :
|
state.set(command == UnitCommand.retreat ? retreat :
|
||||||
(command == UnitCommand.attack ? attack :
|
command == UnitCommand.attack ? attack :
|
||||||
(command == UnitCommand.patrol ? patrol :
|
command == UnitCommand.patrol ? patrol :
|
||||||
(null))));
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -98,9 +98,9 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
@Override
|
@Override
|
||||||
public void onCommand(UnitCommand command){
|
public void onCommand(UnitCommand command){
|
||||||
state.set(command == UnitCommand.retreat ? retreat :
|
state.set(command == UnitCommand.retreat ? retreat :
|
||||||
(command == UnitCommand.attack ? attack :
|
command == UnitCommand.attack ? attack :
|
||||||
(command == UnitCommand.patrol ? patrol :
|
command == UnitCommand.patrol ? patrol :
|
||||||
(null))));
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class DeflectorWall extends Wall{
|
|||||||
|
|
||||||
protected float maxDamageDeflect = 10f;
|
protected float maxDamageDeflect = 10f;
|
||||||
protected Rectangle rect = new Rectangle();
|
protected Rectangle rect = new Rectangle();
|
||||||
|
protected Rectangle rect2 = new Rectangle();
|
||||||
|
|
||||||
public DeflectorWall(String name){
|
public DeflectorWall(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -54,8 +55,10 @@ public class DeflectorWall extends Wall{
|
|||||||
|
|
||||||
float penX = Math.abs(entity.x - bullet.x), penY = Math.abs(entity.y - bullet.y);
|
float penX = Math.abs(entity.x - bullet.x), penY = Math.abs(entity.y - bullet.y);
|
||||||
|
|
||||||
|
bullet.getHitbox(rect2);
|
||||||
|
|
||||||
Vector2 position = Physics.raycastRect(bullet.lastPosition().x, bullet.lastPosition().y, bullet.x, bullet.y,
|
Vector2 position = Physics.raycastRect(bullet.lastPosition().x, bullet.lastPosition().y, bullet.x, bullet.y,
|
||||||
rect.setCenter(entity.x, entity.y).setSize(size * tilesize + bullet.hitbox.width + bullet.hitbox.height));
|
rect.setCenter(entity.x, entity.y).setSize(size * tilesize + rect2.width + rect2.height));
|
||||||
|
|
||||||
if(position != null){
|
if(position != null){
|
||||||
bullet.set(position.x, position.y);
|
bullet.set(position.x, position.y);
|
||||||
|
|||||||
Reference in New Issue
Block a user