Starsector API
Loading...
Searching...
No Matches
GBIPlaySound.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.ghosts;
2
3import com.fs.starfarer.api.Global;
4import com.fs.starfarer.api.campaign.SectorEntityToken;
5
7
8 protected String soundId;
9 protected float volume;
10 protected float pitch;
11 protected boolean played = false;
12
13 public GBIPlaySound(float delay, String soundId, float pitch, float volume) {
14 super(delay);
15 this.soundId = soundId;
16 this.pitch = pitch;
17 this.volume = volume;
18 }
19
20 @Override
21 public boolean shouldInterruptBehavior(SensorGhost ghost, GhostBehavior behavior) {
22 if (hasDelayRemaining()) return false;
23
24 if (!played) {
25 SectorEntityToken entity = ghost.getEntity();
26 if (soundId != null && entity.isInCurrentLocation() && entity.isVisibleToPlayerFleet()) {
27 Global.getSoundPlayer().playSound(soundId, pitch, volume, entity.getLocation(), entity.getVelocity());
28 }
29 played = true;
30 }
31
32 return false;
33 }
34
35
36}
static SoundPlayerAPI getSoundPlayer()
Definition Global.java:43
boolean shouldInterruptBehavior(SensorGhost ghost, GhostBehavior behavior)
GBIPlaySound(float delay, String soundId, float pitch, float volume)
SoundAPI playSound(String id, float pitch, float volume, Vector2f loc, Vector2f vel)