TextFieldReader now loops through parents if the entity field was empty and the current entity didn't have a component of that type.
This commit is contained in:
@@ -7,17 +7,21 @@ void TextFieldReader::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the entity to read from
|
// Find the entity to read from
|
||||||
const std::string& parentEntityName = cAmmunitionHUD["ParentEntityName"];
|
const std::string& entityName = cAmmunitionHUD["ParentEntityName"];
|
||||||
|
const std::string& componentType = cAmmunitionHUD["ComponentType"];
|
||||||
EntityWrapper readEntity = entity;
|
EntityWrapper readEntity = entity;
|
||||||
if (!parentEntityName.empty()) {
|
if (entityName.empty()) {
|
||||||
readEntity = entity.FirstParentByName(parentEntityName);
|
if (!readEntity.HasComponent(componentType)) {
|
||||||
if (!readEntity.Valid()) {
|
readEntity = readEntity.FirstParentWithComponent(componentType);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
readEntity = entity.FirstParentByName(entityName);
|
||||||
|
}
|
||||||
|
if (!readEntity.Valid()) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the component to read from
|
// Find the component to read from
|
||||||
const std::string& componentType = cAmmunitionHUD["ComponentType"];
|
|
||||||
if (componentType.empty() || !readEntity.HasComponent(componentType)) {
|
if (componentType.empty() || !readEntity.HasComponent(componentType)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user