DeathWrench / BestestTVMod

combines these two mods, so videos play sequentially and you can use TV controls.
1 stars 1 forks source link

[Feature Request] Reset play sequence when "Television" is stored to storage #6

Closed dounai2333 closed 5 months ago

dounai2333 commented 5 months ago

Since the current mod didn't support RPC even if all the players share the same video contents, and if there is any late-join player, his play sequence will desync with current players. So the idea is: When TV has been stored (Aim to TV, press B and press X), everyone got their play sequence reset to default, so all the players can enjoy same video at same time.

dounai2333 commented 5 months ago

I have done it by myself. I'll leave this issue open so you may consider to add this feature in future.


[HarmonyPatch(typeof(ShipBuildModeManager), "StoreShipObjectClientRpc")]
[HarmonyPostfix]
private static void StoreShipObjectClientRpcPostfix(int unlockableID)
{
    UnlockableItem unlockableItem = StartOfRound.Instance.unlockablesList.unlockables[unlockableID];
    if (unlockableItem.inStorage && unlockableItem.unlockableName == "Television" && TVIndex != 0)
    {
        if (ConfigManager.enableLogging.Value) { BestestTVModPlugin.Log.LogInfo("Resetting play sequence..."); }
        SetTVIndex();
    }
}
DeathWrench commented 5 months ago

I will implement this into the next version but as a config option like so:

[HarmonyPatch(typeof(ShipBuildModeManager), "StoreShipObjectClientRpc")]
[HarmonyPostfix]
private static void StoreShipObjectClientRpcPostfix(int unlockableID)
{
    if (ConfigManager.storingResets.Value) 
    {
        UnlockableItem unlockableItem = StartOfRound.Instance.unlockablesList.unlockables[unlockableID];
        if (unlockableItem.inStorage && unlockableItem.unlockableName == "Television" && TVIndex != 0)
        {
            if (ConfigManager.enableLogging.Value) { BestestTVModPlugin.Log.LogInfo("Resetting play sequence..."); }
            SetTVIndex();
        }
    }
}

Thanks for posting the issue and the solution!