43 public void advance(
float amount, CombatEngineAPI engine, WeaponAPI weapon) {
44 if (
trails ==
null)
return;
46 Iterator<CryofluxTransducerEffect> iter =
trails.iterator();
47 while (iter.hasNext()) {
48 if (iter.next().isExpired()) iter.remove();
52 if (weapon.getShip() !=
null) {
53 float maxRange = weapon.getRange();
54 ShipAPI ship = weapon.getShip();
55 Vector2f com =
new Vector2f();
58 Vector2f source = weapon.getLocation();
60 if (curr.proj !=
null) {
61 Vector2f.add(com, curr.proj.getLocation(), com);
62 weight += curr.proj.getBrightness();
63 totalDist += Misc.getDistance(source, curr.proj.getLocation());
67 com.scale(1f / weight);
68 float volume = Math.min(weight, 1f);
70 totalDist /= (float)
trails.size();
71 float mult = totalDist / Math.max(maxRange, 1f);
73 if (mult > 1f) mult = 1f;
74 if (mult < 0f) mult = 0f;
75 mult = (float) Math.sqrt(mult);
88 for (
int i = 0; i < numIter; i++) {
91 if (trail.prev !=
null && !trail.prev.isExpired() &&
Global.
getCombatEngine().isEntityInPlay(trail.prev)) {
92 float dist1 = Misc.getDistance(trail.prev.getLocation(), trail.proj.getLocation());
93 if (dist1 < trail.proj.getProjectileSpec().getLength() * 1f) {
94 float maxSpeed = trail.prev.getMoveSpeed() * 0.5f;
96 float e = trail.prev.getElapsed();
99 maxSpeed *= Math.max(0.25f, 1f - (e - t) * 0.5f);
101 if (dist1 < 20f && e > t) {
102 maxSpeed *= dist1 / 20f;
105 Vector2f driftTo = Misc.closestPointOnLineToPoint(trail.proj.getLocation(), trail.proj.getTailEnd(), trail.prev.getLocation());
106 float dist = Misc.getDistance(driftTo, trail.prev.getLocation());
107 Vector2f diff = Vector2f.sub(driftTo, trail.prev.getLocation(),
new Vector2f());
108 diff = Misc.normalise(diff);
109 diff.scale(Math.min(dist, maxSpeed * amount));
110 Vector2f.add(trail.prev.getLocation(), diff, trail.prev.getLocation());
111 Vector2f.add(trail.prev.getTailEnd(), diff, trail.prev.getTailEnd());
119 public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point,
boolean shieldHit, ApplyDamageResultAPI damageResult, CombatEngineAPI engine) {
120 Color color = projectile.getProjectileSpec().getFringeColor();
125 Vector2f vel =
new Vector2f();
126 if (target instanceof ShipAPI) {
127 vel.set(target.getVelocity());
130 float size = projectile.getProjectileSpec().getWidth() * 1f;
132 float sizeMult = Misc.getHitGlowSize(100f, projectile.getDamage().getBaseDamage(), damageResult) / 100f;
137 Color c = Misc.scaleAlpha(color, projectile.getBrightness());
138 engine.addNebulaParticle(point, vel, size, 5f + 3f * sizeMult,
145 Misc.playSound(damageResult, point, vel,
146 "cryoflamer_hit_shield_light",
147 "cryoflamer_hit_shield_solid",
148 "cryoflamer_hit_shield_heavy",
149 "cryoflamer_hit_light",
150 "cryoflamer_hit_solid",
151 "cryoflamer_hit_heavy");
155 public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine) {
156 String prevKey =
"cryo_prev_" + weapon.getShip().getId() +
"_" + weapon.getSlot().getId();
157 DamagingProjectileAPI
prev = (DamagingProjectileAPI) engine.getCustomData().get(prevKey);
160 CombatEntityAPI e = engine.addLayeredRenderingPlugin(trail);
161 e.getLocation().set(projectile.getLocation());
163 engine.getCustomData().put(prevKey, projectile);
166 trails =
new ArrayList<CryofluxTransducerEffect>();
247 for (
int i = 0; i < num; i++) {
251 float length =
proj.getProjectileSpec().getLength();
252 float width =
proj.getProjectileSpec().getWidth();
256 float f = index / (
particles.size() - 1);
257 Vector2f dir = Misc.getUnitVectorAtDegreeAngle(
proj.getFacing() + 180f);
258 dir.scale(length * f);
259 Vector2f.add(p.offset, dir, p.offset);
261 p.offset = Misc.getPointWithinRadius(p.offset, width * 0.5f);
299 public void render(CombatEngineLayers layer, ViewportAPI viewport) {
300 float x = entity.getLocation().x;
301 float y = entity.getLocation().y;
304 Color color =
proj.getProjectileSpec().getFringeColor();
305 color = Misc.setAlpha(color, 50);
306 float b =
proj.getBrightness();
307 b *= viewport.getAlphaMult();
310 float size =
proj.getProjectileSpec().getWidth() * 0.6f;
313 float alphaMult = 1f;
314 Vector2f offset = p.offset;
316 if (Math.abs(diff) > 0.1f) {
317 offset = Misc.rotateAroundOrigin(offset, diff);
319 Vector2f loc =
new Vector2f(x + offset.x, y + offset.y);
321 p.sprite.setAngle(p.angle);
322 p.sprite.setSize(size, size);
323 p.sprite.setAlphaMult(b * alphaMult * p.fader.getBrightness());
324 p.sprite.setColor(color);
325 p.sprite.renderAtCenter(loc.x, loc.y);