mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Change murders to check with the host beforehand
This commit is contained in:
1 parent
7f506000a4
commit
272b14f0e0
2 files changed
+58
-6
No files matched your search
@@ -7,10 +7,12 @@ using Assets.CoreScripts;
|
||||
using BepInEx.Unity.IL2CPP.Utils;
|
||||
using MiraAPI.Events;
|
||||
using MiraAPI.Events.Vanilla.Gameplay;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Networking.Attributes;
|
||||
using Reactor.Networking.Rpc;
|
||||
using Reactor.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using Rewired;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
@@ -22,7 +24,7 @@ namespace MiraAPI.Networking;
|
||||
public static class CustomMurderRpc
|
||||
{
|
||||
/// <summary>
|
||||
/// Networked Custom Murder method.
|
||||
/// Networked Custom Murder method, ran by clients for the host to confirm kills.
|
||||
/// </summary>
|
||||
/// <param name="source">The killer.</param>
|
||||
/// <param name="target">The player to murder.</param>
|
||||
@@ -54,7 +56,7 @@ public static class CustomMurderRpc
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <param name="source">The killer.</param>
|
||||
/// <param name="target">The player to murder.</param>
|
||||
@@ -77,10 +79,6 @@ public static class CustomMurderRpc
|
||||
bool showKillAnim = true,
|
||||
bool playKillSound = true)
|
||||
{
|
||||
if (LobbyBehaviour.Instance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var murderResultFlags = didSucceed ? MurderResultFlags.Succeeded : MurderResultFlags.FailedError;
|
||||
|
||||
var beforeMurderEvent = new BeforeMurderEvent(source, target, inMeeting);
|
||||
@@ -96,6 +94,55 @@ public static class CustomMurderRpc
|
||||
murderResultFlags = MurderResultFlags.FailedError;
|
||||
}
|
||||
|
||||
if (!PlayerControl.LocalPlayer.IsHost())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RpcConfirmCustomMurder(
|
||||
PlayerControl.LocalPlayer,
|
||||
source,
|
||||
target,
|
||||
inMeeting,
|
||||
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="inMeeting">Whether the murder is intended to be triggered in a meeting.</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.Before)]
|
||||
public static void RpcConfirmCustomMurder(
|
||||
this PlayerControl host,
|
||||
PlayerControl source,
|
||||
PlayerControl target,
|
||||
MeetingCheck inMeeting,
|
||||
MurderResultFlags murderResultFlags,
|
||||
bool resetKillTimer = true,
|
||||
bool createDeadBody = true,
|
||||
bool teleportMurderer = true,
|
||||
bool showKillAnim = true,
|
||||
bool playKillSound = true)
|
||||
{
|
||||
if (LobbyBehaviour.Instance || !host.IsHost())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var murderResultFlags2 = MurderResultFlags.DecisionByHost | murderResultFlags;
|
||||
|
||||
source.CustomMurder(
|
||||
|
||||
@@ -35,6 +35,11 @@ public enum MiraRpc : uint
|
||||
/// </summary>
|
||||
CustomMurder,
|
||||
|
||||
/// <summary>
|
||||
/// Custom Murder RPC Confirmation.
|
||||
/// </summary>
|
||||
ConfirmCustomMurder,
|
||||
|
||||
/// <summary>
|
||||
/// Custom Game Over RPC.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user