Add Status Effect Stats to Core Database (#4883)
* Status Effect Stats * import cleanup * Add Sk7725's icons Tinting still a WIP Co-authored-by: Leonwang4234 <62972692+Leonwang4234@users.noreply.github.com>
This commit is contained in:
@@ -26,7 +26,7 @@ public class StatusEffects implements ContentList{
|
||||
|
||||
init(() -> {
|
||||
opposite(wet, freezing);
|
||||
trans(tarred, ((unit, time, newTime, result) -> {
|
||||
affinity(tarred, ((unit, time, newTime, result) -> {
|
||||
unit.damagePierce(8f);
|
||||
Fx.burning.at(unit.x + Mathf.range(unit.bounds() / 2f), unit.y + Mathf.range(unit.bounds() / 2f));
|
||||
result.set(burning, Math.min(time + newTime, 300f));
|
||||
@@ -43,7 +43,7 @@ public class StatusEffects implements ContentList{
|
||||
init(() -> {
|
||||
opposite(melting, burning);
|
||||
|
||||
trans(blasted, ((unit, time, newTime, result) -> {
|
||||
affinity(blasted, ((unit, time, newTime, result) -> {
|
||||
unit.damagePierce(18f);
|
||||
result.set(freezing, time);
|
||||
}));
|
||||
@@ -67,7 +67,7 @@ public class StatusEffects implements ContentList{
|
||||
effectChance = 0.09f;
|
||||
|
||||
init(() -> {
|
||||
trans(shocked, ((unit, time, newTime, result) -> {
|
||||
affinity(shocked, ((unit, time, newTime, result) -> {
|
||||
unit.damagePierce(14f);
|
||||
if(unit.team == state.rules.waveTeam){
|
||||
Events.fire(Trigger.shock);
|
||||
@@ -94,7 +94,7 @@ public class StatusEffects implements ContentList{
|
||||
|
||||
init(() -> {
|
||||
opposite(wet, freezing);
|
||||
trans(tarred, ((unit, time, newTime, result) -> {
|
||||
affinity(tarred, ((unit, time, newTime, result) -> {
|
||||
unit.damagePierce(8f);
|
||||
Fx.burning.at(unit.x + Mathf.range(unit.bounds() / 2f), unit.y + Mathf.range(unit.bounds() / 2f));
|
||||
result.set(melting, Math.min(time + newTime, 200f));
|
||||
@@ -123,8 +123,8 @@ public class StatusEffects implements ContentList{
|
||||
effect = Fx.oily;
|
||||
|
||||
init(() -> {
|
||||
trans(melting, ((unit, time, newTime, result) -> result.set(melting, newTime + time)));
|
||||
trans(burning, ((unit, time, newTime, result) -> result.set(burning, newTime + time)));
|
||||
affinity(melting, ((unit, time, newTime, result) -> result.set(melting, newTime + time)));
|
||||
affinity(burning, ((unit, time, newTime, result) -> result.set(burning, newTime + time)));
|
||||
});
|
||||
}};
|
||||
|
||||
|
||||
@@ -278,6 +278,10 @@ public class ContentLoader{
|
||||
return getByID(ContentType.bullet, id);
|
||||
}
|
||||
|
||||
public Seq<StatusEffect> statusEffects(){
|
||||
return getBy(ContentType.status);
|
||||
}
|
||||
|
||||
public Seq<SectorPreset> sectors(){
|
||||
return getBy(ContentType.sector);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mindustry.type;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
@@ -9,8 +10,10 @@ import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.meta.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
public class StatusEffect extends MappableContent{
|
||||
public class StatusEffect extends UnlockableContent{
|
||||
/** Damage dealt by the unit with the effect. */
|
||||
public float damageMultiplier = 1f;
|
||||
/** Unit health multiplier. */
|
||||
@@ -40,6 +43,9 @@ public class StatusEffect extends MappableContent{
|
||||
/** Called on init. */
|
||||
protected Runnable initblock = () -> {};
|
||||
|
||||
public ObjectSet<StatusEffect> affinities = new ObjectSet<>();
|
||||
public ObjectSet<StatusEffect> opposites = new ObjectSet<>();
|
||||
|
||||
public StatusEffect(String name){
|
||||
super(name);
|
||||
}
|
||||
@@ -53,6 +59,46 @@ public class StatusEffect extends MappableContent{
|
||||
this.initblock = run;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden(){
|
||||
return localizedName.equals(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
if(damageMultiplier != 1){
|
||||
stats.addPercent(Stat.damageMultiplier, damageMultiplier);
|
||||
}
|
||||
|
||||
if(healthMultiplier != 1){
|
||||
stats.addPercent(Stat.healthMultiplier, healthMultiplier);
|
||||
}
|
||||
|
||||
if(speedMultiplier != 1){
|
||||
stats.addPercent(Stat.speedMultiplier, speedMultiplier);
|
||||
}
|
||||
|
||||
if(reloadMultiplier != 1){
|
||||
stats.addPercent(Stat.reloadMultiplier, reloadMultiplier);
|
||||
}
|
||||
|
||||
if(buildSpeedMultiplier != 1){
|
||||
stats.addPercent(Stat.buildSpeedMultiplier, buildSpeedMultiplier);
|
||||
}
|
||||
|
||||
if(damage > 0){
|
||||
stats.add(Stat.damage, damage * 60f, StatUnit.perSecond);
|
||||
}
|
||||
|
||||
for(StatusEffect e : affinities){
|
||||
stats.add(Stat.affinities, e.toString(), StatUnit.none);
|
||||
}
|
||||
|
||||
for(StatusEffect e : opposites){
|
||||
stats.add(Stat.opposites, e.toString(), StatUnit.none);
|
||||
}
|
||||
}
|
||||
|
||||
/** Runs every tick on the affected unit while time is greater than 0. */
|
||||
public void update(Unit unit, float time){
|
||||
if(damage > 0){
|
||||
@@ -72,8 +118,16 @@ public class StatusEffect extends MappableContent{
|
||||
effect.transitions.put(this, handler);
|
||||
}
|
||||
|
||||
protected void affinity(StatusEffect effect, TransitionHandler handler){
|
||||
affinities.add(effect);
|
||||
effect.affinities.add(this);
|
||||
trans(effect, handler);
|
||||
}
|
||||
|
||||
protected void opposite(StatusEffect... effect){
|
||||
opposites.addAll(effect);
|
||||
for(StatusEffect sup : effect){
|
||||
sup.opposites.add(this);
|
||||
trans(sup, (unit, time, newTime, result) -> {
|
||||
time -= newTime * 0.5f;
|
||||
if(time > 0){
|
||||
@@ -108,6 +162,11 @@ public class StatusEffect extends MappableContent{
|
||||
return result.set(to, newTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return localizedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentType getContentType(){
|
||||
return ContentType.status;
|
||||
|
||||
@@ -34,6 +34,12 @@ public enum Stat{
|
||||
canBoost,
|
||||
maxUnits,
|
||||
|
||||
damageMultiplier,
|
||||
healthMultiplier,
|
||||
speedMultiplier,
|
||||
reloadMultiplier,
|
||||
buildSpeedMultiplier,
|
||||
|
||||
itemCapacity(StatCat.items),
|
||||
itemsMoved(StatCat.items),
|
||||
launchTime(StatCat.items),
|
||||
@@ -78,7 +84,8 @@ public enum Stat{
|
||||
|
||||
booster(StatCat.optional),
|
||||
boostEffect(StatCat.optional),
|
||||
affinities(StatCat.optional);
|
||||
affinities(StatCat.optional),
|
||||
opposites(StatCat.optional);
|
||||
|
||||
public final StatCat category;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user