// Copyright (c) 2012-2021 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. /// static const CookingData& GetCurrentData(); /// /// Determines whether game building is running. /// /// true if game building is running; otherwise, false. API_PROPERTY() static bool IsRunning(); /// /// Determines whether building cancel has been requested. /// /// true if building cancel has been requested; otherwise, false. 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. API_FUNCTION() static void Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options); /// /// 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); /// /// 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; };