Read-only component fields / Removed get/set prefix
This commit is contained in:
@@ -5,6 +5,12 @@ import java.lang.annotation.*;
|
|||||||
public class Annotations{
|
public class Annotations{
|
||||||
//region entity interfaces
|
//region entity interfaces
|
||||||
|
|
||||||
|
/** Indicates that a component field is read-only. */
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
public @interface ReadOnly{
|
||||||
|
}
|
||||||
|
|
||||||
/** Indicates multiple inheritance on a component type. */
|
/** Indicates multiple inheritance on a component type. */
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
|||||||
@@ -76,11 +76,14 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(Svar field : component.fields().select(e -> !e.is(Modifier.STATIC) && !e.is(Modifier.PRIVATE) && !e.is(Modifier.TRANSIENT))){
|
for(Svar field : component.fields().select(e -> !e.is(Modifier.STATIC) && !e.is(Modifier.PRIVATE) && !e.is(Modifier.TRANSIENT))){
|
||||||
String cname = Strings.capitalize(field.name());
|
String cname = field.name();
|
||||||
//getter
|
//getter
|
||||||
inter.addMethod(MethodSpec.methodBuilder((field.mirror().toString().equals("boolean") ? "is" : "get") + cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC).returns(field.tname()).build());
|
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC).returns(field.tname()).build());
|
||||||
|
|
||||||
//setter
|
//setter
|
||||||
if(!field.is(Modifier.FINAL)) inter.addMethod(MethodSpec.methodBuilder("set" + cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC).addParameter(field.tname(), field.name()).build());
|
if(!field.is(Modifier.FINAL) && !field.annotations().contains(f -> f.toString().equals("@mindustry.annotations.Annotations.ReadOnly"))){
|
||||||
|
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC).addParameter(field.tname(), field.name()).build());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//add utility methods to interface
|
//add utility methods to interface
|
||||||
@@ -128,6 +131,8 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
if(tree.getInitializer() != null){
|
if(tree.getInitializer() != null){
|
||||||
fbuilder.initializer(tree.getInitializer().toString());
|
fbuilder.initializer(tree.getInitializer().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
builder.addAnnotations(f.annotations().map(AnnotationSpec::get));
|
||||||
builder.addField(fbuilder.build());
|
builder.addField(fbuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,15 +250,18 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
|
|
||||||
//generate getter/setter for each method
|
//generate getter/setter for each method
|
||||||
for(Smethod method : inter.methods()){
|
for(Smethod method : inter.methods()){
|
||||||
if(method.name().length() <= 3) continue;
|
String var = method.name();
|
||||||
|
FieldSpec field = Array.with(def.builder.fieldSpecs).find(f -> f.name.equals(var));
|
||||||
String var = Strings.camelize(method.name().substring(method.name().startsWith("is") ? 2 : 3));
|
|
||||||
//make sure it's a real variable AND that the component doesn't already implement it with custom logic
|
//make sure it's a real variable AND that the component doesn't already implement it with custom logic
|
||||||
if(!Array.with(def.builder.fieldSpecs).contains(f -> f.name.equals(var)) || comp.methods().contains(m -> m.name().equals(method.name()))) continue;
|
if(field == null || comp.methods().contains(m -> m.name().equals(method.name()))) continue;
|
||||||
|
|
||||||
if(method.name().startsWith("get") || method.name().startsWith("is")){
|
//getter
|
||||||
|
if(!method.isVoid()){
|
||||||
def.builder.addMethod(MethodSpec.overriding(method.e).addStatement("return " + var).build());
|
def.builder.addMethod(MethodSpec.overriding(method.e).addStatement("return " + var).build());
|
||||||
}else if(method.name().startsWith("set")){
|
}
|
||||||
|
|
||||||
|
//setter
|
||||||
|
if(method.isVoid() && !Array.with(field.annotations).contains(f -> f.type.toString().equals("@mindustry.annotations.Annotations.ReadOnly"))){
|
||||||
def.builder.addMethod(MethodSpec.overriding(method.e).addStatement("this." + var + " = " + var).build());
|
def.builder.addMethod(MethodSpec.overriding(method.e).addStatement("this." + var + " = " + var).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package mindustry.annotations.util;
|
package mindustry.annotations.util;
|
||||||
|
|
||||||
|
import arc.struct.*;
|
||||||
import com.squareup.javapoet.*;
|
import com.squareup.javapoet.*;
|
||||||
import mindustry.annotations.*;
|
import mindustry.annotations.*;
|
||||||
|
|
||||||
@@ -14,6 +15,10 @@ public class Selement<T extends Element>{
|
|||||||
this.e = e;
|
this.e = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Array<? extends AnnotationMirror> annotations(){
|
||||||
|
return Array.with(e.getAnnotationMirrors());
|
||||||
|
}
|
||||||
|
|
||||||
public <A extends Annotation> A annotation(Class<A> annotation){
|
public <A extends Annotation> A annotation(Class<A> annotation){
|
||||||
return e.getAnnotation(annotation);
|
return e.getAnnotation(annotation);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ public class Smethod extends Selement<ExecutableElement>{
|
|||||||
return Array.with(e.getParameters()).map(Svar::new);
|
return Array.with(e.getParameters()).map(Svar::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isVoid(){
|
||||||
|
return ret().toString().equals("void");
|
||||||
|
}
|
||||||
|
|
||||||
public TypeMirror ret(){
|
public TypeMirror ret(){
|
||||||
return e.getReturnType();
|
return e.getReturnType();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class BlockIndexer{
|
|||||||
|
|
||||||
ObjectSet<Tile> set = damagedTiles[team.id];
|
ObjectSet<Tile> set = damagedTiles[team.id];
|
||||||
for(Tile tile : set){
|
for(Tile tile : set){
|
||||||
if((tile.entity == null || tile.entity.getTeam() != team || !tile.entity.damaged()) || tile.block() instanceof BuildBlock){
|
if((tile.entity == null || tile.entity.team() != team || !tile.entity.damaged()) || tile.block() instanceof BuildBlock){
|
||||||
returnArray.add(tile);
|
returnArray.add(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ public class BlockIndexer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean eachBlock(Teamc team, float range, Boolf<Tile> pred, Cons<Tile> cons){
|
public boolean eachBlock(Teamc team, float range, Boolf<Tile> pred, Cons<Tile> cons){
|
||||||
return eachBlock(team.getTeam(), team.getX(), team.getY(), range, pred, cons);
|
return eachBlock(team.team(), team.getX(), team.getY(), range, pred, cons);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean eachBlock(Team team, float wx, float wy, float range, Boolf<Tile> pred, Cons<Tile> cons){
|
public boolean eachBlock(Team team, float wx, float wy, float range, Boolf<Tile> pred, Cons<Tile> cons){
|
||||||
@@ -213,12 +213,12 @@ public class BlockIndexer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void notifyTileDamaged(Tilec entity){
|
public void notifyTileDamaged(Tilec entity){
|
||||||
if(damagedTiles[(int)entity.getTeam().id] == null){
|
if(damagedTiles[(int)entity.team().id] == null){
|
||||||
damagedTiles[(int)entity.getTeam().id] = new ObjectSet<>();
|
damagedTiles[(int)entity.team().id] = new ObjectSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectSet<Tile> set = damagedTiles[(int)entity.getTeam().id];
|
ObjectSet<Tile> set = damagedTiles[(int)entity.team().id];
|
||||||
set.add(entity.getTile());
|
set.add(entity.tile());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tilec findEnemyTile(Team team, float x, float y, float range, Boolf<Tile> pred){
|
public Tilec findEnemyTile(Team team, float x, float y, float range, Boolf<Tile> pred){
|
||||||
@@ -262,9 +262,9 @@ public class BlockIndexer{
|
|||||||
float ndst = e.dst2(x, y);
|
float ndst = e.dst2(x, y);
|
||||||
if(ndst < range2 && (closest == null ||
|
if(ndst < range2 && (closest == null ||
|
||||||
//this one is closer, and it is at least of equal priority
|
//this one is closer, and it is at least of equal priority
|
||||||
(ndst < dst && (!usePriority || closest.getBlock().priority.ordinal() <= e.getBlock().priority.ordinal())) ||
|
(ndst < dst && (!usePriority || closest.block().priority.ordinal() <= e.block().priority.ordinal())) ||
|
||||||
//priority is used, and new block has higher priority regardless of range
|
//priority is used, and new block has higher priority regardless of range
|
||||||
(usePriority && closest.getBlock().priority.ordinal() < e.getBlock().priority.ordinal()))){
|
(usePriority && closest.block().priority.ordinal() < e.block().priority.ordinal()))){
|
||||||
dst = ndst;
|
dst = ndst;
|
||||||
closest = e;
|
closest = e;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import arc.struct.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -35,7 +34,7 @@ public class WaveSpawner{
|
|||||||
|
|
||||||
/** @return true if the player is near a ground spawn point. */
|
/** @return true if the player is near a ground spawn point. */
|
||||||
public boolean playerNear(){
|
public boolean playerNear(){
|
||||||
return groundSpawns.contains(g -> Mathf.dst(g.x * tilesize, g.y * tilesize, player.x, player.y) < state.rules.dropZoneRadius && player.getTeam() != state.rules.waveTeam);
|
return groundSpawns.contains(g -> Mathf.dst(g.x * tilesize, g.y * tilesize, player.x, player.y) < state.rules.dropZoneRadius && player.team() != state.rules.waveTeam);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnEnemies(){
|
public void spawnEnemies(){
|
||||||
|
|||||||
@@ -584,7 +584,7 @@ public class Blocks implements ContentList{
|
|||||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name + "-top")};
|
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name + "-top")};
|
||||||
|
|
||||||
drawer = tile -> {
|
drawer = tile -> {
|
||||||
LiquidModule mod = tile.entity.getLiquids();
|
LiquidModule mod = tile.entity.liquids();
|
||||||
|
|
||||||
int rotation = rotate ? tile.rotation() * 90 : 0;
|
int rotation = rotate ? tile.rotation() * 90 : 0;
|
||||||
|
|
||||||
@@ -680,7 +680,7 @@ public class Blocks implements ContentList{
|
|||||||
|
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||||
Draw.rect(reg(frameRegions[(int)Mathf.absin(entity.totalProgress, 5f, 2.999f)]), tile.drawx(), tile.drawy());
|
Draw.rect(reg(frameRegions[(int)Mathf.absin(entity.totalProgress, 5f, 2.999f)]), tile.drawx(), tile.drawy());
|
||||||
Draw.color(Color.clear, tile.entity.getLiquids().current().color, tile.entity.getLiquids().total() / liquidCapacity);
|
Draw.color(Color.clear, tile.entity.liquids().current().color, tile.entity.liquids().total() / liquidCapacity);
|
||||||
Draw.rect(reg(liquidRegion), tile.drawx(), tile.drawy());
|
Draw.rect(reg(liquidRegion), tile.drawx(), tile.drawy());
|
||||||
Draw.color();
|
Draw.color();
|
||||||
Draw.rect(reg(topRegion), tile.drawx(), tile.drawy());
|
Draw.rect(reg(topRegion), tile.drawx(), tile.drawy());
|
||||||
@@ -1537,7 +1537,7 @@ public class Blocks implements ContentList{
|
|||||||
@Override
|
@Override
|
||||||
public void init(Bulletc b){
|
public void init(Bulletc b){
|
||||||
for(int i = 0; i < rays; i++){
|
for(int i = 0; i < rays; i++){
|
||||||
Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), rayLength - Math.abs(i - (rays / 2)) * 20f);
|
Damage.collideLine(b, b.team(), hitEffect, b.x, b.y, b.rot(), rayLength - Math.abs(i - (rays / 2)) * 20f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ public class Bullets implements ContentList{
|
|||||||
@Override
|
@Override
|
||||||
public void update(Bulletc b){
|
public void update(Bulletc b){
|
||||||
if(b.timer.get(1, 5f)){
|
if(b.timer.get(1, 5f)){
|
||||||
Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), length, true);
|
Damage.collideLine(b, b.team(), hitEffect, b.x, b.y, b.rot(), length, true);
|
||||||
}
|
}
|
||||||
Effects.shake(1f, 1f, b.x, b.y);
|
Effects.shake(1f, 1f, b.x, b.y);
|
||||||
}
|
}
|
||||||
@@ -587,7 +587,7 @@ public class Bullets implements ContentList{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bulletc b){
|
public void init(Bulletc b){
|
||||||
Lightning.create(b.getTeam(), Pal.lancerLaser, damage * (b.getOwner() instanceof Player ? state.rules.playerDamageMultiplier : 1f), b.x, b.y, b.rot(), 30);
|
Lightning.create(b.team(), Pal.lancerLaser, damage * (b.getOwner() instanceof Player ? state.rules.playerDamageMultiplier : 1f), b.x, b.y, b.rot(), 30);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ public class Mechs implements ContentList{
|
|||||||
if(player.timer.get(Player.timerAbility, healReload)){
|
if(player.timer.get(Player.timerAbility, healReload)){
|
||||||
wasHealed = false;
|
wasHealed = false;
|
||||||
|
|
||||||
Units.nearby(player.getTeam(), player.x, player.y, healRange, unit -> {
|
Units.nearby(player.team(), player.x, player.y, healRange, unit -> {
|
||||||
if(unit.health < unit.maxHealth()){
|
if(unit.health < unit.maxHealth()){
|
||||||
Fx.heal.at(unit);
|
Fx.heal.at(unit);
|
||||||
wasHealed = true;
|
wasHealed = true;
|
||||||
@@ -310,7 +310,7 @@ public class Mechs implements ContentList{
|
|||||||
|
|
||||||
if(player.timer.get(Player.timerAbility, effectReload)){
|
if(player.timer.get(Player.timerAbility, effectReload)){
|
||||||
|
|
||||||
Units.nearby(player.getTeam(), player.x, player.y, effectRange, unit -> {
|
Units.nearby(player.team(), player.x, player.y, effectRange, unit -> {
|
||||||
//unit.applyEffect(StatusEffects.overdrive, effectDuration);
|
//unit.applyEffect(StatusEffects.overdrive, effectDuration);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -368,7 +368,7 @@ public class Mechs implements ContentList{
|
|||||||
float scl = scld(player);
|
float scl = scld(player);
|
||||||
if(Mathf.chance(Time.delta() * (0.15 * scl))){
|
if(Mathf.chance(Time.delta() * (0.15 * scl))){
|
||||||
Fx.hitLancer.at(Pal.lancerLaser, player.x, player.y);
|
Fx.hitLancer.at(Pal.lancerLaser, player.x, player.y);
|
||||||
Lightning.create(player.getTeam(), Pal.lancerLaser, 10f * Vars.state.rules.playerDamageMultiplier,
|
Lightning.create(player.team(), Pal.lancerLaser, 10f * Vars.state.rules.playerDamageMultiplier,
|
||||||
player.x + player.velocity().x, player.y + player.velocity().y, player.rotation, 14);
|
player.x + player.velocity().x, player.y + player.velocity().y, player.rotation, 14);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package mindustry.content;
|
|||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.math.Mathf;
|
import arc.math.Mathf;
|
||||||
import mindustry.entities.Effects;
|
|
||||||
import mindustry.ctype.ContentList;
|
import mindustry.ctype.ContentList;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.type.StatusEffect;
|
import mindustry.type.StatusEffect;
|
||||||
@@ -47,7 +46,7 @@ public class StatusEffects implements ContentList{
|
|||||||
init(() -> {
|
init(() -> {
|
||||||
trans(shocked, ((unit, time, newTime, result) -> {
|
trans(shocked, ((unit, time, newTime, result) -> {
|
||||||
unit.damage(20f);
|
unit.damage(20f);
|
||||||
if(unit.getTeam() == state.rules.waveTeam){
|
if(unit.team() == state.rules.waveTeam){
|
||||||
Events.fire(Trigger.shock);
|
Events.fire(Trigger.shock);
|
||||||
}
|
}
|
||||||
result.set(this, time);
|
result.set(this, time);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import mindustry.entities.type.*;
|
|||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.input.*;
|
import mindustry.input.*;
|
||||||
import mindustry.maps.Map;
|
import mindustry.maps.Map;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
@@ -64,8 +63,8 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(PlayEvent.class, event -> {
|
Events.on(PlayEvent.class, event -> {
|
||||||
player.setTeam(netServer.assignTeam(player, playerGroup.all()));
|
player.team(netServer.assignTeam(player, playerGroup.all()));
|
||||||
player.setDead(true);
|
player.dead(true);
|
||||||
player.add();
|
player.add();
|
||||||
|
|
||||||
state.set(State.playing);
|
state.set(State.playing);
|
||||||
@@ -73,9 +72,9 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
|
|
||||||
Events.on(WorldLoadEvent.class, event -> {
|
Events.on(WorldLoadEvent.class, event -> {
|
||||||
Core.app.post(() -> Core.app.post(() -> {
|
Core.app.post(() -> Core.app.post(() -> {
|
||||||
if(net.active() && player.getClosestCore() != null){
|
if(net.active() && player.closestCore() != null){
|
||||||
//set to closest core since that's where the player will probably respawn; prevents camera jumps
|
//set to closest core since that's where the player will probably respawn; prevents camera jumps
|
||||||
Core.camera.position.set(player.isDead() ? player.getClosestCore() : player);
|
Core.camera.position.set(player.dead() ? player.closestCore() : player);
|
||||||
}else{
|
}else{
|
||||||
//locally, set to player position since respawning occurs immediately
|
//locally, set to player position since respawning occurs immediately
|
||||||
Core.camera.position.set(player);
|
Core.camera.position.set(player);
|
||||||
@@ -130,7 +129,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
Events.on(UnlockEvent.class, e -> ui.hudfrag.showUnlock(e.content));
|
Events.on(UnlockEvent.class, e -> ui.hudfrag.showUnlock(e.content));
|
||||||
|
|
||||||
Events.on(BlockBuildEndEvent.class, e -> {
|
Events.on(BlockBuildEndEvent.class, e -> {
|
||||||
if(e.team == player.getTeam()){
|
if(e.team == player.team()){
|
||||||
if(e.breaking){
|
if(e.breaking){
|
||||||
state.stats.buildingsDeconstructed++;
|
state.stats.buildingsDeconstructed++;
|
||||||
}else{
|
}else{
|
||||||
@@ -140,13 +139,13 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(BlockDestroyEvent.class, e -> {
|
Events.on(BlockDestroyEvent.class, e -> {
|
||||||
if(e.tile.getTeam() == player.getTeam()){
|
if(e.tile.getTeam() == player.team()){
|
||||||
state.stats.buildingsDestroyed++;
|
state.stats.buildingsDestroyed++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(UnitDestroyEvent.class, e -> {
|
Events.on(UnitDestroyEvent.class, e -> {
|
||||||
if(e.unit.getTeam() != player.getTeam()){
|
if(e.unit.team() != player.team()){
|
||||||
state.stats.enemyUnitsDestroyed++;
|
state.stats.enemyUnitsDestroyed++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -164,13 +163,13 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(Trigger.newGame, () -> {
|
Events.on(Trigger.newGame, () -> {
|
||||||
Tilec core = player.getClosestCore();
|
Tilec core = player.closestCore();
|
||||||
|
|
||||||
if(core == null) return;
|
if(core == null) return;
|
||||||
|
|
||||||
app.post(() -> ui.hudfrag.showLand());
|
app.post(() -> ui.hudfrag.showLand());
|
||||||
renderer.zoomIn(Fx.coreLand.lifetime);
|
renderer.zoomIn(Fx.coreLand.lifetime);
|
||||||
app.post(() -> Fx.coreLand.at(core.getX(), core.getY(), 0, core.getBlock()));
|
app.post(() -> Fx.coreLand.at(core.getX(), core.getY(), 0, core.block()));
|
||||||
Time.run(Fx.coreLand.lifetime, () -> {
|
Time.run(Fx.coreLand.lifetime, () -> {
|
||||||
Fx.launch.at(core);
|
Fx.launch.at(core);
|
||||||
Effects.shake(5f, 5f, core);
|
Effects.shake(5f, 5f, core);
|
||||||
@@ -259,7 +258,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
state.rules.zone = zone;
|
state.rules.zone = zone;
|
||||||
for(Tilec core : state.teams.playerCores()){
|
for(Tilec core : state.teams.playerCores()){
|
||||||
for(ItemStack stack : zone.getStartingItems()){
|
for(ItemStack stack : zone.getStartingItems()){
|
||||||
core.getItems().add(stack.item, stack.amount);
|
core.items().add(stack.item, stack.amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.set(State.playing);
|
state.set(State.playing);
|
||||||
@@ -308,11 +307,11 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
state.rules.zone = zone;
|
state.rules.zone = zone;
|
||||||
for(Tilec core : state.teams.playerCores()){
|
for(Tilec core : state.teams.playerCores()){
|
||||||
for(ItemStack stack : zone.getStartingItems()){
|
for(ItemStack stack : zone.getStartingItems()){
|
||||||
core.getItems().add(stack.item, stack.amount);
|
core.items().add(stack.item, stack.amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Tilec core = state.teams.playerCores().first();
|
Tilec core = state.teams.playerCores().first();
|
||||||
core.getItems().clear();
|
core.items().clear();
|
||||||
|
|
||||||
logic.play();
|
logic.play();
|
||||||
state.rules.waveTimer = false;
|
state.rules.waveTimer = false;
|
||||||
@@ -435,9 +434,9 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
input.update();
|
input.update();
|
||||||
|
|
||||||
if(world.isZone()){
|
if(world.isZone()){
|
||||||
for(Tilec tile : state.teams.cores(player.getTeam())){
|
for(Tilec tile : state.teams.cores(player.team())){
|
||||||
for(Item item : content.items()){
|
for(Item item : content.items()){
|
||||||
if(tile.getItems().has(item)){
|
if(tile.items().has(item)){
|
||||||
data.unlockContent(item);
|
data.unlockContent(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import mindustry.gen.*;
|
|||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.game.Teams.*;
|
import mindustry.game.Teams.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
@@ -109,9 +108,9 @@ public class Logic implements ApplicationListener{
|
|||||||
for(TeamData team : state.teams.getActive()){
|
for(TeamData team : state.teams.getActive()){
|
||||||
if(team.hasCore()){
|
if(team.hasCore()){
|
||||||
Tilec entity = team.core();
|
Tilec entity = team.core();
|
||||||
entity.getItems().clear();
|
entity.items().clear();
|
||||||
for(ItemStack stack : state.rules.loadout){
|
for(ItemStack stack : state.rules.loadout){
|
||||||
entity.getItems().add(stack.item, stack.amount);
|
entity.items().add(stack.item, stack.amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,10 +183,10 @@ public class Logic implements ApplicationListener{
|
|||||||
Time.runTask(30f, () -> {
|
Time.runTask(30f, () -> {
|
||||||
for(Tilec entity : state.teams.playerCores()){
|
for(Tilec entity : state.teams.playerCores()){
|
||||||
for(Item item : content.items()){
|
for(Item item : content.items()){
|
||||||
data.addItem(item, entity.getItems().get(item));
|
data.addItem(item, entity.items().get(item));
|
||||||
Events.fire(new LaunchItemEvent(item, entity.getItems().get(item)));
|
Events.fire(new LaunchItemEvent(item, entity.items().get(item)));
|
||||||
}
|
}
|
||||||
entity.getTile().remove();
|
entity.tile().remove();
|
||||||
}
|
}
|
||||||
state.launched = true;
|
state.launched = true;
|
||||||
state.gameOver = true;
|
state.gameOver = true;
|
||||||
|
|||||||
@@ -318,8 +318,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
|
|
||||||
@Remote(variants = Variant.one)
|
@Remote(variants = Variant.one)
|
||||||
public static void onPositionSet(float x, float y){
|
public static void onPositionSet(float x, float y){
|
||||||
player.x = x;
|
player.set(x, y);
|
||||||
player.y = y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote
|
@Remote
|
||||||
@@ -420,7 +419,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
Tile tile = world.tile(pos);
|
Tile tile = world.tile(pos);
|
||||||
|
|
||||||
if(tile != null && tile.entity != null){
|
if(tile != null && tile.entity != null){
|
||||||
tile.entity.getItems().read(input);
|
tile.entity.items().read(input);
|
||||||
}else{
|
}else{
|
||||||
new ItemModule().read(input);
|
new ItemModule().read(input);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import mindustry.net.Administration;
|
|||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.game.Teams.*;
|
import mindustry.game.Teams.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.net.*;
|
import mindustry.net.*;
|
||||||
import mindustry.net.Administration.*;
|
import mindustry.net.Administration.*;
|
||||||
import mindustry.net.Packets.*;
|
import mindustry.net.Packets.*;
|
||||||
@@ -51,7 +50,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
TeamData re = state.teams.getActive().min(data -> {
|
TeamData re = state.teams.getActive().min(data -> {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for(Player other : players){
|
for(Player other : players){
|
||||||
if(other.getTeam() == data.team && other != player){
|
if(other.team() == data.team && other != player){
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,7 +219,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
con.player = player;
|
con.player = player;
|
||||||
|
|
||||||
//playing in pvp mode automatically assigns players to teams
|
//playing in pvp mode automatically assigns players to teams
|
||||||
player.setTeam(assignTeam(player, playerGroup.all()));
|
player.team(assignTeam(player, playerGroup.all()));
|
||||||
|
|
||||||
sendWorldData(player);
|
sendWorldData(player);
|
||||||
|
|
||||||
@@ -281,7 +280,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
});
|
});
|
||||||
|
|
||||||
clientCommands.<Player>register("t", "<message...>", "Send a message only to your teammates.", (args, player) -> {
|
clientCommands.<Player>register("t", "<message...>", "Send a message only to your teammates.", (args, player) -> {
|
||||||
playerGroup.all().each(p -> p.getTeam() == player.getTeam(), o -> o.sendMessage(args[0], player, "[#" + player.getTeam().color.toString() + "]<T>" + NetClient.colorizeName(player.id, player.name)));
|
playerGroup.all().each(p -> p.getTeam() == player.team(), o -> o.sendMessage(args[0], player, "[#" + player.team().color.toString() + "]<T>" + NetClient.colorizeName(player.id, player.name)));
|
||||||
});
|
});
|
||||||
|
|
||||||
//duration of a a kick in seconds
|
//duration of a a kick in seconds
|
||||||
@@ -374,7 +373,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
player.sendMessage("[scarlet]Did you really expect to be able to kick an admin?");
|
player.sendMessage("[scarlet]Did you really expect to be able to kick an admin?");
|
||||||
}else if(found.isLocal){
|
}else if(found.isLocal){
|
||||||
player.sendMessage("[scarlet]Local players cannot be kicked.");
|
player.sendMessage("[scarlet]Local players cannot be kicked.");
|
||||||
}else if(found.getTeam() != player.getTeam()){
|
}else if(found.team() != player.team()){
|
||||||
player.sendMessage("[scarlet]Only players on your team can be kicked.");
|
player.sendMessage("[scarlet]Only players on your team can be kicked.");
|
||||||
}else{
|
}else{
|
||||||
if(!vtime.get()){
|
if(!vtime.get()){
|
||||||
@@ -496,7 +495,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
NetConnection connection = player.con;
|
NetConnection connection = player.con;
|
||||||
if(connection == null || snapshotID < connection.lastRecievedClientSnapshot) return;
|
if(connection == null || snapshotID < connection.lastRecievedClientSnapshot) return;
|
||||||
|
|
||||||
boolean verifyPosition = !player.isDead() && netServer.admins.getStrict() && headless;
|
boolean verifyPosition = !player.dead() && netServer.admins.getStrict() && headless;
|
||||||
|
|
||||||
if(connection.lastRecievedClientTime == 0) connection.lastRecievedClientTime = Time.millis() - 16;
|
if(connection.lastRecievedClientTime == 0) connection.lastRecievedClientTime = Time.millis() - 16;
|
||||||
|
|
||||||
@@ -714,13 +713,13 @@ public class NetServer implements ApplicationListener{
|
|||||||
|
|
||||||
public void writeEntitySnapshot(Player player) throws IOException{
|
public void writeEntitySnapshot(Player player) throws IOException{
|
||||||
syncStream.reset();
|
syncStream.reset();
|
||||||
Array<CoreEntity> cores = state.teams.cores(player.getTeam());
|
Array<CoreEntity> cores = state.teams.cores(player.team());
|
||||||
|
|
||||||
dataStream.writeByte(cores.size);
|
dataStream.writeByte(cores.size);
|
||||||
|
|
||||||
for(CoreEntity entity : cores){
|
for(CoreEntity entity : cores){
|
||||||
dataStream.writeInt(entity.tile.pos());
|
dataStream.writeInt(entity.tile.pos());
|
||||||
entity.getItems().write(dataStream);
|
entity.items().write(dataStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
dataStream.close();
|
dataStream.close();
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import mindustry.content.*;
|
|||||||
import mindustry.core.GameState.*;
|
import mindustry.core.GameState.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.entities.type.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.input.*;
|
import mindustry.input.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
@@ -79,8 +80,8 @@ public class Renderer implements ApplicationListener{
|
|||||||
}else{
|
}else{
|
||||||
Vec2 position = Tmp.v3.set(player);
|
Vec2 position = Tmp.v3.set(player);
|
||||||
|
|
||||||
if(player.isDead()){
|
if(player.dead()){
|
||||||
Tilec core = player.getClosestCore();
|
Tilec core = player.closestCore();
|
||||||
if(core != null){
|
if(core != null){
|
||||||
if(player.spawner == null){
|
if(player.spawner == null){
|
||||||
camera.position.lerpDelta(core.x, core.y, 0.08f);
|
camera.position.lerpDelta(core.x, core.y, 0.08f);
|
||||||
@@ -277,9 +278,9 @@ public class Renderer implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void drawLanding(){
|
private void drawLanding(){
|
||||||
if(landTime > 0 && player.getClosestCore() != null){
|
if(landTime > 0 && player.closestCore() != null){
|
||||||
float fract = landTime / Fx.coreLand.lifetime;
|
float fract = landTime / Fx.coreLand.lifetime;
|
||||||
Tilec entity = player.getClosestCore();
|
Tilec entity = player.closestCore();
|
||||||
|
|
||||||
TextureRegion reg = entity.block.icon(Cicon.full);
|
TextureRegion reg = entity.block.icon(Cicon.full);
|
||||||
float scl = Scl.scl(4f) / camerascale;
|
float scl = Scl.scl(4f) / camerascale;
|
||||||
|
|||||||
@@ -141,9 +141,9 @@ public class EditorTile extends Tile{
|
|||||||
if(block.hasEntity()){
|
if(block.hasEntity()){
|
||||||
entity = block.newEntity().init(this, false);
|
entity = block.newEntity().init(this, false);
|
||||||
entity.cons = new ConsumeModule(entity);
|
entity.cons = new ConsumeModule(entity);
|
||||||
if(block.hasItems) entity.getItems() = new ItemModule();
|
if(block.hasItems) entity.items() = new ItemModule();
|
||||||
if(block.hasLiquids) entity.getLiquids() = new LiquidModule();
|
if(block.hasLiquids) entity.liquids() = new LiquidModule();
|
||||||
if(block.hasPower) entity.getPower() = new PowerModule();
|
if(block.hasPower) entity.power() = new PowerModule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.set(world.width() * tilesize/2f, world.height() * tilesize/2f);
|
player.set(world.width() * tilesize/2f, world.height() * tilesize/2f);
|
||||||
player.setDead(false);
|
player.dead(false);
|
||||||
logic.play();
|
logic.play();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import arc.math.geom.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.effect.*;
|
import mindustry.entities.effect.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
@@ -178,7 +177,7 @@ public class Damage{
|
|||||||
/** Damages all entities and blocks in a radius that are enemies of the team. */
|
/** Damages all entities and blocks in a radius that are enemies of the team. */
|
||||||
public static void damage(Team team, float x, float y, float radius, float damage, boolean complete){
|
public static void damage(Team team, float x, float y, float radius, float damage, boolean complete){
|
||||||
Cons<Unitc> cons = entity -> {
|
Cons<Unitc> cons = entity -> {
|
||||||
if(entity.getTeam() == team || entity.dst(x, y) > radius){
|
if(entity.team() == team || entity.dst(x, y) > radius){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float amount = calculateDamage(x, y, entity.getX(), entity.getY(), radius, damage);
|
float amount = calculateDamage(x, y, entity.getX(), entity.getY(), radius, damage);
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ public class EntityCollisions{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.setX(entity.getX() + rect.x - r2.x);
|
entity.x(entity.getX() + rect.x - r2.x);
|
||||||
entity.setY(entity.getY() + rect.y - r2.y);
|
entity.y(entity.getY() + rect.y - r2.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean overlapsTile(Rect rect){
|
public boolean overlapsTile(Rect rect){
|
||||||
@@ -112,8 +112,8 @@ public class EntityCollisions{
|
|||||||
tree.clear();
|
tree.clear();
|
||||||
|
|
||||||
group.each(s -> {
|
group.each(s -> {
|
||||||
s.setLastX(s.getX());
|
s.lastX(s.getX());
|
||||||
s.setLastY(s.getY());
|
s.lastY(s.getY());
|
||||||
tree.insert(s);
|
tree.insert(s);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -128,15 +128,15 @@ public class EntityCollisions{
|
|||||||
a.hitbox(this.r1);
|
a.hitbox(this.r1);
|
||||||
b.hitbox(this.r2);
|
b.hitbox(this.r2);
|
||||||
|
|
||||||
r1.x += (a.getLastX() - a.getX());
|
r1.x += (a.lastX() - a.getX());
|
||||||
r1.y += (a.getLastY() - a.getY());
|
r1.y += (a.lastY() - a.getY());
|
||||||
r2.x += (b.getLastX() - b.getX());
|
r2.x += (b.lastX() - b.getX());
|
||||||
r2.y += (b.getLastY() - b.getY());
|
r2.y += (b.lastY() - b.getY());
|
||||||
|
|
||||||
float vax = a.getX() - a.getLastX();
|
float vax = a.getX() - a.lastX();
|
||||||
float vay = a.getY() - a.getLastY();
|
float vay = a.getY() - a.lastY();
|
||||||
float vbx = b.getX() - b.getLastX();
|
float vbx = b.getX() - b.lastX();
|
||||||
float vby = b.getY() - b.getLastY();
|
float vby = b.getY() - b.lastY();
|
||||||
|
|
||||||
if(a != b && a.collides(b)){
|
if(a != b && a.collides(b)){
|
||||||
l1.set(a.getX(), a.getY());
|
l1.set(a.getX(), a.getY());
|
||||||
@@ -204,8 +204,8 @@ public class EntityCollisions{
|
|||||||
|
|
||||||
groupa.each(solid -> {
|
groupa.each(solid -> {
|
||||||
solid.hitbox(r1);
|
solid.hitbox(r1);
|
||||||
r1.x += (solid.getLastX() - solid.getX());
|
r1.x += (solid.lastX() - solid.getX());
|
||||||
r1.y += (solid.getLastY() - solid.getY());
|
r1.y += (solid.lastY() - solid.getY());
|
||||||
|
|
||||||
solid.hitbox(r2);
|
solid.hitbox(r2);
|
||||||
r2.merge(r1);
|
r2.merge(r1);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class Units{
|
|||||||
|
|
||||||
/** @return whether this player can interact with a specific tile. if either of these are null, returns true.*/
|
/** @return whether this player can interact with a specific tile. if either of these are null, returns true.*/
|
||||||
public static boolean canInteract(Player player, Tile tile){
|
public static boolean canInteract(Player player, Tile tile){
|
||||||
return player == null || tile == null || tile.interactable(player.getTeam());
|
return player == null || tile == null || tile.interactable(player.team());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +32,7 @@ public class Units{
|
|||||||
* @return whether the target is invalid
|
* @return whether the target is invalid
|
||||||
*/
|
*/
|
||||||
public static boolean invalidateTarget(Teamc target, Team team, float x, float y, float range){
|
public static boolean invalidateTarget(Teamc target, Team team, float x, float y, float range){
|
||||||
return target == null || (range != Float.MAX_VALUE && !target.withinDst(x, y, range)) || target.getTeam() == team || !target.isValid();
|
return target == null || (range != Float.MAX_VALUE && !target.withinDst(x, y, range)) || target.team() == team || !target.isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** See {@link #invalidateTarget(Teamc, Team, float, float, float)} */
|
/** See {@link #invalidateTarget(Teamc, Team, float, float, float)} */
|
||||||
@@ -42,7 +42,7 @@ public class Units{
|
|||||||
|
|
||||||
/** See {@link #invalidateTarget(Teamc, Team, float, float, float)} */
|
/** See {@link #invalidateTarget(Teamc, Team, float, float, float)} */
|
||||||
public static boolean invalidateTarget(Teamc target, Unitc targeter){
|
public static boolean invalidateTarget(Teamc target, Unitc targeter){
|
||||||
return invalidateTarget(target, targeter.getTeam(), targeter.x, targeter.y, targeter.getWeapon().bullet.range());
|
return invalidateTarget(target, targeter.team(), targeter.x, targeter.y, targeter.getWeapon().bullet.range());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns whether there are any entities on this tile. */
|
/** Returns whether there are any entities on this tile. */
|
||||||
@@ -116,7 +116,7 @@ public class Units{
|
|||||||
cdist = 0f;
|
cdist = 0f;
|
||||||
|
|
||||||
nearbyEnemies(team, x - range, y - range, range*2f, range*2f, e -> {
|
nearbyEnemies(team, x - range, y - range, range*2f, range*2f, e -> {
|
||||||
if(e.isDead() || !predicate.get(e)) return;
|
if(e.dead() || !predicate.get(e)) return;
|
||||||
|
|
||||||
float dst2 = Mathf.dst2(e.x, e.y, x, y);
|
float dst2 = Mathf.dst2(e.x, e.y, x, y);
|
||||||
if(dst2 < range*range && (result == null || dst2 < cdist)){
|
if(dst2 < range*range && (result == null || dst2 < cdist)){
|
||||||
|
|||||||
@@ -2,16 +2,11 @@ package mindustry.entities.bullet;
|
|||||||
|
|
||||||
import arc.audio.*;
|
import arc.audio.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
|
||||||
import arc.struct.*;
|
|
||||||
import arc.util.*;
|
|
||||||
import arc.util.pooling.*;
|
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.effect.*;
|
import mindustry.entities.effect.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
@@ -132,7 +127,7 @@ public abstract class BulletType extends Content{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(splashDamageRadius > 0){
|
if(splashDamageRadius > 0){
|
||||||
Damage.damage(b.getTeam(), x, y, splashDamageRadius, splashDamage * b.damageMultiplier());
|
Damage.damage(b.team(), x, y, splashDamageRadius, splashDamage * b.damageMultiplier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +140,7 @@ public abstract class BulletType extends Content{
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < lightining; i++){
|
for(int i = 0; i < lightining; i++){
|
||||||
Lightning.createLighting(Lightning.nextSeed(), b.getTeam(), Pal.surge, damage, b.getX(), b.getY(), Mathf.random(360f), lightningLength);
|
Lightning.createLighting(Lightning.nextSeed(), b.team(), Pal.surge, damage, b.getX(), b.getY(), Mathf.random(360f), lightningLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,9 +159,9 @@ public abstract class BulletType extends Content{
|
|||||||
|
|
||||||
public void update(Bulletc b){
|
public void update(Bulletc b){
|
||||||
if(homingPower > 0.0001f){
|
if(homingPower > 0.0001f){
|
||||||
Teamc target = Units.closestTarget(b.getTeam(), b.getX(), b.getY(), homingRange, e -> !e.isFlying() || collidesAir);
|
Teamc target = Units.closestTarget(b.team(), b.getX(), b.getY(), homingRange, e -> !e.isFlying() || collidesAir);
|
||||||
if(target != null){
|
if(target != null){
|
||||||
b.getVel().setAngle(Mathf.slerpDelta(b.getRotation(), b.angleTo(target), 0.08f));
|
b.vel().setAngle(Mathf.slerpDelta(b.getRotation(), b.angleTo(target), 0.08f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,7 +174,7 @@ public abstract class BulletType extends Content{
|
|||||||
//TODO change 'create' to 'at'
|
//TODO change 'create' to 'at'
|
||||||
|
|
||||||
public Bulletc create(Teamc owner, float x, float y, float angle){
|
public Bulletc create(Teamc owner, float x, float y, float angle){
|
||||||
return create(owner, owner.getTeam(), x, y, angle);
|
return create(owner, owner.team(), x, y, angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bulletc create(Entityc owner, Team team, float x, float y, float angle){
|
public Bulletc create(Entityc owner, Team team, float x, float y, float angle){
|
||||||
@@ -195,11 +190,11 @@ public abstract class BulletType extends Content{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Bulletc create(Bulletc parent, float x, float y, float angle){
|
public Bulletc create(Bulletc parent, float x, float y, float angle){
|
||||||
return create(parent.getOwner(), parent.getTeam(), x, y, angle);
|
return create(parent.getOwner(), parent.team(), x, y, angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bulletc create(Bulletc parent, float x, float y, float angle, float velocityScl){
|
public Bulletc create(Bulletc parent, float x, float y, float angle, float velocityScl){
|
||||||
return create(parent.getOwner(), parent.getTeam(), x, y, angle, velocityScl);
|
return create(parent.getOwner(), parent.team(), x, y, angle, velocityScl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bulletc create(Entityc owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl, Object data){
|
public Bulletc create(Entityc owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl, Object data){
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class FlakBulletType extends BasicBulletType{
|
|||||||
if(b.getData() instanceof Integer) return;
|
if(b.getData() instanceof Integer) return;
|
||||||
|
|
||||||
if(b.timer.get(2, 6)){
|
if(b.timer.get(2, 6)){
|
||||||
Units.nearbyEnemies(b.getTeam(), rect.setSize(explodeRange * 2f).setCenter(b.x, b.y), unit -> {
|
Units.nearbyEnemies(b.team(), rect.setSize(explodeRange * 2f).setCenter(b.x, b.y), unit -> {
|
||||||
if(b.getData() instanceof Float) return;
|
if(b.getData() instanceof Float) return;
|
||||||
|
|
||||||
if(unit.dst(b) < explodeRange){
|
if(unit.dst(b) < explodeRange){
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class HealBulletType extends BulletType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean collides(Bulletc b, Tile tile){
|
public boolean collides(Bulletc b, Tile tile){
|
||||||
return tile.getTeam() != b.getTeam() || tile.entity.healthf() < 1f;
|
return tile.getTeam() != b.team() || tile.entity.healthf() < 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -47,7 +47,7 @@ public class HealBulletType extends BulletType{
|
|||||||
super.hit(b);
|
super.hit(b);
|
||||||
tile = tile.link();
|
tile = tile.link();
|
||||||
|
|
||||||
if(tile.entity != null && tile.getTeam() == b.getTeam() && !(tile.block() instanceof BuildBlock)){
|
if(tile.entity != null && tile.getTeam() == b.team() && !(tile.block() instanceof BuildBlock)){
|
||||||
Fx.healBlockFull.at(tile.drawx(), tile.drawy(), tile.block().size, Pal.heal);
|
Fx.healBlockFull.at(tile.drawx(), tile.drawy(), tile.block().size, Pal.heal);
|
||||||
tile.entity.healBy(healPercent / 100f * tile.entity.maxHealth());
|
tile.entity.healBy(healPercent / 100f * tile.entity.maxHealth());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class LaserBulletType extends BulletType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bulletc b){
|
public void init(Bulletc b){
|
||||||
Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), length);
|
Damage.collideLine(b, b.team(), hitEffect, b.x, b.y, b.rot(), length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,6 +25,6 @@ public class LightningBulletType extends BulletType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Bulletc b){
|
public void init(Bulletc b){
|
||||||
Lightning.create(b.getTeam(), lightningColor, damage, b.x, b.y, b.rot(), lightningLength);
|
Lightning.create(b.team(), lightningColor, damage, b.x, b.y, b.rot(), lightningLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import java.util.*;
|
|||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings({"unused", "unused"})
|
||||||
public class EntityComps{
|
public class EntityComps{
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -47,41 +47,48 @@ public class EntityComps{
|
|||||||
private UnitController controller;
|
private UnitController controller;
|
||||||
private UnitDef type;
|
private UnitDef type;
|
||||||
|
|
||||||
public float getBounds(){
|
@Override
|
||||||
return getHitSize() * 2f;
|
public float bounds(){
|
||||||
|
return hitSize() * 2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setController(UnitController controller){
|
@Override
|
||||||
|
public void controller(UnitController controller){
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
controller.set(this);
|
controller.set(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnitController getController(){
|
@Override
|
||||||
|
public UnitController controller(){
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void set(UnitDef def, UnitController controller){
|
public void set(UnitDef def, UnitController controller){
|
||||||
setType(type);
|
type(type);
|
||||||
setController(controller);
|
controller(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(UnitDef type){
|
@Override
|
||||||
|
public void type(UnitDef type){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
setupWeapons(type);
|
setupWeapons(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnitDef getType(){
|
@Override
|
||||||
|
public UnitDef type(){
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
//apply knockback based on spawns
|
//apply knockback based on spawns
|
||||||
//TODO move elsewhere
|
//TODO move elsewhere
|
||||||
if(getTeam() != state.rules.waveTeam){
|
if(team() != state.rules.waveTeam){
|
||||||
float relativeSize = state.rules.dropZoneRadius + getBounds()/2f + 1f;
|
float relativeSize = state.rules.dropZoneRadius + bounds()/2f + 1f;
|
||||||
for(Tile spawn : spawner.getGroundSpawns()){
|
for(Tile spawn : spawner.getGroundSpawns()){
|
||||||
if(withinDst(spawn.worldx(), spawn.worldy(), relativeSize)){
|
if(withinDst(spawn.worldx(), spawn.worldy(), relativeSize)){
|
||||||
getVel().add(Tmp.v1.set(this).sub(spawn.worldx(), spawn.worldy()).setLength(0.1f + 1f - dst(spawn) / relativeSize).scl(0.45f * Time.delta()));
|
vel().add(Tmp.v1.set(this).sub(spawn.worldx(), spawn.worldy()).setLength(0.1f + 1f - dst(spawn) / relativeSize).scl(0.45f * Time.delta()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,7 +98,7 @@ public class EntityComps{
|
|||||||
|
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
//unit block update
|
//unit block update
|
||||||
tile.block().unitOn(tile, (mindustry.gen.Unitc)this);
|
tile.block().unitOn(tile, this);
|
||||||
|
|
||||||
//apply damage
|
//apply damage
|
||||||
if(floor.damageTaken > 0f){
|
if(floor.damageTaken > 0f){
|
||||||
@@ -100,6 +107,7 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void drawLight(){
|
public void drawLight(){
|
||||||
//TODO move
|
//TODO move
|
||||||
if(type.lightRadius > 0){
|
if(type.lightRadius > 0){
|
||||||
@@ -107,17 +115,19 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
//draw power cell - TODO move
|
//draw power cell - TODO move
|
||||||
Draw.color(Color.black, getTeam().color, healthf() + Mathf.absin(Time.time(), Math.max(healthf() * 5f, 1f), 1f - healthf()));
|
Draw.color(Color.black, team().color, healthf() + Mathf.absin(Time.time(), Math.max(healthf() * 5f, 1f), 1f - healthf()));
|
||||||
Draw.rect(type.cellRegion, getX(), getY(), getRotation() - 90);
|
Draw.rect(type.cellRegion, getX(), getY(), rotation() - 90);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void killed(){
|
public void killed(){
|
||||||
float explosiveness = 2f + item().explosiveness * getStack().amount;
|
float explosiveness = 2f + item().explosiveness * stack().amount;
|
||||||
float flammability = item().flammability * getStack().amount;
|
float flammability = item().flammability * stack().amount;
|
||||||
Damage.dynamicExplosion(getX(), getY(), flammability, explosiveness, 0f, getBounds() / 2f, Pal.darkFlame);
|
Damage.dynamicExplosion(getX(), getY(), flammability, explosiveness, 0f, bounds() / 2f, Pal.darkFlame);
|
||||||
|
|
||||||
//TODO cleanup
|
//TODO cleanup
|
||||||
//ScorchDecal.create(getX(), getY());
|
//ScorchDecal.create(getX(), getY());
|
||||||
@@ -125,7 +135,7 @@ public class EntityComps{
|
|||||||
Effects.shake(2f, 2f, this);
|
Effects.shake(2f, 2f, this);
|
||||||
|
|
||||||
Sounds.bang.at(this);
|
Sounds.bang.at(this);
|
||||||
Events.fire(new UnitDestroyEvent((mindustry.gen.Unitc)this));
|
Events.fire(new UnitDestroyEvent(this));
|
||||||
|
|
||||||
//TODO implement suicide bomb trigger
|
//TODO implement suicide bomb trigger
|
||||||
//if(explosiveness > 7f && this == player){
|
//if(explosiveness > 7f && this == player){
|
||||||
@@ -146,6 +156,7 @@ public class EntityComps{
|
|||||||
private @Nullable Posc parent;
|
private @Nullable Posc parent;
|
||||||
private float offsetX, offsetY;
|
private float offsetX, offsetY;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void add(){
|
public void add(){
|
||||||
if(parent != null){
|
if(parent != null){
|
||||||
offsetX = x - parent.getX();
|
offsetX = x - parent.getX();
|
||||||
@@ -153,6 +164,7 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
if(parent != null){
|
if(parent != null){
|
||||||
x = parent.getX() + offsetX;
|
x = parent.getX() + offsetX;
|
||||||
@@ -168,68 +180,78 @@ public class EntityComps{
|
|||||||
Object data;
|
Object data;
|
||||||
BulletType type;
|
BulletType type;
|
||||||
|
|
||||||
|
@Override
|
||||||
public float getDamage(){
|
public float getDamage(){
|
||||||
return type.damage;
|
return type.damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void add(){
|
public void add(){
|
||||||
type.init(this);
|
type.init(this);
|
||||||
|
|
||||||
setDrag(type.drag);
|
drag(type.drag);
|
||||||
setHitSize(type.hitSize);
|
hitSize(type.hitSize);
|
||||||
setLifetime(lifeScl * type.lifetime);
|
lifetime(lifeScl * type.lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void remove(){
|
public void remove(){
|
||||||
type.despawned(this);
|
type.despawned(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float getLifetime(){
|
public float getLifetime(){
|
||||||
return type.lifetime;
|
return type.lifetime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float damageMultiplier(){
|
public float damageMultiplier(){
|
||||||
if(getOwner() instanceof Unitc){
|
if(owner() instanceof Unitc){
|
||||||
return ((Unitc)getOwner()).getDamageMultiplier();
|
return ((Unitc)owner()).damageMultiplier();
|
||||||
}
|
}
|
||||||
return 1f;
|
return 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void absorb(){
|
public void absorb(){
|
||||||
//TODO
|
//TODO
|
||||||
remove();
|
remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float clipSize(){
|
public float clipSize(){
|
||||||
return type.drawSize;
|
return type.drawSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float damage(){
|
public float damage(){
|
||||||
return type.damage * damageMultiplier();
|
return type.damage * damageMultiplier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void collision(Hitboxc other, float x, float y){
|
public void collision(Hitboxc other, float x, float y){
|
||||||
if(!type.pierce) remove();
|
if(!type.pierce) remove();
|
||||||
type.hit(this, x, y);
|
type.hit(this, x, y);
|
||||||
|
|
||||||
if(other instanceof Unitc){
|
if(other instanceof Unitc){
|
||||||
Unitc unit = (Unitc)other;
|
Unitc unit = (Unitc)other;
|
||||||
unit.getVel().add(Tmp.v3.set(other.getX(), other.getY()).sub(x, y).setLength(type.knockback / unit.getMass()));
|
unit.vel().add(Tmp.v3.set(other.x(), other.y()).sub(x, y).setLength(type.knockback / unit.mass()));
|
||||||
unit.apply(type.status, type.statusDuration);
|
unit.apply(type.status, type.statusDuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
type.update(this);
|
type.update(this);
|
||||||
|
|
||||||
if(type.hitTiles){
|
if(type.hitTiles){
|
||||||
world.raycastEach(world.toTile(getLastX()), world.toTile(getLastY()), tileX(), tileY(), (x, y) -> {
|
world.raycastEach(world.toTile(lastX()), world.toTile(lastY()), tileX(), tileY(), (x, y) -> {
|
||||||
|
|
||||||
Tile tile = world.ltile(x, y);
|
Tile tile = world.ltile(x, y);
|
||||||
if(tile == null) return false;
|
if(tile == null) return false;
|
||||||
|
|
||||||
if(tile.entity != null && tile.entity.collide(this) && type.collides(this, tile) && !tile.entity.isDead() && (type.collidesTeam || tile.getTeam() != getTeam())){
|
if(tile.entity != null && tile.entity.collide(this) && type.collides(this, tile) && !tile.entity.dead() && (type.collidesTeam || tile.getTeam() != team())){
|
||||||
if(tile.getTeam() != getTeam()){
|
if(tile.getTeam() != team()){
|
||||||
tile.entity.collision(this);
|
tile.entity.collision(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,20 +265,23 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
type.draw(this);
|
type.draw(this);
|
||||||
//TODO refactor
|
//TODO refactor
|
||||||
renderer.lights.add(getX(), getY(), 16f, Pal.powerLight, 0.3f);
|
renderer.lights.add(x(), y(), 16f, Pal.powerLight, 0.3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets the bullet's rotation in degrees. */
|
/** Sets the bullet's rotation in degrees. */
|
||||||
public void setRotation(float angle){
|
@Override
|
||||||
getVel().setAngle(angle);
|
public void rotation(float angle){
|
||||||
|
vel().setAngle(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the bullet's rotation. */
|
/** @return the bullet's rotation. */
|
||||||
public float getRotation(){
|
@Override
|
||||||
float angle = Mathf.atan2(getVel().x, getVel().y) * Mathf.radiansToDegrees;
|
public float rotation(){
|
||||||
|
float angle = Mathf.atan2(vel().x, vel().y) * Mathf.radiansToDegrees;
|
||||||
if(angle < 0) angle += 360;
|
if(angle < 0) angle += 360;
|
||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
@@ -264,13 +289,14 @@ public class EntityComps{
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
abstract class DamageComp{
|
abstract class DamageComp{
|
||||||
abstract float getDamage();
|
abstract float damage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
abstract class TimedComp implements Entityc, Scaled{
|
abstract class TimedComp implements Entityc, Scaled{
|
||||||
float time, lifetime;
|
float time, lifetime;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
time = Math.min(time + Time.delta(), lifetime);
|
time = Math.min(time + Time.delta(), lifetime);
|
||||||
|
|
||||||
@@ -300,6 +326,7 @@ public class EntityComps{
|
|||||||
return health / maxHealth;
|
return health / maxHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
hitTime -= Time.delta() / hitDuration;
|
hitTime -= Time.delta() / hitDuration;
|
||||||
}
|
}
|
||||||
@@ -366,6 +393,7 @@ public class EntityComps{
|
|||||||
return elevation < 0.001f;
|
return elevation < 0.001f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
Floor floor = floorOn();
|
Floor floor = floorOn();
|
||||||
|
|
||||||
@@ -377,7 +405,7 @@ public class EntityComps{
|
|||||||
drownTime += Time.delta() * 1f / floor.drownTime;
|
drownTime += Time.delta() * 1f / floor.drownTime;
|
||||||
drownTime = Mathf.clamp(drownTime);
|
drownTime = Mathf.clamp(drownTime);
|
||||||
if(Mathf.chance(Time.delta() * 0.05f)){
|
if(Mathf.chance(Time.delta() * 0.05f)){
|
||||||
floor.drownUpdateEffect.at(getX(), getY(), 0f, floor.color);
|
floor.drownUpdateEffect.at(x, y, 0f, floor.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO is the netClient check necessary?
|
//TODO is the netClient check necessary?
|
||||||
@@ -403,8 +431,8 @@ public class EntityComps{
|
|||||||
void interpolate(){
|
void interpolate(){
|
||||||
Syncc sync = (Syncc)this;
|
Syncc sync = (Syncc)this;
|
||||||
|
|
||||||
if(sync.getInterpolator().values.length > 0){
|
if(sync.interpolator().values.length > 0){
|
||||||
rotation = sync.getInterpolator().values[0];
|
rotation = sync.interpolator().values[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -433,6 +461,7 @@ public class EntityComps{
|
|||||||
private float sleepTime;
|
private float sleepTime;
|
||||||
|
|
||||||
/** Sets this tile entity data to this tile, and adds it if necessary. */
|
/** Sets this tile entity data to this tile, and adds it if necessary. */
|
||||||
|
@Override
|
||||||
public Tilec init(Tile tile, boolean shouldAdd){
|
public Tilec init(Tile tile, boolean shouldAdd){
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
this.block = tile.block();
|
this.block = tile.block();
|
||||||
@@ -442,8 +471,8 @@ public class EntityComps{
|
|||||||
sound = new SoundLoop(block.activeSound, block.activeSoundVolume);
|
sound = new SoundLoop(block.activeSound, block.activeSoundVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
setHealth(block.health);
|
health(block.health);
|
||||||
setMaxHealth(block.health);
|
maxHealth(block.health);
|
||||||
timer = new Interval(block.timers);
|
timer = new Interval(block.timers);
|
||||||
|
|
||||||
if(shouldAdd){
|
if(shouldAdd){
|
||||||
@@ -453,33 +482,40 @@ public class EntityComps{
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getTimeScale(){
|
@Override
|
||||||
|
public float timeScale(){
|
||||||
return timeScale;
|
return timeScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean consValid(){
|
public boolean consValid(){
|
||||||
return cons.valid();
|
return cons.valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void consume(){
|
public void consume(){
|
||||||
cons.trigger();
|
cons.trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean timer(int id, float time){
|
public boolean timer(int id, float time){
|
||||||
return timer.get(id, time);
|
return timer.get(id, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Scaled delta. */
|
/** Scaled delta. */
|
||||||
|
@Override
|
||||||
public float delta(){
|
public float delta(){
|
||||||
return Time.delta() * timeScale;
|
return Time.delta() * timeScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Base efficiency. If this entity has non-buffered power, returns the power %, otherwise returns 1. */
|
/** Base efficiency. If this entity has non-buffered power, returns the power %, otherwise returns 1. */
|
||||||
|
@Override
|
||||||
public float efficiency(){
|
public float efficiency(){
|
||||||
return power != null && (block.consumes.has(ConsumeType.power) && !block.consumes.getPower().buffered) ? power.status : 1f;
|
return power != null && (block.consumes.has(ConsumeType.power) && !block.consumes.getPower().buffered) ? power.status : 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Call when nothing is happening to the entity. This increments the internal sleep timer. */
|
/** Call when nothing is happening to the entity. This increments the internal sleep timer. */
|
||||||
|
@Override
|
||||||
public void sleep(){
|
public void sleep(){
|
||||||
sleepTime += Time.delta();
|
sleepTime += Time.delta();
|
||||||
if(!sleeping && sleepTime >= timeToSleep){
|
if(!sleeping && sleepTime >= timeToSleep){
|
||||||
@@ -490,6 +526,7 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Call when this entity is updating. This wakes it up. */
|
/** Call when this entity is updating. This wakes it up. */
|
||||||
|
@Override
|
||||||
public void noSleep(){
|
public void noSleep(){
|
||||||
sleepTime = 0f;
|
sleepTime = 0f;
|
||||||
if(sleeping){
|
if(sleeping){
|
||||||
@@ -500,20 +537,24 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the version of this TileEntity IO code.*/
|
/** Returns the version of this TileEntity IO code.*/
|
||||||
|
@Override
|
||||||
public byte version(){
|
public byte version(){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean collide(Bulletc other){
|
public boolean collide(Bulletc other){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void collision(Bulletc other){
|
public void collision(Bulletc other){
|
||||||
block.handleBulletHit(this, other);
|
block.handleBulletHit(this, other);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Implement damage!
|
//TODO Implement damage!
|
||||||
|
|
||||||
|
@Override
|
||||||
public void removeFromProximity(){
|
public void removeFromProximity(){
|
||||||
block.onProximityRemoved(tile);
|
block.onProximityRemoved(tile);
|
||||||
|
|
||||||
@@ -525,12 +566,13 @@ public class EntityComps{
|
|||||||
other.block().onProximityUpdate(other);
|
other.block().onProximityUpdate(other);
|
||||||
|
|
||||||
if(other.entity != null){
|
if(other.entity != null){
|
||||||
other.entity.getProximity().remove(tile, true);
|
other.entity.proximity().remove(tile, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void updateProximity(){
|
public void updateProximity(){
|
||||||
tmpTiles.clear();
|
tmpTiles.clear();
|
||||||
proximity.clear();
|
proximity.clear();
|
||||||
@@ -543,8 +585,8 @@ public class EntityComps{
|
|||||||
if(other.entity == null || !(other.interactable(tile.getTeam()))) continue;
|
if(other.entity == null || !(other.interactable(tile.getTeam()))) continue;
|
||||||
|
|
||||||
//add this tile to proximity of nearby tiles
|
//add this tile to proximity of nearby tiles
|
||||||
if(!other.entity.getProximity().contains(tile, true)){
|
if(!other.entity.proximity().contains(tile, true)){
|
||||||
other.entity.getProximity().add(tile);
|
other.entity.proximity().add(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpTiles.add(other);
|
tmpTiles.add(other);
|
||||||
@@ -563,21 +605,25 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Array<Tile> proximity(){
|
public Array<Tile> proximity(){
|
||||||
return proximity;
|
return proximity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Tile configuration. Defaults to 0. Used for block rebuilding. */
|
/** Tile configuration. Defaults to 0. Used for block rebuilding. */
|
||||||
|
@Override
|
||||||
public int config(){
|
public int config(){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void remove(){
|
public void remove(){
|
||||||
if(sound != null){
|
if(sound != null){
|
||||||
sound.stop();
|
sound.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void killed(){
|
public void killed(){
|
||||||
Events.fire(new BlockDestroyEvent(tile));
|
Events.fire(new BlockDestroyEvent(tile));
|
||||||
block.breakSound.at(tile);
|
block.breakSound.at(tile);
|
||||||
@@ -585,6 +631,7 @@ public class EntityComps{
|
|||||||
tile.remove();
|
tile.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
timeScaleDuration -= Time.delta();
|
timeScaleDuration -= Time.delta();
|
||||||
if(timeScaleDuration <= 0f || !block.canOverdrive){
|
if(timeScaleDuration <= 0f || !block.canOverdrive){
|
||||||
@@ -592,7 +639,7 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(sound != null){
|
if(sound != null){
|
||||||
sound.update(getX(), getY(), block.shouldActiveSound(tile));
|
sound.update(x(), y(), block.shouldActiveSound(tile));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(block.idleSound != Sounds.none && block.shouldIdleSound(tile)){
|
if(block.idleSound != Sounds.none && block.shouldIdleSound(tile)){
|
||||||
@@ -621,7 +668,7 @@ public class EntityComps{
|
|||||||
|
|
||||||
Team team = Team.sharded;
|
Team team = Team.sharded;
|
||||||
|
|
||||||
public @Nullable Tilec getClosestCore(){
|
public @Nullable Tilec closestCore(){
|
||||||
return state.teams.closestCore(x, y, team);
|
return state.teams.closestCore(x, y, team);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -638,7 +685,7 @@ public class EntityComps{
|
|||||||
static int sequenceNum = 0;
|
static int sequenceNum = 0;
|
||||||
|
|
||||||
/** weapon mount array, never null */
|
/** weapon mount array, never null */
|
||||||
WeaponMount[] mounts = {};
|
@ReadOnly WeaponMount[] mounts = {};
|
||||||
|
|
||||||
void setupWeapons(UnitDef def){
|
void setupWeapons(UnitDef def){
|
||||||
mounts = new WeaponMount[def.weapons.size];
|
mounts = new WeaponMount[def.weapons.size];
|
||||||
@@ -662,6 +709,7 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Update shooting and rotation for this unit. */
|
/** Update shooting and rotation for this unit. */
|
||||||
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
for(WeaponMount mount : mounts){
|
for(WeaponMount mount : mounts){
|
||||||
Weapon weapon = mount.weapon;
|
Weapon weapon = mount.weapon;
|
||||||
@@ -744,7 +792,7 @@ public class EntityComps{
|
|||||||
|
|
||||||
if(this instanceof Velc){
|
if(this instanceof Velc){
|
||||||
//TODO apply force?
|
//TODO apply force?
|
||||||
((Velc)this).getVel().add(Tmp.v1);
|
((Velc)this).vel().add(Tmp.v1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tmp.v1.trns(rotation, 3f);
|
Tmp.v1.trns(rotation, 3f);
|
||||||
@@ -774,7 +822,7 @@ public class EntityComps{
|
|||||||
void drawShadow(){
|
void drawShadow(){
|
||||||
if(!isGrounded()){
|
if(!isGrounded()){
|
||||||
Draw.color(shadowColor);
|
Draw.color(shadowColor);
|
||||||
Draw.rect(getShadowRegion(), x + shadowTX * getElevation(), y + shadowTY * getElevation(), rotation - 90);
|
Draw.rect(getShadowRegion(), x + shadowTX * elevation(), y + shadowTY * elevation(), rotation - 90);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -787,6 +835,7 @@ public class EntityComps{
|
|||||||
float itemTime;
|
float itemTime;
|
||||||
|
|
||||||
//drawn after base
|
//drawn after base
|
||||||
|
@Override
|
||||||
@MethodPriority(3)
|
@MethodPriority(3)
|
||||||
public void draw(){
|
public void draw(){
|
||||||
boolean number = isLocal();
|
boolean number = isLocal();
|
||||||
@@ -812,7 +861,7 @@ public class EntityComps{
|
|||||||
(3f + Mathf.absin(Time.time(), 5f, 1f)) * itemTime);
|
(3f + Mathf.absin(Time.time(), 5f, 1f)) * itemTime);
|
||||||
|
|
||||||
if(isLocal()){
|
if(isLocal()){
|
||||||
Fonts.outline.draw(getStack().amount + "",
|
Fonts.outline.draw(stack().amount + "",
|
||||||
x + Angles.trnsx(rotation + 180f, backTrns),
|
x + Angles.trnsx(rotation + 180f, backTrns),
|
||||||
y + Angles.trnsy(rotation + 180f, backTrns) - 3,
|
y + Angles.trnsy(rotation + 180f, backTrns) - 3,
|
||||||
Pal.accent, 0.25f * itemTime / Scl.scl(1f), false, Align.center
|
Pal.accent, 0.25f * itemTime / Scl.scl(1f), false, Align.center
|
||||||
@@ -829,12 +878,14 @@ public class EntityComps{
|
|||||||
Color color = new Color(1, 1, 1, 1);
|
Color color = new Color(1, 1, 1, 1);
|
||||||
TextureRegion region;
|
TextureRegion region;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
Draw.color(color);
|
Draw.color(color);
|
||||||
Draw.rect(region, getX(), getY(), getRotation());
|
Draw.rect(region, x(), y(), rotation());
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float clipSize(){
|
public float clipSize(){
|
||||||
return region.getWidth()*2;
|
return region.getWidth()*2;
|
||||||
}
|
}
|
||||||
@@ -883,6 +934,7 @@ public class EntityComps{
|
|||||||
interpolator.lastUpdated = 0;
|
interpolator.lastUpdated = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
if(Vars.net.client() && !isLocal()){
|
if(Vars.net.client() && !isLocal()){
|
||||||
interpolate();
|
interpolate();
|
||||||
@@ -938,11 +990,11 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
|
|
||||||
int tileX(){
|
int tileX(){
|
||||||
return Vars.world.toTile(getX());
|
return Vars.world.toTile(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tileY(){
|
int tileY(){
|
||||||
return Vars.world.toTile(getY());
|
return Vars.world.toTile(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns air if this unit is on a non-air top block. */
|
/** Returns air if this unit is on a non-air top block. */
|
||||||
@@ -954,6 +1006,16 @@ public class EntityComps{
|
|||||||
public @Nullable Tile tileOn(){
|
public @Nullable Tile tileOn(){
|
||||||
return world.tileWorld(x, y);
|
return world.tileWorld(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getX(){
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getY(){
|
||||||
|
return y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -966,23 +1028,23 @@ public class EntityComps{
|
|||||||
|
|
||||||
abstract boolean canMine(Item item);
|
abstract boolean canMine(Item item);
|
||||||
|
|
||||||
abstract float getMiningSpeed();
|
abstract float miningSpeed();
|
||||||
|
|
||||||
abstract boolean offloadImmediately();
|
abstract boolean offloadImmediately();
|
||||||
|
|
||||||
boolean isMining(){
|
boolean mining(){
|
||||||
return mineTile != null;
|
return mineTile != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateMining(){
|
void updateMining(){
|
||||||
Tilec core = getClosestCore();
|
Tilec core = closestCore();
|
||||||
|
|
||||||
if(core != null && mineTile != null && mineTile.drop() != null && !acceptsItem(mineTile.drop()) && dst(core) < mineTransferRange){
|
if(core != null && mineTile != null && mineTile.drop() != null && !acceptsItem(mineTile.drop()) && dst(core) < mineTransferRange){
|
||||||
int accepted = core.getTile().block().acceptStack(item(), getStack().amount, core.getTile(), this);
|
int accepted = core.tile().block().acceptStack(item(), stack().amount, core.tile(), this);
|
||||||
if(accepted > 0){
|
if(accepted > 0){
|
||||||
Call.transferItemTo(item(), accepted,
|
Call.transferItemTo(item(), accepted,
|
||||||
mineTile.worldx() + Mathf.range(tilesize / 2f),
|
mineTile.worldx() + Mathf.range(tilesize / 2f),
|
||||||
mineTile.worldy() + Mathf.range(tilesize / 2f), core.getTile());
|
mineTile.worldy() + Mathf.range(tilesize / 2f), core.tile());
|
||||||
clearItem();
|
clearItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -992,14 +1054,14 @@ public class EntityComps{
|
|||||||
mineTile = null;
|
mineTile = null;
|
||||||
}else{
|
}else{
|
||||||
Item item = mineTile.drop();
|
Item item = mineTile.drop();
|
||||||
setRotation(Mathf.slerpDelta(getRotation(), angleTo(mineTile.worldx(), mineTile.worldy()), 0.4f));
|
rotation(Mathf.slerpDelta(rotation(), angleTo(mineTile.worldx(), mineTile.worldy()), 0.4f));
|
||||||
|
|
||||||
if(Mathf.chance(Time.delta() * (0.06 - item.hardness * 0.01) * getMiningSpeed())){
|
if(Mathf.chance(Time.delta() * (0.06 - item.hardness * 0.01) * miningSpeed())){
|
||||||
|
|
||||||
if(dst(core) < mineTransferRange && core.getTile().block().acceptStack(item, 1, core.getTile(), this) == 1 && offloadImmediately()){
|
if(dst(core) < mineTransferRange && core.tile().block().acceptStack(item, 1, core.tile(), this) == 1 && offloadImmediately()){
|
||||||
Call.transferItemTo(item, 1,
|
Call.transferItemTo(item, 1,
|
||||||
mineTile.worldx() + Mathf.range(tilesize / 2f),
|
mineTile.worldx() + Mathf.range(tilesize / 2f),
|
||||||
mineTile.worldy() + Mathf.range(tilesize / 2f), core.getTile());
|
mineTile.worldy() + Mathf.range(tilesize / 2f), core.tile());
|
||||||
}else if(acceptsItem(item)){
|
}else if(acceptsItem(item)){
|
||||||
//this is clientside, since items are synced anyway
|
//this is clientside, since items are synced anyway
|
||||||
ItemTransfer.transferItemToUnit(item,
|
ItemTransfer.transferItemToUnit(item,
|
||||||
@@ -1016,7 +1078,7 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void drawOver(){
|
void drawOver(){
|
||||||
if(!isMining()) return;
|
if(!mining()) return;
|
||||||
float focusLen = 4f + Mathf.absin(Time.time(), 1.1f, 0.5f);
|
float focusLen = 4f + Mathf.absin(Time.time(), 1.1f, 0.5f);
|
||||||
float swingScl = 12f, swingMag = tilesize / 8f;
|
float swingScl = 12f, swingMag = tilesize / 8f;
|
||||||
float flashScl = 0.3f;
|
float flashScl = 0.3f;
|
||||||
@@ -1042,13 +1104,13 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
abstract static class BuilderComp implements mindustry.gen.Unitc{
|
abstract static class BuilderComp implements Unitc{
|
||||||
static final float placeDistance = 220f;
|
static final float placeDistance = 220f;
|
||||||
static final Vec2[] tmptr = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()};
|
static final Vec2[] tmptr = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()};
|
||||||
|
|
||||||
transient float x, y, rotation;
|
transient float x, y, rotation;
|
||||||
|
|
||||||
Queue<BuildRequest> requests = new Queue<>();
|
@ReadOnly Queue<BuildRequest> requests = new Queue<>();
|
||||||
float buildSpeed = 1f;
|
float buildSpeed = 1f;
|
||||||
//boolean building;
|
//boolean building;
|
||||||
|
|
||||||
@@ -1064,7 +1126,7 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Tilec core = getClosestCore();
|
Tilec core = closestCore();
|
||||||
|
|
||||||
//nothing to build.
|
//nothing to build.
|
||||||
if(buildRequest() == null) return;
|
if(buildRequest() == null) return;
|
||||||
@@ -1087,10 +1149,10 @@ public class EntityComps{
|
|||||||
Tile tile = world.tile(current.x, current.y);
|
Tile tile = world.tile(current.x, current.y);
|
||||||
|
|
||||||
if(!(tile.block() instanceof BuildBlock)){
|
if(!(tile.block() instanceof BuildBlock)){
|
||||||
if(!current.initialized && !current.breaking && Build.validPlace(getTeam(), current.x, current.y, current.block, current.rotation)){
|
if(!current.initialized && !current.breaking && Build.validPlace(team(), current.x, current.y, current.block, current.rotation)){
|
||||||
Build.beginPlace(getTeam(), current.x, current.y, current.block, current.rotation);
|
Build.beginPlace(team(), current.x, current.y, current.block, current.rotation);
|
||||||
}else if(!current.initialized && current.breaking && Build.validBreak(getTeam(), current.x, current.y)){
|
}else if(!current.initialized && current.breaking && Build.validBreak(team(), current.x, current.y)){
|
||||||
Build.beginBreak(getTeam(), current.x, current.y);
|
Build.beginBreak(team(), current.x, current.y);
|
||||||
}else{
|
}else{
|
||||||
requests.removeFirst();
|
requests.removeFirst();
|
||||||
return;
|
return;
|
||||||
@@ -1098,7 +1160,7 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(tile.entity instanceof BuildEntity && !current.initialized){
|
if(tile.entity instanceof BuildEntity && !current.initialized){
|
||||||
Core.app.post(() -> Events.fire(new BuildSelectEvent(tile, getTeam(), (Builderc)this, current.breaking)));
|
Core.app.post(() -> Events.fire(new BuildSelectEvent(tile, team(), (Builderc)this, current.breaking)));
|
||||||
current.initialized = true;
|
current.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1136,7 +1198,7 @@ public class EntityComps{
|
|||||||
boolean shouldSkip(BuildRequest request, @Nullable Tilec core){
|
boolean shouldSkip(BuildRequest request, @Nullable Tilec core){
|
||||||
//requests that you have at least *started* are considered
|
//requests that you have at least *started* are considered
|
||||||
if(state.rules.infiniteResources || request.breaking || !request.initialized || core == null) return false;
|
if(state.rules.infiniteResources || request.breaking || !request.initialized || core == null) return false;
|
||||||
return request.stuck && !core.getItems().has(request.block.requirements);
|
return request.stuck && !core.items().has(request.block.requirements);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeBuild(int x, int y, boolean breaking){
|
void removeBuild(int x, int y, boolean breaking){
|
||||||
@@ -1238,12 +1300,12 @@ public class EntityComps{
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
abstract class ItemsComp{
|
abstract class ItemsComp{
|
||||||
ItemStack stack = new ItemStack();
|
@ReadOnly ItemStack stack = new ItemStack();
|
||||||
|
|
||||||
abstract int getItemCapacity();
|
abstract int itemCapacity();
|
||||||
|
|
||||||
void update(){
|
void update(){
|
||||||
stack.amount = Mathf.clamp(stack.amount, 0, getItemCapacity());
|
stack.amount = Mathf.clamp(stack.amount, 0, itemCapacity());
|
||||||
}
|
}
|
||||||
|
|
||||||
Item item(){
|
Item item(){
|
||||||
@@ -1255,7 +1317,7 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean acceptsItem(Item item){
|
boolean acceptsItem(Item item){
|
||||||
return !hasItem() || item == stack.item && stack.amount + 1 <= getItemCapacity();
|
return !hasItem() || item == stack.item && stack.amount + 1 <= itemCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasItem(){
|
boolean hasItem(){
|
||||||
@@ -1275,14 +1337,17 @@ public class EntityComps{
|
|||||||
Object data;
|
Object data;
|
||||||
float rotation = 0f;
|
float rotation = 0f;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
//TODO fix effects, make everything poolable
|
//TODO fix effects, make everything poolable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float clipSize(){
|
public float clipSize(){
|
||||||
return effect.size;
|
return effect.size;
|
||||||
}
|
}
|
||||||
@@ -1295,6 +1360,7 @@ public class EntityComps{
|
|||||||
final Vec2 vel = new Vec2();
|
final Vec2 vel = new Vec2();
|
||||||
float drag = 0f;
|
float drag = 0f;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
//TODO handle solidity
|
//TODO handle solidity
|
||||||
x += vel.x;
|
x += vel.x;
|
||||||
@@ -1310,6 +1376,7 @@ public class EntityComps{
|
|||||||
float hitSize;
|
float hitSize;
|
||||||
float lastX, lastY;
|
float lastX, lastY;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1323,19 +1390,20 @@ public class EntityComps{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float getDeltaX(){
|
float deltaX(){
|
||||||
return x - lastX;
|
return x - lastX;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getDeltaY(){
|
float deltaY(){
|
||||||
return y - lastY;
|
return y - lastY;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean collides(Hitboxc other){
|
boolean collides(Hitboxc other){
|
||||||
return Intersector.overlapsRect(x - hitSize/2f, y - hitSize/2f, hitSize, hitSize,
|
return Intersector.overlapsRect(x - hitSize/2f, y - hitSize/2f, hitSize, hitSize,
|
||||||
other.getX() - other.getHitSize()/2f, other.getY() - other.getHitSize()/2f, other.getHitSize(), other.getHitSize());
|
other.x() - other.hitSize()/2f, other.y() - other.hitSize()/2f, other.hitSize(), other.hitSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void hitbox(Rect rect){
|
public void hitbox(Rect rect){
|
||||||
rect.setCentered(x, y, hitSize, hitSize);
|
rect.setCentered(x, y, hitSize, hitSize);
|
||||||
}
|
}
|
||||||
@@ -1347,16 +1415,16 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
abstract class StatusComp implements Posc{
|
abstract class StatusComp implements Posc, Flyingc{
|
||||||
private Array<StatusEntry> statuses = new Array<>();
|
private Array<StatusEntry> statuses = new Array<>();
|
||||||
private Bits applied = new Bits(content.getBy(ContentType.status).size);
|
private Bits applied = new Bits(content.getBy(ContentType.status).size);
|
||||||
|
|
||||||
float speedMultiplier;
|
@ReadOnly float speedMultiplier;
|
||||||
float damageMultiplier;
|
@ReadOnly float damageMultiplier;
|
||||||
float armorMultiplier;
|
@ReadOnly float armorMultiplier;
|
||||||
|
|
||||||
/** @return damage taken based on status armor multipliers */
|
/** @return damage taken based on status armor multipliers */
|
||||||
float getDamage(float amount){
|
float getShieldDamage(float amount){
|
||||||
return amount * Mathf.clamp(1f - armorMultiplier / 100f);
|
return amount * Mathf.clamp(1f - armorMultiplier / 100f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1396,7 +1464,7 @@ public class EntityComps{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color getStatusColor(){
|
Color statusColor(){
|
||||||
if(statuses.size == 0){
|
if(statuses.size == 0){
|
||||||
return Tmp.c1.set(Color.white);
|
return Tmp.c1.set(Color.white);
|
||||||
}
|
}
|
||||||
@@ -1410,16 +1478,12 @@ public class EntityComps{
|
|||||||
return Tmp.c1.set(r / statuses.size, g / statuses.size, b / statuses.size, 1f);
|
return Tmp.c1.set(r / statuses.size, g / statuses.size, b / statuses.size, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
Floor floor = floorOn();
|
Floor floor = floorOn();
|
||||||
Tile tile = tileOn();
|
if(isGrounded() && floor.status != null){
|
||||||
boolean flying = false;
|
|
||||||
//TODO conditionally apply status effects on floor, if not flying
|
|
||||||
if(!flying && tile != null){
|
|
||||||
//apply effect
|
//apply effect
|
||||||
if(floor.status != null){
|
apply(floor.status, floor.statusDuration);
|
||||||
apply(floor.status, floor.statusDuration);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
applied.clear();
|
applied.clear();
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import arc.util.*;
|
|||||||
import arc.util.pooling.*;
|
import arc.util.pooling.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
@@ -42,11 +41,11 @@ public class ItemTransfer extends TimedEntity implements DrawTrait{
|
|||||||
|
|
||||||
@Remote(called = Loc.server, unreliable = true)
|
@Remote(called = Loc.server, unreliable = true)
|
||||||
public static void transferItemTo(Item item, int amount, float x, float y, Tile tile){
|
public static void transferItemTo(Item item, int amount, float x, float y, Tile tile){
|
||||||
if(tile == null || tile.entity == null || tile.entity.getItems() == null) return;
|
if(tile == null || tile.entity == null || tile.entity.items() == null) return;
|
||||||
for(int i = 0; i < Mathf.clamp(amount / 3, 1, 8); i++){
|
for(int i = 0; i < Mathf.clamp(amount / 3, 1, 8); i++){
|
||||||
Time.run(i * 3, () -> create(item, x, y, tile, () -> {}));
|
Time.run(i * 3, () -> create(item, x, y, tile, () -> {}));
|
||||||
}
|
}
|
||||||
tile.entity.getItems().add(item, amount);
|
tile.entity.items().add(item, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void create(Item item, float fromx, float fromy, Position to, Runnable done){
|
public static void create(Item item, float fromx, float fromy, Position to, Runnable done){
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{
|
|||||||
return playerGroup;
|
return playerGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTeam(Team team){
|
public void team(Team team){
|
||||||
this.team = team;
|
this.team = team;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,7 +406,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{
|
|||||||
control.input.drawBreaking(request);
|
control.input.drawBreaking(request);
|
||||||
}else{
|
}else{
|
||||||
request.block.drawRequest(request, control.input.allRequests(),
|
request.block.drawRequest(request, control.input.allRequests(),
|
||||||
Build.validPlace(getTeam(), request.x, request.y, request.block, request.rotation) || control.input.requestMatches(request));
|
Build.validPlace(team(), request.x, request.y, request.block, request.rotation) || control.input.requestMatches(request));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,14 +439,14 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{
|
|||||||
velocity.set(0f, 0f);
|
velocity.set(0f, 0f);
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
setDead(true);
|
dead(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(netServer.isWaitingForPlayers()){
|
if(netServer.isWaitingForPlayers()){
|
||||||
setDead(true);
|
dead(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isDead() && isOutOfBounds()){
|
if(!dead() && isOutOfBounds()){
|
||||||
destructTime += Time.delta();
|
destructTime += Time.delta();
|
||||||
|
|
||||||
if(destructTime >= boundsCountdown){
|
if(destructTime >= boundsCountdown){
|
||||||
@@ -456,7 +456,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{
|
|||||||
destructTime = 0f;
|
destructTime = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isDead() && isFlying()){
|
if(!dead() && isFlying()){
|
||||||
loops.play(Sounds.thruster, this, Mathf.clamp(velocity.len() * 2f) * 0.3f);
|
loops.play(Sounds.thruster, this, Mathf.clamp(velocity.len() * 2f) * 0.3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,7 +465,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{
|
|||||||
loops.play(Sounds.build, request.tile(), 0.75f);
|
loops.play(Sounds.build, request.tile(), 0.75f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isDead()){
|
if(dead()){
|
||||||
isBoosting = false;
|
isBoosting = false;
|
||||||
boostHeat = 0f;
|
boostHeat = 0f;
|
||||||
if(respawns > 0 || !state.rules.limitedRespawns){
|
if(respawns > 0 || !state.rules.limitedRespawns){
|
||||||
@@ -604,7 +604,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{
|
|||||||
|
|
||||||
protected void updateTouch(){
|
protected void updateTouch(){
|
||||||
if(Units.invalidateTarget(target, this) &&
|
if(Units.invalidateTarget(target, this) &&
|
||||||
!(target instanceof Tilec && ((Tilec)target).damaged() && target.isValid() && target.getTeam() == team && mech.canHeal && dst(target) < mech.range && !(((Tilec)target).block instanceof BuildBlock))){
|
!(target instanceof Tilec && ((Tilec)target).damaged() && target.isValid() && target.team() == team && mech.canHeal && dst(target) < mech.range && !(((Tilec)target).block instanceof BuildBlock))){
|
||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,10 +616,10 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{
|
|||||||
float attractDst = 15f;
|
float attractDst = 15f;
|
||||||
float speed = isBoosting && !mech.flying ? mech.boostSpeed : mech.speed;
|
float speed = isBoosting && !mech.flying ? mech.boostSpeed : mech.speed;
|
||||||
|
|
||||||
if(moveTarget != null && !moveTarget.isDead()){
|
if(moveTarget != null && !moveTarget.dead()){
|
||||||
targetX = moveTarget.getX();
|
targetX = moveTarget.getX();
|
||||||
targetY = moveTarget.getY();
|
targetY = moveTarget.getY();
|
||||||
boolean tapping = moveTarget instanceof Tilec && moveTarget.getTeam() == team;
|
boolean tapping = moveTarget instanceof Tilec && moveTarget.team() == team;
|
||||||
attractDst = 0f;
|
attractDst = 0f;
|
||||||
|
|
||||||
if(tapping){
|
if(tapping){
|
||||||
@@ -627,7 +627,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(dst(moveTarget) <= 2f * Time.delta()){
|
if(dst(moveTarget) <= 2f * Time.delta()){
|
||||||
if(tapping && !isDead()){
|
if(tapping && !dead()){
|
||||||
Tile tile = ((Tilec)moveTarget).tile;
|
Tile tile = ((Tilec)moveTarget).tile;
|
||||||
tile.block().tapped(tile, this);
|
tile.block().tapped(tile, this);
|
||||||
}
|
}
|
||||||
@@ -680,7 +680,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{
|
|||||||
if(target == null){
|
if(target == null){
|
||||||
isShooting = false;
|
isShooting = false;
|
||||||
if(Core.settings.getBool("autotarget")){
|
if(Core.settings.getBool("autotarget")){
|
||||||
target = Units.closestTarget(team, x, y, mech.range, u -> u.getTeam() != Team.derelict, u -> u.getTeam() != Team.derelict);
|
target = Units.closestTarget(team, x, y, mech.range, u -> u.team() != Team.derelict, u -> u.getTeam() != Team.derelict);
|
||||||
|
|
||||||
if(mech.canHeal && target == null){
|
if(mech.canHeal && target == null){
|
||||||
target = Geometry.findClosest(x, y, indexer.getDamaged(Team.sharded));
|
target = Geometry.findClosest(x, y, indexer.getDamaged(Team.sharded));
|
||||||
@@ -695,7 +695,7 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{
|
|||||||
setMineTile(null);
|
setMineTile(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(target.isValid() || (target instanceof Tilec && ((Tilec)target).damaged() && target.getTeam() == team && mech.canHeal && dst(target) < mech.range)){
|
}else if(target.isValid() || (target instanceof Tilec && ((Tilec)target).damaged() && target.team() == team && mech.canHeal && dst(target) < mech.range)){
|
||||||
//rotate toward and shoot the target
|
//rotate toward and shoot the target
|
||||||
if(mech.faceTarget){
|
if(mech.faceTarget){
|
||||||
rotation = Mathf.slerpDelta(rotation, angleTo(target), 0.2f);
|
rotation = Mathf.slerpDelta(rotation, angleTo(target), 0.2f);
|
||||||
@@ -786,19 +786,19 @@ public class Player extends Unitc implements BuilderMinerTrait, ShooterTrait{
|
|||||||
if(state.isEditor()){
|
if(state.isEditor()){
|
||||||
//instant respawn at center of map.
|
//instant respawn at center of map.
|
||||||
set(world.width() * tilesize/2f, world.height() * tilesize/2f);
|
set(world.width() * tilesize/2f, world.height() * tilesize/2f);
|
||||||
setDead(false);
|
dead(false);
|
||||||
}else if(spawner != null && spawner.isValid()){
|
}else if(spawner != null && spawner.isValid()){
|
||||||
spawner.updateSpawning(this);
|
spawner.updateSpawning(this);
|
||||||
}else if(!netServer.isWaitingForPlayers()){
|
}else if(!netServer.isWaitingForPlayers()){
|
||||||
if(!net.client()){
|
if(!net.client()){
|
||||||
if(lastSpawner != null && lastSpawner.isValid()){
|
if(lastSpawner != null && lastSpawner.isValid()){
|
||||||
this.spawner = lastSpawner;
|
this.spawner = lastSpawner;
|
||||||
}else if(getClosestCore() != null){
|
}else if(closestCore() != null){
|
||||||
this.spawner = (SpawnerTrait)getClosestCore();
|
this.spawner = (SpawnerTrait)closestCore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(getClosestCore() != null){
|
}else if(closestCore() != null){
|
||||||
set(getClosestCore().getX(), getClosestCore().getY());
|
set(closestCore().getX(), closestCore().getY());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class BuilderDrone extends BaseDrone implements BuilderTrait{
|
|||||||
}else{ //else, building isn't valid, follow a player
|
}else{ //else, building isn't valid, follow a player
|
||||||
target = null;
|
target = null;
|
||||||
|
|
||||||
if(playerTarget == null || playerTarget.getTeam() != team || !playerTarget.isValid()){
|
if(playerTarget == null || playerTarget.team() != team || !playerTarget.isValid()){
|
||||||
playerTarget = null;
|
playerTarget = null;
|
||||||
|
|
||||||
if(retarget()){
|
if(retarget()){
|
||||||
@@ -77,7 +77,7 @@ public class BuilderDrone extends BaseDrone implements BuilderTrait{
|
|||||||
|
|
||||||
//find player with min amount of drones
|
//find player with min amount of drones
|
||||||
for(Player player : playerGroup.all()){
|
for(Player player : playerGroup.all()){
|
||||||
if(player.getTeam() == team){
|
if(player.team() == team){
|
||||||
int drones = getDrones(player);
|
int drones = getDrones(player);
|
||||||
float dst = dst2(player);
|
float dst = dst2(player);
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ public class BuilderDrone extends BaseDrone implements BuilderTrait{
|
|||||||
|
|
||||||
if(!isBuilding() && timer.get(timerTarget2, 15)){
|
if(!isBuilding() && timer.get(timerTarget2, 15)){
|
||||||
for(Player player : playerGroup.all()){
|
for(Player player : playerGroup.all()){
|
||||||
if(player.getTeam() == team && player.buildRequest() != null){
|
if(player.team() == team && player.buildRequest() != null){
|
||||||
BuildRequest req = player.buildRequest();
|
BuildRequest req = player.buildRequest();
|
||||||
Tile tile = world.tile(req.x, req.y);
|
Tile tile = world.tile(req.x, req.y);
|
||||||
if(tile != null && tile.entity instanceof BuildEntity){
|
if(tile != null && tile.entity instanceof BuildEntity){
|
||||||
|
|||||||
@@ -173,6 +173,6 @@ public class MinerDrone extends BaseDrone implements MinerTrait{
|
|||||||
if(entity == null){
|
if(entity == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
targetItem = Structs.findMin(type.toMine, indexer::hasOre, (a, b) -> -Integer.compare(entity.getItems().get(a), entity.getItems().get(b)));
|
targetItem = Structs.findMin(type.toMine, indexer::hasOre, (a, b) -> -Integer.compare(entity.items().get(a), entity.items().get(b)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class MusicControl{
|
|||||||
|
|
||||||
/** Whether to play dark music.*/
|
/** Whether to play dark music.*/
|
||||||
private boolean isDark(){
|
private boolean isDark(){
|
||||||
if(state.teams.get(player.getTeam()).hasCore() && state.teams.get(player.getTeam()).core().healthf() < 0.85f){
|
if(state.teams.get(player.team()).hasCore() && state.teams.get(player.team()).core().healthf() < 0.85f){
|
||||||
//core damaged -> dark
|
//core damaged -> dark
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import arc.math.geom.*;
|
|||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.world.blocks.storage.CoreBlock.*;
|
import mindustry.world.blocks.storage.CoreBlock.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
@@ -102,7 +101,7 @@ public class Teams{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerCore(CoreEntity core){
|
public void registerCore(CoreEntity core){
|
||||||
TeamData data = get(core.getTeam());
|
TeamData data = get(core.team());
|
||||||
//add core if not present
|
//add core if not present
|
||||||
if(!data.cores.contains(core)){
|
if(!data.cores.contains(core)){
|
||||||
data.cores.add(core);
|
data.cores.add(core);
|
||||||
@@ -117,7 +116,7 @@ public class Teams{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void unregisterCore(CoreEntity entity){
|
public void unregisterCore(CoreEntity entity){
|
||||||
TeamData data = get(entity.getTeam());
|
TeamData data = get(entity.team());
|
||||||
//remove core
|
//remove core
|
||||||
data.cores.remove(entity);
|
data.cores.remove(entity);
|
||||||
//unregister in active list
|
//unregister in active list
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class BlockRenderer implements Disposable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(brokenFade > 0.001f){
|
if(brokenFade > 0.001f){
|
||||||
for(BrokenBlock block : state.teams.get(player.getTeam()).brokenBlocks){
|
for(BrokenBlock block : state.teams.get(player.team()).brokenBlocks){
|
||||||
Block b = content.block(block.block);
|
Block b = content.block(block.block);
|
||||||
if(!camera.bounds(Tmp.r1).grow(tilesize * 2f).overlaps(Tmp.r2.setSize(b.size * tilesize).setCenter(block.x * tilesize + b.offset(), block.y * tilesize + b.offset()))) continue;
|
if(!camera.bounds(Tmp.r1).grow(tilesize * 2f).overlaps(Tmp.r2.setSize(b.size * tilesize).setCenter(block.x * tilesize + b.offset(), block.y * tilesize + b.offset()))) continue;
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ public class BlockRenderer implements Disposable{
|
|||||||
addRequest(tile, block.layer2);
|
addRequest(tile, block.layer2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tile.entity != null && tile.entity.getPower() != null && tile.entity.getPower().links.size > 0){
|
if(tile.entity != null && tile.entity.power() != null && tile.entity.power().links.size > 0){
|
||||||
for(Tile other : block.getPowerConnections(tile, outArray)){
|
for(Tile other : block.getPowerConnections(tile, outArray)){
|
||||||
if(other.block().layer == Layer.power){
|
if(other.block().layer == Layer.power){
|
||||||
addRequest(other, Layer.power);
|
addRequest(other, Layer.power);
|
||||||
@@ -275,7 +275,7 @@ public class BlockRenderer implements Disposable{
|
|||||||
if(request.tile.entity != null && request.tile.entity.damaged()){
|
if(request.tile.entity != null && request.tile.entity.damaged()){
|
||||||
block.drawCracks(request.tile);
|
block.drawCracks(request.tile);
|
||||||
}
|
}
|
||||||
if(block.synthetic() && request.tile.getTeam() != player.getTeam()){
|
if(block.synthetic() && request.tile.getTeam() != player.team()){
|
||||||
block.drawTeam(request.tile);
|
block.drawTeam(request.tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class OverlayRenderer{
|
|||||||
public void drawBottom(){
|
public void drawBottom(){
|
||||||
InputHandler input = control.input;
|
InputHandler input = control.input;
|
||||||
|
|
||||||
if(player.isDead()) return;
|
if(player.dead()) return;
|
||||||
|
|
||||||
input.drawBottom();
|
input.drawBottom();
|
||||||
}
|
}
|
||||||
@@ -37,13 +37,13 @@ public class OverlayRenderer{
|
|||||||
|
|
||||||
if(Core.settings.getBool("indicators")){
|
if(Core.settings.getBool("indicators")){
|
||||||
for(Player player : playerGroup.all()){
|
for(Player player : playerGroup.all()){
|
||||||
if(Vars.player != player && Vars.player.getTeam() == player.getTeam()){
|
if(Vars.player != player && Vars.player.team() == player.team()){
|
||||||
if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f)
|
if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f)
|
||||||
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x, player.y)){
|
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x, player.y)){
|
||||||
|
|
||||||
Tmp.v1.set(player.x, player.y).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
Tmp.v1.set(player.x, player.y).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
||||||
|
|
||||||
Lines.stroke(2f, player.getTeam().color);
|
Lines.stroke(2f, player.team().color);
|
||||||
Lines.lineAngle(Core.camera.position.x + Tmp.v1.x, Core.camera.position.y + Tmp.v1.y, Tmp.v1.angle(), 4f);
|
Lines.lineAngle(Core.camera.position.x + Tmp.v1.x, Core.camera.position.y + Tmp.v1.y, Tmp.v1.angle(), 4f);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
@@ -51,17 +51,17 @@ public class OverlayRenderer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Units.all(unit -> {
|
Units.all(unit -> {
|
||||||
if(unit != player && unit.getTeam() != player.getTeam() && !rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f).setCenter(Core.camera.position.x, Core.camera.position.y).contains(unit.x, unit.y)){
|
if(unit != player && unit.team() != player.team() && !rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f).setCenter(Core.camera.position.x, Core.camera.position.y).contains(unit.x, unit.y)){
|
||||||
Tmp.v1.set(unit.x, unit.y).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
Tmp.v1.set(unit.x, unit.y).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
||||||
|
|
||||||
Lines.stroke(1f, unit.getTeam().color);
|
Lines.stroke(1f, unit.team().color);
|
||||||
Lines.lineAngle(Core.camera.position.x + Tmp.v1.x, Core.camera.position.y + Tmp.v1.y, Tmp.v1.angle(), 3f);
|
Lines.lineAngle(Core.camera.position.x + Tmp.v1.x, Core.camera.position.y + Tmp.v1.y, Tmp.v1.angle(), 3f);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ui.hudfrag.blockfrag.currentCategory == Category.upgrade){
|
if(ui.hudfrag.blockfrag.currentCategory == Category.upgrade){
|
||||||
for(Tile mechpad : indexer.getAllied(player.getTeam(), BlockFlag.mechPad)){
|
for(Tile mechpad : indexer.getAllied(player.team(), BlockFlag.mechPad)){
|
||||||
if(!(mechpad.block() instanceof MechPad)) continue;
|
if(!(mechpad.block() instanceof MechPad)) continue;
|
||||||
if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f)
|
if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f)
|
||||||
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(mechpad.drawx(), mechpad.drawy())){
|
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(mechpad.drawx(), mechpad.drawy())){
|
||||||
@@ -76,7 +76,7 @@ public class OverlayRenderer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.isDead()) return; //dead players don't draw
|
if(player.dead()) return; //dead players don't draw
|
||||||
|
|
||||||
InputHandler input = control.input;
|
InputHandler input = control.input;
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ public class OverlayRenderer{
|
|||||||
Lines.stroke(buildFadeTime * 2f);
|
Lines.stroke(buildFadeTime * 2f);
|
||||||
|
|
||||||
if(buildFadeTime > 0.005f){
|
if(buildFadeTime > 0.005f){
|
||||||
state.teams.eachEnemyCore(player.getTeam(), core -> {
|
state.teams.eachEnemyCore(player.team(), core -> {
|
||||||
float dst = core.dst(player);
|
float dst = core.dst(player);
|
||||||
if(dst < state.rules.enemyCoreBuildRadius * 2.2f){
|
if(dst < state.rules.enemyCoreBuildRadius * 2.2f){
|
||||||
Draw.color(Color.darkGray);
|
Draw.color(Color.darkGray);
|
||||||
@@ -122,10 +122,10 @@ public class OverlayRenderer{
|
|||||||
Vec2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
Vec2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
||||||
Tile tile = world.ltileWorld(vec.x, vec.y);
|
Tile tile = world.ltileWorld(vec.x, vec.y);
|
||||||
|
|
||||||
if(tile != null && tile.block() != Blocks.air && tile.getTeam() == player.getTeam()){
|
if(tile != null && tile.block() != Blocks.air && tile.getTeam() == player.team()){
|
||||||
tile.block().drawSelect(tile);
|
tile.block().drawSelect(tile);
|
||||||
|
|
||||||
if(Core.input.keyDown(Binding.rotateplaced) && tile.block().rotate && tile.interactable(player.getTeam())){
|
if(Core.input.keyDown(Binding.rotateplaced) && tile.block().rotate && tile.interactable(player.team())){
|
||||||
control.input.drawArrow(tile.block(), tile.x, tile.y, tile.rotation(), true);
|
control.input.drawArrow(tile.block(), tile.x, tile.y, tile.rotation(), true);
|
||||||
Draw.color(Pal.accent, 0.3f + Mathf.absin(4f, 0.2f));
|
Draw.color(Pal.accent, 0.3f + Mathf.absin(4f, 0.2f));
|
||||||
Fill.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize/2f);
|
Fill.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize/2f);
|
||||||
@@ -144,7 +144,7 @@ public class OverlayRenderer{
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
|
||||||
Tile tile = world.ltileWorld(v.x, v.y);
|
Tile tile = world.ltileWorld(v.x, v.y);
|
||||||
if(tile != null && tile.interactable(player.getTeam()) && tile.block().acceptStack(player.item().item, player.item().amount, tile, player) > 0){
|
if(tile != null && tile.interactable(player.team()) && tile.block().acceptStack(player.item().item, player.item().amount, tile, player) > 0){
|
||||||
Lines.stroke(3f, Pal.gray);
|
Lines.stroke(3f, Pal.gray);
|
||||||
Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f + 3 + Mathf.absin(Time.time(), 5f, 1f));
|
Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f + 3 + Mathf.absin(Time.time(), 5f, 1f));
|
||||||
Lines.stroke(1f, Pal.place);
|
Lines.stroke(1f, Pal.place);
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
ui.listfrag.toggle();
|
ui.listfrag.toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(((player.getClosestCore() == null && player.isDead()) || state.isPaused()) && !ui.chatfrag.shown()){
|
if(((player.closestCore() == null && player.dead()) || state.isPaused()) && !ui.chatfrag.shown()){
|
||||||
//move camera around
|
//move camera around
|
||||||
float camSpeed = !Core.input.keyDown(Binding.dash) ? 3f : 8f;
|
float camSpeed = !Core.input.keyDown(Binding.dash) ? 3f : 8f;
|
||||||
Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(Time.delta() * camSpeed));
|
Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(Time.delta() * camSpeed));
|
||||||
@@ -162,7 +162,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
renderer.scaleCamera(Core.input.axisTap(Binding.zoom));
|
renderer.scaleCamera(Core.input.axisTap(Binding.zoom));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.isDead()){
|
if(player.dead()){
|
||||||
cursorType = SystemCursor.arrow;
|
cursorType = SystemCursor.arrow;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
cursorType = ui.unloadCursor;
|
cursorType = ui.unloadCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cursor.interactable(player.getTeam()) && !isPlacing() && Math.abs(Core.input.axisTap(Binding.rotate)) > 0 && Core.input.keyDown(Binding.rotateplaced) && cursor.block().rotate){
|
if(cursor.interactable(player.team()) && !isPlacing() && Math.abs(Core.input.axisTap(Binding.rotate)) > 0 && Core.input.keyDown(Binding.rotateplaced) && cursor.block().rotate){
|
||||||
Call.rotateBlock(player, cursor, Core.input.axisTap(Binding.rotate) > 0);
|
Call.rotateBlock(player, cursor, Core.input.axisTap(Binding.rotate) > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
ItemTransfer.create(item,
|
ItemTransfer.create(item,
|
||||||
player.x + Angles.trnsx(player.rotation + 180f, backTrns), player.y + Angles.trnsy(player.rotation + 180f, backTrns),
|
player.x + Angles.trnsx(player.rotation + 180f, backTrns), player.y + Angles.trnsy(player.rotation + 180f, backTrns),
|
||||||
new Vec2(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> {
|
new Vec2(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> {
|
||||||
if(tile.block() != block || tile.entity == null || tile.entity.getItems() == null) return;
|
if(tile.block() != block || tile.entity == null || tile.entity.items() == null) return;
|
||||||
|
|
||||||
tile.block().handleStack(item, removed, tile, player);
|
tile.block().handleStack(item, removed, tile, player);
|
||||||
remaining[1] -= removed;
|
remaining[1] -= removed;
|
||||||
@@ -417,7 +417,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(BrokenBlock req : player.getTeam().data().brokenBlocks){
|
for(BrokenBlock req : player.team().data().brokenBlocks){
|
||||||
Block block = content.block(req.block);
|
Block block = content.block(req.block);
|
||||||
if(block.bounds(req.x, req.y, Tmp.r2).overlaps(Tmp.r1)){
|
if(block.bounds(req.x, req.y, Tmp.r2).overlaps(Tmp.r1)){
|
||||||
drawSelected(req.x, req.y, content.block(req.block), Pal.remove);
|
drawSelected(req.x, req.y, content.block(req.block), Pal.remove);
|
||||||
@@ -525,7 +525,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//remove blocks to rebuild
|
//remove blocks to rebuild
|
||||||
Iterator<BrokenBlock> broken = state.teams.get(player.getTeam()).brokenBlocks.iterator();
|
Iterator<BrokenBlock> broken = state.teams.get(player.team()).brokenBlocks.iterator();
|
||||||
while(broken.hasNext()){
|
while(broken.hasNext()){
|
||||||
BrokenBlock req = broken.next();
|
BrokenBlock req = broken.next();
|
||||||
Block block = content.block(req.block);
|
Block block = content.block(req.block);
|
||||||
@@ -565,7 +565,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
boolean consumed = false, showedInventory = false;
|
boolean consumed = false, showedInventory = false;
|
||||||
|
|
||||||
//check if tapped block is configurable
|
//check if tapped block is configurable
|
||||||
if(tile.block().configurable && tile.interactable(player.getTeam())){
|
if(tile.block().configurable && tile.interactable(player.team())){
|
||||||
consumed = true;
|
consumed = true;
|
||||||
if(((!frag.config.isShown() && tile.block().shouldShowConfigure(tile, player)) //if the config fragment is hidden, show
|
if(((!frag.config.isShown() && tile.block().shouldShowConfigure(tile, player)) //if the config fragment is hidden, show
|
||||||
//alternatively, the current selected block can 'agree' to switch config tiles
|
//alternatively, the current selected block can 'agree' to switch config tiles
|
||||||
@@ -587,15 +587,15 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//call tapped event
|
//call tapped event
|
||||||
if(!consumed && tile.interactable(player.getTeam())){
|
if(!consumed && tile.interactable(player.team())){
|
||||||
Call.onTileTapped(player, tile);
|
Call.onTileTapped(player, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
//consume tap event if necessary
|
//consume tap event if necessary
|
||||||
if(tile.interactable(player.getTeam()) && tile.block().consumesTap){
|
if(tile.interactable(player.team()) && tile.block().consumesTap){
|
||||||
consumed = true;
|
consumed = true;
|
||||||
}else if(tile.interactable(player.getTeam()) && tile.block().synthetic() && !consumed){
|
}else if(tile.interactable(player.team()) && tile.block().synthetic() && !consumed){
|
||||||
if(tile.block().hasItems && tile.entity.getItems().total() > 0){
|
if(tile.block().hasItems && tile.entity.items().total() > 0){
|
||||||
frag.inv.showFor(tile);
|
frag.inv.showFor(tile);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
showedInventory = true;
|
showedInventory = true;
|
||||||
@@ -750,7 +750,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
ItemStack stack = player.item();
|
ItemStack stack = player.item();
|
||||||
|
|
||||||
if(tile.block().acceptStack(stack.item, stack.amount, tile, player) > 0 && tile.interactable(player.getTeam()) && tile.block().hasItems && player.item().amount > 0 && !player.isTransferring && tile.interactable(player.getTeam())){
|
if(tile.block().acceptStack(stack.item, stack.amount, tile, player) > 0 && tile.interactable(player.team()) && tile.block().hasItems && player.item().amount > 0 && !player.isTransferring && tile.interactable(player.team())){
|
||||||
Call.transferInventory(player, tile);
|
Call.transferInventory(player, tile);
|
||||||
}else{
|
}else{
|
||||||
Call.dropItem(player.angleTo(x, y));
|
Call.dropItem(player.angleTo(x, y));
|
||||||
@@ -782,11 +782,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Build.validPlace(player.getTeam(), x, y, type, rotation);
|
return Build.validPlace(player.team(), x, y, type, rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validBreak(int x, int y){
|
public boolean validBreak(int x, int y){
|
||||||
return Build.validBreak(player.getTeam(), x, y);
|
return Build.validBreak(player.team(), x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void placeBlock(int x, int y, Block block, int rotation){
|
public void placeBlock(int x, int y, Block block, int rotation){
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
/** Check and assign targets for a specific position. */
|
/** Check and assign targets for a specific position. */
|
||||||
void checkTargets(float x, float y){
|
void checkTargets(float x, float y){
|
||||||
Unitc unit = Units.closestEnemy(player.getTeam(), x, y, 20f, u -> !u.isDead());
|
Unitc unit = Units.closestEnemy(player.team(), x, y, 20f, u -> !u.dead());
|
||||||
|
|
||||||
if(unit != null){
|
if(unit != null){
|
||||||
player.setMineTile(null);
|
player.setMineTile(null);
|
||||||
@@ -75,11 +75,11 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
}else{
|
}else{
|
||||||
Tile tile = world.ltileWorld(x, y);
|
Tile tile = world.ltileWorld(x, y);
|
||||||
|
|
||||||
if(tile != null && tile.synthetic() && player.getTeam().isEnemy(tile.getTeam())){
|
if(tile != null && tile.synthetic() && player.team().isEnemy(tile.getTeam())){
|
||||||
Tilec entity = tile.entity;
|
Tilec entity = tile.entity;
|
||||||
player.setMineTile(null);
|
player.setMineTile(null);
|
||||||
player.target = entity;
|
player.target = entity;
|
||||||
}else if(tile != null && player.mech.canHeal && tile.entity != null && tile.getTeam() == player.getTeam() && tile.entity.damaged()){
|
}else if(tile != null && player.mech.canHeal && tile.entity != null && tile.getTeam() == player.team() && tile.entity.damaged()){
|
||||||
player.setMineTile(null);
|
player.setMineTile(null);
|
||||||
player.target = tile.entity;
|
player.target = tile.entity;
|
||||||
}
|
}
|
||||||
@@ -441,7 +441,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
down = true;
|
down = true;
|
||||||
|
|
||||||
if(player.isDead()) return false;
|
if(player.dead()) return false;
|
||||||
|
|
||||||
//get tile on cursor
|
//get tile on cursor
|
||||||
Tile cursor = tileAt(screenX, screenY);
|
Tile cursor = tileAt(screenX, screenY);
|
||||||
@@ -518,7 +518,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean longPress(float x, float y){
|
public boolean longPress(float x, float y){
|
||||||
if(state.is(State.menu) || mode == none || player.isDead()) return false;
|
if(state.is(State.menu) || mode == none || player.dead()) return false;
|
||||||
|
|
||||||
//get tile on cursor
|
//get tile on cursor
|
||||||
Tile cursor = tileAt(x, y);
|
Tile cursor = tileAt(x, y);
|
||||||
@@ -583,7 +583,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
mode = none;
|
mode = none;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.isDead()){
|
if(player.dead()){
|
||||||
mode = none;
|
mode = none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public class MapGenerator extends Generator{
|
|||||||
if(tile.block() instanceof StorageBlock && !(tile.block() instanceof CoreBlock) && world.getZone() != null){
|
if(tile.block() instanceof StorageBlock && !(tile.block() instanceof CoreBlock) && world.getZone() != null){
|
||||||
for(Item item : world.getZone().resources){
|
for(Item item : world.getZone().resources){
|
||||||
if(Mathf.chance(0.3)){
|
if(Mathf.chance(0.3)){
|
||||||
tile.entity.getItems().add(item, Math.min(Mathf.random(500), tile.block().itemCapacity));
|
tile.entity.items().add(item, Math.min(Mathf.random(500), tile.block().itemCapacity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class StatusEffect extends MappableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(effect != Fx.none && Mathf.chance(Time.delta() * 0.15f)){
|
if(effect != Fx.none && Mathf.chance(Time.delta() * 0.15f)){
|
||||||
effect.at(unit.getX() + Mathf.range(unit.getBounds() / 2f), unit.getY() + Mathf.range(unit.getBounds() / 2f));
|
effect.at(unit.getX() + Mathf.range(unit.bounds() / 2f), unit.getY() + Mathf.range(unit.bounds() / 2f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import arc.util.ArcAnnotate.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.entities.type.base.*;
|
import mindustry.entities.type.base.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
@@ -106,7 +105,7 @@ public class UnitDef extends UnlockableContent{
|
|||||||
public void drawStats(Unitc player){
|
public void drawStats(Unitc player){
|
||||||
if(drawCell){
|
if(drawCell){
|
||||||
float health = player.healthf();
|
float health = player.healthf();
|
||||||
Draw.color(Color.black, player.getTeam().color, health + Mathf.absin(Time.time(), health * 5f, 1f - health));
|
Draw.color(Color.black, player.team().color, health + Mathf.absin(Time.time(), health * 5f, 1f - health));
|
||||||
Draw.rect(player.getPowerCellRegion(),
|
Draw.rect(player.getPowerCellRegion(),
|
||||||
player.x + Angles.trnsx(player.rotation, cellOffsetY, cellOffsetX),
|
player.x + Angles.trnsx(player.rotation, cellOffsetY, cellOffsetX),
|
||||||
player.y + Angles.trnsy(player.rotation, cellOffsetY, cellOffsetX),
|
player.y + Angles.trnsy(player.rotation, cellOffsetY, cellOffsetX),
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ public class ItemsDisplay extends Table{
|
|||||||
private String format(Item item){
|
private String format(Item item){
|
||||||
builder.setLength(0);
|
builder.setLength(0);
|
||||||
builder.append(ui.formatAmount(data.items().get(item, 0)));
|
builder.append(ui.formatAmount(data.items().get(item, 0)));
|
||||||
if(!state.is(State.menu) && player.getTeam().data().hasCore() && player.getTeam().core().items.get(item) > 0){
|
if(!state.is(State.menu) && player.team().data().hasCore() && player.team().core().items.get(item) > 0){
|
||||||
builder.append(" [unlaunched]+ ");
|
builder.append(" [unlaunched]+ ");
|
||||||
builder.append(ui.formatAmount(state.teams.get(player.getTeam()).core().items.get(item)));
|
builder.append(ui.formatAmount(state.teams.get(player.team()).core().items.get(item)));
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class GameOverDialog extends FloatingDialog{
|
|||||||
public void show(Team winner){
|
public void show(Team winner){
|
||||||
this.winner = winner;
|
this.winner = winner;
|
||||||
show();
|
show();
|
||||||
if(winner == player.getTeam()){
|
if(winner == player.team()){
|
||||||
Events.fire(new WinEvent());
|
Events.fire(new WinEvent());
|
||||||
}else{
|
}else{
|
||||||
Events.fire(new LoseEvent());
|
Events.fire(new LoseEvent());
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
|
|
||||||
@Remote(called = Loc.server, targets = Loc.both, forward = true)
|
@Remote(called = Loc.server, targets = Loc.both, forward = true)
|
||||||
public static void requestItem(Player player, Tile tile, Item item, int amount){
|
public static void requestItem(Player player, Tile tile, Item item, int amount){
|
||||||
if(player == null || tile == null || !tile.interactable(player.getTeam())) return;
|
if(player == null || tile == null || !tile.interactable(player.team())) return;
|
||||||
amount = Mathf.clamp(amount, 0, player.getItemCapacity());
|
amount = Mathf.clamp(amount, 0, player.ttemCapacity());
|
||||||
int fa = amount;
|
int fa = amount;
|
||||||
|
|
||||||
if(net.server() && (!Units.canInteract(player, tile) ||
|
if(net.server() && (!Units.canInteract(player, tile) ||
|
||||||
@@ -71,7 +71,7 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.tile = t;
|
this.tile = t;
|
||||||
if(tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.getItems().total() == 0)
|
if(tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items().total() == 0)
|
||||||
return;
|
return;
|
||||||
rebuild(true);
|
rebuild(true);
|
||||||
}
|
}
|
||||||
@@ -98,14 +98,14 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
table.touchable(Touchable.enabled);
|
table.touchable(Touchable.enabled);
|
||||||
table.update(() -> {
|
table.update(() -> {
|
||||||
|
|
||||||
if(state.is(State.menu) || tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.getItems().total() == 0){
|
if(state.is(State.menu) || tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items().total() == 0){
|
||||||
hide();
|
hide();
|
||||||
}else{
|
}else{
|
||||||
if(holding && lastItem != null){
|
if(holding && lastItem != null){
|
||||||
holdTime += Time.delta();
|
holdTime += Time.delta();
|
||||||
|
|
||||||
if(holdTime >= holdWithdraw){
|
if(holdTime >= holdWithdraw){
|
||||||
int amount = Math.min(tile.entity.getItems().get(lastItem), player.maxAccepted(lastItem));
|
int amount = Math.min(tile.entity.items().get(lastItem), player.maxAccepted(lastItem));
|
||||||
Call.requestItem(player, tile, lastItem, amount);
|
Call.requestItem(player, tile, lastItem, amount);
|
||||||
holding = false;
|
holding = false;
|
||||||
holdTime = 0f;
|
holdTime = 0f;
|
||||||
@@ -117,7 +117,7 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
updateTablePosition();
|
updateTablePosition();
|
||||||
if(tile.block().hasItems){
|
if(tile.block().hasItems){
|
||||||
for(int i = 0; i < content.items().size; i++){
|
for(int i = 0; i < content.items().size; i++){
|
||||||
boolean has = tile.entity.getItems().has(content.item(i));
|
boolean has = tile.entity.items().has(content.item(i));
|
||||||
if(has != container.contains(i)){
|
if(has != container.contains(i)){
|
||||||
rebuild(false);
|
rebuild(false);
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
|
|
||||||
for(int i = 0; i < content.items().size; i++){
|
for(int i = 0; i < content.items().size; i++){
|
||||||
Item item = content.item(i);
|
Item item = content.item(i);
|
||||||
if(!tile.entity.getItems().has(item)) continue;
|
if(!tile.entity.items().has(item)) continue;
|
||||||
|
|
||||||
container.add(i);
|
container.add(i);
|
||||||
|
|
||||||
@@ -149,14 +149,14 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
if(tile == null || tile.entity == null){
|
if(tile == null || tile.entity == null){
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return round(tile.entity.getItems().get(item));
|
return round(tile.entity.items().get(item));
|
||||||
});
|
});
|
||||||
image.addListener(l);
|
image.addListener(l);
|
||||||
|
|
||||||
image.addListener(new InputListener(){
|
image.addListener(new InputListener(){
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||||
if(!canPick.get() || tile == null || tile.entity == null || tile.entity.getItems() == null || !tile.entity.getItems().has(item)) return false;
|
if(!canPick.get() || tile == null || tile.entity == null || tile.entity.items() == null || !tile.entity.items().has(item)) return false;
|
||||||
int amount = Math.min(1, player.maxAccepted(item));
|
int amount = Math.min(1, player.maxAccepted(item));
|
||||||
if(amount > 0){
|
if(amount > 0){
|
||||||
Call.requestItem(player, tile, item, amount);
|
Call.requestItem(player, tile, item, amount);
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import mindustry.gen.*;
|
|||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.input.*;
|
import mindustry.input.*;
|
||||||
import mindustry.net.Packets.*;
|
import mindustry.net.Packets.*;
|
||||||
import mindustry.type.*;
|
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.ui.Cicon;
|
import mindustry.ui.Cicon;
|
||||||
import mindustry.ui.dialogs.*;
|
import mindustry.ui.dialogs.*;
|
||||||
@@ -173,7 +172,7 @@ public class HudFragment extends Fragment{
|
|||||||
.size(50f).margin(6f).get();
|
.size(50f).margin(6f).get();
|
||||||
button.getImageCell().grow();
|
button.getImageCell().grow();
|
||||||
button.getStyle().imageUpColor = team.color;
|
button.getStyle().imageUpColor = team.color;
|
||||||
button.update(() -> button.setChecked(player.getTeam() == team));
|
button.update(() -> button.setChecked(player.team() == team));
|
||||||
|
|
||||||
if(++i % 3 == 0){
|
if(++i % 3 == 0){
|
||||||
teams.row();
|
teams.row();
|
||||||
@@ -287,7 +286,7 @@ public class HudFragment extends Fragment{
|
|||||||
});
|
});
|
||||||
|
|
||||||
t.top().visible(() -> {
|
t.top().visible(() -> {
|
||||||
if(state.is(State.menu) || !state.teams.get(player.getTeam()).hasCore()){
|
if(state.is(State.menu) || !state.teams.get(player.team()).hasCore()){
|
||||||
coreAttackTime[0] = 0f;
|
coreAttackTime[0] = 0f;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -347,14 +346,14 @@ public class HudFragment extends Fragment{
|
|||||||
@Remote(targets = Loc.both, forward = true, called = Loc.both)
|
@Remote(targets = Loc.both, forward = true, called = Loc.both)
|
||||||
public static void setPlayerTeamEditor(Player player, Team team){
|
public static void setPlayerTeamEditor(Player player, Team team){
|
||||||
if(state.isEditor() && player != null){
|
if(state.isEditor() && player != null){
|
||||||
player.setTeam(team);
|
player.team(team);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.both, called = Loc.server)
|
@Remote(targets = Loc.both, called = Loc.server)
|
||||||
public static void spawnUnitEditor(Player player, UnitType type){
|
public static void spawnUnitEditor(Player player, UnitType type){
|
||||||
if(state.isEditor()){
|
if(state.isEditor()){
|
||||||
BaseUnit unit = type.create(player.getTeam());
|
BaseUnit unit = type.create(player.team());
|
||||||
unit.set(player.x, player.y);
|
unit.set(player.x, player.y);
|
||||||
unit.rotation = player.rotation;
|
unit.rotation = player.rotation;
|
||||||
unit.add();
|
unit.add();
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import mindustry.content.*;
|
|||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.input.*;
|
import mindustry.input.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
@@ -220,8 +219,8 @@ public class PlacementFragment extends Fragment{
|
|||||||
button.resizeImage(Cicon.medium.size);
|
button.resizeImage(Cicon.medium.size);
|
||||||
|
|
||||||
button.update(() -> { //color unplacable things gray
|
button.update(() -> { //color unplacable things gray
|
||||||
Tilec core = player.getClosestCore();
|
Tilec core = player.closestCore();
|
||||||
Color color = state.rules.infiniteResources || (core != null && (core.getItems().has(block.requirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources)) ? Color.white : Color.gray;
|
Color color = state.rules.infiniteResources || (core != null && (core.items().has(block.requirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources)) ? Color.white : Color.gray;
|
||||||
button.forEach(elem -> elem.setColor(color));
|
button.forEach(elem -> elem.setColor(color));
|
||||||
button.setChecked(control.input.block == block);
|
button.setChecked(control.input.block == block);
|
||||||
|
|
||||||
@@ -308,10 +307,10 @@ public class PlacementFragment extends Fragment{
|
|||||||
line.addImage(stack.item.icon(Cicon.small)).size(8 * 2);
|
line.addImage(stack.item.icon(Cicon.small)).size(8 * 2);
|
||||||
line.add(stack.item.localizedName).maxWidth(140f).fillX().color(Color.lightGray).padLeft(2).left().get().setEllipsis(true);
|
line.add(stack.item.localizedName).maxWidth(140f).fillX().color(Color.lightGray).padLeft(2).left().get().setEllipsis(true);
|
||||||
line.labelWrap(() -> {
|
line.labelWrap(() -> {
|
||||||
Tilec core = player.getClosestCore();
|
Tilec core = player.closestCore();
|
||||||
if(core == null || state.rules.infiniteResources) return "*/*";
|
if(core == null || state.rules.infiniteResources) return "*/*";
|
||||||
|
|
||||||
int amount = core.getItems().get(stack.item);
|
int amount = core.items().get(stack.item);
|
||||||
int stackamount = Math.round(stack.amount * state.rules.buildCostMultiplier);
|
int stackamount = Math.round(stack.amount * state.rules.buildCostMultiplier);
|
||||||
String color = (amount < stackamount / 2f ? "[red]" : amount < stackamount ? "[accent]" : "[white]");
|
String color = (amount < stackamount / 2f ? "[red]" : amount < stackamount ? "[accent]" : "[white]");
|
||||||
|
|
||||||
@@ -338,7 +337,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
t.add(new Image(lastDisplay.getDisplayIcon(hoverTile))).size(8 * 4);
|
t.add(new Image(lastDisplay.getDisplayIcon(hoverTile))).size(8 * 4);
|
||||||
t.labelWrap(lastDisplay.getDisplayName(hoverTile)).left().width(190f).padLeft(5);
|
t.labelWrap(lastDisplay.getDisplayName(hoverTile)).left().width(190f).padLeft(5);
|
||||||
}).growX().left();
|
}).growX().left();
|
||||||
if(hoverTile.getTeam() == player.getTeam()){
|
if(hoverTile.getTeam() == player.team()){
|
||||||
topTable.row();
|
topTable.row();
|
||||||
topTable.table(t -> {
|
topTable.table(t -> {
|
||||||
t.left().defaults().left();
|
t.left().defaults().left();
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class PlayerListFragment extends Fragment{
|
|||||||
|
|
||||||
float h = 74f;
|
float h = 74f;
|
||||||
|
|
||||||
playerGroup.all().sort(Structs.comparing(Unitc::getTeam));
|
playerGroup.all().sort(Structs.comparing(Unitc::team));
|
||||||
playerGroup.all().each(user -> {
|
playerGroup.all().each(user -> {
|
||||||
NetConnection connection = user.con;
|
NetConnection connection = user.con;
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ public class PlayerListFragment extends Fragment{
|
|||||||
t.addImageButton(Icon.zoom, Styles.clearPartiali, () -> Call.onAdminRequest(user, AdminAction.trace));
|
t.addImageButton(Icon.zoom, Styles.clearPartiali, () -> Call.onAdminRequest(user, AdminAction.trace));
|
||||||
|
|
||||||
}).padRight(12).size(bs + 10f, bs);
|
}).padRight(12).size(bs + 10f, bs);
|
||||||
}else if(!user.isLocal && !user.isAdmin && net.client() && playerGroup.size() >= 3 && player.getTeam() == user.getTeam()){ //votekick
|
}else if(!user.isLocal && !user.isAdmin && net.client() && playerGroup.size() >= 3 && player.team() == user.getTeam()){ //votekick
|
||||||
button.add().growY();
|
button.add().growY();
|
||||||
|
|
||||||
button.addImageButton(Icon.hammer, Styles.clearPartiali,
|
button.addImageButton(Icon.hammer, Styles.clearPartiali,
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ public class Block extends BlockStorage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onProximityRemoved(Tile tile){
|
public void onProximityRemoved(Tile tile){
|
||||||
if(tile.entity.getPower() != null){
|
if(tile.entity.power() != null){
|
||||||
tile.block().powerGraphRemoved(tile);
|
tile.block().powerGraphRemoved(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,41 +189,41 @@ public class Block extends BlockStorage{
|
|||||||
Tilec entity = tile.ent();
|
Tilec entity = tile.ent();
|
||||||
|
|
||||||
for(Tile other : getPowerConnections(tile, tempTiles)){
|
for(Tile other : getPowerConnections(tile, tempTiles)){
|
||||||
if(other.entity.getPower() != null){
|
if(other.entity.power() != null){
|
||||||
other.entity.getPower().graph.add(entity.getPower().graph);
|
other.entity.power().graph.add(entity.power().graph);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void powerGraphRemoved(Tile tile){
|
protected void powerGraphRemoved(Tile tile){
|
||||||
if(tile.entity == null || tile.entity.getPower() == null){
|
if(tile.entity == null || tile.entity.power() == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tile.entity.getPower().graph.remove(tile);
|
tile.entity.power().graph.remove(tile);
|
||||||
for(int i = 0; i < tile.entity.getPower().links.size; i++){
|
for(int i = 0; i < tile.entity.power().links.size; i++){
|
||||||
Tile other = world.tile(tile.entity.getPower().links.get(i));
|
Tile other = world.tile(tile.entity.power().links.get(i));
|
||||||
if(other != null && other.entity != null && other.entity.getPower() != null){
|
if(other != null && other.entity != null && other.entity.power() != null){
|
||||||
other.entity.getPower().links.removeValue(tile.pos());
|
other.entity.power().links.removeValue(tile.pos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Array<Tile> getPowerConnections(Tile tile, Array<Tile> out){
|
public Array<Tile> getPowerConnections(Tile tile, Array<Tile> out){
|
||||||
out.clear();
|
out.clear();
|
||||||
if(tile == null || tile.entity == null || tile.entity.getPower() == null) return out;
|
if(tile == null || tile.entity == null || tile.entity.power() == null) return out;
|
||||||
|
|
||||||
for(Tile other : tile.entity.proximity()){
|
for(Tile other : tile.entity.proximity()){
|
||||||
if(other != null && other.entity != null && other.entity.getPower() != null
|
if(other != null && other.entity != null && other.entity.power() != null
|
||||||
&& !(consumesPower && other.block().consumesPower && !outputsPower && !other.block().outputsPower)
|
&& !(consumesPower && other.block().consumesPower && !outputsPower && !other.block().outputsPower)
|
||||||
&& !tile.entity.getPower().links.contains(other.pos())){
|
&& !tile.entity.power().links.contains(other.pos())){
|
||||||
out.add(other);
|
out.add(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < tile.entity.getPower().links.size; i++){
|
for(int i = 0; i < tile.entity.power().links.size; i++){
|
||||||
Tile link = world.tile(tile.entity.getPower().links.get(i));
|
Tile link = world.tile(tile.entity.power().links.get(i));
|
||||||
if(link != null && link.entity != null && link.entity.getPower() != null) out.add(link);
|
if(link != null && link.entity != null && link.entity.power() != null) out.add(link);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -300,8 +300,8 @@ public class Block extends BlockStorage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void drawLight(Tile tile){
|
public void drawLight(Tile tile){
|
||||||
if(tile.entity != null && hasLiquids && drawLiquidLight && tile.entity.getLiquids().current().lightColor.a > 0.001f){
|
if(tile.entity != null && hasLiquids && drawLiquidLight && tile.entity.liquids().current().lightColor.a > 0.001f){
|
||||||
drawLiquidLight(tile, tile.entity.getLiquids().current(), tile.entity.getLiquids().smoothAmount());
|
drawLiquidLight(tile, tile.entity.liquids().current(), tile.entity.liquids().smoothAmount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,14 +339,14 @@ public class Block extends BlockStorage{
|
|||||||
Geometry.circle(tile.x, tile.y, range, (x, y) -> {
|
Geometry.circle(tile.x, tile.y, range, (x, y) -> {
|
||||||
Tile other = world.ltile(x, y);
|
Tile other = world.ltile(x, y);
|
||||||
if(other != null && other.block instanceof PowerNode && ((PowerNode)other.block).linkValid(other, tile) && !PowerNode.insulated(other, tile) && !other.entity.proximity().contains(tile) &&
|
if(other != null && other.block instanceof PowerNode && ((PowerNode)other.block).linkValid(other, tile) && !PowerNode.insulated(other, tile) && !other.entity.proximity().contains(tile) &&
|
||||||
!(outputsPower && tile.entity.proximity().contains(p -> p.entity != null && p.entity.getPower() != null && p.entity.getPower().graph == other.entity.getPower().graph))){
|
!(outputsPower && tile.entity.proximity().contains(p -> p.entity != null && p.entity.power() != null && p.entity.power().graph == other.entity.power().graph))){
|
||||||
tempTiles.add(other);
|
tempTiles.add(other);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tempTiles.sort(Structs.comparingFloat(t -> t.dst2(tile)));
|
tempTiles.sort(Structs.comparingFloat(t -> t.dst2(tile)));
|
||||||
if(!tempTiles.isEmpty()){
|
if(!tempTiles.isEmpty()){
|
||||||
Tile toLink = tempTiles.first();
|
Tile toLink = tempTiles.first();
|
||||||
if(!toLink.entity.getPower().links.contains(tile.pos())){
|
if(!toLink.entity.power().links.contains(tile.pos())){
|
||||||
toLink.configureAny(tile.pos());
|
toLink.configureAny(tile.pos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -372,7 +372,7 @@ public class Block extends BlockStorage{
|
|||||||
/** Call when some content is produced. This unlocks the content if it is applicable. */
|
/** Call when some content is produced. This unlocks the content if it is applicable. */
|
||||||
public void useContent(Tile tile, UnlockableContent content){
|
public void useContent(Tile tile, UnlockableContent content){
|
||||||
//only unlocks content in zones
|
//only unlocks content in zones
|
||||||
if(!headless && tile.getTeam() == player.getTeam() && world.isZone()){
|
if(!headless && tile.getTeam() == player.team() && world.isZone()){
|
||||||
logic.handleContent(content);
|
logic.handleContent(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -547,10 +547,10 @@ public class Block extends BlockStorage{
|
|||||||
Liquid liquid = consumes.<ConsumeLiquid>get(ConsumeType.liquid).liquid;
|
Liquid liquid = consumes.<ConsumeLiquid>get(ConsumeType.liquid).liquid;
|
||||||
current = entity -> liquid;
|
current = entity -> liquid;
|
||||||
}else{
|
}else{
|
||||||
current = entity -> entity.getLiquids().current();
|
current = entity -> entity.liquids().current();
|
||||||
}
|
}
|
||||||
bars.add("liquid", entity -> new Bar(() -> entity.getLiquids().get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName,
|
bars.add("liquid", entity -> new Bar(() -> entity.liquids().get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName,
|
||||||
() -> current.get(entity).barColor(), () -> entity.getLiquids().get(current.get(entity)) / liquidCapacity));
|
() -> current.get(entity).barColor(), () -> entity.liquids().get(current.get(entity)) / liquidCapacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasPower && consumes.hasPower()){
|
if(hasPower && consumes.hasPower()){
|
||||||
@@ -558,12 +558,12 @@ public class Block extends BlockStorage{
|
|||||||
boolean buffered = cons.buffered;
|
boolean buffered = cons.buffered;
|
||||||
float capacity = cons.capacity;
|
float capacity = cons.capacity;
|
||||||
|
|
||||||
bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.getPower().status * capacity) ? "<ERROR>" : (int)(entity.getPower().status * capacity)) :
|
bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.power().status * capacity) ? "<ERROR>" : (int)(entity.power().status * capacity)) :
|
||||||
Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> Mathf.zero(cons.requestedPower(entity)) && entity.getPower().graph.getPowerProduced() + entity.getPower().graph.getBatteryStored() > 0f ? 1f : entity.getPower().status));
|
Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> Mathf.zero(cons.requestedPower(entity)) && entity.power().graph.getPowerProduced() + entity.power().graph.getBatteryStored() > 0f ? 1f : entity.power().status));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasItems && configurable){
|
if(hasItems && configurable){
|
||||||
bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.getItems().total()), () -> Pal.items, () -> (float)entity.getItems().total() / itemCapacity));
|
bars.add("items", entity -> new Bar(() -> Core.bundle.format("bar.items", entity.items().total()), () -> Pal.items, () -> (float)entity.items().total() / itemCapacity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -608,24 +608,24 @@ public class Block extends BlockStorage{
|
|||||||
|
|
||||||
if(hasItems){
|
if(hasItems){
|
||||||
for(Item item : content.items()){
|
for(Item item : content.items()){
|
||||||
int amount = tile.entity.getItems().get(item);
|
int amount = tile.entity.items().get(item);
|
||||||
explosiveness += item.explosiveness * amount;
|
explosiveness += item.explosiveness * amount;
|
||||||
flammability += item.flammability * amount;
|
flammability += item.flammability * amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasLiquids){
|
if(hasLiquids){
|
||||||
flammability += tile.entity.getLiquids().sum((liquid, amount) -> liquid.explosiveness * amount / 2f);
|
flammability += tile.entity.liquids().sum((liquid, amount) -> liquid.explosiveness * amount / 2f);
|
||||||
explosiveness += tile.entity.getLiquids().sum((liquid, amount) -> liquid.flammability * amount / 2f);
|
explosiveness += tile.entity.liquids().sum((liquid, amount) -> liquid.flammability * amount / 2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(consumes.hasPower() && consumes.getPower().buffered){
|
if(consumes.hasPower() && consumes.getPower().buffered){
|
||||||
power += tile.entity.getPower().status * consumes.getPower().capacity;
|
power += tile.entity.power().status * consumes.getPower().capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasLiquids){
|
if(hasLiquids){
|
||||||
|
|
||||||
tile.entity.getLiquids().each((liquid, amount) -> {
|
tile.entity.liquids().each((liquid, amount) -> {
|
||||||
float splash = Mathf.clamp(amount / 4f, 0f, 10f);
|
float splash = Mathf.clamp(amount / 4f, 0f, 10f);
|
||||||
|
|
||||||
for(int i = 0; i < Mathf.clamp(amount / 5, 0, 30); i++){
|
for(int i = 0; i < Mathf.clamp(amount / 5, 0, 30); i++){
|
||||||
@@ -656,10 +656,10 @@ public class Block extends BlockStorage{
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
}else{
|
||||||
float result = tile.entity.getItems().sum((item, amount) -> item.flammability * amount);
|
float result = tile.entity.items().sum((item, amount) -> item.flammability * amount);
|
||||||
|
|
||||||
if(hasLiquids){
|
if(hasLiquids){
|
||||||
result += tile.entity.getLiquids().sum((liquid, amount) -> liquid.flammability * amount / 3f);
|
result += tile.entity.liquids().sum((liquid, amount) -> liquid.flammability * amount / 3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import mindustry.content.*;
|
|||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.effect.*;
|
import mindustry.entities.effect.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
@@ -49,8 +48,8 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
|
|
||||||
/** Returns the amount of items this block can accept. */
|
/** Returns the amount of items this block can accept. */
|
||||||
public int acceptStack(Item item, int amount, Tile tile, Teamc source){
|
public int acceptStack(Item item, int amount, Tile tile, Teamc source){
|
||||||
if(acceptItem(item, tile, tile) && hasItems && (source == null || source.getTeam() == tile.getTeam())){
|
if(acceptItem(item, tile, tile) && hasItems && (source == null || source.team() == tile.getTeam())){
|
||||||
return Math.min(getMaximumAccepted(tile, item) - tile.entity.getItems().get(item), amount);
|
return Math.min(getMaximumAccepted(tile, item) - tile.entity.items().get(item), amount);
|
||||||
}else{
|
}else{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -62,17 +61,17 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
|
|
||||||
/** Remove a stack from this inventory, and return the amount removed. */
|
/** Remove a stack from this inventory, and return the amount removed. */
|
||||||
public int removeStack(Tile tile, Item item, int amount){
|
public int removeStack(Tile tile, Item item, int amount){
|
||||||
if(tile.entity == null || tile.entity.getItems() == null) return 0;
|
if(tile.entity == null || tile.entity.items() == null) return 0;
|
||||||
amount = Math.min(amount, tile.entity.getItems().get(item));
|
amount = Math.min(amount, tile.entity.items().get(item));
|
||||||
tile.entity.noSleep();
|
tile.entity.noSleep();
|
||||||
tile.entity.getItems().remove(item, amount);
|
tile.entity.items().remove(item, amount);
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle a stack input. */
|
/** Handle a stack input. */
|
||||||
public void handleStack(Item item, int amount, Tile tile, Teamc source){
|
public void handleStack(Item item, int amount, Tile tile, Teamc source){
|
||||||
tile.entity.noSleep();
|
tile.entity.noSleep();
|
||||||
tile.entity.getItems().add(item, amount);
|
tile.entity.items().add(item, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean outputsItems(){
|
public boolean outputsItems(){
|
||||||
@@ -89,19 +88,19 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleItem(Item item, Tile tile, Tile source){
|
public void handleItem(Item item, Tile tile, Tile source){
|
||||||
tile.entity.getItems().add(item, 1);
|
tile.entity.items().add(item, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||||
return consumes.itemFilters.get(item.id) && tile.entity.getItems().get(item) < getMaximumAccepted(tile, item);
|
return consumes.itemFilters.get(item.id) && tile.entity.items().get(item) < getMaximumAccepted(tile, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||||
return hasLiquids && tile.entity.getLiquids().get(liquid) + amount < liquidCapacity && consumes.liquidfilters.get(liquid.id);
|
return hasLiquids && tile.entity.liquids().get(liquid) + amount < liquidCapacity && consumes.liquidfilters.get(liquid.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||||
tile.entity.getLiquids().add(liquid, amount);
|
tile.entity.liquids().add(liquid, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tryDumpLiquid(Tile tile, Liquid liquid){
|
public void tryDumpLiquid(Tile tile, Liquid liquid){
|
||||||
@@ -115,9 +114,9 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
|
|
||||||
other = other.block().getLiquidDestination(other, in, liquid);
|
other = other.block().getLiquidDestination(other, in, liquid);
|
||||||
|
|
||||||
if(other != null && other.getTeam() == tile.getTeam() && other.block().hasLiquids && canDumpLiquid(tile, other, liquid) && other.entity.getLiquids() != null){
|
if(other != null && other.getTeam() == tile.getTeam() && other.block().hasLiquids && canDumpLiquid(tile, other, liquid) && other.entity.liquids() != null){
|
||||||
float ofract = other.entity.getLiquids().get(liquid) / other.block().liquidCapacity;
|
float ofract = other.entity.liquids().get(liquid) / other.block().liquidCapacity;
|
||||||
float fract = tile.entity.getLiquids().get(liquid) / liquidCapacity;
|
float fract = tile.entity.liquids().get(liquid) / liquidCapacity;
|
||||||
|
|
||||||
if(ofract < fract) tryMoveLiquid(tile, in, other, (fract - ofract) * liquidCapacity / 2f, liquid);
|
if(ofract < fract) tryMoveLiquid(tile, in, other, (fract - ofract) * liquidCapacity / 2f, liquid);
|
||||||
}
|
}
|
||||||
@@ -130,11 +129,11 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void tryMoveLiquid(Tile tile, Tile tileSource, Tile next, float amount, Liquid liquid){
|
public void tryMoveLiquid(Tile tile, Tile tileSource, Tile next, float amount, Liquid liquid){
|
||||||
float flow = Math.min(next.block().liquidCapacity - next.entity.getLiquids().get(liquid) - 0.001f, amount);
|
float flow = Math.min(next.block().liquidCapacity - next.entity.liquids().get(liquid) - 0.001f, amount);
|
||||||
|
|
||||||
if(next.block().acceptLiquid(next, tileSource, liquid, flow)){
|
if(next.block().acceptLiquid(next, tileSource, liquid, flow)){
|
||||||
next.block().handleLiquid(next, tileSource, liquid, flow);
|
next.block().handleLiquid(next, tileSource, liquid, flow);
|
||||||
tile.entity.getLiquids().remove(liquid, flow);
|
tile.entity.liquids().remove(liquid, flow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,20 +147,20 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
next = next.link();
|
next = next.link();
|
||||||
next = next.block().getLiquidDestination(next, tile, liquid);
|
next = next.block().getLiquidDestination(next, tile, liquid);
|
||||||
|
|
||||||
if(next.getTeam() == tile.getTeam() && next.block().hasLiquids && tile.entity.getLiquids().get(liquid) > 0f){
|
if(next.getTeam() == tile.getTeam() && next.block().hasLiquids && tile.entity.liquids().get(liquid) > 0f){
|
||||||
|
|
||||||
if(next.block().acceptLiquid(next, tile, liquid, 0f)){
|
if(next.block().acceptLiquid(next, tile, liquid, 0f)){
|
||||||
float ofract = next.entity.getLiquids().get(liquid) / next.block().liquidCapacity;
|
float ofract = next.entity.liquids().get(liquid) / next.block().liquidCapacity;
|
||||||
float fract = tile.entity.getLiquids().get(liquid) / liquidCapacity * liquidPressure;
|
float fract = tile.entity.liquids().get(liquid) / liquidCapacity * liquidPressure;
|
||||||
float flow = Math.min(Mathf.clamp((fract - ofract) * (1f)) * (liquidCapacity), tile.entity.getLiquids().get(liquid));
|
float flow = Math.min(Mathf.clamp((fract - ofract) * (1f)) * (liquidCapacity), tile.entity.liquids().get(liquid));
|
||||||
flow = Math.min(flow, next.block().liquidCapacity - next.entity.getLiquids().get(liquid) - 0.001f);
|
flow = Math.min(flow, next.block().liquidCapacity - next.entity.liquids().get(liquid) - 0.001f);
|
||||||
|
|
||||||
if(flow > 0f && ofract <= fract && next.block().acceptLiquid(next, tile, liquid, flow)){
|
if(flow > 0f && ofract <= fract && next.block().acceptLiquid(next, tile, liquid, flow)){
|
||||||
next.block().handleLiquid(next, tile, liquid, flow);
|
next.block().handleLiquid(next, tile, liquid, flow);
|
||||||
tile.entity.getLiquids().remove(liquid, flow);
|
tile.entity.liquids().remove(liquid, flow);
|
||||||
return flow;
|
return flow;
|
||||||
}else if(ofract > 0.1f && fract > 0.1f){
|
}else if(ofract > 0.1f && fract > 0.1f){
|
||||||
Liquid other = next.entity.getLiquids().current();
|
Liquid other = next.entity.liquids().current();
|
||||||
if((other.flammability > 0.3f && liquid.temperature > 0.7f) || (liquid.flammability > 0.3f && other.temperature > 0.7f)){
|
if((other.flammability > 0.3f && liquid.temperature > 0.7f) || (liquid.flammability > 0.3f && other.temperature > 0.7f)){
|
||||||
tile.entity.damage(1 * Time.delta());
|
tile.entity.damage(1 * Time.delta());
|
||||||
next.entity.damage(1 * Time.delta());
|
next.entity.damage(1 * Time.delta());
|
||||||
@@ -169,7 +168,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
Fx.fire.at((tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f);
|
Fx.fire.at((tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f);
|
||||||
}
|
}
|
||||||
}else if((liquid.temperature > 0.7f && other.temperature < 0.55f) || (other.temperature > 0.7f && liquid.temperature < 0.55f)){
|
}else if((liquid.temperature > 0.7f && other.temperature < 0.55f) || (other.temperature > 0.7f && liquid.temperature < 0.55f)){
|
||||||
tile.entity.getLiquids().remove(liquid, Math.min(tile.entity.getLiquids().get(liquid), 0.7f * Time.delta()));
|
tile.entity.liquids().remove(liquid, Math.min(tile.entity.liquids().get(liquid), 0.7f * Time.delta()));
|
||||||
if(Mathf.chance(0.2f * Time.delta())){
|
if(Mathf.chance(0.2f * Time.delta())){
|
||||||
Fx.steam.at((tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f);
|
Fx.steam.at((tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f);
|
||||||
}
|
}
|
||||||
@@ -177,9 +176,9 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(leakResistance != 100f && !next.block().solid && !next.block().hasLiquids){
|
}else if(leakResistance != 100f && !next.block().solid && !next.block().hasLiquids){
|
||||||
float leakAmount = tile.entity.getLiquids().get(liquid) / leakResistance;
|
float leakAmount = tile.entity.liquids().get(liquid) / leakResistance;
|
||||||
Puddle.deposit(next, tile, liquid, leakAmount);
|
Puddle.deposit(next, tile, liquid, leakAmount);
|
||||||
tile.entity.getLiquids().remove(liquid, leakAmount);
|
tile.entity.liquids().remove(liquid, leakAmount);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -220,7 +219,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
*/
|
*/
|
||||||
public boolean tryDump(Tile tile, Item todump){
|
public boolean tryDump(Tile tile, Item todump){
|
||||||
Tilec entity = tile.entity;
|
Tilec entity = tile.entity;
|
||||||
if(entity == null || !hasItems || tile.entity.getItems().total() == 0 || (todump != null && !entity.getItems().has(todump)))
|
if(entity == null || !hasItems || tile.entity.items().total() == 0 || (todump != null && !entity.items().has(todump)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Array<Tile> proximity = entity.proximity();
|
Array<Tile> proximity = entity.proximity();
|
||||||
@@ -237,9 +236,9 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
for(int ii = 0; ii < Vars.content.items().size; ii++){
|
for(int ii = 0; ii < Vars.content.items().size; ii++){
|
||||||
Item item = Vars.content.item(ii);
|
Item item = Vars.content.item(ii);
|
||||||
|
|
||||||
if(other.getTeam() == tile.getTeam() && entity.getItems().has(item) && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){
|
if(other.getTeam() == tile.getTeam() && entity.items().has(item) && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){
|
||||||
other.block().handleItem(item, other, in);
|
other.block().handleItem(item, other, in);
|
||||||
tile.entity.getItems().remove(item, 1);
|
tile.entity.items().remove(item, 1);
|
||||||
incrementDump(tile, proximity.size);
|
incrementDump(tile, proximity.size);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -248,7 +247,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
|||||||
|
|
||||||
if(other.getTeam() == tile.getTeam() && other.block().acceptItem(todump, other, in) && canDump(tile, other, todump)){
|
if(other.getTeam() == tile.getTeam() && other.block().acceptItem(todump, other, in) && canDump(tile, other, todump)){
|
||||||
other.block().handleItem(todump, other, in);
|
other.block().handleItem(todump, other, in);
|
||||||
tile.entity.getItems().remove(todump, 1);
|
tile.entity.items().remove(todump, 1);
|
||||||
incrementDump(tile, proximity.size);
|
incrementDump(tile, proximity.size);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -455,12 +455,12 @@ public class Tile implements Position{
|
|||||||
if(block.hasEntity()){
|
if(block.hasEntity()){
|
||||||
//TODO assign data and don't use new entity
|
//TODO assign data and don't use new entity
|
||||||
entity = block.newEntity().init(this, block.update);
|
entity = block.newEntity().init(this, block.update);
|
||||||
entity.setCons(new ConsumeModule(entity));
|
entity.cons(new ConsumeModule(entity));
|
||||||
if(block.hasItems) entity.setItems(new ItemModule());
|
if(block.hasItems) entity.items(new ItemModule());
|
||||||
if(block.hasLiquids) entity.setLiquids(new LiquidModule());
|
if(block.hasLiquids) entity.liquids(new LiquidModule());
|
||||||
if(block.hasPower){
|
if(block.hasPower){
|
||||||
entity.setPower(new PowerModule());
|
entity.power(new PowerModule());
|
||||||
entity.getPower().graph.add(this);
|
entity.power().graph.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!world.isGenerating()){
|
if(!world.isGenerating()){
|
||||||
@@ -511,7 +511,7 @@ public class Tile implements Position{
|
|||||||
@Remote(called = Loc.server, unreliable = true)
|
@Remote(called = Loc.server, unreliable = true)
|
||||||
public static void onTileDamage(Tile tile, float health){
|
public static void onTileDamage(Tile tile, float health){
|
||||||
if(tile.entity != null){
|
if(tile.entity != null){
|
||||||
tile.entity.setHealth(health);
|
tile.entity.health(health);
|
||||||
|
|
||||||
if(tile.entity.damaged()){
|
if(tile.entity.damaged()){
|
||||||
indexer.notifyTileDamaged(tile.entity);
|
indexer.notifyTileDamaged(tile.entity);
|
||||||
|
|||||||
@@ -9,13 +9,11 @@ import arc.math.*;
|
|||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.effect.*;
|
|
||||||
import mindustry.entities.type.*;
|
import mindustry.entities.type.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
@@ -228,7 +226,7 @@ public class BuildBlock extends Block{
|
|||||||
setConstruct(previous, cblock);
|
setConstruct(previous, cblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
float maxProgress = core == null ? amount : checkRequired(core.getItems(), amount, false);
|
float maxProgress = core == null ? amount : checkRequired(core.items(), amount, false);
|
||||||
|
|
||||||
for(int i = 0; i < cblock.requirements.length; i++){
|
for(int i = 0; i < cblock.requirements.length; i++){
|
||||||
int reqamount = Math.round(state.rules.buildCostMultiplier * cblock.requirements[i].amount);
|
int reqamount = Math.round(state.rules.buildCostMultiplier * cblock.requirements[i].amount);
|
||||||
@@ -236,13 +234,13 @@ public class BuildBlock extends Block{
|
|||||||
totalAccumulator[i] = Math.min(totalAccumulator[i] + reqamount * maxProgress, reqamount);
|
totalAccumulator[i] = Math.min(totalAccumulator[i] + reqamount * maxProgress, reqamount);
|
||||||
}
|
}
|
||||||
|
|
||||||
maxProgress = core == null ? maxProgress : checkRequired(core.getItems(), maxProgress, true);
|
maxProgress = core == null ? maxProgress : checkRequired(core.items(), maxProgress, true);
|
||||||
|
|
||||||
progress = Mathf.clamp(progress + maxProgress);
|
progress = Mathf.clamp(progress + maxProgress);
|
||||||
builderID = builder.getId();
|
builderID = builder.getId();
|
||||||
|
|
||||||
if(progress >= 1f || state.rules.infiniteResources){
|
if(progress >= 1f || state.rules.infiniteResources){
|
||||||
constructed(tile, cblock, builderID, tile.rotation(), builder.getTeam(), configured);
|
constructed(tile, cblock, builderID, tile.rotation(), builder.team(), configured);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class LiquidBlock extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(Tile tile){
|
||||||
LiquidModule mod = tile.entity.getLiquids();
|
LiquidModule mod = tile.entity.liquids();
|
||||||
|
|
||||||
int rotation = rotate ? tile.rotation() * 90 : 0;
|
int rotation = rotate ? tile.rotation() * 90 : 0;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class SurgeWall extends Wall{
|
|||||||
public void handleBulletHit(Tilec entity, Bullet bullet){
|
public void handleBulletHit(Tilec entity, Bullet bullet){
|
||||||
super.handleBulletHit(entity, bullet);
|
super.handleBulletHit(entity, bullet);
|
||||||
if(Mathf.chance(lightningChance)){
|
if(Mathf.chance(lightningChance)){
|
||||||
Lightning.create(entity.getTeam(), Pal.surge, lightningDamage, bullet.x, bullet.y, bullet.rot() + 180f, lightningLength);
|
Lightning.create(entity.team(), Pal.surge, lightningDamage, bullet.x, bullet.y, bullet.rot() + 180f, lightningLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import arc.math.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.Effects.*;
|
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -37,7 +36,7 @@ public class CooledTurret extends Turret{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||||
if(tile.entity.getLiquids().currentAmount() <= 0.001f){
|
if(tile.entity.liquids().currentAmount() <= 0.001f){
|
||||||
Events.fire(Trigger.turretCool);
|
Events.fire(Trigger.turretCool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,11 +50,11 @@ public class CooledTurret extends Turret{
|
|||||||
float maxUsed = consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount;
|
float maxUsed = consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount;
|
||||||
|
|
||||||
TurretEntity entity = tile.ent();
|
TurretEntity entity = tile.ent();
|
||||||
Liquid liquid = entity.getLiquids().current();
|
Liquid liquid = entity.liquids().current();
|
||||||
|
|
||||||
float used = Math.min(Math.min(entity.getLiquids().get(liquid), maxUsed * Time.delta()), Math.max(0, ((reload - entity.reload) / coolantMultiplier) / liquid.heatCapacity)) * baseReloadSpeed(tile);
|
float used = Math.min(Math.min(entity.liquids().get(liquid), maxUsed * Time.delta()), Math.max(0, ((reload - entity.reload) / coolantMultiplier) / liquid.heatCapacity)) * baseReloadSpeed(tile);
|
||||||
entity.reload += used * liquid.heatCapacity * coolantMultiplier;
|
entity.reload += used * liquid.heatCapacity * coolantMultiplier;
|
||||||
entity.getLiquids().remove(liquid, used);
|
entity.liquids().remove(liquid, used);
|
||||||
|
|
||||||
if(Mathf.chance(0.06 * used)){
|
if(Mathf.chance(0.06 * used)){
|
||||||
coolEffect.at(tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f));
|
coolEffect.at(tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f));
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ package mindustry.world.blocks.defense.turrets;
|
|||||||
|
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.entities.*;
|
|
||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
@@ -72,12 +70,12 @@ public class LaserTurret extends PowerTurret{
|
|||||||
|
|
||||||
entity.reload = 0f;
|
entity.reload = 0f;
|
||||||
}else{
|
}else{
|
||||||
Liquid liquid = entity.getLiquids().current();
|
Liquid liquid = entity.liquids().current();
|
||||||
float maxUsed = consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount;
|
float maxUsed = consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount;
|
||||||
|
|
||||||
float used = baseReloadSpeed(tile) * (tile.isEnemyCheat() ? maxUsed : Math.min(entity.getLiquids().get(liquid), maxUsed * Time.delta())) * liquid.heatCapacity * coolantMultiplier;
|
float used = baseReloadSpeed(tile) * (tile.isEnemyCheat() ? maxUsed : Math.min(entity.liquids().get(liquid), maxUsed * Time.delta())) * liquid.heatCapacity * coolantMultiplier;
|
||||||
entity.reload += used;
|
entity.reload += used;
|
||||||
entity.getLiquids().remove(liquid, used);
|
entity.liquids().remove(liquid, used);
|
||||||
|
|
||||||
if(Mathf.chance(0.06 * used)){
|
if(Mathf.chance(0.06 * used)){
|
||||||
coolEffect.at(tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f));
|
coolEffect.at(tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f));
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import mindustry.entities.*;
|
|||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.entities.effect.*;
|
import mindustry.entities.effect.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
@@ -38,8 +37,8 @@ public class LiquidTurret extends Turret{
|
|||||||
TurretEntity entity = tile.ent();
|
TurretEntity entity = tile.ent();
|
||||||
|
|
||||||
if(Core.atlas.isFound(reg(liquidRegion))){
|
if(Core.atlas.isFound(reg(liquidRegion))){
|
||||||
Draw.color(entity.getLiquids().current().color);
|
Draw.color(entity.liquids().current().color);
|
||||||
Draw.alpha(entity.getLiquids().total() / liquidCapacity);
|
Draw.alpha(entity.liquids().total() / liquidCapacity);
|
||||||
Draw.rect(reg(liquidRegion), tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
Draw.rect(reg(liquidRegion), tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
@@ -72,7 +71,7 @@ public class LiquidTurret extends Turret{
|
|||||||
@Override
|
@Override
|
||||||
protected boolean validateTarget(Tile tile){
|
protected boolean validateTarget(Tile tile){
|
||||||
TurretEntity entity = tile.ent();
|
TurretEntity entity = tile.ent();
|
||||||
if(entity.getLiquids().current().canExtinguish() && entity.target instanceof Tile){
|
if(entity.liquids().current().canExtinguish() && entity.target instanceof Tile){
|
||||||
return Fire.has(((Tile)entity.target).x, ((Tile)entity.target).y);
|
return Fire.has(((Tile)entity.target).x, ((Tile)entity.target).y);
|
||||||
}
|
}
|
||||||
return super.validateTarget(tile);
|
return super.validateTarget(tile);
|
||||||
@@ -81,7 +80,7 @@ public class LiquidTurret extends Turret{
|
|||||||
@Override
|
@Override
|
||||||
protected void findTarget(Tile tile){
|
protected void findTarget(Tile tile){
|
||||||
TurretEntity entity = tile.ent();
|
TurretEntity entity = tile.ent();
|
||||||
if(entity.getLiquids().current().canExtinguish()){
|
if(entity.liquids().current().canExtinguish()){
|
||||||
int tr = (int)(range / tilesize);
|
int tr = (int)(range / tilesize);
|
||||||
for(int x = -tr; x <= tr; x++){
|
for(int x = -tr; x <= tr; x++){
|
||||||
for(int y = -tr; y <= tr; y++){
|
for(int y = -tr; y <= tr; y++){
|
||||||
@@ -102,8 +101,8 @@ public class LiquidTurret extends Turret{
|
|||||||
|
|
||||||
TurretEntity entity = tile.ent();
|
TurretEntity entity = tile.ent();
|
||||||
|
|
||||||
type.shootEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.getLiquids().current().color);
|
type.shootEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.liquids().current().color);
|
||||||
type.smokeEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.getLiquids().current().color);
|
type.smokeEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.liquids().current().color);
|
||||||
//shootSound.at(tile);
|
//shootSound.at(tile);
|
||||||
|
|
||||||
if(shootShake > 0){
|
if(shootShake > 0){
|
||||||
@@ -116,21 +115,21 @@ public class LiquidTurret extends Turret{
|
|||||||
@Override
|
@Override
|
||||||
public BulletType useAmmo(Tile tile){
|
public BulletType useAmmo(Tile tile){
|
||||||
TurretEntity entity = tile.ent();
|
TurretEntity entity = tile.ent();
|
||||||
if(tile.isEnemyCheat()) return ammo.get(entity.getLiquids().current());
|
if(tile.isEnemyCheat()) return ammo.get(entity.liquids().current());
|
||||||
BulletType type = ammo.get(entity.getLiquids().current());
|
BulletType type = ammo.get(entity.liquids().current());
|
||||||
entity.getLiquids().remove(entity.getLiquids().current(), type.ammoMultiplier);
|
entity.liquids().remove(entity.liquids().current(), type.ammoMultiplier);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BulletType peekAmmo(Tile tile){
|
public BulletType peekAmmo(Tile tile){
|
||||||
return ammo.get(tile.entity.getLiquids().current());
|
return ammo.get(tile.entity.liquids().current());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasAmmo(Tile tile){
|
public boolean hasAmmo(Tile tile){
|
||||||
TurretEntity entity = tile.ent();
|
TurretEntity entity = tile.ent();
|
||||||
return ammo.get(entity.getLiquids().current()) != null && entity.getLiquids().total() >= ammo.get(entity.getLiquids().current()).ammoMultiplier;
|
return ammo.get(entity.liquids().current()) != null && entity.liquids().total() >= ammo.get(entity.liquids().current()).ammoMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -141,7 +140,7 @@ public class LiquidTurret extends Turret{
|
|||||||
@Override
|
@Override
|
||||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||||
return ammo.get(liquid) != null
|
return ammo.get(liquid) != null
|
||||||
&& (tile.entity.getLiquids().current() == liquid || (ammo.containsKey(tile.entity.getLiquids().current()) && tile.entity.getLiquids().get(tile.entity.getLiquids().current()) <= ammo.get(tile.entity.getLiquids().current()).ammoMultiplier + 0.001f));
|
&& (tile.entity.liquids().current() == liquid || (ammo.containsKey(tile.entity.liquids().current()) && tile.entity.liquids().get(tile.entity.liquids().current()) <= ammo.get(tile.entity.liquids().current()).ammoMultiplier + 0.001f));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,6 @@ public class PowerTurret extends CooledTurret{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float baseReloadSpeed(Tile tile){
|
protected float baseReloadSpeed(Tile tile){
|
||||||
return tile.isEnemyCheat() ? 1f : tile.entity.getPower().status;
|
return tile.isEnemyCheat() ? 1f : tile.entity.power().status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,8 @@ import arc.math.geom.Vec2;
|
|||||||
import arc.util.Time;
|
import arc.util.Time;
|
||||||
import mindustry.content.Fx;
|
import mindustry.content.Fx;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.*;
|
|
||||||
import mindustry.entities.bullet.BulletType;
|
import mindustry.entities.bullet.BulletType;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.world.Block;
|
import mindustry.world.Block;
|
||||||
import mindustry.world.Tile;
|
import mindustry.world.Tile;
|
||||||
@@ -193,9 +191,9 @@ public abstract class Turret extends Block{
|
|||||||
TurretEntity entity = tile.ent();
|
TurretEntity entity = tile.ent();
|
||||||
|
|
||||||
if(targetAir && !targetGround){
|
if(targetAir && !targetGround){
|
||||||
entity.target = Units.closestEnemy(tile.getTeam(), tile.drawx(), tile.drawy(), range, e -> !e.isDead() && e.isFlying());
|
entity.target = Units.closestEnemy(tile.getTeam(), tile.drawx(), tile.drawy(), range, e -> !e.dead() && e.isFlying());
|
||||||
}else{
|
}else{
|
||||||
entity.target = Units.closestTarget(tile.getTeam(), tile.drawx(), tile.drawy(), range, e -> !e.isDead() && (!e.isFlying() || targetAir) && (e.isFlying() || targetGround));
|
entity.target = Units.closestTarget(tile.getTeam(), tile.drawx(), tile.drawy(), range, e -> !e.dead() && (!e.isFlying() || targetAir) && (e.isFlying() || targetGround));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import arc.util.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
@@ -96,7 +95,7 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
|
|
||||||
if(tile.front() != null && tile.front().entity != null){
|
if(tile.front() != null && tile.front().entity != null){
|
||||||
entity.next = tile.front().entity;
|
entity.next = tile.front().entity;
|
||||||
entity.nextc = entity.next instanceof ConveyorEntity && entity.next.getTeam() == tile.getTeam() ? (ConveyorEntity)entity.next : null;
|
entity.nextc = entity.next instanceof ConveyorEntity && entity.next.team() == tile.getTeam() ? (ConveyorEntity)entity.next : null;
|
||||||
entity.aligned = entity.nextc != null && tile.rotation() == entity.next.tile.rotation();
|
entity.aligned = entity.nextc != null && tile.rotation() == entity.next.tile.rotation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,10 +266,10 @@ public class ItemBridge extends Block{
|
|||||||
|
|
||||||
if(rel == rel2) return false;
|
if(rel == rel2) return false;
|
||||||
}else{
|
}else{
|
||||||
return source.block() instanceof ItemBridge && source.<ItemBridgeEntity>ent().link == tile.pos() && tile.entity.getItems().total() < itemCapacity;
|
return source.block() instanceof ItemBridge && source.<ItemBridgeEntity>ent().link == tile.pos() && tile.entity.items().total() < itemCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tile.entity.getItems().total() < itemCapacity;
|
return tile.entity.items().total() < itemCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -315,7 +315,7 @@ public class ItemBridge extends Block{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tile.entity.getLiquids().get(liquid) + amount < liquidCapacity && (tile.entity.getLiquids().current() == liquid || tile.entity.getLiquids().get(tile.entity.getLiquids().current()) < 0.2f);
|
return tile.entity.liquids().get(liquid) + amount < liquidCapacity && (tile.entity.liquids().current() == liquid || tile.entity.liquids().get(tile.entity.liquids().current()) < 0.2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ public class MassDriver extends Block{
|
|||||||
float targetRotation = tile.angleTo(link);
|
float targetRotation = tile.angleTo(link);
|
||||||
|
|
||||||
if(
|
if(
|
||||||
tile.entity.getItems().total() >= minDistribute && //must shoot minimum amount of items
|
tile.entity.items().total() >= minDistribute && //must shoot minimum amount of items
|
||||||
link.block().itemCapacity - link.entity.getItems().total() >= minDistribute //must have minimum amount of space
|
link.block().itemCapacity - link.entity.items().total() >= minDistribute //must have minimum amount of space
|
||||||
){
|
){
|
||||||
MassDriverEntity other = link.ent();
|
MassDriverEntity other = link.ent();
|
||||||
other.waitingShooters.add(tile);
|
other.waitingShooters.add(tile);
|
||||||
@@ -225,7 +225,7 @@ public class MassDriver extends Block{
|
|||||||
@Override
|
@Override
|
||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||||
//mass drivers that ouput only cannot accept items
|
//mass drivers that ouput only cannot accept items
|
||||||
return tile.entity.getItems().total() < itemCapacity && linkValid(tile);
|
return tile.entity.items().total() < itemCapacity && linkValid(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fire(Tile tile, Tile target){
|
protected void fire(Tile tile, Tile target){
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ public class OverflowGate extends Block{
|
|||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
OverflowGateEntity entity = tile.ent();
|
OverflowGateEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.lastItem == null && entity.getItems().total() > 0){
|
if(entity.lastItem == null && entity.items().total() > 0){
|
||||||
entity.getItems().clear();
|
entity.items().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.lastItem != null){
|
if(entity.lastItem != null){
|
||||||
@@ -53,7 +53,7 @@ public class OverflowGate extends Block{
|
|||||||
if(target != null && (entity.time >= 1f)){
|
if(target != null && (entity.time >= 1f)){
|
||||||
getTileTarget(tile, entity.lastItem, entity.lastInput, true);
|
getTileTarget(tile, entity.lastItem, entity.lastInput, true);
|
||||||
target.block().handleItem(entity.lastItem, target, Edges.getFacingEdge(tile, target));
|
target.block().handleItem(entity.lastItem, target, Edges.getFacingEdge(tile, target));
|
||||||
entity.getItems().remove(entity.lastItem, 1);
|
entity.items().remove(entity.lastItem, 1);
|
||||||
entity.lastItem = null;
|
entity.lastItem = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,13 +63,13 @@ public class OverflowGate extends Block{
|
|||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||||
OverflowGateEntity entity = tile.ent();
|
OverflowGateEntity entity = tile.ent();
|
||||||
|
|
||||||
return tile.getTeam() == source.getTeam() && entity.lastItem == null && entity.getItems().total() == 0;
|
return tile.getTeam() == source.getTeam() && entity.lastItem == null && entity.items().total() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleItem(Item item, Tile tile, Tile source){
|
public void handleItem(Item item, Tile tile, Tile source){
|
||||||
OverflowGateEntity entity = tile.ent();
|
OverflowGateEntity entity = tile.ent();
|
||||||
entity.getItems().add(item, 1);
|
entity.items().add(item, 1);
|
||||||
entity.lastItem = item;
|
entity.lastItem = item;
|
||||||
entity.time = 0f;
|
entity.time = 0f;
|
||||||
entity.lastInput = source;
|
entity.lastInput = source;
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ public class Router extends Block{
|
|||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
RouterEntity entity = tile.ent();
|
RouterEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.lastItem == null && entity.getItems().total() > 0){
|
if(entity.lastItem == null && entity.items().total() > 0){
|
||||||
entity.getItems().clear();
|
entity.items().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.lastItem != null){
|
if(entity.lastItem != null){
|
||||||
@@ -37,7 +37,7 @@ public class Router extends Block{
|
|||||||
if(target != null && (entity.time >= 1f || !(target.block() instanceof Router))){
|
if(target != null && (entity.time >= 1f || !(target.block() instanceof Router))){
|
||||||
getTileTarget(tile, entity.lastItem, entity.lastInput, true);
|
getTileTarget(tile, entity.lastItem, entity.lastInput, true);
|
||||||
target.block().handleItem(entity.lastItem, target, Edges.getFacingEdge(tile, target));
|
target.block().handleItem(entity.lastItem, target, Edges.getFacingEdge(tile, target));
|
||||||
entity.getItems().remove(entity.lastItem, 1);
|
entity.items().remove(entity.lastItem, 1);
|
||||||
entity.lastItem = null;
|
entity.lastItem = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,13 +47,13 @@ public class Router extends Block{
|
|||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||||
RouterEntity entity = tile.ent();
|
RouterEntity entity = tile.ent();
|
||||||
|
|
||||||
return tile.getTeam() == source.getTeam() && entity.lastItem == null && entity.getItems().total() == 0;
|
return tile.getTeam() == source.getTeam() && entity.lastItem == null && entity.items().total() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleItem(Item item, Tile tile, Tile source){
|
public void handleItem(Item item, Tile tile, Tile source){
|
||||||
RouterEntity entity = tile.ent();
|
RouterEntity entity = tile.ent();
|
||||||
entity.getItems().add(item, 1);
|
entity.items().add(item, 1);
|
||||||
entity.lastItem = item;
|
entity.lastItem = item;
|
||||||
entity.time = 0f;
|
entity.time = 0f;
|
||||||
entity.lastInput = source;
|
entity.lastInput = source;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import arc.math.geom.*;
|
|||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -96,7 +95,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
|||||||
Draw.colorl(0.34f);
|
Draw.colorl(0.34f);
|
||||||
Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
|
Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
|
||||||
|
|
||||||
Draw.color(tile.entity.getLiquids().current().color);
|
Draw.color(tile.entity.liquids().current().color);
|
||||||
Draw.alpha(entity.smoothLiquid);
|
Draw.alpha(entity.smoothLiquid);
|
||||||
Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
|
Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
@@ -109,8 +108,8 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
|||||||
ConduitEntity entity = tile.ent();
|
ConduitEntity entity = tile.ent();
|
||||||
entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.getLiquids().currentAmount() / liquidCapacity, 0.05f);
|
entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.getLiquids().currentAmount() / liquidCapacity, 0.05f);
|
||||||
|
|
||||||
if(tile.entity.getLiquids().total() > 0.001f && tile.entity.timer(timerFlow, 1)){
|
if(tile.entity.liquids().total() > 0.001f && tile.entity.timer(timerFlow, 1)){
|
||||||
tryMoveLiquid(tile, tile.getNearby(tile.rotation()), leakResistance, tile.entity.getLiquids().current());
|
tryMoveLiquid(tile, tile.getNearby(tile.rotation()), leakResistance, tile.entity.liquids().current());
|
||||||
entity.noSleep();
|
entity.noSleep();
|
||||||
}else{
|
}else{
|
||||||
entity.sleep();
|
entity.sleep();
|
||||||
@@ -125,7 +124,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
|||||||
@Override
|
@Override
|
||||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||||
tile.entity.noSleep();
|
tile.entity.noSleep();
|
||||||
return tile.entity.getLiquids().get(liquid) + amount < liquidCapacity && (tile.entity.getLiquids().current() == liquid || tile.entity.getLiquids().get(tile.entity.getLiquids().current()) < 0.2f)
|
return tile.entity.liquids().get(liquid) + amount < liquidCapacity && (tile.entity.liquids().current() == liquid || tile.entity.liquids().get(tile.entity.liquids().current()) < 0.2f)
|
||||||
&& ((source.absoluteRelativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation());
|
&& ((source.absoluteRelativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ public class LiquidRouter extends LiquidBlock{
|
|||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
|
|
||||||
if(tile.entity.getLiquids().total() > 0.01f){
|
if(tile.entity.liquids().total() > 0.01f){
|
||||||
tryDumpLiquid(tile, tile.entity.getLiquids().current());
|
tryDumpLiquid(tile, tile.entity.liquids().current());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||||
return tile.entity.getLiquids().get(liquid) + amount < liquidCapacity && (tile.entity.getLiquids().current() == liquid || tile.entity.getLiquids().get(tile.entity.getLiquids().current()) < 0.2f);
|
return tile.entity.liquids().get(liquid) + amount < liquidCapacity && (tile.entity.liquids().current() == liquid || tile.entity.liquids().get(tile.entity.liquids().current()) < 0.2f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class ImpactReactor extends PowerGenerator{
|
|||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
FusionReactorEntity entity = tile.ent();
|
FusionReactorEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.consValid() && entity.getPower().status >= 0.99f){
|
if(entity.consValid() && entity.power().status >= 0.99f){
|
||||||
boolean prevOut = getPowerProduction(tile) <= consumes.getPower().requestedPower(entity);
|
boolean prevOut = getPowerProduction(tile) <= consumes.getPower().requestedPower(entity);
|
||||||
|
|
||||||
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, warmupSpeed);
|
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, warmupSpeed);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import arc.math.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.Effects.*;
|
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
@@ -106,7 +105,7 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
|||||||
|
|
||||||
Liquid liquid = null;
|
Liquid liquid = null;
|
||||||
for(Liquid other : content.liquids()){
|
for(Liquid other : content.liquids()){
|
||||||
if(hasLiquids && entity.getLiquids().get(other) >= 0.001f && getLiquidEfficiency(other) >= minLiquidEfficiency){
|
if(hasLiquids && entity.liquids().get(other) >= 0.001f && getLiquidEfficiency(other) >= minLiquidEfficiency){
|
||||||
liquid = other;
|
liquid = other;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -115,12 +114,12 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
|||||||
entity.heat = Mathf.lerpDelta(entity.heat, entity.generateTime >= 0.001f ? 1f : 0f, 0.05f);
|
entity.heat = Mathf.lerpDelta(entity.heat, entity.generateTime >= 0.001f ? 1f : 0f, 0.05f);
|
||||||
|
|
||||||
//liquid takes priority over solids
|
//liquid takes priority over solids
|
||||||
if(hasLiquids && liquid != null && entity.getLiquids().get(liquid) >= 0.001f){
|
if(hasLiquids && liquid != null && entity.liquids().get(liquid) >= 0.001f){
|
||||||
float baseLiquidEfficiency = getLiquidEfficiency(liquid);
|
float baseLiquidEfficiency = getLiquidEfficiency(liquid);
|
||||||
float maximumPossible = maxLiquidGenerate * calculationDelta;
|
float maximumPossible = maxLiquidGenerate * calculationDelta;
|
||||||
float used = Math.min(entity.getLiquids().get(liquid) * calculationDelta, maximumPossible);
|
float used = Math.min(entity.liquids().get(liquid) * calculationDelta, maximumPossible);
|
||||||
|
|
||||||
entity.getLiquids().remove(liquid, used * entity.getPower().graph.getUsageFraction());
|
entity.liquids().remove(liquid, used * entity.power().graph.getUsageFraction());
|
||||||
entity.productionEfficiency = baseLiquidEfficiency * used / maximumPossible;
|
entity.productionEfficiency = baseLiquidEfficiency * used / maximumPossible;
|
||||||
|
|
||||||
if(used > 0.001f && Mathf.chance(0.05 * entity.delta())){
|
if(used > 0.001f && Mathf.chance(0.05 * entity.delta())){
|
||||||
@@ -128,16 +127,16 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
|||||||
}
|
}
|
||||||
}else if(hasItems){
|
}else if(hasItems){
|
||||||
// No liquids accepted or none supplied, try using items if accepted
|
// No liquids accepted or none supplied, try using items if accepted
|
||||||
if(entity.generateTime <= 0f && entity.getItems().total() > 0){
|
if(entity.generateTime <= 0f && entity.items().total() > 0){
|
||||||
generateEffect.at(tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f));
|
generateEffect.at(tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f));
|
||||||
Item item = entity.getItems().take();
|
Item item = entity.items().take();
|
||||||
entity.productionEfficiency = getItemEfficiency(item);
|
entity.productionEfficiency = getItemEfficiency(item);
|
||||||
entity.explosiveness = item.explosiveness;
|
entity.explosiveness = item.explosiveness;
|
||||||
entity.generateTime = 1f;
|
entity.generateTime = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.generateTime > 0f){
|
if(entity.generateTime > 0f){
|
||||||
entity.generateTime -= Math.min(1f / itemDuration * entity.delta() * entity.getPower().graph.getUsageFraction(), entity.generateTime);
|
entity.generateTime -= Math.min(1f / itemDuration * entity.delta() * entity.power().graph.getUsageFraction(), entity.generateTime);
|
||||||
|
|
||||||
if(randomlyExplode && state.rules.reactorExplosions && Mathf.chance(entity.delta() * 0.06 * Mathf.clamp(entity.explosiveness - 0.5f))){
|
if(randomlyExplode && state.rules.reactorExplosions && Mathf.chance(entity.delta() * 0.06 * Mathf.clamp(entity.explosiveness - 0.5f))){
|
||||||
//this block is run last so that in the event of a block destruction, no code relies on the block type
|
//this block is run last so that in the event of a block destruction, no code relies on the block type
|
||||||
@@ -166,8 +165,8 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(hasLiquids){
|
if(hasLiquids){
|
||||||
Draw.color(entity.getLiquids().current().color);
|
Draw.color(entity.liquids().current().color);
|
||||||
Draw.alpha(entity.getLiquids().currentAmount() / liquidCapacity);
|
Draw.alpha(entity.liquids().currentAmount() / liquidCapacity);
|
||||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class NuclearReactor extends PowerGenerator{
|
|||||||
ConsumeLiquid cliquid = consumes.get(ConsumeType.liquid);
|
ConsumeLiquid cliquid = consumes.get(ConsumeType.liquid);
|
||||||
Item item = consumes.<ConsumeItems>get(ConsumeType.item).items[0].item;
|
Item item = consumes.<ConsumeItems>get(ConsumeType.item).items[0].item;
|
||||||
|
|
||||||
int fuel = entity.getItems().get(item);
|
int fuel = entity.items().get(item);
|
||||||
float fullness = (float)fuel / itemCapacity;
|
float fullness = (float)fuel / itemCapacity;
|
||||||
entity.productionEfficiency = fullness;
|
entity.productionEfficiency = fullness;
|
||||||
|
|
||||||
@@ -94,9 +94,9 @@ public class NuclearReactor extends PowerGenerator{
|
|||||||
Liquid liquid = cliquid.liquid;
|
Liquid liquid = cliquid.liquid;
|
||||||
|
|
||||||
if(entity.heat > 0){
|
if(entity.heat > 0){
|
||||||
float maxUsed = Math.min(entity.getLiquids().get(liquid), entity.heat / coolantPower);
|
float maxUsed = Math.min(entity.liquids().get(liquid), entity.heat / coolantPower);
|
||||||
entity.heat -= maxUsed * coolantPower;
|
entity.heat -= maxUsed * coolantPower;
|
||||||
entity.getLiquids().remove(liquid, maxUsed);
|
entity.liquids().remove(liquid, maxUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.heat > smokeThreshold){
|
if(entity.heat > smokeThreshold){
|
||||||
@@ -123,7 +123,7 @@ public class NuclearReactor extends PowerGenerator{
|
|||||||
|
|
||||||
NuclearReactorEntity entity = tile.ent();
|
NuclearReactorEntity entity = tile.ent();
|
||||||
|
|
||||||
int fuel = entity.getItems().get(consumes.<ConsumeItems>get(ConsumeType.item).items[0].item);
|
int fuel = entity.items().get(consumes.<ConsumeItems>get(ConsumeType.item).items[0].item);
|
||||||
|
|
||||||
if((fuel < 5 && entity.heat < 0.5f) || !state.rules.reactorExplosions) return;
|
if((fuel < 5 && entity.heat < 0.5f) || !state.rules.reactorExplosions) return;
|
||||||
|
|
||||||
@@ -166,8 +166,8 @@ public class NuclearReactor extends PowerGenerator{
|
|||||||
Draw.color(coolColor, hotColor, entity.heat);
|
Draw.color(coolColor, hotColor, entity.heat);
|
||||||
Fill.rect(tile.drawx(), tile.drawy(), size * tilesize, size * tilesize);
|
Fill.rect(tile.drawx(), tile.drawy(), size * tilesize, size * tilesize);
|
||||||
|
|
||||||
Draw.color(entity.getLiquids().current().color);
|
Draw.color(entity.liquids().current().color);
|
||||||
Draw.alpha(entity.getLiquids().currentAmount() / liquidCapacity);
|
Draw.alpha(entity.liquids().currentAmount() / liquidCapacity);
|
||||||
Draw.rect(topRegion, tile.drawx(), tile.drawy());
|
Draw.rect(topRegion, tile.drawx(), tile.drawy());
|
||||||
|
|
||||||
if(entity.heat > flashThreshold){
|
if(entity.heat > flashThreshold){
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ public class PowerDiode extends Block{
|
|||||||
|
|
||||||
if(tile.front() == null || tile.back() == null || !tile.back().block().hasPower || !tile.front().block().hasPower || tile.back().getTeam() != tile.front().getTeam()) return;
|
if(tile.front() == null || tile.back() == null || !tile.back().block().hasPower || !tile.front().block().hasPower || tile.back().getTeam() != tile.front().getTeam()) return;
|
||||||
|
|
||||||
PowerGraph backGraph = tile.back().entity.getPower().graph;
|
PowerGraph backGraph = tile.back().entity.power().graph;
|
||||||
PowerGraph frontGraph = tile.front().entity.getPower().graph;
|
PowerGraph frontGraph = tile.front().entity.power().graph;
|
||||||
if(backGraph == frontGraph) return;
|
if(backGraph == frontGraph) return;
|
||||||
|
|
||||||
// 0f - 1f of battery capacity in use
|
// 0f - 1f of battery capacity in use
|
||||||
@@ -51,7 +51,7 @@ public class PowerDiode extends Block{
|
|||||||
|
|
||||||
// battery % of the graph on either side, defaults to zero
|
// battery % of the graph on either side, defaults to zero
|
||||||
public float bar(Tile tile){
|
public float bar(Tile tile){
|
||||||
return (tile != null && tile.block().hasPower) ? tile.entity.getPower().graph.getBatteryStored() / tile.entity.getPower().graph.getTotalBatteryCapacity() : 0f;
|
return (tile != null && tile.block().hasPower) ? tile.entity.power().graph.getBatteryStored() / tile.entity.power().graph.getTotalBatteryCapacity() : 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class PowerGraph{
|
|||||||
for(Tile battery : batteries){
|
for(Tile battery : batteries){
|
||||||
Consumers consumes = battery.block().consumes;
|
Consumers consumes = battery.block().consumes;
|
||||||
if(consumes.hasPower()){
|
if(consumes.hasPower()){
|
||||||
totalAccumulator += battery.entity.getPower().status * consumes.getPower().capacity;
|
totalAccumulator += battery.entity.power().status * consumes.getPower().capacity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return totalAccumulator;
|
return totalAccumulator;
|
||||||
@@ -99,7 +99,7 @@ public class PowerGraph{
|
|||||||
for(Tile battery : batteries){
|
for(Tile battery : batteries){
|
||||||
if(battery.block().consumes.hasPower()){
|
if(battery.block().consumes.hasPower()){
|
||||||
ConsumePower power = battery.block().consumes.getPower();
|
ConsumePower power = battery.block().consumes.getPower();
|
||||||
totalCapacity += (1f - battery.entity.getPower().status) * power.capacity;
|
totalCapacity += (1f - battery.entity.power().status) * power.capacity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return totalCapacity;
|
return totalCapacity;
|
||||||
@@ -124,7 +124,7 @@ public class PowerGraph{
|
|||||||
for(Tile battery : batteries){
|
for(Tile battery : batteries){
|
||||||
Consumers consumes = battery.block().consumes;
|
Consumers consumes = battery.block().consumes;
|
||||||
if(consumes.hasPower()){
|
if(consumes.hasPower()){
|
||||||
battery.entity.getPower().status *= (1f-consumedPowerPercentage);
|
battery.entity.power().status *= (1f-consumedPowerPercentage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return used;
|
return used;
|
||||||
@@ -141,7 +141,7 @@ public class PowerGraph{
|
|||||||
if(consumes.hasPower()){
|
if(consumes.hasPower()){
|
||||||
ConsumePower consumePower = consumes.getPower();
|
ConsumePower consumePower = consumes.getPower();
|
||||||
if(consumePower.capacity > 0f){
|
if(consumePower.capacity > 0f){
|
||||||
battery.entity.getPower().status += (1f-battery.entity.getPower().status) * chargedPercent;
|
battery.entity.power().status += (1f-battery.entity.power().status) * chargedPercent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,17 +159,17 @@ public class PowerGraph{
|
|||||||
if(!Mathf.zero(consumePower.capacity)){
|
if(!Mathf.zero(consumePower.capacity)){
|
||||||
// Add an equal percentage of power to all buffers, based on the global power coverage in this graph
|
// Add an equal percentage of power to all buffers, based on the global power coverage in this graph
|
||||||
float maximumRate = consumePower.requestedPower(consumer.entity) * coverage * consumer.entity.delta();
|
float maximumRate = consumePower.requestedPower(consumer.entity) * coverage * consumer.entity.delta();
|
||||||
consumer.entity.getPower().status = Mathf.clamp(consumer.entity.getPower().status + maximumRate / consumePower.capacity);
|
consumer.entity.power().status = Mathf.clamp(consumer.entity.power().status + maximumRate / consumePower.capacity);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//valid consumers get power as usual
|
//valid consumers get power as usual
|
||||||
if(otherConsumersAreValid(consumer, consumePower)){
|
if(otherConsumersAreValid(consumer, consumePower)){
|
||||||
consumer.entity.getPower().status = coverage;
|
consumer.entity.power().status = coverage;
|
||||||
}else{ //invalid consumers get an estimate, if they were to activate
|
}else{ //invalid consumers get an estimate, if they were to activate
|
||||||
consumer.entity.getPower().status = Math.min(1, produced / (needed + consumePower.usage * consumer.entity.delta()));
|
consumer.entity.power().status = Math.min(1, produced / (needed + consumePower.usage * consumer.entity.delta()));
|
||||||
//just in case
|
//just in case
|
||||||
if(Float.isNaN(consumer.entity.getPower().status)){
|
if(Float.isNaN(consumer.entity.power().status)){
|
||||||
consumer.entity.getPower().status = 0f;
|
consumer.entity.power().status = 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ public class PowerGraph{
|
|||||||
}else if(!consumers.isEmpty() && consumers.first().isEnemyCheat()){
|
}else if(!consumers.isEmpty() && consumers.first().isEnemyCheat()){
|
||||||
//when cheating, just set status to 1
|
//when cheating, just set status to 1
|
||||||
for(Tile tile : consumers){
|
for(Tile tile : consumers){
|
||||||
tile.entity.getPower().status = 1f;
|
tile.entity.power().status = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastPowerNeeded = lastPowerProduced = lastUsageFraction = 1f;
|
lastPowerNeeded = lastPowerProduced = lastUsageFraction = 1f;
|
||||||
@@ -230,8 +230,8 @@ public class PowerGraph{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(Tile tile){
|
public void add(Tile tile){
|
||||||
if(tile.entity == null || tile.entity.getPower() == null) return;
|
if(tile.entity == null || tile.entity.power() == null) return;
|
||||||
tile.entity.getPower().graph = this;
|
tile.entity.power().graph = this;
|
||||||
all.add(tile);
|
all.add(tile);
|
||||||
|
|
||||||
if(tile.block().outputsPower && tile.block().consumesPower && !tile.block().consumes.getPower().buffered){
|
if(tile.block().outputsPower && tile.block().consumesPower && !tile.block().consumes.getPower().buffered){
|
||||||
@@ -277,7 +277,7 @@ public class PowerGraph{
|
|||||||
//go through all the connections of this tile
|
//go through all the connections of this tile
|
||||||
for(Tile other : tile.block().getPowerConnections(tile, outArray1)){
|
for(Tile other : tile.block().getPowerConnections(tile, outArray1)){
|
||||||
//a graph has already been assigned to this tile from a previous call, skip it
|
//a graph has already been assigned to this tile from a previous call, skip it
|
||||||
if(other.entity.getPower().graph != this) continue;
|
if(other.entity.power().graph != this) continue;
|
||||||
|
|
||||||
//create graph for this branch
|
//create graph for this branch
|
||||||
PowerGraph graph = new PowerGraph();
|
PowerGraph graph = new PowerGraph();
|
||||||
@@ -296,7 +296,7 @@ public class PowerGraph{
|
|||||||
for(Tile next : child.block().getPowerConnections(child, outArray2)){
|
for(Tile next : child.block().getPowerConnections(child, outArray2)){
|
||||||
//make sure it hasn't looped back, and that the new graph being assigned hasn't already been assigned
|
//make sure it hasn't looped back, and that the new graph being assigned hasn't already been assigned
|
||||||
//also skip closed tiles
|
//also skip closed tiles
|
||||||
if(next != tile && next.entity.getPower().graph != graph && !closedSet.contains(next.pos())){
|
if(next != tile && next.entity.power().graph != graph && !closedSet.contains(next.pos())){
|
||||||
queue.addLast(next);
|
queue.addLast(next);
|
||||||
closedSet.add(next.pos());
|
closedSet.add(next.pos());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,19 +41,19 @@ public class PowerNode extends PowerBlock{
|
|||||||
public void configured(Tile tile, Player player, int value){
|
public void configured(Tile tile, Player player, int value){
|
||||||
Tilec entity = tile.entity;
|
Tilec entity = tile.entity;
|
||||||
Tile other = world.tile(value);
|
Tile other = world.tile(value);
|
||||||
boolean contains = entity.getPower().links.contains(value), valid = other != null && other.entity != null && other.entity.getPower() != null;
|
boolean contains = entity.getPower().links.contains(value), valid = other != null && other.entity != null && other.entity.power() != null;
|
||||||
|
|
||||||
if(contains){
|
if(contains){
|
||||||
//unlink
|
//unlink
|
||||||
entity.getPower().links.removeValue(value);
|
entity.getPower().links.removeValue(value);
|
||||||
if(valid) other.entity.getPower().links.removeValue(tile.pos());
|
if(valid) other.entity.power().links.removeValue(tile.pos());
|
||||||
|
|
||||||
PowerGraph newgraph = new PowerGraph();
|
PowerGraph newgraph = new PowerGraph();
|
||||||
|
|
||||||
//reflow from this point, covering all tiles on this side
|
//reflow from this point, covering all tiles on this side
|
||||||
newgraph.reflow(tile);
|
newgraph.reflow(tile);
|
||||||
|
|
||||||
if(valid && other.entity.getPower().graph != newgraph){
|
if(valid && other.entity.power().graph != newgraph){
|
||||||
//create new graph for other end
|
//create new graph for other end
|
||||||
PowerGraph og = new PowerGraph();
|
PowerGraph og = new PowerGraph();
|
||||||
//reflow from other end
|
//reflow from other end
|
||||||
@@ -67,12 +67,12 @@ public class PowerNode extends PowerBlock{
|
|||||||
|
|
||||||
if(other.getTeamID() == tile.getTeamID()){
|
if(other.getTeamID() == tile.getTeamID()){
|
||||||
|
|
||||||
if(!other.entity.getPower().links.contains(tile.pos())){
|
if(!other.entity.power().links.contains(tile.pos())){
|
||||||
other.entity.getPower().links.add(tile.pos());
|
other.entity.power().links.add(tile.pos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.getPower().graph.add(other.entity.getPower().graph);
|
entity.getPower().graph.add(other.entity.power().graph);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,15 +89,15 @@ public class PowerNode extends PowerBlock{
|
|||||||
super.setBars();
|
super.setBars();
|
||||||
bars.add("power", entity -> new Bar(() ->
|
bars.add("power", entity -> new Bar(() ->
|
||||||
Core.bundle.format("bar.powerbalance",
|
Core.bundle.format("bar.powerbalance",
|
||||||
((entity.getPower().graph.getPowerBalance() >= 0 ? "+" : "") + Strings.fixed(entity.getPower().graph.getPowerBalance() * 60, 1))),
|
((entity.power().graph.getPowerBalance() >= 0 ? "+" : "") + Strings.fixed(entity.power().graph.getPowerBalance() * 60, 1))),
|
||||||
() -> Pal.powerBar,
|
() -> Pal.powerBar,
|
||||||
() -> Mathf.clamp(entity.getPower().graph.getLastPowerProduced() / entity.getPower().graph.getLastPowerNeeded())));
|
() -> Mathf.clamp(entity.power().graph.getLastPowerProduced() / entity.power().graph.getLastPowerNeeded())));
|
||||||
|
|
||||||
bars.add("batteries", entity -> new Bar(() ->
|
bars.add("batteries", entity -> new Bar(() ->
|
||||||
Core.bundle.format("bar.powerstored",
|
Core.bundle.format("bar.powerstored",
|
||||||
(ui.formatAmount((int)entity.getPower().graph.getBatteryStored())), ui.formatAmount((int)entity.getPower().graph.getTotalBatteryCapacity())),
|
(ui.formatAmount((int)entity.power().graph.getBatteryStored())), ui.formatAmount((int)entity.power().graph.getTotalBatteryCapacity())),
|
||||||
() -> Pal.powerBar,
|
() -> Pal.powerBar,
|
||||||
() -> Mathf.clamp(entity.getPower().graph.getBatteryStored() / entity.getPower().graph.getTotalBatteryCapacity())));
|
() -> Mathf.clamp(entity.power().graph.getBatteryStored() / entity.power().graph.getTotalBatteryCapacity())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -105,7 +105,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
if(net.client()) return;
|
if(net.client()) return;
|
||||||
|
|
||||||
Boolf<Tile> valid = other -> other != null && other != tile && ((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && linkValid(tile, other)
|
Boolf<Tile> valid = other -> other != null && other != tile && ((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && linkValid(tile, other)
|
||||||
&& !other.entity.proximity().contains(tile) && other.entity.getPower().graph != tile.entity.getPower().graph;
|
&& !other.entity.proximity().contains(tile) && other.entity.power().graph != tile.entity.power().graph;
|
||||||
|
|
||||||
tempTiles.clear();
|
tempTiles.clear();
|
||||||
Geometry.circle(tile.x, tile.y, (int)(laserRange + 2), (x, y) -> {
|
Geometry.circle(tile.x, tile.y, (int)(laserRange + 2), (x, y) -> {
|
||||||
@@ -123,7 +123,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
return Float.compare(a.dst2(tile), b.dst2(tile));
|
return Float.compare(a.dst2(tile), b.dst2(tile));
|
||||||
});
|
});
|
||||||
tempTiles.each(valid, other -> {
|
tempTiles.each(valid, other -> {
|
||||||
if(!tile.entity.getPower().links.contains(other.pos())){
|
if(!tile.entity.power().links.contains(other.pos())){
|
||||||
tile.configureAny(other.pos());
|
tile.configureAny(other.pos());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -132,10 +132,10 @@ public class PowerNode extends PowerBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void getPotentialLinks(Tile tile, Cons<Tile> others){
|
private void getPotentialLinks(Tile tile, Cons<Tile> others){
|
||||||
Boolf<Tile> valid = other -> other != null && other != tile && other.entity != null && other.entity.getPower() != null &&
|
Boolf<Tile> valid = other -> other != null && other != tile && other.entity != null && other.entity.power() != null &&
|
||||||
((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) &&
|
((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) &&
|
||||||
overlaps(tile.x * tilesize + offset(), tile.y * tilesize + offset(), other, laserRange * tilesize) && other.getTeam() == player.getTeam()
|
overlaps(tile.x * tilesize + offset(), tile.y * tilesize + offset(), other, laserRange * tilesize) && other.getTeam() == player.team()
|
||||||
&& !other.entity.proximity().contains(tile) && !graphs.contains(other.entity.getPower().graph);
|
&& !other.entity.proximity().contains(tile) && !graphs.contains(other.entity.power().graph);
|
||||||
|
|
||||||
tempTiles.clear();
|
tempTiles.clear();
|
||||||
graphs.clear();
|
graphs.clear();
|
||||||
@@ -152,7 +152,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
return Float.compare(a.dst2(tile), b.dst2(tile));
|
return Float.compare(a.dst2(tile), b.dst2(tile));
|
||||||
});
|
});
|
||||||
tempTiles.each(valid, t -> {
|
tempTiles.each(valid, t -> {
|
||||||
graphs.add(t.entity.getPower().graph);
|
graphs.add(t.entity.power().graph);
|
||||||
others.get(t);
|
others.get(t);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
tile.entity.getPower().graph.update();
|
tile.entity.power().graph.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -181,7 +181,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(tile == other){
|
if(tile == other){
|
||||||
if(other.entity.getPower().links.size == 0){
|
if(other.entity.power().links.size == 0){
|
||||||
int[] total = {0};
|
int[] total = {0};
|
||||||
getPotentialLinks(tile, link -> {
|
getPotentialLinks(tile, link -> {
|
||||||
if(!insulated(tile, link) && total[0]++ < maxNodes){
|
if(!insulated(tile, link) && total[0]++ < maxNodes){
|
||||||
@@ -281,7 +281,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean linked(Tile tile, Tile other){
|
protected boolean linked(Tile tile, Tile other){
|
||||||
return tile.entity.getPower().links.contains(other.pos());
|
return tile.entity.power().links.contains(other.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean linkValid(Tile tile, Tile link){
|
public boolean linkValid(Tile tile, Tile link){
|
||||||
@@ -293,7 +293,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
|
|
||||||
if(overlaps(tile, link, laserRange * tilesize) || (link.block() instanceof PowerNode && overlaps(link, tile, link.<PowerNode>cblock().laserRange * tilesize))){
|
if(overlaps(tile, link, laserRange * tilesize) || (link.block() instanceof PowerNode && overlaps(link, tile, link.<PowerNode>cblock().laserRange * tilesize))){
|
||||||
if(checkMaxNodes && link.block() instanceof PowerNode){
|
if(checkMaxNodes && link.block() instanceof PowerNode){
|
||||||
return link.entity.getPower().links.size < link.<PowerNode>cblock().maxNodes || link.entity.getPower().links.contains(tile.pos());
|
return link.entity.power().links.size < link.<PowerNode>cblock().maxNodes || link.entity.power().links.contains(tile.pos());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -331,7 +331,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
x2 += t2.x;
|
x2 += t2.x;
|
||||||
y2 += t2.y;
|
y2 += t2.y;
|
||||||
|
|
||||||
float fract = 1f - tile.entity.getPower().graph.getSatisfaction();
|
float fract = 1f - tile.entity.power().graph.getSatisfaction();
|
||||||
|
|
||||||
Draw.color(Color.white, Pal.powerLight, fract * 0.86f + Mathf.absin(3f, 0.1f));
|
Draw.color(Color.white, Pal.powerLight, fract * 0.86f + Mathf.absin(3f, 0.1f));
|
||||||
Draw.alpha(opacity);
|
Draw.alpha(opacity);
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import arc.util.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
@@ -76,7 +75,7 @@ public class Drill extends Block{
|
|||||||
bars.add("drillspeed", e -> {
|
bars.add("drillspeed", e -> {
|
||||||
DrillEntity entity = (DrillEntity)e;
|
DrillEntity entity = (DrillEntity)e;
|
||||||
|
|
||||||
return new Bar(() -> Core.bundle.format("bar.drillspeed", Strings.fixed(entity.lastDrillSpeed * 60 * entity.getTimeScale(), 2)), () -> Pal.ammo, () -> entity.warmup);
|
return new Bar(() -> Core.bundle.format("bar.drillspeed", Strings.fixed(entity.lastDrillSpeed * 60 * entity.timeScale(), 2)), () -> Pal.ammo, () -> entity.warmup);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +127,7 @@ public class Drill extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldConsume(Tile tile){
|
public boolean shouldConsume(Tile tile){
|
||||||
return tile.entity.getItems().total() < itemCapacity;
|
return tile.entity.items().total() < itemCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -252,11 +251,11 @@ public class Drill extends Block{
|
|||||||
|
|
||||||
entity.drillTime += entity.warmup * entity.delta();
|
entity.drillTime += entity.warmup * entity.delta();
|
||||||
|
|
||||||
if(entity.getItems().total() < itemCapacity && entity.dominantItems > 0 && entity.consValid()){
|
if(entity.items().total() < itemCapacity && entity.dominantItems > 0 && entity.consValid()){
|
||||||
|
|
||||||
float speed = 1f;
|
float speed = 1f;
|
||||||
|
|
||||||
if(entity.getCons().optionalValid()){
|
if(entity.cons().optionalValid()){
|
||||||
speed = liquidBoostIntensity;
|
speed = liquidBoostIntensity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +274,7 @@ public class Drill extends Block{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.dominantItems > 0 && entity.progress >= drillTime + hardnessDrillMultiplier * entity.dominantItem.hardness && tile.entity.getItems().total() < itemCapacity){
|
if(entity.dominantItems > 0 && entity.progress >= drillTime + hardnessDrillMultiplier * entity.dominantItem.hardness && tile.entity.items().total() < itemCapacity){
|
||||||
|
|
||||||
offloadNear(tile, entity.dominantItem);
|
offloadNear(tile, entity.dominantItem);
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class Fracker extends SolidPump{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldConsume(Tile tile){
|
public boolean shouldConsume(Tile tile){
|
||||||
return tile.entity.getLiquids().get(result) < liquidCapacity - 0.01f;
|
return tile.entity.liquids().get(result) < liquidCapacity - 0.01f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,7 +55,7 @@ public class Fracker extends SolidPump{
|
|||||||
super.drawCracks(tile);
|
super.drawCracks(tile);
|
||||||
|
|
||||||
Draw.color(result.color);
|
Draw.color(result.color);
|
||||||
Draw.alpha(tile.entity.getLiquids().get(result) / liquidCapacity);
|
Draw.alpha(tile.entity.liquids().get(result) / liquidCapacity);
|
||||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
||||||
Draw.color();
|
Draw.color();
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ public class Fracker extends SolidPump{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float typeLiquid(Tile tile){
|
public float typeLiquid(Tile tile){
|
||||||
return tile.entity.getLiquids().get(result);
|
return tile.entity.liquids().get(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FrackerEntity extends SolidPumpEntity{
|
public static class FrackerEntity extends SolidPumpEntity{
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import arc.util.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.consumers.*;
|
import mindustry.world.consumers.*;
|
||||||
@@ -60,7 +59,7 @@ public class GenericCrafter extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldIdleSound(Tile tile){
|
public boolean shouldIdleSound(Tile tile){
|
||||||
return tile.entity.getCons().valid();
|
return tile.entity.cons().valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -135,10 +134,10 @@ public class GenericCrafter extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldConsume(Tile tile){
|
public boolean shouldConsume(Tile tile){
|
||||||
if(outputItem != null && tile.entity.getItems().get(outputItem.item) >= itemCapacity){
|
if(outputItem != null && tile.entity.items().get(outputItem.item) >= itemCapacity){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return outputLiquid == null || !(tile.entity.getLiquids().get(outputLiquid.liquid) >= liquidCapacity);
|
return outputLiquid == null || !(tile.entity.liquids().get(outputLiquid.liquid) >= liquidCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class LiquidConverter extends GenericCrafter{
|
|||||||
@Override
|
@Override
|
||||||
public void drawLight(Tile tile){
|
public void drawLight(Tile tile){
|
||||||
if(hasLiquids && drawLiquidLight && outputLiquid.liquid.lightColor.a > 0.001f){
|
if(hasLiquids && drawLiquidLight && outputLiquid.liquid.lightColor.a > 0.001f){
|
||||||
drawLiquidLight(tile, outputLiquid.liquid, tile.entity.getLiquids().get(outputLiquid.liquid));
|
drawLiquidLight(tile, outputLiquid.liquid, tile.entity.liquids().get(outputLiquid.liquid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,12 +44,12 @@ public class LiquidConverter extends GenericCrafter{
|
|||||||
GenericCrafterEntity entity = tile.ent();
|
GenericCrafterEntity entity = tile.ent();
|
||||||
ConsumeLiquidBase cl = consumes.get(ConsumeType.liquid);
|
ConsumeLiquidBase cl = consumes.get(ConsumeType.liquid);
|
||||||
|
|
||||||
if(tile.entity.getCons().valid()){
|
if(tile.entity.cons().valid()){
|
||||||
float use = Math.min(cl.amount * entity.delta(), liquidCapacity - entity.getLiquids().get(outputLiquid.liquid)) * entity.efficiency();
|
float use = Math.min(cl.amount * entity.delta(), liquidCapacity - entity.liquids().get(outputLiquid.liquid)) * entity.efficiency();
|
||||||
|
|
||||||
useContent(tile, outputLiquid.liquid);
|
useContent(tile, outputLiquid.liquid);
|
||||||
entity.progress += use / cl.amount / craftTime;
|
entity.progress += use / cl.amount / craftTime;
|
||||||
entity.getLiquids().add(outputLiquid.liquid, use);
|
entity.liquids().add(outputLiquid.liquid, use);
|
||||||
if(entity.progress >= 1f){
|
if(entity.progress >= 1f){
|
||||||
entity.consume();
|
entity.consume();
|
||||||
entity.progress = 0f;
|
entity.progress = 0f;
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ public class Pump extends LiquidBlock{
|
|||||||
public void draw(Tile tile){
|
public void draw(Tile tile){
|
||||||
Draw.rect(name, tile.drawx(), tile.drawy());
|
Draw.rect(name, tile.drawx(), tile.drawy());
|
||||||
|
|
||||||
Draw.color(tile.entity.getLiquids().current().color);
|
Draw.color(tile.entity.liquids().current().color);
|
||||||
Draw.alpha(tile.entity.getLiquids().total() / liquidCapacity);
|
Draw.alpha(tile.entity.liquids().total() / liquidCapacity);
|
||||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
@@ -118,16 +118,16 @@ public class Pump extends LiquidBlock{
|
|||||||
liquidDrop = tile.floor().liquidDrop;
|
liquidDrop = tile.floor().liquidDrop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tile.entity.getCons().valid() && liquidDrop != null){
|
if(tile.entity.cons().valid() && liquidDrop != null){
|
||||||
float maxPump = Math.min(liquidCapacity - tile.entity.getLiquids().total(), tiles * pumpAmount * tile.entity.delta() / size / size) * tile.entity.efficiency();
|
float maxPump = Math.min(liquidCapacity - tile.entity.liquids().total(), tiles * pumpAmount * tile.entity.delta() / size / size) * tile.entity.efficiency();
|
||||||
tile.entity.getLiquids().add(liquidDrop, maxPump);
|
tile.entity.liquids().add(liquidDrop, maxPump);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tile.entity.getLiquids().currentAmount() > 0f && tile.entity.timer(timerContentCheck, 10)){
|
if(tile.entity.liquids().currentAmount() > 0f && tile.entity.timer(timerContentCheck, 10)){
|
||||||
useContent(tile, tile.entity.getLiquids().current());
|
useContent(tile, tile.entity.liquids().current());
|
||||||
}
|
}
|
||||||
|
|
||||||
tryDumpLiquid(tile, tile.entity.getLiquids().current());
|
tryDumpLiquid(tile, tile.entity.liquids().current());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isValid(Tile tile){
|
protected boolean isValid(Tile tile){
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class Separator extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldConsume(Tile tile){
|
public boolean shouldConsume(Tile tile){
|
||||||
return tile.entity.getItems().total() < itemCapacity;
|
return tile.entity.items().total() < itemCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -63,8 +63,8 @@ public class Separator extends Block{
|
|||||||
|
|
||||||
GenericCrafterEntity entity = tile.ent();
|
GenericCrafterEntity entity = tile.ent();
|
||||||
|
|
||||||
Draw.color(tile.entity.getLiquids().current().color);
|
Draw.color(tile.entity.liquids().current().color);
|
||||||
Draw.alpha(tile.entity.getLiquids().total() / liquidCapacity);
|
Draw.alpha(tile.entity.liquids().total() / liquidCapacity);
|
||||||
Draw.rect(reg(liquidRegion), tile.drawx(), tile.drawy());
|
Draw.rect(reg(liquidRegion), tile.drawx(), tile.drawy());
|
||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
@@ -106,7 +106,7 @@ public class Separator extends Block{
|
|||||||
|
|
||||||
entity.consume();
|
entity.consume();
|
||||||
|
|
||||||
if(item != null && entity.getItems().get(item) < itemCapacity){
|
if(item != null && entity.items().get(item) < itemCapacity){
|
||||||
offloadNear(tile, item);
|
offloadNear(tile, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ public class SolidPump extends Pump{
|
|||||||
SolidPumpEntity entity = tile.ent();
|
SolidPumpEntity entity = tile.ent();
|
||||||
|
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||||
Draw.color(tile.entity.getLiquids().current().color);
|
Draw.color(tile.entity.liquids().current().color);
|
||||||
Draw.alpha(tile.entity.getLiquids().total() / liquidCapacity);
|
Draw.alpha(tile.entity.liquids().total() / liquidCapacity);
|
||||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
||||||
Draw.color();
|
Draw.color();
|
||||||
Draw.rect(name + "-rotator", tile.drawx(), tile.drawy(), entity.pumpTime * rotateSpeed);
|
Draw.rect(name + "-rotator", tile.drawx(), tile.drawy(), entity.pumpTime * rotateSpeed);
|
||||||
@@ -105,9 +105,9 @@ public class SolidPump extends Pump{
|
|||||||
|
|
||||||
fraction += entity.boost;
|
fraction += entity.boost;
|
||||||
|
|
||||||
if(tile.entity.getCons().valid() && typeLiquid(tile) < liquidCapacity - 0.001f){
|
if(tile.entity.cons().valid() && typeLiquid(tile) < liquidCapacity - 0.001f){
|
||||||
float maxPump = Math.min(liquidCapacity - typeLiquid(tile), pumpAmount * entity.delta() * fraction * entity.efficiency());
|
float maxPump = Math.min(liquidCapacity - typeLiquid(tile), pumpAmount * entity.delta() * fraction * entity.efficiency());
|
||||||
tile.entity.getLiquids().add(result, maxPump);
|
tile.entity.liquids().add(result, maxPump);
|
||||||
entity.lastPump = maxPump;
|
entity.lastPump = maxPump;
|
||||||
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.02f);
|
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.02f);
|
||||||
if(Mathf.chance(entity.delta() * updateEffectChance))
|
if(Mathf.chance(entity.delta() * updateEffectChance))
|
||||||
@@ -152,7 +152,7 @@ public class SolidPump extends Pump{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float typeLiquid(Tile tile){
|
public float typeLiquid(Tile tile){
|
||||||
return tile.entity.getLiquids().total();
|
return tile.entity.liquids().total();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SolidPumpEntity extends Tilec{
|
public static class SolidPumpEntity extends Tilec{
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import arc.util.ArcAnnotate.*;
|
|||||||
import mindustry.entities.type.*;
|
import mindustry.entities.type.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.ui.Cicon;
|
import mindustry.ui.Cicon;
|
||||||
@@ -54,9 +53,9 @@ public class LiquidSource extends Block{
|
|||||||
LiquidSourceEntity entity = tile.ent();
|
LiquidSourceEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.source == null){
|
if(entity.source == null){
|
||||||
tile.entity.getLiquids().clear();
|
tile.entity.liquids().clear();
|
||||||
}else{
|
}else{
|
||||||
tile.entity.getLiquids().add(entity.source, liquidCapacity);
|
tile.entity.liquids().add(entity.source, liquidCapacity);
|
||||||
tryDumpLiquid(tile, entity.source);
|
tryDumpLiquid(tile, entity.source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import mindustry.entities.traits.*;
|
|||||||
import mindustry.entities.type.*;
|
import mindustry.entities.type.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
@@ -71,7 +70,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||||
return tile.entity.getItems().get(item) < getMaximumAccepted(tile, item);
|
return tile.entity.items().get(item) < getMaximumAccepted(tile, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -86,14 +85,14 @@ public class CoreBlock extends StorageBlock{
|
|||||||
|
|
||||||
for(Tilec other : state.teams.cores(tile.getTeam())){
|
for(Tilec other : state.teams.cores(tile.getTeam())){
|
||||||
if(other.tile != tile){
|
if(other.tile != tile){
|
||||||
entity.getItems() = other.items;
|
entity.items() = other.items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.teams.registerCore(entity);
|
state.teams.registerCore(entity);
|
||||||
|
|
||||||
entity.storageCapacity = itemCapacity + entity.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
entity.storageCapacity = itemCapacity + entity.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
||||||
entity.proximity().each(this::isContainer, t -> {
|
entity.proximity().each(this::isContainer, t -> {
|
||||||
t.entity.getItems() = entity.getItems();
|
t.entity.items() = entity.items();
|
||||||
t.<StorageBlockEntity>ent().linkedCore = tile;
|
t.<StorageBlockEntity>ent().linkedCore = tile;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -104,7 +103,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
|
|
||||||
if(!world.isGenerating()){
|
if(!world.isGenerating()){
|
||||||
for(Item item : content.items()){
|
for(Item item : content.items()){
|
||||||
entity.getItems().set(item, Math.min(entity.getItems().get(item), entity.storageCapacity));
|
entity.items().set(item, Math.min(entity.items().get(item), entity.storageCapacity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,10 +122,10 @@ public class CoreBlock extends StorageBlock{
|
|||||||
Draw.rect("block-select", t.drawx() + offset * p.x, t.drawy() + offset * p.y, i * 90);
|
Draw.rect("block-select", t.drawx() + offset * p.x, t.drawy() + offset * p.y, i * 90);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if(tile.entity.proximity().contains(e -> isContainer(e) && e.entity.getItems() == tile.entity.getItems())){
|
if(tile.entity.proximity().contains(e -> isContainer(e) && e.entity.items() == tile.entity.items())){
|
||||||
outline.get(tile);
|
outline.get(tile);
|
||||||
}
|
}
|
||||||
tile.entity.proximity().each(e -> isContainer(e) && e.entity.getItems() == tile.entity.getItems(), outline);
|
tile.entity.proximity().each(e -> isContainer(e) && e.entity.items() == tile.entity.items(), outline);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +136,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float handleDamage(Tile tile, float amount){
|
public float handleDamage(Tile tile, float amount){
|
||||||
if(player != null && tile.getTeam() == player.getTeam()){
|
if(player != null && tile.getTeam() == player.team()){
|
||||||
Events.fire(Trigger.teamCoreDamage);
|
Events.fire(Trigger.teamCoreDamage);
|
||||||
}
|
}
|
||||||
return amount;
|
return amount;
|
||||||
@@ -151,15 +150,15 @@ public class CoreBlock extends StorageBlock{
|
|||||||
@Override
|
@Override
|
||||||
public void removed(Tile tile){
|
public void removed(Tile tile){
|
||||||
CoreEntity entity = tile.ent();
|
CoreEntity entity = tile.ent();
|
||||||
int total = tile.entity.proximity().count(e -> e.entity != null && e.entity.getItems() != null && e.entity.getItems() == tile.entity.getItems());
|
int total = tile.entity.proximity().count(e -> e.entity != null && e.entity.items() != null && e.entity.items() == tile.entity.items());
|
||||||
float fract = 1f / total / state.teams.cores(tile.getTeam()).size;
|
float fract = 1f / total / state.teams.cores(tile.getTeam()).size;
|
||||||
|
|
||||||
tile.entity.proximity().each(e -> isContainer(e) && e.entity.getItems() == tile.entity.getItems(), t -> {
|
tile.entity.proximity().each(e -> isContainer(e) && e.entity.items() == tile.entity.items(), t -> {
|
||||||
StorageBlockEntity ent = (StorageBlockEntity)t.entity;
|
StorageBlockEntity ent = (StorageBlockEntity)t.entity;
|
||||||
ent.linkedCore = null;
|
ent.linkedCore = null;
|
||||||
ent.items = new ItemModule();
|
ent.items = new ItemModule();
|
||||||
for(Item item : content.items()){
|
for(Item item : content.items()){
|
||||||
ent.items.set(item, (int)(fract * tile.entity.getItems().get(item)));
|
ent.items.set(item, (int)(fract * tile.entity.items().get(item)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -167,7 +166,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
|
|
||||||
int max = itemCapacity * state.teams.cores(tile.getTeam()).size;
|
int max = itemCapacity * state.teams.cores(tile.getTeam()).size;
|
||||||
for(Item item : content.items()){
|
for(Item item : content.items()){
|
||||||
tile.entity.getItems().set(item, Math.min(tile.entity.getItems().get(item), max));
|
tile.entity.items().set(item, Math.min(tile.entity.items().get(item), max));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(CoreEntity other : state.teams.cores(tile.getTeam())){
|
for(CoreEntity other : state.teams.cores(tile.getTeam())){
|
||||||
@@ -206,7 +205,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
CoreEntity entity = tile.ent();
|
CoreEntity entity = tile.ent();
|
||||||
|
|
||||||
if(entity.spawnPlayer != null){
|
if(entity.spawnPlayer != null){
|
||||||
if(!entity.spawnPlayer.isDead() || !entity.spawnPlayer.isAdded()){
|
if(!entity.spawnPlayer.dead() || !entity.spawnPlayer.isAdded()){
|
||||||
entity.spawnPlayer = null;
|
entity.spawnPlayer = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,14 +40,14 @@ public class LaunchPad extends StorageBlock{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||||
return item.type == ItemType.material && tile.entity.getItems().total() < itemCapacity;
|
return item.type == ItemType.material && tile.entity.items().total() < itemCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(Tile tile){
|
||||||
super.draw(tile);
|
super.draw(tile);
|
||||||
|
|
||||||
float progress = Mathf.clamp(Mathf.clamp((tile.entity.getItems().total() / (float)itemCapacity)) * ((tile.entity.timerTime(timerLaunch) / (launchTime / tile.entity.timeScale))));
|
float progress = Mathf.clamp(Mathf.clamp((tile.entity.items().total() / (float)itemCapacity)) * ((tile.entity.timerTime(timerLaunch) / (launchTime / tile.entity.timeScale))));
|
||||||
float scale = size / 3f;
|
float scale = size / 3f;
|
||||||
|
|
||||||
Lines.stroke(2f);
|
Lines.stroke(2f);
|
||||||
@@ -56,7 +56,7 @@ public class LaunchPad extends StorageBlock{
|
|||||||
|
|
||||||
Draw.color(Pal.accent);
|
Draw.color(Pal.accent);
|
||||||
|
|
||||||
if(tile.entity.getCons().valid()){
|
if(tile.entity.cons().valid()){
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
float f = (Time.time() / 200f + i * 0.5f) % 1f;
|
float f = (Time.time() / 200f + i * 0.5f) % 1f;
|
||||||
|
|
||||||
@@ -72,13 +72,13 @@ public class LaunchPad extends StorageBlock{
|
|||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
Tilec entity = tile.entity;
|
Tilec entity = tile.entity;
|
||||||
|
|
||||||
if(world.isZone() && entity.consValid() && entity.getItems().total() >= itemCapacity && entity.timer(timerLaunch, launchTime / entity.timeScale)){
|
if(world.isZone() && entity.consValid() && entity.items().total() >= itemCapacity && entity.timer(timerLaunch, launchTime / entity.timeScale)){
|
||||||
for(Item item : Vars.content.items()){
|
for(Item item : Vars.content.items()){
|
||||||
Events.fire(Trigger.itemLaunch);
|
Events.fire(Trigger.itemLaunch);
|
||||||
Fx.padlaunch.at(tile);
|
Fx.padlaunch.at(tile);
|
||||||
int used = Math.min(entity.getItems().get(item), itemCapacity);
|
int used = Math.min(entity.items().get(item), itemCapacity);
|
||||||
data.addItem(item, used);
|
data.addItem(item, used);
|
||||||
entity.getItems().remove(item, used);
|
entity.items().remove(item, used);
|
||||||
Events.fire(new LaunchItemEvent(item, used));
|
Events.fire(new LaunchItemEvent(item, used));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public abstract class StorageBlock extends Block{
|
|||||||
@Override
|
@Override
|
||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||||
StorageBlockEntity entity = tile.ent();
|
StorageBlockEntity entity = tile.ent();
|
||||||
return entity.linkedCore != null ? entity.linkedCore.block().acceptItem(item, entity.linkedCore, source) : tile.entity.getItems().get(item) < getMaximumAccepted(tile, item);
|
return entity.linkedCore != null ? entity.linkedCore.block().acceptItem(item, entity.linkedCore, source) : tile.entity.items().get(item) < getMaximumAccepted(tile, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -46,10 +46,10 @@ public abstract class StorageBlock extends Block{
|
|||||||
Tilec entity = tile.entity;
|
Tilec entity = tile.entity;
|
||||||
|
|
||||||
if(item == null){
|
if(item == null){
|
||||||
return entity.getItems().take();
|
return entity.items().take();
|
||||||
}else{
|
}else{
|
||||||
if(entity.getItems().has(item)){
|
if(entity.items().has(item)){
|
||||||
entity.getItems().remove(item, 1);
|
entity.items().remove(item, 1);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,9 +64,9 @@ public abstract class StorageBlock extends Block{
|
|||||||
public boolean hasItem(Tile tile, Item item){
|
public boolean hasItem(Tile tile, Item item){
|
||||||
Tilec entity = tile.entity;
|
Tilec entity = tile.entity;
|
||||||
if(item == null){
|
if(item == null){
|
||||||
return entity.getItems().total() > 0;
|
return entity.items().total() > 0;
|
||||||
}else{
|
}else{
|
||||||
return entity.getItems().has(item);
|
return entity.items().has(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class Unloader extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configured(Tile tile, Player player, int value){
|
public void configured(Tile tile, Player player, int value){
|
||||||
tile.entity.getItems().clear();
|
tile.entity.items().clear();
|
||||||
tile.<UnloaderEntity>ent().sortItem = content.item(value);
|
tile.<UnloaderEntity>ent().sortItem = content.item(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,10 +63,10 @@ public class Unloader extends Block{
|
|||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
UnloaderEntity entity = tile.ent();
|
UnloaderEntity entity = tile.ent();
|
||||||
|
|
||||||
if(tile.entity.timer(timerUnload, speed / entity.timeScale) && tile.entity.getItems().total() == 0){
|
if(tile.entity.timer(timerUnload, speed / entity.timeScale) && tile.entity.items().total() == 0){
|
||||||
for(Tile other : tile.entity.proximity()){
|
for(Tile other : tile.entity.proximity()){
|
||||||
if(other.interactable(tile.getTeam()) && other.block().unloadable && other.block().hasItems && entity.getItems().total() == 0 &&
|
if(other.interactable(tile.getTeam()) && other.block().unloadable && other.block().hasItems && entity.getItems().total() == 0 &&
|
||||||
((entity.sortItem == null && other.entity.getItems().total() > 0) || hasItem(other, entity.sortItem))){
|
((entity.sortItem == null && other.entity.items().total() > 0) || hasItem(other, entity.sortItem))){
|
||||||
offloadNear(tile, removeItem(other, entity.sortItem));
|
offloadNear(tile, removeItem(other, entity.sortItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import mindustry.entities.traits.*;
|
|||||||
import mindustry.entities.type.*;
|
import mindustry.entities.type.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
@@ -80,7 +79,7 @@ public class MechPad extends Block{
|
|||||||
|
|
||||||
protected static boolean checkValidTap(Tile tile, Player player){
|
protected static boolean checkValidTap(Tile tile, Player player){
|
||||||
MechFactoryEntity entity = tile.ent();
|
MechFactoryEntity entity = tile.ent();
|
||||||
return !player.isDead() && tile.interactable(player.getTeam()) && Math.abs(player.x - tile.drawx()) <= tile.block().size * tilesize &&
|
return !player.dead() && tile.interactable(player.team()) && Math.abs(player.x - tile.drawx()) <= tile.block().size * tilesize &&
|
||||||
Math.abs(player.y - tile.drawy()) <= tile.block().size * tilesize && entity.consValid() && entity.player == null;
|
Math.abs(player.y - tile.drawy()) <= tile.block().size * tilesize && entity.consValid() && entity.player == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +99,7 @@ public class MechPad extends Block{
|
|||||||
|
|
||||||
if(checkValidTap(tile, player)){
|
if(checkValidTap(tile, player)){
|
||||||
Call.onMechFactoryTap(player, tile);
|
Call.onMechFactoryTap(player, tile);
|
||||||
}else if(player.isLocal && mobile && !player.isDead() && entity.consValid() && entity.player == null){
|
}else if(player.isLocal && mobile && !player.dead() && entity.consValid() && entity.player == null){
|
||||||
//deselect on double taps
|
//deselect on double taps
|
||||||
player.moveTarget = player.moveTarget == tile.entity ? null : tile.entity;
|
player.moveTarget = player.moveTarget == tile.entity ? null : tile.entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class RepairPoint extends Block{
|
|||||||
RepairPointEntity entity = tile.ent();
|
RepairPointEntity entity = tile.ent();
|
||||||
|
|
||||||
boolean targetIsBeingRepaired = false;
|
boolean targetIsBeingRepaired = false;
|
||||||
if(entity.target != null && (entity.target.isDead() || entity.target.dst(tile) > repairRadius || entity.target.health >= entity.target.maxHealth())){
|
if(entity.target != null && (entity.target.dead() || entity.target.dst(tile) > repairRadius || entity.target.health >= entity.target.maxHealth())){
|
||||||
entity.target = null;
|
entity.target = null;
|
||||||
}else if(entity.target != null && entity.consValid()){
|
}else if(entity.target != null && entity.consValid()){
|
||||||
entity.target.health += repairSpeed * Time.delta() * entity.strength * entity.efficiency();
|
entity.target.health += repairSpeed * Time.delta() * entity.strength * entity.efficiency();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import arc.struct.*;
|
|||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.ui.Cicon;
|
import mindustry.ui.Cicon;
|
||||||
@@ -35,7 +34,7 @@ public class ConsumeItemFilter extends Consume{
|
|||||||
@Override
|
@Override
|
||||||
public void build(Tile tile, Table table){
|
public void build(Tile tile, Table table){
|
||||||
MultiReqImage image = new MultiReqImage();
|
MultiReqImage image = new MultiReqImage();
|
||||||
content.items().each(i -> filter.get(i) && (!world.isZone() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1), () -> tile.entity != null && tile.entity.getItems() != null && tile.entity.getItems().has(item))));
|
content.items().each(i -> filter.get(i) && (!world.isZone() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1), () -> tile.entity != null && tile.entity.items() != null && tile.entity.items().has(item))));
|
||||||
|
|
||||||
table.add(image).size(8 * 4);
|
table.add(image).size(8 * 4);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package mindustry.world.consumers;
|
|||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.ui.Cicon;
|
import mindustry.ui.Cicon;
|
||||||
@@ -38,7 +37,7 @@ public class ConsumeItems extends Consume{
|
|||||||
@Override
|
@Override
|
||||||
public void build(Tile tile, Table table){
|
public void build(Tile tile, Table table){
|
||||||
for(ItemStack stack : items){
|
for(ItemStack stack : items){
|
||||||
table.add(new ReqImage(new ItemImage(stack.item.icon(Cicon.medium), stack.amount), () -> tile.entity != null && tile.entity.getItems() != null && tile.entity.getItems().has(stack.item, stack.amount))).size(8 * 4).padRight(5);
|
table.add(new ReqImage(new ItemImage(stack.item.icon(Cicon.medium), stack.amount), () -> tile.entity != null && tile.entity.items() != null && tile.entity.items().has(stack.item, stack.amount))).size(8 * 4).padRight(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{
|
|||||||
public void build(Tile tile, Table table){
|
public void build(Tile tile, Table table){
|
||||||
Array<Liquid> list = content.liquids().select(l -> !l.isHidden() && filter.get(l));
|
Array<Liquid> list = content.liquids().select(l -> !l.isHidden() && filter.get(l));
|
||||||
MultiReqImage image = new MultiReqImage();
|
MultiReqImage image = new MultiReqImage();
|
||||||
list.each(liquid -> image.add(new ReqImage(liquid.icon(Cicon.medium), () -> tile.entity != null && tile.entity.getLiquids() != null && tile.entity.getLiquids().get(liquid) >= use(tile.entity))));
|
list.each(liquid -> image.add(new ReqImage(liquid.icon(Cicon.medium), () -> tile.entity != null && tile.entity.liquids() != null && tile.entity.liquids().get(liquid) >= use(tile.entity))));
|
||||||
|
|
||||||
table.add(image).size(8 * 4);
|
table.add(image).size(8 * 4);
|
||||||
}
|
}
|
||||||
@@ -44,12 +44,12 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tilec entity){
|
public void update(Tilec entity){
|
||||||
entity.getLiquids().remove(entity.getLiquids().current(), use(entity));
|
entity.liquids().remove(entity.liquids().current(), use(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean valid(Tilec entity){
|
public boolean valid(Tilec entity){
|
||||||
return entity != null && entity.getLiquids() != null && filter.get(entity.getLiquids().current()) && entity.getLiquids().currentAmount() >= use(entity);
|
return entity != null && entity.liquids() != null && filter.get(entity.liquids().current()) && entity.liquids().currentAmount() >= use(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class ConsumePower extends Consume{
|
|||||||
if(buffered){
|
if(buffered){
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
return entity.getPower().status > 0f;
|
return entity.power().status > 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,12 +69,12 @@ public class ConsumePower extends Consume{
|
|||||||
* @return The amount of power which is requested per tick.
|
* @return The amount of power which is requested per tick.
|
||||||
*/
|
*/
|
||||||
public float requestedPower(Tilec entity){
|
public float requestedPower(Tilec entity){
|
||||||
if(entity.getTile().entity == null) return 0f;
|
if(entity.tile().entity == null) return 0f;
|
||||||
if(buffered){
|
if(buffered){
|
||||||
return (1f-entity.getPower().status)*capacity;
|
return (1f-entity.power().status)*capacity;
|
||||||
}else{
|
}else{
|
||||||
try{
|
try{
|
||||||
return usage * Mathf.num(entity.getBlock().shouldConsume(entity.getTile()));
|
return usage * Mathf.num(entity.block().shouldConsume(entity.tile()));
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
//HACK an error will only happen with a bar that is checking its requested power, and the entity is null/a different class
|
//HACK an error will only happen with a bar that is checking its requested power, and the entity is null/a different class
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import arc.util.*;
|
|||||||
import com.codedisaster.steamworks.*;
|
import com.codedisaster.steamworks.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.Stats.*;
|
import mindustry.game.Stats.*;
|
||||||
@@ -54,17 +53,17 @@ public class SStats implements SteamUserStatsCallback{
|
|||||||
|
|
||||||
private void checkUpdate(){
|
private void checkUpdate(){
|
||||||
if(campaign()){
|
if(campaign()){
|
||||||
SStat.maxUnitActive.max(unitGroup.count(t -> t.getTeam() == player.getTeam()));
|
SStat.maxUnitActive.max(unitGroup.count(t -> t.getTeam() == player.team()));
|
||||||
|
|
||||||
if(unitGroup.count(u -> u.getType() == UnitTypes.phantom && u.getTeam() == player.getTeam()) >= 10){
|
if(unitGroup.count(u -> u.getType() == UnitTypes.phantom && u.getTeam() == player.team()) >= 10){
|
||||||
active10Phantoms.complete();
|
active10Phantoms.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unitGroup.count(u -> u.getType() == UnitTypes.crawler && u.getTeam() == player.getTeam()) >= 50){
|
if(unitGroup.count(u -> u.getType() == UnitTypes.crawler && u.getTeam() == player.team()) >= 50){
|
||||||
active50Crawlers.complete();
|
active50Crawlers.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Tilec entity : player.getTeam().cores()){
|
for(Tilec entity : player.team().cores()){
|
||||||
if(!content.items().contains(i -> i.type == ItemType.material && entity.getItems().get(i) < entity.block.itemCapacity)){
|
if(!content.items().contains(i -> i.type == ItemType.material && entity.getItems().get(i) < entity.block.itemCapacity)){
|
||||||
fillCoreAllCampaign.complete();
|
fillCoreAllCampaign.complete();
|
||||||
break;
|
break;
|
||||||
@@ -76,7 +75,7 @@ public class SStats implements SteamUserStatsCallback{
|
|||||||
private void registerEvents(){
|
private void registerEvents(){
|
||||||
Events.on(UnitDestroyEvent.class, e -> {
|
Events.on(UnitDestroyEvent.class, e -> {
|
||||||
if(ncustom()){
|
if(ncustom()){
|
||||||
if(e.unit.getTeam() != Vars.player.getTeam()){
|
if(e.unit.team() != Vars.player.team()){
|
||||||
SStat.unitsDestroyed.add();
|
SStat.unitsDestroyed.add();
|
||||||
|
|
||||||
if(e.unit instanceof BaseUnit && ((BaseUnit)e.unit).isBoss()){
|
if(e.unit instanceof BaseUnit && ((BaseUnit)e.unit).isBoss()){
|
||||||
@@ -93,7 +92,7 @@ public class SStats implements SteamUserStatsCallback{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(Trigger.newGame, () -> Core.app.post(() -> {
|
Events.on(Trigger.newGame, () -> Core.app.post(() -> {
|
||||||
if(campaign() && player.getClosestCore() != null && player.getClosestCore().items.total() >= 10 * 1000){
|
if(campaign() && player.closestCore() != null && player.closestCore().items.total() >= 10 * 1000){
|
||||||
drop10kitems.complete();
|
drop10kitems.complete();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@@ -133,7 +132,7 @@ public class SStats implements SteamUserStatsCallback{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(BlockDestroyEvent.class, e -> {
|
Events.on(BlockDestroyEvent.class, e -> {
|
||||||
if(campaign() && e.tile.getTeam() != player.getTeam()){
|
if(campaign() && e.tile.getTeam() != player.team()){
|
||||||
SStat.blocksDestroyed.add();
|
SStat.blocksDestroyed.add();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -180,7 +179,7 @@ public class SStats implements SteamUserStatsCallback{
|
|||||||
trigger(Trigger.itemLaunch, launchItemPad);
|
trigger(Trigger.itemLaunch, launchItemPad);
|
||||||
|
|
||||||
Events.on(UnitCreateEvent.class, e -> {
|
Events.on(UnitCreateEvent.class, e -> {
|
||||||
if(campaign() && e.unit.getTeam() == player.getTeam()){
|
if(campaign() && e.unit.team() == player.team()){
|
||||||
SStat.unitsBuilt.add();
|
SStat.unitsBuilt.add();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -866,7 +866,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
Array<Player> players = new Array<>();
|
Array<Player> players = new Array<>();
|
||||||
for(Player p : playerGroup.all()){
|
for(Player p : playerGroup.all()){
|
||||||
players.add(p);
|
players.add(p);
|
||||||
p.setDead(true);
|
p.dead(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
logic.reset();
|
logic.reset();
|
||||||
@@ -881,7 +881,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
|
|
||||||
p.reset();
|
p.reset();
|
||||||
if(state.rules.pvp){
|
if(state.rules.pvp){
|
||||||
p.setTeam(netServer.assignTeam(p, new ArrayIterable<>(players)));
|
p.team(netServer.assignTeam(p, new ArrayIterable<>(players)));
|
||||||
}
|
}
|
||||||
netServer.sendWorldData(p);
|
netServer.sendWorldData(p);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import mindustry.content.*;
|
|||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
import mindustry.core.GameState.*;
|
import mindustry.core.GameState.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.entities.type.*;
|
|
||||||
import mindustry.entities.type.base.*;
|
import mindustry.entities.type.base.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
@@ -143,12 +142,12 @@ public class ApplicationTests{
|
|||||||
void blockInventories(){
|
void blockInventories(){
|
||||||
multiblock();
|
multiblock();
|
||||||
Tile tile = world.tile(4, 4);
|
Tile tile = world.tile(4, 4);
|
||||||
tile.entity.getItems().add(Items.coal, 5);
|
tile.entity.items().add(Items.coal, 5);
|
||||||
tile.entity.getItems().add(Items.titanium, 50);
|
tile.entity.items().add(Items.titanium, 50);
|
||||||
assertEquals(tile.entity.getItems().total(), 55);
|
assertEquals(tile.entity.items().total(), 55);
|
||||||
tile.entity.getItems().remove(Items.phasefabric, 10);
|
tile.entity.items().remove(Items.phasefabric, 10);
|
||||||
tile.entity.getItems().remove(Items.titanium, 10);
|
tile.entity.items().remove(Items.titanium, 10);
|
||||||
assertEquals(tile.entity.getItems().total(), 45);
|
assertEquals(tile.entity.items().total(), 45);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -422,7 +421,7 @@ public class ApplicationTests{
|
|||||||
Tile core = world.tile(5, 5);
|
Tile core = world.tile(5, 5);
|
||||||
core.set(Blocks.coreShard, Team.sharded);
|
core.set(Blocks.coreShard, Team.sharded);
|
||||||
for(Item item : content.items()){
|
for(Item item : content.items()){
|
||||||
core.entity.getItems().set(item, 3000);
|
core.entity.items().set(item, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(core.entity, state.teams.get(Team.sharded).core());
|
assertEquals(core.entity, state.teams.get(Team.sharded).core());
|
||||||
@@ -439,12 +438,12 @@ public class ApplicationTests{
|
|||||||
assertEquals(capacity - 1, deposited);
|
assertEquals(capacity - 1, deposited);
|
||||||
|
|
||||||
tile.block().handleStack(item, capacity - 1, tile, unit);
|
tile.block().handleStack(item, capacity - 1, tile, unit);
|
||||||
assertEquals(tile.entity.getItems().get(item), capacity - 1);
|
assertEquals(tile.entity.items().get(item), capacity - 1);
|
||||||
|
|
||||||
int overflow = tile.block().acceptStack(item, 10, tile, unit);
|
int overflow = tile.block().acceptStack(item, 10, tile, unit);
|
||||||
assertEquals(1, overflow);
|
assertEquals(1, overflow);
|
||||||
|
|
||||||
tile.block().handleStack(item, 1, tile, unit);
|
tile.block().handleStack(item, 1, tile, unit);
|
||||||
assertEquals(capacity, tile.entity.getItems().get(item));
|
assertEquals(capacity, tile.entity.items().get(item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,13 +87,13 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
|||||||
createGenerator(inputType);
|
createGenerator(inputType);
|
||||||
assertTrue(generator.acceptLiquid(tile, null, liquid, availableLiquidAmount), inputType + " | " + parameterDescription + ": Liquids which will be declined by the generator don't need to be tested - The code won't be called for those cases.");
|
assertTrue(generator.acceptLiquid(tile, null, liquid, availableLiquidAmount), inputType + " | " + parameterDescription + ": Liquids which will be declined by the generator don't need to be tested - The code won't be called for those cases.");
|
||||||
|
|
||||||
entity.getLiquids().add(liquid, availableLiquidAmount);
|
entity.liquids().add(liquid, availableLiquidAmount);
|
||||||
entity.cons.update();
|
entity.cons.update();
|
||||||
|
|
||||||
// Perform an update on the generator once - This should use up any resource up to the maximum liquid usage
|
// Perform an update on the generator once - This should use up any resource up to the maximum liquid usage
|
||||||
generator.update(tile);
|
generator.update(tile);
|
||||||
|
|
||||||
assertEquals(expectedRemainingLiquidAmount, entity.getLiquids().get(liquid), inputType + " | " + parameterDescription + ": Remaining liquid amount mismatch.");
|
assertEquals(expectedRemainingLiquidAmount, entity.liquids().get(liquid), inputType + " | " + parameterDescription + ": Remaining liquid amount mismatch.");
|
||||||
assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch.");
|
assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
|||||||
assertTrue(generator.acceptItem(item, tile, null), inputType + " | " + parameterDescription + ": Items which will be declined by the generator don't need to be tested - The code won't be called for those cases.");
|
assertTrue(generator.acceptItem(item, tile, null), inputType + " | " + parameterDescription + ": Items which will be declined by the generator don't need to be tested - The code won't be called for those cases.");
|
||||||
|
|
||||||
if(amount > 0){
|
if(amount > 0){
|
||||||
entity.getItems().add(item, amount);
|
entity.items().add(item, amount);
|
||||||
}
|
}
|
||||||
entity.cons.update();
|
entity.cons.update();
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
|||||||
try{
|
try{
|
||||||
generator.update(tile);
|
generator.update(tile);
|
||||||
|
|
||||||
assertEquals(expectedRemainingItemAmount, entity.getItems().get(item), inputType + " | " + parameterDescription + ": Remaining item amount mismatch.");
|
assertEquals(expectedRemainingItemAmount, entity.items().get(item), inputType + " | " + parameterDescription + ": Remaining item amount mismatch.");
|
||||||
assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch.");
|
assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch.");
|
||||||
}catch(NullPointerException e){
|
}catch(NullPointerException e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -162,7 +162,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
|||||||
createGenerator(inputType);
|
createGenerator(inputType);
|
||||||
|
|
||||||
// Burn a single coal and test for the duration
|
// Burn a single coal and test for the duration
|
||||||
entity.getItems().add(Items.coal, 1);
|
entity.items().add(Items.coal, 1);
|
||||||
entity.cons.update();
|
entity.cons.update();
|
||||||
generator.update(tile);
|
generator.update(tile);
|
||||||
|
|
||||||
|
|||||||
@@ -87,19 +87,19 @@ public class PowerTestFixture{
|
|||||||
|
|
||||||
// Simulate the "changed" method. Calling it through reflections would require half the game to be initialized.
|
// Simulate the "changed" method. Calling it through reflections would require half the game to be initialized.
|
||||||
tile.entity = block.newEntity().init(tile, false);
|
tile.entity = block.newEntity().init(tile, false);
|
||||||
tile.entity.getCons() = new ConsumeModule(tile.entity);
|
tile.entity.cons() = new ConsumeModule(tile.entity);
|
||||||
if(block.hasItems) tile.entity.getItems() = new ItemModule();
|
if(block.hasItems) tile.entity.items() = new ItemModule();
|
||||||
if(block.hasLiquids) tile.entity.getLiquids() = new LiquidModule();
|
if(block.hasLiquids) tile.entity.liquids() = new LiquidModule();
|
||||||
if(block.hasPower){
|
if(block.hasPower){
|
||||||
tile.entity.getPower() = new PowerModule();
|
tile.entity.power() = new PowerModule();
|
||||||
tile.entity.getPower().graph = new PowerGraph(){
|
tile.entity.power().graph = new PowerGraph(){
|
||||||
//assume there's always something consuming power
|
//assume there's always something consuming power
|
||||||
@Override
|
@Override
|
||||||
public float getUsageFraction(){
|
public float getUsageFraction(){
|
||||||
return 1f;
|
return 1f;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
tile.entity.getPower().graph.add(tile);
|
tile.entity.power().graph.add(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign incredibly high health so the block does not get destroyed on e.g. burning Blast Compound
|
// Assign incredibly high health so the block does not get destroyed on e.g. burning Blast Compound
|
||||||
|
|||||||
Reference in New Issue
Block a user