mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-11-19 13:16:56 +00:00
v
This commit is contained in:
1 parent
c743925fe0
commit
a8eeb82036
3 files changed
+57
-44
No files matched your search
+50
-38
@@ -14,32 +14,40 @@ public static class CustomSoundsManager
|
||||
|
||||
public static void RPCPlayCustomSound(this PlayerControl pc, string sound, float volume = 1f, float pitch = 1f, bool force = false)
|
||||
{
|
||||
if (!force && (!AmongUsClient.Instance.AmHost || !pc.IsModdedClient())) return;
|
||||
|
||||
if (pc == null || PlayerControl.LocalPlayer.PlayerId == pc.PlayerId)
|
||||
try
|
||||
{
|
||||
Play(sound, volume, pitch);
|
||||
return;
|
||||
}
|
||||
if (!force && (!AmongUsClient.Instance.AmHost || !pc.IsModdedClient())) return;
|
||||
|
||||
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlayCustomSound, SendOption.None, pc.OwnerId);
|
||||
writer.Write(sound);
|
||||
writer.Write(volume);
|
||||
writer.Write(pitch);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(writer);
|
||||
if (!pc || PlayerControl.LocalPlayer.PlayerId == pc.PlayerId)
|
||||
{
|
||||
Play(sound, volume, pitch);
|
||||
return;
|
||||
}
|
||||
|
||||
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlayCustomSound, SendOption.None, pc.OwnerId);
|
||||
writer.Write(sound);
|
||||
writer.Write(volume);
|
||||
writer.Write(pitch);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(writer);
|
||||
}
|
||||
catch (Exception e) { Utils.ThrowException(e); }
|
||||
}
|
||||
|
||||
public static void RPCPlayCustomSoundAll(string sound, float volume = 1f, float pitch = 1f)
|
||||
{
|
||||
if (!AmongUsClient.Instance.AmHost) return;
|
||||
try
|
||||
{
|
||||
if (!AmongUsClient.Instance.AmHost) return;
|
||||
|
||||
Play(sound, volume, pitch);
|
||||
Play(sound, volume, pitch);
|
||||
|
||||
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlayCustomSound, SendOption.None);
|
||||
writer.Write(sound);
|
||||
writer.Write(volume);
|
||||
writer.Write(pitch);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(writer);
|
||||
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlayCustomSound, SendOption.None);
|
||||
writer.Write(sound);
|
||||
writer.Write(volume);
|
||||
writer.Write(pitch);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(writer);
|
||||
}
|
||||
catch (Exception e) { Utils.ThrowException(e); }
|
||||
}
|
||||
|
||||
public static void ReceiveRPC(MessageReader reader)
|
||||
@@ -49,31 +57,35 @@ public static class CustomSoundsManager
|
||||
|
||||
public static void Play(string sound, float volume = 1f, float pitch = 1f)
|
||||
{
|
||||
if (!Constants.ShouldPlaySfx() || !Main.EnableCustomSoundEffect.Value || !OperatingSystem.IsWindows()) return;
|
||||
|
||||
string path = SoundsPath + sound + ".wav";
|
||||
if (!Directory.Exists(SoundsPath)) Directory.CreateDirectory(SoundsPath);
|
||||
|
||||
DirectoryInfo folder = new(SoundsPath);
|
||||
if ((folder.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) folder.Attributes = FileAttributes.Hidden;
|
||||
|
||||
if (!File.Exists(path))
|
||||
try
|
||||
{
|
||||
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("EHR.Resources.Sounds." + sound + ".wav");
|
||||
if (!Constants.ShouldPlaySfx() || !Main.EnableCustomSoundEffect.Value || !OperatingSystem.IsWindows()) return;
|
||||
|
||||
if (stream == null)
|
||||
string path = SoundsPath + sound + ".wav";
|
||||
if (!Directory.Exists(SoundsPath)) Directory.CreateDirectory(SoundsPath);
|
||||
|
||||
DirectoryInfo folder = new(SoundsPath);
|
||||
if ((folder.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) folder.Attributes = FileAttributes.Hidden;
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Logger.Warn($"Could not find sound: {sound}", "CustomSounds");
|
||||
return;
|
||||
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("EHR.Resources.Sounds." + sound + ".wav");
|
||||
|
||||
if (stream == null)
|
||||
{
|
||||
Logger.Warn($"Could not find sound: {sound}", "CustomSounds");
|
||||
return;
|
||||
}
|
||||
|
||||
FileStream fileStream = File.Create(path);
|
||||
stream.CopyTo(fileStream);
|
||||
fileStream.Close();
|
||||
}
|
||||
|
||||
FileStream fileStream = File.Create(path);
|
||||
stream.CopyTo(fileStream);
|
||||
fileStream.Close();
|
||||
StartPlay(path, volume, pitch);
|
||||
Logger.Msg($"Playing sound: {sound}", "CustomSounds");
|
||||
}
|
||||
|
||||
StartPlay(path, volume, pitch);
|
||||
Logger.Msg($"Playing sound: {sound}", "CustomSounds");
|
||||
catch (Exception e) { Utils.ThrowException(e); }
|
||||
}
|
||||
|
||||
private static readonly Dictionary<string, AudioClip> audioCache = [];
|
||||
@@ -86,7 +98,7 @@ public static class CustomSoundsManager
|
||||
audioCache[path] = clip;
|
||||
}
|
||||
|
||||
if (clip != null)
|
||||
if (clip)
|
||||
SoundManager.Instance.PlaySoundImmediate(clip, false, volume);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,11 +92,15 @@ public static class OnlinePresetsManager
|
||||
|
||||
Object.Destroy(row.transform.FindChild("Value_TMP (1)").gameObject);
|
||||
Object.Destroy(row.transform.FindChild("ValueBox").gameObject);
|
||||
|
||||
row.OnValueChanged = new Action<OptionBehaviour>(menu.ValueChanged);
|
||||
row.LabelBackground.transform.localScale += new Vector3(1f, 0f, 0f);
|
||||
row.TitleText.GetComponent<RectTransform>().sizeDelta = new(5.7f, 0.37f);
|
||||
|
||||
TextMeshPro plusText = row.PlusBtn.GetComponentInChildren<TextMeshPro>();
|
||||
plusText.DestroyTranslator();
|
||||
plusText.text = "ⓘ";
|
||||
row.PlusBtn.transform.localPosition += new Vector3(2.1f, 0f, 0f);
|
||||
row.PlusBtn.transform.localPosition += new Vector3(1.8f, 0f, 0f);
|
||||
row.PlusBtn.OnClick = new();
|
||||
row.PlusBtn.OnClick.AddListener((UnityAction)(() =>
|
||||
{
|
||||
@@ -105,9 +109,6 @@ public static class OnlinePresetsManager
|
||||
plusText.text = b ? "∅" : "ⓘ";
|
||||
}));
|
||||
|
||||
row.OnValueChanged = new Action<OptionBehaviour>(menu.ValueChanged);
|
||||
row.LabelBackground.transform.localScale += new Vector3(1f, 0f, 0f);
|
||||
row.TitleText.GetComponent<RectTransform>().sizeDelta = new(5.7f, 0.37f);
|
||||
row.MinusBtn.transform.localPosition += new Vector3(1.7f, 0f, 0f);
|
||||
row.MinusBtn.OnClick = new();
|
||||
row.MinusBtn.OnClick.AddListener((UnityAction)(() =>
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Duellist : RoleBase
|
||||
{
|
||||
if (!IsEnable) return false;
|
||||
|
||||
if (duellist == null || target == null) return false;
|
||||
if (!duellist || !target) return false;
|
||||
|
||||
Vector2 pos = Pelican.GetBlackRoomPS();
|
||||
|
||||
@@ -66,7 +66,7 @@ public class Duellist : RoleBase
|
||||
if (DuelPair.TryGetValue(duellist.PlayerId, out byte previousTargetId))
|
||||
{
|
||||
PlayerControl previousTarget = GetPlayerById(previousTargetId);
|
||||
if (previousTarget != null) previousTarget.TPToRandomVent();
|
||||
if (previousTarget) previousTarget.TPToRandomVent();
|
||||
}
|
||||
|
||||
duellist.TP(pos);
|
||||
|
||||
Reference in new issue
Block a user