1package com.fs.starfarer.api.impl.campaign.intel.contacts;
4import java.util.Random;
7import org.lwjgl.input.Keyboard;
9import com.fs.starfarer.api.Global;
10import com.fs.starfarer.api.campaign.FactionAPI;
11import com.fs.starfarer.api.campaign.InteractionDialogAPI;
12import com.fs.starfarer.api.campaign.PersonImportance;
13import com.fs.starfarer.api.campaign.SectorEntityToken;
14import com.fs.starfarer.api.campaign.StoryPointActionDelegate;
15import com.fs.starfarer.api.campaign.TextPanelAPI;
16import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin;
17import com.fs.starfarer.api.campaign.econ.MarketAPI;
18import com.fs.starfarer.api.campaign.rules.MemoryAPI;
19import com.fs.starfarer.api.characters.PersonAPI;
20import com.fs.starfarer.api.impl.campaign.DebugFlags;
21import com.fs.starfarer.api.impl.campaign.ids.Conditions;
22import com.fs.starfarer.api.impl.campaign.ids.Factions;
23import com.fs.starfarer.api.impl.campaign.ids.Sounds;
24import com.fs.starfarer.api.impl.campaign.ids.Stats;
25import com.fs.starfarer.api.impl.campaign.ids.Tags;
26import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
27import com.fs.starfarer.api.impl.campaign.missions.hub.BaseMissionHub;
28import com.fs.starfarer.api.impl.campaign.rulecmd.SetStoryOption.BaseOptionStoryPointActionDelegate;
29import com.fs.starfarer.api.impl.campaign.rulecmd.SetStoryOption.StoryOptionParams;
30import com.fs.starfarer.api.ui.ButtonAPI;
31import com.fs.starfarer.api.ui.IntelUIAPI;
32import com.fs.starfarer.api.ui.LabelAPI;
33import com.fs.starfarer.api.ui.SectorMapAPI;
34import com.fs.starfarer.api.ui.TooltipMakerAPI;
35import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
36import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipLocation;
37import com.fs.starfarer.api.ui.UIComponentAPI;
38import com.fs.starfarer.api.util.IntervalUtil;
39import com.fs.starfarer.api.util.Misc;
40import com.fs.starfarer.api.util.WeightedRandomPicker;
44 public static enum ContactState {
74 protected ContactState
state = ContactState.POTENTIAL;
117 if (
market ==
null)
return;
128 if (
tracker.intervalElapsed()) {
138 if (
market ==
null)
return null;
144 if (curr ==
market)
continue;
149 return picker.
pick();
161 state = ContactState.LOST_CONTACT;
162 if (dialog !=
null) {
177 if (
state != ContactState.LOST_CONTACT_DECIV &&
state != ContactState.LOST_CONTACT &&
market !=
null) {
182 state = ContactState.LOST_CONTACT_DECIV;
190 if (
state == ContactState.LOST_CONTACT)
return;
191 if (
state == ContactState.POTENTIAL)
return;
192 if (
state == ContactState.SUSPENDED) {
197 if (
state == ContactState.PRIORITY) {
210 if (bonusMissions > 0) {
215 if (bonusQuality > 0) {
231 if (withIntelUpdate) {
239 if (priority < 1f) priority = 1f;
246 super.reportPlayerClickedOn();
252 super.notifyEnding();
270 super.reportRemovedIntel();
276 if (
state != ContactState.POTENTIAL)
return false;
286 if (
state == ContactState.LOST_CONTACT_DECIV) {
288 }
else if (
state == ContactState.LOST_CONTACT) {
290 }
else if (
state == ContactState.POTENTIAL) {
292 }
else if (
state == ContactState.SUSPENDED) {
294 }
else if (
state == ContactState.PRIORITY) {
302 if (
state == ContactState.POTENTIAL) {
304 }
else if (
state == ContactState.SUSPENDED) {
306 }
else if (
state == ContactState.PRIORITY) {
326 if (tags.length <= 0)
return;
327 String str =
"Type: ";
328 for (String tag : tags) {
331 if (tags.length > 0) {
332 str = str.substring(0, str.length() - 2);
334 info.
addPara(str, pad, tc, h, tags);
340 String str =
"Faction: " + faction;
354 if (mode == ListInfoMode.IN_DESC) initPad = opad;
366 if (
state == ContactState.LOST_CONTACT_DECIV) {
367 if (mode != ListInfoMode.IN_DESC) {
375 if (
state == ContactState.LOST_CONTACT) {
386 if (mode != ListInfoMode.IN_DESC) {
390 if (
state == ContactState.PRIORITY ||
state == ContactState.NON_PRIORITY ||
state == ContactState.SUSPENDED) {
392 if (ts <= Long.MIN_VALUE) {
408 if (mode != ListInfoMode.IN_DESC) {
411 initPad, tc, h,
getDays(days));
435 float relBarWidth = 128f * 2f + 10f;
436 float importanceBarWidth = relBarWidth;
443 relBarWidth = (relBarWidth - 10f) / 2f;
462 if (
state == ContactState.NON_PRIORITY ||
state == ContactState.PRIORITY) {
473 if (
market !=
null &&
state == ContactState.LOST_CONTACT_DECIV) {
480 info.
addPara(
"This colony has decivilized, and you've since lost contact with " +
person.
getHimOrHer() +
".", opad);
481 }
else if (
state == ContactState.LOST_CONTACT) {
482 info.
addPara(
"You've lost this contact.", opad);
501 if (
state == ContactState.POTENTIAL){
503 "have work for you. As the relationship improves, you may gain " +
504 "access to better opportunities.", opad);
505 }
else if (
state == ContactState.SUSPENDED) {
512 if (
state == ContactState.PRIORITY ||
state == ContactState.NON_PRIORITY ||
state == ContactState.SUSPENDED) {
516 if (ts <= Long.MIN_VALUE) {
537 public boolean isTooltipExpandable(Object tooltipParam) {
540 public float getTooltipWidth(Object tooltipParam) {
544 public void createTooltip(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
545 tooltip.
addPara(
"Can not delete or suspend contact at this time.", 0f);
549 if (
state == ContactState.POTENTIAL ||
state == ContactState.SUSPENDED){
552 info.
addPara(
"The opportunity to develop this contact will be available for %s more " +
getDaysString(days) +
".",
560 info.
addPara(
"Active contacts: %s %s %s", opad,
561 h,
"" + curr,
"/",
"" + max);
564 String developText =
"Develop contact";
565 if (
state == ContactState.SUSPENDED) developText =
"Resume contact";
576 }
else if (
state == ContactState.NON_PRIORITY ||
state == ContactState.PRIORITY) {
601 if (
state == ContactState.NON_PRIORITY) {
602 state = ContactState.PRIORITY;
603 }
else if (
state == ContactState.PRIORITY) {
604 state = ContactState.NON_PRIORITY;
618 state = ContactState.SUSPENDED;
625 if (
market ==
null)
return;
642 state = ContactState.NON_PRIORITY;
653 if (
state == ContactState.POTENTIAL) {
654 prompt.
addPara(
"Are you sure? Deleting a potential contact can not be undone.", 0f);
655 }
else if (
state == ContactState.SUSPENDED) {
656 prompt.
addPara(
"Are you sure? Deleting a contact can not be undone.", 0f);
658 prompt.
addPara(
"Are you sure? Deleting a contact can not be undone. " +
659 "To stop receiving missions from a contact, but not lose them permanently, you can \"suspend\" the contact instead.", 0f);
663 prompt.
addPara(
"Develop a relationship with this contact?", 0f);
666 super.createConfirmationPrompt(buttonId, prompt);
674 return super.doesButtonHaveConfirmDialog(buttonId);
679 StoryOptionParams params =
new StoryOptionParams(
null, 1,
"developContactOverMax",
682 return new BaseOptionStoryPointActionDelegate(
null, params) {
684 public void confirm() {
688 public String getTitle() {
699 StoryOptionParams params =
new StoryOptionParams(
null, 1,
"suspendContact",
702 return new BaseOptionStoryPointActionDelegate(
null, params) {
704 public void confirm() {
708 public String getTitle() {
714 info.
addPara(
"If suspended, this contact will not offer you missions and will not " +
715 "count against the maximum number of contacts. You will be able to re-develop this " +
716 "contact at any time.", -10f);
718 super.createDescription(info);
733 Set<String> tags = super.getIntelTags(map);
740 return super.getCommMessageSound();
781 public boolean isTooltipExpandable(Object tooltipParam) {
784 public float getTooltipWidth(Object tooltipParam) {
787 public void createTooltip(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
788 tooltip.
addPara(
"The importance of this person in whatever hierarchy or social structure they " +
789 "belong to. A more highly placed or connected individual will have more difficult - " +
790 "and more profitable - missions and opportunities to offer.", 0f);
792 }, TooltipLocation.LEFT);
796 public boolean isTooltipExpandable(Object tooltipParam) {
799 public float getTooltipWidth(Object tooltipParam) {
801 }
public void createTooltip(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
803 tooltip.
addPara(
"Whether cultivating a relationship with this contact is a priority for you. " +
804 "Priority contacts will have more missions available, and the missions will be of a " +
805 "higher quality.", 0f);
806 tooltip.
addPara(
"The more priority contacts you have, the less the impact there is on each individual contact.", opad);
807 tooltip.
addPara(
"It takes about a month for changes in priority status to take full effect.", opad);
809 }, TooltipLocation.LEFT);
813 public boolean isTooltipExpandable(Object tooltipParam) {
816 public float getTooltipWidth(Object tooltipParam) {
819 public void createTooltip(
TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
820 tooltip.
addPara(
"Developing contacts above the maximum " +
821 "requires a story point for each additional contact.", 0f,
824 }, TooltipLocation.LEFT);
837 if (intel.isEnding() || intel.isEnded())
continue;
850 if (intel.isEnding() || intel.isEnded())
continue;
870 if (
state == ContactState.POTENTIAL && !includePotential) {
873 if (
state == ContactState.LOST_CONTACT ||
state == ContactState.LOST_CONTACT_DECIV) {
890 if (
person ==
null)
return;
903 if (
market ==
null)
return;
913 String key =
"$potentialContactRollFails";
915 float fails = mem.
getInt(key);
935 long seed =
Misc.seedUniquifier() ^ (
person.
getId().hashCode() * 17000);
936 Random r =
new Random(seed);
937 for (
int i = 0; i < 5; i++) {
static SettingsAPI getSettings()
static SoundPlayerAPI getSoundPlayer()
static SectorAPI getSector()
float computeEffective(float baseValue)
static boolean ALWAYS_ADD_POTENTIAL_CONTACT
static final String DECIVILIZED
static final String CUSTOM_NO_CONTACTS
static String STORY_POINT_SPEND
static final String NUM_MAX_CONTACTS_MOD
void indent(TooltipMakerAPI info)
void sendUpdate(Object listInfoParam, TextPanelAPI textPanel)
String getDays(float days)
void unindent(TooltipMakerAPI info)
ButtonAPI addGenericButton(TooltipMakerAPI info, float width, String text, Object data)
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
Object getListInfoParam()
Color getBulletColorForMode(ListInfoMode mode)
float getDaysSincePlayerVisible()
static String getDaysString(float days)
void bullet(TooltipMakerAPI info)
Color getTitleColor(ListInfoMode mode)
static void set(PersonAPI person, MissionHub hub)
static String CONTACT_SUSPENDED
static long getLastOpenedTimestamp(PersonAPI person)
static String MISSION_QUALITY_BONUS
static MissionHub get(PersonAPI person)
static String NUM_BONUS_MISSIONS
void advance(float amount)
static Color getStoryOptionColor()
static Color getTextColor()
static Color getStoryDarkColor()
static String ucFirst(String str)
static Color getNegativeHighlightColor()
static Color getGrayColor()
static long getSalvageSeed(SectorEntityToken entity)
static Color getHighlightColor()
static String getDetailedAgoString(long timestamp)
static String getPersonalityName(PersonAPI person)
float getFloat(String key)
SoundAPI playUISound(String id, float pitch, float volume)
float convertToDays(float realSeconds)
void removePerson(PersonAPI person)
CommDirectoryEntryAPI getEntryForPerson(PersonAPI person)
String addPerson(PersonAPI person)
String getDisplayNameWithArticleWithoutArticle()
String getDisplayNameWithArticle()
boolean getCustomBoolean(String key)
boolean isPlayerFaction()
TextPanelAPI getTextPanel()
void addScript(EveryFrameScript script)
CampaignClockAPI getClock()
void removeScript(EveryFrameScript script)
FactionAPI getPlayerFaction()
IntelManagerAPI getIntelManager()
List< EveryFrameScript > getScripts()
MutableCharacterStatsAPI getPlayerStats()
MemoryAPI getMemoryWithoutUpdate()
void createDescription(TooltipMakerAPI info)
void addIntel(IntelInfoPlugin plugin)
List< IntelInfoPlugin > getIntel()
List< MarketAPI > getMarketsInGroup(String group)
MemoryAPI getMemoryWithoutUpdate()
void addPerson(PersonAPI person)
CommDirectoryAPI getCommDirectory()
List< PersonAPI > getPeopleCopy()
boolean hasCondition(String id)
void removePerson(PersonAPI person)
SectorEntityToken getPrimaryEntity()
void set(String key, Object value)
boolean getBoolean(String key)
DynamicStatsAPI getDynamic()
String getPortraitSprite()
RelationshipAPI getRelToPlayer()
void setImportance(PersonImportance importance)
void setMarket(MarketAPI market)
PersonImportance getImportance()
MemoryAPI getMemoryWithoutUpdate()
List< String > getSortedContactTagStrings()
void updateUIForItem(IntelInfoPlugin plugin)
void setHighlightColors(Color ... colors)
PositionAPI setYAlignOffset(float yAlignOffset)
PositionAPI setXAlignOffset(float xAlignOffset)
PositionAPI getPosition()
StatBonus getMod(String id)