-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |