Starsector API
Loading...
Searching...
No Matches
SetPersonPortrait.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.rulecmd;
2
3import java.util.List;
4import java.util.Map;
5
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.campaign.InteractionDialogAPI;
8import com.fs.starfarer.api.campaign.rules.MemoryAPI;
9import com.fs.starfarer.api.characters.PersonAPI;
10import com.fs.starfarer.api.util.Misc.Token;
11
16
17 public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
18
19
20 // if you wanted to just pass in the person ID. The person has to have been
21 // added to ImportantPeople at some point (as the people defined in People are)
22 String id = params.get(0).getString(memoryMap);
23 PersonAPI person = Global.getSector().getImportantPeople().getPerson(id);
24
25 //VarAndMemory var = params.get(0).getVarNameAndMemory(memoryMap);
26 //PersonAPI person = (PersonAPI) var.memory.get(var.name);
27
28 String portrait_key = params.get(1).getString(memoryMap);
29
30 if (Global.getSettings().getSpriteName("characters", portrait_key) == null) return false;
31 if (person.getMarket() == null) return false;
32 if (person.getMarket().getCommDirectory() == null) return false;
33 if (person.getMarket().getCommDirectory().getEntryForPerson(person.getId()) == null) return false;
34
35 person.setPortraitSprite(Global.getSettings().getSpriteName("characters", portrait_key));
36 return true;
37 }
38}
static SettingsAPI getSettings()
Definition Global.java:51
static SectorAPI getSector()
Definition Global.java:59
boolean execute(String ruleId, InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)
String getSpriteName(String category, String id)