60 angle = Misc.normalizeAngle(angle);
62 float index = angle / 360f * resolution;
63 int i1 = (int) Math.floor(index);
64 int i2 = (int) Math.ceil(index);
65 while (i1 >= resolution) i1 -= resolution;
66 while (i2 >= resolution) i2 -= resolution;
71 return v1 + (v2 - v1) * (index - (
int) index);
94 public void updateLimits(SectorEntityToken entity, SectorEntityToken exclude,
float diffMult) {
97 for (
int i = 0; i < resolution; i++) {
101 isAnythingShortened =
false;
103 for (PlanetAPI planet : entity.getContainingLocation().getPlanets()) {
104 if (planet == entity || planet == exclude)
continue;
105 float dist = Misc.getDistance(entity.getLocation(), planet.getLocation());
106 if (dist > maxRange)
continue;
108 float graceRadius = 100f;
110 graceRadius = planet.getRadius() + 100f;
111 float span = Misc.computeAngleSpan(planet.getRadius() + graceRadius, dist);
113 float angle = Misc.getAngleInDegrees(entity.getLocation(), planet.getLocation());
115 float offsetSize = maxRange * 0.2f;
117 float spanOffset = span * 0.4f * 1f / diffMult;
119 for (
float f = angle - span/2f - spanOffset; f <= angle + span/2f - spanOffset; f += degreesPerUnit) {
120 float offset = Math.abs(f - angle) / (span / 2f);
121 if (offset > 1) offset = 1;
122 offset = (1f - (float) Math.cos(offset * 3.1416f / 2f));
129 offset *= offsetSize;
133 limits[index] = Math.min(dist - (planet.getRadius()) * 0.5f + offset, limits[index]);
134 isAnythingShortened =
true;
141 public void block(
float angle,
float arc,
float limit) {
143 float offsetSize = Math.max(limit, maxRange * 0.1f);
145 for (
float f = angle - arc/2f; f <= angle + arc/2f; f += degreesPerUnit) {
147 float offset = Math.abs(f - angle) / (arc / 2f);
148 if (offset > 1) offset = 1;
149 offset = (1f - (float) Math.cos(offset * 3.1416f / 2f));
153 offset *= offsetSize;
155 offset = Math.abs(offset);
158 limits[index] = Math.min(limit + offset, limits[index]);
159 isAnythingShortened =
true;