Starsector API
Loading...
Searching...
No Matches
HiddenCacheEntityPlugin.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign;
2
3import com.fs.starfarer.api.campaign.AsteroidAPI;
4import com.fs.starfarer.api.campaign.CampaignEngineLayers;
5import com.fs.starfarer.api.campaign.SectorEntityToken;
6import com.fs.starfarer.api.combat.ViewportAPI;
7import com.fs.starfarer.api.util.Misc;
8
10
11 private AsteroidAPI asteroid;
12
13 public void init(SectorEntityToken entity, Object pluginParams) {
14 super.init(entity, pluginParams);
15 readResolve();
16 }
17
18 Object readResolve() {
19 return this;
20 }
21
22 protected void createAsteroidIfNeeded() {
23 if (asteroid != null) return;
24 if (entity.getContainingLocation() == null) return;
25
26 asteroid = entity.getContainingLocation().addAsteroid(16f);
27 asteroid.setLocation(entity.getLocation().x, entity.getLocation().y);
28 asteroid.setFacing(Misc.random.nextFloat() * 360f);
29 entity.getContainingLocation().removeEntity(asteroid);
30// float orbitDays = 100f;
31// asteroid.setCircularOrbit(this.entity, 0f, 0f, orbitDays);
32// asteroid.addTag(Tags.NON_CLICKABLE);
33// asteroid.addTag(Tags.NO_ENTITY_TOOLTIP);
34 }
35
36 public void advance(float amount) {
37 if (entity.isInCurrentLocation()) {
39 if (asteroid != null) {
40 asteroid.advance(amount);
41 }
42 }
43 }
44
45 public float getRenderRange() {
46 return entity.getRadius() + 100f;
47 }
48
49 public void render(CampaignEngineLayers layer, ViewportAPI viewport) {
50 if (asteroid != null) {
51 asteroid.setLocation(entity.getLocation().x, entity.getLocation().y);
52 asteroid.setLightSource(entity.getLightSource(), entity.getLightColor());
53 asteroid.forceRender();
54 }
55 }
56
57}
58
59
60
61
62
void render(CampaignEngineLayers layer, ViewportAPI viewport)
void init(SectorEntityToken entity, Object pluginParams)