001package com.fs.starfarer.api.impl.campaign.intel.misc; 002 003import java.util.Set; 004 005import com.fs.starfarer.api.Global; 006import com.fs.starfarer.api.campaign.CampaignTerrainAPI; 007import com.fs.starfarer.api.campaign.PlanetAPI; 008import com.fs.starfarer.api.campaign.SectorEntityToken; 009import com.fs.starfarer.api.campaign.econ.MarketAPI.SurveyLevel; 010import com.fs.starfarer.api.impl.campaign.ids.Tags; 011import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin; 012import com.fs.starfarer.api.impl.campaign.terrain.DebrisFieldTerrainPlugin; 013import com.fs.starfarer.api.ui.SectorMapAPI; 014 015/** 016 * Implements EveryFrameScript because of deriving from BaseIntelPlugin, but not actually 017 * expected to be added as a script to anything unless that's necessary for the specific subclass. 018 * 019 * Copyright 2018 Fractal Softworks, LLC 020 */ 021public class FleetLogIntel extends BaseIntelPlugin { 022 023 public static Object DISCOVERED_PARAM = new Object(); 024 025 public static float DEFAULT_DURATION = 365f; 026 027 protected Float duration = null; 028 protected SectorEntityToken removeTrigger = null; 029 protected Boolean keepExploredDebrisField = null; 030 protected Boolean removeSurveyedPlanet = null; 031 protected String icon = null; 032 protected String iconId = null; 033 protected String sound = null; 034 035 public FleetLogIntel() { 036 } 037 038 public FleetLogIntel(float duration) { 039 this.duration = duration; 040 } 041 042 public void setDefaultExpiration() { 043 duration = DEFAULT_DURATION; 044 } 045 046 public void setDuration(float days) { 047 duration = days; 048 } 049 050 public String getSortString() { 051 return getSortStringNewestFirst(); 052 } 053 054 public Boolean getKeepExploredDebrisField() { 055 return keepExploredDebrisField; 056 } 057 058 public void setKeepExploredDebrisField(Boolean keepExploredDebrisField) { 059 this.keepExploredDebrisField = keepExploredDebrisField; 060 } 061 062 public Boolean getRemoveSurveyedPlanet() { 063 return removeSurveyedPlanet; 064 } 065 066 public void setRemoveSurveyedPlanet(Boolean removeSurveyedPlanet) { 067 this.removeSurveyedPlanet = removeSurveyedPlanet; 068 } 069 070 @Override 071 public boolean shouldRemoveIntel() { 072 if (isEnded()) return true; 073 074 if (removeTrigger != null) { 075 if (!removeTrigger.isAlive()) return true; 076 if (removeTrigger instanceof CampaignTerrainAPI && keepExploredDebrisField == null) { 077 CampaignTerrainAPI terrain = (CampaignTerrainAPI) removeTrigger; 078 if (terrain.getPlugin() instanceof DebrisFieldTerrainPlugin) { 079 DebrisFieldTerrainPlugin debris = (DebrisFieldTerrainPlugin) terrain.getPlugin(); 080 if (debris.isScavenged()) return true; 081 } 082 } else if (removeTrigger instanceof PlanetAPI) { 083 if (removeSurveyedPlanet != null && removeSurveyedPlanet) { 084 PlanetAPI planet = (PlanetAPI) removeTrigger; 085 if (planet.getMarket() != null && planet.getMarket().getSurveyLevel() == SurveyLevel.FULL) { 086 return true; 087 } 088 } 089 } 090 } 091 092 if (isImportant() || duration == null) return false; 093 094 Long ts = getPlayerVisibleTimestamp(); 095 if (ts == null) return false; 096 return Global.getSector().getClock().getElapsedDaysSince(ts) >= duration; 097 098// float dur = DEFAULT_DURATION; 099// if (duration != null) dur = duration; 100// return Global.getSector().getClock().getElapsedDaysSince(ts) >= dur; 101 } 102 103 104 105 public String getIconId() { 106 return iconId; 107 } 108 109 public void setIconId(String iconId) { 110 this.iconId = iconId; 111 } 112 113 public void setIcon(String icon) { 114 this.icon = icon; 115 } 116 117 @Override 118 public String getIcon() { 119 if (iconId != null) { 120 return Global.getSettings().getSpriteName("intel", iconId); 121 } 122 if (icon != null) return icon; 123 return Global.getSettings().getSpriteName("intel", "fleet_log"); 124 } 125 126 @Override 127 public Set<String> getIntelTags(SectorMapAPI map) { 128 Set<String> tags = super.getIntelTags(map); 129 tags.add(Tags.INTEL_FLEET_LOG); 130 return tags; 131 } 132 133 public SectorEntityToken getRemoveTrigger() { 134 return removeTrigger; 135 } 136 137 public void setRemoveTrigger(SectorEntityToken removeTrigger) { 138 this.removeTrigger = removeTrigger; 139 } 140 141 public String getSound() { 142 return sound; 143 } 144 145 public void setSound(String sound) { 146 this.sound = sound; 147 } 148 149 @Override 150 public String getCommMessageSound() { 151 if (sound != null) return sound; 152 return getSoundLogUpdate(); 153 } 154 155} 156 157 158 159 160