2023-09-03 02:01:32 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
2023-09-07 03:57:29 -04:00
|
|
|
#include "lpx-enginewrapper.hpp"
|
2023-09-07 23:50:49 -04:00
|
|
|
#include "CommonTypes.h"
|
2023-09-03 02:01:32 -04:00
|
|
|
|
2023-09-15 13:28:18 -04:00
|
|
|
// Class FlxLockableWrapper
|
2023-09-03 02:01:32 -04:00
|
|
|
//
|
|
|
|
|
// Contains the EngineWrapper and a Mutex to lock it.
|
|
|
|
|
// This class has no methods. To access the EngineWrapper,
|
2023-09-15 13:28:18 -04:00
|
|
|
// construct a FlxLockedWrapper, and then dereference it
|
2023-09-03 02:01:32 -04:00
|
|
|
// using operator right arrow.
|
|
|
|
|
//
|
2023-09-15 13:28:18 -04:00
|
|
|
class FlxLockableWrapper {
|
2023-09-03 02:01:32 -04:00
|
|
|
private:
|
|
|
|
|
FCriticalSection Mutex;
|
|
|
|
|
EngineWrapper Wrapper;
|
2023-09-08 01:52:30 -04:00
|
|
|
|
|
|
|
|
// Temporary buffers. These are only used
|
|
|
|
|
// inside wrapper methods. There's nothing
|
|
|
|
|
// persistent in these.
|
|
|
|
|
//
|
|
|
|
|
TArray<uint32> AQLenBuffer;
|
|
|
|
|
TArray<const char*> AQStrBuffer;
|
|
|
|
|
|
2023-09-03 02:01:32 -04:00
|
|
|
public:
|
2023-09-15 13:28:18 -04:00
|
|
|
friend class FlxLockedWrapper;
|
2023-09-03 02:01:32 -04:00
|
|
|
};
|
|
|
|
|
|
2023-09-15 13:28:18 -04:00
|
|
|
class FlxLockedWrapper {
|
2023-09-03 02:01:32 -04:00
|
|
|
private:
|
2023-09-15 13:28:18 -04:00
|
|
|
FlxLockableWrapper& Lockable;
|
2023-09-03 02:01:32 -04:00
|
|
|
|
2023-09-07 23:50:49 -04:00
|
|
|
public:
|
2023-09-08 01:52:30 -04:00
|
|
|
// Import these types into our Namespace.
|
|
|
|
|
using IdArray = CommonTypes::IdArray;
|
|
|
|
|
using IdView = CommonTypes::IdView;
|
|
|
|
|
using StringViewVec = CommonTypes::StringViewVec;
|
2023-09-06 23:25:37 -04:00
|
|
|
|
2023-09-03 02:01:32 -04:00
|
|
|
public:
|
2023-09-15 13:28:18 -04:00
|
|
|
// The constructor of the FlxLockedWrapper claims the mutex.
|
|
|
|
|
FlxLockedWrapper(FlxLockableWrapper& w) : Lockable(w) {
|
2023-09-03 02:01:32 -04:00
|
|
|
Lockable.Mutex.Lock();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-15 13:28:18 -04:00
|
|
|
// The destructor of the FlxLockedWrapper releases the mutex.
|
|
|
|
|
~FlxLockedWrapper() {
|
2023-09-03 02:01:32 -04:00
|
|
|
Lockable.Mutex.Unlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Operator right arrow accesses the EngineWrapper.
|
|
|
|
|
EngineWrapper* operator ->() {
|
|
|
|
|
return &Lockable.Wrapper;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get a pointer to the enginewrapper. This is not
|
|
|
|
|
// very safe because you could keep the pointer after
|
|
|
|
|
// the LockedWrapper is destroyed. Don't do that.
|
|
|
|
|
EngineWrapper* Get() {
|
|
|
|
|
return &Lockable.Wrapper;
|
|
|
|
|
}
|
2023-09-05 03:20:11 -04:00
|
|
|
|
|
|
|
|
// Initialize the engine wrapper if it's not already.
|
|
|
|
|
//
|
|
|
|
|
// All this does is open the DLL and hook up all
|
|
|
|
|
// the function pointers in the wrapper to point into
|
|
|
|
|
// the DLL.
|
|
|
|
|
//
|
|
|
|
|
void InitWrapper();
|
|
|
|
|
|
|
|
|
|
// Fetch Stdout as a string.
|
|
|
|
|
//
|
|
|
|
|
FString FetchStdout();
|
2023-09-06 23:25:37 -04:00
|
|
|
|
|
|
|
|
// Get the current Actor ID.
|
|
|
|
|
//
|
|
|
|
|
int64 GetActor();
|
|
|
|
|
|
|
|
|
|
// Get the list of tangibles near the actor.
|
|
|
|
|
//
|
|
|
|
|
// This function is fast but not free. You should fetch this
|
2023-09-07 23:50:49 -04:00
|
|
|
// once per frame and then store the IdView somewhere (like
|
2023-09-06 23:25:37 -04:00
|
|
|
// in the TangibleManager, for example).
|
|
|
|
|
//
|
2023-09-07 23:50:49 -04:00
|
|
|
IdView GetNear(int64 id, double rx, double ry, double rz);
|
2023-09-08 01:52:30 -04:00
|
|
|
|
2024-09-04 21:01:20 -04:00
|
|
|
// PlayCallFunction - a thin wrapper around play_call_function.
|
|
|
|
|
//
|
|
|
|
|
std::string_view PlayCallFunction(InvocationKind kind, int64 place, std::string_view datapk);
|
|
|
|
|
|
2023-09-08 01:52:30 -04:00
|
|
|
// Get animation queues.
|
|
|
|
|
//
|
|
|
|
|
// The array returned by this is valid until the
|
|
|
|
|
// next time you call this.
|
|
|
|
|
//
|
|
|
|
|
StringViewVec GetAnimationQueues(IdView ids);
|
2023-09-03 02:01:32 -04:00
|
|
|
};
|