mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-15 02:07:53 +07:00
Payload support
This commit is contained in:
@ -1,20 +0,0 @@
|
|||||||
#Maps entity names to IDs. Autogenerated.
|
|
||||||
|
|
||||||
alpha=0
|
|
||||||
block=1
|
|
||||||
cix=17
|
|
||||||
draug=2
|
|
||||||
mindustry.entities.comp.BulletComp=3
|
|
||||||
mindustry.entities.comp.DecalComp=4
|
|
||||||
mindustry.entities.comp.EffectComp=5
|
|
||||||
mindustry.entities.comp.FireComp=6
|
|
||||||
mindustry.entities.comp.PlayerComp=7
|
|
||||||
mindustry.entities.comp.PuddleComp=8
|
|
||||||
mindustry.entities.comp.TileComp=9
|
|
||||||
mindustry.type.Weather.WeatherComp=10
|
|
||||||
mindustry.world.blocks.storage.LaunchPad.LaunchPayloadComp=11
|
|
||||||
oculon=12
|
|
||||||
phantom=13
|
|
||||||
titan=14
|
|
||||||
vanguard=15
|
|
||||||
wraith=16
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:tile,type:Tilec,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:armor,type:float,size:4},{name:baseRotation,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:requests,type:arc.struct.Queue<mindustry.entities.units.BuildRequest>,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:armor,type:float,size:4},{name:baseRotation,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:requests,type:arc.struct.Queue<mindustry.entities.units.BuildRequest>,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:requests,type:arc.struct.Queue<mindustry.entities.units.BuildRequest>,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:requests,type:arc.struct.Queue<mindustry.entities.units.BuildRequest>,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:collided,type:arc.struct.IntArray,size:-1},{name:damage,type:float,size:4},{name:data,type:java.lang.Object,size:-1},{name:lifetime,type:float,size:4},{name:owner,type:Entityc,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:time,type:float,size:4},{name:type,type:mindustry.entities.bullet.BulletType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:color,type:arc.graphics.Color,size:-1},{name:lifetime,type:float,size:4},{name:region,type:arc.graphics.g2d.TextureRegion,size:-1},{name:rotation,type:float,size:4},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:color,type:arc.graphics.Color,size:-1},{name:data,type:java.lang.Object,size:-1},{name:effect,type:mindustry.entities.Effect,size:-1},{name:lifetime,type:float,size:4},{name:offsetX,type:float,size:4},{name:offsetY,type:float,size:4},{name:parent,type:Posc,size:-1},{name:rotation,type:float,size:4},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:baseFlammability,type:float,size:4},{name:block,type:mindustry.world.Block,size:-1},{name:lifetime,type:float,size:4},{name:puddleFlammability,type:float,size:4},{name:tile,type:mindustry.world.Tile,size:-1},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:lifetime,type:float,size:4},{name:stacks,type:arc.struct.Array<mindustry.type.ItemStack>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:time,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:armor,type:float,size:4},{name:baseRotation,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{version:1,fields:[{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:armor,type:float,size:4},{name:baseRotation,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:mineTile,type:mindustry.world.Tile,size:-1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:admin,type:boolean,size:1},{name:boosting,type:boolean,size:1},{name:color,type:arc.graphics.Color,size:-1},{name:mouseX,type:float,size:4},{name:mouseY,type:float,size:4},{name:name,type:java.lang.String,size:-1},{name:shooting,type:boolean,size:1},{name:team,type:mindustry.game.Team,size:-1},{name:typing,type:boolean,size:1},{name:unit,type:Unitc,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:accepting,type:float,size:4},{name:amount,type:float,size:4},{name:generation,type:int,size:4},{name:lastRipple,type:float,size:4},{name:liquid,type:mindustry.type.Liquid,size:-1},{name:tile,type:mindustry.world.Tile,size:-1},{name:updateTime,type:float,size:4},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:cons,type:mindustry.world.modules.ConsumeModule,size:-1},{name:health,type:float,size:4},{name:items,type:mindustry.world.modules.ItemModule,size:-1},{name:liquids,type:mindustry.world.modules.LiquidModule,size:-1},{name:power,type:mindustry.world.modules.PowerModule,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:armor,type:float,size:4},{name:controller,type:mindustry.entities.units.UnitController,size:-1},{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:isShooting,type:boolean,size:1},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:spawnedByCore,type:boolean,size:1},{name:stack,type:mindustry.type.ItemStack,size:-1},{name:statuses,type:arc.struct.Array<mindustry.entities.units.StatusEntry>,size:-1},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
@ -1 +0,0 @@
|
|||||||
{fields:[{name:intensity,type:float,size:4},{name:life,type:float,size:4},{name:opacity,type:float,size:4},{name:weather,type:mindustry.type.Weather,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
|
15
build.gradle
15
build.gradle
@ -145,6 +145,20 @@ allprojects{
|
|||||||
|
|
||||||
processorFile.text = text.toString().replace(".java", "").replace("/", ".").replace("\\", ".")
|
processorFile.text = text.toString().replace(".java", "").replace("/", ".").replace("\\", ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writePlugins = {
|
||||||
|
new File(rootDir, "annotations/src/main/resources/META-INF/services/").mkdirs()
|
||||||
|
def processorFile = new File(rootDir, "annotations/src/main/resources/META-INF/services/com.sun.source.util.Plugin")
|
||||||
|
def text = new StringBuilder()
|
||||||
|
def files = new File(rootDir, "annotations/src/main/java")
|
||||||
|
files.eachFileRecurse(groovy.io.FileType.FILES){ file ->
|
||||||
|
if(file.name.endsWith(".java") && (file.text.contains(" implements Plugin"))){
|
||||||
|
text.append(file.path.substring(files.path.length() + 1)).append("\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processorFile.text = text.toString().replace(".java", "").replace("/", ".").replace("\\", ".")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories{
|
repositories{
|
||||||
@ -221,6 +235,7 @@ project(":core"){
|
|||||||
generateLocales()
|
generateLocales()
|
||||||
writeVersion()
|
writeVersion()
|
||||||
writeProcessors()
|
writeProcessors()
|
||||||
|
writePlugins()
|
||||||
}
|
}
|
||||||
|
|
||||||
task copyChangelog{
|
task copyChangelog{
|
||||||
|
BIN
core/assets-raw/sprites/weapons/heal-weapon-mount.png
Normal file
BIN
core/assets-raw/sprites/weapons/heal-weapon-mount.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 296 B |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 826 KiB After Width: | Height: | Size: 822 KiB |
Binary file not shown.
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 128 KiB |
@ -34,6 +34,9 @@ public class UnitTypes implements ContentList{
|
|||||||
//TODO implement other starter drones
|
//TODO implement other starter drones
|
||||||
public static @EntityDef({Unitc.class, Builderc.class, Minerc.class}) UnitType alpha, beta, gamma;
|
public static @EntityDef({Unitc.class, Builderc.class, Minerc.class}) UnitType alpha, beta, gamma;
|
||||||
|
|
||||||
|
//air + building + mining + payload
|
||||||
|
public static @EntityDef({Unitc.class, Builderc.class, Minerc.class, Payloadc.class}) UnitType trident;
|
||||||
|
|
||||||
//water
|
//water
|
||||||
public static @EntityDef({Unitc.class, WaterMovec.class, Commanderc.class}) UnitType vanguard;
|
public static @EntityDef({Unitc.class, WaterMovec.class, Commanderc.class}) UnitType vanguard;
|
||||||
|
|
||||||
@ -264,6 +267,7 @@ public class UnitTypes implements ContentList{
|
|||||||
engineOffset = 7.8f;
|
engineOffset = 7.8f;
|
||||||
range = 140f;
|
range = 140f;
|
||||||
faceTarget = false;
|
faceTarget = false;
|
||||||
|
|
||||||
weapons.add(new Weapon(){{
|
weapons.add(new Weapon(){{
|
||||||
x = 3f;
|
x = 3f;
|
||||||
shootY = 0f;
|
shootY = 0f;
|
||||||
@ -423,6 +427,45 @@ public class UnitTypes implements ContentList{
|
|||||||
}};
|
}};
|
||||||
}});
|
}});
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
trident = new UnitType("trident"){{
|
||||||
|
//wraith.upgrade = this;
|
||||||
|
tier = 3;
|
||||||
|
|
||||||
|
health = 500;
|
||||||
|
speed = 2f;
|
||||||
|
accel = 0.05f;
|
||||||
|
drag = 0.016f;
|
||||||
|
lowAltitude = true;
|
||||||
|
flying = true;
|
||||||
|
engineOffset = 10.5f;
|
||||||
|
rotateShooting = false;
|
||||||
|
hitsize = 14f;
|
||||||
|
engineSize = 3f;
|
||||||
|
|
||||||
|
for(boolean b : Mathf.booleans){
|
||||||
|
weapons.add(
|
||||||
|
new Weapon("heal-weapon-mount"){{
|
||||||
|
reload = 25f;
|
||||||
|
x = 8f * Mathf.sign(b);
|
||||||
|
y = -6f;
|
||||||
|
rotate = true;
|
||||||
|
mirror = false;
|
||||||
|
flipSprite = !b;
|
||||||
|
bullet = Bullets.healBulletBig;
|
||||||
|
}},
|
||||||
|
new Weapon("heal-weapon-mount"){{
|
||||||
|
reload = 15f;
|
||||||
|
x = 4f * Mathf.sign(b);
|
||||||
|
y = 5f;
|
||||||
|
rotate = true;
|
||||||
|
mirror = false;
|
||||||
|
flipSprite = !b;
|
||||||
|
bullet = Bullets.healBullet;
|
||||||
|
}}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
chaosArray = new UnitType("chaos-array", GroundUnit::new){{
|
chaosArray = new UnitType("chaos-array", GroundUnit::new){{
|
||||||
|
@ -10,7 +10,7 @@ import static mindustry.Vars.tilesize;
|
|||||||
abstract class BlockUnitComp implements Unitc{
|
abstract class BlockUnitComp implements Unitc{
|
||||||
@Import Team team;
|
@Import Team team;
|
||||||
|
|
||||||
@ReadOnly Tilec tile;
|
@ReadOnly transient Tilec tile;
|
||||||
|
|
||||||
public void tile(Tilec tile){
|
public void tile(Tilec tile){
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
package mindustry.entities.comp;
|
package mindustry.entities.comp;
|
||||||
|
|
||||||
|
import arc.math.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
|
import arc.util.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.content.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.payloads.*;
|
import mindustry.world.blocks.payloads.*;
|
||||||
|
|
||||||
/** An entity that holds a payload. */
|
/** An entity that holds a payload. */
|
||||||
@Component
|
@Component
|
||||||
abstract class PayloadComp{
|
abstract class PayloadComp implements Posc, Rotc{
|
||||||
Array<Payload> payloads = new Array<>();
|
Array<Payload> payloads = new Array<>();
|
||||||
|
|
||||||
boolean hasPayload(){
|
boolean hasPayload(){
|
||||||
@ -16,4 +21,72 @@ abstract class PayloadComp{
|
|||||||
void addPayload(Payload load){
|
void addPayload(Payload load){
|
||||||
payloads.add(load);
|
payloads.add(load);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pickup(Unitc unit){
|
||||||
|
unit.remove();
|
||||||
|
payloads.add(new UnitPayload(unit));
|
||||||
|
Fx.unitPickup.at(unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pickup(Tilec tile){
|
||||||
|
tile.tile().remove();
|
||||||
|
payloads.add(new BlockPayload(tile));
|
||||||
|
Fx.unitPickup.at(tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean dropLastPayload(){
|
||||||
|
if(payloads.isEmpty()) return false;
|
||||||
|
|
||||||
|
Payload load = payloads.peek();
|
||||||
|
|
||||||
|
if(tryDropPayload(load)){
|
||||||
|
payloads.pop();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean tryDropPayload(Payload payload){
|
||||||
|
if(payload instanceof BlockPayload){
|
||||||
|
return dropBlock((BlockPayload)payload);
|
||||||
|
}else if(payload instanceof UnitPayload){
|
||||||
|
return dropUnit((UnitPayload)payload);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean dropUnit(UnitPayload payload){
|
||||||
|
//TODO create an effect here and/or make them be at a lower elevation
|
||||||
|
Unitc u = payload.unit;
|
||||||
|
|
||||||
|
//can't drop ground units
|
||||||
|
if((tileOn() == null || tileOn().solid()) && u.elevation() < 0.1f){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
u.set(this);
|
||||||
|
u.trns(Tmp.v1.rnd(Mathf.random(2f)));
|
||||||
|
u.add();
|
||||||
|
Fx.unitDrop.at(u);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return whether the tile has been successfully placed. */
|
||||||
|
boolean dropBlock(BlockPayload payload){
|
||||||
|
Tilec tile = payload.entity;
|
||||||
|
int tx = tileX(), ty = tileY();
|
||||||
|
Tile on = tileOn();
|
||||||
|
if(Build.validPlace(tile.team(), tx, ty, tile.block(), tile.rotation())){
|
||||||
|
int rot = (int)((rotation() + 45f) / 90f) % 4;
|
||||||
|
payload.place(tileOn(), rot);
|
||||||
|
|
||||||
|
Fx.unitDrop.at(tile);
|
||||||
|
Fx.placeBlock.at(on.drawx(), on.drawy(), on.block().size);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,13 +40,17 @@ abstract class PosComp implements Position{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns air if this unit is on a non-air top block. */
|
/** Returns air if this unit is on a non-air top block. */
|
||||||
public Floor floorOn(){
|
Floor floorOn(){
|
||||||
Tile tile = tileOn();
|
Tile tile = tileOn();
|
||||||
return tile == null || tile.block() != Blocks.air ? (Floor)Blocks.air : tile.floor();
|
return tile == null || tile.block() != Blocks.air ? (Floor)Blocks.air : tile.floor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable
|
Block blockOn(){
|
||||||
Tile tileOn(){
|
Tile tile = tileOn();
|
||||||
|
return tile == null ? Blocks.air : tile.block();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable Tile tileOn(){
|
||||||
return world.tileWorld(x, y);
|
return world.tileWorld(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{
|
|||||||
|
|
||||||
@Import float x, y;
|
@Import float x, y;
|
||||||
|
|
||||||
float amount, lastRipple, accepting, updateTime;
|
transient float accepting, updateTime, lastRipple;
|
||||||
|
float amount;
|
||||||
int generation;
|
int generation;
|
||||||
Tile tile;
|
Tile tile;
|
||||||
Liquid liquid;
|
Liquid liquid;
|
||||||
|
@ -10,24 +10,32 @@ public enum Binding implements KeyBind{
|
|||||||
move_x(new Axis(KeyCode.a, KeyCode.d), "general"),
|
move_x(new Axis(KeyCode.a, KeyCode.d), "general"),
|
||||||
move_y(new Axis(KeyCode.s, KeyCode.w)),
|
move_y(new Axis(KeyCode.s, KeyCode.w)),
|
||||||
mouse_move(KeyCode.mouseBack),
|
mouse_move(KeyCode.mouseBack),
|
||||||
|
|
||||||
boost(KeyCode.shiftLeft),
|
boost(KeyCode.shiftLeft),
|
||||||
control(KeyCode.controlLeft),
|
control(KeyCode.controlLeft),
|
||||||
respawn(KeyCode.v),
|
respawn(KeyCode.v),
|
||||||
select(KeyCode.mouseLeft),
|
select(KeyCode.mouseLeft),
|
||||||
deselect(KeyCode.mouseRight),
|
deselect(KeyCode.mouseRight),
|
||||||
break_block(KeyCode.mouseRight),
|
break_block(KeyCode.mouseRight),
|
||||||
|
|
||||||
|
pickupCargo(KeyCode.leftBracket),
|
||||||
|
dropCargo(KeyCode.rightBracket),
|
||||||
|
|
||||||
clear_building(KeyCode.q),
|
clear_building(KeyCode.q),
|
||||||
pause_building(KeyCode.e),
|
pause_building(KeyCode.e),
|
||||||
rotate(new Axis(KeyCode.scroll)),
|
rotate(new Axis(KeyCode.scroll)),
|
||||||
rotateplaced(KeyCode.r),
|
rotateplaced(KeyCode.r),
|
||||||
diagonal_placement(KeyCode.controlLeft),
|
diagonal_placement(KeyCode.controlLeft),
|
||||||
pick(KeyCode.mouseMiddle),
|
pick(KeyCode.mouseMiddle),
|
||||||
|
|
||||||
schematic_select(KeyCode.f),
|
schematic_select(KeyCode.f),
|
||||||
schematic_flip_x(KeyCode.z),
|
schematic_flip_x(KeyCode.z),
|
||||||
schematic_flip_y(KeyCode.x),
|
schematic_flip_y(KeyCode.x),
|
||||||
schematic_menu(KeyCode.t),
|
schematic_menu(KeyCode.t),
|
||||||
|
|
||||||
category_prev(KeyCode.comma),
|
category_prev(KeyCode.comma),
|
||||||
category_next(KeyCode.period),
|
category_next(KeyCode.period),
|
||||||
|
|
||||||
block_select_left(KeyCode.left),
|
block_select_left(KeyCode.left),
|
||||||
block_select_right(KeyCode.right),
|
block_select_right(KeyCode.right),
|
||||||
block_select_up(KeyCode.up),
|
block_select_up(KeyCode.up),
|
||||||
@ -42,6 +50,7 @@ public enum Binding implements KeyBind{
|
|||||||
block_select_08(KeyCode.num8),
|
block_select_08(KeyCode.num8),
|
||||||
block_select_09(KeyCode.num9),
|
block_select_09(KeyCode.num9),
|
||||||
block_select_10(KeyCode.num0),
|
block_select_10(KeyCode.num0),
|
||||||
|
|
||||||
zoom(new Axis(KeyCode.scroll), "view"),
|
zoom(new Axis(KeyCode.scroll), "view"),
|
||||||
menu(Core.app.getType() == ApplicationType.Android ? KeyCode.back : KeyCode.escape),
|
menu(Core.app.getType() == ApplicationType.Android ? KeyCode.back : KeyCode.escape),
|
||||||
fullscreen(KeyCode.f11),
|
fullscreen(KeyCode.f11),
|
||||||
|
@ -607,5 +607,25 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
isBoosting = Core.input.keyDown(Binding.boost) && !movement.isZero();
|
isBoosting = Core.input.keyDown(Binding.boost) && !movement.isZero();
|
||||||
player.boosting(isBoosting);
|
player.boosting(isBoosting);
|
||||||
|
|
||||||
|
if(unit instanceof Payloadc){
|
||||||
|
Payloadc pay = (Payloadc)unit;
|
||||||
|
|
||||||
|
if(Core.input.keyTap(Binding.pickupCargo) && pay.payloads().size < unit.type().payloadCapacity){
|
||||||
|
Unitc target = Units.closest(player.team(), pay.x(), pay.y(), 30f, u -> u.isAI() && u.isGrounded());
|
||||||
|
if(target != null){
|
||||||
|
pay.pickup(target);
|
||||||
|
}else if(!pay.hasPayload()){
|
||||||
|
Tilec tile = world.entWorld(pay.x(), pay.y());
|
||||||
|
if(tile != null && tile.team() == unit.team()){
|
||||||
|
pay.pickup(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Core.input.keyTap(Binding.dropCargo)){
|
||||||
|
pay.dropLastPayload();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import mindustry.net.Packets.*;
|
|||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
|
import mindustry.world.blocks.payloads.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.*;
|
import java.nio.*;
|
||||||
@ -87,6 +88,14 @@ public class TypeIO{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void writePayload(Writes writes, Payload payload){
|
||||||
|
Payload.write(payload, writes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Payload readPayload(Reads read){
|
||||||
|
return Payload.read(read);
|
||||||
|
}
|
||||||
|
|
||||||
//only for players!
|
//only for players!
|
||||||
public static void writeUnit(Writes write, Unitc unit){
|
public static void writeUnit(Writes write, Unitc unit){
|
||||||
write.b(unit.isNull() ? 0 : unit instanceof BlockUnitc ? 1 : 2);
|
write.b(unit.isNull() ? 0 : unit instanceof BlockUnitc ? 1 : 2);
|
||||||
|
@ -21,6 +21,7 @@ import mindustry.gen.*;
|
|||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.blocks.environment.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
import mindustry.world.blocks.payloads.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ public class UnitType extends UnlockableContent{
|
|||||||
public boolean faceTarget = true, rotateShooting = true, isCounted = true, lowAltitude = false;
|
public boolean faceTarget = true, rotateShooting = true, isCounted = true, lowAltitude = false;
|
||||||
public boolean canBoost = false;
|
public boolean canBoost = false;
|
||||||
public float sway = 1f;
|
public float sway = 1f;
|
||||||
|
public int payloadCapacity = 1;
|
||||||
|
|
||||||
public int legCount = 4;
|
public int legCount = 4;
|
||||||
public float legLength = 24f, legSpeed = 0.1f, legTrns = 1f;
|
public float legLength = 24f, legSpeed = 0.1f, legTrns = 1f;
|
||||||
@ -159,6 +161,11 @@ public class UnitType extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Draw.z(Math.min(z - 0.01f, Layer.bullet - 1f));
|
Draw.z(Math.min(z - 0.01f, Layer.bullet - 1f));
|
||||||
|
|
||||||
|
if(unit instanceof Payloadc){
|
||||||
|
drawPayload((Payloadc)unit);
|
||||||
|
}
|
||||||
|
|
||||||
drawOcclusion(unit);
|
drawOcclusion(unit);
|
||||||
|
|
||||||
Draw.z(z);
|
Draw.z(z);
|
||||||
@ -178,6 +185,14 @@ public class UnitType extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void drawPayload(Payloadc unit){
|
||||||
|
if(unit.hasPayload()){
|
||||||
|
Payload pay = unit.payloads().first();
|
||||||
|
pay.set(unit.x(), unit.y(), unit.rotation());
|
||||||
|
pay.draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void drawShield(Unitc unit){
|
public void drawShield(Unitc unit){
|
||||||
float alpha = unit.shieldAlpha();
|
float alpha = unit.shieldAlpha();
|
||||||
float radius = unit.hitSize() * 1.3f;
|
float radius = unit.hitSize() * 1.3f;
|
||||||
|
@ -287,19 +287,16 @@ public class MassDriver extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean shooterValid(Tile other){
|
protected boolean shooterValid(Tile other){
|
||||||
|
|
||||||
if(other == null) return true;
|
if(other == null) return true;
|
||||||
if(!(other.block() instanceof MassDriver)) return false;
|
if(!(other.block() instanceof MassDriver)) return false;
|
||||||
MassDriverEntity entity = other.ent();
|
MassDriverEntity entity = other.ent();
|
||||||
return link == tile.pos() && tile.dst(other) <= range;
|
return entity.link == tile.pos() && tile.dst(other) <= range;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean linkValid(){
|
protected boolean linkValid(){
|
||||||
if(tile == null) return false;
|
|
||||||
if(link == -1) return false;
|
if(link == -1) return false;
|
||||||
Tilec link = world.ent(this.link);
|
Tile link = world.tile(this.link);
|
||||||
|
return link != null && link.block() instanceof MassDriver && link.team() == tile.team() && tile.dst(link) <= range;
|
||||||
return link != null && link.block() instanceof MassDriver && link.team() == team && tile.dst(link) <= range;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,6 +17,10 @@ public class BlockPayload implements Payload{
|
|||||||
this.entity = block.newEntity().create(block, team);
|
this.entity = block.newEntity().create(block, team);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockPayload(Tilec entity){
|
||||||
|
this.entity = entity;
|
||||||
|
}
|
||||||
|
|
||||||
public Block block(){
|
public Block block(){
|
||||||
return entity.block();
|
return entity.block();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package mindustry.world.blocks.production;
|
package mindustry.world.blocks.production;
|
||||||
|
|
||||||
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
@ -16,6 +17,7 @@ public class ResearchBlock extends Block{
|
|||||||
solid = true;
|
solid = true;
|
||||||
hasPower = true;
|
hasPower = true;
|
||||||
hasItems = true;
|
hasItems = true;
|
||||||
|
configurable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ResearchBlockEntity extends TileEntity{
|
public class ResearchBlockEntity extends TileEntity{
|
||||||
@ -26,6 +28,11 @@ public class ResearchBlock extends Block{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildConfiguration(Table table){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(Writes write){
|
public void write(Writes write){
|
||||||
super.write(write);
|
super.write(write);
|
||||||
|
@ -54,6 +54,8 @@ public class LaunchPad extends Block{
|
|||||||
public void draw(){
|
public void draw(){
|
||||||
super.draw();
|
super.draw();
|
||||||
|
|
||||||
|
if(!Vars.state.isCampaign()) return;
|
||||||
|
|
||||||
if(lightRegion.found()){
|
if(lightRegion.found()){
|
||||||
Draw.color(lightColor);
|
Draw.color(lightColor);
|
||||||
float progress = Math.min((float)items.total() / itemCapacity, timer.getTime(timerLaunch) / (launchTime / timeScale));
|
float progress = Math.min((float)items.total() / itemCapacity, timer.getTime(timerLaunch) / (launchTime / timeScale));
|
||||||
@ -89,6 +91,7 @@ public class LaunchPad extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTile(){
|
public void updateTile(){
|
||||||
|
if(!Vars.state.isCampaign()) return;
|
||||||
|
|
||||||
//launch when full and base conditions are met
|
//launch when full and base conditions are met
|
||||||
if(items.total() >= itemCapacity && efficiency() >= 1f && timer(timerLaunch, launchTime / timeScale)){
|
if(items.total() >= itemCapacity && efficiency() >= 1f && timer(timerLaunch, launchTime / timeScale)){
|
||||||
|
Reference in New Issue
Block a user