Starsector API
Loading...
Searching...
No Matches
Constellation.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.procgen;
2
3import java.util.ArrayList;
4import java.util.HashMap;
5import java.util.List;
6import java.util.Map;
7
8import org.lwjgl.util.vector.Vector2f;
9
10import com.fs.starfarer.api.campaign.PlanetAPI;
11import com.fs.starfarer.api.campaign.SectorEntityToken;
12import com.fs.starfarer.api.campaign.StarSystemAPI;
13import com.fs.starfarer.api.impl.campaign.procgen.ProcgenUsedNames.NamePick;
14
15public class Constellation {
16
17 public static enum ConstellationType {
18 NORMAL,
19 NEBULA,
20 }
21 protected StarAge age;
22 protected transient Map<SectorEntityToken, PlanetAPI> lagrangeParentMap = new HashMap<SectorEntityToken, PlanetAPI>();
23 protected transient Map<SectorEntityToken, List<SectorEntityToken>> allEntitiesAdded = new HashMap<SectorEntityToken, List<SectorEntityToken>>();
24 protected NamePick namePick;
25 protected List<StarSystemAPI> systems = new ArrayList<StarSystemAPI>();
26 protected ConstellationType type = ConstellationType.NORMAL;
27 protected String nameOverride = null;
28
29 protected transient boolean leavePickedNameUnused = false;
30
31 public Constellation(ConstellationType type, StarAge age) {
32 this.type = type;
33 this.age = age;
34 }
35
36 public boolean isLeavePickedNameUnused() {
38 }
39
41 this.leavePickedNameUnused = leavePickedNameUnused;
42 }
43
44 public StarAge getAge() {
45 return age;
46 }
47
48 public void setAge(StarAge age) {
49 this.age = age;
50 }
51
52 public Vector2f getLocation() {
53 Vector2f loc = new Vector2f();
54 if (systems.isEmpty()) return loc;
55
56 for (StarSystemAPI system : systems) {
57 Vector2f.add(loc, system.getLocation(), loc);
58 }
59
60 loc.scale(1f / (float) systems.size());
61 return loc;
62 }
63
64 public ConstellationType getType() {
65 return type;
66 }
67
68 public void setType(ConstellationType type) {
69 this.type = type;
70 }
71
72 public String getNameOverride() {
73 return nameOverride;
74 }
75
76 public void setNameOverride(String nameOverride) {
77 this.nameOverride = nameOverride;
78 }
79
80 public String getName() {
81 if (nameOverride != null) return nameOverride;
82 return namePick.nameWithRomanSuffixIfAny;
83 }
84
85 public String getNameWithType() {
86 if (nameOverride != null) return nameOverride;
87 String constellationText = getName() + " Constellation";
88 if (getType() == ConstellationType.NEBULA) {
89 constellationText = getName() + " Nebula";
90 }
91 return constellationText;
92 }
93
94 public String getNameWithLowercaseType() {
95 if (nameOverride != null) return nameOverride;
96 String name = getNameWithType();
97 name = name.replaceAll("Constellation", "constellation");
98 name = name.replaceAll("Nebula", "nebula");
99 return name;
100 }
101
102 public NamePick getNamePick() {
103 return namePick;
104 }
105 public void setNamePick(NamePick namePick) {
106 this.namePick = namePick;
107 }
108 public List<StarSystemAPI> getSystems() {
109 return systems;
110 }
111
112 public Map<SectorEntityToken, PlanetAPI> getLagrangeParentMap() {
113 return lagrangeParentMap;
114 }
115
116 public void setLagrangeParentMap(Map<SectorEntityToken, PlanetAPI> lagrangeParentMap) {
117 this.lagrangeParentMap = lagrangeParentMap;
118 }
119
120 public Map<SectorEntityToken, List<SectorEntityToken>> getAllEntitiesAdded() {
121 return allEntitiesAdded;
122 }
123
125 Map<SectorEntityToken, List<SectorEntityToken>> allEntitiesAdded) {
126 this.allEntitiesAdded = allEntitiesAdded;
127 }
128
129 public StarSystemAPI getSystemWithMostPlanets() {
130 int most = -1;
131 StarSystemAPI result = null;
132 for (StarSystemAPI curr : systems) {
133 int count = curr.getPlanets().size();
134 if (count > most) {
135 most = count;
136 result = curr;
137 }
138 }
139 return result;
140 }
141}
142
143
144
145
transient Map< SectorEntityToken, List< SectorEntityToken > > allEntitiesAdded
Map< SectorEntityToken, PlanetAPI > getLagrangeParentMap()
void setAllEntitiesAdded(Map< SectorEntityToken, List< SectorEntityToken > > allEntitiesAdded)
Map< SectorEntityToken, List< SectorEntityToken > > getAllEntitiesAdded()
Constellation(ConstellationType type, StarAge age)
void setLagrangeParentMap(Map< SectorEntityToken, PlanetAPI > lagrangeParentMap)
void setLeavePickedNameUnused(boolean leavePickedNameUnused)
transient Map< SectorEntityToken, PlanetAPI > lagrangeParentMap