mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-10 18:57:39 +07:00
Merge branch '6.0' into crater
# Conflicts: # core/assets/icons/icons.properties # core/assets/sprites/block_colors.png # core/assets/sprites/sprites.atlas # core/assets/sprites/sprites.png # core/assets/sprites/sprites2.png # core/assets/sprites/sprites4.png # core/assets/sprites/sprites6.png
This commit is contained in:
commit
32e32ecae2
@ -26,6 +26,12 @@ public class Annotations{
|
||||
public @interface Replace{
|
||||
}
|
||||
|
||||
/** Indicates that a method should be final in all implementing classes. */
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface Final{
|
||||
}
|
||||
|
||||
/** Indicates that a component field is imported from other components. */
|
||||
@Target({ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
@ -308,7 +308,7 @@ public class EntityProcess extends BaseProcessor{
|
||||
|
||||
//build method using same params/returns
|
||||
MethodSpec.Builder mbuilder = MethodSpec.methodBuilder(first.name()).addModifiers(first.is(Modifier.PRIVATE) ? Modifier.PRIVATE : Modifier.PUBLIC);
|
||||
if(isFinal) mbuilder.addModifiers(Modifier.FINAL);
|
||||
if(isFinal || entry.value.contains(s -> s.has(Final.class))) mbuilder.addModifiers(Modifier.FINAL);
|
||||
if(first.is(Modifier.STATIC)) mbuilder.addModifiers(Modifier.STATIC);
|
||||
mbuilder.addTypeVariables(first.typeVariables().map(TypeVariableName::get));
|
||||
mbuilder.returns(first.retn());
|
||||
|
@ -1194,7 +1194,7 @@ block.force-projector.description = Creates a hexagonal force field around itsel
|
||||
block.shock-mine.description = Damages enemies stepping on the mine. Nearly invisible to the enemy.
|
||||
block.conveyor.description = Basic item transport block. Moves items forward and automatically deposits them into blocks. Rotatable.
|
||||
block.titanium-conveyor.description = Advanced item transport block. Moves items faster than standard conveyors.
|
||||
block.plastanium-conveyor.description = The \uf81c moves items in batches.\nOnly accepts items at the back.\nLoads & unloads on all 3 sides.
|
||||
block.plastanium-conveyor.description = The \uf818 moves items in batches.\nOnly accepts items at the back.\nLoads & unloads on all 3 sides.
|
||||
block.junction.description = Acts as a bridge for two crossing conveyor belts. Useful in situations with two different conveyors carrying different materials to different locations.
|
||||
block.bridge-conveyor.description = Advanced item transport block. Allows transporting items over up to 3 tiles of any terrain or building.
|
||||
block.phase-conveyor.description = Advanced item transport block. Uses power to teleport items to a connected phase conveyor over several tiles.
|
||||
|
@ -225,6 +225,8 @@
|
||||
63519=ground-factory|block-ground-factory-medium
|
||||
63518=legacy-unit-factory|block-legacy-unit-factory-medium
|
||||
63517=mass-conveyor|block-mass-conveyor-medium
|
||||
63516=crater|crater
|
||||
63515=plastanium-conveyor|block-plastanium-conveyor-medium
|
||||
63514=legacy-command-center|block-legacy-command-center-medium
|
||||
63516=legacy-command-center|block-legacy-command-center-medium
|
||||
63515=block-forge|block-block-forge-medium
|
||||
63514=block-launcher|block-block-launcher-medium
|
||||
63513=plastanium-conveyor|block-plastanium-conveyor-medium
|
||||
63512=crater|crater
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 711 B After Width: | Height: | Size: 711 B |
Binary file not shown.
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 126 KiB |
@ -18,6 +18,7 @@ import mindustry.world.blocks.defense.*;
|
||||
import mindustry.world.blocks.defense.turrets.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
import mindustry.world.blocks.experimental.*;
|
||||
import mindustry.world.blocks.legacy.*;
|
||||
import mindustry.world.blocks.liquid.*;
|
||||
import mindustry.world.blocks.logic.*;
|
||||
@ -76,7 +77,11 @@ public class Blocks implements ContentList{
|
||||
duo, scatter, scorch, hail, arc, wave, lancer, swarmer, salvo, fuse, ripple, cyclone, spectre, meltdown,
|
||||
|
||||
//units
|
||||
groundFactory, repairPoint
|
||||
groundFactory, repairPoint,
|
||||
|
||||
//misc experimental
|
||||
|
||||
blockForge, blockLauncher;
|
||||
|
||||
;
|
||||
|
||||
@ -1733,6 +1738,23 @@ public class Blocks implements ContentList{
|
||||
new LegacyUnitFactory("legacy-unit-factory");
|
||||
new LegacyCommandCenter("legacy-command-center");
|
||||
|
||||
//endregion
|
||||
//region experimental
|
||||
|
||||
blockForge = new BlockForge("block-forge"){{
|
||||
requirements(Category.production, ItemStack.with(Items.thorium, 100));
|
||||
hasPower = true;
|
||||
consumes.power(2f);
|
||||
size = 3;
|
||||
}};
|
||||
|
||||
blockLauncher = new BlockLauncher("block-launcher"){{
|
||||
requirements(Category.production, ItemStack.with(Items.thorium, 100));
|
||||
size = 3;
|
||||
hasPower = true;
|
||||
consumes.power(2f);
|
||||
}};
|
||||
|
||||
//endregion
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.experimental.BlockLauncher.*;
|
||||
|
||||
import static arc.graphics.g2d.Draw.*;
|
||||
import static arc.graphics.g2d.Lines.*;
|
||||
@ -86,6 +88,20 @@ public class Fx{
|
||||
Fill.circle(x, y, e.fslope() * 1.5f * size);
|
||||
}),
|
||||
|
||||
blockTransfer = new Effect(25f, e -> {
|
||||
if(!(e.data instanceof LaunchedBlock)) return;
|
||||
|
||||
LaunchedBlock l = e.data();
|
||||
|
||||
Block block = l.block;
|
||||
Position to = Tmp.v3.set(l.x * tilesize, l.y * tilesize).add(block.offset(), block.offset());
|
||||
|
||||
Tmp.v1.set(e.x, e.y).interpolate(Tmp.v2.set(to), e.fin(), Interpolation.linear);
|
||||
float x = Tmp.v1.x, y = Tmp.v1.y;
|
||||
|
||||
Draw.rect(block.icon(Cicon.full), x, y);
|
||||
}),
|
||||
|
||||
lightning = new Effect(10f, 500f, e -> {
|
||||
if(!(e.data instanceof Array)) return;
|
||||
Array<Vec2> lines = e.data();
|
||||
|
@ -1012,6 +1012,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
|
||||
remove();
|
||||
}
|
||||
|
||||
@Final
|
||||
@Override
|
||||
public void update(){
|
||||
timeScaleDuration -= Time.delta();
|
||||
|
@ -13,7 +13,9 @@ import static mindustry.Vars.state;
|
||||
|
||||
/** Renders overlay lights. Client only. */
|
||||
public class LightRenderer{
|
||||
public static boolean enable = true;
|
||||
private static final int scaling = 4;
|
||||
|
||||
private float[] vertices = new float[24];
|
||||
private FrameBuffer buffer = new FrameBuffer(2, 2);
|
||||
private Array<Runnable> lights = new Array<>();
|
||||
@ -178,6 +180,11 @@ public class LightRenderer{
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
if(!enable){
|
||||
lights.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if(buffer.getWidth() != Core.graphics.getWidth()/scaling || buffer.getHeight() != Core.graphics.getHeight()/scaling){
|
||||
buffer.resize(Core.graphics.getWidth()/scaling, Core.graphics.getHeight()/scaling);
|
||||
}
|
||||
|
140
core/src/mindustry/world/blocks/experimental/BlockForge.java
Normal file
140
core/src/mindustry/world/blocks/experimental/BlockForge.java
Normal file
@ -0,0 +1,140 @@
|
||||
package mindustry.world.blocks.experimental;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
|
||||
public class BlockForge extends Block{
|
||||
public float buildSpeed = 0.4f;
|
||||
|
||||
public BlockForge(String name){
|
||||
super(name);
|
||||
|
||||
size = 3;
|
||||
update = true;
|
||||
outputsPayload = true;
|
||||
hasItems = true;
|
||||
configurable = true;
|
||||
hasPower = true;
|
||||
|
||||
config(Block.class, (tile, block) -> ((BlockForgeEntity)tile).recipe = block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
||||
bars.add("progress", entity -> new Bar("bar.progress", Pal.ammo, () -> ((BlockForgeEntity)entity).progress));
|
||||
}
|
||||
|
||||
public class BlockForgeEntity extends TileEntity{
|
||||
public @Nullable Payload payload;
|
||||
public @Nullable Block recipe;
|
||||
public float progress, time, heat;
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
return items.get(item) < getMaximumAccepted(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumAccepted(Item item){
|
||||
if(recipe == null) return 0;
|
||||
for(ItemStack stack : recipe.requirements){
|
||||
if(stack.item == item) return stack.amount * 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
boolean produce = recipe != null && consValid() && payload == null && items.has(recipe.requirements);
|
||||
|
||||
if(produce){
|
||||
progress += buildSpeed * edelta();
|
||||
|
||||
if(progress >= recipe.buildCost){
|
||||
items.remove(recipe.requirements);
|
||||
payload = new BlockPayload(recipe);
|
||||
progress = 0f;
|
||||
}
|
||||
}else{
|
||||
progress = 0;
|
||||
}
|
||||
|
||||
heat = Mathf.lerpDelta(heat, Mathf.num(produce), 0.3f);
|
||||
time += heat * delta();
|
||||
|
||||
if(payload != null && dumpPayload(payload)){
|
||||
payload = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildConfiguration(Table table){
|
||||
Array<Block> blocks = Vars.content.blocks().select(b -> b.isVisible() && b.size <= 2 && b.requirements.length <= 3);
|
||||
|
||||
ItemSelection.buildTable(table, blocks, () -> recipe, block -> recipe = block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object config(){
|
||||
return recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
|
||||
if(payload != null){
|
||||
payload.draw(x, y, 0);
|
||||
}
|
||||
|
||||
if(recipe != null){
|
||||
TextureRegion region = recipe.icon(Cicon.full);
|
||||
|
||||
Shaders.build.region = region;
|
||||
Shaders.build.progress = progress / recipe.buildCost;
|
||||
Shaders.build.color.set(Pal.accent);
|
||||
Shaders.build.color.a = heat;
|
||||
Shaders.build.time = -time / 20f;
|
||||
|
||||
Draw.shader(Shaders.build);
|
||||
Draw.rect(region, x, y);
|
||||
Draw.shader();
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
Draw.alpha(heat);
|
||||
|
||||
Lines.lineAngleCenter(x + Mathf.sin(time, 20f, Vars.tilesize / 2f * size - 2f), y, 90, size * Vars.tilesize - 4f);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Writes write){
|
||||
super.write(write);
|
||||
write.s(recipe == null ? -1 : recipe.id);
|
||||
write.f(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(Reads read, byte revision){
|
||||
super.read(read, revision);
|
||||
recipe = Vars.content.block(read.s());
|
||||
progress = read.f();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package mindustry.world.blocks.experimental;
|
||||
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
//pointless, will definitely be removed eventually
|
||||
public class BlockLauncher extends PayloadAcceptor{
|
||||
static final IntArray positions = new IntArray();
|
||||
|
||||
public float range = 150;
|
||||
|
||||
public BlockLauncher(String name){
|
||||
super(name);
|
||||
|
||||
update = true;
|
||||
size = 3;
|
||||
}
|
||||
|
||||
public class BlockLauncherEntity extends PayloadAcceptorEntity{
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
|
||||
drawPayload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptPayload(Tilec source, Payload payload){
|
||||
return this.payload == null && payload instanceof BlockPayload;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(updatePayload() && efficiency() >= 0.99f){
|
||||
Effects.shake(4f, 4f, this);
|
||||
Fx.producesmoke.at(this);
|
||||
|
||||
positions.clear();
|
||||
BlockPayload pay = (BlockPayload)payload;
|
||||
|
||||
Geometry.circle(tileX(), tileY(), world.width(), world.height(), (int)(range / tilesize), (cx, cy) -> {
|
||||
if(Build.validPlace(team, cx, cy, pay.block, 0)){
|
||||
positions.add(Point2.pack(cx, cy));
|
||||
}
|
||||
});
|
||||
|
||||
if(positions.isEmpty()) return;
|
||||
|
||||
int pick = positions.random();
|
||||
LaunchedBlock launch = new LaunchedBlock(Point2.x(pick), Point2.y(pick), pay.block, team);
|
||||
Fx.blockTransfer.at(x, y, 0, launch);
|
||||
Time.run(Fx.blockTransfer.lifetime, () -> {
|
||||
float ex = launch.x * tilesize + launch.block.offset(), ey = launch.y * tilesize + launch.block.offset();
|
||||
if(Build.validPlace(launch.team, launch.x, launch.y, launch.block, 0)){
|
||||
world.tile(launch.x, launch.y).setBlock(launch.block, launch.team);
|
||||
Fx.placeBlock.at(ex, ey, launch.block.size);
|
||||
}else{
|
||||
Fx.breakBlock.at(ex, ey, launch.block.size);
|
||||
Fx.explosion.at(ex, ey);
|
||||
}
|
||||
});
|
||||
payload = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LaunchedBlock{
|
||||
public final int x, y;
|
||||
public final Block block;
|
||||
public final Team team;
|
||||
|
||||
public LaunchedBlock(int x, int y, Block block, Team team){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.block = block;
|
||||
this.team = team;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package mindustry.world.blocks.logic;
|
||||
package mindustry.world.blocks.experimental;
|
||||
|
||||
import arc.math.*;
|
||||
import mindustry.gen.*;
|
@ -1,4 +1,4 @@
|
||||
package mindustry.world.blocks.units;
|
||||
package mindustry.world.blocks.experimental;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
@ -1,4 +1,4 @@
|
||||
package mindustry.world.blocks.logic;
|
||||
package mindustry.world.blocks.experimental;
|
||||
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
22
core/src/mindustry/world/blocks/payloads/BlockPayload.java
Normal file
22
core/src/mindustry/world/blocks/payloads/BlockPayload.java
Normal file
@ -0,0 +1,22 @@
|
||||
package mindustry.world.blocks.payloads;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.tilesize;
|
||||
|
||||
public class BlockPayload implements Payload{
|
||||
public Block block;
|
||||
|
||||
public BlockPayload(Block block){
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(float x, float y, float rotation){
|
||||
Drawf.shadow(x, y, block.size * tilesize * 2f);
|
||||
Draw.rect(block.icon(Cicon.full), x, y, 0);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package mindustry.world.blocks.production;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
|
||||
import static mindustry.Vars.tilesize;
|
||||
|
||||
public class PayloadAcceptor extends Block{
|
||||
|
||||
public PayloadAcceptor(String name){
|
||||
super(name);
|
||||
|
||||
update = true;
|
||||
}
|
||||
|
||||
public class PayloadAcceptorEntity extends TileEntity{
|
||||
public @Nullable Payload payload;
|
||||
public Vec2 inputVector = new Vec2();
|
||||
public float inputRotation;
|
||||
|
||||
@Override
|
||||
public boolean acceptPayload(Tilec source, Payload payload){
|
||||
return this.payload == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePayload(Tilec source, Payload payload){
|
||||
this.payload = payload;
|
||||
this.inputVector.set(source).sub(this).clamp(-size * tilesize / 2f, size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f);
|
||||
this.inputRotation = source.angleTo(this);
|
||||
}
|
||||
|
||||
/** @return true if the payload is in position. */
|
||||
public boolean updatePayload(){
|
||||
if(payload == null) return false;
|
||||
|
||||
inputRotation = Mathf.slerpDelta(inputRotation, 90f, 0.3f);
|
||||
inputVector.lerpDelta(Vec2.ZERO, 0.2f);
|
||||
|
||||
return inputVector.isZero(0.5f);
|
||||
}
|
||||
|
||||
public void drawPayload(){
|
||||
if(payload != null){
|
||||
payload.draw(x + inputVector.x, y + inputVector.y, inputRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -161,6 +161,10 @@ public class ItemModule extends BlockModule{
|
||||
total -= amount;
|
||||
}
|
||||
|
||||
public void remove(ItemStack[] stacks){
|
||||
for(ItemStack stack : stacks) remove(stack.item, stack.amount);
|
||||
}
|
||||
|
||||
public void remove(ItemStack stack){
|
||||
remove(stack.item, stack.amount);
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ def tileImage = { File file ->
|
||||
|
||||
if(index != -1){
|
||||
int resultIndex = (x == y ? 1 : index == 2 ? 0 : index == 0 ? 2 : 1);
|
||||
result.setRGB(x, y, Color.argb8888(list[resultIndex]))
|
||||
result.setRGB(x, y, list[resultIndex].argb8888())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user