001package com.fs.starfarer.api.impl.campaign.rulecmd; 002 003import java.util.List; 004import java.util.Map; 005 006import com.fs.starfarer.api.Global; 007import com.fs.starfarer.api.campaign.InteractionDialogAPI; 008import com.fs.starfarer.api.campaign.rules.MemoryAPI; 009import com.fs.starfarer.api.characters.PersonAPI; 010import com.fs.starfarer.api.util.Misc.Token; 011 012/** 013 * SetPersonPortrait by person id, sprite as defined in settings "characters" section 014 */ 015public class SetPersonPortrait extends BaseCommandPlugin { 016 017 public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) { 018 019 020 // if you wanted to just pass in the person ID. The person has to have been 021 // added to ImportantPeople at some point (as the people defined in People are) 022 String id = params.get(0).getString(memoryMap); 023 PersonAPI person = Global.getSector().getImportantPeople().getPerson(id); 024 025 //VarAndMemory var = params.get(0).getVarNameAndMemory(memoryMap); 026 //PersonAPI person = (PersonAPI) var.memory.get(var.name); 027 028 String portrait_key = params.get(1).getString(memoryMap); 029 030 if (Global.getSettings().getSpriteName("characters", portrait_key) == null) return false; 031 if (person.getMarket() == null) return false; 032 if (person.getMarket().getCommDirectory() == null) return false; 033 if (person.getMarket().getCommDirectory().getEntryForPerson(person.getId()) == null) return false; 034 035 person.setPortraitSprite(Global.getSettings().getSpriteName("characters", portrait_key)); 036 return true; 037 } 038}