001package com.fs.starfarer.api.campaign; 002 003import java.awt.Color; 004import java.util.Collection; 005import java.util.List; 006import java.util.Map; 007 008import org.lwjgl.util.vector.Vector2f; 009 010import com.fs.starfarer.api.EveryFrameScript; 011import com.fs.starfarer.api.InteractionDialogImageVisual; 012import com.fs.starfarer.api.campaign.econ.MarketAPI; 013import com.fs.starfarer.api.campaign.rules.HasMemory; 014import com.fs.starfarer.api.campaign.rules.MemoryAPI; 015import com.fs.starfarer.api.characters.AbilityPlugin; 016import com.fs.starfarer.api.characters.PersonAPI; 017import com.fs.starfarer.api.combat.StatBonus; 018import com.fs.starfarer.api.impl.campaign.procgen.Constellation; 019import com.fs.starfarer.api.impl.campaign.procgen.SalvageEntityGenDataSpec.DropData; 020 021 022/** 023 * @author Alex Mosolov 024 * 025 * Copyright 2012 Fractal Softworks, LLC 026 */ 027public interface SectorEntityToken extends HasMemory { 028 029 public static enum VisibilityLevel { 030 NONE, 031 SENSOR_CONTACT, 032 COMPOSITION_DETAILS, 033 COMPOSITION_AND_FACTION_DETAILS, 034 } 035 boolean isPlayerFleet(); 036 037 MarketAPI getMarket(); 038 039 /** 040 * Sets market for specified planet object. 041 * @param market Specify the market object to add to planet. 042 */ 043 void setMarket(MarketAPI market); 044 045 /** 046 * For the player fleet, the actual cargo. 047 * For AI fleets, only non-logistics-related stuff - i.e. goods being carried, etc. 048 * NOT supplies/fuel/crew/etc. 049 * 050 * @return 051 */ 052 CargoAPI getCargo(); 053 Vector2f getLocation(); 054 055 056 /** 057 * The location in hyperspace of the LocationAPI containing this entity, or this entity's location 058 * if it's already in hyperspace. 059 * @return 060 */ 061 Vector2f getLocationInHyperspace(); 062 OrbitAPI getOrbit(); 063 void setOrbit(OrbitAPI orbit); 064 065 String getId(); 066 String getName(); 067 String getFullName(); 068 069 void setFaction(String factionId); 070 LocationAPI getContainingLocation(); 071 072 float getRadius(); 073// void setRadius(float radius); 074 075 FactionAPI getFaction(); 076 077 String getCustomDescriptionId(); 078 void setCustomDescriptionId(String customDescriptionId); 079 080 void setCustomInteractionDialogImageVisual(InteractionDialogImageVisual visual); 081 InteractionDialogImageVisual getCustomInteractionDialogImageVisual(); 082 083 /** 084 * Whether moving ships and items to and from this entity has a cost. 085 * @param freeTransfer 086 */ 087 public void setFreeTransfer(boolean freeTransfer); 088 public boolean isFreeTransfer(); 089 090 boolean hasTag(String tag); 091 void addTag(String tag); 092 void removeTag(String tag); 093 Collection<String> getTags(); 094 void clearTags(); 095 void setFixedLocation(float x, float y); 096 /** 097 * Causes this entity to enter a circular, fixed orbit around focus. 098 * 099 * @param focus The entity to orbit around. 100 * @param angle The initial angle the orbit will start at, relative to focus. 101 * @param orbitRadius The radius of the orbit. 102 * @param orbitDays The orbit will make a complete rotation after this many days. 103 * Negative values cause the orbit to move counterclockwise. Warning: If set to zero, will cause numerous issues including preventing serialization. 104 */ 105 void setCircularOrbit(SectorEntityToken focus, float angle, float orbitRadius, float orbitDays); 106 /** 107 * Causes this entity to enter a circular, fixed orbit around focus. 108 * This orbit causes the orbiting entity to always have the bottom of its sprite pointing at the focus. 109 * 110 * @param focus The entity to orbit around. 111 * @param angle The initial angle the orbit will start at, relative to focus. 112 * @param orbitRadius The radius of the orbit. 113 * @param orbitDays The orbit will make a complete rotation after this many days. 114 * Negative values cause the orbit to move counterclockwise. Warning: If set to zero, will cause numerous issues including preventing serialization. 115 */ 116 void setCircularOrbitPointingDown(SectorEntityToken focus, float angle, float orbitRadius, float orbitDays); 117 /** 118 * Causes this entity to enter a circular, fixed orbit around focus. 119 * This orbit causes the orbiting entity to spin independently of the orbit. 120 * 121 * @param focus The entity to orbit around. 122 * @param angle The initial angle the orbit will start at, relative to focus. 123 * @param orbitRadius The radius of the orbit. 124 * @param orbitDays The orbit will make a complete rotation after this many days. 125 * Negative values cause the orbit to move counterclockwise. Warning: If set to zero, will cause numerous issues including preventing serialization. 126 * @param minSpin The minimum speed at which this entity will spin. 127 * @param maxSpin The maximum speed at which this entity will spin. The speed is randomly picked between minSpin and maxSpin. 128 */ 129 void setCircularOrbitWithSpin(SectorEntityToken focus, float angle, float orbitRadius, float orbitDays, float minSpin, float maxSpin); 130 /** 131 * Will cause the relevant updateFacts() methods to run to update the entity's 132 * perception of the world. Return value should be stored and re-used rather 133 * than calling this method again, unless a fact update is needed. 134 * @return 135 */ 136 MemoryAPI getMemory(); 137 138 /** 139 * Get the memory without updating facts. 140 * @return 141 */ 142 MemoryAPI getMemoryWithoutUpdate(); 143 144 float getFacing(); 145 void setFacing(float facing); 146 boolean isInHyperspace(); 147 void addScript(EveryFrameScript script); 148 void removeScript(EveryFrameScript script); 149 void removeScriptsOfClass(Class c); 150 151 152 /** 153 * True if in system or within commRelayRangeAroundSystem light-years. 154 * @param system 155 * @return 156 */ 157 boolean isInOrNearSystem(StarSystemAPI system); 158 159 boolean isInCurrentLocation(); 160 161 162 /** 163 * In pixels per second. 164 * @return 165 */ 166 Vector2f getVelocity(); 167 168 void setInteractionImage(String category, String key); 169 170 void setName(String name); 171 172 /** 173 * Returns false if: 174 * 1) getContainingLocation() is null, or 175 * 2) getContainingLocation() doesn't contain this entity 176 * @return 177 */ 178 boolean isAlive(); 179 180 181 PersonAPI getActivePerson(); 182 void setActivePerson(PersonAPI activePerson); 183 184 185// ActionIndicatorAPI getActionIndicator(); 186// boolean hasActionIndicator(); 187 188 boolean isVisibleToSensorsOf(SectorEntityToken other); 189 boolean isVisibleToPlayerFleet(); 190 191 VisibilityLevel getVisibilityLevelToPlayerFleet(); 192 VisibilityLevel getVisibilityLevelTo(SectorEntityToken other); 193 194 195 void addAbility(String id); 196 void removeAbility(String id); 197 AbilityPlugin getAbility(String id); 198 boolean hasAbility(String id); 199 Map<String, AbilityPlugin> getAbilities(); 200 201 boolean isTransponderOn(); 202 203 void setTransponderOn(boolean transponderOn); 204 205 void addFloatingText(String text, Color color, float duration); 206 207 SectorEntityToken getLightSource(); 208 Color getLightColor(); 209 210 211 212 void setMemory(MemoryAPI memory); 213 214 Map<String, Object> getCustomData(); 215 216 Color getIndicatorColor(); 217 218 /** 219 * Only returns non-null for custom campaign entities with a plugin. 220 * @return 221 */ 222 CustomCampaignEntityPlugin getCustomPlugin(); 223 224 float getCircularOrbitRadius(); 225 float getCircularOrbitPeriod(); 226 227 SectorEntityToken getOrbitFocus(); 228 229 void setId(String id); 230 231 //String getAutogenJumpPointNameInSystem(); 232 //void setAutogenJumpPointNameInSystem(String autogenJumpPointNameInSystem); 233 String getAutogenJumpPointNameInHyper(); 234 void setAutogenJumpPointNameInHyper(String autogenJumpPointNameInHyper); 235 236 boolean isSkipForJumpPointAutoGen(); 237 void setSkipForJumpPointAutoGen(boolean skipForJumpPointAutoGen); 238 239 float getCircularOrbitAngle(); 240 241 String getCustomEntityType(); 242 243 float getSensorStrength(); 244 void setSensorStrength(Float sensorStrength); 245 float getSensorProfile(); 246 void setSensorProfile(Float sensorProfile); 247 StatBonus getDetectedRangeMod(); 248 StatBonus getSensorRangeMod(); 249 250 float getBaseSensorRangeToDetect(float sensorProfile); 251 252 boolean hasSensorStrength(); 253 boolean hasSensorProfile(); 254 255 256 257 /** 258 * Does not includes fleet radii - i.e. the returned range is from 259 * outer edge to outer edge. 260 * @return 261 */ 262 float getMaxSensorRangeToDetect(SectorEntityToken other); 263 264 boolean isDiscoverable(); 265 void setDiscoverable(Boolean discoverable); 266 267 CustomEntitySpecAPI getCustomEntitySpec(); 268 269 List<DropData> getDropValue(); 270 List<DropData> getDropRandom(); 271 void addDropValue(String group, int value); 272 void addDropRandom(String group, int chances); 273 void addDropRandom(String group, int chances, int value); 274 275 boolean isExpired(); 276 void setExpired(boolean expired); 277 278 float getSensorFaderBrightness(); 279 float getSensorContactFaderBrightness(); 280 281 void forceSensorFaderBrightness(float b); 282 283 Float getDiscoveryXP(); 284 void setDiscoveryXP(Float discoveryXP); 285 boolean hasDiscoveryXP(); 286 287 void addDropValue(DropData data); 288 void addDropRandom(DropData data); 289 290 /** 291 * Always use sensor fader brightness for rendering circular indicator around the entity. 292 * @param alwaysUseSensorFaderBrightness 293 */ 294 void setAlwaysUseSensorFaderBrightness(Boolean alwaysUseSensorFaderBrightness); 295 Boolean getAlwaysUseSensorFaderBrightness(); 296 297 void advance(float amount); 298 299 boolean hasScriptOfClass(Class c); 300 301 void setContainingLocation(LocationAPI location); 302 303 void clearAbilities(); 304 305 Constellation getConstellation(); 306 307 boolean isStar(); 308 309 Float getSalvageXP(); 310 void setSalvageXP(Float salvageXP); 311 boolean hasSalvageXP(); 312 313 void setDetectionRangeDetailsOverrideMult(Float detectionRangeDetailsOverrideMult); 314 Float getDetectionRangeDetailsOverrideMult(); 315 316 VisibilityLevel getVisibilityLevelOfPlayerFleet(); 317 318 void setCircularOrbitAngle(float angle); 319 320 void addFloatingText(String text, Color color, float duration, boolean showWhenOnlySensorContact); 321 322 boolean isSystemCenter(); 323 324 StarSystemAPI getStarSystem(); 325 326 void clearFloatingText(); 327 328 void setLocation(float x, float y); 329 330 void autoUpdateHyperLocationBasedOnInSystemEntityAtRadius(SectorEntityToken entity, float radius); 331 332 void forceSensorContactFaderBrightness(float b); 333 334 void forceSensorFaderOut(); 335 336 void setLightSource(SectorEntityToken star, Color color); 337 338 List<EveryFrameScript> getScripts(); 339 340 341 /** 342 * Applies to the 5000/2000 max sensor range limit in normal/hyper space. Does not, by itself, increase the 343 * range at which the entity is detected, just applies to the limit. 344 * @return 345 */ 346 float getExtendedDetectedAtRange(); 347 /** 348 * Applies to the 5000/2000 max sensor range limit in normal/hyper space. Does not, by itself, increase the 349 * range at which the entity is detected, just applies to the limit. 350 * @return 351 */ 352 void setExtendedDetectedAtRange(Float extendedDetectedAtRange); 353 354 void fadeOutIndicator(); 355 356 void fadeInIndicator(); 357 358 void forceOutIndicator(); 359 360 void setOrbitFocus(SectorEntityToken focus); 361 362} 363 364 365 366 367 368 369 370 371 372