mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-31 01:44:22 +07:00
Researched list is now UnlockableContent
This commit is contained in:
parent
950716c70d
commit
5d4ece62d0
@ -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));
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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. */
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user