Add buildSpeedMultiplier status effect (#4816)

* Make disarmed status effect prevent building

* Revert disarmed changes, add buildSpeedMultiplier status

* Add buildSpeedMultiplier to StatusComp
This commit is contained in:
Joshua Fan
2021-03-05 14:09:46 -05:00
committed by GitHub
parent 4690aae197
commit 830fe03898
3 changed files with 11 additions and 8 deletions
@@ -26,10 +26,10 @@ import java.util.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
@Component @Component
abstract class BuilderComp implements Posc, Teamc, Rotc{ abstract class BuilderComp implements Posc, Statusc, Teamc, Rotc{
static final Vec2[] vecs = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()}; static final Vec2[] vecs = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()};
@Import float x, y, rotation; @Import float x, y, rotation, buildSpeedMultiplier;
@Import UnitType type; @Import UnitType type;
@Import Team team; @Import Team team;
@@ -41,7 +41,7 @@ abstract class BuilderComp implements Posc, Teamc, Rotc{
private transient float buildAlpha = 0f; private transient float buildAlpha = 0f;
public boolean canBuild(){ public boolean canBuild(){
return type.buildSpeed > 0; return type.buildSpeed > 0 && buildSpeedMultiplier > 0;
} }
@Override @Override
@@ -126,9 +126,9 @@ abstract class BuilderComp implements Posc, Teamc, Rotc{
//otherwise, update it. //otherwise, update it.
if(current.breaking){ if(current.breaking){
entity.deconstruct(self(), core, 1f / entity.buildCost * Time.delta * type.buildSpeed * state.rules.buildSpeedMultiplier); entity.deconstruct(self(), core, 1f / entity.buildCost * Time.delta * type.buildSpeed * buildSpeedMultiplier * state.rules.buildSpeedMultiplier);
}else{ }else{
entity.construct(self(), core, 1f / entity.buildCost * Time.delta * type.buildSpeed * state.rules.buildSpeedMultiplier, current.config); entity.construct(self(), core, 1f / entity.buildCost * Time.delta * type.buildSpeed * buildSpeedMultiplier * state.rules.buildSpeedMultiplier, current.config);
} }
current.stuck = Mathf.equal(current.progress, entity.progress); current.stuck = Mathf.equal(current.progress, entity.progress);
@@ -19,7 +19,7 @@ abstract class StatusComp implements Posc, Flyingc{
private Seq<StatusEntry> statuses = new Seq<>(); private Seq<StatusEntry> statuses = new Seq<>();
private transient Bits applied = new Bits(content.getBy(ContentType.status).size); private transient Bits applied = new Bits(content.getBy(ContentType.status).size);
@ReadOnly transient float speedMultiplier = 1, damageMultiplier = 1, healthMultiplier = 1, reloadMultiplier = 1; @ReadOnly transient float speedMultiplier = 1, damageMultiplier = 1, healthMultiplier = 1, reloadMultiplier = 1, buildSpeedMultiplier = 1;
@ReadOnly transient boolean disarmed = false; @ReadOnly transient boolean disarmed = false;
@Import UnitType type; @Import UnitType type;
@@ -111,7 +111,7 @@ abstract class StatusComp implements Posc, Flyingc{
} }
applied.clear(); applied.clear();
speedMultiplier = damageMultiplier = healthMultiplier = reloadMultiplier = 1f; speedMultiplier = damageMultiplier = healthMultiplier = reloadMultiplier = buildSpeedMultiplier = 1f;
disarmed = false; disarmed = false;
if(statuses.isEmpty()) return; if(statuses.isEmpty()) return;
@@ -134,6 +134,7 @@ abstract class StatusComp implements Posc, Flyingc{
healthMultiplier *= entry.effect.healthMultiplier; healthMultiplier *= entry.effect.healthMultiplier;
damageMultiplier *= entry.effect.damageMultiplier; damageMultiplier *= entry.effect.damageMultiplier;
reloadMultiplier *= entry.effect.reloadMultiplier; reloadMultiplier *= entry.effect.reloadMultiplier;
buildSpeedMultiplier *= entry.effect.buildSpeedMultiplier;
disarmed |= entry.effect.disarm; disarmed |= entry.effect.disarm;
+3 -1
View File
@@ -15,10 +15,12 @@ public class StatusEffect extends MappableContent{
public float damageMultiplier = 1f; public float damageMultiplier = 1f;
/** Unit health multiplier. */ /** Unit health multiplier. */
public float healthMultiplier = 1f; public float healthMultiplier = 1f;
/** Unit speed multiplier */ /** Unit speed multiplier. */
public float speedMultiplier = 1f; public float speedMultiplier = 1f;
/** Unit reload multiplier. */ /** Unit reload multiplier. */
public float reloadMultiplier = 1f; public float reloadMultiplier = 1f;
/** Unit build speed multiplier. */
public float buildSpeedMultiplier = 1f;
/** Unit weapon(s) disabled. */ /** Unit weapon(s) disabled. */
public boolean disarm = false; public boolean disarm = false;
/** Damage per frame. */ /** Damage per frame. */