Added new Prefab C# type
This commit is contained in:
@@ -180,6 +180,7 @@ namespace Nuake
|
||||
const std::string absoluteAssemblyPath = FileSystem::Root + assemblyPath;
|
||||
m_GameAssembly = m_LoadContext.LoadAssembly(absoluteAssemblyPath);
|
||||
|
||||
m_PrefabType = m_GameAssembly.GetType("Nuake.Net.Prefab");
|
||||
auto& exposedFieldAttributeType = m_GameAssembly.GetType("Nuake.Net.ExposedAttribute");
|
||||
|
||||
for (auto& type : m_GameAssembly.GetTypes())
|
||||
@@ -235,6 +236,10 @@ namespace Nuake
|
||||
{
|
||||
varType = ExposedVarTypes::Entity;
|
||||
}
|
||||
else if (typeName == "Nuake.Net.Prefab")
|
||||
{
|
||||
varType = ExposedVarTypes::Prefab;
|
||||
}
|
||||
|
||||
if (varType != ExposedVarTypes::Unsupported)
|
||||
{
|
||||
@@ -341,6 +346,11 @@ namespace Nuake
|
||||
int32_t handle;
|
||||
};
|
||||
|
||||
break;
|
||||
}
|
||||
case ExposedVarTypes::Prefab:
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -385,6 +395,23 @@ namespace Nuake
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (exposedVarUserValue.Type == NetScriptExposedVarType::Prefab)
|
||||
{
|
||||
if (exposedVarUserValue.Value.has_value())
|
||||
{
|
||||
std::string path = std::any_cast<std::string>(exposedVarUserValue.Value);
|
||||
if (FileSystem::FileExists(path))
|
||||
{
|
||||
// In the case where the entity doesnt have an instance, we create one
|
||||
auto newPrefab = m_PrefabType.CreateInstance(Coral::String::New(path));
|
||||
classInstance.SetFieldValue<Coral::ManagedObject>(exposedVarUserValue.Name, newPrefab);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Log("Invalid prefab exposed variable set", ".net", CRITICAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
classInstance.SetFieldValue(exposedVarUserValue.Name, exposedVarUserValue.Value);
|
||||
|
||||
Reference in New Issue
Block a user