Add a map renderer (#3613)
Co-authored-by: github-actions <github-actions@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
4b732dda8f
commit
c30c8020e8
32
Content.MapRenderer/Extensions/DirectoryExtensions.cs
Normal file
32
Content.MapRenderer/Extensions/DirectoryExtensions.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Content.MapRenderer.Extensions
|
||||
{
|
||||
public static class DirectoryExtensions
|
||||
{
|
||||
public static DirectoryInfo RepositoryRoot()
|
||||
{
|
||||
// space-station-14/bin/Content.MapRenderer/Content.MapRenderer.dll
|
||||
var currentLocation = Assembly.GetExecutingAssembly().Location;
|
||||
|
||||
// space-station-14
|
||||
return Directory.GetParent(currentLocation)!.Parent!.Parent!;
|
||||
}
|
||||
|
||||
public static DirectoryInfo Resources()
|
||||
{
|
||||
return new DirectoryInfo($"{RepositoryRoot()}{Path.DirectorySeparatorChar}Resources");
|
||||
}
|
||||
|
||||
public static DirectoryInfo Maps()
|
||||
{
|
||||
return new DirectoryInfo($"{Resources()}{Path.DirectorySeparatorChar}Maps");
|
||||
}
|
||||
|
||||
public static DirectoryInfo MapImages()
|
||||
{
|
||||
return new DirectoryInfo($"{Resources()}{Path.DirectorySeparatorChar}MapImages");
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Content.MapRenderer/Extensions/EnvironmentExtensions.cs
Normal file
20
Content.MapRenderer/Extensions/EnvironmentExtensions.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Content.MapRenderer.Extensions
|
||||
{
|
||||
public static class EnvironmentExtensions
|
||||
{
|
||||
public static bool TryGetVariable(string key, [NotNullWhen(true)] out string? value)
|
||||
{
|
||||
return (value = Environment.GetEnvironmentVariable(key)) != null;
|
||||
}
|
||||
|
||||
public static string GetVariableOrThrow(string key)
|
||||
{
|
||||
return Environment.GetEnvironmentVariable(key) ??
|
||||
throw new ArgumentException($"No environment variable found with key {key}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user