Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features
Conflicts: core/assets/icons/icons.properties core/assets/logicids.dat core/src/mindustry/ui/dialogs/PlanetDialog.java core/src/mindustry/world/blocks/distribution/ItemBridge.java core/src/mindustry/world/blocks/liquid/LiquidExtendingBridge.java core/src/mindustry/world/blocks/storage/StorageBlock.java gradle.properties
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
package mindustry.entities.comp;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.blocks.units.*;
|
||||
|
||||
@Component
|
||||
abstract class AmmoDistributeComp implements Unitc{
|
||||
@Import float x, y;
|
||||
@Import UnitType type;
|
||||
@Import Team team;
|
||||
@Import float ammo;
|
||||
|
||||
private transient float ammoCooldown;
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
if(ammoCooldown > 0f) ammoCooldown -= Time.delta;
|
||||
|
||||
if(ammo > 0 && ammoCooldown <= 0f && ResupplyPoint.resupply(team, x, y, type.ammoResupplyRange, Math.min(type.ammoResupplyAmount, ammo), type.ammoType.color, u -> u != self())){
|
||||
ammo -= Math.min(type.ammoResupplyAmount, ammo);
|
||||
ammoCooldown = 5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ abstract class BuilderComp implements Posc, Statusc, Teamc, Rotc{
|
||||
|
||||
if(!(tile.build instanceof ConstructBuild cb)){
|
||||
if(!current.initialized && !current.breaking && Build.validPlace(current.block, team, current.x, current.y, current.rotation)){
|
||||
boolean hasAll = infinite || current.isRotation(team) || !Structs.contains(current.block.requirements, i -> core != null && !core.items.has(i.item));
|
||||
boolean hasAll = infinite || current.isRotation(team) || !Structs.contains(current.block.requirements, i -> core != null && !core.items.has(i.item, Math.min(Mathf.round(i.amount * state.rules.buildCostMultiplier), 1)));
|
||||
|
||||
if(hasAll){
|
||||
Call.beginPlace(self(), current.block, team, current.x, current.y, current.rotation);
|
||||
@@ -176,7 +176,7 @@ abstract class BuilderComp implements Posc, Statusc, Teamc, Rotc{
|
||||
/** @return whether this request should be skipped, in favor of the next one. */
|
||||
boolean shouldSkip(BuildPlan request, @Nullable Building core){
|
||||
//requests that you have at least *started* are considered
|
||||
if(state.rules.infiniteResources || team.rules().infiniteResources || request.breaking || core == null || request.isRotation(team)) return false;
|
||||
if(state.rules.infiniteResources || team.rules().infiniteResources || request.breaking || core == null || request.isRotation(team) || (isBuilding() && !within(plans.last(), buildingRange))) return false;
|
||||
|
||||
return (request.stuck && !core.items.has(request.block.requirements)) || (Structs.contains(request.block.requirements, i -> !core.items.has(i.item, Math.min(i.amount, 15)) && Mathf.round(i.amount * state.rules.buildCostMultiplier) > 0) && !request.initialized);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
static final float timeToSleep = 60f * 1, timeToUncontrol = 60f * 6;
|
||||
static final ObjectSet<Building> tmpTiles = new ObjectSet<>();
|
||||
static final Seq<Building> tempBuilds = new Seq<>();
|
||||
static final BuildTeamChangeEvent teamChangeEvent = new BuildTeamChangeEvent();
|
||||
static int sleepingEntities = 0;
|
||||
|
||||
@Import float x, y, health, maxHealth;
|
||||
@@ -63,6 +64,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
transient boolean enabled = true;
|
||||
transient float enabledControlTime;
|
||||
transient String lastAccessed;
|
||||
transient boolean wasDamaged; //used only by the indexer
|
||||
|
||||
PowerModule power;
|
||||
ItemModule items;
|
||||
@@ -158,7 +160,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
}
|
||||
|
||||
public final void readBase(Reads read){
|
||||
health = read.f();
|
||||
//cap health by block health in case of nerfs
|
||||
health = Math.min(read.f(), block.health);
|
||||
byte rot = read.b();
|
||||
team = Team.get(read.b());
|
||||
|
||||
@@ -1071,7 +1074,10 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
}
|
||||
|
||||
public String getDisplayName(){
|
||||
return block.localizedName;
|
||||
//derelict team icon currently doesn't display
|
||||
return team == Team.derelict ?
|
||||
block.localizedName + "\n" + Core.bundle.get("block.derelict") :
|
||||
block.localizedName + (team == player.team() || team.emoji.isEmpty() ? "" : " " + team.emoji);
|
||||
}
|
||||
|
||||
public TextureRegion getDisplayIcon(){
|
||||
@@ -1100,7 +1106,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
table.row();
|
||||
table.table(this::displayConsumption).growX();
|
||||
|
||||
boolean displayFlow = (block.category == Category.distribution || block.category == Category.liquid) && Core.settings.getBool("flow") && block.displayFlow;
|
||||
boolean displayFlow = (block.category == Category.distribution || block.category == Category.liquid) && block.displayFlow;
|
||||
|
||||
if(displayFlow){
|
||||
String ps = " " + StatUnit.perSecond.localized();
|
||||
@@ -1254,9 +1260,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
|
||||
/** Changes this building's team in a safe manner. */
|
||||
public void changeTeam(Team next){
|
||||
Team last = this.team;
|
||||
indexer.removeIndex(tile);
|
||||
this.team = next;
|
||||
indexer.addIndex(tile);
|
||||
Events.fire(teamChangeEvent.set(last, self()));
|
||||
}
|
||||
|
||||
public boolean canPickup(){
|
||||
@@ -1342,6 +1350,18 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
return tile.build == self() && !dead();
|
||||
}
|
||||
|
||||
@MethodPriority(100)
|
||||
@Override
|
||||
public void heal(){
|
||||
indexer.notifyBuildHealed(self());
|
||||
}
|
||||
|
||||
@MethodPriority(100)
|
||||
@Override
|
||||
public void heal(float amount){
|
||||
indexer.notifyBuildHealed(self());
|
||||
}
|
||||
|
||||
@Override
|
||||
public float hitSize(){
|
||||
return tile.block().size * tilesize;
|
||||
|
||||
@@ -81,7 +81,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
|
||||
}
|
||||
|
||||
public boolean hasCollided(int id){
|
||||
return collided.size != 0 && !collided.contains(id);
|
||||
return collided.size != 0 && collided.contains(id);
|
||||
}
|
||||
|
||||
@Replace
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mindustry.entities.comp;
|
||||
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
@@ -20,16 +21,29 @@ import static mindustry.entities.Puddles.*;
|
||||
@EntityDef(value = {Puddlec.class}, pooled = true)
|
||||
@Component(base = true)
|
||||
abstract class PuddleComp implements Posc, Puddlec, Drawc{
|
||||
private static final int maxGeneration = 2;
|
||||
private static final Rect rect = new Rect(), rect2 = new Rect();
|
||||
private static int seeds;
|
||||
|
||||
private static Puddle paramPuddle;
|
||||
private static Cons<Unit> unitCons = unit -> {
|
||||
if(unit.isGrounded() && !unit.hovering){
|
||||
unit.hitbox(rect2);
|
||||
if(rect.overlaps(rect2)){
|
||||
unit.apply(paramPuddle.liquid.effect, 60 * 2);
|
||||
|
||||
if(unit.vel.len2() > 0.1f * 0.1f){
|
||||
Fx.ripple.at(unit.x, unit.y, unit.type.rippleScale, paramPuddle.liquid.color);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Import int id;
|
||||
@Import float x, y;
|
||||
|
||||
transient float accepting, updateTime, lastRipple;
|
||||
transient private boolean mismatch = false;
|
||||
transient float accepting, updateTime, lastRipple = Time.time + Mathf.random(40f);
|
||||
float amount;
|
||||
int generation;
|
||||
Tile tile;
|
||||
Liquid liquid;
|
||||
|
||||
@@ -39,46 +53,45 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
//update code
|
||||
float addSpeed = accepting > 0 ? 3f : 0f;
|
||||
|
||||
amount -= Time.delta * (1f - liquid.viscosity) / (5f + addSpeed);
|
||||
amount += accepting;
|
||||
accepting = 0f;
|
||||
|
||||
if(amount >= maxLiquid / 1.5f && generation < maxGeneration){
|
||||
if(amount >= maxLiquid / 1.5f){
|
||||
float deposited = Math.min((amount - maxLiquid / 1.5f) / 4f, 0.3f) * Time.delta;
|
||||
int targets = 0;
|
||||
for(Point2 point : Geometry.d4){
|
||||
Tile other = world.tile(tile.x + point.x, tile.y + point.y);
|
||||
if(other != null && other.block() == Blocks.air){
|
||||
Puddles.deposit(other, tile, liquid, deposited, generation + 1);
|
||||
amount -= deposited / 2f; //tweak to speed up/slow down Puddle propagation
|
||||
targets ++;
|
||||
Puddles.deposit(other, tile, liquid, deposited, false);
|
||||
}
|
||||
}
|
||||
amount -= deposited * targets;
|
||||
}
|
||||
|
||||
amount = Mathf.clamp(amount, 0, maxLiquid);
|
||||
|
||||
if(amount <= 0f){
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if(Puddles.get(tile) != self()){
|
||||
mismatch = true;
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
//effects-only code
|
||||
if(amount >= maxLiquid / 2f && updateTime <= 0f){
|
||||
Units.nearby(rect.setSize(Mathf.clamp(amount / (maxLiquid / 1.5f)) * 10f).setCenter(x, y), unit -> {
|
||||
if(unit.isGrounded() && !unit.hovering){
|
||||
unit.hitbox(rect2);
|
||||
if(rect.overlaps(rect2)){
|
||||
unit.apply(liquid.effect, 60 * 2);
|
||||
paramPuddle = self();
|
||||
|
||||
if(unit.vel.len() > 0.1){
|
||||
Fx.ripple.at(unit.x, unit.y, unit.type.rippleScale, liquid.color);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Units.nearby(rect.setSize(Mathf.clamp(amount / (maxLiquid / 1.5f)) * 10f).setCenter(x, y), unitCons);
|
||||
|
||||
if(liquid.temperature > 0.7f && (tile.build != null) && Mathf.chance(0.5)){
|
||||
if(liquid.temperature > 0.7f && tile.build != null && Mathf.chance(0.5)){
|
||||
Fires.create(tile);
|
||||
}
|
||||
|
||||
@@ -121,7 +134,9 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{
|
||||
|
||||
@Override
|
||||
public void remove(){
|
||||
Puddles.remove(tile);
|
||||
if(!mismatch){
|
||||
Puddles.remove(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -154,7 +154,7 @@ abstract class StatusComp implements Posc, Flyingc{
|
||||
|
||||
public void draw(){
|
||||
for(StatusEntry e : statuses){
|
||||
e.effect.draw(self());
|
||||
e.effect.draw(self(), e.time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,14 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
vel.approachDelta(vector, type.accel * realSpeed());
|
||||
}
|
||||
|
||||
public void rotateMove(Vec2 vec){
|
||||
moveAt(Tmp.v2.trns(rotation, vec.len()));
|
||||
|
||||
if(!vec.isZero()){
|
||||
rotation = Angles.moveToward(rotation, vec.angle(), type.rotateSpeed * Math.max(Time.delta, 1));
|
||||
}
|
||||
}
|
||||
|
||||
public void aimLook(Position pos){
|
||||
aim(pos);
|
||||
lookAt(pos);
|
||||
@@ -126,6 +134,9 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
if(isBuilding()){
|
||||
return state.rules.infiniteResources ? Float.MAX_VALUE : Math.max(type.clipSize, type.region.width) + buildingRange + tilesize*4f;
|
||||
}
|
||||
if(mining()){
|
||||
return type.clipSize + type.miningRange;
|
||||
}
|
||||
return type.clipSize;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user