001package com.fs.starfarer.api.impl.combat;
002
003import java.awt.Color;
004
005import com.fs.starfarer.api.combat.MutableShipStatsAPI;
006import com.fs.starfarer.api.combat.ShipAPI;
007import com.fs.starfarer.api.plugins.ShipSystemStatsScript;
008
009public class PlasmaJetsStats extends BaseShipSystemScript {
010
011        public static float SPEED_BONUS = 125f;
012        public static float TURN_BONUS = 20f;
013        
014        private Color color = new Color(100,255,100,255);
015        
016//      private Color [] colors = new Color[] {
017//                      new Color(140, 100, 235),
018//                      new Color(180, 110, 210),
019//                      new Color(150, 140, 190),
020//                      new Color(140, 190, 210),
021//                      new Color(90, 200, 170), 
022//                      new Color(65, 230, 160),
023//                      new Color(20, 220, 70)
024//      };
025        
026        public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
027                if (state == ShipSystemStatsScript.State.OUT) {
028                        stats.getMaxSpeed().unmodify(id); // to slow down ship to its regular top speed while powering drive down
029                        stats.getMaxTurnRate().unmodify(id);
030                } else {
031                        stats.getMaxSpeed().modifyFlat(id, SPEED_BONUS);
032                        stats.getAcceleration().modifyPercent(id, SPEED_BONUS * 3f * effectLevel);
033                        stats.getDeceleration().modifyPercent(id, SPEED_BONUS * 3f * effectLevel);
034                        stats.getTurnAcceleration().modifyFlat(id, TURN_BONUS * effectLevel);
035                        stats.getTurnAcceleration().modifyPercent(id, TURN_BONUS * 5f * effectLevel);
036                        stats.getMaxTurnRate().modifyFlat(id, 15f);
037                        stats.getMaxTurnRate().modifyPercent(id, 100f);
038                }
039                
040                if (stats.getEntity() instanceof ShipAPI) {
041                        ShipAPI ship = (ShipAPI) stats.getEntity();
042                        
043                        ship.getEngineController().fadeToOtherColor(this, color, new Color(0,0,0,0), effectLevel, 0.67f);
044                        //ship.getEngineController().fadeToOtherColor(this, Color.white, new Color(0,0,0,0), effectLevel, 0.67f);
045                        ship.getEngineController().extendFlame(this, 2f * effectLevel, 0f * effectLevel, 0f * effectLevel);
046                        
047//                      String key = ship.getId() + "_" + id;
048//                      Object test = Global.getCombatEngine().getCustomData().get(key);
049//                      if (state == State.IN) {
050//                              if (test == null && effectLevel > 0.2f) {
051//                                      Global.getCombatEngine().getCustomData().put(key, new Object());
052//                                      ship.getEngineController().getExtendLengthFraction().advance(1f);
053//                                      for (ShipEngineAPI engine : ship.getEngineController().getShipEngines()) {
054//                                              if (engine.isSystemActivated()) {
055//                                                      ship.getEngineController().setFlameLevel(engine.getEngineSlot(), 1f);
056//                                              }
057//                                      }
058//                              }
059//                      } else {
060//                              Global.getCombatEngine().getCustomData().remove(key);
061//                      }
062                }
063        }
064        public void unapply(MutableShipStatsAPI stats, String id) {
065                stats.getMaxSpeed().unmodify(id);
066                stats.getMaxTurnRate().unmodify(id);
067                stats.getTurnAcceleration().unmodify(id);
068                stats.getAcceleration().unmodify(id);
069                stats.getDeceleration().unmodify(id);
070        }
071        
072        public StatusData getStatusData(int index, State state, float effectLevel) {
073                if (index == 0) {
074                        return new StatusData("improved maneuverability", false);
075                } else if (index == 1) {
076                        return new StatusData("+" + (int)SPEED_BONUS + " top speed", false);
077                }
078                return null;
079        }
080}