SeqEffect / Auto-clear Erekir lost sectors
This commit is contained in:
@@ -226,14 +226,14 @@ public class ErekirTechTree{
|
||||
});
|
||||
});
|
||||
|
||||
node(shipAssembler, Seq.with(tmpNever), () -> {
|
||||
node(shipAssembler, () -> {
|
||||
node(UnitTypes.quell, () -> {
|
||||
node(UnitTypes.disrupt, Seq.with(tmpNever), () -> {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
node(mechAssembler, () -> {
|
||||
node(mechAssembler, Seq.with(tmpNever), () -> {
|
||||
node(UnitTypes.bulwark, () -> {
|
||||
node(UnitTypes.krepost, Seq.with(tmpNever), () -> {
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ public class Planets{
|
||||
totalRadius += 2.6f;
|
||||
lightSrcTo = 0.5f;
|
||||
lightDstFrom = 0.2f;
|
||||
clearSectorOnLose = true;
|
||||
hiddenItems.addAll(Items.serpuloItems).removeAll(Items.erekirItems);
|
||||
ruleSetter = r -> {
|
||||
r.unitCommand = true;
|
||||
|
||||
@@ -346,7 +346,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
ui.planet.hide();
|
||||
SaveSlot slot = sector.save;
|
||||
sector.planet.setLastSector(sector);
|
||||
if(slot != null && !clearSectors){
|
||||
if(slot != null && !clearSectors && (!sector.planet.clearSectorOnLose || sector.info.hasCore)){
|
||||
|
||||
try{
|
||||
boolean hadNoCore = !sector.info.hasCore;
|
||||
|
||||
@@ -280,6 +280,10 @@ public class Effect{
|
||||
return (T)data;
|
||||
}
|
||||
|
||||
public EffectContainer inner(){
|
||||
return innerContainer == null ? (innerContainer = new EffectContainer()) : innerContainer;
|
||||
}
|
||||
|
||||
public void scaled(float lifetime, Cons<EffectContainer> cons){
|
||||
if(innerContainer == null) innerContainer = new EffectContainer();
|
||||
if(time <= lifetime){
|
||||
|
||||
46
core/src/mindustry/entities/effect/SeqEffect.java
Normal file
46
core/src/mindustry/entities/effect/SeqEffect.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package mindustry.entities.effect;
|
||||
|
||||
import mindustry.entities.*;
|
||||
|
||||
/**
|
||||
* Renders multiple particle effects in sequence.
|
||||
* Will not work correctly for effects that modify life dynamically.
|
||||
* */
|
||||
public class SeqEffect extends Effect{
|
||||
public Effect[] effects = {};
|
||||
|
||||
public SeqEffect(){
|
||||
clip = 100f;
|
||||
}
|
||||
|
||||
public SeqEffect(Effect... effects){
|
||||
this();
|
||||
this.effects = effects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
lifetime = 0f;
|
||||
for(Effect f : effects){
|
||||
f.init();
|
||||
clip = Math.max(clip, f.clip);
|
||||
lifetime += f.lifetime;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(EffectContainer e){
|
||||
var cont = e.inner();
|
||||
float life = e.time, sum = 0f;
|
||||
for(int i = 0; i < effects.length; i++){
|
||||
var fx = effects[i];
|
||||
if(life <= fx.lifetime + sum){
|
||||
cont.set(e.id + i, e.color, life - sum, fx.lifetime, e.rotation, e.x, e.y, e.data);
|
||||
fx.render(cont);
|
||||
clip = Math.max(clip, fx.clip);
|
||||
break;
|
||||
}
|
||||
sum += fx.lifetime;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,8 @@ public class Planet extends UnlockableContent{
|
||||
public boolean allowSectorInvasion = false;
|
||||
/** If true, builder AI is turned on for all sectors on this planet by default. */
|
||||
public boolean defaultAI = false;
|
||||
/** If true, sectors saves are cleared when lost. */
|
||||
public boolean clearSectorOnLose = false;
|
||||
/** Sets up rules on game load for any sector on this planet. */
|
||||
public Cons<Rules> ruleSetter = r -> {};
|
||||
/** Parent body that this planet orbits around. If null, this planet is considered to be in the middle of the solar system.*/
|
||||
|
||||
Reference in New Issue
Block a user