Starsector API
Loading...
Searching...
No Matches
GBIRemoraDrain.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.ghosts;
2
3import java.awt.Color;
4import java.util.ArrayList;
5import java.util.List;
6
7import com.fs.starfarer.api.Global;
8import com.fs.starfarer.api.campaign.CampaignFleetAPI;
9import com.fs.starfarer.api.campaign.CustomCampaignEntityAPI;
10import com.fs.starfarer.api.campaign.SectorEntityToken;
11import com.fs.starfarer.api.impl.campaign.ids.Tags;
12import com.fs.starfarer.api.loading.CampaignPingSpec;
13import com.fs.starfarer.api.util.IntervalUtil;
14import com.fs.starfarer.api.util.Misc;
15
16
18
19 //public static float REMORA_RANGE = 1000f;
20
21 protected SectorEntityToken target;
22 protected float drainRange;
23 protected IntervalUtil tracker = new IntervalUtil(5f, 10f);
24
25 public GBIRemoraDrain(SectorEntityToken target, float drainRange) {
26 super(0f);
27 this.target = target;
28 this.drainRange = drainRange;
29 }
30
31
32 @Override
33 public void advance(float amount, SensorGhost ghost, GhostBehavior behavior) {
34 super.advance(amount, ghost, behavior);
35
36 tracker.advance(amount);
37 if (tracker.intervalElapsed()) {
38
39 CustomCampaignEntityAPI entity = ghost.getEntity();
40
41 CampaignPingSpec custom = new CampaignPingSpec();
42 //custom.setUseFactionColor(true);
43 custom.setWidth(15);
44 custom.setRange(drainRange * 1.3f);
45// custom.setRange(drainRange * 1.3f);
46// custom.setMinRange(entity.getRadius());
47// custom.setInvert(true);
48 custom.setDuration(0.5f);
49 custom.setAlphaMult(1f);
50 custom.setInFraction(0.1f);
51 custom.setNum(1);
52 custom.setColor(new Color(255, 100, 100, 255));
53 Global.getSector().addPing(entity, custom);
54// Color color = custom.getColor();
55// Misc.addHitGlow(entity.getContainingLocation(), entity.getLocation(), entity.getVelocity(),
56// entity.getRadius() * 3f + 100f, 0.5f, color);
57
58 if (ghost.getEntity().isInCurrentLocation()) {
59 Global.getSoundPlayer().playSound("ghost_remora_hit", 1f, 1f,
60 ghost.getEntity().getLocation(), ghost.getEntity().getVelocity());
61 }
62
63 List<SectorEntityToken> list = new ArrayList<SectorEntityToken>(entity.getContainingLocation().getFleets());
64 list.addAll(entity.getContainingLocation().getCustomEntities());
65 //list.add(target);
66 for (SectorEntityToken other : list) {
67 if (other.hasTag(Tags.IMMUNE_TO_REMORA_PULSE)) continue;
68 float dist = Misc.getDistance(entity, other) - entity.getRadius() - other.getRadius();
69 if (dist < drainRange) {
70 if (other.isPlayerFleet()) {
71 other.addFloatingText("Drive field drain!", Misc.getNegativeHighlightColor(), 1f, true);
72 }
73 float mult = 0.5f + 0.5f * (1f - dist / drainRange);
74 if (other instanceof CampaignFleetAPI) {
75 mult *= 2f;
76 }
77 other.addScript(new SpeedReduction(other, 0.5f * mult, 0.5f));
78 }
79 }
80 }
81 }
82
83}
84
85
86
87
88
89
90
91
92
93
94
95
96
static SoundPlayerAPI getSoundPlayer()
Definition Global.java:43
static SectorAPI getSector()
Definition Global.java:59
void advance(float amount, SensorGhost ghost, GhostBehavior behavior)
GBIRemoraDrain(SectorEntityToken target, float drainRange)
SoundAPI playSound(String id, float pitch, float volume, Vector2f loc, Vector2f vel)