Added LuaCall.h
This commit is contained in:
@@ -77,6 +77,9 @@ void AIntegrationGameModeBase::ResetToInitialState()
|
||||
w->release(w.Get());
|
||||
}
|
||||
|
||||
// Clear the lua call assembly buffer.
|
||||
LuaCallBuffer.clear();
|
||||
|
||||
// Reset the clocks.
|
||||
EngineSeconds = 0;
|
||||
NextRotateCube = 1.0;
|
||||
@@ -138,19 +141,26 @@ void AIntegrationGameModeBase::UpdateTangibles() {
|
||||
TangibleManager->DeleteFarawayTangibles();
|
||||
}
|
||||
|
||||
void AIntegrationGameModeBase::InvokeEngioMove(const FString &action, const FVector &xyz, double facing) {
|
||||
FTCHARToUTF8 utf8action(action);
|
||||
std::string uaction(utf8action.Get(), utf8action.Length());
|
||||
FlxStreamBuffer sb;
|
||||
sb.write_string("engio");
|
||||
sb.write_string("move");
|
||||
sb.write_simple_dynamic_tag(SimpleDynamicTag::STRING);
|
||||
sb.write_string(uaction);
|
||||
sb.write_simple_dynamic_tag(SimpleDynamicTag::VECTOR);
|
||||
sb.write_fvector(xyz);
|
||||
sb.write_simple_dynamic_tag(SimpleDynamicTag::NUMBER);
|
||||
sb.write_double(facing);
|
||||
std::string_view datapk = sb.view();
|
||||
// void AIntegrationGameModeBase::InvokeEngioMove(const FString &action, const FVector &xyz, double facing) {
|
||||
// FTCHARToUTF8 utf8action(action);
|
||||
// std::string uaction(utf8action.Get(), utf8action.Length());
|
||||
// FlxStreamBuffer sb;
|
||||
// sb.write_string("engio");
|
||||
// sb.write_string("move");
|
||||
// sb.write_simple_dynamic_tag(SimpleDynamicTag::STRING);
|
||||
// sb.write_string(uaction);
|
||||
// sb.write_simple_dynamic_tag(SimpleDynamicTag::VECTOR);
|
||||
// sb.write_fvector(xyz);
|
||||
// sb.write_simple_dynamic_tag(SimpleDynamicTag::NUMBER);
|
||||
// sb.write_double(facing);
|
||||
// std::string_view datapk = sb.view();
|
||||
// FlxLockedWrapper w(LockableWrapper);
|
||||
// int64 player = w.GetActor();
|
||||
// w->play_invoke_lua_call(w.Get(), player, datapk.size(), datapk.data());
|
||||
// }
|
||||
|
||||
void AIntegrationGameModeBase::LuaCallInvoke(bool background) {
|
||||
std::string_view datapk = LuaCallBuffer.view();
|
||||
FlxLockedWrapper w(LockableWrapper);
|
||||
int64 player = w.GetActor();
|
||||
w->play_invoke_lua_call(w.Get(), player, datapk.size(), datapk.data());
|
||||
@@ -302,3 +312,48 @@ void AIntegrationGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
int64 AIntegrationGameModeBase::GetPlayerId() {
|
||||
return PlayerId;
|
||||
}
|
||||
|
||||
AIntegrationGameModeBase *AIntegrationGameModeBase::GetFromWorld(UWorld *world) {
|
||||
AIntegrationGameModeBase *result = world->GetAuthGameMode<AIntegrationGameModeBase>();
|
||||
if (result == nullptr) {
|
||||
UE_LOG(LogBlueprint, Fatal, TEXT("No IntegrationGameModeBase in this context"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
AIntegrationGameModeBase *AIntegrationGameModeBase::GetFromContext(UObject *context) {
|
||||
return GetFromWorld(context->GetWorld());
|
||||
}
|
||||
|
||||
// /** Gets the game mode that owns this component, this will always return null on the client */
|
||||
// template <class T>
|
||||
// T* GetGameMode() const
|
||||
// {
|
||||
// // Note: Intentionally getting the game mode from the world instead of the game state as it can be null during game state initialization
|
||||
// static_assert(TPointerIsConvertibleFromTo<T, AGameModeBase>::Value, "'T' template parameter to GetGameMode must be derived from AGameModeBase");
|
||||
// const UWorld* World = GetWorld();
|
||||
// return World ? World->GetAuthGameMode<T>() : nullptr;
|
||||
// }
|
||||
|
||||
|
||||
// // in GameplayStatics
|
||||
// /** Returns the current GameModeBase or Null if it can't be retrieved, such as on the client */
|
||||
// UFUNCTION(BlueprintPure, Category="Game", meta=(WorldContext="WorldContextObject"))
|
||||
// static ENGINE_API class AGameModeBase* GetGameMode(const UObject* WorldContextObject);
|
||||
|
||||
// // Give the URL a chance to override it
|
||||
// if (AGameModeBase* GameModeBase = GetGameMode<AGameModeBase>())
|
||||
// {
|
||||
// EffectiveBotCount = UGameplayStatics::GetIntOption(GameModeBase->OptionsString, TEXT("NumBots"), EffectiveBotCount);
|
||||
// }
|
||||
|
||||
// // In UWorld
|
||||
// /**
|
||||
// * Returns the current Game Mode instance cast to the template type.
|
||||
// * This can only return a valid pointer on the server and may be null if the cast fails. Will always return null on a client.
|
||||
// */
|
||||
// template< class T >
|
||||
// T* GetAuthGameMode() const
|
||||
// {
|
||||
// return Cast<T>(AuthorityGameMode);
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user