Yeet safe_cast

This commit is contained in:
kynex7510 2024-06-06 12:31:22 +02:00
parent 7b2051d0b6
commit 4ac52b11d2
No known key found for this signature in database
GPG key ID: 8BBB0FD2C57920AD
2 changed files with 1 additions and 11 deletions

View file

@ -62,14 +62,4 @@ namespace geode::cast {
}
return nullptr;
}
/**
* Cast based on RTTI. This behaves as a replacement
* of dynamic_cast for cocos and gd classes,
* and must be used for expected results.
*/
template <class T, class F>
static T safe_cast(F const obj) {
return typeinfo_cast<T>(obj);
}
}

View file

@ -743,7 +743,7 @@ namespace geode::cocos {
*/
template <class Type = cocos2d::CCNode>
Type* findFirstChildRecursive(cocos2d::CCNode* node, utils::MiniFunction<bool(Type*)> predicate) {
if (cast::safe_cast<Type*>(node) && predicate(static_cast<Type*>(node)))
if (cast::typeinfo_cast<Type*>(node) && predicate(static_cast<Type*>(node)))
return static_cast<Type*>(node);
auto children = node->getChildren();