What does MarketAPI.reapplyIndustries() do? Is it necessary when changing industries through a script or, maybe, does it read and reapply what is contained in the economy json files?
-----------------------------------------
I had someone ask about portrait overrides or otherwise adding or removing portraits, so thought this might be helpful to anyone needing info on this (Edited for a general audience):
The faction file determines what portrait png files from the graphics folder will be applied to created npcs within that faction. So, afaik all portraits are added to the campaign this way in vanilla. Its not a script but part of the JSON file that is read by the game. You should be able to add portraits to each faction's pool using scripts, though. As an example of code that modifies portraits:
Spoiler
/**
* By Morrokain
*
* Parameters: Accepts "ALL" or a faction ID which it will use to obtain that faction's portraits.
*/
public class SetPlayerPortraits extends BaseCommandPlugin {
@Override
public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {
String faction = params.get(0).getString(memoryMap);
WeightedRandomPicker<String> factionMalePortraitIDs = new WeightedRandomPicker<>();
WeightedRandomPicker<String> factionFemalePortraitIDs = new WeightedRandomPicker<>();
if (!faction.equalsIgnoreCase("all")) {
factionMalePortraitIDs = Global.getSector().getFaction(faction).getPortraits(FullName.Gender.MALE);
factionFemalePortraitIDs = Global.getSector().getFaction(faction).getPortraits(FullName.Gender.FEMALE);
} else {
List<FactionAPI> allFactions = Global.getSector().getAllFactions();
Iterator<FactionAPI> iterator = allFactions.iterator();
String nextFaction;
while (iterator.hasNext()) {
nextFaction = iterator.next().getId();
if (!nextFaction.equalsIgnoreCase("remnant") && !nextFaction.equalsIgnoreCase("pirates")
&& !nextFaction.equalsIgnoreCase("sleeper") && !nextFaction.equalsIgnoreCase("scavengers")
&& !nextFaction.equalsIgnoreCase("poor") && !nextFaction.equalsIgnoreCase("derelict")
&& !nextFaction.equalsIgnoreCase("luddic_path") && !nextFaction.equalsIgnoreCase("player")
&& !nextFaction.equalsIgnoreCase("neutral")) {
factionMalePortraitIDs.addAll(Global.getSector().getFaction(nextFaction).getPortraits(FullName.Gender.MALE));
factionFemalePortraitIDs.addAll(Global.getSector().getFaction(nextFaction).getPortraits(FullName.Gender.FEMALE));
}
}
}
Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.MALE).clear();
Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.FEMALE).clear();
Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.MALE).addAll(factionMalePortraitIDs);
Global.getSector().getPlayerFaction().getPortraits(FullName.Gender.FEMALE).addAll(factionFemalePortraitIDs);
return true;
}
}
If you are wanting to replace portraits (either overriding the vanilla portraits in a mod you are making or removing the mod portraits from being used in a mod due to subjective portrait tastes/themes, for instance) you don't have to mess with the replace array in mod_info for the portrait files but instead replace the faction files (to completely change everything- additions don't require this and can just add the portrait references in a mod faction json of the same name). For example:
"data\\world\\factions\\player.faction",
-In the replace array- Would override the player faction file in windows. Then change the portrait references in that faction file to reference your own portraits png names:
"graphics/portraits/portrait_hegemony01.png",
-is an example of how this is referenced in the faction file. Scroll down towards the bottom to see it.
To remove portraits, comment out the portrait line for the portrait files you don't want by adding a #
#"graphics/portraits/portrait_hegemony01.png",