001package com.fs.starfarer.api.impl.campaign.terrain;
002
003import java.awt.Color;
004
005import org.lwjgl.util.vector.Vector2f;
006
007import com.fs.starfarer.api.Global;
008import com.fs.starfarer.api.campaign.PlanetAPI;
009import com.fs.starfarer.api.campaign.SectorEntityToken;
010import com.fs.starfarer.api.loading.Description.Type;
011import com.fs.starfarer.api.ui.Alignment;
012import com.fs.starfarer.api.ui.TooltipMakerAPI;
013import com.fs.starfarer.api.util.Misc;
014
015public class StarCoronaAkaMainyuTerrainPlugin extends StarCoronaTerrainPlugin {
016
017        public static final float ARC = 100f;
018        
019        @Override
020        public float getAuroraAlphaMultForAngle(float angle) {
021                SectorEntityToken star = params.relatedEntity.getLightSource();
022                if (star != null) {
023                        float toStar = Misc.getAngleInDegrees(params.relatedEntity.getLocation(), star.getLocation());
024                        float diff = Misc.getAngleDiff(toStar, angle);
025                        float max = ARC / 2f;
026                        if (diff < max) {
027                                return Math.max(0, 1f - diff / max);
028                        }
029                        return 0f;
030                }
031                
032                return 1f;
033        }
034
035        @Override
036        public Color getAuroraColorForAngle(float angle) {
037                if (color == null) {
038                        if (params.relatedEntity instanceof PlanetAPI) {
039                                color = ((PlanetAPI)params.relatedEntity).getSpec().getAtmosphereColor();
040                                //color = Misc.interpolateColor(color, Color.white, 0.25f);
041                        } else {
042                                color = Color.white;
043                        }
044                        color = Misc.setAlpha(color, 155);
045                }
046                if (flareManager.isInActiveFlareArc(angle)) {
047                        return flareManager.getColorForAngle(color, angle);
048                }
049                return super.getAuroraColorForAngle(angle);
050        }
051
052        @Override
053        public boolean containsPoint(Vector2f point, float radius) {
054                SectorEntityToken star = params.relatedEntity.getLightSource();
055                if (star != null) {
056                        float toStar = Misc.getAngleInDegrees(params.relatedEntity.getLocation(), star.getLocation());
057                        if (!Misc.isInArc(toStar, ARC, params.relatedEntity.getLocation(), point)) {
058                                return false;
059                        }
060                }
061                return super.containsPoint(point, radius);
062        }
063
064        @Override
065        public String getTerrainName() {
066                return "Ion Storm";
067        }
068
069        @Override
070        public void createTooltip(TooltipMakerAPI tooltip, boolean expanded) {
071                float pad = 10f;
072                float small = 5f;
073                tooltip.addTitle("Ion Storm");
074                tooltip.addPara(Global.getSettings().getDescription(getTerrainId(), Type.TERRAIN).getText1(), pad);
075                float nextPad = pad;
076                if (expanded) {
077                        tooltip.addSectionHeading("Travel", Alignment.MID, small);
078                        nextPad = small;
079                }
080                tooltip.addPara("The intense heat and radiation reduce the combat readiness of " +
081                                                "all ships in the magnetotail at a steady pace.", nextPad);
082                tooltip.addPara("The ionized gas being ejected from the atmosphere makes the planet difficult to approach.", pad);
083                
084                if (expanded) {
085                        tooltip.addSectionHeading("Combat", Alignment.MID, pad);
086                        tooltip.addPara("Reduces the peak performance time of ships and increases the rate of combat readiness degradation in protracted engagements.", small);
087                }
088        }
089
090        
091        
092        
093        
094        
095        
096}