From 83d55d409b6dd5ad2fd1d2e19b6322e4c48e59b5 Mon Sep 17 00:00:00 2001 From: Atony <75191600+AtonyGit@users.noreply.github.com> Date: Thu, 13 Aug 2026 10:07:40 -0500 Subject: [PATCH 1/2] Change indirect and defense flags to get sets --- .../Vanilla/Gameplay/BeforeMurderEvent.cs | 8 +-- MiraAPI/Networking/CustomMurderRpc.cs | 61 ++++++++++++++----- 2 files changed, 49 insertions(+), 20 deletions(-) diff --git a/MiraAPI/Events/Vanilla/Gameplay/BeforeMurderEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/BeforeMurderEvent.cs index 8a770dc..00a977e 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/BeforeMurderEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/BeforeMurderEvent.cs @@ -23,15 +23,15 @@ public sealed class BeforeMurderEvent : MiraCancelableEvent public PlayerControl? Framed { get; } /// - /// Gets a value indicating whether the murder is done indirectly. + /// Gets or sets a value indicating whether the murder is done indirectly. /// This is commonly used to prevent the from being killed. /// - public bool IsIndirectAttack { get; } + public bool IsIndirectAttack { get; set; } /// - /// Gets a value indicating whether the murder should bypass protective roles or general defense, such as . + /// Gets or sets a value indicating whether the murder should bypass protective roles or general defense, such as . /// - public bool IgnoreDefense { get; } + public bool IgnoreDefense { get; set; } /// /// Gets whether the murder was meant to be done in a meeting, via an enum. diff --git a/MiraAPI/Networking/CustomMurderRpc.cs b/MiraAPI/Networking/CustomMurderRpc.cs index b53fd85..0622492 100644 --- a/MiraAPI/Networking/CustomMurderRpc.cs +++ b/MiraAPI/Networking/CustomMurderRpc.cs @@ -84,13 +84,15 @@ public static class CustomMurderRpc var beforeMurderEvent = new BeforeMurderEvent(source, target, inMeeting); MiraEventManager.InvokeEvent(beforeMurderEvent); + var defenseFlag = beforeMurderEvent.IgnoreDefense; + var indirectFlag = beforeMurderEvent.IsIndirectAttack; var isMeetingActive = MeetingHud.Instance != null || ExileController.Instance != null; if ((inMeeting is MeetingCheck.ForMeeting && !isMeetingActive) || (inMeeting is MeetingCheck.OutsideMeeting && isMeetingActive)) { beforeMurderEvent.Cancel(); } - if (target.ProtectedByGa()) + if (!defenseFlag && target.ProtectedByGa()) { beforeMurderEvent.Cancel(); murderResultFlags = MurderResultFlags.FailedProtected; @@ -114,6 +116,8 @@ public static class CustomMurderRpc PlayerControl.LocalPlayer, source, target, + indirectFlag, + defenseFlag, murderResultFlags, resetKillTimer, createDeadBody, @@ -128,6 +132,8 @@ public static class CustomMurderRpc /// The game host. /// The killer. /// The player to murder. + /// Should the kill be indirect. + /// Should the kill ignore defense. /// End result for the murder. /// Should the kill timer be reset. /// Should a dead body be created. @@ -139,6 +145,8 @@ public static class CustomMurderRpc this PlayerControl host, PlayerControl source, PlayerControl target, + bool isIndirect, + bool ignoreDefense, MurderResultFlags murderResultFlags, bool resetKillTimer = true, bool createDeadBody = true, @@ -154,14 +162,31 @@ public static class CustomMurderRpc var murderResultFlags2 = MurderResultFlags.DecisionByHost | murderResultFlags; - source.CustomMurder( - target, - murderResultFlags2, - resetKillTimer, - createDeadBody, - teleportMurderer, - showKillAnim, - playKillSound); + if (isIndirect || ignoreDefense) + { + source.CustomMurder( + target, + null, + isIndirect, + ignoreDefense, + murderResultFlags2, + resetKillTimer, + createDeadBody, + teleportMurderer, + showKillAnim, + playKillSound); + } + else + { + source.CustomMurder( + target, + murderResultFlags2, + resetKillTimer, + createDeadBody, + teleportMurderer, + showKillAnim, + playKillSound); + } } /// @@ -200,13 +225,15 @@ public static class CustomMurderRpc var beforeMurderEvent = new BeforeMurderEvent(source, target, isIndirect, ignoreDefense, inMeeting); MiraEventManager.InvokeEvent(beforeMurderEvent); + var defenseFlag = beforeMurderEvent.IgnoreDefense; + var indirectFlag = beforeMurderEvent.IsIndirectAttack; var isMeetingActive = MeetingHud.Instance != null || ExileController.Instance != null; if ((inMeeting is MeetingCheck.ForMeeting && !isMeetingActive) || (inMeeting is MeetingCheck.OutsideMeeting && isMeetingActive)) { beforeMurderEvent.Cancel(); } - if (!ignoreDefense && target.ProtectedByGa()) + if (!defenseFlag && target.ProtectedByGa()) { beforeMurderEvent.Cancel(); murderResultFlags = MurderResultFlags.FailedProtected; @@ -230,8 +257,8 @@ public static class CustomMurderRpc PlayerControl.LocalPlayer, source, target, - isIndirect, - ignoreDefense, + indirectFlag, + defenseFlag, murderResultFlags, resetKillTimer, createDeadBody, @@ -327,13 +354,15 @@ public static class CustomMurderRpc var beforeMurderEvent = new BeforeMurderEvent(source, target, framed, isIndirect, ignoreDefense, inMeeting); MiraEventManager.InvokeEvent(beforeMurderEvent); + var defenseFlag = beforeMurderEvent.IgnoreDefense; + var indirectFlag = beforeMurderEvent.IsIndirectAttack; var isMeetingActive = MeetingHud.Instance != null || ExileController.Instance != null; if ((inMeeting is MeetingCheck.ForMeeting && !isMeetingActive) || (inMeeting is MeetingCheck.OutsideMeeting && isMeetingActive)) { beforeMurderEvent.Cancel(); } - if (!ignoreDefense && target.ProtectedByGa()) + if (!defenseFlag && target.ProtectedByGa()) { beforeMurderEvent.Cancel(); murderResultFlags = MurderResultFlags.FailedProtected; @@ -358,8 +387,8 @@ public static class CustomMurderRpc source, target, framed, - isIndirect, - ignoreDefense, + indirectFlag, + defenseFlag, murderResultFlags, resetKillTimer, createDeadBody, @@ -420,7 +449,7 @@ public static class CustomMurderRpc } /// - /// Custom Murder method without networking. If you need a networked version, use . + /// Custom Murder method without networking. If you need a networked version, use or . /// /// The killer. /// The player to murder. From 6fd5993959fd0301c68e0c03b01cdda692e0292d Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Thu, 13 Aug 2026 23:27:07 -0400 Subject: [PATCH 2/2] pass shader caching through helper method --- MiraAPI/Utilities/ShaderID.cs | 76 +++++++++++++++++------------------ 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/MiraAPI/Utilities/ShaderID.cs b/MiraAPI/Utilities/ShaderID.cs index 3ef92e6..3f2855a 100644 --- a/MiraAPI/Utilities/ShaderID.cs +++ b/MiraAPI/Utilities/ShaderID.cs @@ -24,80 +24,80 @@ public static class ShaderID } // For player shader - public static readonly int BodyColor = Shader.PropertyToID("_BodyColor"); - public static readonly int BackColor = Shader.PropertyToID("_BackColor"); - public static readonly int VisorColor = Shader.PropertyToID("_VisorColor"); + public static readonly int BodyColor = Get("_BodyColor"); + public static readonly int BackColor = Get("_BackColor"); + public static readonly int VisorColor = Get("_VisorColor"); // Main texture, very obviously used in any shader with a texture - public static readonly int MainTex = Shader.PropertyToID("_MainTex"); + public static readonly int MainTex = Get("_MainTex"); // Any masking stuff, like MeetingHud bubbles - public static readonly int Mask = Shader.PropertyToID("_Mask"); - public static readonly int MaskComp = Shader.PropertyToID("_MaskComp"); - public static readonly int MaskLayer = Shader.PropertyToID("_MaskLayer"); - public static readonly int Stencil = Shader.PropertyToID("_Stencil"); - public static readonly int StencilComp = Shader.PropertyToID("_StencilComp"); + public static readonly int Mask = Get("_Mask"); + public static readonly int MaskComp = Get("_MaskComp"); + public static readonly int MaskLayer = Get("_MaskLayer"); + public static readonly int Stencil = Get("_Stencil"); + public static readonly int StencilComp = Get("_StencilComp"); // Used in many tasks - public static readonly int Color = Shader.PropertyToID("_Color"); + public static readonly int Color = Get("_Color"); // Has 2 uses in the game, provided for convenience - public static readonly int Opacity = Shader.PropertyToID("_Opacity"); + public static readonly int Opacity = Get("_Opacity"); // Used once in CooldownHelpers, once in PowerBarMining - public static readonly int NormalizedUvs = Shader.PropertyToID("_NormalizedUvs"); + public static readonly int NormalizedUvs = Get("_NormalizedUvs"); // Used in many consoles - public static readonly int Outline = Shader.PropertyToID("_Outline"); - public static readonly int OutlineColor = Shader.PropertyToID("_OutlineColor"); + public static readonly int Outline = Get("_Outline"); + public static readonly int OutlineColor = Get("_OutlineColor"); // Used in some consoles - public static readonly int AddColor = Shader.PropertyToID("_AddColor"); + public static readonly int AddColor = Get("_AddColor"); // Has some uses in various locations - public static readonly int Percent = Shader.PropertyToID("_Percent"); - public static readonly int PercentY = Shader.PropertyToID("_PercentY"); - public static readonly int Desat = Shader.PropertyToID("_Desat"); + public static readonly int Percent = Get("_Percent"); + public static readonly int PercentY = Get("_PercentY"); + public static readonly int Desat = Get("_Desat"); // Used in LightSource - public static readonly int PlayerRadius = Shader.PropertyToID("_PlayerRadius"); - public static readonly int LightRadius = Shader.PropertyToID("_LightRadius"); - public static readonly int LightOffset = Shader.PropertyToID("_LightOffset"); - public static readonly int FlashlightSize = Shader.PropertyToID("_FlashlightSize"); - public static readonly int FlashlightAngle = Shader.PropertyToID("_FlashlightAngle"); + public static readonly int PlayerRadius = Get("_PlayerRadius"); + public static readonly int LightRadius = Get("_LightRadius"); + public static readonly int LightOffset = Get("_LightOffset"); + public static readonly int FlashlightSize = Get("_FlashlightSize"); + public static readonly int FlashlightAngle = Get("_FlashlightAngle"); // Used once for LightSourceGpuRenderer - public static readonly int DepthCompressionValue = Shader.PropertyToID("_DepthCompressionValue"); + public static readonly int DepthCompressionValue = Get("_DepthCompressionValue"); // Used in ProgressTracker - public static readonly int Buckets = Shader.PropertyToID("_Buckets"); - public static readonly int FullBuckets = Shader.PropertyToID("_FullBuckets"); + public static readonly int Buckets = Get("_Buckets"); + public static readonly int FullBuckets = Get("_FullBuckets"); // Used once in IntroCutscene and EndGameManager - public static readonly int Rad = Shader.PropertyToID("_Rad"); + public static readonly int Rad = Get("_Rad"); // Used only once for Quick Chat - public static readonly int FaceColor = Shader.PropertyToID("_FaceColor"); + public static readonly int FaceColor = Get("_FaceColor"); // Used for NavigationMinigame - public static readonly int CrossHair = Shader.PropertyToID("_CrossHair"); - public static readonly int CrossColor = Shader.PropertyToID("_CrossColor"); + public static readonly int CrossHair = Get("_CrossHair"); + public static readonly int CrossColor = Get("_CrossColor"); // Used for both SurveillanceMinigame (Planet and Normal) - public static readonly int Center = Shader.PropertyToID("_Center"); - public static readonly int Color2 = Shader.PropertyToID("_Color2"); + public static readonly int Center = Get("_Center"); + public static readonly int Color2 = Get("_Color2"); // Used in ReactorShipRoom - public static readonly int Speed = Shader.PropertyToID("_Speed"); + public static readonly int Speed = Get("_Speed"); // Used only once in CourseMinigame - public static readonly int AltTex = Shader.PropertyToID("_AltTex"); - public static readonly int Perc = Shader.PropertyToID("_Perc"); + public static readonly int AltTex = Get("_AltTex"); + public static readonly int Perc = Get("_Perc"); // Used once in TextMarquee - public static readonly int VertexOffsetX = Shader.PropertyToID("_VertexOffsetX"); - public static readonly int VertexOffsetY = Shader.PropertyToID("_VertexOffsetY"); + public static readonly int VertexOffsetX = Get("_VertexOffsetX"); + public static readonly int VertexOffsetY = Get("_VertexOffsetY"); // Used in VertLineBehaviour - public static readonly int Fade = Shader.PropertyToID("_Fade"); + public static readonly int Fade = Get("_Fade"); }