// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "CookingData.h" #include "Engine/Scripting/ScriptingType.h" /// /// Game building service. Processes project files and outputs build game for a target platform. /// API_CLASS(Static, Namespace="FlaxEditor") class FLAXENGINE_API GameCooker { DECLARE_SCRIPTING_TYPE_NO_SPAWN(GameCooker); friend CookingData; public: /// /// Single build step. /// class FLAXENGINE_API BuildStep { public: /// /// Finalizes an instance of the class. /// virtual ~BuildStep() = default; /// /// Called when building starts. /// /// The data. virtual void OnBuildStarted(CookingData& data) { } /// /// Performs this step. /// /// The data. /// True if failed, otherwise false. virtual bool Perform(CookingData& data) = 0; /// /// Called when building ends. /// /// The cooking data. /// True if build failed, otherwise false. virtual void OnBuildEnded(CookingData& data, bool failed) { } }; public: /// /// Gets the current build data. Valid only during active build process. /// API_PROPERTY() static CookingData* GetCurrentData(); /// /// Determines whether game building is running. /// API_PROPERTY() static bool IsRunning(); /// /// Determines whether building cancel has been requested. /// API_PROPERTY() static bool IsCancelRequested(); /// /// Gets the tools for the given platform. /// /// The platform. /// The platform tools implementation or null if not supported. static PlatformTools* GetTools(BuildPlatform platform); /// /// Starts building game for the specified platform. /// /// The target platform. /// The build configuration. /// The output path (output directory). /// The build options. /// The list of custom defines passed to the build tool when compiling project scripts. Can be used in build scripts for configuration (Configuration.CustomDefines). /// The name of build preset used for cooking (can be used by editor and game plugins). /// The name of build preset target used for cooking (can be used by editor and game plugins). API_FUNCTION() static void Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options, const Array& customDefines, const StringView& preset = StringView::Empty, const StringView& presetTarget = StringView::Empty); /// /// Sends a cancel event to the game building service. /// /// If set to true wait for the stopped building end. API_FUNCTION() static void Cancel(bool waitForEnd = false); /// /// Gets the current Editor build info (platform, configuration, etc). /// API_FUNCTION() static void GetCurrentPlatform(API_PARAM(Out) PlatformType& platform, API_PARAM(Out) BuildPlatform& buildPlatform, API_PARAM(Out) BuildConfiguration& buildConfiguration); /// /// Building event type. /// enum class EventType { /// /// The build started. /// BuildStarted = 0, /// /// The build failed. /// BuildFailed = 1, /// /// The build done. /// BuildDone = 2, }; /// /// Occurs when building event rises. /// static Delegate OnEvent; /// /// Occurs when building game progress fires. /// static Delegate OnProgress; /// /// Occurs when game files and data is deployed. /// API_EVENT() static Action DeployFiles; /// /// Occurs when game files and data are deployed and can be post-processed. /// API_EVENT() static Action PostProcessFiles; /// /// Occurs when game files and data are ready to be packaged. Called only if game is about to packaged, otherwise this step is skipped. /// API_EVENT() static Action PackageFiles; /// /// Occurs when building collects assets to cook. /// static Delegate&> OnCollectAssets; };