Starsector API
Loading...
Searching...
No Matches
RadialLattice.java
Go to the documentation of this file.
1package com.fs.starfarer.api.util;
2
3import java.util.ArrayList;
4import java.util.LinkedHashSet;
5import java.util.List;
6import java.util.Set;
7
8import org.lwjgl.util.vector.Vector2f;
9
10import com.fs.starfarer.api.Global;
11import com.fs.starfarer.api.campaign.CampaignFleetAPI;
12import com.fs.starfarer.api.campaign.StarSystemAPI;
13import com.fs.starfarer.api.campaign.econ.MarketAPI;
14
15public class RadialLattice {
16
17 public static class RadialLatticeBucket {
19 public Set<MarketAPI> markets = new LinkedHashSet<MarketAPI>();
20 public float angle;
21
22 public RadialLatticeBucket(float angle) {
23 this.angle = angle;
24 }
25
26
27 }
28
29 protected long updateTimestamp;
31
32 protected int numBuckets = 8;
33 protected float arc = (360 / numBuckets * 2) + 20;
34
35 public void update() {
36
37 buckets.clear();
38 float anglePer = 360f / (numBuckets * 2);
39
40 for (int i = 0; i < numBuckets; i++) {
41 RadialLatticeBucket bucket = new RadialLatticeBucket(i * anglePer);
43 }
44
45
46 CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet();
47 Vector2f origin = playerFleet.getLocation();
48
49
50 for (StarSystemAPI system : Global.getSector().getStarSystems()) {
51 float angle = Misc.getAngleInDegrees(origin, system.getLocation());
52 }
53
54 }
55
56
57 public RadialLatticeBucket getBucket(float angle) {
58 angle = Misc.normalizeAngle(angle);
59
60 float anglePer = 360f / (numBuckets * 2);
61
62 int index = (int) (angle / anglePer);
63 if (index >= numBuckets) index -= numBuckets;
64
65 return buckets.get(index);
66 }
67
68
69
70
71}
72
73
74
75
76
77
78
79
80
81
82
static SectorAPI getSector()
Definition Global.java:59
static float normalizeAngle(float angleDeg)
Definition Misc.java:1135
static float getAngleInDegrees(Vector2f v)
Definition Misc.java:1119
RadialLatticeBucket getBucket(float angle)
List< RadialLatticeBucket > buckets