This commit is contained in:
Anuken
2020-10-18 09:08:47 -04:00
parent 521d44714d
commit c1c41a19c8
16 changed files with 30 additions and 30 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ public class BaseAI{
private static final Vec2 axis = new Vec2(), rotator = new Vec2(); private static final Vec2 axis = new Vec2(), rotator = new Vec2();
private static final float correctPercent = 0.5f; private static final float correctPercent = 0.5f;
private static final float step = 5; private static final float step = 5;
private static final int attempts = 5; private static final int attempts = 4;
private static final float emptyChance = 0.01f; private static final float emptyChance = 0.01f;
private static final int timerStep = 0, timerSpawn = 1; private static final int timerStep = 0, timerSpawn = 1;
+1 -1
View File
@@ -103,7 +103,7 @@ public class Pathfinder implements Runnable{
boolean nearLiquid = false, nearSolid = false, nearGround = false; boolean nearLiquid = false, nearSolid = false, nearGround = false;
for(int i = 0; i < 4; i++){ for(int i = 0; i < 4; i++){
Tile other = tile.getNearby(i); Tile other = tile.nearby(i);
if(other != null){ if(other != null){
if(other.floor().isLiquid) nearLiquid = true; if(other.floor().isLiquid) nearLiquid = true;
if(other.solid()) nearSolid = true; if(other.solid()) nearSolid = true;
+2 -2
View File
@@ -105,9 +105,9 @@ public class EditorTile extends Tile{
} }
@Override @Override
protected void changeEntity(Team team, Prov<Building> entityprov, int rotation){ protected void changeBuild(Team team, Prov<Building> entityprov, int rotation){
if(skip()){ if(skip()){
super.changeEntity(team, entityprov, rotation); super.changeBuild(team, entityprov, rotation);
return; return;
} }
@@ -51,7 +51,7 @@ public class MapGenerateDialog extends BaseDialog{
CachedTile ctile = new CachedTile(){ CachedTile ctile = new CachedTile(){
//nothing. //nothing.
@Override @Override
protected void changeEntity(Team team, Prov<Building> entityprov, int rotation){ protected void changeBuild(Team team, Prov<Building> entityprov, int rotation){
} }
}; };
@@ -464,7 +464,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
*/ */
public boolean movePayload(Payload todump){ public boolean movePayload(Payload todump){
int trns = block.size/2 + 1; int trns = block.size/2 + 1;
Tile next = tile.getNearby(Geometry.d4(rotation).x * trns, Geometry.d4(rotation).y * trns); Tile next = tile.nearby(Geometry.d4(rotation).x * trns, Geometry.d4(rotation).y * trns);
if(next != null && next.build != null && next.build.team == team && next.build.acceptPayload(self(), todump)){ if(next != null && next.build != null && next.build.team == team && next.build.acceptPayload(self(), todump)){
next.build.handlePayload(self(), todump); next.build.handlePayload(self(), todump);
@@ -547,7 +547,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
} }
public float moveLiquidForward(boolean leaks, Liquid liquid){ public float moveLiquidForward(boolean leaks, Liquid liquid){
Tile next = tile.getNearby(rotation); Tile next = tile.nearby(rotation);
if(next == null) return 0; if(next == null) return 0;
+3 -3
View File
@@ -229,8 +229,8 @@ public class EventType{
} }
/** /**
* Called when block building begins by placing down the BuildBlock. * Called when block building begins by placing down the ConstructBlock.
* The tile's block will nearly always be a BuildBlock. * The tile's block will nearly always be a ConstructBlock.
*/ */
public static class BlockBuildBeginEvent{ public static class BlockBuildBeginEvent{
public final Tile tile; public final Tile tile;
@@ -262,7 +262,7 @@ public class EventType{
/** /**
* Called when a player or drone begins building something. * Called when a player or drone begins building something.
* This does not necessarily happen when a new BuildBlock is created. * This does not necessarily happen when a new ConstructBlock is created.
*/ */
public static class BuildSelectEvent{ public static class BuildSelectEvent{
public final Tile tile; public final Tile tile;
@@ -414,7 +414,7 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
state.rules.attackMode = sector.info.attack = true; state.rules.attackMode = sector.info.attack = true;
}else{ }else{
state.rules.winWave = sector.info.winWave = 15 * (int)Math.max(difficulty * 10, 1); state.rules.winWave = sector.info.winWave = 10 + 5 * (int)Math.max(difficulty * 10, 1);
} }
state.rules.waves = sector.info.waves = true; state.rules.waves = sector.info.waves = true;
+1 -1
View File
@@ -45,7 +45,7 @@ public class Build{
Core.app.post(() -> Events.fire(new BlockBuildBeginEvent(tile, team, true))); Core.app.post(() -> Events.fire(new BlockBuildBeginEvent(tile, team, true)));
} }
/** Places a BuildBlock at this location. */ /** Places a ConstructBlock at this location. */
@Remote(called = Loc.server) @Remote(called = Loc.server)
public static void beginPlace(Block result, Team team, int x, int y, int rotation){ public static void beginPlace(Block result, Team team, int x, int y, int rotation){
if(!validPlace(result, team, x, y, rotation)){ if(!validPlace(result, team, x, y, rotation)){
+1 -1
View File
@@ -21,7 +21,7 @@ public class CachedTile extends Tile{
} }
@Override @Override
protected void changeEntity(Team team, Prov<Building> entityprov, int rotation){ protected void changeBuild(Team team, Prov<Building> entityprov, int rotation){
build = null; build = null;
Block block = block(); Block block = block();
+7 -7
View File
@@ -45,7 +45,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
this.block = wall; this.block = wall;
//update entity and create it if needed //update entity and create it if needed
changeEntity(Team.derelict, wall::newBuilding, 0); changeBuild(Team.derelict, wall::newBuilding, 0);
changed(); changed();
} }
@@ -186,7 +186,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
this.block = type; this.block = type;
preChanged(); preChanged();
changeEntity(team, entityprov, (byte)Mathf.mod(rotation, 4)); changeBuild(team, entityprov, (byte)Mathf.mod(rotation, 4));
if(build != null){ if(build != null){
build.team(team); build.team(team);
@@ -430,15 +430,15 @@ public class Tile implements Position, QuadTreeObject, Displayable{
getHitbox(rect); getHitbox(rect);
} }
public Tile getNearby(Point2 relative){ public Tile nearby(Point2 relative){
return world.tile(x + relative.x, y + relative.y); return world.tile(x + relative.x, y + relative.y);
} }
public Tile getNearby(int dx, int dy){ public Tile nearby(int dx, int dy){
return world.tile(x + dx, y + dy); return world.tile(x + dx, y + dy);
} }
public Tile getNearby(int rotation){ public Tile nearby(int rotation){
if(rotation == 0) return world.tile(x + 1, y); if(rotation == 0) return world.tile(x + 1, y);
if(rotation == 1) return world.tile(x, y + 1); if(rotation == 1) return world.tile(x, y + 1);
if(rotation == 2) return world.tile(x - 1, y); if(rotation == 2) return world.tile(x - 1, y);
@@ -446,7 +446,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
return null; return null;
} }
public Building getNearbyEntity(int rotation){ public Building nearbyBuild(int rotation){
if(rotation == 0) return world.build(x + 1, y); if(rotation == 0) return world.build(x + 1, y);
if(rotation == 1) return world.build(x, y + 1); if(rotation == 1) return world.build(x, y + 1);
if(rotation == 2) return world.build(x - 1, y); if(rotation == 2) return world.build(x - 1, y);
@@ -503,7 +503,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
} }
} }
protected void changeEntity(Team team, Prov<Building> entityprov, int rotation){ protected void changeBuild(Team team, Prov<Building> entityprov, int rotation){
if(build != null){ if(build != null){
int size = build.block.size; int size = build.block.size;
build.remove(); build.remove();
@@ -133,7 +133,7 @@ public interface Autotiler{
for(int i = 0; i < 4; i++){ for(int i = 0; i < 4; i++){
int realDir = Mathf.mod(rotation - i, 4); int realDir = Mathf.mod(rotation - i, 4);
if(blends(tile, rotation, directional, i, world) && (tile != null && tile.getNearbyEntity(realDir) != null && !tile.getNearbyEntity(realDir).block.squareSprite)){ if(blends(tile, rotation, directional, i, world) && (tile != null && tile.nearbyBuild(realDir) != null && !tile.nearbyBuild(realDir).block.squareSprite)){
blendresult[4] |= (1 << i); blendresult[4] |= (1 << i);
} }
} }
@@ -194,7 +194,7 @@ public interface Autotiler{
// TODO docs -- use for direction? // TODO docs -- use for direction?
default boolean blends(Tile tile, int rotation, int direction){ default boolean blends(Tile tile, int rotation, int direction){
Building other = tile.getNearbyEntity(Mathf.mod(rotation - direction, 4)); Building other = tile.nearbyBuild(Mathf.mod(rotation - direction, 4));
return other != null && other.team == tile.team() && blends(tile, rotation, other.tileX(), other.tileY(), other.rotation, other.block); return other != null && other.team == tile.team() && blends(tile, rotation, other.tileX(), other.tileY(), other.rotation, other.block);
} }
@@ -42,7 +42,7 @@ public class ConstructBlock extends Block{
consBlocks[size - 1] = this; consBlocks[size - 1] = this;
} }
/** Returns a BuildBlock by size. */ /** Returns a ConstructBlock by size. */
public static ConstructBlock get(int size){ public static ConstructBlock get(int size){
if(size > maxSize) throw new IllegalArgumentException("No. Don't place ConstructBlock of size greater than " + maxSize); if(size > maxSize) throw new IllegalArgumentException("No. Don't place ConstructBlock of size greater than " + maxSize);
return consBlocks[size - 1]; return consBlocks[size - 1];
@@ -202,7 +202,7 @@ public class ItemBridge extends Block{
for(int i = 1; i <= range; i++){ for(int i = 1; i <= range; i++){
for(int j = 0; j < 4; j++){ for(int j = 0; j < 4; j++){
Tile other = tile.getNearby(Geometry.d4[j].x * i, Geometry.d4[j].y * i); Tile other = tile.nearby(Geometry.d4[j].x * i, Geometry.d4[j].y * i);
if(linkValid(tile, other)){ if(linkValid(tile, other)){
boolean linked = other.pos() == link; boolean linked = other.pos() == link;
@@ -87,7 +87,7 @@ public class PayloadConveyor extends Block{
} }
int ntrns = 1 + size/2; int ntrns = 1 + size/2;
Tile next = tile.getNearby(Geometry.d4(rotation).x * ntrns, Geometry.d4(rotation).y * ntrns); Tile next = tile.nearby(Geometry.d4(rotation).x * ntrns, Geometry.d4(rotation).y * ntrns);
blocked = (next != null && next.solid() && !next.block().outputsPayload) || (this.next != null && (this.next.rotation + 2)%4 == rotation); blocked = (next != null && next.solid() && !next.block().outputsPayload) || (this.next != null && (this.next.rotation + 2)%4 == rotation);
} }
@@ -183,7 +183,7 @@ public class Floor extends Block{
for(int i = 0; i < 8; i++){ for(int i = 0; i < 8; i++){
Point2 point = Geometry.d8[i]; Point2 point = Geometry.d8[i];
Tile other = tile.getNearby(point); Tile other = tile.nearby(point);
if(other != null && other.floor().cacheLayer == layer && other.floor().edges() != null){ if(other != null && other.floor().cacheLayer == layer && other.floor().edges() != null){
if(!blended.getAndSet(other.floor().id)){ if(!blended.getAndSet(other.floor().id)){
blenders.add(other.floor()); blenders.add(other.floor());
@@ -200,7 +200,7 @@ public class Floor extends Block{
for(int i = 0; i < 8; i++){ for(int i = 0; i < 8; i++){
Point2 point = Geometry.d8[i]; Point2 point = Geometry.d8[i];
Tile other = tile.getNearby(point); Tile other = tile.nearby(point);
if(other != null && doEdge(other.floor()) && other.floor().cacheLayer == cacheLayer && other.floor().edges() != null){ if(other != null && doEdge(other.floor()) && other.floor().cacheLayer == cacheLayer && other.floor().edges() != null){
if(!blended.getAndSet(other.floor().id)){ if(!blended.getAndSet(other.floor().id)){
blenders.add(other.floor()); blenders.add(other.floor());
@@ -217,7 +217,7 @@ public class Floor extends Block{
for(Block block : blenders){ for(Block block : blenders){
for(int i = 0; i < 8; i++){ for(int i = 0; i < 8; i++){
Point2 point = Geometry.d8[i]; Point2 point = Geometry.d8[i];
Tile other = tile.getNearby(point); Tile other = tile.nearby(point);
if(other != null && other.floor() == block){ if(other != null && other.floor() == block){
TextureRegion region = edge((Floor)block, 1 - point.x, 1 - point.y); TextureRegion region = edge((Floor)block, 1 - point.x, 1 - point.y);
Draw.rect(region, tile.worldx(), tile.worldy()); Draw.rect(region, tile.worldx(), tile.worldy());
@@ -229,7 +229,7 @@ public class Floor extends Block{
//'new' style of edges with shadows instead of colors, not used currently //'new' style of edges with shadows instead of colors, not used currently
protected void drawEdgesFlat(Tile tile, boolean sameLayer){ protected void drawEdgesFlat(Tile tile, boolean sameLayer){
for(int i = 0; i < 4; i++){ for(int i = 0; i < 4; i++){
Tile other = tile.getNearby(i); Tile other = tile.nearby(i);
if(other != null && doEdge(other.floor())){ if(other != null && doEdge(other.floor())){
Color color = other.floor().mapColor; Color color = other.floor().mapColor;
Draw.color(color.r, color.g, color.b, 1f); Draw.color(color.r, color.g, color.b, 1f);
@@ -21,7 +21,7 @@ public class StaticTree extends StaticWall{
float oy = 0; float oy = 0;
for(int i = 0; i < 4; i++){ for(int i = 0; i < 4; i++){
if(tile.getNearby(i) != null && tile.getNearby(i).block() instanceof StaticWall){ if(tile.nearby(i) != null && tile.nearby(i).block() instanceof StaticWall){
if(i == 0){ if(i == 0){
r.setWidth(r.width - crop); r.setWidth(r.width - crop);