Starsector API
Loading...
Searching...
No Matches
BaseBarEventWithPerson.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.bar.events;
2
3import java.util.Random;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.campaign.econ.MarketAPI;
7import com.fs.starfarer.api.characters.FullName.Gender;
8import com.fs.starfarer.api.characters.PersonAPI;
9import com.fs.starfarer.api.impl.campaign.ids.Factions;
10import com.fs.starfarer.api.impl.campaign.ids.Ranks;
11import com.fs.starfarer.api.util.Misc;
12
13public abstract class BaseBarEventWithPerson extends BaseBarEvent {
14 protected PersonAPI person;
15 protected long seed;
16 protected MarketAPI market = null;
17 protected transient Random random;
18
20 seed = Misc.random.nextLong();
21 }
22
23 protected void regen(MarketAPI market) {
24 if (this.market == market) return;
25 this.market = market;
26
27 random = new Random(seed + market.getId().hashCode());
29 }
30
31 protected PersonAPI createPerson() {
32 PersonAPI person = Global.getSector().getFaction(getPersonFaction()).createRandomPerson(getPersonGender(), random);
33 String p = getPersonPortrait();
34 if (p != null) person.setPortraitSprite(p);
35 person.setRankId(getPersonRank());
36 person.setPostId(getPersonPost());
37 return person;
38 }
39
40 protected String getPersonPortrait() {
41 return null;
42 }
43
44 protected String getPersonFaction() {
45 return Factions.INDEPENDENT;
46 }
47 protected String getPersonRank() {
48 return Ranks.CITIZEN;
49 }
50 protected Gender getPersonGender() {
51 return Gender.ANY;
52 }
53 protected String getPersonPost() {
54 return Ranks.CITIZEN;
55 }
56
57 protected String getManOrWoman() {
58 String manOrWoman = "man";
59 if (person.getGender() == Gender.FEMALE) manOrWoman = "woman";
60 return manOrWoman;
61 }
62
63 protected String getHeOrShe() {
64 String heOrShe = "he";
65 if (person.getGender() == Gender.FEMALE) {
66 heOrShe = "she";
67 }
68 return heOrShe;
69 }
70
71 protected String getHimOrHer() {
72 String himOrHer = "him";
73 if (person.getGender() == Gender.FEMALE) {
74 himOrHer = "her";
75 }
76 return himOrHer;
77 }
78
79 protected String getHimOrHerself() {
80 String himOrHer = "himself";
81 if (person.getGender() == Gender.FEMALE) {
82 himOrHer = "herself";
83 }
84 return himOrHer;
85 }
86
87 protected String getHisOrHer() {
88 String hisOrHer = "his";
89 if (person.getGender() == Gender.FEMALE) {
90 hisOrHer = "her";
91 }
92 return hisOrHer;
93 }
94
95 @Override
96 public boolean isDialogFinished() {
97 return done;
98 }
99
100 public PersonAPI getPerson() {
101 return person;
102 }
103
104 public MarketAPI getMarket() {
105 return market;
106 }
107
108 public Random getRandom() {
109 return random;
110 }
111
112}
113
114
115
static SectorAPI getSector()
Definition Global.java:59