001package com.fs.starfarer.api.impl.combat; 002 003import org.lwjgl.util.vector.Vector2f; 004 005import com.fs.starfarer.api.Global; 006import com.fs.starfarer.api.combat.CombatEngineAPI; 007import com.fs.starfarer.api.combat.CombatEntityAPI; 008import com.fs.starfarer.api.combat.DamagingProjectileAPI; 009import com.fs.starfarer.api.combat.EveryFrameWeaponEffectPlugin; 010import com.fs.starfarer.api.combat.MissileAPI; 011import com.fs.starfarer.api.combat.OnFireEffectPlugin; 012import com.fs.starfarer.api.combat.OnHitEffectPlugin; 013import com.fs.starfarer.api.combat.WeaponAPI; 014import com.fs.starfarer.api.combat.listeners.ApplyDamageResultAPI; 015 016/** 017 * IMPORTANT: will be multiple instances of this, as this doubles as the every frame effect and the on fire effect (same instance) 018 * But also as the visual for each individual shot (created via onFire, using the non-default constructor) 019 */ 020public class RealityDisruptorEffect implements OnFireEffectPlugin, OnHitEffectPlugin, EveryFrameWeaponEffectPlugin { 021 022 023 protected CombatEntityAPI chargeGlowEntity; 024 protected RealityDisruptorChargeGlow chargeGlowPlugin; 025 public RealityDisruptorEffect() { 026 } 027 028 //protected IntervalUtil interval = new IntervalUtil(0.1f, 0.2f); 029 public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) { 030 //interval.advance(amount); 031 032 boolean charging = weapon.getChargeLevel() > 0 && weapon.getCooldownRemaining() <= 0; 033 if (charging && chargeGlowEntity == null) { 034 chargeGlowPlugin = new RealityDisruptorChargeGlow(weapon); 035 chargeGlowEntity = Global.getCombatEngine().addLayeredRenderingPlugin(chargeGlowPlugin); 036 } else if (!charging && chargeGlowEntity != null) { 037 chargeGlowEntity = null; 038 chargeGlowPlugin = null; 039 } 040 } 041 042 043 public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, ApplyDamageResultAPI damageResult, CombatEngineAPI engine) { 044 045 } 046 047 public void onFire(DamagingProjectileAPI projectile, WeaponAPI weapon, CombatEngineAPI engine) { 048 if (chargeGlowPlugin != null) { 049 chargeGlowPlugin.attachToProjectile(projectile); 050 chargeGlowPlugin = null; 051 chargeGlowEntity = null; 052 053 MissileAPI missile = (MissileAPI) projectile; 054 missile.setMine(true); 055 missile.setNoMineFFConcerns(true); 056 missile.setMineExplosionRange(RealityDisruptorChargeGlow.MAX_ARC_RANGE + 50f); 057 missile.setMinePrimed(true); 058 missile.setUntilMineExplosion(0f); 059 } 060 061// RiftTrailEffect trail = new RiftTrailEffect((MissileAPI) projectile); 062// ((MissileAPI) projectile).setEmpResistance(1000); 063// Global.getCombatEngine().addPlugin(trail); 064 065 066// RealityDisruptorEffect effect = new RealityDisruptorEffect(projectile); 067// CombatEntityAPI e = engine.addLayeredRenderingPlugin(effect); 068// e.getLocation().set(projectile.getLocation()); 069 } 070 071 072 073 074} 075 076 077 078