// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
#include "../BinaryAsset.h"
#include "Engine/Animations/Graph/AnimGraph.h"
///
/// Animation Graph function asset that contains reusable part of the anim graph.
///
API_CLASS(NoSpawn) class FLAXENGINE_API AnimationGraphFunction : public BinaryAsset
{
DECLARE_BINARY_ASSET_HEADER(AnimationGraphFunction, 1);
public:
///
/// The loaded anim graph function graph data (serialized anim graph).
///
BytesContainer GraphData;
struct FunctionParameter
{
int32 NodeIndex;
Array> GraphIndices;
#if USE_EDITOR
String Type;
String Name;
#endif
};
///
/// The input nodes.
///
Array> Inputs;
///
/// The output nodes.
///
Array> Outputs;
///
/// Tries to load surface graph from the asset.
///
/// The output surface data, or empty if failed to load.
API_FUNCTION() BytesContainer LoadSurface() const;
#if USE_EDITOR
// Gets the function signature for Visject Surface editor.
API_FUNCTION() void GetSignature(API_PARAM(Out) Array>& types, API_PARAM(Out) Array>& names);
///
/// Updates the anim graph surface (save new one, discards cached data, reloads asset).
///
/// The surface graph data.
/// True if cannot save it, otherwise false.
API_FUNCTION() bool SaveSurface(BytesContainer& data);
#endif
private:
void ProcessGraphForSignature(AnimGraphBase* graph, bool canUseOutputs, const Array>& graphIndices);
protected:
// [BinaryAsset]
LoadResult load() override;
void unload(bool isReloading) override;
AssetChunksFlag getChunksToPreload() const override;
};