23 public static class NEParams
implements Cloneable {
25 public float fadeIn = 0.1f;
26 public float fadeOut = 0.5f;
27 public float spawnHitGlowAt = 0f;
28 public float hitGlowSizeMult = 0.75f;
29 public float radius = 20f;
30 public float thickness = 25f;
31 public float noiseMag = 1f;
32 public float noisePeriod = 0.1f;
33 public boolean withHitGlow =
true;
34 public Color color =
new Color(100,100,255);
36 public Color invertForDarkening =
null;
41 public NEParams(
float radius,
float thickness, Color color) {
44 this.thickness = thickness;
49 protected NEParams clone() {
51 return (NEParams) super.clone();
52 }
catch (CloneNotSupportedException e) {
84 return p.radius + 500f;
90 return EnumSet.of(CombatEngineLayers.ABOVE_PARTICLES_LOWER, CombatEngineLayers.ABOVE_PARTICLES);
96 fader.advance(amount);
106 for (
int i = 0; i <
noise.length; i++) {
109 noise[i] = n1 + (n2 - n1) * f;
113 if (!
p.withHitGlow)
return;
115 float glowSpawnAt = 1f;
117 float size = Math.min(
p.radius * 7f,
p.radius + 150f);
118 float coreSize = Math.max(size,
p.radius * 4f);
119 if (coreSize > size) size = coreSize;
121 size *=
p.hitGlowSizeMult;
122 coreSize *=
p.hitGlowSizeMult;
125 Vector2f point = entity.getLocation();
126 Vector2f vel = entity.getVelocity();
127 float dur =
fader.getDurationOut() * glowSpawnAt;
128 engine.addHitParticle(point, vel, size * 3f, 1f, dur,
p.color);
130 engine.addHitParticle(point, vel, coreSize * 1.5f, 1f, dur, Color.white);
133 Color invert =
p.color;
134 if (
p.invertForDarkening !=
null) invert =
p.invertForDarkening;
135 Color c =
new Color(255 - invert.getRed(),
136 255 - invert.getGreen(),
137 255 - invert.getBlue(), 127);
138 c = Misc.interpolateColor(c, Color.white, 0.4f);
142 for (
int i = 0; i < 7; i++) {
143 dur = 4f + 4f * (float) Math.random();
149 float nSize = size * 1f;
150 Vector2f pt = Misc.getPointAtRadius(point, nSize * 0.5f);
151 Vector2f v = Misc.getUnitVectorAtDegreeAngle((
float) Math.random() * 360f);
152 v.scale(nSize + nSize * (
float) Math.random() * 0.5f);
154 Vector2f.add(vel, v, v);
164 v =
new Vector2f(entity.getVelocity());
166 engine.addNegativeNebulaParticle(pt, v, nSize * 1f, 2f,
167 p.fadeIn / dur, 0f, dur, c);
170 dur = p.fadeIn + p.fadeOut + 2f;
172 float rampUp = (p.fadeIn +
p.fadeOut) / dur;
179 for (
int i = 0; i < 15; i++) {
181 Vector2f loc =
new Vector2f(point);
182 loc = Misc.getPointWithinRadius(loc, size * 1f);
184 float s = size * 3f * (0.25f + (float) Math.random() * 0.25f);
187 engine.addNebulaParticle(loc, entity.getVelocity(), s, 1.5f, rampUp, 0f, dur, c);
193 public void init(CombatEntityAPI entity) {
196 fader =
new FaderUtil(0f,
p.fadeIn,
p.fadeOut);
197 fader.setBounceDown(
true);
202 float perSegment = 2f;
203 segments = (int) ((
p.radius * 2f * 3.14f) / perSegment);
212 return fader.isFadedOut();
215 public void render(CombatEngineLayers layer, ViewportAPI viewport) {
216 float x = entity.getLocation().x;
217 float y = entity.getLocation().y;
219 float f =
fader.getBrightness();
220 float alphaMult = viewport.getAlphaMult();
226 float tSmall =
p.thickness;
228 if (
fader.isFadingIn()) {
229 r *= 0.75f + Math.sqrt(f) * 0.25f;
231 r *= 0.1f + 0.9f * f;
232 tSmall = Math.min(r * 1f,
p.thickness);
241 if (layer == CombatEngineLayers.ABOVE_PARTICLES_LOWER) {
245 }
else if (layer == CombatEngineLayers.ABOVE_PARTICLES) {
246 float circleAlpha = 1f;
247 if (alphaMult < 0.5f) {
248 circleAlpha = alphaMult * 2f;
250 float tCircleBorder = 1f;
251 renderCircle(x, y, r, circleAlpha,
segments, Color.black);
260 private void renderCircle(
float x,
float y,
float radius,
float alphaMult,
int segments, Color color) {
261 if (
fader.isFadingIn()) alphaMult = 1f;
263 float startRad = (float) Math.toRadians(0);
264 float endRad = (float) Math.toRadians(360);
265 float spanRad = Misc.normalizeAngle(endRad - startRad);
266 float anglePerSegment = spanRad /
segments;
269 GL11.glTranslatef(x, y, 0);
270 GL11.glRotatef(0, 0, 0, 1);
271 GL11.glDisable(GL11.GL_TEXTURE_2D);
273 GL11.glEnable(GL11.GL_BLEND);
274 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
277 GL11.glColor4ub((
byte)color.getRed(),
278 (byte)color.getGreen(),
279 (byte)color.getBlue(),
280 (byte)((
float) color.getAlpha() * alphaMult));
282 GL11.glBegin(GL11.GL_TRIANGLE_FAN);
283 GL11.glVertex2f(0, 0);
284 for (
float i = 0; i <
segments + 1; i++) {
287 float theta = anglePerSegment * i;
288 float cos = (float) Math.cos(theta);
289 float sin = (float) Math.sin(theta);
291 float m1 = 0.75f + 0.65f *
noise[(int)i];
292 if (
p.noiseMag <= 0) {
296 float x1 = cos * radius * m1;
297 float y1 = sin * radius * m1;
299 GL11.glVertex2f(x1, y1);
311 private void renderAtmosphere(
float x,
float y,
float radius,
float thickness,
float alphaMult,
int segments, SpriteAPI tex,
float []
noise, Color color,
boolean additive) {
313 float startRad = (float) Math.toRadians(0);
314 float endRad = (float) Math.toRadians(360);
315 float spanRad = Misc.normalizeAngle(endRad - startRad);
316 float anglePerSegment = spanRad /
segments;
319 GL11.glTranslatef(x, y, 0);
320 GL11.glRotatef(0, 0, 0, 1);
321 GL11.glEnable(GL11.GL_TEXTURE_2D);
325 GL11.glEnable(GL11.GL_BLEND);
327 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
329 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
332 GL11.glColor4ub((
byte)color.getRed(),
333 (byte)color.getGreen(),
334 (byte)color.getBlue(),
335 (byte)((
float) color.getAlpha() * alphaMult));
338 GL11.glBegin(GL11.GL_QUAD_STRIP);
339 for (
float i = 0; i <
segments + 1; i++) {
342 float theta = anglePerSegment * i;
343 float cos = (float) Math.cos(theta);
344 float sin = (float) Math.sin(theta);
346 float m1 = 0.75f + 0.65f *
noise[(int)i];
348 if (
p.noiseMag <= 0) {
353 float x1 = cos * radius * m1;
354 float y1 = sin * radius * m1;
355 float x2 = cos * (radius + thickness * m2);
356 float y2 = sin * (radius + thickness * m2);
358 GL11.glTexCoord2f(0.5f, 0.05f);
359 GL11.glVertex2f(x1, y1);
361 GL11.glTexCoord2f(0.5f, 0.95f);
362 GL11.glVertex2f(x2, y2);