Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anuken 2020-08-08 14:14:43 -04:00
commit 0fc246cfdc
11 changed files with 47 additions and 48 deletions

View File

@ -40,20 +40,20 @@ In general, if you are using IntelliJ, you should be warned about platform incom
#### Use `arc` collections and classes when possible.
Instead of using `java.util.List`, `java.util.HashMap`, and other standard Java collections, use `Array`, `ObjectMap` and other equivalents from `arc.struct`.
Instead of using `java.util.List`, `java.util.HashMap`, and other standard Java collections, use `Seq`, `ObjectMap` and other equivalents from `arc.struct`.
Why? Because that's what the rest of the codebase uses, and the standard collections have a lot of cruft and usability issues associated with them.
In the rare case that concurrency is required, you may use the standard Java classes for that purpose (e.g. `CopyOnWriteArrayList`).
What you'll usually need to change:
- `HashSet` -> `ObjectSet`
- `HashMap` -> `ObjectMap`
- `List` / `ArrayList` / `Stack` -> `Array`
- `List` / `ArrayList` / `Stack` -> `Seq`
- `java.util.Queue` -> `arc.struct.Queue`
- *Many others*
#### Avoid boxed types (Integer, Boolean)
Never create variables or collections with boxed types `Array<Integer>` or `ObjectMap<Integer, ...>`. Use the collections specialized for this task, e.g. `IntArray` and `IntMap`.
Never create variables or collections with boxed types `Seq<Integer>` or `ObjectMap<Integer, ...>`. Use the collections specialized for this task, e.g. `IntSeq` and `IntMap`.
#### Do not allocate anything if possible.

View File

