-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
247 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using ABI_RC.Core.EventSystem; | ||
using ABI_RC.Core.InteractionSystem; | ||
using ABI_RC.Core.Networking; | ||
using ABI_RC.Core.Util; | ||
using DarkRift.Client; | ||
using System.Reflection; | ||
|
||
namespace ml_egn | ||
{ | ||
public class ExtendedGameNotifications : MelonLoader.MelonMod | ||
{ | ||
public override void OnInitializeMelon() | ||
{ | ||
HarmonyInstance.Patch( | ||
typeof(AssetManagement).GetMethod(nameof(AssetManagement.LoadLocalAvatar)), | ||
null, | ||
new HarmonyLib.HarmonyMethod(typeof(ExtendedGameNotifications).GetMethod(nameof(OnLocalAvatarLoad), BindingFlags.NonPublic | BindingFlags.Static)) | ||
); | ||
|
||
HarmonyInstance.Patch( | ||
typeof(CVRSyncHelper).GetMethod(nameof(CVRSyncHelper.SpawnProp)), | ||
null, | ||
new HarmonyLib.HarmonyMethod(typeof(ExtendedGameNotifications).GetMethod(nameof(OnPropSpawned), BindingFlags.NonPublic | BindingFlags.Static)) | ||
); | ||
|
||
HarmonyInstance.Patch( | ||
typeof(NetworkManager).GetMethod("OnGameNetworkConnectionClosed", BindingFlags.NonPublic | BindingFlags.Instance), | ||
null, | ||
new HarmonyLib.HarmonyMethod(typeof(ExtendedGameNotifications).GetMethod(nameof(OnGameNetworkConnectionClosed), BindingFlags.NonPublic | BindingFlags.Static)) | ||
); | ||
} | ||
|
||
static void OnLocalAvatarLoad() | ||
{ | ||
try | ||
{ | ||
if(Utils.IsMenuOpened()) | ||
Utils.ShowMenuNotification("Avatar changed", 1f); | ||
else | ||
Utils.ShowHUDNotification("(Synced) Client", "Avatar changed"); | ||
} | ||
catch(System.Exception e) | ||
{ | ||
MelonLoader.MelonLogger.Error(e); | ||
} | ||
} | ||
|
||
static void OnPropSpawned() | ||
{ | ||
try | ||
{ | ||
if(Utils.IsConnected()) | ||
{ | ||
if(Utils.IsMenuOpened()) | ||
Utils.ShowMenuNotification("Prop spawned", 1f); | ||
else | ||
Utils.ShowHUDNotification("(Synced) Client", "Prop spawned"); | ||
} | ||
else | ||
{ | ||
if(Utils.IsMenuOpened()) | ||
ViewManager.Instance.TriggerAlert("Prop Error", "Not connected to live instance", -1, true); | ||
else | ||
Utils.ShowHUDNotification("(Local) Client", "Unable to spawn prop", "Not connected to live instance"); | ||
} | ||
} | ||
catch(System.Exception e) | ||
{ | ||
MelonLoader.MelonLogger.Error(e); | ||
} | ||
} | ||
|
||
static void OnGameNetworkConnectionClosed(object __0, DisconnectedEventArgs __1) | ||
{ | ||
try | ||
{ | ||
if((__1 != null) && (!__1.LocalDisconnect)) | ||
Utils.ShowHUDNotification("(Local) Client", "Connection lost", (__1.Error != System.Net.Sockets.SocketError.Success) ? ("Reason: " + __1.Error.ToString()) : "", true); | ||
} | ||
catch(System.Exception e) | ||
{ | ||
MelonLoader.MelonLogger.Error(e); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Reflection; | ||
|
||
[assembly: AssemblyTitle("ExtendedGameNotifications")] | ||
[assembly: AssemblyVersion("1.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0")] | ||
|
||
[assembly: MelonLoader.MelonInfo(typeof(ml_egn.ExtendedGameNotifications), "ExtendedGameNotifications", "1.0.0", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] | ||
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")] | ||
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] | ||
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Extended Game Notifications | ||
This mod shows main menu notifications and HUD popups upon avatar changing, prop spawning and server connection loss. | ||
Basically, merged previous `Avatar Change Info` and `Server Connection Info` mods in one. | ||
|
||
# Installation | ||
* Install [latest MelonLoader](https://github.com/LavaGang/MelonLoader) | ||
* Get [latest release DLL](../../../releases/latest): | ||
* Put `ml_egn.dll` in `Mods` folder of game |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using ABI_RC.Core.InteractionSystem; | ||
using ABI_RC.Core.Networking; | ||
using ABI_RC.Core.UI; | ||
using DarkRift; | ||
|
||
namespace ml_egn | ||
{ | ||
static class Utils | ||
{ | ||
public static bool IsMenuOpened() | ||
{ | ||
return ((ViewManager.Instance != null) ? ViewManager.Instance.isGameMenuOpen() : false); | ||
} | ||
|
||
public static void ShowMenuNotification(string p_message, float p_time = 1f) | ||
{ | ||
if(ViewManager.Instance != null) | ||
ViewManager.Instance.TriggerPushNotification(p_message, p_time); | ||
} | ||
|
||
public static void ShowMenuAlert(string p_title, string p_message) | ||
{ | ||
if(ViewManager.Instance != null) | ||
ViewManager.Instance.TriggerAlert(p_title, p_message, -1, true); | ||
} | ||
|
||
public static void ShowHUDNotification(string p_title, string p_message, string p_small = "", bool p_immediate = false) | ||
{ | ||
if(CohtmlHud.Instance != null) | ||
{ | ||
if(p_immediate) | ||
CohtmlHud.Instance.ViewDropTextImmediate(p_title, p_message, p_small); | ||
else | ||
CohtmlHud.Instance.ViewDropText(p_title, p_message, p_small); | ||
} | ||
} | ||
|
||
public static bool IsConnected() | ||
{ | ||
bool l_result = false; | ||
if((NetworkManager.Instance != null) && (NetworkManager.Instance.GameNetwork != null)) | ||
l_result = (NetworkManager.Instance.GameNetwork.ConnectionState == ConnectionState.Connected); | ||
return l_result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{1B5ACA07-6266-4C9A-BA30-D4BBE6634846}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>ml_egn</RootNamespace> | ||
<AssemblyName>ml_egn</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\x64\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> | ||
<OutputPath>bin\x64\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<DebugType>pdbonly</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="0Harmony, Version=2.9.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>F:\games\Steam\common\ChilloutVR\MelonLoader\0Harmony.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>F:\games\Steam\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="DarkRift"> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="DarkRift.Client, Version=2.4.5.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="MelonLoader, Version=0.5.4.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>F:\games\Steam\common\ChilloutVR\MelonLoader\MelonLoader.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<Private>False</Private> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Main.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Utils.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<PropertyGroup> | ||
<PreBuildEvent> | ||
</PreBuildEvent> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<PostBuildEvent>copy /y "$(TargetPath)" "D:\Games\Steam\steamapps\common\ChilloutVR\Mods\"</PostBuildEvent> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<ReferencePath>D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\;D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\</ReferencePath> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters