1package com.fs.starfarer.api.impl.combat;
5import org.lwjgl.util.vector.Vector2f;
7import com.fs.starfarer.api.Global;
8import com.fs.starfarer.api.combat.BeamAPI;
9import com.fs.starfarer.api.combat.BeamEffectPlugin;
10import com.fs.starfarer.api.combat.BoundsAPI;
11import com.fs.starfarer.api.combat.BoundsAPI.SegmentAPI;
12import com.fs.starfarer.api.combat.CombatEngineAPI;
13import com.fs.starfarer.api.combat.CombatEntityAPI;
14import com.fs.starfarer.api.combat.EmpArcEntityAPI;
15import com.fs.starfarer.api.combat.MissileAPI;
16import com.fs.starfarer.api.combat.ShipAPI;
17import com.fs.starfarer.api.combat.WeaponAPI.WeaponType;
18import com.fs.starfarer.api.loading.MissileSpecAPI;
19import com.fs.starfarer.api.util.IntervalUtil;
20import com.fs.starfarer.api.util.Misc;
75 if (
tracker.intervalElapsed()) {
109 boolean spawnedMine =
false;
114 Vector2f.add(loc, beam.
getFrom(), loc);
144 if (length <= 10f)
return;
148 Vector2f from = beam.
getFrom();
165 for (
int i = 0; i < 3; i++) {
166 float rampUp = 0.25f + 0.25f * (float) Math.random();
167 float dur = 1f + 1f * (float) Math.random();
169 float size = 200f + 50f * (float) Math.random();
182 float spawnOtherParticleRange = 100;
183 if (length > spawnOtherParticleRange * 2f && (
float) Math.random() < 0.25f) {
185 color =
new Color(150,255,150,75);
186 int numToSpawn = (int) ((length - spawnOtherParticleRange) / 200f + 1);
189 float distAlongBeam = spawnOtherParticleRange + (length - spawnOtherParticleRange * 2f) * (
float) Math.random();
190 float groupSpeed = 100f + (float) Math.random() * 100f;
191 for (
int j = 0; j < 7; j++) {
192 float rampUp = 0.25f + 0.25f * (float) Math.random();
193 float dur = 1f + 1f * (float) Math.random();
194 float size = 50f + 50f * (float) Math.random();
195 Vector2f loc =
new Vector2f(dir);
196 float sign = Math.signum((
float) Math.random() - 0.5f);
197 loc.scale(distAlongBeam + sign * (
float) Math.random() * size * 0.5f);
198 Vector2f.add(loc, from, loc);
209 Vector2f vel =
new Vector2f(dir);
210 if ((
float) Math.random() < 0.5f) {
215 float speed = groupSpeed;
216 float maxSpeed = dist / dur;
217 if (speed > maxSpeed) speed = maxSpeed;
230 float radiusOverride = -1f;
231 if (target instanceof
ShipAPI) {
257 boolean computeNextLoc =
false;
260 if (dist < perSpawn) {
262 computeNextLoc =
true;
265 if (!computeNextLoc) {
275 if (radiusOverride >= 0) {
276 targetRadius = radiusOverride;
286 if (hitShield) perSpawn *= 0.67f;
295 float anglePerSegment = 360f * perSpawn / (3.14f * 2f * targetRadius);
296 if (anglePerSegment > 90f) anglePerSegment = 90f;
297 float angle = prevAngle + anglePerSegment *
spawnDir;
301 arcTo.scale(targetRadius);
302 Vector2f.add(targetLoc, arcTo, arcTo);
305 if (radiusOverride >= 0) {
306 actualRadius = radiusOverride;
310 actualRadius += 30f + 50f * (float) Math.random();
314 actualRadius += 30f + 50f * (float) Math.random();
323 arcTo.scale(actualRadius);
324 Vector2f.add(targetLoc, arcTo, arcTo);
329 if (target instanceof
ShipAPI && !hitShield) {
332 if (bounds !=
null) {
333 Vector2f best =
null;
334 float bestDist = Float.MAX_VALUE;
337 if (test < bestDist) {
339 best = segment.getP1();
346 float explosionRadius = (float) spec.
getBehaviorJSON().optJSONObject(
"explosionSpec").optDouble(
"coreRadius", 100f);
348 explosionRadius *= sizeMult;
351 dir.scale(explosionRadius * 0.9f);
352 Vector2f.add(best, dir, dir);
369 sizeMult = 0.75f + (1f - sizeMult) * 0.5f;
380 (
float) Math.random() * 360f,
null);
386 if (source !=
null) {
388 source, WeaponType.ENERGY,
false, mine.
getDamage());
394 float fadeInTime = 0.05f;
static SettingsAPI getSettings()
static CombatEngineAPI getCombatEngine()
void modifyMult(String source, float value)
static float SPAWN_SPACING
static String RIFTCASCADE_MINELAYER
void spawnNegativeParticles(CombatEngineAPI engine, BeamAPI beam)
static float UNUSED_RANGE_PER_SPAWN
static float SPAWN_INTERVAL
void advance(float amount, CombatEngineAPI engine, BeamAPI beam)
void spawnMine(ShipAPI source, Vector2f mineLoc)
static Color NEGATIVE_SOURCE_COLOR
static Color STANDARD_RIFT_COLOR
boolean doneSpawningMines
Vector2f getNextArcLoc(CombatEngineAPI engine, BeamAPI beam, float perSpawn)
static Color EXPLOSION_UNDERCOLOR
static String SIZE_MULT_KEY
void advance(float amount)
static Vector2f getUnitVectorAtDegreeAngle(float degrees)
static float getDistance(SectorEntityToken from, SectorEntityToken to)
static float getClosestTurnDirection(float facing, float desired)
static Vector2f getPointAtRadius(Vector2f from, float r)
static Vector2f getPointWithinRadius(Vector2f from, float r)
static float getAngleInDegrees(Vector2f v)
float getTargetingRadius(Vector2f from, CombatEntityAPI target, boolean considerShield)
WeaponSpecAPI getWeaponSpec(String weaponId)
CombatEntityAPI getDamageTarget()
Vector2f getRayEndPrevFrame()
float getLengthPrevFrame()
List< SegmentAPI > getSegments()
EmpArcEntityAPI spawnEmpArcVisual(Vector2f from, CombatEntityAPI fromAnchor, Vector2f to, CombatEntityAPI toAnchor, float thickness, Color fringe, Color core)
CombatEntityAPI spawnProjectile(ShipAPI ship, WeaponAPI weapon, String weaponId, Vector2f point, float angle, Vector2f shipVelocity)
void addNegativeParticle(Vector2f loc, Vector2f vel, float size, float rampUpFraction, float totalDuration, Color color)
void applyDamageModifiersToSpawnedProjectileWithNullWeapon(ShipAPI source, WeaponType type, boolean isBeam, DamageAPI damage)
float getCollisionRadius()
void setCustomData(String key, Object data)
BoundsAPI getExactBounds()
MutableStat getModifier()
void addDamagedAlready(CombatEntityAPI c)
void setCoreWidthOverride(float coreWidthOverride)
void fadeOutThenIn(float inDur)
void setNoMineFFConcerns(boolean noFFConcerns)
void setFlightTime(float flightTime)
boolean isWithinArc(Vector2f point)
WeaponSlotAPI getStationSlot()
ShipAPI getParentStation()
JSONObject getBehaviorJSON()
Object getProjectileSpec()