mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-04-27 16:00:51 -07:00
Make an interface for blocks that spawn tethered units (#8395)
This commit is contained in:
parent
4be7cf5c0e
commit
90f7bbae65
2 changed files with 10 additions and 4 deletions
5
core/src/mindustry/world/blocks/UnitTetherBlock.java
Normal file
5
core/src/mindustry/world/blocks/UnitTetherBlock.java
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
package mindustry.world.blocks;
|
||||
|
||||
public interface UnitTetherBlock{
|
||||
void spawned(int id);
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ import mindustry.graphics.*;
|
|||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
|
|
@ -75,12 +76,12 @@ public class UnitCargoLoader extends Block{
|
|||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void cargoLoaderDroneSpawned(Tile tile, int id){
|
||||
if(tile == null || !(tile.build instanceof UnitTransportSourceBuild build)) return;
|
||||
public static void unitTetherBlockSpawned(Tile tile, int id){
|
||||
if(tile == null || !(tile.build instanceof UnitTetherBlock build)) return;
|
||||
build.spawned(id);
|
||||
}
|
||||
|
||||
public class UnitTransportSourceBuild extends Building{
|
||||
public class UnitTransportSourceBuild extends Building implements UnitTetherBlock{
|
||||
//needs to be "unboxed" after reading, since units are read after buildings.
|
||||
public int readUnitId = -1;
|
||||
public float buildProgress, totalProgress;
|
||||
|
|
@ -117,7 +118,7 @@ public class UnitCargoLoader extends Block{
|
|||
unit.set(x, y);
|
||||
unit.rotation = 90f;
|
||||
unit.add();
|
||||
Call.cargoLoaderDroneSpawned(tile, unit.id);
|
||||
Call.unitTetherBlockSpawned(tile, unit.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue