mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 19:42:39 +08:00
5410a48a58
Co-authored-by: bofeng.song <bofeng.song@chukong-inc.com> Co-authored-by: dumganhar <dumganhar@gmail.com> Co-authored-by: mmyduckx <308303735@qq.com> Co-authored-by: Patrice Jiang <397136899@qq.com> Co-authored-by: 江战 <40414978+PatriceJiang@users.noreply.github.com>
22 lines
650 B
C++
22 lines
650 B
C++
#include "core/utils/IDGenerator.h"
|
|
#include "base/Random.h"
|
|
|
|
namespace cc {
|
|
|
|
IDGenerator globalIdGenerator("global");
|
|
|
|
IDGenerator::IDGenerator(const std::string &category) {
|
|
// Tnit with a random id to emphasize that the returns id should not be stored in persistence data.
|
|
_id = static_cast<uint32_t>(RandomHelper::randomInt(0, 998));
|
|
_prefix = (category + nonUuidMark);
|
|
}
|
|
|
|
std::string IDGenerator::getNewId() {
|
|
//cjh TODO: if (EDITOR && (this.prefix === 'Node.' || this.prefix === 'Comp.')) {
|
|
// return EditorExtends.UuidUtils.uuid();
|
|
// }
|
|
return _prefix + std::to_string(++_id);
|
|
}
|
|
|
|
} // namespace cc
|