Merge branch 'master' into dev

This commit is contained in:
ang-xd committed 2024-08-27 20:10:37 -04:00
commit d4955b5183
7 files changed
+101 -17

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
name: CI
on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x
- name: Run the Cake script
uses: cake-build/cake-action@v2
with:
verbosity: Diagnostic
- uses: actions/upload-artifact@v3
with:
name: MiraAPI.dll
path: MiraAPI/bin/Release/net6.0/MiraAPI.dll
@@ -15,7 +15,7 @@ public class ModifierTimerExample : TimedModifier
public override void OnTimerComplete()
{
Player.SetColor((byte)_rand.Next(0, Palette.PlayerColors.Count));
Player.RpcSetColor((byte)_rand.Next(0, Palette.PlayerColors.Count));
StartTimer();
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
<LangVersion>latest</LangVersion>
<DebugType>embedded</DebugType>
<PackageId>AllOfUs.MiraAPI</PackageId>
<Version>0.1.0</Version>
<Version>0.1.2</Version>
<Description>Simple and easy to use Among Us modding API.</Description>
<Authors>Angxl, XtraCube</Authors>
<Company>All Of Us</Company>
+5 -14
View File
@@ -6,6 +6,7 @@ using Reactor.Networking.Rpc;
using Reactor.Utilities.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using Random = System.Random;
namespace MiraAPI.Modifiers;
@@ -40,7 +41,7 @@ public static class ModifierManager
List<uint> filteredModifiers = [];
foreach (var modifier in IdToTypeModifiers)
foreach (var modifier in IdToTypeModifiers.Where(pair => pair.Value.GetType() == typeof(GameModifier)))
{
var mod = (GameModifier)Activator.CreateInstance(modifier.Value);
var num = mod.GetAmountPerGame();
@@ -92,22 +93,12 @@ public static class ModifierManager
{
var data = new List<NetData>();
if (targetId == -1)
foreach (var player in GameData.Instance.AllPlayers)
{
foreach (var player in GameData.Instance.AllPlayers)
{
data.Add(GetPlayerModifiers(player.Object));
}
}
else
{
var player = GameData.Instance.GetPlayerById((byte)targetId).Object;
data.Add(GetPlayerModifiers(player));
data.Add(GetPlayerModifiers(player.Object));
}
Rpc<SyncModifiersRpc>.Instance.Send(PlayerControl.LocalPlayer, data.ToArray(), true);
Rpc<SyncModifiersRpc>.Instance.SendTo(PlayerControl.LocalPlayer, targetId, data.ToArray());
}
internal static void HandleSyncModifiers(NetData[] data)
@@ -0,0 +1,39 @@
using HarmonyLib;
using Il2CppSystem;
using MiraAPI.Roles;
using System.Linq;
namespace MiraAPI.Patches.Options;
[HarmonyPatch(typeof(NotificationPopper))]
public class NotificationPopperPatch
{
[HarmonyPrefix]
[HarmonyPatch(nameof(NotificationPopper.AddRoleSettingsChangeMessage))]
public static bool RoleChangeMsgPatch(NotificationPopper __instance,
[HarmonyArgument(0)] StringNames key, [HarmonyArgument(1)] int roleCount, [HarmonyArgument(2)] int roleChance, [HarmonyArgument(3)] RoleTeamTypes teamType,
[HarmonyArgument(4)] bool playSound)
{
if (CustomRoleManager.CustomRoles.Values.Any(role => role.StringName == key))
{
string item = string.Empty;
string text = (teamType == RoleTeamTypes.Crewmate) ? Palette.CrewmateSettingChangeText.ToTextColor() : Palette.ImpostorRed.ToTextColor();
item = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.LobbyChangeSettingNotificationRole, new Object[]
{
string.Concat(
[
"<font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">",
text,
DestroyableSingleton<TranslationController>.Instance.GetString(key, Array.Empty<Object>()),
"</color></font>"
]),
"<font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">" + roleCount.ToString() + "</font>",
"<font=\"Barlow-Black SDF\" material=\"Barlow-Black Outline\">" + roleChance.ToString() + "%"
});
__instance.SettingsChangeMessageLogic(key, item, playSound);
return false;
}
return true;
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ Mira API strives to be simple and easy to use, while also using as many base gam
# Usage
To start using Mira API, you need to:
1. Add a reference to Mira API either through a DLL, project reference, or NuGet package.
1. Add a reference to Mira API either through a [DLL](https://github.com/All-Of-Us-Mods/MiraAPI/releases), project reference, or [NuGet package](https://www.nuget.org/packages/AllOfUs.MiraAPI).
2. Add a BepInDependency on your plugin class like this: `[BepInDependency(MiraApiPlugin.Id)]`
3. Implement the IMiraPlugin interface on your plugin class.
+28
View File
@@ -0,0 +1,28 @@
var target = Argument("target", "Build");
var workflow = BuildSystem.GitHubActions.Environment.Workflow;
var buildId = workflow.RunNumber;
var tag = workflow.RefType == GitHubActionsRefType.Tag ? workflow.RefName : null;
Task("Build")
.Does(() =>
{
var settings = new DotNetBuildSettings
{
Configuration = "Release",
MSBuildSettings = new DotNetMSBuildSettings()
};
if (tag != null)
{
settings.MSBuildSettings.Version = tag;
}
else if (buildId != 0)
{
settings.MSBuildSettings.VersionSuffix = "ci." + buildId;
}
DotNetBuild(".", settings);
});
RunTarget(target);