using System;
using System.Collections.Generic;
using ModTool.Shared;
using UnityEditor;
namespace ModTool.Editor.Exporting
{
///
/// Extension methods for ModPlatform.
///
public static class EditorModPlatformExtensions
{
///
/// Does this ModPlatform include the equivalent BuildTarget?
///
/// A ModPlatform instance.
/// The BuildTarget to check.
/// True if the ModPlatform has the BuildTarget.
public static bool HasBuildTarget(this ModPlatform self, BuildTarget buildTarget)
{
switch (buildTarget)
{
case BuildTarget.StandaloneWindows:
if ((self & ModPlatform.Windows) == ModPlatform.Windows)
return true;
break;
case BuildTarget.StandaloneLinuxUniversal:
if ((self & ModPlatform.Linux) == ModPlatform.Linux)
return true;
break;
case BuildTarget.StandaloneOSX:
if ((self & ModPlatform.OSX) == ModPlatform.OSX)
return true;
break;
case BuildTarget.Android:
if ((self & ModPlatform.Android) == ModPlatform.Android)
return true;
break;
}
return false;
}
///
/// Get the ModPlatform equivalent to this BuildTarget
///
/// A BuildTarget instance.
/// The equivalent ModPlatform.
public static ModPlatform GetModPlatform(this BuildTarget self)
{
switch (self)
{
case BuildTarget.StandaloneWindows:
return ModPlatform.Windows;
case BuildTarget.StandaloneLinuxUniversal:
return ModPlatform.Linux;
case BuildTarget.StandaloneOSX:
return ModPlatform.OSX;
case BuildTarget.Android:
return ModPlatform.Android;
}
return 0;
}
///
/// Get a list of BuildTargets that are equivalent to this ModPlatform.
///
/// A ModPlatform Instance.
/// A list with equivalent BuildTargets
public static List GetBuildTargets(this ModPlatform self)
{
List runtimePlatforms = new List();
var values = Enum.GetValues(typeof(BuildTarget));
foreach (BuildTarget r in values)
{
if (self.HasBuildTarget(r))
runtimePlatforms.Add(r);
}
return runtimePlatforms;
}
}
}