001package com.fs.starfarer.api.combat; 002 003import java.util.List; 004 005import java.awt.Color; 006 007import org.lwjgl.util.vector.Vector2f; 008 009import com.fs.starfarer.api.AnimationAPI; 010import com.fs.starfarer.api.graphics.SpriteAPI; 011import com.fs.starfarer.api.loading.MuzzleFlashSpec; 012import com.fs.starfarer.api.loading.WeaponSlotAPI; 013import com.fs.starfarer.api.loading.WeaponSpecAPI; 014 015/** 016 * @author Alex Mosolov 017 * 018 * Copyright 2012 Fractal Softworks, LLC 019 */ 020public interface WeaponAPI { 021 022 public static interface DerivedWeaponStatsAPI { 023 float getBurstFireDuration(); 024 float getSustainedDps(); 025 float getEmpPerSecond(); 026 float getDamageOver30Sec(); 027 float getDps(); 028 float getBurstDamage(); 029 float getFluxPerDam(); 030 float getRoF(); 031 float getFluxPerSecond(); 032 float getSustainedFluxPerSecond(); 033 /** 034 * Multiplied by number of barrels for LINKED, by 2 for DUAL_LINKED, and by the number of missiles for MIRVs. 035 * @return 036 */ 037 float getDamagePerShot(); 038 float getEmpPerShot(); 039 } 040 041 public static enum WeaponType { 042 BALLISTIC("Ballistic"), 043 ENERGY("Energy"), 044 MISSILE("Missile"), 045 LAUNCH_BAY("Launch Bay"), 046 UNIVERSAL("Universal"), 047 HYBRID("Hybrid"), 048 SYNERGY("Synergy"), 049 COMPOSITE("Composite"), 050 BUILT_IN("Built in"), 051 DECORATIVE("Decorative"), 052 SYSTEM("System"), 053 STATION_MODULE("Station Module"); 054 055 private String displayName; 056 private WeaponType(String displayName) { 057 this.displayName = displayName; 058 } 059 public String getDisplayName() { 060 return displayName; 061 } 062 063 } 064 065 public static enum WeaponSize { 066 SMALL("Small"), 067 MEDIUM("Medium"), 068 LARGE("Large"); 069 070 private String displayName; 071 private WeaponSize(String name) { 072 this.displayName = name; 073 } 074 public String getDisplayName() { 075 return displayName; 076 } 077 } 078 079 public static enum AIHints { 080 PD, 081 PD_ONLY, 082 PD_ALSO, // PD, but only if there are no other targets 083 USE_VS_FRIGATES, 084 STRIKE, 085 DANGEROUS, /** like STRIKE but only for when the enemy ship is considering it, not for its own weapon use */ 086 BOMB, 087 GUIDED_POOR, 088 DO_NOT_AIM, 089 ANTI_FTR, 090 HEATSEEKER, 091 SYSTEM, 092 SHOW_IN_CODEX, 093 AUTOZOOM, 094 DO_NOT_CONSERVE, 095 CONSERVE_1, 096 CONSERVE_2, 097 CONSERVE_3, 098 CONSERVE_4, 099 CONSERVE_5, 100 CONSERVE_ALL, 101 CONSERVE_FOR_ANTI_ARMOR, 102 FIRE_WHEN_INEFFICIENT, 103 EXTRA_RANGE_ON_FIGHTER, 104 105 IGNORES_FLARES, 106 107 GROUP_LINKED, 108 GROUP_ALTERNATING, 109 110 MISSILE_SPREAD, 111 DIRECT_AIM, 112 NO_TURN_RATE_BOOST_WHEN_IDLE, 113 RESET_BARREL_INDEX_ON_BURST, 114 115 USE_LESS_VS_SHIELDS, 116 117 /** 118 * Compute range from the ship's targeting oval instead of from the slot location. 119 * Useful for swarm missile weapons where the launch point is not from the weapon slot. 120 */ 121 RANGE_FROM_TARGETING_OVAL, 122 123 /** 124 * Similar to RANGE_FROM_TARGETING_OVAL, but from ship center + radius instead. Useful for missile weapons 125 * that have a fixed maximum range rather than being limited by flight time, but - as in the case of 126 * some fragment weapons - can be launched from very different locations. 127 */ 128 RANGE_FROM_SHIP_RADIUS, 129 130 /** 131 * Increased weight for preferring to select for manual fire. 132 */ 133 IMPORTANT, 134 135 /** 136 * The weapon should not be selected for manual fire. It still might be if it's in a group with other 137 * weapons or there's no other choice. 138 */ 139 NO_MANUAL_FIRE, 140 } 141 142 143 String getId(); 144 WeaponType getType(); 145 WeaponSize getSize(); 146 147 void setPD(boolean pd); 148 149 /** 150 * Returns 0 if the target is in arc, angular distance to edge of arc otherwise. 151 * @param target 152 * @return 153 */ 154 float distanceFromArc(Vector2f target); 155 boolean isAlwaysFire(); 156 157 float getCurrSpread(); 158 float getCurrAngle(); 159 float getArcFacing(); 160 float getArc(); 161 void setCurrAngle(float angle); 162 163 float getRange(); 164 float getDisplayArcRadius(); 165 float getChargeLevel(); 166 float getTurnRate(); 167 float getProjectileSpeed(); 168 String getDisplayName(); 169 int getAmmo(); 170 int getMaxAmmo(); 171 void setMaxAmmo(int maxAmmo); 172 void resetAmmo(); 173 float getCooldownRemaining(); 174 float getCooldown(); 175 void setRemainingCooldownTo(float value); 176 177 boolean isBeam(); 178 boolean isBurstBeam(); 179 boolean isPulse(); 180 boolean requiresFullCharge(); 181 182 /** 183 * @return location, in absolute engine coordinates. 184 */ 185 Vector2f getLocation(); 186 187 /** 188 * @return whether the weapon is trying to fire or firing. Might return true if the weapon is e.g. cooling down. 189 * for weapons without cooldown/chargeup, this probably does what you think it does. 190 * for weapons with cooldown/chargeup, checking chargeLevel and cooldownRemaining is probably more sensible: 191 * if 0 < chargeLevel < 1 and cooldownRemaining <= 0, the weapon is charging up. When chargeLevel is 1, the weapon is firing 192 */ 193 boolean isFiring(); 194 195 boolean usesAmmo(); 196 boolean usesEnergy(); 197 198 boolean hasAIHint(AIHints hint); 199 CollisionClass getProjectileCollisionClass(); 200 201 void beginSelectionFlash(); 202 float getFluxCostToFire(); 203 204 float getMaxHealth(); 205 float getCurrHealth(); 206 boolean isDisabled(); 207 float getDisabledDuration(); 208 209 boolean isPermanentlyDisabled(); 210 211 DamageType getDamageType(); 212 213 ShipAPI getShip(); 214 215 /** 216 * Base stats, does not include character skill bonuses/hull mods/etc. 217 * @return 218 */ 219 DerivedWeaponStatsAPI getDerivedStats(); 220 221 void setAmmo(int ammo); 222 223 /** 224 * @return null for non-animated weapons. 225 */ 226 AnimationAPI getAnimation(); 227 228 229 /** 230 * Note: 231 * setAlphaMult() and setAngle() will be called on the sprite returned here just prior to rendering. 232 * Thus, setting these is pointless - the values will be overridden. Uses the alpha channel in SpriteAPI.setColor() 233 * and WeaponAPI.setCurrAngle() instead. 234 * 235 * @return either the base sprite, or, for animated weapons, the sprite for the current frame. 236 */ 237 SpriteAPI getSprite(); 238 239 /** 240 * "Base" sprite for the weapon (see: mjolnir.wpn), or null. 241 * @return 242 */ 243 SpriteAPI getUnderSpriteAPI(); 244 245 /** 246 * Sprite with the weapon barrels, or null if the weapon doesn't use recoil/separate barrel graphics. 247 * @return 248 */ 249 SpriteAPI getBarrelSpriteAPI(); 250 /** 251 * Renders the barrel. Shouldn't need to do this unless for shaders etc. 252 * @param alphaMult 253 */ 254 void renderBarrel(SpriteAPI sprite, Vector2f loc, float alphaMult); 255 /** 256 * Whether the barrel goes below or above the weapon sprite. 257 * @return 258 */ 259 boolean isRenderBarrelBelow(); 260 261 262 void disable(); 263 264 void disable(boolean permanent); 265 266 void repair(); 267 268 WeaponSpecAPI getSpec(); 269 WeaponSlotAPI getSlot(); 270 271 EveryFrameWeaponEffectPlugin getEffectPlugin(); 272 273 List<MissileRenderDataAPI> getMissileRenderData(); 274 DamageAPI getDamage(); 275 float getProjectileFadeRange(); 276 boolean isDecorative(); 277 void ensureClonedSpec(); 278 float getAmmoPerSecond(); 279 void setPDAlso(boolean pdAlso); 280 void setCurrHealth(float currHealth); 281 MuzzleFlashSpec getMuzzleFlashSpec(); 282 List<BeamAPI> getBeams(); 283 Vector2f getFirePoint(int barrel); 284 void setTurnRateOverride(Float turnRateOverride); 285 SpriteAPI getGlowSpriteAPI(); 286 AmmoTrackerAPI getAmmoTracker(); 287 void setRefireDelay(float delay); 288 void setFacing(float facing); 289 void updateBeamFromPoints(); 290 boolean isKeepBeamTargetWhileChargingDown(); 291 void setKeepBeamTargetWhileChargingDown(boolean keepTargetWhileChargingDown); 292 void setScaleBeamGlowBasedOnDamageEffectiveness(boolean scaleGlowBasedOnDamageEffectiveness); 293 void setForceFireOneFrame(boolean forceFire); 294 void setGlowAmount(float glow, Color glowColor); 295 void setForceNoFireOneFrame(boolean forceNoFireOneFrame); 296 void setSuspendAutomaticTurning(boolean suspendAutomaticTurning); 297 float getBurstFireTimeRemaining(); 298 Vector2f getRenderOffsetForDecorativeBeamWeaponsOnly(); 299 void setRenderOffsetForDecorativeBeamWeaponsOnly(Vector2f renderOffsetForDecorativeBeamWeaponsOnly); 300 float getRefireDelay(); 301 void forceShowBeamGlow(); 302 boolean isInBurst(); 303 WeaponSpecAPI getOriginalSpec(); 304 void setWeaponGlowWidthMult(float weaponGlowWidthMult); 305 void setWeaponGlowHeightMult(float weaponGlowHeightMult); 306 void stopFiring(); 307 boolean isForceDisabled(); 308 void setForceDisabled(boolean forceDisabled); 309 Object getCustom(); 310 void setCustom(Object custom); 311 boolean isForceNoFireOneFrame(); 312} 313 314