forked from DjShinter/VideoRemote
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHarmonyP.cs
More file actions
138 lines (121 loc) · 5.4 KB
/
HarmonyP.cs
File metadata and controls
138 lines (121 loc) · 5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using MelonLoader;
using UnityEngine;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Concurrent;
using System.Reflection;
using ABI.CCK.Components;
using HarmonyLib;
using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.Player;
using DarkRift;
using DarkRift.Client;
using ABI_RC.Core.Networking;
using ABI_RC.Core.Networking.IO.UserGeneratedContent;
namespace VideoRemote
{
[HarmonyPatch]
internal class HarmonyPatches
{
//[HarmonyPostfix]
//[HarmonyPatch(typeof(ABI_RC.Core.Networking.IO.UserGeneratedContent.VideoPlayer), nameof(VideoPlayer.HandleVideoPlayerCommand))]
//internal static void OnHandleVideoPlayerCommand(ABI_RC.Core.Networking.IO.UserGeneratedContent.VideoPlayer.VideoPlayerCommandTypes_t t, Message message)
//{
// if (VideoRemoteMod.worldLastJoin + 30 > Time.time && message.Tag == (ushort)Tags.VideoPlayerSetUrl)
// {
// using DarkRiftReader reader = message.GetReader();
// string vidPlayerID = reader.ReadString();
// //MelonLogger.Msg(ConsoleColor.Green, $"m:{message.Tag} - {vidPlayerID}");
// string playerName = CVRPlayerManager.Instance.TryGetPlayerName(reader.ReadString());
// string url = reader.ReadString();
// string objPath = reader.ReadString();
// bool isPaused = reader.ReadBoolean();
// //var currentPlayers = GameObject.FindObjectsOfType<CVRVideoPlayer>(false);
// if (CVRWorld.Instance._registeredVideoPlayers.Find((Predicate<CVRVideoPlayer>)(match => match.playerId == vidPlayerID)))
// { //If the video player exists in world, this doesn't need to run
// if (VideoRemoteMod.vidPlayerJoinBuffer.ContainsKey(vidPlayerID) && VideoRemoteMod.vidPlayerJoinBuffer[vidPlayerID].Item1 != url)
// VideoRemoteMod.vidJoinBuffer_toRemove.Add(vidPlayerID); //If another command comes in while we have one in the buffer, drop past one from buffer
// return;
// }
// //MelonLogger.Msg(ConsoleColor.Green, $"Player not found in world, adding to buffer");
// (string, bool, string, string, float) data = (url, isPaused, playerName, objPath, Time.time);
// VideoRemoteMod.vidPlayerJoinBuffer.TryAdd(vidPlayerID, data);
// //MelonLogger.Msg(ConsoleColor.Green, $"Added: {vidPlayerID} -- {data}");
// if (!VideoRemoteMod.vidPlayerJoinCoroutine_Run)
// {
// //MelonLogger.Msg(ConsoleColor.Green, $"Starting ProccessJoinBufferInit");
// MelonCoroutines.Start(VideoRemoteMod.Instance.ProccessJoinBufferInit());
// }
// }
//}
//HarmonyInstance.Patch(typeof(CVR_MenuManager).GetMethod(nameof(CVR_MenuManager.ToggleQuickMenu)), null, new HarmonyMethod(typeof(VideoRemoteMod).GetMethod(nameof(QMtoggle), BindingFlags.NonPublic | BindingFlags.Static)));
[HarmonyPostfix]
[HarmonyPatch(typeof(CVR_MenuManager), nameof(CVR_MenuManager.ToggleQuickMenu))]
internal static void OnToggleQuickMenu(bool show)
{
try
{
VideoRemoteMod.QMtoggle(show);
}
catch (Exception ex)
{
MelonLogger.Warning("Error in OnToggleQuickMenu \n" + ex.ToString());
}
}
//[HarmonyPostfix]
//[HarmonyPatch(typeof(CVRVideoPlayer), nameof(CVRVideoPlayer.AddLogEntry))]
//internal static void OnAddLogEntry(string username, string text)
//{
// try
// {
// MelonLogger.Msg($"OnAddLogEntry: {username}, {text}");
// }
// catch (Exception ex)
// {
// MelonLogger.Warning("Error in OnAddLogEntry \n" + ex.ToString());
// }
//}
[HarmonyPostfix]
[HarmonyPatch(typeof(CVRVideoPlayer), nameof(CVRVideoPlayer.StartedPlaying))]
internal static void OnStartedPlaying()
{
try
{
//MelonLogger.Msg($"OnStartedPlaying");
if(VideoRemoteMod.videoHistory_En.Value) VideoRemoteMod.AllURLhistory();
}
catch (Exception ex)
{
MelonLogger.Warning("Error in OnStartedPlaying \n" + ex.ToString());
}
}
//[HarmonyPostfix]
//[HarmonyPatch(typeof(CVRVideoPlayer), nameof(CVRVideoPlayer.FinishedPlaying))]
//internal static void OnFinishedPlaying()
//{
// try
// {
// MelonLogger.Msg($"OnFinishedPlaying");
// }
// catch (Exception ex)
// {
// MelonLogger.Warning("Error in OnFinishedPlaying \n" + ex.ToString());
// }
//}
//[HarmonyPostfix]
//[HarmonyPatch(typeof(ABI_RC.VideoPlayer.YoutubeDl), nameof(ABI_RC.VideoPlayer.YoutubeDl.GetVideoMetaDataAsync))]
//internal static void OnGetVideoMetaDataAsync()
//{
// try
// {
// MelonLogger.Msg($"OnGetVideoMetaDataAsync");
// }
// catch (Exception ex)
// {
// MelonLogger.Warning("Error in OnGetVideoMetaDataAsync \n" + ex.ToString());
// }
//}
}
}