mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
3 files changed
+93
-5
No files matched your search
@@ -7,10 +7,12 @@ using Assets.CoreScripts;
|
|||||||
using BepInEx.Unity.IL2CPP.Utils;
|
using BepInEx.Unity.IL2CPP.Utils;
|
||||||
using MiraAPI.Events;
|
using MiraAPI.Events;
|
||||||
using MiraAPI.Events.Vanilla.Gameplay;
|
using MiraAPI.Events.Vanilla.Gameplay;
|
||||||
|
using MiraAPI.Utilities;
|
||||||
using Reactor.Networking.Attributes;
|
using Reactor.Networking.Attributes;
|
||||||
using Reactor.Networking.Rpc;
|
using Reactor.Networking.Rpc;
|
||||||
using Reactor.Utilities;
|
using Reactor.Utilities;
|
||||||
using Reactor.Utilities.Extensions;
|
using Reactor.Utilities.Extensions;
|
||||||
|
using Rewired;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
@@ -22,7 +24,7 @@ namespace MiraAPI.Networking;
|
|||||||
public static class CustomMurderRpc
|
public static class CustomMurderRpc
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Networked Custom Murder method.
|
/// Networked Custom Murder method, ran by clients for the host to confirm kills.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">The killer.</param>
|
/// <param name="source">The killer.</param>
|
||||||
/// <param name="target">The player to murder.</param>
|
/// <param name="target">The player to murder.</param>
|
||||||
@@ -54,7 +56,7 @@ public static class CustomMurderRpc
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Networked Custom Murder method, which checks for meetings as well.
|
/// Networked Custom Murder method, which checks for meetings as well, ran by clients for the host to confirm kills.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">The killer.</param>
|
/// <param name="source">The killer.</param>
|
||||||
/// <param name="target">The player to murder.</param>
|
/// <param name="target">The player to murder.</param>
|
||||||
@@ -96,6 +98,52 @@ public static class CustomMurderRpc
|
|||||||
murderResultFlags = MurderResultFlags.FailedError;
|
murderResultFlags = MurderResultFlags.FailedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!PlayerControl.LocalPlayer.IsHost())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RpcConfirmCustomMurder(
|
||||||
|
PlayerControl.LocalPlayer,
|
||||||
|
source,
|
||||||
|
target,
|
||||||
|
murderResultFlags,
|
||||||
|
resetKillTimer,
|
||||||
|
createDeadBody,
|
||||||
|
teleportMurderer,
|
||||||
|
showKillAnim,
|
||||||
|
playKillSound);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Networked Custom Murder method, which checks for meetings as well, ran by clients for the host to confirm kills.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="host">The game host.</param>
|
||||||
|
/// <param name="source">The killer.</param>
|
||||||
|
/// <param name="target">The player to murder.</param>
|
||||||
|
/// <param name="murderResultFlags">End result for the murder.</param>
|
||||||
|
/// <param name="resetKillTimer">Should the kill timer be reset.</param>
|
||||||
|
/// <param name="createDeadBody">Should a dead body be created.</param>
|
||||||
|
/// <param name="teleportMurderer">Should the killer be snapped to the dead player.</param>
|
||||||
|
/// <param name="showKillAnim">Should the kill animation be shown.</param>
|
||||||
|
/// <param name="playKillSound">Should the kill sound be played.</param>
|
||||||
|
[MethodRpc((uint)MiraRpc.ConfirmCustomMurder, LocalHandling = RpcLocalHandling.After)]
|
||||||
|
public static void RpcConfirmCustomMurder(
|
||||||
|
this PlayerControl host,
|
||||||
|
PlayerControl source,
|
||||||
|
PlayerControl target,
|
||||||
|
MurderResultFlags murderResultFlags,
|
||||||
|
bool resetKillTimer = true,
|
||||||
|
bool createDeadBody = true,
|
||||||
|
bool teleportMurderer = true,
|
||||||
|
bool showKillAnim = true,
|
||||||
|
bool playKillSound = true)
|
||||||
|
{
|
||||||
|
if (LobbyBehaviour.Instance || !host.IsHost() || target.Data.IsDead || target.Data.Disconnected)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var murderResultFlags2 = MurderResultFlags.DecisionByHost | murderResultFlags;
|
var murderResultFlags2 = MurderResultFlags.DecisionByHost | murderResultFlags;
|
||||||
|
|
||||||
source.CustomMurder(
|
source.CustomMurder(
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ public enum MiraRpc : uint
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
CustomMurder,
|
CustomMurder,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Custom Murder RPC Confirmation.
|
||||||
|
/// </summary>
|
||||||
|
ConfirmCustomMurder,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Custom Game Over RPC.
|
/// Custom Game Over RPC.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -210,12 +210,19 @@ public static class LobbyViewPanePatches
|
|||||||
list.Add(roleBehaviour);
|
list.Add(roleBehaviour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var color = (i == 0) ? Palette.CrewmateRoleBlue : Palette.ImpostorRoleRed;
|
||||||
|
if (roleBehaviour is ICustomRole custom && (custom.Team is not ModdedRoleTeams.Crewmate &&
|
||||||
|
custom.Team is not ModdedRoleTeams.Impostor))
|
||||||
|
{
|
||||||
|
color = Color.grey;
|
||||||
|
}
|
||||||
|
|
||||||
viewSettingsInfoPanelRoleVariant.SetInfo(
|
viewSettingsInfoPanelRoleVariant.SetInfo(
|
||||||
roleBehaviour.NiceName,
|
roleBehaviour.NiceName,
|
||||||
numPerGame,
|
numPerGame,
|
||||||
chancePerGame,
|
chancePerGame,
|
||||||
61,
|
61,
|
||||||
(i == 0) ? Palette.CrewmateRoleBlue : Palette.ImpostorRoleRed,
|
color,
|
||||||
roleBehaviour.RoleIconSolid,
|
roleBehaviour.RoleIconSolid,
|
||||||
i == 0,
|
i == 0,
|
||||||
flag);
|
flag);
|
||||||
@@ -513,6 +520,34 @@ public static class LobbyViewPanePatches
|
|||||||
instance.scrollBar.SetYBoundsMax(-num);
|
instance.scrollBar.SetYBoundsMax(-num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetModdedHeader(this CategoryHeaderRoleVariant header, StringNames roleName, int maskLayer, ModdedRoleTeams team, Sprite? roleIcon = null)
|
||||||
|
{
|
||||||
|
header.SetHeader(roleName, maskLayer);
|
||||||
|
if (team is ModdedRoleTeams.Crewmate)
|
||||||
|
{
|
||||||
|
header.Background.color = Palette.CrewmateRoleHeaderBlue;
|
||||||
|
header.Divider.color = Palette.CrewmateRoleHeaderBlue;
|
||||||
|
header.Title.color = Palette.CrewmateRoleHeaderTextBlue;
|
||||||
|
}
|
||||||
|
else if (team is ModdedRoleTeams.Impostor)
|
||||||
|
{
|
||||||
|
header.Background.color = Palette.ImpostorRoleHeaderRed;
|
||||||
|
header.Divider.color = Palette.ImpostorRoleHeaderRed;
|
||||||
|
header.Title.color = Palette.ImpostorRoleHeaderTextRed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
header.Background.color = Color.grey;
|
||||||
|
header.Divider.color = Color.grey;
|
||||||
|
header.Title.color = new Color32(50, 50, 50, 255);
|
||||||
|
}
|
||||||
|
if (roleIcon != null && header.icon != null)
|
||||||
|
{
|
||||||
|
header.icon.material.SetInt(PlayerMaterial.MaskLayer, maskLayer);
|
||||||
|
header.icon.sprite = roleIcon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static float SetUpAdvancedRoleViewPanel(
|
private static float SetUpAdvancedRoleViewPanel(
|
||||||
AdvancedRoleViewPanel viewPanel,
|
AdvancedRoleViewPanel viewPanel,
|
||||||
Type roleType,
|
Type roleType,
|
||||||
@@ -536,10 +571,10 @@ public static class LobbyViewPanePatches
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
viewPanel.header.SetHeader(
|
viewPanel.header.SetModdedHeader(
|
||||||
role.StringName,
|
role.StringName,
|
||||||
maskLayer,
|
maskLayer,
|
||||||
role.TeamType == RoleTeamTypes.Crewmate,
|
customRole.Team,
|
||||||
customRole.Configuration.Icon != null ? customRole.Configuration.Icon.LoadAsset() : MiraAssets.Empty.LoadAsset());
|
customRole.Configuration.Icon != null ? customRole.Configuration.Icon.LoadAsset() : MiraAssets.Empty.LoadAsset());
|
||||||
viewPanel.header.icon.transform.localScale = new Vector3(0.465f, 0.465f, 1f);
|
viewPanel.header.icon.transform.localScale = new Vector3(0.465f, 0.465f, 1f);
|
||||||
viewPanel.divider.material.SetInt(PlayerMaterial.MaskLayer, maskLayer);
|
viewPanel.divider.material.SetInt(PlayerMaterial.MaskLayer, maskLayer);
|
||||||
|
|||||||
Reference in new issue
Block a user