001package com.fs.starfarer.api.impl.hullmods; 002 003import com.fs.starfarer.api.combat.BaseHullMod; 004import com.fs.starfarer.api.combat.MutableShipStatsAPI; 005import com.fs.starfarer.api.combat.ShipAPI; 006import com.fs.starfarer.api.combat.ShipAPI.HullSize; 007import com.fs.starfarer.api.fleet.FleetMemberAPI; 008import com.fs.starfarer.api.impl.campaign.ids.Tags; 009import com.fs.starfarer.api.ui.TooltipMakerAPI; 010import com.fs.starfarer.api.util.Misc; 011 012public class Automated extends BaseHullMod { 013 014 public static float MAX_CR_PENALTY = 1f; 015 016 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) { 017 stats.getMinCrewMod().modifyMult(id, 0); 018 stats.getMaxCrewMod().modifyMult(id, 0); 019 020 if (isInPlayerFleet(stats) && !isAutomatedNoPenalty(stats)) { 021 stats.getMaxCombatReadiness().modifyFlat(id, -MAX_CR_PENALTY, "Automated ship penalty"); 022 } 023 } 024 025 @Override 026 public void applyEffectsAfterShipCreation(ShipAPI ship, String id) { 027 ship.setInvalidTransferCommandTarget(true); 028 } 029 030 031 032 public String getDescriptionParam(int index, HullSize hullSize) { 033 //if (index == 0) return "" + (int)Math.round(MAX_CR_PENALTY * 100f) + "%"; 034 return null; 035 } 036 037 public void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec) { 038 float opad = 10f; 039 if (ship == null || ship.getHullSpec().hasTag(Tags.AUTOMATED_RECOVERABLE)) { 040 tooltip.addPara("Automated ships usually require specialized equipment and expertise to maintain, " 041 + "resulting in a maximum combat readiness penalty of %s. " 042 + "This penalty can be offset by a fleet commander skilled in the use of " 043 + "automated ships.", opad, Misc.getHighlightColor(), 044 "" + (int)Math.round(MAX_CR_PENALTY * 100f) + "%"); 045 } 046 047 if (isInPlayerFleet(ship)) { 048 boolean noPenalty = isAutomatedNoPenalty(ship); 049// String usually = ""; 050// if (noPenalty) usually = "usually "; 051 if (noPenalty) { 052 tooltip.addPara("However, this ship was automated in a fashion that does not require special expertise " 053 + "to maintain. Some of the techniques used are poorly understood, likely dating to " 054 + "an earlier period.", opad, Misc.getHighlightColor(), 055 "does not require special expertise"); 056 } 057 } 058 } 059 060 public static boolean isAutomatedNoPenalty(MutableShipStatsAPI stats) { 061 if (stats == null) return false; 062 FleetMemberAPI member = stats.getFleetMember(); 063 if (member == null) return false; 064 return member.getHullSpec().hasTag(Tags.TAG_AUTOMATED_NO_PENALTY) || 065 member.getVariant().hasTag(Tags.TAG_AUTOMATED_NO_PENALTY); 066 } 067 068 public static boolean isAutomatedNoPenalty(ShipAPI ship) { 069 if (ship == null) return false; 070 FleetMemberAPI member = ship.getFleetMember(); 071 if (member == null) return false; 072 return member.getHullSpec().hasTag(Tags.TAG_AUTOMATED_NO_PENALTY) || 073 member.getVariant().hasTag(Tags.TAG_AUTOMATED_NO_PENALTY); 074 } 075 076 public static boolean isAutomatedNoPenalty(FleetMemberAPI member) { 077 if (member == null) return false; 078 return member.getHullSpec().hasTag(Tags.TAG_AUTOMATED_NO_PENALTY) || 079 member.getVariant().hasTag(Tags.TAG_AUTOMATED_NO_PENALTY); 080 } 081 082 083// @Override 084// public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) { 085// new RoilingSwarmEffect(fighter); 086// } 087 088 089}