// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using System;
using System.Collections.Generic;
using FlaxEngine;
namespace FlaxEditor
{
partial class GameCooker
{
///
/// Build options data.
///
public struct Options
{
///
/// The platform.
///
public BuildPlatform Platform;
///
/// The build configuration.
///
public BuildConfiguration Configuration;
///
/// The options.
///
public BuildOptions Flags;
///
/// The output path (normalized, absolute).
///
public string OutputPath;
}
///
/// Building event type.
///
public enum EventType
{
///
/// The build started.
///
BuildStarted = 0,
///
/// The build failed.
///
BuildFailed = 1,
///
/// The build done.
///
BuildDone = 2,
}
///
/// Game building event delegate.
///
/// The type.
public delegate void BuildEventDelegate(EventType type);
///
/// Game building progress reporting delegate type.
///
/// The information text.
/// The total progress percentage (normalized to 0-1).
public delegate void BuildProgressDelegate(string info, float totalProgress);
///
/// Occurs when building event rises.
///
public static event BuildEventDelegate Event;
///
/// Occurs when building game progress fires.
///
public static event BuildProgressDelegate Progress;
///
/// Occurs when building collects assets to cook.
///
public static event Action> CollectAssets;
///
/// Gets the type of the platform from the game build platform type.
///
/// The build platform.
/// The run-type platform type.
public static PlatformType GetPlatformType(BuildPlatform buildPlatform)
{
switch (buildPlatform)
{
case BuildPlatform.Windows32:
case BuildPlatform.Windows64: return PlatformType.Windows;
case BuildPlatform.UWPx86:
case BuildPlatform.UWPx64: return PlatformType.UWP;
case BuildPlatform.XboxOne: return PlatformType.XboxOne;
case BuildPlatform.LinuxX64: return PlatformType.Linux;
case BuildPlatform.PS4: return PlatformType.PS4;
case BuildPlatform.PS5: return PlatformType.PS5;
case BuildPlatform.AndroidARM64: return PlatformType.Android;
case BuildPlatform.XboxScarlett: return PlatformType.XboxScarlett;
case BuildPlatform.Switch: return PlatformType.Switch;
case BuildPlatform.MacOSARM64:
case BuildPlatform.MacOSx64: return PlatformType.Mac;
case BuildPlatform.iOSARM64: return PlatformType.iOS;
default: throw new ArgumentOutOfRangeException(nameof(buildPlatform), buildPlatform, null);
}
}
internal static void Internal_OnEvent(EventType type)
{
Event?.Invoke(type);
}
internal static void Internal_OnProgress(string info, float totalProgress)
{
Progress?.Invoke(info, totalProgress);
}
internal static Guid[] Internal_OnCollectAssets()
{
var list = new List();
// Custom assets
CollectAssets?.Invoke(list);
// Plugin assets
foreach (var plugin in PluginManager.GamePlugins)
{
var pluginRefs = plugin.GetReferences();
if (pluginRefs != null)
list.AddRange(pluginRefs);
}
if (list.Count == 0)
return null;
return list.ToArray();
}
}
}