mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-02 20:33:50 +07:00
Bugfixes
This commit is contained in:
parent
0847fc9f09
commit
5c98512e4f
Binary file not shown.
Before Width: | Height: | Size: 810 B After Width: | Height: | Size: 805 B |
Binary file not shown.
Before Width: | Height: | Size: 187 KiB After Width: | Height: | Size: 185 KiB |
Binary file not shown.
Before Width: | Height: | Size: 188 KiB After Width: | Height: | Size: 186 KiB |
@ -33,7 +33,7 @@ public class BlockIndexer{
|
||||
/** Maps each team ID to a quarant. A quadrant is a grid of bits, where each bit is set if and only if there is a block of that team in that quadrant. */
|
||||
private GridBits[] structQuadrants;
|
||||
/** Stores all damaged tile entities by team. */
|
||||
private BuildingArray[] damagedTiles = new BuildingArray[Team.all.length];
|
||||
private ObjectSet<Building>[] damagedTiles = new ObjectSet[Team.all.length];
|
||||
/** All ores available on this map. */
|
||||
private ObjectSet<Item> allOres = new ObjectSet<>();
|
||||
/** Stores teams that are present here as tiles. */
|
||||
@ -70,7 +70,7 @@ public class BlockIndexer{
|
||||
Events.on(WorldLoadEvent.class, event -> {
|
||||
scanOres.clear();
|
||||
scanOres.addAll(Item.getAllOres());
|
||||
damagedTiles = new BuildingArray[Team.all.length];
|
||||
damagedTiles = new ObjectSet[Team.all.length];
|
||||
flagMap = new TileArray[Team.all.length][BlockFlag.all.length];
|
||||
unitCaps = new int[Team.all.length];
|
||||
activeTeams = new Seq<>(Team.class);
|
||||
@ -139,14 +139,14 @@ public class BlockIndexer{
|
||||
}
|
||||
|
||||
/** Returns all damaged tiles by team. */
|
||||
public BuildingArray getDamaged(Team team){
|
||||
returnArray.clear();
|
||||
public ObjectSet<Building> getDamaged(Team team){
|
||||
breturnArray.clear();
|
||||
|
||||
if(damagedTiles[team.id] == null){
|
||||
damagedTiles[team.id] = new BuildingArray();
|
||||
damagedTiles[team.id] = new ObjectSet<>();
|
||||
}
|
||||
|
||||
BuildingArray set = damagedTiles[team.id];
|
||||
ObjectSet<Building> set = damagedTiles[team.id];
|
||||
for(Building build : set){
|
||||
if((!build.isValid() || build.team != team || !build.damaged()) || build.block instanceof ConstructBlock){
|
||||
breturnArray.add(build);
|
||||
@ -214,7 +214,7 @@ public class BlockIndexer{
|
||||
|
||||
public void notifyTileDamaged(Building entity){
|
||||
if(damagedTiles[entity.team.id] == null){
|
||||
damagedTiles[entity.team.id] = new BuildingArray();
|
||||
damagedTiles[entity.team.id] = new ObjectSet<Building>();
|
||||
}
|
||||
|
||||
damagedTiles[entity.team.id].add(entity);
|
||||
@ -476,35 +476,4 @@ public class BlockIndexer{
|
||||
return tiles.iterator();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO copy-pasted code, generics would be nice here
|
||||
public static class BuildingArray implements Iterable<Building>{
|
||||
private Seq<Building> tiles = new Seq<>(false, 16);
|
||||
private IntSet contained = new IntSet();
|
||||
|
||||
public void add(Building tile){
|
||||
if(contained.add(tile.pos())){
|
||||
tiles.add(tile);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(Building tile){
|
||||
if(contained.remove(tile.pos())){
|
||||
tiles.remove(tile);
|
||||
}
|
||||
}
|
||||
|
||||
public int size(){
|
||||
return tiles.size;
|
||||
}
|
||||
|
||||
public Building first(){
|
||||
return tiles.first();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Building> iterator(){
|
||||
return tiles.iterator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1011,7 +1011,7 @@ public class Blocks implements ContentList{
|
||||
|
||||
mechanicalPump = new Pump("mechanical-pump"){{
|
||||
requirements(Category.liquid, with(Items.copper, 15, Items.metaglass, 10));
|
||||
pumpAmount = 0.1f;
|
||||
pumpAmount = 0.11f;
|
||||
}};
|
||||
|
||||
rotaryPump = new Pump("rotary-pump"){{
|
||||
@ -1136,7 +1136,7 @@ public class Blocks implements ContentList{
|
||||
requirements(Category.power, with(Items.copper, 35, Items.graphite, 25, Items.lead, 40, Items.silicon, 30));
|
||||
powerProduction = 5.5f;
|
||||
itemDuration = 90f;
|
||||
consumes.liquid(Liquids.water, 0.06f);
|
||||
consumes.liquid(Liquids.water, 0.07f);
|
||||
hasLiquids = true;
|
||||
size = 2;
|
||||
}};
|
||||
@ -1269,7 +1269,7 @@ public class Blocks implements ContentList{
|
||||
hasItems = true;
|
||||
|
||||
consumes.power(0.80f);
|
||||
consumes.liquid(Liquids.water, 0.18f);
|
||||
consumes.liquid(Liquids.water, 0.2f);
|
||||
}};
|
||||
|
||||
oilExtractor = new Fracker("oil-extractor"){{
|
||||
|
@ -2,6 +2,7 @@ package mindustry.editor;
|
||||
|
||||
import arc.func.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.editor.DrawOperation.*;
|
||||
import mindustry.game.*;
|
||||
@ -20,7 +21,7 @@ public class EditorTile extends Tile{
|
||||
|
||||
@Override
|
||||
public void setFloor(@NonNull Floor type){
|
||||
if(state.isGame()){
|
||||
if(skip()){
|
||||
super.setFloor(type);
|
||||
return;
|
||||
}
|
||||
@ -41,13 +42,11 @@ public class EditorTile extends Tile{
|
||||
|
||||
@Override
|
||||
public void setBlock(Block type, Team team, int rotation){
|
||||
if(state.isGame()){
|
||||
if(skip()){
|
||||
super.setBlock(type, team, rotation);
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.block == type && (build == null || build.rotation == rotation)) return;
|
||||
|
||||
if(rotation != 0) op(OpType.rotation, (byte)rotation);
|
||||
if(team() != Team.derelict) op(OpType.team, (byte)team().id);
|
||||
op(OpType.block, block.id);
|
||||
@ -56,7 +55,7 @@ public class EditorTile extends Tile{
|
||||
|
||||
@Override
|
||||
public void setTeam(Team team){
|
||||
if(state.isGame()){
|
||||
if(skip()){
|
||||
super.setTeam(team);
|
||||
return;
|
||||
}
|
||||
@ -68,7 +67,7 @@ public class EditorTile extends Tile{
|
||||
|
||||
@Override
|
||||
public void setOverlay(Block overlay){
|
||||
if(state.isGame()){
|
||||
if(skip()){
|
||||
super.setOverlay(overlay);
|
||||
return;
|
||||
}
|
||||
@ -81,7 +80,7 @@ public class EditorTile extends Tile{
|
||||
|
||||
@Override
|
||||
protected void fireChanged(){
|
||||
if(state.isGame()){
|
||||
if(skip()){
|
||||
super.fireChanged();
|
||||
}else{
|
||||
ui.editor.editor.renderer().updatePoint(x, y);
|
||||
@ -90,14 +89,14 @@ public class EditorTile extends Tile{
|
||||
|
||||
@Override
|
||||
public void recache(){
|
||||
if(state.isGame()){
|
||||
if(skip()){
|
||||
super.recache();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void changeEntity(Team team, Prov<Building> entityprov, int rotation){
|
||||
if(state.isGame()){
|
||||
if(skip()){
|
||||
super.changeEntity(team, entityprov, rotation);
|
||||
return;
|
||||
}
|
||||
@ -118,6 +117,10 @@ public class EditorTile extends Tile{
|
||||
}
|
||||
}
|
||||
|
||||
private boolean skip(){
|
||||
return state.isGame() || ui.editor.editor.isLoading();
|
||||
}
|
||||
|
||||
private void op(OpType type, short value){
|
||||
ui.editor.editor.addTileOp(TileOp.get(x, y, (byte)type.ordinal(), value));
|
||||
}
|
||||
|
@ -31,6 +31,10 @@ public class MapEditor{
|
||||
public Block drawBlock = Blocks.stone;
|
||||
public Team drawTeam = Team.sharded;
|
||||
|
||||
public boolean isLoading(){
|
||||
return loading;
|
||||
}
|
||||
|
||||
public StringMap getTags(){
|
||||
return tags;
|
||||
}
|
||||
@ -52,7 +56,7 @@ public class MapEditor{
|
||||
if(map.file.parent().parent().name().equals("1127400") && steam){
|
||||
tags.put("steamid", map.file.parent().name());
|
||||
}
|
||||
MapIO.loadMap(map, context);
|
||||
load(() -> MapIO.loadMap(map, context));
|
||||
renderer.resize(width(), height());
|
||||
loading = false;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class MapRenderer implements Disposable{
|
||||
wx * tilesize + wall.offset + (tilesize - width) / 2f,
|
||||
wy * tilesize + wall.offset + (tilesize - height) / 2f,
|
||||
width, height,
|
||||
tile.build == null || !wall.rotate ? 0 : tile.build.rotdeg() - 90);
|
||||
tile.build == null || !wall.rotate ? 0 : tile.build.rotdeg());
|
||||
}else{
|
||||
region = floor.editorVariantRegions()[Mathf.randomSeed(idxWall, 0, floor.editorVariantRegions().length - 1)];
|
||||
|
||||
|
@ -115,7 +115,9 @@ public class Fonts{
|
||||
|
||||
/** Called from a static context for use in the loading screen.*/
|
||||
public static void loadDefaultFont(){
|
||||
UI.packer = new PixmapPacker(2048, 2048, Format.rgba8888, 2, true);
|
||||
int max = Gl.getInt(Gl.maxTextureSize);
|
||||
|
||||
UI.packer = new PixmapPacker(max >= 4096 ? 4096 : 2048, 2048, Format.rgba8888, 2, true);
|
||||
FileHandleResolver resolver = new InternalFileHandleResolver();
|
||||
Core.assets.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
|
||||
Core.assets.setLoader(Font.class, null, new FreetypeFontLoader(resolver){
|
||||
|
@ -232,18 +232,22 @@ public class Generators{
|
||||
|
||||
boolean hasEmpty = false;
|
||||
Color average = new Color();
|
||||
float asum = 0f;
|
||||
for(int x = 0; x < image.width; x++){
|
||||
for(int y = 0; y < image.height; y++){
|
||||
Color color = image.getColor(x, y);
|
||||
average.r += color.r;
|
||||
average.g += color.g;
|
||||
average.b += color.b;
|
||||
average.r += color.r*color.a;
|
||||
average.g += color.g*color.a;
|
||||
average.b += color.b*color.a;
|
||||
asum += color.a;
|
||||
if(color.a < 0.9f){
|
||||
hasEmpty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
average.mul(1f / (image.width * image.height));
|
||||
|
||||
average.mul(1f / asum);
|
||||
|
||||
if(block instanceof Floor){
|
||||
average.mul(0.8f);
|
||||
}else{
|
||||
|
Loading…
Reference in New Issue
Block a user