Fix map errors from GetTemplate not being available in the sim
Follows ea72437739
. Fixes it by providing a convenience function in the
component Manager that matches the API in the GUI / AI
Refs #6444
Differential Revision: https://code.wildfiregames.com/D4630
This was SVN commit r26867.
This commit is contained in:
parent
69c76acabb
commit
ee0fcf2b95
@ -86,6 +86,8 @@ CComponentManager::CComponentManager(CSimContext& context, std::shared_ptr<Scrip
|
||||
ScriptFunction::Register<&CComponentManager::QueryInterface, Getter>(rq, "QueryInterface");
|
||||
ScriptFunction::Register<&CComponentManager::DestroyComponentsSoon, Getter>(rq, "DestroyEntity");
|
||||
ScriptFunction::Register<&CComponentManager::FlushDestroyedComponents, Getter>(rq, "FlushDestroyedEntities");
|
||||
ScriptFunction::Register<&CComponentManager::Script_GetTemplate, Getter>(rq, "GetTemplate");
|
||||
|
||||
}
|
||||
|
||||
// Globalscripts may use VFS script functions
|
||||
@ -382,6 +384,23 @@ void CComponentManager::Script_RegisterGlobal(const std::string& name, JS::Handl
|
||||
m_ScriptInterface.SetGlobal(name.c_str(), value, m_CurrentlyHotloading);
|
||||
}
|
||||
|
||||
const CParamNode& CComponentManager::Script_GetTemplate(const std::string& templateName)
|
||||
{
|
||||
static CParamNode nullNode(false);
|
||||
|
||||
ICmpTemplateManager* cmpTemplateManager = static_cast<ICmpTemplateManager*> (QueryInterface(SYSTEM_ENTITY, IID_TemplateManager));
|
||||
if (!cmpTemplateManager)
|
||||
{
|
||||
LOGERROR("Template manager is not loaded");
|
||||
return nullNode;
|
||||
}
|
||||
|
||||
const CParamNode* tmpl = cmpTemplateManager->GetTemplate(templateName);
|
||||
if (!tmpl)
|
||||
return nullNode;
|
||||
return *tmpl;
|
||||
}
|
||||
|
||||
std::vector<int> CComponentManager::Script_GetEntitiesWithInterface(int iid)
|
||||
{
|
||||
std::vector<int> ret;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
/* Copyright (C) 2022 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -286,6 +286,7 @@ private:
|
||||
void Script_BroadcastMessage(int mtid, JS::HandleValue data);
|
||||
int Script_AddEntity(const std::wstring& templateName);
|
||||
int Script_AddLocalEntity(const std::wstring& templateName);
|
||||
const CParamNode& Script_GetTemplate(const std::string& templateName);
|
||||
|
||||
CMessage* ConstructMessage(int mtid, JS::HandleValue data);
|
||||
void SendGlobalMessage(entity_id_t ent, const CMessage& msg);
|
||||
|
Loading…
Reference in New Issue
Block a user