Start the process of standardizing the formatting of documentation inside our header files.
This commit is contained in:
@@ -8,17 +8,17 @@
|
||||
|
||||
#include "AnimQueue.generated.h"
|
||||
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// An single animation step.
|
||||
//
|
||||
// This struct contains an entire animation step. The
|
||||
// key-value pairs are stored in an encoded form, which is not
|
||||
// directly accessible to blueprints. To read these key-value
|
||||
// pairs, blueprints will need to use UnpackAnimationStep or
|
||||
// AnimationStepGetXXX.
|
||||
// FlxAnimationStep
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
// A single animation step. The key-value pairs
|
||||
// are stored in an encoded form, which is not
|
||||
// directly accessible to blueprints. To read
|
||||
// them, use UnpackAnimationStep or the
|
||||
// AnimationStepGetXXX functions.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct INTEGRATION_API FlxAnimationStep {
|
||||
@@ -28,14 +28,16 @@ public:
|
||||
UPROPERTY()
|
||||
bool Finished;
|
||||
|
||||
// The hash of the animation step, a 63-bit unique identifier.
|
||||
// The hash of the animation step, a 63-bit
|
||||
// unique identifier.
|
||||
//
|
||||
UPROPERTY()
|
||||
int64 Hash;
|
||||
|
||||
// The Body contains all the key-value pairs in an encoded form. To
|
||||
// obtain these in a useful form, you will need to use
|
||||
// UnpackAnimationStep or AnimationStepGetXXX.
|
||||
// The Body contains all the key-value pairs
|
||||
// in an encoded form. To obtain these in a
|
||||
// useful form, use UnpackAnimationStep or the
|
||||
// AnimationStepGetXXX functions.
|
||||
//
|
||||
UPROPERTY()
|
||||
TArray<uint8> Body;
|
||||
@@ -48,25 +50,26 @@ public:
|
||||
|
||||
// Auto-Execute
|
||||
//
|
||||
// These functions automatically update certain actor
|
||||
// properties:
|
||||
// These functions automatically update certain
|
||||
// actor properties:
|
||||
//
|
||||
// AutoUpdateXYZ - uses 'xyz' keyword
|
||||
// AutoUpdateFacing - uses 'facing' keyword
|
||||
// AutoUpdatePlane - uses 'plane' keyword
|
||||
//
|
||||
// AutoUpdateXYZ(AActor *actor); // uses 'xyz' keyword
|
||||
// AutoUpdateFacing(AActor *actor); // uses 'facing' keyword.
|
||||
// AutoUpdatePlane(FName *plane); // uses 'plane' keyword
|
||||
//
|
||||
void AutoUpdateXYZ(AActor *actor) const;
|
||||
void AutoUpdateFacing(AActor *actor) const;
|
||||
void AutoUpdatePlane(FName *plane) const;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This UClass is never instantiated. It exists to
|
||||
// expose certain static functions to the blueprint
|
||||
// library.
|
||||
// UlxAnimationStepLibrary
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
// Blueprint function library for reading and
|
||||
// applying animation steps.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
UCLASS()
|
||||
class INTEGRATION_API UlxAnimationStepLibrary : public UBlueprintFunctionLibrary
|
||||
@@ -77,26 +80,23 @@ public:
|
||||
UFUNCTION(BlueprintPure, Category = "Luprex|Animation Step")
|
||||
static FString AnimationStepDebugString(const FlxAnimationStep& step);
|
||||
|
||||
// Stores the key-value pairs in properties of the target object.
|
||||
// Stores the key-value pairs in properties of the
|
||||
// target object.
|
||||
//
|
||||
// The animation step contains key-value pairs. The goal of this function
|
||||
// is to store these in properties of the target. The prefix parameter
|
||||
// is prepended to the property names.
|
||||
// The prefix parameter is prepended to the property
|
||||
// names. For example, if the pairs are "color=blue,
|
||||
// speed=20" and the prefix is "aq", then "aq Color" is
|
||||
// set to "blue" and "aq Speed" is set to 20. A
|
||||
// property "aq Animation Step" is also written,
|
||||
// containing the entire animation step.
|
||||
//
|
||||
// For example, suppose the key-value pairs are "color=blue, speed=20",
|
||||
// and suppose the prefix is "aq". In that case, two properties would
|
||||
// be written: "aq Color" would be set to "blue", and "aq Speed" would be
|
||||
// set to 20. In addition, a property "aq Animation Step" would
|
||||
// be written, containing the entire animation step.
|
||||
// If a key has no corresponding property, it is
|
||||
// silently ignored. If a property has no corresponding
|
||||
// key, it is cleared.
|
||||
//
|
||||
// If the step contains a key-value pair, but there is no corresponding
|
||||
// property in the target, then the key-value pair is silently
|
||||
// ignored. If the target contains properties that begin with the prefix,
|
||||
// but which don't have any corresponding key-value pair, those properties
|
||||
// are cleared.
|
||||
//
|
||||
// Returns 'Changed' if the hash-value of the "aq Animation Step" property
|
||||
// has changed. Returns 'Action' string from the action=xxx property.
|
||||
// Returns bChanged=true if the hash of the "aq
|
||||
// Animation Step" property has changed. Returns the
|
||||
// Action string from action=xxx.
|
||||
//
|
||||
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = "Luprex|Animation Step")
|
||||
static void UnpackAnimationStep(bool &bChanged, FString &Action, const FlxAnimationStep& step, UObject* target, const FString& VariableNamePrefix = TEXT("aq"));
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "Luprex|Animation Step")
|
||||
static bool AnimationStepIsIdle(const FlxAnimationStep &step);
|
||||
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "Luprex|Animation Step")
|
||||
static FVector AnimationStepGetVector(const FlxAnimationStep& step, const FString& name);
|
||||
|
||||
@@ -125,27 +125,34 @@ public:
|
||||
UFUNCTION(BlueprintPure, meta = (BlueprintAutocast), Category = "Luprex|Animation Step")
|
||||
static int64 AnimationStepID(const FlxAnimationStep& step) { return step.Hash; }
|
||||
|
||||
// Scan an animation step for key-value pairs of the form mat_XXXX={x,y,z}.
|
||||
// For each match, create a dynamic material instance on the actor's mesh
|
||||
// components and set the vector parameter XXXX. Materials are restored to
|
||||
// their base (non-dynamic) state before applying, so parameters from
|
||||
// previous calls do not persist.
|
||||
// Scan an animation step for key-value pairs of the
|
||||
// form mat_XXXX={x,y,z}. For each match, create a
|
||||
// dynamic material instance on the actor's mesh
|
||||
// components and set the vector parameter XXXX.
|
||||
// Materials are restored to their base (non-dynamic)
|
||||
// state before applying, so parameters from previous
|
||||
// calls do not persist.
|
||||
//
|
||||
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "actor"), Category = "Luprex|Animation Step")
|
||||
static void AnimationStepApplyMaterials(const FlxAnimationStep& step, AActor* actor);
|
||||
|
||||
// Look for a mesh=name key-value pair in the animation step.
|
||||
// If found, load the named mesh and apply it to the actor's
|
||||
// mesh component. The actor must have exactly one mesh component.
|
||||
// Look for a mesh=name key-value pair. If found, load
|
||||
// the named mesh and apply it to the actor's mesh
|
||||
// component. The actor must have exactly one mesh
|
||||
// component.
|
||||
//
|
||||
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "actor"), Category = "Luprex|Animation Step")
|
||||
static void AnimationStepApplyMesh(const FlxAnimationStep& step, bool FallbackToBP, AActor* actor);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
// FlxAnimationStepView
|
||||
//
|
||||
// A lightweight, non-owning view of an animation
|
||||
// step (hash + body as a string_view).
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
struct FlxAnimationStepView {
|
||||
int64 Hash;
|
||||
@@ -155,19 +162,17 @@ struct FlxAnimationStepView {
|
||||
FlxAnimationStepView(int64 h, std::string_view b) : Hash(h), Body(b) {}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// A single animation field.
|
||||
//
|
||||
// A field consists of a variable name,
|
||||
// a persistent flag, a type, and some fields
|
||||
// to hold the values.
|
||||
// FlxAnimationField
|
||||
//
|
||||
// If the value is boolean, it is stored in
|
||||
// X, as either 1 or 0. If the value is double,
|
||||
// it is stored in X.
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
// A single field from an animation step: a variable name, a
|
||||
// persistent flag, a type, and value storage.
|
||||
//
|
||||
// Boolean values are stored in X as 1 or 0. Double values
|
||||
// are stored in X.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
struct FlxAnimationField {
|
||||
std::string_view Name;
|
||||
@@ -177,48 +182,47 @@ struct FlxAnimationField {
|
||||
std::string_view S;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// An Animation Queue Decoder.
|
||||
// FlxAnimQueueDecoder
|
||||
//
|
||||
// This acts a lot like a stream reader,
|
||||
// it reads one AnimEntry at a time from
|
||||
// the animation queue until you reach
|
||||
// 'end-of-file'.
|
||||
// Stream reader for animation queues. Reads one
|
||||
// FlxAnimationStepView at a time until EOF.
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
class FlxAnimQueueDecoder {
|
||||
private:
|
||||
FlxStreamBuffer Decoder;
|
||||
|
||||
// These values are immediately read from the header.
|
||||
|
||||
// Read from the header immediately on
|
||||
// construction.
|
||||
//
|
||||
int SizeLimit;
|
||||
int ActualSize;
|
||||
|
||||
public:
|
||||
// Initialize the FlxAnimQueueDecoder with the encoded animation queue.
|
||||
// Initialize with an encoded animation queue.
|
||||
//
|
||||
FlxAnimQueueDecoder(std::string_view s);
|
||||
|
||||
|
||||
// Get the size limit of the animation queue.
|
||||
//
|
||||
//
|
||||
int GetSizeLimit() const { return SizeLimit; }
|
||||
|
||||
// Get the Actual Size of the animation queue.
|
||||
// Get the actual size of the animation queue.
|
||||
//
|
||||
int GetActualSize() const { return ActualSize; }
|
||||
|
||||
// Return true if the parser has reached the end of the string.
|
||||
// Return true if the parser has reached EOF.
|
||||
//
|
||||
bool AtEOF() { return Decoder.empty(); }
|
||||
|
||||
// Read one animation step.
|
||||
//
|
||||
//
|
||||
FlxAnimationStepView ReadStep();
|
||||
|
||||
// Peek at the hash of the next animation step.
|
||||
// Peek at the hash of the next step.
|
||||
//
|
||||
int64 PeekHash();
|
||||
|
||||
@@ -227,115 +231,101 @@ public:
|
||||
// static FString DebugString(std::string_view s);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// An Animation Step Decoder.
|
||||
// FlxAnimationStepDecoder
|
||||
//
|
||||
// This acts a lot like a stream reader,
|
||||
// it reads one FlxAnimationField at a time from
|
||||
// the animation queue until you reach
|
||||
// 'end-of-file'.
|
||||
// Stream reader for a single animation step. Reads one
|
||||
// FlxAnimationField at a time until EOF.
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
class FlxAnimationStepDecoder {
|
||||
private:
|
||||
FlxStreamBuffer Decoder;
|
||||
|
||||
public:
|
||||
// Initialize the FlxAnimationStepDecoder from the FlxAnimationStepView.
|
||||
//
|
||||
// Initialize from an encoded step body.
|
||||
//
|
||||
FlxAnimationStepDecoder(std::string_view body) : Decoder(body) {}
|
||||
|
||||
// Return true if the parser has reached the end of the string.
|
||||
// Return true if the parser has reached EOF.
|
||||
//
|
||||
bool AtEOF() { return Decoder.empty(); }
|
||||
|
||||
// Read one field.
|
||||
//
|
||||
//
|
||||
FlxAnimationField ReadField();
|
||||
|
||||
// Convert an AnimStep to an FString.
|
||||
// Convert an animation step to a debug string.
|
||||
//
|
||||
static FString DebugString(bool finished, int64 hash, std::string_view body);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FlxAnimTracker
|
||||
//
|
||||
// This class monitors the animation queue for a single
|
||||
// tangible. It can identify when a new animation has
|
||||
// appeared on the animation queue, and when animations have
|
||||
// been removed from the animation queue. It also
|
||||
// keeps track of which animations have been started.
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
// Monitors the animation queue for a single tangible.
|
||||
// Identifies when animations appear or are removed, and
|
||||
// tracks which ones have been marked as finished.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
class FlxAnimTracker {
|
||||
public:
|
||||
// Our own copy of the animation queue. We only
|
||||
// store the hashes, not the steps. The First element
|
||||
// of the queue is the oldest item.
|
||||
// Our copy of the animation queue. The first element
|
||||
// is the oldest item.
|
||||
//
|
||||
TArray<FlxAnimationStep> AQ;
|
||||
|
||||
// True if something has recently changed.
|
||||
//
|
||||
bool Changed;
|
||||
|
||||
|
||||
public:
|
||||
// Construct a tracker.
|
||||
//
|
||||
// Initially, the tracker is in the empty (Clear) state.
|
||||
// Construct a tracker in the empty (Clear) state.
|
||||
//
|
||||
FlxAnimTracker();
|
||||
|
||||
// Clear everything, reset to the initial state.
|
||||
// Clear everything, reset to initial state.
|
||||
//
|
||||
void Clear();
|
||||
|
||||
// Update from the specified animation queue.
|
||||
//
|
||||
// After the update is done, AQ will be a copy
|
||||
// of the animation queue that is passed in.
|
||||
// Update from the specified animation queue. After the
|
||||
// update, AQ will be a copy of the queue that was
|
||||
// passed in.
|
||||
//
|
||||
void Update(std::string_view encqueue);
|
||||
|
||||
// Get the current blueprint name, as a string.
|
||||
// Get the current blueprint name.
|
||||
//
|
||||
FString GetCurrentBlueprintName();
|
||||
|
||||
// Get the current animation step.
|
||||
// Get the current animation step. This is the step
|
||||
// that the blueprint should currently be playing.
|
||||
//
|
||||
// Get the current animation step. This is the step that the
|
||||
// blueprint should currently be playing.
|
||||
//
|
||||
FlxAnimationStep GetCurrentAnimation();
|
||||
|
||||
// Declare that an animation is finished.
|
||||
// Declare that an animation is finished. The blueprint
|
||||
// calls this to indicate that it is done playing the
|
||||
// specified animation. This causes GetCurrentAnimation
|
||||
// to advance to the next step.
|
||||
//
|
||||
// The blueprint uses this function call to indicate that it
|
||||
// is done playing the specified animation. This will cause the
|
||||
// animation to be marked as finished, which in turn causes
|
||||
// 'GetCurrentStep' to advance to the next animation.
|
||||
//
|
||||
void FinishedAnimation(int64 Hash);
|
||||
|
||||
// Return true if an animation step is marked finished.
|
||||
//
|
||||
// Also return true if the animation step is not found.
|
||||
// Also returns true if the step is not found.
|
||||
//
|
||||
bool IsFinished(int64 Hash);
|
||||
|
||||
// Skip to the end of the animation queue.
|
||||
//
|
||||
// This is equivalent to calling 'FinishedHash' on every
|
||||
// animation in the entire queue.
|
||||
|
||||
// Skip to the end of the animation queue. Equivalent to
|
||||
// calling FinishedAnimation on every animation in the
|
||||
// queue.
|
||||
//
|
||||
void SkipToEnd();
|
||||
|
||||
// Get all the hashes of all the animation steps.
|
||||
// Get the hashes of all animation steps.
|
||||
//
|
||||
TArray<int64> GetHashes();
|
||||
|
||||
@@ -347,24 +337,25 @@ public:
|
||||
//
|
||||
const FlxAnimationStep *LastFinished() const;
|
||||
|
||||
// Return the first animation with the specified hash.
|
||||
// Return the first animation with the
|
||||
// specified hash.
|
||||
//
|
||||
const FlxAnimationStep *FindAnimation(int64 hash) const;
|
||||
|
||||
// Clear the 'Changed' flag.
|
||||
// Clear the Changed flag.
|
||||
//
|
||||
void ClearChanged() { Changed = false; }
|
||||
|
||||
// Get the 'Changed' flag.
|
||||
// Get the Changed flag.
|
||||
//
|
||||
// The changed flag is set to true whenever the Luprex animation
|
||||
// queue changes from its previous state. The changed flag is also
|
||||
// set to true whenever 'SetFinished' marks an animation as finished.
|
||||
// The changed flag can only be set to false by 'ClearChanged,' above.
|
||||
// Set to true whenever the animation queue changes, or
|
||||
// when FinishedAnimation marks a step. Only cleared by
|
||||
// ClearChanged.
|
||||
//
|
||||
bool IsChanged() const { return Changed; }
|
||||
|
||||
// Return a debug string for the entire animation tracker.
|
||||
// Return a debug string for the entire animation
|
||||
// tracker.
|
||||
//
|
||||
FString DebugString() const;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user