Convert to GamecraftRPC
This commit is contained in:
parent
65c3bda1b5
commit
f43c7e17cd
6 changed files with 102 additions and 74 deletions
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.29609.76
|
VisualStudioVersion = 16.0.29609.76
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloModdingWorld", "HelloModdingWorld\HelloModdingWorld.csproj", "{E0EEA15D-AB3C-4C73-A000-C49B5AE9EA66}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GamecraftRPC", "GamecraftRPC\GamecraftRPC.csproj", "{E0EEA15D-AB3C-4C73-A000-C49B5AE9EA66}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
@ -6,12 +6,13 @@
|
||||||
<Version>0.0.1</Version>
|
<Version>0.0.1</Version>
|
||||||
<Authors>Me</Authors>
|
<Authors>Me</Authors>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageProjectUrl>https://git.exmods.org/modtainers/HelloModdingWorld</PackageProjectUrl>
|
<PackageProjectUrl>https://git.exmods.org/???/???</PackageProjectUrl>
|
||||||
<NeutralLanguage>en-CA</NeutralLanguage>
|
<NeutralLanguage>en-CA</NeutralLanguage>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Lib.Harmony" Version="1.2.0.1" />
|
<PackageReference Include="Lib.Harmony" Version="1.2.0.1" />
|
||||||
|
<PackageReference Include="DiscordRichPresence" Version="1.0.150" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!--Start Dependencies-->
|
<!--Start Dependencies-->
|
90
GamecraftRPC/MyPlugin.cs
Normal file
90
GamecraftRPC/MyPlugin.cs
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
using IllusionPlugin;
|
||||||
|
// using GamecraftModdingAPI;
|
||||||
|
using GamecraftModdingAPI.Commands;
|
||||||
|
using DiscordRPC;
|
||||||
|
|
||||||
|
namespace GamecraftRPC
|
||||||
|
{
|
||||||
|
public class MyPlugin : IPlugin // the Illusion Plugin Architecture (IPA) will ignore classes that don't implement IPlugin'
|
||||||
|
{
|
||||||
|
public string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name;
|
||||||
|
|
||||||
|
public string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||||
|
|
||||||
|
private static readonly string CLIENT_ID = "692733325902872619";
|
||||||
|
|
||||||
|
private DiscordRpcClient discordRPC;
|
||||||
|
|
||||||
|
// called when Gamecraft shuts down
|
||||||
|
public void OnApplicationQuit()
|
||||||
|
{
|
||||||
|
// Shutdown this mod
|
||||||
|
GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has shutdown");
|
||||||
|
|
||||||
|
// Shutdown the Gamecraft modding API last
|
||||||
|
GamecraftModdingAPI.Main.Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
// called when Gamecraft starts up
|
||||||
|
public void OnApplicationStart()
|
||||||
|
{
|
||||||
|
// Initialize the Gamecraft modding API first
|
||||||
|
GamecraftModdingAPI.Main.Init();
|
||||||
|
|
||||||
|
// Initialize this mod
|
||||||
|
SimpleCustomCommandEngine rpcCommand = new SimpleCustomCommandEngine(
|
||||||
|
() => { }, // TODO: command action
|
||||||
|
// also try using CommandLogWarning or CommandLogError instead of CommandLog
|
||||||
|
"RPC", // command name (used to invoke it in the console)
|
||||||
|
"DiscordRPC Experimental command" // command description (displayed when help command is executed)
|
||||||
|
); // this command can also be executed using the Command Computer
|
||||||
|
|
||||||
|
// register the command so the modding API knows about it
|
||||||
|
CommandManager.AddCommand(rpcCommand);
|
||||||
|
|
||||||
|
discordRPC = new DiscordRpcClient(CLIENT_ID);
|
||||||
|
|
||||||
|
discordRPC.OnReady += (sender, e) =>
|
||||||
|
{
|
||||||
|
GamecraftModdingAPI.Utility.Logging.LogDebug($"Received Ready from user {e.User.Username}");
|
||||||
|
};
|
||||||
|
|
||||||
|
discordRPC.OnPresenceUpdate += (sender, e) =>
|
||||||
|
{
|
||||||
|
GamecraftModdingAPI.Utility.Logging.LogDebug($"Received Update! {e.Presence}");
|
||||||
|
};
|
||||||
|
|
||||||
|
discordRPC.Initialize();
|
||||||
|
|
||||||
|
discordRPC.SetPresence(new RichPresence()
|
||||||
|
{
|
||||||
|
Details = "Gamecraft Rich Presence",
|
||||||
|
State = "Gamecraft RPC test",
|
||||||
|
Assets = new DiscordRPC.Assets()
|
||||||
|
{
|
||||||
|
LargeImageKey = "image_large",
|
||||||
|
LargeImageText = "Testing stuff",
|
||||||
|
SmallImageKey = "image_small"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has started up");
|
||||||
|
}
|
||||||
|
|
||||||
|
// unused methods
|
||||||
|
|
||||||
|
public void OnFixedUpdate() { } // called once per physics update
|
||||||
|
|
||||||
|
public void OnLevelWasInitialized(int level) { } // called after a level is initialized
|
||||||
|
|
||||||
|
public void OnLevelWasLoaded(int level) { } // called after a level is loaded
|
||||||
|
|
||||||
|
public void OnUpdate() // called once per rendered frame (frame update)
|
||||||
|
{
|
||||||
|
if (discordRPC != null ) discordRPC.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,63 +0,0 @@
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
using IllusionPlugin;
|
|
||||||
// using GamecraftModdingAPI;
|
|
||||||
using GamecraftModdingAPI.Commands;
|
|
||||||
|
|
||||||
namespace HelloModdingWorld
|
|
||||||
{
|
|
||||||
public class MyPlugin : IPlugin // the Illusion Plugin Architecture (IPA) will ignore classes that don't implement IPlugin'
|
|
||||||
{
|
|
||||||
public string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name; // HelloModdingWorld by default
|
|
||||||
// To change the name, change the project's name
|
|
||||||
|
|
||||||
public string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString(); // 0.0.1 by default
|
|
||||||
// To change the version, change <Version>0.0.1</Version> in HelloModdingWorld.csproj
|
|
||||||
|
|
||||||
private static readonly string helloWorldCommandName = "HelloWorld"; // command name
|
|
||||||
|
|
||||||
// called when Gamecraft shuts down
|
|
||||||
public void OnApplicationQuit()
|
|
||||||
{
|
|
||||||
// Shutdown this mod
|
|
||||||
GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has shutdown");
|
|
||||||
|
|
||||||
// Shutdown the Gamecraft modding API last
|
|
||||||
GamecraftModdingAPI.Main.Shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
// called when Gamecraft starts up
|
|
||||||
public void OnApplicationStart()
|
|
||||||
{
|
|
||||||
// Initialize the Gamecraft modding API first
|
|
||||||
GamecraftModdingAPI.Main.Init();
|
|
||||||
// check out the modding API docs here: https://mod.exmods.org/
|
|
||||||
|
|
||||||
// Initialize this mod
|
|
||||||
// create SimpleCustomCommandEngine
|
|
||||||
// this writes "Hello modding world!" when you execute it in Gamecraft's console
|
|
||||||
// (use the forward-slash key '/' to open the console in Gamecraft when in a game)
|
|
||||||
SimpleCustomCommandEngine helloWorldCommand = new SimpleCustomCommandEngine(
|
|
||||||
() => { GamecraftModdingAPI.Utility.Logging.CommandLog("Hello modding world!"); }, // command action
|
|
||||||
// also try using CommandLogWarning or CommandLogError instead of CommandLog
|
|
||||||
helloWorldCommandName, // command name (used to invoke it in the console)
|
|
||||||
"Says Hello modding world!" // command description (displayed when help command is executed)
|
|
||||||
); // this command can also be executed using the Command Computer
|
|
||||||
|
|
||||||
// register the command so the modding API knows about it
|
|
||||||
CommandManager.AddCommand(helloWorldCommand);
|
|
||||||
|
|
||||||
GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has started up");
|
|
||||||
}
|
|
||||||
|
|
||||||
// unused methods
|
|
||||||
|
|
||||||
public void OnFixedUpdate() { } // called once per physics update
|
|
||||||
|
|
||||||
public void OnLevelWasInitialized(int level) { } // called after a level is initialized
|
|
||||||
|
|
||||||
public void OnLevelWasLoaded(int level) { } // called after a level is loaded
|
|
||||||
|
|
||||||
public void OnUpdate() { } // called once per rendered frame (frame update)
|
|
||||||
}
|
|
||||||
}
|
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) <year> <copyright holders>
|
Copyright (c) 2020 Exmods
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
16
README.md
16
README.md
|
@ -1,15 +1,15 @@
|
||||||
# HelloModdingWorld
|
# GamecraftRPC
|
||||||
|
|
||||||
Shell project for Gamecraft mods.
|
Experimental project for Discord Rich Presence in Gamecraft.
|
||||||
Use this as a quick-start project structure for your own mods, or to learn how modding works.
|
This currently only works in native environments (eg this does not work with Wine/Proton) although I'm sure someone can find a way to fix that'.
|
||||||
|
|
||||||
## Setup
|
## Dev environment Setup
|
||||||
|
|
||||||
This project requires most of Gamecraft's `.dll` files to function correctly.
|
This project requires most of Gamecraft's `.dll` files to function correctly.
|
||||||
Most, but not all, of these files are stored in Gamecraft's `Gamecraft_Data\Managed` folder.
|
Most, but not all, of these files are stored in Gamecraft's `Gamecraft_Data\Managed` folder.
|
||||||
The project is pre-configured to look in a folder called ref in the solution's main directory or one level up from that.
|
The project is pre-configured to look in a folder called ref in the solution's main directory or one level up from that.
|
||||||
|
|
||||||
You can make sure HelloModdingWorld can find all of `.dll` files it needs by copying your Gamecraft folder here and renaming it to `ref`, but you'll have to re-copy it after every Gamecraft update.
|
You can make sure GamecraftRPC can find all of `.dll` files it needs by copying your Gamecraft folder here and renaming it to `ref`, but you'll have to re-copy it after every Gamecraft update.
|
||||||
You can also create a symbolic link (look it up) to your Gamecraft install folder named `ref` in this folder to avoid having to re-copy files.
|
You can also create a symbolic link (look it up) to your Gamecraft install folder named `ref` in this folder to avoid having to re-copy files.
|
||||||
|
|
||||||
For any mod to work, you will have to patch your game with [GCIPA](https://git.exmods.org/modtainers/GCIPA).
|
For any mod to work, you will have to patch your game with [GCIPA](https://git.exmods.org/modtainers/GCIPA).
|
||||||
|
@ -21,12 +21,12 @@ This project also requires the [GamecraftModdingAPI](https://git.exmods.org/modt
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
After you've completed the setup, open the solution file `HelloModdingWorld.sln` in your prefered C# .NET/Mono development environment.
|
After you've completed the setup, open the solution file `GamecraftRPC.sln` in your prefered C# .NET/Mono development environment.
|
||||||
I'd recommend Visual Studio Community Edition or JetBrains Rider for Windows and Monodevelop for Linux.
|
I'd recommend Visual Studio Community Edition or JetBrains Rider for Windows and Monodevelop for Linux.
|
||||||
|
|
||||||
If you've successfully completed setup, you should be able to build the HelloModdingWorld project without errors.
|
If you've successfully completed setup, you should be able to build the GamecraftRPC project without errors.
|
||||||
If it doesn't work and you can't figure out why, ask for help on [our Discord server](https://discord.gg/xjnFxQV).
|
If it doesn't work and you can't figure out why, ask for help on [our Discord server](https://discord.gg/xjnFxQV).
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
To install the HelloModdingWorld mod, copy the build's `HelloModdingWorld.dll` into the `Plugins` folder in Gamecraft's main folder.
|
To install the GamecraftRPC mod, copy the build's `GamecraftRPC.dll` into the `Plugins` folder in Gamecraft's main folder.
|
||||||
|
|
Loading…
Add table
Reference in a new issue