cmooref17 / Lethal-Company-TooManyEmotes

https://thunderstore.io/c/lethal-company/p/FlipMods/TooManyEmotes/
MIT License
16 stars 9 forks source link

Audio manager or emote sync group cleanup seems to break other emote-related mods custom audio #125

Open Sumable opened 6 months ago

Sumable commented 6 months ago

[Info : Console] PLAYER EMOTE END Bnuuy //<-------- Other mod's noise on emote 2 (point) works [Info : Console] PLAYER EMOTE END Bnuuy //<-------- Other mod's noise on emote 2 (point) works [Info : Console] PLAYER EMOTE END Bnuuy //<-------- Other mod's noise on emote 2 (point) works [Info :TooManyEmotes-2.1.15] Attempting to perform emote on local player. [Info :TooManyEmotes-2.1.15] [Bnuuy] Performing emote: pump_up_the_jam [Warning:TooManyEmotes-2.1.15] [VERBOSE] [PerformEmote] On perform vanilla emote on local player. Stopping custom emote. [Info :TooManyEmotes-2.1.15] [Bnuuy] Stopping emote. [Info :TooManyEmotes-2.1.15] Cleaning up emote sync group with id: 0 <---- possibly where it breaks [Info : Console] PLAYER EMOTE END Bnuuy //<-------- Other mod's noise on emote 2 (point) no longer works [Info : Console] PLAYER EMOTE END Bnuuy //<-------- Other mod's noise on emote 2 (point) no longer works

If the mod's audio manager or emote sync cleanup changes any files regarding vanilla emotes, it breaks any other mod that has audio w/ emotes after a TME emote is stopped and cleaned

Sumable commented 6 months ago
protected override void OnEmoteStart(int emoteId)
        {
            if (emoteId == 2)
            {
                ((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(Assets.GetRandomCaw(), Plugin.cawVolume.Value);
            }
        }

For reference, here's the code used. Pretty basic use of PlayOneShot to play a sound when the emote runs, but if your audio system overrides anything when initialized or cleaned up it may cause this to not work

cmooref17 commented 6 months ago

Thanks for posting this!

First off, I'll just state a few things just in case, but maybe you already knew most of this.

This mod doesn't change the default emotes or animator/animator controller. It used to in the early days of the mod, but now plays all animations on a separate skeleton, and this should prevent conflicts with the vanilla code and/or other mods that touch the player's animator. This mod will then translate the bones of the player in a LateUpdate method to match the position of the separate skeleton being animated by TME.

I do however tell the player to perform the vanilla emote 1 when they emote, just so the vanilla game (and clients not running the mod) know that they are emoting.

Also, when the player stops performing an emote from TME, it will stop performing the vanilla emote so the game knows they're not emoting anymore.

As for audio, emotes can play audio on boomboxes/ship speaker, or on the actual players, depending on the config settings. No matter which option is chosen, a new AudioSource is created, which is where the emote audio will play from, so with the example of the boombox, this mod does not touch the original AudioSource, but rather, only the AudioSource that was added by this mod. This is also to help prevent conflicts with the vanilla game, and with other mods.

Sorry, just had to state that first in case that helped clear anything up.

As for the logs you sent, it looks like the player performs an emote from TME, and then stops the emote, correct? So this part: [Info :TooManyEmotes-2.1.15] Cleaning up emote sync group with id: 0, what's supposed to happen is that if that emote has audio, then it stops the audio from playing on the audio source. Somewhere in there, it stops the player from performing an emote, which includes with the player's vanilla animator. (not sure if that's where the issue is?)

Maybe I need more information about this. Referring to this log: Other mod's noise on emote 2 (point) no longer works, what does this mod's audio do? Is it supposed to play while the player is emoting, or all the time?

Also, sorry if I misunderstood your message!

Sumable commented 6 months ago

No worries and thank you for the quick response!

The mod (Lethal CAWmpany) just plays a single short sound effect via PlayOneShot whenever an emote starts and has an emoteID equal to 2, which is the pointing emote :)

To explain the mod more, it replaces your player model with a crow and lets you caw when you point. Pretty simple and otherwise works great with TME.

As far as the audio source for the mod's emote, it seems to use the BodyReplacementBase instance for that player, gets the controller for it, and uses movementAudio as the audio source.

I also think the issue is somewhere the emote sync group cleanup code... I'll take a look at it later and see if I can't find anything.

cmooref17 commented 6 months ago

Okay, I will take a look at this this weekend when I have some free time, but I'll let you know if I find the issue!

cmooref17 commented 6 months ago

Hey, just to double check, but what is the issue going on in the example? Is it safe to assume that the caw audio shouldn't be playing in the case where the player is emoting with a TME emote?

And when the player stops emoting with a TME emote, what is the issue exactly? Does the caw audio just not play at all afterwards?

Sumable commented 6 months ago

That's correct, it shouldn't play with any TME emotes, just the pointing emote. After a TME emote is used, the caw audio doesn't play at all