浏览代码

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

tags/v1.0.0
NGnius (Graham) 4 年前
父节点
当前提交
be7edbe596
共有 3 个文件被更改,包括 510 次插入420 次删除
  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 查看文件

@@ -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
文件差异内容过多而无法显示
查看文件


+ 18
- 0
GamecraftRPC/Plugin.cs 查看文件

@@ -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); });