From bdce8fa37d9d5189952e6b52d6bc609804174755 Mon Sep 17 00:00:00 2001
From: Ang <106892549+ang-xd@users.noreply.github.com>
Date: Wed, 28 Aug 2024 15:17:56 -0400
Subject: [PATCH 1/7] Update README.md
---
README.md | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/README.md b/README.md
index 01c3d2cd..ee83945b 100644
--- a/README.md
+++ b/README.md
@@ -180,6 +180,15 @@ public class MyOptionsGroup : AbstractOptionGroup
An example can be found [here](https://github.com/All-Of-Us-Mods/MiraAPI/blob/master/MiraAPI.Example/Options/Roles/CustomRoleSettings.cs).
+## Custom Murders
+Mira API provides it's own implementation for murders. Our implementation allows for more customization on kills, and helps bypass server checks.
+You can use `PlayerControl.RpcCustomMurder` to perform a networked custom murder, or `PlayerControl.CustomMurder` to normally perform a custom murder.
+For example:
+```cs
+PlayerControl.LocalPlayer.RpcCustomMurder(Target, createDeadBody: false, teleportMurderer: false, playKillSound: false, resetKillTimer: false, showKillAnim: false);
+```
+This will kill a player without creating a dead body and without teleporting the murderer.
+
## Buttons
Mira API provides a simple interface for adding ability buttons to the game. There is only 2 steps:
From 4775bbfeaa12b7dfd88e85e06f135b1e726a25ec Mon Sep 17 00:00:00 2001
From: XtraCube <72575280+XtraCube@users.noreply.github.com>
Date: Sat, 31 Aug 2024 21:42:20 -0400
Subject: [PATCH 2/7] precautions for the nuget stuff
---
.github/workflows/main.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
index 6c874283..23450ddd 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/main.yaml
@@ -46,6 +46,6 @@ jobs:
files: MiraAPI/bin/Release/net6.0/MiraAPI.dll
- name: Push NuGet package
- if: github.repository == 'All-Of-Us-Mods/MiraAPI' && github.ref == 'refs/heads/master'
+ if: github.ref_type == 'tag'
run: |
dotnet nuget push {MiraAPI/bin/Release/AllOfUs.MiraAPI.*.nupkg} --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
\ No newline at end of file
From bdb88523470410c9e627285ee701bbb32c87d05e Mon Sep 17 00:00:00 2001
From: XtraCube <72575280+XtraCube@users.noreply.github.com>
Date: Sat, 31 Aug 2024 21:45:01 -0400
Subject: [PATCH 3/7] FIX NUGET CI PRAYING RN
---
.github/workflows/main.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
index 23450ddd..278c2054 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/main.yaml
@@ -48,4 +48,4 @@ jobs:
- name: Push NuGet package
if: github.ref_type == 'tag'
run: |
- dotnet nuget push {MiraAPI/bin/Release/AllOfUs.MiraAPI.*.nupkg} --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
\ No newline at end of file
+ dotnet nuget push MiraAPI/bin/Release/AllOfUs.MiraAPI.*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
\ No newline at end of file
From f92d08b825b2c961b9986f3ea550ba15c466e0b8 Mon Sep 17 00:00:00 2001
From: Rubyboat <52091447+Rubyboat1207@users.noreply.github.com>
Date: Mon, 2 Sep 2024 15:37:53 -0500
Subject: [PATCH 4/7] Added Loadable Audio Resource Asset
---
.../Assets/LoadableAudioResourceAsset.cs | 66 +++++++++++++++++++
1 file changed, 66 insertions(+)
create mode 100644 MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs
diff --git a/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs b/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs
new file mode 100644
index 00000000..7e4decf7
--- /dev/null
+++ b/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs
@@ -0,0 +1,66 @@
+using System;
+using System.IO;
+using System.Reflection;
+using System.Text;
+using Cpp2IL.Core.Extensions;
+using MiraAPI.Utilities.Assets;
+using Reactor.Utilities.Extensions;
+using UnityEngine;
+
+namespace MiraAPI.Utilities.Assets;
+
+///
+/// A utility class for loading .WAV audio assets from the DLL's embedded resources.
+///
+/// The path of the wave file
+public class LoadableAudioResourceAsset(string path) : LoadableAsset
+{
+ private readonly Assembly _assembly = Assembly.GetCallingAssembly();
+
+ ///
+ /// Loads the asset from embedded resources.
+ ///
+ /// The asset to load.
+ /// Attempted to load an Audio file in non WAV format.
+ /// Stream failed to load. Check if the name of your asset was correct.
+ public override AudioClip LoadAsset()
+ {
+ var assetStream = _assembly.GetManifestResourceStream(path);
+
+ if (assetStream != null)
+ {
+ var audioBytes = assetStream.ReadFully();
+
+ string riffHeader = Encoding.ASCII.GetString(audioBytes.SubArray(0, 4));
+ string waveHeader = Encoding.ASCII.GetString(audioBytes.SubArray(8, 4));
+
+ if (riffHeader != "RIFF" || waveHeader != "WAVE")
+ {
+ throw new NotSupportedException($"Attempted to load an Audio file in non WAV format '{path}'.");
+ }
+
+ int channels = BitConverter.ToInt16(audioBytes, 22);
+ int sampleRate = BitConverter.ToInt32(audioBytes, 24);
+ int dataSize = BitConverter.ToInt32(audioBytes, 40);
+
+ float[] audioData = new float[dataSize / 2];
+ for (int i = 0; i < audioData.Length; i++)
+ {
+ audioData[i] = BitConverter.ToInt16(audioBytes, 44 + i * 2) / 32768.0f;
+ }
+
+ AudioClip audioClip = AudioClip.Create(
+ "WavClip",
+ audioData.Length,
+ channels,
+ sampleRate,
+ false
+ );
+ audioClip.SetData(audioData, 0);
+
+ return audioClip;
+ }
+
+ throw new FileNotFoundException("Stream failed to load. Check if the name of your asset was correct.");
+ }
+}
From 4e474dc5b2b8a5bad345dd2572e6893009241420 Mon Sep 17 00:00:00 2001
From: XtraCube <72575280+XtraCube@users.noreply.github.com>
Date: Tue, 3 Sep 2024 21:05:32 -0400
Subject: [PATCH 5/7] formatting
---
.../Assets/LoadableAudioResourceAsset.cs | 63 +++++++++----------
1 file changed, 29 insertions(+), 34 deletions(-)
diff --git a/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs b/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs
index 7e4decf7..25640e4f 100644
--- a/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs
+++ b/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs
@@ -3,7 +3,6 @@ using System.IO;
using System.Reflection;
using System.Text;
using Cpp2IL.Core.Extensions;
-using MiraAPI.Utilities.Assets;
using Reactor.Utilities.Extensions;
using UnityEngine;
@@ -25,42 +24,38 @@ public class LoadableAudioResourceAsset(string path) : LoadableAsset
/// Stream failed to load. Check if the name of your asset was correct.
public override AudioClip LoadAsset()
{
- var assetStream = _assembly.GetManifestResourceStream(path);
+ var assetStream = _assembly.GetManifestResourceStream(path) ??
+ throw new FileNotFoundException(
+ "Stream failed to load. Check if the name of your asset was correct.");
+ var audioBytes = assetStream.ReadFully();
- if (assetStream != null)
+ var riffHeader = Encoding.ASCII.GetString(audioBytes.SubArray(0, 4));
+ var waveHeader = Encoding.ASCII.GetString(audioBytes.SubArray(8, 4));
+
+ if (riffHeader != "RIFF" || waveHeader != "WAVE")
{
- var audioBytes = assetStream.ReadFully();
-
- string riffHeader = Encoding.ASCII.GetString(audioBytes.SubArray(0, 4));
- string waveHeader = Encoding.ASCII.GetString(audioBytes.SubArray(8, 4));
-
- if (riffHeader != "RIFF" || waveHeader != "WAVE")
- {
- throw new NotSupportedException($"Attempted to load an Audio file in non WAV format '{path}'.");
- }
-
- int channels = BitConverter.ToInt16(audioBytes, 22);
- int sampleRate = BitConverter.ToInt32(audioBytes, 24);
- int dataSize = BitConverter.ToInt32(audioBytes, 40);
-
- float[] audioData = new float[dataSize / 2];
- for (int i = 0; i < audioData.Length; i++)
- {
- audioData[i] = BitConverter.ToInt16(audioBytes, 44 + i * 2) / 32768.0f;
- }
-
- AudioClip audioClip = AudioClip.Create(
- "WavClip",
- audioData.Length,
- channels,
- sampleRate,
- false
- );
- audioClip.SetData(audioData, 0);
-
- return audioClip;
+ throw new NotSupportedException($"Attempted to load an Audio file in non WAV format '{path}'.");
}
- throw new FileNotFoundException("Stream failed to load. Check if the name of your asset was correct.");
+ int channels = BitConverter.ToInt16(audioBytes, 22);
+ var sampleRate = BitConverter.ToInt32(audioBytes, 24);
+ var dataSize = BitConverter.ToInt32(audioBytes, 40);
+
+ var audioData = new float[dataSize / 2];
+ for (var i = 0; i < audioData.Length; i++)
+ {
+ audioData[i] = BitConverter.ToInt16(audioBytes, 44 + i * 2) / 32768.0f;
+ }
+
+ var audioClip = AudioClip.Create(
+ "WavClip",
+ audioData.Length,
+ channels,
+ sampleRate,
+ false
+ );
+ audioClip.SetData(audioData, 0);
+
+ return audioClip;
}
}
From 08a4dc75f28ffca567a17553ab0e98c2c9d3bcee Mon Sep 17 00:00:00 2001
From: XtraCube <72575280+XtraCube@users.noreply.github.com>
Date: Tue, 3 Sep 2024 21:05:55 -0400
Subject: [PATCH 6/7] fix period oops
---
MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs b/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs
index 25640e4f..be32627d 100644
--- a/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs
+++ b/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs
@@ -11,7 +11,7 @@ namespace MiraAPI.Utilities.Assets;
///
/// A utility class for loading .WAV audio assets from the DLL's embedded resources.
///
-/// The path of the wave file
+/// The path of the wave file.
public class LoadableAudioResourceAsset(string path) : LoadableAsset
{
private readonly Assembly _assembly = Assembly.GetCallingAssembly();
From 24dca63df11eb9c462b601f3f81611d738b047b7 Mon Sep 17 00:00:00 2001
From: Rubyboat <52091447+Rubyboat1207@users.noreply.github.com>
Date: Tue, 3 Sep 2024 20:17:50 -0500
Subject: [PATCH 7/7] File name more descriptive
---
MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs b/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs
index be32627d..381e9bc2 100644
--- a/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs
+++ b/MiraAPI/Utilities/Assets/LoadableAudioResourceAsset.cs
@@ -48,7 +48,7 @@ public class LoadableAudioResourceAsset(string path) : LoadableAsset
}
var audioClip = AudioClip.Create(
- "WavClip",
+ path,
audioData.Length,
channels,
sampleRate,