Reduce coupling in the unreal side
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
#include "AnimQueue.h"
|
||||
#include "Common.h"
|
||||
#include "StreamBuffer.h"
|
||||
#include "UtilityLibrary.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "Components/MeshComponent.h"
|
||||
@@ -10,6 +11,127 @@
|
||||
#include "Materials/MaterialInstanceDynamic.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// An animation step that doesn't actually store the step,
|
||||
// it just contains a pointer to the string.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
struct FlxAnimationStepView {
|
||||
int64 Hash;
|
||||
std::string_view Body;
|
||||
|
||||
FlxAnimationStepView() : Hash(0), Body("") {}
|
||||
FlxAnimationStepView(int64 h, std::string_view b) : Hash(h), Body(b) {}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FlxAnimationField
|
||||
//
|
||||
// A single field from an animation step: a variable name, a
|
||||
// persistent flag, a type, and value storage.
|
||||
//
|
||||
// IMPORTANT: Stores a string_view, not a string, so the lifetime
|
||||
// of this field is only as long as the step you're parsing.
|
||||
//
|
||||
// Boolean values are stored in X as 1 or 0. Double values
|
||||
// are stored in X.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
struct FlxAnimationField {
|
||||
std::string_view Name;
|
||||
bool Persistent;
|
||||
LuaValueType Type;
|
||||
double X, Y, Z;
|
||||
std::string_view S;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FlxAnimationStepDecoder
|
||||
//
|
||||
// Stream reader for a single animation step. Reads one
|
||||
// FlxAnimationField at a time until EOF.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
class FlxAnimationStepDecoder {
|
||||
private:
|
||||
FlxStreamBuffer Decoder;
|
||||
|
||||
public:
|
||||
// Initialize from an encoded step body.
|
||||
//
|
||||
FlxAnimationStepDecoder(std::string_view body) : Decoder(body) {}
|
||||
|
||||
// Return true if the parser has reached EOF.
|
||||
//
|
||||
bool AtEOF() { return Decoder.empty(); }
|
||||
|
||||
// Read one field.
|
||||
//
|
||||
FlxAnimationField ReadField();
|
||||
|
||||
// Convert an animation step to a debug string.
|
||||
//
|
||||
static FString DebugString(bool finished, int64 hash, std::string_view body);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FlxAnimQueueDecoder
|
||||
//
|
||||
// Stream reader for animation queues. Reads one
|
||||
// FlxAnimationStepView at a time until EOF.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
class FlxAnimQueueDecoder {
|
||||
private:
|
||||
FlxStreamBuffer Decoder;
|
||||
|
||||
// Read from the header immediately on
|
||||
// construction.
|
||||
//
|
||||
int SizeLimit;
|
||||
int ActualSize;
|
||||
|
||||
public:
|
||||
// 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.
|
||||
//
|
||||
int GetActualSize() const { return ActualSize; }
|
||||
|
||||
// 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 step.
|
||||
//
|
||||
int64 PeekHash();
|
||||
|
||||
// Convert an AnimQueue to an FString.
|
||||
//
|
||||
// static FString DebugString(std::string_view s);
|
||||
};
|
||||
|
||||
FlxAnimationStep::FlxAnimationStep(int64 hash, std::string_view body) {
|
||||
Finished = false;
|
||||
Hash = hash;
|
||||
|
||||
Reference in New Issue
Block a user