JustDerb / RoR2-VsTwitch

Risk of Rain 2 Mod - Fight Twitch Chat.
https://thunderstore.io/package/JustDerb/Vs_Twitch/
6 stars 4 forks source link

Story: Twitch Extension #20

Open JustDerb opened 3 years ago

JustDerb commented 3 years ago

Issue tracking the greater work towards integrating this mod with a Twitch Extension.

Simon-Kaz commented 3 years ago

hey, great job on the mod+twitch integration! I'm in a similar boat, i'm working on a ror2 mod that will interact with the broadcaster's installed extension.

I'm probably going to use bits of your mod for my twitch integration, so i was wondering if you need help getting the extension API working, assuming you're still working on it?

Also, I was wondering if you looked into the official c# extension https://github.com/TwitchLib/TwitchLib.Extension? It's made for4.5.2 and core, so not as useful for unity, but parts of it could be reused such as auth?

JustDerb commented 3 years ago

I'm probably going to use bits of your mod for my twitch integration, so i was wondering if you need help getting the extension API working, assuming you're still working on it?

I have a PoC working for the extension - it hasn't been checked in but it's a Typescript Vue.js app that simply updates it's state based on the Twitch extension.js data it receives and then actual "writes" happen via calls to an API Gateway that's auth'd to the extensions authorization token.

Also, I was wondering if you looked into the official c# extension https://github.com/TwitchLib/TwitchLib.Extension? It's made for4.5.2 and core, so not as useful for unity, but parts of it could be reused such as auth?

Haven't looked at it! Mainly because I wasn't thinking of writing the backend in C#. My backend API is written in Typescript and Twitch's Auth is pretty standard OAuth 2.0 - so I'm just using common modules from the NPM ecosystem and it's worked out fairly well.


Overall, progress is slow simply due to other priorities/projects I have (and let's not forget my actual day job 😄 ). At this point I just need to come up with a solid API schema between the game and backend as well as between the backend and the extension. After that it's doing a final "glueing" of them together, testing, and polishing the UI. The current mod's hook points make it super simple to hook everything up into the game code - so I don't expect much more code effort on the mod side of things...

I'm curious: what will your mod integration will be covering? If this extension that I'm working on is successful I have wanted to make another one that simply adds a ton of extra metadata over top the gameplay for new people to learn about what's going on. For example, if someone picks up an item, you can hover your mouse over it in the Twitch player and it'll do a popup with the items details as well as any stats (like when you hold Tab and hover over the item in game). You could do so much with an extension like that.....

Simon-Kaz commented 3 years ago

I'm curious: what will your mod integration will be covering? If this extension that I'm working on is successful I have wanted to make another one that simply adds a ton of extra metadata over top the gameplay for new people to learn about what's going on. For example, if someone picks up an item, you can hover your mouse over it in the Twitch player and it'll do a popup with the items details as well as any stats (like when you hold Tab and hover over the item in game). You could do so much with an extension like that.....

Yeah thats what im working on. A mod that reads the player's items/equipment, and then passes it to the extension to display in a component or overlay. I was just looking for an interesting project to work on related to Twitch and Unity, ended up falling down a rabbit hole of modding + extension haha.

My initial idea was to have the backend written in c# as part of the RoR2 mod. So the mod would parse the inventory, save it as json and push up to the player's extension to update the state. Not sure how viable that is, i was investigating it just now and thats why i popped a question here in your repo :) Might just play it safe and have a react/vue app for the frontend of the extension, with some sort of backend to parse the uploaded results from streamer, then authenticate and push it to the extension.

JustDerb commented 3 years ago

So the mod would parse the inventory, save it as json and push up to the player's extension to update the state. Not sure how viable that is

That's completely viable! And fairly easy to do with the MMHOOK's for mod development here.

Might just play it safe and have a react/vue app for the frontend of the extension, with some sort of backend to parse the uploaded results from streamer, then authenticate and push it to the extension.

So since the extension will probably be read-only you might be able to get away with no backend and have the game client push to the extensions PubSub subscriptions. That will make the architecture very simple and you won't need to pay for infrastructure.

I was just looking for an interesting project to work on related to Twitch and Unity, ended up falling down a rabbit hole of modding + extension haha.

Feel free to implement it - again, I don't know when I'll have time to work on that idea and I welcome more Twitch integrations from others; so go for it! If you need any help along the way feel free to reach out.

Simon-Kaz commented 3 years ago

So the mod would parse the inventory, save it as json and push up to the player's extension to update the state. Not sure how viable that is

That's completely viable! And fairly easy to do with the MMHOOK's for mod development here.

Yep! I have an early POC to confirm it works, and it does. Just trying to figure out the Twitch side of things now, definitely more complex hahaha! I'll first roll with a a component extension, but eventually i want to have it running as a video overlay with hover over effect on items, equipment and skills :)

Might just play it safe and have a react/vue app for the frontend of the extension, with some sort of backend to parse the uploaded results from streamer, then authenticate and push it to the extension.

So since the extension will probably be read-only you might be able to get away with no backend and have the game client push to the extensions PubSub subscriptions. That will make the architecture very simple and you won't need to pay for infrastructure.

Yeah that's exactly what i was thinking! I'm still trying to figure out how to do that. From what I gather, to update the extension i have to send the broadcast websocket message with the content. Also, apparently we're constrained by 5kb limit per message, hopefully that's enough for a bunch of strings in a json (item name, count and hopefully description as well).

I was just looking for an interesting project to work on related to Twitch and Unity, ended up falling down a rabbit hole of modding + extension haha.

Feel free to implement it - again, I don't know when I'll have time to work on that idea and I welcome more Twitch integrations from others; so go for it! If you need any help along the way feel free to reach out.

I'll be using your implementation as a base, so hopefully i'll be able to contribute back once i have it working! I'll ping you with the repo once i have it set up, in case you're interested! Thanks for replying and once again, great job on the mod!

JustDerb commented 2 years ago

The extension has been put on an indefinite hiatus due to me not having a lot of time outside my work/life to commit to finishing it. If development for the extension starts up again I'll update this issue accordingly.