001package com.fs.starfarer.api.campaign;
002
003import java.util.Collection;
004import java.util.List;
005import java.util.Map;
006
007import java.awt.Color;
008
009import org.lwjgl.util.vector.Vector2f;
010
011import com.fs.starfarer.api.EveryFrameScript;
012import com.fs.starfarer.api.campaign.rules.MemoryAPI;
013import com.fs.starfarer.api.impl.campaign.procgen.Constellation;
014import com.fs.starfarer.api.util.ColorShifterAPI;
015
016/**
017 * @author Alex Mosolov
018 *
019 * Copyright 2012 Fractal Softworks, LLC
020 */
021public interface LocationAPI {
022        
023        String getId();
024        
025        /**
026         * Whether the location's advance() method was/will be called this frame. Always returns true for
027         * the current location.
028         * @return
029         */
030        boolean activeThisFrame();
031        
032        String getBackgroundTextureFilename();
033        void setBackgroundTextureFilename(String backgroundTextureFilename);
034        
035        void addSpawnPoint(SpawnPointPlugin point);
036        void removeSpawnPoint(SpawnPointPlugin point);
037        List<SpawnPointPlugin> getSpawnPoints();
038        
039        void spawnFleet(SectorEntityToken anchor, float xOffset, float yOffset, CampaignFleetAPI fleet);
040
041        /**
042         * Not actually added to the location, and doesn't need to be. Can be added via addEntity if it needs to have an orbit.
043         * @param x
044         * @param y
045         * @return
046         */
047        SectorEntityToken createToken(float x, float y);
048        
049        SectorEntityToken createToken(Vector2f loc);
050        
051        
052        void addEntity(SectorEntityToken entity);
053        void removeEntity(SectorEntityToken entity);
054
055        
056        PlanetAPI addPlanet(String id, SectorEntityToken focus, String name, String type,
057                                                float angle, float radius, float orbitRadius, float orbitDays);
058        SectorEntityToken addAsteroidBelt(SectorEntityToken focus, int numAsteroids, float orbitRadius, float width, float minOrbitDays, float maxOrbitDays);
059
060        SectorEntityToken addAsteroidBelt(SectorEntityToken focus, int numAsteroids,
061                        float orbitRadius, float width, float minOrbitDays,
062                        float maxOrbitDays, String terrainId, String optionalName);
063
064        void addOrbitalJunk(SectorEntityToken focus, String junkType, int num,
065                                                float minSize, float maxSize, float orbitRadius, float width,
066                                                float minOrbitDays, float maxOrbitDays, float minSpin, float maxSpin);
067        
068        
069        /**
070         * Texture must have vertical, equal width bands in it. Each band must tile vertically with itself.
071         * 
072         * Returns a RingBandAPI - i.e. the visuals.
073         * @param focus
074         * @param category graphics category in settings.json
075         * @param key id within category
076         * @param bandWidthInTexture
077         * @param bandIndex
078         * @param color
079         * @param bandWidthInEngine
080         * @param orbitDays
081         * @param middleRadius
082         * @return
083         */
084        RingBandAPI addRingBand(SectorEntityToken focus, String category, String key,
085                                         float bandWidthInTexture, int bandIndex, Color color,
086                                         float bandWidthInEngine, float middleRadius, float orbitDays);
087
088        
089        /**
090         * Same as above, but with a "terrain" ring also being added.
091         * If there are multiple rings occupying the same location, it's best to only
092         * have one of them add terrain.
093         * 
094         * Returns the terrain entity, NOT the RingBandAPI visuals.
095         * 
096         * @param focus
097         * @param category
098         * @param key
099         * @param bandWidthInTexture
100         * @param bandIndex
101         * @param color
102         * @param bandWidthInEngine
103         * @param middleRadius
104         * @param orbitDays
105         * @param terrainId
106         * @param optionalName
107         * @return
108         */
109        SectorEntityToken addRingBand(SectorEntityToken focus, String category,
110                        String key, float bandWidthInTexture, int bandIndex, Color color,
111                        float bandWidthInEngine, float middleRadius, float orbitDays,
112                        String terrainId, String optionalName);
113
114        
115//      /**
116//       * Add station with custom graphic and radius.
117//       * @param id
118//       * @param focus
119//       * @param category key in graphics section in settings.jsno
120//       * @param key in category
121//       * @param radius radius. Sprite will be sized to (radius * 2, radius * 2)
122//       * @param angle
123//       * @param orbitRadius
124//       * @param orbitDays
125//       * @param name
126//       * @param factionId
127//       * @return
128//       */
129//      SectorEntityToken addOrbitalStation(String id, SectorEntityToken focus,
130//                                                                              String category, String key, float radius, 
131//                                                                              float angle, float orbitRadius, float orbitDays,
132//                                                                              String name, String factionId);
133//      SectorEntityToken addOrbitalStation(String id, SectorEntityToken focus,
134//                                                                              float angle, float orbitRadius, float orbitDays,
135//                                                                              String name, String factionId);
136        
137        
138        /**
139         * Adds a custom entity.
140         * Use SectorEntityToken.setFixedLocation() or .setCircularOrbit (or setOrbit) to set its location and/or orbit.
141         * @param id unique id. autogenerated if null.
142         * @param name default name for entity used if this is null
143         * @param type id in custom_entities.json
144         * @param factionId defaults to "neutral" if not specified
145         * @return
146         */
147        public CustomCampaignEntityAPI addCustomEntity(String id, String name, String type,
148                                                                                         String factionId);
149        
150        /**
151         * Adds a custom entity with a radius/spritWidth/spriteHeight different than
152         * those defined for this entity type in custom_entities.json.
153         * Use SectorEntityToken.setFixedLocation() or .setCircularOrbit (or setOrbit) to set its location and/or orbit.
154         * @param id unique id. autogenerated if null.
155         * @param name default name for entity used if this is null
156         * @param type id in custom_entities.json
157         * @param factionId defaults to "neutral" if not specified
158         * @param radius
159         * @param spriteWidth
160         * @param spriteHeight
161         * @return
162         */
163        public CustomCampaignEntityAPI addCustomEntity(String id, String name, String type,
164                                                                                         String factionId, float radius, float spriteWidth, float spriteHeight);        
165        
166        
167        public SectorEntityToken addTerrain(String terrainId, Object param);
168        
169        /**
170         * Examples:
171         *              getEntities(JumpPointAPI.class) - gets all jump points
172         *              getEntities(CampaignFleetAPI.class) - gets all fleets
173         * 
174         * General version of getFleets(), getPlanets(), etc
175         * 
176         * @param implementedClassOrInterface
177         * @return
178         */
179        List getEntities(Class implementedClassOrInterface);
180        
181        List<SectorEntityToken> getEntitiesWithTag(String tag);
182        
183        List<CampaignFleetAPI> getFleets();
184        List<PlanetAPI> getPlanets();
185        
186        /**
187         * Use getEntitiesWithTag(Tags.STATION) instead, in order to pick up custom entities
188         * that are acting as stations. Regular stations also have this tag and will also be picked
189         * up by that method.
190         * @return
191         */
192        @Deprecated List<SectorEntityToken> getOrbitalStations();
193        List<SectorEntityToken> getAsteroids(); 
194        
195        /**
196         * Use getEntityById() instead
197         * @param name
198         * @return
199         */
200        @Deprecated
201        SectorEntityToken getEntityByName(String name);
202        SectorEntityToken getEntityById(String id);
203        Vector2f getLocation();
204
205        boolean isHyperspace();
206        
207        /**
208         * Will run every time this location's advance() is called. Note that locations
209         * that are not "current" may run at a lower number of "frames" per second. 
210         * @param script
211         */
212        void addScript(EveryFrameScript script);
213        void removeScriptsOfClass(Class c);
214        void removeScript(EveryFrameScript script);
215        
216        String getName();
217        void setName(String name);
218
219        List<SectorEntityToken> getAllEntities();
220
221        
222        SectorEntityToken addCorona(SectorEntityToken star, float extraRadius, float windBurnLevel, float flareProbability, float crLossMult);
223        SectorEntityToken addCorona(SectorEntityToken star, String terrainType, float extraRadius, float windBurnLevel, float flareProbability, float crLossMult);
224        List<CampaignTerrainAPI> getTerrainCopy();
225
226        Map<String, Object> getPersistentData();
227
228        AsteroidAPI addAsteroid(float radius);
229
230        void setBackgroundOffset(float x, float y);
231
232        SectorEntityToken addRadioChatter(SectorEntityToken entity, float extraRadius);
233
234        void updateAllOrbits();
235        
236        boolean isNebula();
237
238        String getNameWithLowercaseType();
239
240        List<FleetStubAPI> getFleetStubs();
241        void removeFleetStub(FleetStubAPI stub);
242        void addFleetStub(FleetStubAPI stub);
243
244        Constellation getConstellation();
245
246        boolean isInConstellation();
247
248        String getNameWithTypeIfNebula();
249
250        Collection<String> getTags();
251        boolean hasTag(String tag);
252        void addTag(String tag);
253        void removeTag(String tag);
254        void clearTags();
255
256        CustomCampaignEntityAPI addCustomEntity(String id, String name,
257                        String type, String factionId, float radius, float spriteWidth,
258                        float spriteHeight, Object pluginParams);
259
260        CustomCampaignEntityAPI addCustomEntity(String id, String name,
261                        String type, String factionId, Object pluginParams);
262
263        List<SectorEntityToken> getJumpPoints();
264
265        long getLastPlayerVisitTimestamp();
266
267        float getDaysSinceLastPlayerVisit();
268
269        
270        /** 
271         * Similar to getEntitiesWithTag(), but for custom entities only. More performant
272         * since there are less entities to iterate through.
273         * 
274         * @param tag
275         * @return
276         */
277        List<CustomCampaignEntityAPI> getCustomEntitiesWithTag(String tag);
278
279        List<EveryFrameScript> getScripts();
280
281        void addHitParticle(Vector2f loc, Vector2f vel, float size, float brightness, float duration, Color color);
282        
283        void renderingLayersUpdated(SectorEntityToken entity);
284
285        MemoryAPI getMemoryWithoutUpdate();
286
287        ParticleControllerAPI addParticle(Vector2f loc, Vector2f vel, float size, float brightness, float rampUp, float duration, Color color);
288
289        String getNameWithNoType();
290
291        boolean isCurrentLocation();
292
293        String getNameWithLowercaseTypeShort();
294
295        String getNameWithTypeShort();
296
297        List<NascentGravityWellAPI> getGravityWells();
298
299        List<CustomCampaignEntityAPI> getCustomEntities();
300
301        ColorShifterAPI getBackgroundColorShifter();
302
303        ColorShifterAPI getBackgroundParticleColorShifter();
304
305        boolean isDeepSpace();
306
307}
308
309
310
311
312