Skip to content

Commit 964fb20

Browse files
authored
Initial commit
1 parent 71eb394 commit 964fb20

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed

BotCommands.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System.IO;
2+
using BepInEx;
3+
using BepInEx.Configuration;
4+
using UnityEngine;
5+
6+
namespace BotCMDs
7+
8+
// BUG: Sometimes has trouble reading the first line as a command, especially if there's no \n afterwards (the python bot adds this though)
9+
{
10+
[BepInDependency("com.bepis.r2api")]
11+
[BepInPlugin("com.Rayss.BotCommands", "Bot Commands", "0.1.0")]
12+
public class BotCommands : BaseUnityPlugin
13+
{
14+
15+
// Config
16+
private static ConfigEntry<string> Cmdpath { get; set; }
17+
private string botcmd_path;
18+
19+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Code Quality", "IDE0051:Remove unused private members")]
20+
public void Awake()
21+
{
22+
Cmdpath = Config.Bind<string>(
23+
"Config",
24+
"botcmd",
25+
"C:/Program Files (x86)/Steam/steamapps/common/Risk of Rain 2 Dedicated Server/BepInEx/plugins/botcmd.txt",
26+
"Insert the path of your botcmd.txt"
27+
);
28+
botcmd_path = Cmdpath.Value;
29+
30+
Debug.Log("Created by Rayss and InfernalPlacebo.");
31+
}
32+
33+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Code Quality", "IDE0051:Remove unused private members")]
34+
private void Update()
35+
{
36+
using (StreamReader reader = new StreamReader(new FileStream(botcmd_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
37+
{
38+
//start at the end of the file
39+
long lastMaxOffset = reader.BaseStream.Length;
40+
41+
System.Threading.Thread.Sleep(100);
42+
43+
//seek to the last max offset
44+
reader.BaseStream.Seek(lastMaxOffset, SeekOrigin.Begin);
45+
46+
//read out of the file until the EOF
47+
string line = "";
48+
49+
while ((line = reader.ReadLine()) != null)
50+
RoR2.Console.instance.SubmitCmd(null, line);
51+
52+
//update the last max offset
53+
lastMaxOffset = reader.BaseStream.Position;
54+
}
55+
}
56+
}
57+
}

BotCommands.csproj

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<Reference Include="0Harmony">
9+
<HintPath>..\misc\libs\0Harmony.dll</HintPath>
10+
</Reference>
11+
<Reference Include="Assembly-CSharp">
12+
<HintPath>..\misc\libs\Assembly-CSharp.dll</HintPath>
13+
</Reference>
14+
<Reference Include="Assembly-CSharp.R2API.mm">
15+
<HintPath>..\misc\libs\Assembly-CSharp.R2API.mm.dll</HintPath>
16+
</Reference>
17+
<Reference Include="BepInEx">
18+
<HintPath>..\misc\libs\BepInEx.dll</HintPath>
19+
</Reference>
20+
<Reference Include="BepInEx.Harmony">
21+
<HintPath>..\misc\libs\BepInEx.Harmony.dll</HintPath>
22+
</Reference>
23+
<Reference Include="BepInEx.MonoMod.Loader">
24+
<HintPath>..\misc\libs\BepInEx.MonoMod.Loader.dll</HintPath>
25+
</Reference>
26+
<Reference Include="BepInEx.Preloader">
27+
<HintPath>..\misc\libs\BepInEx.Preloader.dll</HintPath>
28+
</Reference>
29+
<Reference Include="Facepunch.Steamworks">
30+
<HintPath>..\misc\libs\Facepunch.Steamworks.dll</HintPath>
31+
</Reference>
32+
<Reference Include="MiniRpcLib">
33+
<HintPath>..\misc\libs\MiniRpcLib.dll</HintPath>
34+
</Reference>
35+
<Reference Include="MMHOOK_Assembly-CSharp">
36+
<HintPath>..\misc\libs\MMHOOK_Assembly-CSharp.dll</HintPath>
37+
</Reference>
38+
<Reference Include="Mono.Cecil">
39+
<HintPath>..\misc\libs\Mono.Cecil.dll</HintPath>
40+
</Reference>
41+
<Reference Include="Mono.Cecil.Mdb">
42+
<HintPath>..\misc\libs\Mono.Cecil.Mdb.dll</HintPath>
43+
</Reference>
44+
<Reference Include="Mono.Cecil.Pdb">
45+
<HintPath>..\misc\libs\Mono.Cecil.Pdb.dll</HintPath>
46+
</Reference>
47+
<Reference Include="Mono.Cecil.Rocks">
48+
<HintPath>..\misc\libs\Mono.Cecil.Rocks.dll</HintPath>
49+
</Reference>
50+
<Reference Include="MonoMod">
51+
<HintPath>..\misc\libs\MonoMod.exe</HintPath>
52+
</Reference>
53+
<Reference Include="MonoMod.RuntimeDetour">
54+
<HintPath>..\misc\libs\MonoMod.RuntimeDetour.dll</HintPath>
55+
</Reference>
56+
<Reference Include="MonoMod.Utils">
57+
<HintPath>..\misc\libs\MonoMod.Utils.dll</HintPath>
58+
</Reference>
59+
<Reference Include="R2API">
60+
<HintPath>..\misc\libs\R2API.dll</HintPath>
61+
</Reference>
62+
<Reference Include="UnityEngine">
63+
<HintPath>..\misc\libs\UnityEngine.dll</HintPath>
64+
</Reference>
65+
<Reference Include="UnityEngine.CoreModule">
66+
<HintPath>..\misc\libs\UnityEngine.CoreModule.dll</HintPath>
67+
</Reference>
68+
<Reference Include="UnityEngine.Networking">
69+
<HintPath>..\misc\libs\UnityEngine.Networking.dll</HintPath>
70+
</Reference>
71+
<Reference Include="UnityEngine.UnityWebRequestModule">
72+
<HintPath>..\misc\libs\UnityEngine.UnityWebRequestModule.dll</HintPath>
73+
</Reference>
74+
</ItemGroup>
75+
76+
</Project>

BotCommands.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29613.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotCommands", "BotCommands.csproj", "{9F3855A7-02AB-4E44-A337-F4594A1D2148}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{9F3855A7-02AB-4E44-A337-F4594A1D2148}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{9F3855A7-02AB-4E44-A337-F4594A1D2148}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{9F3855A7-02AB-4E44-A337-F4594A1D2148}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{9F3855A7-02AB-4E44-A337-F4594A1D2148}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {AB46F715-CF67-4DC8-A149-F3861AA4BF76}
24+
EndGlobalSection
25+
EndGlobal

0 commit comments

Comments
 (0)