Researched list is now UnlockableContent

This commit is contained in:
Anuken 2024-10-13 23:16:44 -04:00
parent 950716c70d
commit 5d4ece62d0
4 changed files with 16 additions and 12 deletions

View File

@ -395,7 +395,7 @@ public class Logic implements ApplicationListener{
if(!(content instanceof UnlockableContent u)) return;
boolean was = u.unlockedNow();
state.rules.researched.add(u.name);
state.rules.researched.add(u);
if(!was){
Events.fire(new UnlockEvent(u));

View File

@ -222,17 +222,25 @@ public abstract class UnlockableContent extends MappableContent{
}
}
/** @return in multiplayer, whether this is unlocked for the host player, otherwise, whether it is unlocked for the local player (same as unlocked()) */
public boolean unlockedNowHost(){
if(!state.isCampaign()) return true;
return !state.isCampaign() || unlockedHost();
}
/** @return in multiplayer, whether this is unlocked for the host player, otherwise, whether it is unlocked for the local player (same as unlocked()) */
public boolean unlockedHost(){
return net != null && net.client() ?
alwaysUnlocked || state.rules.researched.contains(name) :
alwaysUnlocked || state.rules.researched.contains(this) :
unlocked || alwaysUnlocked;
}
/** @return whether this content is unlocked, or the player is in a custom (non-campaign) game. */
public boolean unlockedNow(){
return unlocked() || !state.isCampaign();
}
public boolean unlocked(){
return net != null && net.client() ?
alwaysUnlocked || unlocked || state.rules.researched.contains(name) :
alwaysUnlocked || unlocked || state.rules.researched.contains(this) :
unlocked || alwaysUnlocked;
}
@ -244,11 +252,6 @@ public abstract class UnlockableContent extends MappableContent{
}
}
/** @return whether this content is unlocked, or the player is in a custom (non-campaign) game. */
public boolean unlockedNow(){
return unlocked() || !state.isCampaign();
}
public boolean locked(){
return !unlocked();
}

View File

@ -7,6 +7,7 @@ import arc.util.serialization.*;
import arc.util.serialization.Json.*;
import mindustry.*;
import mindustry.content.*;
import mindustry.ctype.*;
import mindustry.graphics.g3d.*;
import mindustry.io.*;
import mindustry.type.*;
@ -160,7 +161,7 @@ public class Rules{
/** Reveals blocks normally hidden by build visibility. */
public ObjectSet<Block> revealedBlocks = new ObjectSet<>();
/** Unlocked content names. Only used in multiplayer when the campaign is enabled. */
public ObjectSet<String> researched = new ObjectSet<>();
public ObjectSet<UnlockableContent> researched = new ObjectSet<>();
/** In-map objective executor. */
public MapObjectives objectives = new MapObjectives();
/** Flags set by objectives. Used in world processors. */

View File

@ -30,7 +30,7 @@ public class NetworkIO{
for(ContentType type : ContentType.all){
for(Content c : content.getBy(type)){
if(c instanceof UnlockableContent u && u.unlocked() && u.techNode != null){
state.rules.researched.add(u.name);
state.rules.researched.add(u);
}
}
}