Many various internal changes
This commit is contained in:
@@ -88,7 +88,7 @@ public class Damage{
|
||||
tr.trns(angle, length);
|
||||
Intc2 collider = (cx, cy) -> {
|
||||
Tile tile = world.ltile(cx, cy);
|
||||
if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.entity != null && tile.getTeamID() != (int) team.id && tile.entity.collide(hitter)){
|
||||
if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.entity != null && tile.getTeamID() != (int)team.id && tile.entity.collide(hitter)){
|
||||
tile.entity.collision(hitter);
|
||||
collidedBlocks.add(tile.pos());
|
||||
hitter.getBulletType().hit(hitter, tile.worldx(), tile.worldy());
|
||||
|
||||
@@ -157,7 +157,7 @@ public class Units{
|
||||
|
||||
/** Iterates over all units in a rectangle. */
|
||||
public static void nearby(Team team, float x, float y, float width, float height, Cons<Unit> cons){
|
||||
unitGroups[(int) team.id].intersect(x, y, width, height, cons);
|
||||
unitGroups[(int)team.id].intersect(x, y, width, height, cons);
|
||||
playerGroup.intersect(x, y, width, height, player -> {
|
||||
if(player.getTeam() == team){
|
||||
cons.get(player);
|
||||
@@ -167,7 +167,7 @@ public class Units{
|
||||
|
||||
/** Iterates over all units in a circle around this position. */
|
||||
public static void nearby(Team team, float x, float y, float radius, Cons<Unit> cons){
|
||||
unitGroups[(int) team.id].intersect(x - radius, y - radius, radius*2f, radius*2f, unit -> {
|
||||
unitGroups[(int)team.id].intersect(x - radius, y - radius, radius*2f, radius*2f, unit -> {
|
||||
if(unit.withinDst(x, y, radius)){
|
||||
cons.get(unit);
|
||||
}
|
||||
@@ -183,7 +183,7 @@ public class Units{
|
||||
/** Iterates over all units in a rectangle. */
|
||||
public static void nearby(float x, float y, float width, float height, Cons<Unit> cons){
|
||||
for(Team team : Team.all){
|
||||
unitGroups[(int) team.id].intersect(x, y, width, height, cons);
|
||||
unitGroups[(int)team.id].intersect(x, y, width, height, cons);
|
||||
}
|
||||
|
||||
playerGroup.intersect(x, y, width, height, cons);
|
||||
@@ -199,7 +199,7 @@ public class Units{
|
||||
EnumSet<Team> targets = state.teams.enemiesOf(team);
|
||||
|
||||
for(Team other : targets){
|
||||
unitGroups[(int) other.id].intersect(x, y, width, height, cons);
|
||||
unitGroups[(int)other.id].intersect(x, y, width, height, cons);
|
||||
}
|
||||
|
||||
playerGroup.intersect(x, y, width, height, player -> {
|
||||
@@ -216,10 +216,7 @@ public class Units{
|
||||
|
||||
/** Iterates over all units. */
|
||||
public static void all(Cons<Unit> cons){
|
||||
for(Team team : Team.all){
|
||||
unitGroups[(int) team.id].all().each(cons);
|
||||
}
|
||||
|
||||
unitGroup.all().each(cons);
|
||||
playerGroup.all().each(cons);
|
||||
}
|
||||
|
||||
|
||||
@@ -185,23 +185,16 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
}
|
||||
}
|
||||
|
||||
public Tile getClosest(BlockFlag flag){
|
||||
public @Nullable Tile getClosest(BlockFlag flag){
|
||||
return Geometry.findClosest(x, y, indexer.getAllied(team, flag));
|
||||
}
|
||||
|
||||
public Tile getClosestSpawner(){
|
||||
public @Nullable Tile getClosestSpawner(){
|
||||
return Geometry.findClosest(x, y, Vars.spawner.getGroundSpawns());
|
||||
}
|
||||
|
||||
public TileEntity getClosestEnemyCore(){
|
||||
for(Team enemy : Vars.state.teams.enemiesOf(team)){
|
||||
Tile tile = Geometry.findClosest(x, y, Vars.state.teams.get(enemy).cores);
|
||||
if(tile != null){
|
||||
return tile.entity;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
public @Nullable TileEntity getClosestEnemyCore(){
|
||||
return Vars.state.teams.closestEnemyCore(x, y, team);
|
||||
}
|
||||
|
||||
public UnitState getStartState(){
|
||||
@@ -370,7 +363,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
|
||||
@Override
|
||||
public EntityGroup targetGroup(){
|
||||
return unitGroups[(int) team.id];
|
||||
return unitGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -124,7 +124,8 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
@CallSuper
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
stream.writeShort((short)health);
|
||||
stream.writeByte(Pack.byteByte(tile.getTeamID(), tile.rotation())); //team + rotation
|
||||
stream.writeByte(Pack.byteByte((byte)8, tile.rotation())); //rotation + marker to indicate that team is moved (8 isn't valid)
|
||||
stream.writeByte(tile.getTeamID());
|
||||
if(items != null) items.write(stream);
|
||||
if(power != null) power.write(stream);
|
||||
if(liquids != null) liquids.write(stream);
|
||||
@@ -134,11 +135,11 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
@CallSuper
|
||||
public void read(DataInput stream, byte revision) throws IOException{
|
||||
health = stream.readUnsignedShort();
|
||||
byte tr = stream.readByte();
|
||||
byte team = Pack.leftByte(tr);
|
||||
byte rotation = Pack.rightByte(tr);
|
||||
byte packedrot = stream.readByte();
|
||||
byte team = Pack.leftByte(packedrot) == 8 ? stream.readByte() : Pack.leftByte(packedrot);
|
||||
byte rotation = Pack.rightByte(packedrot);
|
||||
|
||||
tile.setTeam(Team.all[team]);
|
||||
tile.setTeam(Team.get(team));
|
||||
tile.rotation(rotation);
|
||||
|
||||
if(items != null) items.read(stream);
|
||||
@@ -277,7 +278,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
Events.fire(new BlockDestroyEvent(tile));
|
||||
block.breakSound.at(tile);
|
||||
block.onDestroyed(tile);
|
||||
world.removeBlock(tile);
|
||||
tile.remove();
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package mindustry.entities.type;
|
||||
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.content.*;
|
||||
@@ -16,13 +16,11 @@ import mindustry.entities.traits.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.Teams.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.net.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Cicon;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
@@ -158,7 +156,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
this.item.amount = itemAmount;
|
||||
this.item.item = content.item(itemID);
|
||||
this.dead = dead;
|
||||
this.team = Team.all[team];
|
||||
this.team = Team.get(team);
|
||||
this.health = health;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -169,7 +167,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
public void writeSave(DataOutput stream, boolean net) throws IOException{
|
||||
if(item.item == null) item.item = Items.copper;
|
||||
|
||||
stream.writeByte((int) team.id);
|
||||
stream.writeByte((int)team.id);
|
||||
stream.writeBoolean(isDead());
|
||||
stream.writeFloat(net ? interpolator.target.x : x);
|
||||
stream.writeFloat(net ? interpolator.target.y : y);
|
||||
@@ -217,13 +215,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
float fsize = getSize() / radScl;
|
||||
moveVector.setZero();
|
||||
float cx = x - fsize/2f, cy = y - fsize/2f;
|
||||
|
||||
for(Team team : Team.all){
|
||||
if(team != getTeam() || !(this instanceof Player)){
|
||||
avoid(unitGroups[(int) team.id].intersect(cx, cy, fsize, fsize));
|
||||
}
|
||||
}
|
||||
|
||||
avoid(unitGroup.intersect(cx, cy, fsize, fsize));
|
||||
if(!(this instanceof Player)){
|
||||
avoid(playerGroup.intersect(cx, cy, fsize, fsize));
|
||||
}
|
||||
@@ -242,14 +234,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
}
|
||||
|
||||
public @Nullable TileEntity getClosestCore(){
|
||||
TeamData data = state.teams.get(team);
|
||||
|
||||
Tile tile = Geometry.findClosest(x, y, data.cores);
|
||||
if(tile == null){
|
||||
return null;
|
||||
}else{
|
||||
return tile.entity;
|
||||
}
|
||||
return state.teams.closestCore(x, y, team);
|
||||
}
|
||||
|
||||
public Floor getFloorOn(){
|
||||
@@ -275,7 +260,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
}
|
||||
|
||||
//apply knockback based on spawns
|
||||
if(getTeam() != waveTeam){
|
||||
if(getTeam() != state.rules.waveTeam){
|
||||
float relativeSize = state.rules.dropZoneRadius + getSize()/2f + 1f;
|
||||
for(Tile spawn : spawner.getGroundSpawns()){
|
||||
if(withinDst(spawn.worldx(), spawn.worldy(), relativeSize)){
|
||||
|
||||
@@ -114,7 +114,7 @@ public class BuilderDrone extends BaseDrone implements BuilderTrait{
|
||||
public BuilderDrone(){
|
||||
if(reset.check()){
|
||||
Events.on(BuildSelectEvent.class, event -> {
|
||||
EntityGroup<BaseUnit> group = unitGroups[(int) event.team.id];
|
||||
EntityGroup<BaseUnit> group = unitGroups[(int)event.team.id];
|
||||
|
||||
if(!(event.tile.entity instanceof BuildEntity)) return;
|
||||
|
||||
|
||||
@@ -7,13 +7,14 @@ import mindustry.entities.type.BaseUnit;
|
||||
import mindustry.entities.type.TileEntity;
|
||||
import mindustry.gen.Call;
|
||||
import mindustry.type.Item;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class UnitDrops{
|
||||
private static Item[] dropTable;
|
||||
|
||||
public static void dropItems(BaseUnit unit){
|
||||
//items only dropped in waves for enemy team
|
||||
if(unit.getTeam() != Vars.waveTeam || !Vars.state.rules.unitDrops){
|
||||
if(unit.getTeam() != state.rules.waveTeam || !Vars.state.rules.unitDrops){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user