36 template<
typename T, u
int64_t UID>
43 operator bool() {
return _v != 0; }
52 template<
typename T, u
int64_t UID>
82 _nameDebug =
typeid(
T).name();
93 if (std::type_index(
typeid(
T)) == _id)
122 return "Debug版本才有此字段!";
130 std::string _nameDebug;
159 for (
auto& iter : _vec)
161 if (iter._id == std::type_index(
typeid(
T)))
163 ret.push_back((
T*)iter._p);
176 for (
auto& iter : _vec)
178 if (iter._id == std::type_index(
typeid(
T)))
181 return (
T*)(iter._p);
197 std::vector<AnyType>::iterator
begin() {
return _vec.begin(); }
199 std::vector<AnyType>::iterator
end() {
return _vec.end(); }
204 std::vector<AnyType> _vec;
212 template <
typename T>
216 _nameDebug = _any.GetNameDebug();
227 template <
typename T>
233 template <
typename T>
234 T*
Get(
size_t index = 0) {
return _vec.Get<
T>(index); }
272 return _any.IsNull();
279 std::string _nameDebug;
285 Components* ret =
new Components((
int*)
nullptr);
296 std::vector<T*>
GetComp(std::vector<Components*>& vec)
301 VectorAny& vec_any = cpt->GetVectorAny();
302 std::vector<T*> mul = vec_any.
GetMulti<
T>();
303 ret.insert(ret.end(), mul.begin(), mul.end());
316 T* p = cpt->GetSelf().Cast<
T>();
326 T*
GetN(std::vector<Components*>& vec,
size_t n)
330 T* p = cpt->GetSelf().Cast<
T>();
357 std::array<std::string, 2>
_str;
358 std::function<void(std::string_view, std::string_view)>
_func;
std::type_index GetId()
返回类型id
bool operator==(const AnyType &b)
bool operator!=(const AnyType &b)
std::string GetNameDebug()
T * Get(size_t index=0)
返回第n个类型对象,失败返回nullptr
void SetName(std::string_view name)
设置自定义名字
bool operator==(const Components &b)
bool operator!=(const Components &b)
void PushBack(AnyType any)
添加一个任意对象
VectorAny & GetVectorAny()
bool IsPure()
单纯的Componets,any为空
int GetOrderOffset()
order偏移
Position GetOffset()
位置偏移(实际coor位置)
std::function< bool()> Call
void operator=(const T &func)
std::array< std::string, 2 > _str
std::function< void(std::string_view, std::string_view)> _func
T * Get(size_t index=0)
返回第n个类型对象,失败返回nullptr
std::vector< AnyType >::iterator begin()
void PushBack(AnyType any)
添加一个任意对象
std::vector< T * > GetMulti()
返回所有指定类型的对象
std::vector< AnyType >::iterator end()
std::array< Direction, 2 > Direction2
constexpr std::array< T, N > Size2Anchor(const std::array< T, N > &size, const std::array< Direction, N > &dir)
垂直位置
Function< std::function< bool()>, str_uid("IsSelect")> IsSelect
选择
Function< std::function< void(float)>, str_uid("SetOrder")> SetOrder
设置order
Function< std::function< dl::Coor *()>, str_uid("GetCoor")> GetCoor
返回坐标系
Function< std::function< bool()>, str_uid("IsPickup")> IsPickup
---------------------------—具体组件----------------------------------—
Function< std::function< bool()>, str_uid("IsDown")> IsDown
按下状态
Function< std::function< float()>, str_uid("GetOrder")> GetOrder
返回order
Function< std::function< void(bool)>, str_uid("SetSelect")> SetSelect
设置是否选择
Function< std::function< void()>, str_uid("Render")> Render
绘制
T * GetN(std::vector< Components * > &vec, size_t n)
从vector<Components*>返回指定类型的第n个元素
Function< std::function< void()>, str_uid("DeleteThis")> DeleteThis
删除自身
Function< std::function< void()>, str_uid("Update")> Update
逻辑
Function< std::function< bool()>, str_uid("IsClick")> IsClick
点击
Function< std::function< Components *()>, str_uid("Clone")> Clone
克隆
std::vector< T * > GetComp(std::vector< Components * > &vec)
从vector<Components*>返回指定类型的所有组件
T * GetFirst(std::vector< Components * > &vec)
从vector<Components*>返回指定类型的第一个元素
consteval uint64_t str_uid(const char(&str)[N])
固定条件的字符串,生成唯一id
Components * createComponents(std::string_view name={})