1package com.fs.starfarer.api.impl.campaign;
4import java.util.LinkedHashSet;
6import org.lwjgl.opengl.GL11;
7import org.lwjgl.util.vector.Vector2f;
9import com.fs.starfarer.api.Global;
10import com.fs.starfarer.api.campaign.CampaignEngineLayers;
11import com.fs.starfarer.api.campaign.CampaignFleetAPI;
12import com.fs.starfarer.api.campaign.CargoAPI;
13import com.fs.starfarer.api.campaign.CargoAPI.CargoItemType;
14import com.fs.starfarer.api.campaign.CustomEntitySpecAPI;
15import com.fs.starfarer.api.campaign.SectorEntityToken;
16import com.fs.starfarer.api.campaign.SectorEntityToken.VisibilityLevel;
17import com.fs.starfarer.api.campaign.SpecialItemData;
18import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin;
19import com.fs.starfarer.api.combat.ViewportAPI;
20import com.fs.starfarer.api.graphics.SpriteAPI;
21import com.fs.starfarer.api.impl.campaign.ids.Items;
22import com.fs.starfarer.api.impl.campaign.ids.Tags;
23import com.fs.starfarer.api.impl.campaign.intel.misc.GateIntel;
24import com.fs.starfarer.api.impl.campaign.world.ZigLeashAssignmentAI;
25import com.fs.starfarer.api.ui.TooltipMakerAPI;
26import com.fs.starfarer.api.util.FaderUtil;
27import com.fs.starfarer.api.util.IntervalUtil;
28import com.fs.starfarer.api.util.JitterUtil;
29import com.fs.starfarer.api.util.Misc;
30import com.fs.starfarer.api.util.WarpingSpriteRendererUtil;
54 public static class GateData {
55 public LinkedHashSet<SectorEntityToken> scanned =
new LinkedHashSet<SectorEntityToken>();
60 if (!(data instanceof GateData)) {
61 data =
new GateData();
64 return (GateData) data;
67 public static boolean isScanned(SectorEntityToken gate) {
68 return gate.getMemoryWithoutUpdate().getBoolean(
GATE_SCANNED);
71 public static boolean isActive(SectorEntityToken gate) {
81 return cargo.getQuantity(CargoItemType.SPECIAL,
new SpecialItemData(Items.JANUS,
null)) > 0;
90 return cargo.getQuantity(CargoItemType.SPECIAL,
new SpecialItemData(Items.JANUS,
null)) > 0;
97 transient protected SpriteAPI
whirl1;
98 transient protected SpriteAPI
whirl2;
100 transient protected SpriteAPI
rays;
103 transient protected WarpingSpriteRendererUtil
warp;
106 protected FaderUtil
glowFader =
new FaderUtil(0f, 1f, 1f,
true,
true);
118 public void init(SectorEntityToken
entity, Object pluginParams) {
119 super.init(
entity, pluginParams);
124 Object readResolve() {
139 glowFader =
new FaderUtil(0f, 1f, 1f,
true,
true);
152 jitter =
new JitterUtil();
192 float dist = Misc.getDistance(player.getLocation(),
entity.getLocation());
193 float radSum =
entity.getRadius() + player.getRadius();
200 f = 1f - (dist - 300f) / 100f;
213 float volumeMult = prox;
214 float suppressionMult = prox;
215 if (volumeMult <= 0)
return;
216 volumeMult = (float) Math.sqrt(volumeMult);
219 Global.
getSector().getCampaignUI().suppressMusic(1f * suppressionMult);
221 float dirToEntity = Misc.getAngleInDegrees(
entity.getLocation(), this.
entity.getLocation());
222 Vector2f playbackLoc = Misc.getUnitVectorAtDegreeAngle(dirToEntity);
223 playbackLoc.scale(500f);
224 Vector2f.add(
entity.getLocation(), playbackLoc, playbackLoc);
229 playbackLoc, Misc.ZERO);
235 playbackLoc, Misc.ZERO);
250 warp.advance(amount);
276 if (
entity.getName().equals(
entity.getCustomEntitySpec().getDefaultName())) {
277 entity.setName(
"Active Gate");
279 entity.setCustomDescriptionId(
"active_gate");
280 entity.setInteractionImage(
"illustrations",
"active_gate");
281 entity.removeTag(Tags.NEUTRINO);
282 entity.addTag(Tags.NEUTRINO_HIGH);
288 if (
entity.isInCurrentLocation()) {
306 boolean alreadyHas =
false;
307 for (IntelInfoPlugin intel :
Global.
getSector().getIntelManager().getIntel(GateIntel.class)) {
308 if (((GateIntel)intel).getGate() ==
entity) {
322 moteSpawn.advance(amount * moteSpawnMult);
324 ZigLeashAssignmentAI.spawnMote(
entity);
336 return entity.getRadius() + 500f;
341 Color color =
entity.getFaction().getBaseUIColor();
353 tooltip.addPara(
entity.getName(), color, 0);
357 tooltip.addPara(
"Active", Misc.getGrayColor(), 3f);
359 tooltip.addPara(
"Scanned", Misc.getGrayColor(), 3f);
372 tooltip.setParaFontDefault();
374 tooltip.addPara(
"This gate is active.", Misc.getGrayColor(), 10f);
376 tooltip.addPara(
"You've scanned this gate.", Misc.getGrayColor(), 10f);
385 CustomEntitySpecAPI spec =
entity.getCustomEntitySpec();
388 baseSprite.setSize(spec.getSpriteWidth(), spec.getSpriteHeight());
395 rays.setSize(
rays.getWidth() * scale,
rays.getHeight() * scale);
403 public void render(CampaignEngineLayers layer, ViewportAPI viewport) {
404 if (layer == CampaignEngineLayers.BELOW_STATIONS) {
407 float alphaMult = viewport.getAlphaMult();
408 alphaMult *=
entity.getSensorFaderBrightness();
409 alphaMult *=
entity.getSensorContactFaderBrightness();
410 if (alphaMult <= 0f)
return;
415 warp =
new WarpingSpriteRendererUtil(cells, cells, cs * 0.2f, cs * 0.2f, 2f);
418 Vector2f loc =
entity.getLocation();
420 float glowAlpha = 1f;
425 starfield.setAlphaMult(alphaMult * glowAlpha);
429 GL11.glEnable(GL11.GL_BLEND);
430 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
431 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
433 loc.y -
starfield.getHeight() / 2f,
false);
436 if (layer == CampaignEngineLayers.STATIONS) {
437 float alphaMult = viewport.getAlphaMult();
438 alphaMult *=
entity.getSensorFaderBrightness();
439 alphaMult *=
entity.getSensorContactFaderBrightness();
440 if (alphaMult <= 0f)
return;
442 CustomEntitySpecAPI spec =
entity.getCustomEntitySpec();
443 if (spec ==
null)
return;
445 float w = spec.getSpriteWidth();
446 float h = spec.getSpriteHeight();
450 Vector2f loc =
entity.getLocation();
453 Color scannedGlowColor =
new Color(255,200,0,255);
454 Color activeGlowColor =
new Color(200,50,255,255);
456 scannedGlowColor = Color.white;
457 activeGlowColor = Color.white;
459 float glowAlpha = 1f;
462 float glowMod1 = 0.5f + 0.5f *
glowFader.getBrightness();
463 float glowMod2 = 0.75f + 0.25f *
glowFader.getBrightness();
473 if (c ==
null) c =
new Color(255,255,255,255);
482 if (!active && scanned) {
485 scannedGlow.setAlphaMult(alphaMult * glowAlpha * glowMod1);
490 if (active && scanned) {
493 activeGlow.setAlphaMult(alphaMult * glowAlpha * glowMod2);
512 rays.setAlphaMult(alphaMult * glowAlpha);
513 rays.setAdditiveBlend();
514 rays.renderAtCenter(loc.x + 1.5f, loc.y);
516 concentric.setAlphaMult(alphaMult * glowAlpha * 1f);
518 concentric.renderAtCenter(loc.x + 1.5f, loc.y);
521 angle = Misc.normalizeAngle(angle);
523 whirl1.setAlphaMult(alphaMult * glowAlpha);
524 whirl1.setAdditiveBlend();
525 whirl1.renderAtCenter(loc.x + 1.5f, loc.y);
528 angle = Misc.normalizeAngle(angle);
530 whirl2.setAlphaMult(alphaMult * glowAlpha * 0.5f);
531 whirl2.setAdditiveBlend();
532 whirl2.renderAtCenter(loc.x + 1.5f, loc.y);
static SettingsAPI getSettings()
static SoundPlayerAPI getSoundPlayer()
static SectorAPI getSector()
transient boolean scaledSprites
static String CAN_SCAN_GATES
static GateData getGateData()
void showBeingUsed(float dur, float transitDistLY)
transient SpriteAPI starfield
static int getNumGatesScanned()
void setJitterColor(Color jitterColor)
static boolean canUseGates()
static boolean isScanned(SectorEntityToken gate)
float getProximitySoundFactor()
void init(SectorEntityToken entity, Object pluginParams)
void createMapTooltip(TooltipMakerAPI tooltip, boolean expanded)
static boolean isActive(SectorEntityToken gate)
static String GATES_ACTIVE
static void addGateScanned()
transient SpriteAPI activeGlow
transient SpriteAPI whirl2
transient SpriteAPI whirl1
static String NUM_GATES_SCANNED
void appendToCampaignTooltip(TooltipMakerAPI tooltip, VisibilityLevel level)
static float ACCUMULATED_TRANSIT_DIST_DECAY_RATE
void render(CampaignEngineLayers layer, ViewportAPI viewport)
static String GATE_SCANNED
static String PLAYER_CAN_USE_GATES
static float MOTE_SPAWN_MULT_BASELINE_DIST_LY
void showBeingUsed(float transitDistLY)
transient SpriteAPI concentric
transient WarpingSpriteRendererUtil warp
boolean hasCustomMapTooltip()
transient SpriteAPI scannedGlow
static boolean areGatesActive()
void advance(float amount)
transient SpriteAPI baseSprite
float accumulatedTransitDistLY
SpriteAPI getSprite(String filename)
void playLoop(String id, Object playingEntity, float pitch, float volume, Vector2f loc, Vector2f vel)