Campaign core item incineration + better idle gen
This commit is contained in:
@@ -157,6 +157,7 @@ public class CoreBlock extends StorageBlock{
|
||||
public int storageCapacity;
|
||||
//note that this unit is never actually used for control; the possession handler makes the player respawn when this unit is controlled
|
||||
public BlockUnitc unit = Nulls.blockUnit;
|
||||
public boolean noEffect = false;
|
||||
|
||||
@Override
|
||||
public void created(){
|
||||
@@ -195,7 +196,7 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return items.get(item) < getMaximumAccepted(item);
|
||||
return items.get(item) < getMaximumAccepted(item) || incinerate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -264,6 +265,10 @@ public class CoreBlock extends StorageBlock{
|
||||
return tile instanceof StorageBuild && (((StorageBuild)tile).linkedCore == core || ((StorageBuild)tile).linkedCore == null);
|
||||
}
|
||||
|
||||
public boolean incinerate(){
|
||||
return state.isCampaign();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float handleDamage(float amount){
|
||||
if(player != null && team == player.team()){
|
||||
@@ -298,16 +303,35 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void placed(){
|
||||
super.placed();
|
||||
state.teams.registerCore(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemTaken(Item item){
|
||||
if(state.isCampaign()){
|
||||
//update item taken amount
|
||||
state.secinfo.handleCoreItem(item, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Building source, Item item){
|
||||
if(net.server() || !net.active()){
|
||||
super.handleItem(source, item);
|
||||
|
||||
if(items.get(item) >= getMaximumAccepted(item)){
|
||||
//create item incineration effect at random intervals
|
||||
if(!noEffect){
|
||||
incinerateEffect(this, source);
|
||||
}
|
||||
noEffect = false;
|
||||
}else{
|
||||
super.handleItem(source, item);
|
||||
}
|
||||
|
||||
if(state.rules.tutorial){
|
||||
Events.fire(new CoreItemDeliverEvent());
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package mindustry.world.blocks.storage;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.storage.CoreBlock.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class StorageBlock extends Block{
|
||||
@@ -22,6 +25,16 @@ public class StorageBlock extends Block{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void incinerateEffect(Building self, Building source){
|
||||
if(Mathf.chance(0.1)){
|
||||
Tile edge = Edges.getFacingEdge(source, self);
|
||||
Tile edge2 = Edges.getFacingEdge(self, source);
|
||||
if(edge != null && edge2 != null){
|
||||
Fx.fuelburn.at((edge.worldx() + edge2.worldx())/2f, (edge.worldy() + edge2.worldy())/2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class StorageBuild extends Building{
|
||||
protected @Nullable Building linkedCore;
|
||||
|
||||
@@ -30,6 +43,17 @@ public class StorageBlock extends Block{
|
||||
return linkedCore != null ? linkedCore.acceptItem(source, item) : items.get(item) < getMaximumAccepted(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Building source, Item item){
|
||||
if(linkedCore != null){
|
||||
incinerateEffect(this, source);
|
||||
((CoreBuild)linkedCore).noEffect = true;
|
||||
linkedCore.handleItem(source, item);
|
||||
}else{
|
||||
super.handleItem(source, item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumAccepted(Item item){
|
||||
return itemCapacity;
|
||||
|
||||
@@ -66,6 +66,7 @@ public class Unloader extends Block{
|
||||
}else{
|
||||
other.items.remove(item, 1);
|
||||
}
|
||||
other.itemTaken(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user