-
Notifications
You must be signed in to change notification settings - Fork 40
chore: now AudioSource gets disabled when out of Scene Bounds #1420
chore: now AudioSource gets disabled when out of Scene Bounds #1420
Conversation
This branch can be previewed at https://explorer.decentraland.zone/branch/chore/1276_disable_outofscene_audiosource/index.html |
Tests for DCLAudioStream won't be included here. The tests (along the refactor needed to make them doable) will be tackled down here #1421 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!. Left some small comments.
@@ -202,6 +210,15 @@ protected virtual void UpdateEntityCollidersValidState(DecentralandEntity entity | |||
} | |||
} | |||
|
|||
protected virtual void UpdateComponents(DecentralandEntity entity, bool isInsideBoundaries) | |||
{ | |||
IOutOfSceneBoundariesHandler[] audioSources = entity.gameObject.GetComponentsInChildren<IOutOfSceneBoundariesHandler>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IOutOfSceneBoundariesHandler[] audioSources = entity.gameObject.GetComponentsInChildren<IOutOfSceneBoundariesHandler>(); | |
IOutOfSceneBoundariesHandler[] components = entity.gameObject.GetComponentsInChildren<IOutOfSceneBoundariesHandler>(); |
if (classId == CLASS_ID_COMPONENT.AUDIO_SOURCE || classId == CLASS_ID_COMPONENT.AUDIO_STREAM) | ||
{ | ||
SceneController.i.boundariesChecker?.AddEntityToBeChecked(entity); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR, but we should be configuring these aspect of components on some sort of manifest to avoid all the ifs like this. Take into account we already have this anti-pattern in messaging system -- the conditional voiding the lossy messages depending on message type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can use the same interface and simply check if the Monobehaviour
retrieved (either by the componentFactory or the entity components list is IOutOfSceneBoundariesHandler
.
I'm gonna give it a call in this PR and if it gets messy I will leave it and create a ticket.
} | ||
else | ||
{ | ||
Interface.WebInterface.SendAudioStreamEvent(model.url, true, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is supposed to stop the streaming? A comment or wrapper method would be useful here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the last param is the volume, I will add a comment!
public interface IOutOfSceneBoundariesHandler | ||
{ | ||
void UpdateOutOfBoundariesState(bool enable); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ 🏗️
#1276
Now AudioSource is part of the scenery boundaries checks. If the entity has no mesh a simple check against the entity position is made.
The case for AudioStreaming/VideoStreaming is different since it's done inNevermind, it will be done here.kernel
and it will be tackled-down in #1419