@ -94,24 +94,24 @@ public class Conveyor extends Block implements Autotiler{
public class ConveyorEntity extends Building{
//parallel array data
Item[] ids = new Item[capacity];
float[] xs = new float[capacity];
float[] ys = new float[capacity];
public Item[] ids = new Item[capacity];
public float[] xs = new float[capacity];
public float[] ys = new float[capacity];
//amount of items, always < capacity
int len = 0;
public int len = 0;
//next entity
@Nullable Building next;
@Nullable ConveyorEntity nextc;
public @Nullable Building next;
public @Nullable ConveyorEntity nextc;
//whether the next conveyor's rotation == tile rotation
boolean aligned;
public boolean aligned;
int lastInserted, mid;
float minitem = 1;
public int lastInserted, mid;
public float minitem = 1;
int blendbits, blending;
int blendsclx, blendscly;
public int blendbits, blending;
public int blendsclx, blendscly;
float clogHeat = 0f;
public float clogHeat = 0f;
@Override
public void draw(){
@ -350,7 +350,7 @@ public class Conveyor extends Block implements Autotiler{
}
final void add(int o){
public final void add(int o){
for(int i = Math.max(o + 1, len); i > o; i--){
ids[i] = ids[i - 1];
xs[i] = xs[i - 1];
@ -360,7 +360,7 @@ public class Conveyor extends Block implements Autotiler{
len++;
}
final void remove(int o){
public final void remove(int o){
for(int i = o; i < len - 1; i++){
ids[i] = ids[i + 1];
xs[i] = xs[i + 1];

View File

@ -15,7 +15,7 @@ public class ExtendingItemBridge extends ItemBridge{
super(name);
hasItems = true;
}
public class ExtendingItemBridgeEntity extends ItemBridgeEntity{
@Override
public void draw(){

View File

@ -357,7 +357,7 @@ public class ItemBridge extends Block{
return liquids.get(liquid) + amount < liquidCapacity && (liquids.current() == liquid || liquids.get(liquids.current()) < 0.2f);
}
private boolean linked(Building source){
protected boolean linked(Building source){
return source instanceof ItemBridgeEntity && linkValid(source.tile(), tile) && ((ItemBridgeEntity)source).link == pos();
}

View File

@ -27,7 +27,7 @@ public class Junction extends Block{
}
public class JunctionEntity extends Building{
DirectionalItemBuffer buffer = new DirectionalItemBuffer(capacity);
public DirectionalItemBuffer buffer = new DirectionalItemBuffer(capacity);
@Override
public int acceptStack(Item item, int amount, Teamc source){

View File

@ -86,13 +86,13 @@ public class MassDriver extends Block{
}
public class MassDriverEntity extends Building{
int link = -1;
float rotation = 90;
float reload = 0f;
DriverState state = DriverState.idle;
OrderedSet<Tile> waitingShooters = new OrderedSet<>();
public int link = -1;
public float rotation = 90;
public float reload = 0f;
public DriverState state = DriverState.idle;
public OrderedSet<Tile> waitingShooters = new OrderedSet<>();
Tile currentShooter(){
public Tile currentShooter(){
return waitingShooters.isEmpty() ? null : waitingShooters.first();
}
@ -322,7 +322,7 @@ public class MassDriver extends Block{
}
}
enum DriverState{
public enum DriverState{
idle, //nothing is shooting at this mass driver and it does not have any target
accepting, //currently getting shot at, unload items
shooting,

View File

@ -31,9 +31,9 @@ public class OverflowGate extends Block{
}
public class OverflowGateEntity extends Building{
Item lastItem;
Tile lastInput;
float time;
public Item lastItem;
public Tile lastInput;
public float time;
@Override
public int acceptStack(Item item, int amount, Teamc source){

View File

@ -136,7 +136,7 @@ public class PayloadConveyor extends Block{
super.draw();
}
@Override
@Override
public void draw(){
super.draw();
@ -241,15 +241,14 @@ public class PayloadConveyor extends Block{
}
}
boolean blends(int direction){
protected boolean blends(int direction){
if(direction == rotation){
return !blocked || next != null;
}else{
return PayloadAcceptor.blends(this, direction);
}
return PayloadAcceptor.blends(this, direction);
}
TextureRegion clipRegion(Rect bounds, Rect sprite, TextureRegion region){
protected TextureRegion clipRegion(Rect bounds, Rect sprite, TextureRegion region){
Rect over = Tmp.r3;
boolean overlaps = Intersector.intersectRectangles(bounds, sprite, over);
@ -273,11 +272,11 @@ public class PayloadConveyor extends Block{
return out;
}
int curStep(){
public int curStep(){
return (int)((Time.time()) / moveTime);
}
float fract(){
public float fract(){
return interp.apply(progress / moveTime);
}
}

View File

@ -20,9 +20,9 @@ public class Router extends Block{
}
public class RouterEntity extends Building{
Item lastItem;
Tile lastInput;
float time;
public Item lastItem;
public Tile lastInput;
public float time;
@Override
public void updateTile(){
@ -70,7 +70,7 @@ public class Router extends Block{
return result;
}
Building getTileTarget(Item item, Tile from, boolean set){
public Building getTileTarget(Item item, Tile from, boolean set){
int counter = rotation;
for(int i = 0; i < proximity.size; i++){
Building other = proximity.get((i + counter) % proximity.size);

View File

@ -48,7 +48,7 @@ public class Sorter extends Block{
}
public class SorterEntity extends Building{
@Nullable Item sortItem;
public @Nullable Item sortItem;
@Override
public void configured(Player player, Object value){
@ -86,12 +86,12 @@ public class Sorter extends Block{
to.handleItem(this, item);
}
boolean isSame(Building other){
//uncomment code below to prevent sorter/gate chaining
public boolean isSame(Building other){
// comment code below to allow sorter/gate chaining
return other != null && (other.block() instanceof Sorter || other.block() instanceof OverflowGate);
}
Building getTileTarget(Item item, Building source, boolean flip){
public Building getTileTarget(Item item, Building source, boolean flip){
int dir = source.relativeTo(tile.x, tile.y);
if(dir == -1) return null;
Building to;

View File

@ -147,7 +147,7 @@ public class StackConveyor extends Block implements Autotiler{
int[] bits = buildBlending(tile, rotation, null, true);
if(bits[0] == 0 && blends(tile, rotation, 0) && !blends(tile, rotation, 2)) state = stateLoad; // a 0 that faces into a conveyor with none behind it
if(bits[0] == 0 && !blends(tile, rotation, 0) && blends(tile, rotation, 2)) state = stateUnload; // a 0 that faces into none with a conveyor behind it
blendprox = 0;
for(int i = 0; i < 4; i++){
@ -219,12 +219,12 @@ public class StackConveyor extends Block implements Autotiler{
return false; // has no moving parts;
}
private void poofIn(){
protected void poofIn(){
link = tile.pos();
Fx.plasticburn.at(this);
}
private void poofOut(){
protected void poofOut(){
Fx.plasticburn.at(this);
link = -1;
}