1package com.fs.starfarer.api.impl.campaign.skills;
3import java.util.ArrayList;
4import java.util.LinkedHashMap;
10import org.lwjgl.input.Mouse;
12import com.fs.starfarer.api.Global;
13import com.fs.starfarer.api.characters.PersonAPI;
14import com.fs.starfarer.api.combat.BaseEveryFrameCombatPlugin;
15import com.fs.starfarer.api.combat.CombatEngineAPI;
16import com.fs.starfarer.api.combat.CombatFleetManagerAPI;
17import com.fs.starfarer.api.combat.DeployedFleetMemberAPI;
18import com.fs.starfarer.api.combat.ShipAIPlugin;
19import com.fs.starfarer.api.combat.ShipAPI;
20import com.fs.starfarer.api.combat.ShipCommand;
21import com.fs.starfarer.api.combat.ViewportAPI;
22import com.fs.starfarer.api.combat.WeaponGroupAPI;
23import com.fs.starfarer.api.impl.campaign.ids.Stats;
24import com.fs.starfarer.api.impl.hullmods.NeuralInterface;
25import com.fs.starfarer.api.input.InputEventAPI;
26import com.fs.starfarer.api.loading.WeaponGroupSpec;
27import com.fs.starfarer.api.mission.FleetSide;
47 public static class SavedShipControlState {
49 public Map<WeaponGroupAPI, Boolean> autofiring =
new LinkedHashMap<WeaponGroupAPI, Boolean>();
63 protected List<ShipAPI>
linked =
new ArrayList<ShipAPI>();
76 savedState.ship = ship;
78 savedState.autofiring.put(group, group.isAutofiring());
91 if (index >= groups.size())
break;
93 boolean auto = groupSpec.isAutofireOnByDefault();
104 if (groups.size() >= 1) {
112 Boolean auto =
prevState.autofiring.get(group);
113 if (auto ==
null) auto =
false;
126 public void advance(
float amount, List<InputEventAPI> events) {
127 if (
engine ==
null)
return;
132 if (playerShip ==
null) {
158 if (playerShip.
getAI() ==
null) {
204 if (playerShip ==
null)
return;
206 Color color =
new Color(0,121,216,255);
220 getFloatySize(playerShip), color, playerShip, 4f * timeMult, 0.8f/timeMult, 1f/timeMult, 0f, 0f,
245 boolean aliveOrDisabledButNonPhysical = ship.
isAlive();
247 if (ship == playerShip && ship != physicalLocation) {
248 aliveOrDisabledButNonPhysical =
true;
251 return aliveOrDisabledButNonPhysical && !ship.
isShuttlePod() &&
258 if (playerShip ==
null)
return;
262 if (!ship.isAlive()) {
263 if (ship == playerShip && ship != physicalLocation) {
267 if (ship != playerShip) {
268 PersonAPI orig = ship.getOriginalCaptain();
275 ship.setCaptain(orig);
281 boolean physicallyPresent =
linked.contains(physicalLocation);
282 if (!
linked.contains(playerShip) || !physicallyPresent ||
285 PersonAPI orig = ship.getOriginalCaptain();
292 if (ship.getCaptain() != orig) {
293 ship.setCaptain(orig);
294 if (ship.getFleetMember() !=
null) {
295 ship.getFleetMember().setCaptain(ship.getOriginalCaptain());
305 if (
linked.isEmpty())
return;
311 if (physicallyPresent) {
313 if (
linked.size() >= 2)
break;
315 if (dfm.isFighterWing())
continue;
316 if (dfm.isAlly())
continue;
319 if (
linked.contains(ship))
continue;
343 if (player ==
null) {
351 if (ship.getCaptain() != player) {
352 ship.setCaptain(player);
353 if (ship.getFleetMember() !=
null) {
354 ship.getFleetMember().setCaptain(player);
359 if (
linked.contains(playerShip)) {
362 if (ship != playerShip) {
368 String title =
"Neural System Reset";
374 Float timeout =
null;
375 if (other !=
null) timeout = (Float) other.
getCustomData().get(key);
376 if (timeout ==
null) timeout = 0f;
379 }
else if (timeout <= 0) {
382 int show = (int) Math.ceil(timeout);
388 if (ship != playerShip) {
391 String title =
"Neural Link Active";
394 String data =
"Target: " + ship.getHullSpec().getHullNameWithDashClass();
400 String title =
"Neural Transfer";
401 String data =
"Link in " + show +
" seconds";
411 if (
linked.size() <= 1 &&
linked.contains(playerShip)) {
412 String title =
"Neural Link Inactive";
413 String data =
"No signal";
414 if (!physicallyPresent) {
415 data =
"requires physical transfer";
427 if (playerShip ==
null)
return;
428 if (!
linked.contains(playerShip) ||
linked.size() < 2)
return;
432 if (event.isConsumed())
continue;
437 if (ship != playerShip) {
452 if (ship ==
null)
return;
454 if (playerShip ==
null)
return;
455 if (!
linked.contains(playerShip))
return;
456 if (!
linked.contains(ship))
return;
484 if (playerShipAI !=
null) {
497 }
else if (autopilot) {
514 boolean instant =
false;
516 if (ship.getFleetMember() ==
null)
continue;
517 total += ship.getFleetMember().getDeploymentPointsCost();
524 total = Math.round(total);
525 if (instant) total = 0f;
537 time = (float) Math.ceil(time);
551 case FIGHTER:
return 15f;
552 case FRIGATE:
return 17f;
553 case DESTROYER:
return 21f;
554 case CRUISER:
return 24f;
555 case CAPITAL_SHIP:
return 27f;
static SettingsAPI getSettings()
static SoundPlayerAPI getSoundPlayer()
static FactoryAPI getFactory()
static CombatEngineAPI getCombatEngine()
static SectorAPI getSector()
float computeEffective(float baseValue)
static final String INSTANT_NEURAL_TRANSFER_FROM
static final String HAS_NEURAL_LINK
void suppressControlsDuringTransfer(ShipAPI playerShip)
static float TRANSFER_MIN_SECONDS_IF_NOT_INSTANT
static final String TRANSFER_COMPLETE_KEY
void renderInWorldCoords(ViewportAPI viewport)
static boolean ALLOW_ENGINE_CONTROL_DURING_TRANSFER
void renderInUICoords(ViewportAPI viewport)
static String TRANSFER_CONTROL
SavedShipControlState prevState
void processInputPreCoreControls(float amount, List< InputEventAPI > events)
static float getFloatySize(ShipAPI ship)
void saveControlState(ShipAPI ship)
void restoreControlState(ShipAPI ship)
void init(CombatEngineAPI engine)
void doTransfer(ShipAPI ship)
static float TRANSFER_MAX_SECONDS
static float INSTANT_TRANSFER_DP
void advance(float amount, List< InputEventAPI > events)
static final Object KEY_STATUS2
static final Object KEY_STATUS
void showTranferFloatyIfNeeded()
SavedShipControlState savedState
static float TRANSFER_SECONDS_PER_DP
boolean canLink(ShipAPI ship)
static final String SYSTEM_RESET_TIMEOUT_KEY
String getSpriteName(String category, String id)
float getScreenWidthPixels()
ShipAIPlugin pickShipAIPlugin(FleetMemberAPI member, ShipAPI ship)
float getScreenHeightPixels()
void applyLowPassFilter(float gain, float gainHF)
SoundAPI playUISound(String id, float pitch, float volume)
FactionAPI getPlayerFaction()
MutableCharacterStatsAPI getPlayerStats()
DynamicStatsAPI getDynamic()
void setPersonality(String personality)
CombatUIAPI getCombatUI()
ShipAPI getShipPlayerLastTransferredCommandTo()
void maintainStatusForPlayerShip(Object key, String spriteName, String title, String data, boolean isDebuff)
CombatFleetManagerAPI getFleetManager(FleetSide side)
boolean isInCampaignSim()
void addFloatingTextAlways(Vector2f loc, String text, float size, Color color, CombatEntityAPI attachedTo, float flashFrequency, float flashDuration, float durInPlace, float durFloatingUp, float durFadingOut, float baseAlpha)
void setPlayerShipExternal(ShipAPI ship)
void setCustomData(String key, Object data)
Map< String, Object > getCustomData()
List< DeployedFleetMemberAPI > getDeployedCopyDFM()
DeployedFleetMemberAPI getDeployedFleetMember(ShipAPI ship)
void setDisablePlayerShipControlOneFrame(boolean disablePlayerShipControlOneFrame)
boolean isShowingCommandUI()
FleetMemberAPI getMember()
DynamicStatsAPI getDynamic()
MutableStat getTimeMult()
MutableShipStatsAPI getMutableStats()
WeaponGroupAPI getSelectedGroupAPI()
PersonAPI getOriginalCaptain()
FleetMemberAPI getFleetMember()
void setShipAI(ShipAIPlugin ai)
ShipVariantAPI getVariant()
List< WeaponGroupAPI > getWeaponGroupsCopy()
void blockCommandForOneFrame(ShipCommand command)
void giveCommand(ShipCommand command, Object param, int groupNumber)
List< WeaponGroupSpec > getWeaponGroups()
void setCaptain(PersonAPI commander)
float getValue(String id)
StatBonus getMod(String id)