mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-26 07:37:54 +07:00
Editor crash fix
This commit is contained in:
@ -102,6 +102,15 @@ public class EditorTile extends Tile{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void firePreChanged(){
|
||||||
|
if(skip()){
|
||||||
|
super.firePreChanged();
|
||||||
|
}else{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recache(){
|
public void recache(){
|
||||||
if(skip()){
|
if(skip()){
|
||||||
|
@ -82,6 +82,13 @@ public class Drawf{
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void dashRect(Color color, Rect rect){
|
||||||
|
dashLine(color, rect.x, rect.y, rect.x + rect.width, rect.y);
|
||||||
|
dashLine(color, rect.x, rect.y, rect.x, rect.y + rect.height);
|
||||||
|
dashLine(color, rect.x + rect.width, rect.y, rect.x + rect.width, rect.y + rect.height);
|
||||||
|
dashLine(color, rect.x, rect.y + rect.height, rect.x + rect.width, rect.y + rect.height);
|
||||||
|
}
|
||||||
|
|
||||||
public static void target(float x, float y, float rad, Color color){
|
public static void target(float x, float y, float rad, Color color){
|
||||||
target(x, y, rad, 1, color);
|
target(x, y, rad, 1, color);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
|
|||||||
|
|
||||||
tile.block = tile.floor.asFloor().wall;
|
tile.block = tile.floor.asFloor().wall;
|
||||||
|
|
||||||
if(Ridged.noise3d(1, position.x, position.y, position.z, 2, 14) > 0.15){
|
if(Ridged.noise3d(1, position.x, position.y, position.z, 2, 14) > 0.14){
|
||||||
tile.block = Blocks.air;
|
tile.block = Blocks.air;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void preChanged(){
|
protected void preChanged(){
|
||||||
firePreChange();
|
firePreChanged();
|
||||||
|
|
||||||
if(build != null){
|
if(build != null){
|
||||||
//only call removed() for the center block - this only gets called once.
|
//only call removed() for the center block - this only gets called once.
|
||||||
@ -552,7 +552,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
|||||||
//reset entity and block *manually* - thus, preChanged() will not be called anywhere else, for multiblocks
|
//reset entity and block *manually* - thus, preChanged() will not be called anywhere else, for multiblocks
|
||||||
if(other != this){ //do not remove own entity so it can be processed in changed()
|
if(other != this){ //do not remove own entity so it can be processed in changed()
|
||||||
//manually call pre-change event for other tile
|
//manually call pre-change event for other tile
|
||||||
other.firePreChange();
|
other.firePreChanged();
|
||||||
|
|
||||||
other.build = null;
|
other.build = null;
|
||||||
other.block = Blocks.air;
|
other.block = Blocks.air;
|
||||||
@ -634,7 +634,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void firePreChange(){
|
protected void firePreChanged(){
|
||||||
if(!world.isGenerating()){
|
if(!world.isGenerating()){
|
||||||
|
|
||||||
//same as above
|
//same as above
|
||||||
|
80
core/src/mindustry/world/blocks/units/UnitAssembler.java
Normal file
80
core/src/mindustry/world/blocks/units/UnitAssembler.java
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
package mindustry.world.blocks.units;
|
||||||
|
|
||||||
|
import arc.math.geom.*;
|
||||||
|
import arc.struct.*;
|
||||||
|
import arc.util.*;
|
||||||
|
import mindustry.content.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.type.*;
|
||||||
|
import mindustry.world.blocks.payloads.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Steps:
|
||||||
|
* 0. place the assembler with the rectangle indicating build area
|
||||||
|
* 1. wait for power/consValid
|
||||||
|
* 2. print / create the 3-5 drones for free, make sure they're tethered - build speed depends on drone active fraction
|
||||||
|
* 3.
|
||||||
|
* */
|
||||||
|
public class UnitAssembler extends PayloadBlock{
|
||||||
|
public int areaSize = 10;
|
||||||
|
public UnitType unitType;
|
||||||
|
public int unitsCreated = 4;
|
||||||
|
|
||||||
|
public UnitAssembler(String name){
|
||||||
|
super(name);
|
||||||
|
update = solid = true;
|
||||||
|
rotate = true;
|
||||||
|
rotateDraw = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||||
|
super.drawPlace(x, y, rotation, valid);
|
||||||
|
|
||||||
|
x *= tilesize;
|
||||||
|
y *= tilesize;
|
||||||
|
|
||||||
|
Tmp.r1.setCentered(x, y, areaSize * tilesize);
|
||||||
|
float len = tilesize * (areaSize + size)/2f;
|
||||||
|
|
||||||
|
Tmp.r1.x += Geometry.d4x(rotation) * len;
|
||||||
|
Tmp.r1.y += Geometry.d4y(rotation) * len;
|
||||||
|
|
||||||
|
//TODO better visuals here?
|
||||||
|
Drawf.dashRect(valid ? Pal.accent : Pal.remove, Tmp.r1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UnitAssemblerBuild extends PayloadBlockBuild<Payload>{
|
||||||
|
public Seq<Unit> units = new Seq<>();
|
||||||
|
public Seq<BuildPayload> payloads = new Seq<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTile(){
|
||||||
|
units.removeAll(u -> !u.isAdded() || u.dead);
|
||||||
|
|
||||||
|
if(consValid() && units.size < unitsCreated){
|
||||||
|
//TODO build animation? distribute spawning?
|
||||||
|
var unit = unitType.create(team);
|
||||||
|
if(unit instanceof BuildingTetherc bt){
|
||||||
|
bt.building(this);
|
||||||
|
}
|
||||||
|
unit.set(x, y);
|
||||||
|
unit.rotation = 90f;
|
||||||
|
unit.add();
|
||||||
|
|
||||||
|
Fx.spawn.at(unit);
|
||||||
|
units.add(unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO drones need to indicate that they are in position
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptPayload(Building source, Payload payload){
|
||||||
|
return super.acceptPayload(source, payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user