Browse Source

Update to modding API v1.0 and mention wine-discord bridge

tags/v1.0.1
NGnius (Graham) 4 years ago
parent
commit
be7edbe596
3 changed files with 510 additions and 420 deletions
  1. +9
    -5
      GamecraftRPC/Engines/PlayerCountEngine.cs
  2. +483
    -415
      GamecraftRPC/GamecraftRPC.csproj
  3. +18
    -0
      GamecraftRPC/Plugin.cs

+ 9
- 5
GamecraftRPC/Engines/PlayerCountEngine.cs View File

@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;

using GamecraftModdingAPI.Tasks;
using GamecraftModdingAPI.Utility;
using GamecraftModdingAPI.Engines;
using Svelto.ECS;

using RobocraftX.Character;
@@ -19,7 +19,9 @@ namespace GamecraftRPC.Engines

public EntitiesDB entitiesDB { set; private get; }

private Discord.Discord discordRPC = null;
public bool isRemovable => false;

private Discord.Discord discordRPC = null;

private bool Ok = false;

@@ -35,7 +37,7 @@ namespace GamecraftRPC.Engines
public void Ready()
{
Ok = true;
Scheduler.Schedule(new Repeatable(updatePlayerCount, () => { return Ok; }, delay: 2f));
Scheduler.Schedule(new Repeatable(updatePlayerCount, () => { return Ok; }, delay: 5f));
PresenceUtility.Activity.Party.Size.CurrentSize = 1;
PresenceUtility.Activity.Party.Size.MaxSize = PresenceUtility.LobbySize;
PresenceUtility.Activity.Party.Id = "";//PresenceUtility.PartyId.ToString();
@@ -49,8 +51,10 @@ namespace GamecraftRPC.Engines
{
count += entitiesDB.Count<RigidBodyEntityStruct>(CharacterExclusiveGroups.AllCharacters[i]);
}
GamecraftModdingAPI.Utility.Logging.MetaLog($"Player Count: {count}");
if ((int)count != PresenceUtility.PlayerCount && count > 0)
#if DEBUG
GamecraftModdingAPI.Utility.Logging.MetaLog($"Player Count: {count}");
#endif
if ((int)count != PresenceUtility.PlayerCount && count > 0)
{
PresenceUtility.PlayerCount = (int)count;
PresenceUtility.Activity.Party.Size.CurrentSize = (int)count;


+ 483
- 415
GamecraftRPC/GamecraftRPC.csproj
File diff suppressed because it is too large
View File


+ 18
- 0
GamecraftRPC/Plugin.cs View File

@@ -1,5 +1,6 @@
using System;
using System.Reflection;
//using Microsoft.Win32;

using IllusionPlugin;
using GamecraftModdingAPI.Events;
@@ -44,6 +45,23 @@ namespace GamecraftRPC
// Initialize the Gamecraft modding API first
GamecraftModdingAPI.Main.Init();

// detect Wine (maybe?)
bool isWineDetected = false;
foreach (var key in Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software").GetSubKeyNames())
{
if (key == "Wine")
{
isWineDetected = true;
break;
}
}
if (isWineDetected)
{
// check for or install fake Discord
GamecraftModdingAPI.Utility.Logging.MetaLog("\n--------------------------------\n\nIt looks like you may be using Wine/Proton, cool!\nPlease install https://github.com/0e4ef622/wine-discord-ipc-bridge to get this to work.\n\n--------------------------------");
}

// Initialize this mod
discordRPC = new Discord.Discord(CLIENT_ID, (UInt64)Discord.CreateFlags.Default);
discordRPC.SetLogHook(LogLevel.Debug, (_, msg) => { GamecraftModdingAPI.Utility.Logging.MetaLog(msg); });


Loading…
Cancel
Save