Skip to content

Commit

Permalink
Fix loop sound persisting after the payload carrier is removed. (#8034)
Browse files Browse the repository at this point in the history
* Properly remove units and blocks in the case that the carrier dies

* added = false

---------

Co-authored-by: Anuken <[email protected]>
  • Loading branch information
MEEPofFaith and Anuken authored Feb 6, 2025
1 parent de8087e commit 527e2ee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/mindustry/entities/comp/BuildingComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2089,6 +2089,10 @@ public boolean inFogTo(Team viewer){

@Override
public void remove(){
stopSound();
}

public void stopSound(){
if(sound != null){
sound.stop();
}
Expand Down
7 changes: 7 additions & 0 deletions core/src/mindustry/entities/comp/PayloadComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ public void update(){
}

@Override
public void remove(){
for(Payload pay : payloads){
pay.remove();
}
payloads.clear();
}

public void destroy(){
if(Vars.state.rules.unitPayloadsExplode) payloads.each(Payload::destroyed);
}
Expand Down
5 changes: 5 additions & 0 deletions core/src/mindustry/world/blocks/payloads/BuildPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public float size(){
return build.block.size * tilesize;
}

@Override
public void remove(){
build.stopSound();
}

@Override
public void write(Writes write){
write.b(payloadBlock);
Expand Down
2 changes: 2 additions & 0 deletions core/src/mindustry/world/blocks/payloads/Payload.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ default float getY(){
return y();
}

default void remove(){}

static void write(@Nullable Payload payload, Writes write){
if(payload == null){
write.bool(false);
Expand Down

0 comments on commit 527e2ee

Please sign in to comment.