Skip to content

Commit

Permalink
Height channel check
Browse files Browse the repository at this point in the history
  • Loading branch information
VoidXH committed Dec 19, 2023
1 parent cf6a490 commit 72101f6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
23 changes: 1 addition & 22 deletions Cavern/Channels/ReferenceChannel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Text;

namespace Cavern.Channels {
namespace Cavern.Channels {
/// <summary>
/// Possible channels in channel-based legacy systems.
/// </summary>
Expand Down Expand Up @@ -41,23 +39,4 @@ public enum ReferenceChannel {
TopRearCenter
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
}

/// <summary>
/// Extension functions for reference channels.
/// </summary>
public static class ReferenceChannelExtensions {
/// <summary>
/// Get the first letters of each word in the channel's name, like TFL from Top Front Left.
/// </summary>
public static string GetShortName(this ReferenceChannel channel) {
StringBuilder result = new StringBuilder();
string source = channel.ToString();
for (int i = channel == ReferenceChannel.ScreenLFE ? 6 : 0; i < source.Length; i++) {
if ('A' <= source[i] && source[i] <= 'Z') {
result.Append(source[i]);
}
}
return result.ToString();
}
}
}
30 changes: 30 additions & 0 deletions Cavern/Channels/ReferenceChannelExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Text;

namespace Cavern.Channels {
/// <summary>
/// Extension functions for reference channels.
/// </summary>
public static class ReferenceChannelExtensions {
/// <summary>
/// Get the first letters of each word in the channel's name, like TFL from Top Front Left.
/// </summary>
public static string GetShortName(this ReferenceChannel channel) {
StringBuilder result = new StringBuilder();
string source = channel.ToString();
for (int i = channel == ReferenceChannel.ScreenLFE ? 6 : 0; i < source.Length; i++) {
if ('A' <= source[i] && source[i] <= 'Z') {
result.Append(source[i]);
}
}
return result.ToString();
}

/// <summary>
/// Is the parameter a height <paramref name="channel"/>?
/// </summary>
public static bool IsHeight(this ReferenceChannel channel) =>
(channel >= ReferenceChannel.TopFrontLeft && channel <= ReferenceChannel.TopSideRight) ||
channel == ReferenceChannel.TopFrontCenter || channel == ReferenceChannel.GodsVoice ||
(channel >= ReferenceChannel.TopRearLeft && channel <= ReferenceChannel.TopRearCenter);
}
}

0 comments on commit 72101f6

Please sign in to comment.