102 out<<YAML::Key<<
"Entity";
105 out<<YAML::Key<<
"UID"<<YAML::Value<<entity.
m_UID;
106 out<<YAML::Key<<
"X"<<YAML::Value<<entity.
m_X;
107 out<<YAML::Key<<
"Y"<<YAML::Value<<entity.
m_Y;
108 out<<YAML::Key<<
"PreviousX"<<YAML::Value<<entity.
m_PreviousX;
109 out<<YAML::Key<<
"PreviousY"<<YAML::Value<<entity.
m_PreviousY;
114 out<<YAML::Key<<
"TagComponent";
119 std::string tag=tagcomponent->
m_Tag;
120 tag.erase(std::remove(tag.begin(),tag.end(),
'\0'),tag.end());
122 out<<YAML::Key<<
"Tag"<<YAML::Value<<tag;
129 out<<YAML::Key<<
"TextureComponent";
134 out<<YAML::Key<<
"Filepath"<<YAML::Value<<texturecomponent->
m_Texture.get()->m_LoadedFilePath;
135 out<<YAML::Key<<
"MagFilter"<<YAML::Value<<texturecomponent->
m_Texture.get()->m_LoadedMagFilter;
136 out<<YAML::Key<<
"MinFilter"<<YAML::Value<<texturecomponent->
m_Texture.get()->m_LoadedMinFilter;
138 out<<YAML::Key<<
"Width"<<YAML::Value<<texturecomponent->
m_Width;
139 out<<YAML::Key<<
"Height"<<YAML::Value<<texturecomponent->
m_Height;
140 out<<YAML::Key<<
"Layer"<<YAML::Value<<texturecomponent->
m_Layer;
146 out<<YAML::Key<<
"AnimatedTextureComponent";
151 out<<YAML::Key<<
"Filepath"<<YAML::Value<<animatedtexturecomponent->
m_AnimatedTexture.get()->m_LoadedFilePath;
152 out<<YAML::Key<<
"MagFilter"<<YAML::Value<<animatedtexturecomponent->
m_AnimatedTexture.get()->m_LoadedMagFilter;
153 out<<YAML::Key<<
"MinFilter"<<YAML::Value<<animatedtexturecomponent->
m_AnimatedTexture.get()->m_LoadedMinFilter;
155 out<<YAML::Key<<
"TileWidth"<<YAML::Value<<animatedtexturecomponent->
m_AnimatedTexture.get()->m_TileWidth;
156 out<<YAML::Key<<
"TileHeight"<<YAML::Value<<animatedtexturecomponent->
m_AnimatedTexture.get()->m_TileHeight;
158 out<<YAML::Key<<
"PlayAnimation"<<YAML::Value<<animatedtexturecomponent->
m_PlayAnimation;
159 out<<YAML::Key<<
"LoopAnimation"<<YAML::Value<<animatedtexturecomponent->
m_LoopAnimation;
160 out<<YAML::Key<<
"AnimationDelay"<<YAML::Value<<animatedtexturecomponent->
m_AnimationDelay;
161 out<<YAML::Key<<
"AnimationIndex"<<YAML::Value<<animatedtexturecomponent->
m_AnimationIndex;
163 out<<YAML::Key<<
"Width"<<YAML::Value<<animatedtexturecomponent->
m_Width;
164 out<<YAML::Key<<
"Height"<<YAML::Value<<animatedtexturecomponent->
m_Height;
165 out<<YAML::Key<<
"Layer"<<YAML::Value<<animatedtexturecomponent->
m_Layer;
171 out<<YAML::Key<<
"RigidbodyComponent";
177 out<<YAML::Key<<
"FixedRotation"<<YAML::Value<<rigidbodycomponent->
m_FixedRotation;
183 out<<YAML::Key<<
"BoxColliderComponent";
188 out<<YAML::Key<<
"XOffset"<<YAML::Value<<boxcollidercomponent->
m_XOffset;
189 out<<YAML::Key<<
"YOffset"<<YAML::Value<<boxcollidercomponent->
m_YOffset;
190 out<<YAML::Key<<
"Width"<<YAML::Value<<boxcollidercomponent->
m_Width;
191 out<<YAML::Key<<
"Height"<<YAML::Value<<boxcollidercomponent->
m_Height;
192 out<<YAML::Key<<
"Density"<<YAML::Value<<boxcollidercomponent->
m_Density;
193 out<<YAML::Key<<
"Friction"<<YAML::Value<<boxcollidercomponent->
m_Friction;
194 out<<YAML::Key<<
"Restitution"<<YAML::Value<<boxcollidercomponent->
m_Restitution;
201 out<<YAML::Key<<
"CircleColliderComponent";
206 out<<YAML::Key<<
"XOffset"<<YAML::Value<<circlecollidercomponent->
m_XOffset;
207 out<<YAML::Key<<
"YOffset"<<YAML::Value<<circlecollidercomponent->
m_YOffset;
208 out<<YAML::Key<<
"Radius"<<YAML::Value<<circlecollidercomponent->
m_Radius;
209 out<<YAML::Key<<
"Density"<<YAML::Value<<circlecollidercomponent->
m_Density;
210 out<<YAML::Key<<
"Friction"<<YAML::Value<<circlecollidercomponent->
m_Friction;
211 out<<YAML::Key<<
"Restitution"<<YAML::Value<<circlecollidercomponent->
m_Restitution;
218 out<<YAML::Key<<
"LightComponent";
223 out<<YAML::Key<<
"XOffset"<<YAML::Value<<lightcomponent->
m_XOffset;
224 out<<YAML::Key<<
"YOffset"<<YAML::Value<<lightcomponent->
m_YOffset;
225 out<<YAML::Key<<
"Radius"<<YAML::Value<<lightcomponent->
m_Radius;
226 out<<YAML::Key<<
"Blur"<<YAML::Value<<lightcomponent->
m_Blur;
227 out<<YAML::Key<<
"Color"<<YAML::Value<<lightcomponent->
m_Color;
234 out<<YAML::Key<<
"TextComponent";
239 out<<YAML::Key<<
"FontPath"<<YAML::Value<<textcomponent->
m_TextRenderer->m_LoadedFontPath;
240 out<<YAML::Key<<
"GlyphSize"<<YAML::Value<<textcomponent->
m_TextRenderer->m_LoadedGlyphSize;
241 out<<YAML::Key<<
"Fixed"<<YAML::Value<<textcomponent->
m_TextRenderer->m_Fixed;
242 out<<YAML::Key<<
"Text"<<YAML::Value<<textcomponent->
m_Text;
243 out<<YAML::Key<<
"Offset"<<YAML::Value<<textcomponent->
m_Offset;
244 out<<YAML::Key<<
"Color"<<YAML::Value<<textcomponent->
m_Color;
245 out<<YAML::Key<<
"Scale"<<YAML::Value<<textcomponent->
m_Scale;
246 out<<YAML::Key<<
"Layer"<<YAML::Value<<textcomponent->
m_Layer;
247 out<<YAML::Key<<
"IgnoreLighting"<<YAML::Value<<textcomponent->
m_IgnoreLighting;
252 for(
auto &[fn_name,
id]:script_components){
253 if(
id==entity.
m_UID){
254 if(!fn_name.empty()){
255 out<<YAML::Key<<
"NativeScriptComponent";
257 out<<YAML::Key<<
"FunctionName"<<YAML::Value<<fn_name;
492 auto ent=e[
"Entity"];
493 uint32_t uid=ent[
"UID"].as<uint32_t>();
496 entity->
m_X=ent[
"X"].as<
float>();
497 entity->m_Y=ent[
"Y"].as<
float>();
498 entity->m_PreviousX=ent[
"PreviousX"].as<
float>();
499 entity->m_PreviousY=ent[
"PreviousY"].as<
float>();
501 auto tagcomponent=e[
"TagComponent"];
503 std::string tag=tagcomponent[
"Tag"].as<std::string>();
507 auto texturecomponent=e[
"TextureComponent"];
508 if(texturecomponent){
509 std::string filepath=texturecomponent[
"Filepath"].as<std::string>();
510 int magfilter=texturecomponent[
"MagFilter"].as<
int>();
511 int minfilter=texturecomponent[
"MinFilter"].as<
int>();
512 int width=texturecomponent[
"Width"].as<
int>();
513 int height=texturecomponent[
"Height"].as<
int>();
514 int layer=texturecomponent[
"Layer"].as<
int>();
520 auto animatedtexturecomponent=e[
"AnimatedTextureComponent"];
521 if(animatedtexturecomponent){
522 std::string filepath=animatedtexturecomponent[
"Filepath"].as<std::string>();
523 int magfilter=animatedtexturecomponent[
"MagFilter"].as<
int>();
524 int minfilter=animatedtexturecomponent[
"MinFilter"].as<
int>();
525 unsigned int tilewidth=animatedtexturecomponent[
"TileWidth"].as<
unsigned int>();
526 unsigned int tileheight=animatedtexturecomponent[
"TileHeight"].as<
unsigned int>();
527 bool playanimation=animatedtexturecomponent[
"PlayAnimation"].as<
bool>();
528 bool loopanimation=animatedtexturecomponent[
"LoopAnimation"].as<
bool>();
529 float animationdelay=animatedtexturecomponent[
"AnimationDelay"].as<
float>();
530 int animationindex=animatedtexturecomponent[
"AnimationIndex"].as<
int>();
531 int width=animatedtexturecomponent[
"Width"].as<
float>();
532 int height=animatedtexturecomponent[
"Height"].as<
float>();
533 int layer=animatedtexturecomponent[
"Layer"].as<
int>();
539 auto rigidbodycomponent=e[
"RigidbodyComponent"];
540 if(rigidbodycomponent){
542 bool fixedrotation=rigidbodycomponent[
"FixedRotation"].as<
bool>();
547 auto boxcollidercomponent=e[
"BoxColliderComponent"];
548 if(boxcollidercomponent){
549 float xoffset=boxcollidercomponent[
"XOffset"].as<
float>();
550 float yoffset=boxcollidercomponent[
"YOffset"].as<
float>();
551 float width=boxcollidercomponent[
"Width"].as<
float>();
552 float height=boxcollidercomponent[
"Height"].as<
float>();
553 float density=boxcollidercomponent[
"Density"].as<
float>();
554 float friction=boxcollidercomponent[
"Friction"].as<
float>();
555 float restitution=boxcollidercomponent[
"Restitution"].as<
float>();
556 float restitutionthreshold=boxcollidercomponent[
"RestitutionThreshold"].as<
float>();
561 auto circlecollidercomponent=e[
"CircleColliderComponent"];
562 if(circlecollidercomponent){
563 float xoffset=circlecollidercomponent[
"XOffset"].as<
float>();
564 float yoffset=circlecollidercomponent[
"YOffset"].as<
float>();
565 float radius=circlecollidercomponent[
"Radius"].as<
float>();
566 float density=circlecollidercomponent[
"Density"].as<
float>();
567 float friction=circlecollidercomponent[
"Friction"].as<
float>();
568 float restitution=circlecollidercomponent[
"Restitution"].as<
float>();
569 float restitutionthreshold=circlecollidercomponent[
"RestitutionThreshold"].as<
float>();
574 auto lightcomponent=e[
"LightComponent"];
576 float xoffset=lightcomponent[
"XOffset"].as<
float>();
577 float yoffset=lightcomponent[
"YOffset"].as<
float>();
578 float radius=lightcomponent[
"Radius"].as<
float>();
579 float blur=lightcomponent[
"Blur"].as<
float>();
580 Vec3 color=lightcomponent[
"Color"].as<
Vec3>();
586 auto textcomponent=e[
"TextComponent"];
588 std::string fontpath=textcomponent[
"FontPath"].as<std::string>();
589 float glyphsize=textcomponent[
"GlyphSize"].as<
float>();
590 bool fixed=textcomponent[
"Fixed"].as<
bool>();
591 std::string text=textcomponent[
"Text"].as<std::string>();
592 Vec2 offset=textcomponent[
"Offset"].as<
Vec2>();
593 Vec3 color=textcomponent[
"Color"].as<
Vec3>();
594 float scale=textcomponent[
"Scale"].as<
float>();
595 int layer=textcomponent[
"Layer"].as<
int>();
596 bool ignore_lighting=textcomponent[
"IgnoreLighting"].as<
bool>();
603 auto nativescriptcomponent=e[
"NativeScriptComponent"];
604 if(nativescriptcomponent){
605 std::string functionname=nativescriptcomponent[
"FunctionName"].as<std::string>();
606 script_components.push_back(std::make_pair(functionname,uid));
std::shared_ptr< TextRenderer > m_TextRenderer
std::shared_ptr< Texture > m_Texture
std::pair< uint32_t, std::shared_ptr< SpriteSheet > > GetSpriteSheet(const std::string &path, unsigned int tile_width, unsigned int tile_height, int mag_filter, int min_filter)
std::pair< uint32_t, std::shared_ptr< Texture > > GetTexture(const std::string &path, int mag_filter, int min_filter)