44 public void init(ShipAPI ship) {
53 for (WeaponAPI w : ship.getAllWeapons()) {
54 if (w.isDecorative() && w.getSpec().hasTag(Tags.LIDAR)) {
58 List<WeaponAPI> lidar =
new ArrayList<WeaponAPI>();
59 for (WeaponAPI w : ship.getAllWeapons()) {
60 if (w.isDecorative() && w.getSpec().hasTag(Tags.LIDAR)) {
64 Collections.sort(lidar,
new Comparator<WeaponAPI>() {
65 public int compare(WeaponAPI o1, WeaponAPI o2) {
66 return (
int) Math.signum(o1.getSlot().getLocation().x - o2.getSlot().getLocation().x);
69 for (WeaponAPI w : lidar) {
70 if (w.isDecorative() && w.getSpec().hasTag(Tags.LIDAR)) {
71 w.setSuspendAutomaticTurning(
true);
72 LidarDishData data =
new LidarDishData();
73 data.turnDir = Math.signum(turnDir);
78 data.phase = index / count;
90 float turnRateMult = 1f;
96 for (LidarDishData data :
dishData) {
97 float arc = data.w.getArc();
98 float useTurnDir = data.turnDir;
100 useTurnDir = Misc.getClosestTurnDirection(data.angle, 0f);
102 float delta = useTurnDir * amount * data.turnRate * turnRateMult * arc;
103 if (active && effectLevel > 0f && Math.abs(data.angle) < Math.abs(delta * 1.5f)) {
107 data.phase += 1f * amount;
109 if (data.angle > arc/2f && data.turnDir > 0f) {
113 if (data.angle < -arc/2f && data.turnDir < 0f) {
114 data.angle = -arc/2f;
118 data.angle = data.angle % 360f;
123 float facing = data.angle + data.w.getArcFacing() + data.w.getShip().getFacing();
124 data.w.setFacing(facing);
125 data.w.updateBeamFromPoints();
133 public void apply(MutableShipStatsAPI stats, String
id, State state,
float effectLevel) {
134 ShipAPI ship = (ShipAPI)stats.getEntity();
135 if (ship ==
null || ship.isHulk()) {
138 for (WeaponAPI w : ship.getAllWeapons()) {
139 if (!w.isDecorative() && w.getSlot().isHardpoint() && !w.isBeam() &&
140 (w.getType() == WeaponType.BALLISTIC || w.getType() == WeaponType.ENERGY)) {
141 w.setGlowAmount(0,
null);
153 boolean active = state == State.IN || state == State.ACTIVE || state == State.OUT;
158 modify(
id, stats, effectLevel);
163 for (WeaponAPI w : ship.getAllWeapons()) {
164 if (w.getSlot().isSystemSlot())
continue;
165 if (!w.isDecorative() && w.getSlot().isHardpoint() && !w.isBeam() &&
166 (w.getType() == WeaponType.BALLISTIC || w.getType() == WeaponType.ENERGY)) {
167 w.setGlowAmount(0,
null);
177 for (WeaponAPI w : ship.getAllWeapons()) {
178 if (w.getSlot().isSystemSlot())
continue;
179 if (w.getType() == WeaponType.MISSILE)
continue;
180 if (state == State.IN) {
181 if (!(w.isDecorative() && w.getSpec().hasTag(Tags.LIDAR))) {
182 w.setForceNoFireOneFrame(
true);
185 if (!(!w.isDecorative() && w.getSlot().isHardpoint() && !w.isBeam() &&
186 (w.getType() == WeaponType.BALLISTIC || w.getType() == WeaponType.ENERGY))) {
187 w.setForceNoFireOneFrame(
true);
194 float lidarRange = 500;
195 for (WeaponAPI w : ship.getAllWeapons()) {
196 if (!w.isDecorative() && w.getSlot().isHardpoint() && !w.isBeam() &&
197 (w.getType() == WeaponType.BALLISTIC || w.getType() == WeaponType.ENERGY)) {
198 lidarRange = Math.max(lidarRange, w.getRange());
199 w.setGlowAmount(effectLevel, glowColor);
203 stats.getBeamWeaponRangeBonus().modifyFlat(
"lidararray", lidarRange);
216 float fireThreshold = 0.25f / 3.25f;
217 fireThreshold += 0.02f;
219 for (LidarDishData data :
dishData) {
220 boolean skip = data.phase % 1f > 1f / data.count;
224 if (data.w.isDecorative() && data.w.getSpec().hasTag(Tags.LIDAR)) {
225 if (state == State.IN && Math.abs(data.angle) < 5f && effectLevel >= fireThreshold) {
226 data.w.setForceFireOneFrame(
true);
231 if (((state == State.IN && effectLevel > 0.67f) || state == State.ACTIVE) && !
playedWindup) {
238 protected void modify(String
id, MutableShipStatsAPI stats,
float effectLevel) {
239 float mult = 1f +
ROF_BONUS * effectLevel;
241 stats.getBallisticWeaponRangeBonus().modifyPercent(
id,
RANGE_BONUS);
242 stats.getEnergyWeaponRangeBonus().modifyPercent(
id,
RANGE_BONUS);
243 stats.getBallisticRoFMult().modifyMult(
id, mult);
244 stats.getEnergyRoFMult().modifyMult(
id, mult);
246 stats.getMaxRecoilMult().modifyMult(
id, 1f - (0.01f *
RECOIL_BONUS));
247 stats.getRecoilPerShotMult().modifyMult(
id, 1f - (0.01f *
RECOIL_BONUS));
248 stats.getRecoilDecayMult().modifyMult(
id, 1f - (0.01f *
RECOIL_BONUS));
253 protected void unmodify(String
id, MutableShipStatsAPI stats) {
259 stats.getBallisticRoFMult().unmodifyMult(
id);
260 stats.getEnergyRoFMult().unmodifyMult(
id);
261 stats.getMaxRecoilMult().unmodifyMult(
id);
262 stats.getRecoilPerShotMult().unmodifyMult(
id);
263 stats.getRecoilDecayMult().unmodifyMult(
id);
265 stats.getBallisticProjectileSpeedMult().unmodifyPercent(
id);
266 stats.getEnergyProjectileSpeedMult().unmodifyPercent(
id);