001package com.fs.starfarer.api.impl.combat; 002 003import java.awt.Color; 004 005import com.fs.starfarer.api.Global; 006import com.fs.starfarer.api.combat.MutableShipStatsAPI; 007import com.fs.starfarer.api.combat.ShipAPI; 008 009public class TemporalShellStats extends BaseShipSystemScript { 010 public static final float MAX_TIME_MULT = 3f; 011 public static final float MIN_TIME_MULT = 0.1f; 012 public static final float DAM_MULT = 0.1f; 013 014 public static final Color JITTER_COLOR = new Color(90,165,255,55); 015 public static final Color JITTER_UNDER_COLOR = new Color(90,165,255,155); 016 017 018 public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) { 019 ShipAPI ship = null; 020 boolean player = false; 021 if (stats.getEntity() instanceof ShipAPI) { 022 ship = (ShipAPI) stats.getEntity(); 023 player = ship == Global.getCombatEngine().getPlayerShip(); 024 id = id + "_" + ship.getId(); 025 } else { 026 return; 027 } 028 029 float jitterLevel = effectLevel; 030 float jitterRangeBonus = 0; 031 float maxRangeBonus = 10f; 032 if (state == State.IN) { 033 jitterLevel = effectLevel / (1f / ship.getSystem().getChargeUpDur()); 034 if (jitterLevel > 1) { 035 jitterLevel = 1f; 036 } 037 jitterRangeBonus = jitterLevel * maxRangeBonus; 038 } else if (state == State.ACTIVE) { 039 jitterLevel = 1f; 040 jitterRangeBonus = maxRangeBonus; 041 } else if (state == State.OUT) { 042 jitterRangeBonus = jitterLevel * maxRangeBonus; 043 } 044 jitterLevel = (float) Math.sqrt(jitterLevel); 045 effectLevel *= effectLevel; 046 047 ship.setJitter(this, JITTER_COLOR, jitterLevel, 3, 0, 0 + jitterRangeBonus); 048 ship.setJitterUnder(this, JITTER_UNDER_COLOR, jitterLevel, 25, 0f, 7f + jitterRangeBonus); 049 050 051 float shipTimeMult = 1f + (MAX_TIME_MULT - 1f) * effectLevel; 052 stats.getTimeMult().modifyMult(id, shipTimeMult); 053 if (player) { 054 Global.getCombatEngine().getTimeMult().modifyMult(id, 1f / shipTimeMult); 055// if (ship.areAnyEnemiesInRange()) { 056// Global.getCombatEngine().getTimeMult().modifyMult(id, 1f / shipTimeMult); 057// } else { 058// Global.getCombatEngine().getTimeMult().modifyMult(id, 2f / shipTimeMult); 059// } 060 } else { 061 Global.getCombatEngine().getTimeMult().unmodify(id); 062 } 063 064 ship.getEngineController().fadeToOtherColor(this, JITTER_COLOR, new Color(0,0,0,0), effectLevel, 0.5f); 065 ship.getEngineController().extendFlame(this, -0.25f, -0.25f, -0.25f); 066 } 067 068 069 public void unapply(MutableShipStatsAPI stats, String id) { 070 ShipAPI ship = null; 071 boolean player = false; 072 if (stats.getEntity() instanceof ShipAPI) { 073 ship = (ShipAPI) stats.getEntity(); 074 player = ship == Global.getCombatEngine().getPlayerShip(); 075 id = id + "_" + ship.getId(); 076 } else { 077 return; 078 } 079 080 Global.getCombatEngine().getTimeMult().unmodify(id); 081 stats.getTimeMult().unmodify(id); 082 083// stats.getHullDamageTakenMult().unmodify(id); 084// stats.getArmorDamageTakenMult().unmodify(id); 085// stats.getEmpDamageTakenMult().unmodify(id); 086 } 087 088 public StatusData getStatusData(int index, State state, float effectLevel) { 089 float shipTimeMult = 1f + (MAX_TIME_MULT - 1f) * effectLevel; 090 if (index == 0) { 091 return new StatusData("time flow altered", false); 092 } 093// if (index == ) { 094// return new StatusData("increased speed", false); 095// } 096// if (index == 1) { 097// return new StatusData("increased acceleration", false); 098// } 099 return null; 100 } 101} 102 103 104 105 106 107 108 109