Created
August 3, 2021 10:53
-
-
Save rdeioris/71fefe0e9942c160c7014bfff3e9a269 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TArray<FLuaValue> ULuaReflectionState::MetaMethodIndex(TArray<FLuaValue> LuaArgs) | |
{ | |
TArray<FLuaValue> ReturnValues; | |
UObject* Object = LuaArgs[0].Object; | |
FString Key = LuaArgs[1].ToString(); | |
if (!Object) | |
{ | |
return ReturnValues; | |
} | |
if (Object->IsA<UClass>()) | |
{ | |
return ReturnValues; | |
} | |
if (LuaFunctionsMap.Contains(Key)) | |
{ | |
ReturnValues.Add(LuaFunctionsMap[Key]); | |
return ReturnValues; | |
} | |
ELuaReflectionType ReflectionType = ELuaReflectionType::Unknown; | |
ULuaBlueprintFunctionLibrary::GetLuaReflectionType(Object, Key, ReflectionType); | |
if (ReflectionType == ELuaReflectionType::Property) | |
{ | |
ReturnValues.Add(GetLuaValueFromProperty(Object, Key)); | |
} | |
else if (ReflectionType == ELuaReflectionType::Function) | |
{ | |
ReturnValues.Add(FLuaValue::FunctionOfObject(Object, FName(Key))); | |
} | |
return ReturnValues; | |
} | |
TArray<FLuaValue> ULuaReflectionState::MetaMethodNewIndex(TArray<FLuaValue> LuaArgs) | |
{ | |
TArray<FLuaValue> ReturnValues; | |
UObject* Object = LuaArgs[0].Object; | |
FString Key = LuaArgs[1].ToString(); | |
FLuaValue Value = LuaArgs[2]; | |
if (!Object) | |
{ | |
return ReturnValues; | |
} | |
if (Object->IsA<UClass>()) | |
{ | |
return ReturnValues; | |
} | |
ELuaReflectionType ReflectionType = ELuaReflectionType::Unknown; | |
ULuaBlueprintFunctionLibrary::GetLuaReflectionType(Object, Key, ReflectionType); | |
if (ReflectionType == ELuaReflectionType::Property) | |
{ | |
SetPropertyFromLuaValue(Object, Key, Value); | |
} | |
return ReturnValues; | |
} | |
TArray<FLuaValue> ULuaReflectionState::MetaMethodEq(TArray<FLuaValue> LuaArgs) | |
{ | |
TArray<FLuaValue> ReturnValues; | |
UObject* Object = LuaArgs[0].Object; | |
UObject* OtherObject = LuaArgs[1].Object; | |
if (!Object || !OtherObject) | |
{ | |
ReturnValues.Add(FLuaValue(false)); | |
} | |
else | |
{ | |
ReturnValues.Add(FLuaValue(Object == OtherObject)); | |
} | |
return ReturnValues; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment