Removed blacklist/whitelist-based planet item system

This commit is contained in:
Anuken 2024-08-22 04:51:37 -04:00
parent 074684e935
commit 8df50a67ec
12 changed files with 24 additions and 59 deletions

View File

@ -65,7 +65,6 @@ public class Planets{
clearSectorOnLose = true;
defaultCore = Blocks.coreBastion;
iconColor = Color.valueOf("ff9266");
hiddenItems.addAll(Items.serpuloItems).removeAll(Items.erekirItems);
enemyBuildSpeedMultiplier = 0.4f;
//TODO disallowed for now
@ -152,7 +151,6 @@ public class Planets{
startSector = 15;
alwaysUnlocked = true;
landCloudColor = Pal.spore.cpy().a(0.5f);
hiddenItems.addAll(Items.erekirItems).removeAll(Items.serpuloItems);
}};
verilus = makeAsteroid("verlius", sun, Blocks.stoneWall, Blocks.iceWall, 0.5f, 12, 2f, gen -> {

View File

@ -143,7 +143,6 @@ public class Logic implements ApplicationListener{
//set up hidden items
state.rules.hiddenBuildItems.clear();
state.rules.hiddenBuildItems.addAll(state.rules.sector.planet.hiddenItems);
}
//save settings

View File

@ -322,7 +322,6 @@ public class World{
state.rules.env = sector.planet.defaultEnv;
state.rules.planet = sector.planet;
state.rules.hiddenBuildItems.clear();
state.rules.hiddenBuildItems.addAll(sector.planet.hiddenItems);
sector.planet.applyRules(state.rules);
sector.info.resources = content.toSeq();
sector.info.resources.sort(Structs.comps(Structs.comparing(Content::getContentType), Structs.comparingInt(c -> c.id)));

View File

@ -102,6 +102,10 @@ public abstract class UnlockableContent extends MappableContent{
uiIcon = Core.atlas.find(getContentType().name() + "-" + name + "-ui", fullIcon);
}
public boolean isOnPlanet(@Nullable Planet planet){
return planet == null || shownPlanets.isEmpty() || shownPlanets.contains(planet);
}
public int getLogicId(){
return logicVars.lookupLogicId(this);
}

View File

@ -153,8 +153,11 @@ public class Rules{
public ObjectSet<Block> revealedBlocks = new ObjectSet<>();
/** Unlocked content names. Only used in multiplayer when the campaign is enabled. */
public ObjectSet<String> researched = new ObjectSet<>();
/** Block containing these items as requirements are hidden. */
public ObjectSet<Item> hiddenBuildItems = Items.erekirOnlyItems.asSet();
/**
* Block containing these items as requirements are hidden.
* @deprecated May be removed in the near future.
* */
public @Deprecated ObjectSet<Item> hiddenBuildItems = Items.erekirOnlyItems.asSet();
/** In-map objective executor. */
public MapObjectives objectives = new MapObjectives();
/** Flags set by objectives. Used in world processors. */

View File

@ -34,7 +34,7 @@ public class BaseGenerator{
Seq<Block> wallsSmall = content.blocks().select(b -> b instanceof Wall && b.isVanilla() && b.size == size
&& !b.insulated && b.buildVisibility == BuildVisibility.shown
&& !(b instanceof Door)
&& !(Structs.contains(b.requirements, i -> state.rules.hiddenBuildItems.contains(i.item))));
&& b.isOnPlanet(state.getPlanet()));
wallsSmall.sort(b -> b.buildCost);
return wallsSmall.getFrac(difficulty * 0.91f);
}

View File

@ -81,12 +81,12 @@ public class GameService{
}
private void registerEvents(){
allTransportSerpulo = content.blocks().select(b -> b.category == Category.distribution && b.isVisibleOn(Planets.serpulo) && b.isVanilla() && b.buildVisibility == BuildVisibility.shown).toArray(Block.class);
allTransportErekir = content.blocks().select(b -> b.category == Category.distribution && b.isVisibleOn(Planets.erekir) && b.isVanilla() && b.buildVisibility == BuildVisibility.shown).toArray(Block.class);
allTransportSerpulo = content.blocks().select(b -> b.category == Category.distribution && b.isOnPlanet(Planets.serpulo) && b.isVanilla() && b.buildVisibility == BuildVisibility.shown).toArray(Block.class);
allTransportErekir = content.blocks().select(b -> b.category == Category.distribution && b.isOnPlanet(Planets.erekir) && b.isVanilla() && b.buildVisibility == BuildVisibility.shown).toArray(Block.class);
//cores are ignored since they're upgrades and can be skipped
allSerpuloBlocks = content.blocks().select(b -> b.synthetic() && b.isVisibleOn(Planets.serpulo) && b.isVanilla() && !(b instanceof CoreBlock) && b.buildVisibility == BuildVisibility.shown).toArray(Block.class);
allErekirBlocks = content.blocks().select(b -> b.synthetic() && b.isVisibleOn(Planets.erekir) && b.isVanilla() && !(b instanceof CoreBlock) && b.buildVisibility == BuildVisibility.shown).toArray(Block.class);
allSerpuloBlocks = content.blocks().select(b -> b.synthetic() && b.isOnPlanet(Planets.serpulo) && b.isVanilla() && !(b instanceof CoreBlock) && b.buildVisibility == BuildVisibility.shown).toArray(Block.class);
allErekirBlocks = content.blocks().select(b -> b.synthetic() && b.isOnPlanet(Planets.erekir) && b.isVanilla() && !(b instanceof CoreBlock) && b.buildVisibility == BuildVisibility.shown).toArray(Block.class);
unitsBuilt = Core.settings.getJson("units-built" , ObjectSet.class, String.class, ObjectSet::new);
blocksBuilt = Core.settings.getJson("blocks-built" , ObjectSet.class, String.class, ObjectSet::new);

View File

@ -47,8 +47,6 @@ public class Item extends UnlockableContent implements Senseable{
/** If true, this material is used by buildings. If false, this material will be incinerated in certain cores. */
public boolean buildable = true;
public boolean hidden = false;
/** For mods. Adds this item to the listed planets' hidden items Seq. */
public @Nullable Planet[] hiddenOnPlanets;
public Item(String name, Color color){
super(name);
@ -60,14 +58,9 @@ public class Item extends UnlockableContent implements Senseable{
}
@Override
public void init(){
super.init();
if(hiddenOnPlanets != null){
for(Planet planet : hiddenOnPlanets){
planet.hiddenItems.add(this);
}
}
public boolean isOnPlanet(Planet planet){
//hidden items should not appear on any planet's resource selection screen
return super.isOnPlanet(planet) && !hidden;
}
@Override

View File

@ -15,7 +15,6 @@ import mindustry.content.*;
import mindustry.content.TechTree.*;
import mindustry.ctype.*;
import mindustry.game.*;
import mindustry.game.EventType.ContentInitEvent;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.graphics.g3d.*;
@ -146,10 +145,6 @@ public class Planet extends UnlockableContent{
public @Nullable TechNode techTree;
/** TODO remove? Planets that can be launched to from this one. Made mutual in init(). */
public Seq<Planet> launchCandidates = new Seq<>();
/** Items not available on this planet. Left out for backwards compatibility. */
public Seq<Item> hiddenItems = new Seq<>();
/** The only items available on this planet, if defined. */
public Seq<Item> itemWhitelist = new Seq<>();
/** If true, all content in this planet's tech tree will be assigned this planet in their shownPlanets. */
public boolean autoAssignPlanet = true;
/** Content (usually planet-specific) that is unlocked upon landing here. */
@ -181,13 +176,6 @@ public class Planet extends UnlockableContent{
parent.updateTotalRadius();
}
//if an item whitelist exists, add everything else not in that whitelist to hidden items
Events.on(ContentInitEvent.class, e -> {
if(itemWhitelist.size > 0){
hiddenItems.addAll(content.items().select(i -> !itemWhitelist.contains(i)));
}
});
//calculate solar system
for(solarSystem = this; solarSystem.parent != null; solarSystem = solarSystem.parent);
}
@ -219,7 +207,6 @@ public class Planet extends UnlockableContent{
rules.env = defaultEnv;
rules.planet = this;
rules.hiddenBuildItems.clear();
rules.hiddenBuildItems.addAll(hiddenItems);
}
public @Nullable Sector getLastSector(){
@ -340,12 +327,9 @@ public class Planet extends UnlockableContent{
techTree = TechTree.roots.find(n -> n.planet == this);
}
if(techTree != null){
if(techTree != null && autoAssignPlanet){
techTree.addDatabaseTab(this);
if(autoAssignPlanet){
techTree.addPlanet(this);
}
techTree.addPlanet(this);
}
for(Sector sector : sectors){

View File

@ -229,19 +229,8 @@ public class CustomRulesDialog extends BaseDialog{
}
number("@rules.dropzoneradius", false, f -> rules.dropZoneRadius = f * tilesize, () -> rules.dropZoneRadius / tilesize, () -> rules.waves);
category("resourcesbuilding");
check("@rules.infiniteresources", b -> {
rules.infiniteResources = b;
//reset to serpulo if any env was enabled
if(!b && rules.hiddenBuildItems.isEmpty()){
rules.env = Planets.serpulo.defaultEnv;
rules.hiddenBuildItems.clear();
rules.hiddenBuildItems.addAll(Planets.serpulo.hiddenItems);
setup();
}
}, () -> rules.infiniteResources);
check("@rules.infiniteresources", b -> rules.infiniteResources = b, () -> rules.infiniteResources);
check("@rules.onlydepositcore", b -> rules.onlyDepositCore = b, () -> rules.onlyDepositCore);
check("@rules.derelictrepair", b -> rules.derelictRepair = b, () -> rules.derelictRepair);
check("@rules.reactorexplosions", b -> rules.reactorExplosions = b, () -> rules.reactorExplosions);

View File

@ -48,7 +48,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
ItemSeq launch = universe.getLaunchResources();
if(sector.planet.allowLaunchLoadout){
for(var item : content.items()){
if(sector.planet.hiddenItems.contains(item)){
if(!item.isOnPlanet(sector.planet)){
launch.set(item, 0);
}
}
@ -72,7 +72,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
if(destination.preset != null){
var rules = destination.preset.generator.map.rules();
for(var stack : rules.loadout){
if(!sector.planet.hiddenItems.contains(stack.item)){
if(stack.item.isOnPlanet(sector.planet)){
resources.add(stack.item, stack.amount);
}
}
@ -136,7 +136,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
ItemSeq realItems = sitems.copy();
selected.requirements().each(realItems::remove);
loadout.show(lastCapacity, realItems, out, i -> i.unlocked() && !sector.planet.hiddenItems.contains(i), out::clear, () -> {}, () -> {
loadout.show(lastCapacity, realItems, out, i -> i.unlocked() && i.isOnPlanet(sector.planet), out::clear, () -> {}, () -> {
universe.updateLaunchResources(new ItemSeq(out));
update.run();
rebuildItems.run();
@ -172,7 +172,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
Cons<Schematic> handler = s -> {
if(s.tiles.contains(tile -> !tile.block.supportsEnv(sector.planet.defaultEnv) ||
//make sure block can be built here.
(!sector.planet.hiddenItems.isEmpty() && Structs.contains(tile.block.requirements, stack -> sector.planet.hiddenItems.contains(stack.item))))){
tile.block.isOnPlanet(sector.planet))){
return;
}

View File

@ -899,10 +899,6 @@ public class Block extends UnlockableContent implements Senseable{
return !isHidden() && (state.rules.editor || (!state.rules.hideBannedBlocks || !state.rules.isBanned(this)));
}
public boolean isVisibleOn(Planet planet){
return !Structs.contains(requirements, i -> planet.hiddenItems.contains(i.item)) && (shownPlanets.isEmpty() || shownPlanets.contains(planet));
}
public boolean isPlaceable(){
return isVisible() && (!state.rules.isBanned(this) || state.rules.editor) && supportsEnv(state.rules.env);
}