Remote unlock tweaks

This commit is contained in:
Anuken
2021-08-18 17:52:59 -04:00
parent ba48373bbc
commit a94735c5a5
3 changed files with 15 additions and 7 deletions
@@ -149,9 +149,17 @@ public abstract class UnlockableContent extends MappableContent{
} }
} }
public boolean unlockedNowHost(){
if(!state.isCampaign()) return true;
return net != null && net.client() ?
alwaysUnlocked || state.rules.researched.contains(name) :
unlocked || alwaysUnlocked;
}
public boolean unlocked(){ public boolean unlocked(){
if(net != null && net.client()) return alwaysUnlocked || state.rules.researched.contains(name); return net != null && net.client() ?
return unlocked || alwaysUnlocked; alwaysUnlocked || unlocked || state.rules.researched.contains(name) :
unlocked || alwaysUnlocked;
} }
/** Locks this content again. */ /** Locks this content again. */
@@ -302,7 +302,7 @@ public class ConstructBlock extends Block{
int accumulated = (int)(accumulator[i]); //get amount int accumulated = (int)(accumulator[i]); //get amount
if(clampedAmount > 0 && accumulated > 0){ //if it's positive, add it to the core if(clampedAmount > 0 && accumulated > 0){ //if it's positive, add it to the core
if(core != null && requirements[i].item.unlockedNow()){ //only accept items that are unlocked if(core != null && requirements[i].item.unlockedNowHost()){ //only accept items that are unlocked
int accepting = Math.min(accumulated, core.storageCapacity - core.items.get(requirements[i].item)); int accepting = Math.min(accumulated, core.storageCapacity - core.items.get(requirements[i].item));
//transfer items directly, as this is not production. //transfer items directly, as this is not production.
core.items.add(requirements[i].item, accepting); core.items.add(requirements[i].item, accepting);
@@ -126,7 +126,7 @@ public class Reconstructor extends UnitBlock{
var upgrade = upgrade(pay.unit.type); var upgrade = upgrade(pay.unit.type);
if(upgrade != null){ if(upgrade != null){
if(!upgrade.unlockedNow()){ if(!upgrade.unlockedNowHost()){
//flash "not researched" //flash "not researched"
pay.showOverlay(Icon.tree); pay.showOverlay(Icon.tree);
} }
@@ -137,7 +137,7 @@ public class Reconstructor extends UnitBlock{
} }
} }
return upgrade != null && upgrade.unlockedNow() && !upgrade.isBanned(); return upgrade != null && upgrade.unlockedNowHost() && !upgrade.isBanned();
} }
@Override @Override
@@ -232,7 +232,7 @@ public class Reconstructor extends UnitBlock{
if(payload == null) return null; if(payload == null) return null;
UnitType t = upgrade(payload.unit.type); UnitType t = upgrade(payload.unit.type);
return t != null && t.unlockedNow() ? t : null; return t != null && t.unlockedNowHost() ? t : null;
} }
public boolean constructing(){ public boolean constructing(){
@@ -241,7 +241,7 @@ public class Reconstructor extends UnitBlock{
public boolean hasUpgrade(UnitType type){ public boolean hasUpgrade(UnitType type){
UnitType t = upgrade(type); UnitType t = upgrade(type);
return t != null && t.unlockedNow() && !type.isBanned(); return t != null && t.unlockedNowHost() && !type.isBanned();
} }
public UnitType upgrade(UnitType type){ public UnitType upgrade(UnitType type){