SpiecsEngine
 
Loading...
Searching...
No Matches
EntityComponent.cpp
Go to the documentation of this file.
1/**
2* @file EntityComponent.cpp.
3* @brief The EntityComponent Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
9#include "Render/FrameInfo.h"
10#include "World/World/World.h"
11#include "World/Entity.h"
12
13namespace Spices {
14
16 {
17
18 }
20 {
21
22 }
23
25 {
27
28 if (ImGui::BeginChild("Entity Attachments", ImVec2(0, std::min(m_Entities.size() + 0.2f, 10.0f) * ImGuiH::GetLineItemSize().x), ImGuiChildFlags_None, ImGuiWindowFlags_HorizontalScrollbar))
29 {
30 for (auto& item : m_Entities)
31 {
32 std::stringstream ss;
33 ss << "Attchments [" << item << "]";
34
35 ImGuiH::DrawPropertyItem(ss.str().c_str(), 0, nullptr, [&]() {
36 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
37 char buffer[12] = {};
38 ImGui::InputTextWithHint("##", std::to_string(item).c_str(), buffer, sizeof(buffer));
39 ImGui::PopItemWidth();
40 ImGui::SameLine();
41 ImGuiH::DrawResetIcon(false);
42 });
43 }
44
45 ImGui::EndChild();
46 }
47 }
48
49 void EntityComponent::AddEntity(uint32_t entity)
50 {
52
53 m_Entities.insert(entity);
54
55 Entity e((entt::entity)entity, FrameInfo::Get().m_World.get());
57 }
58
59 void EntityComponent::RemoveEntity(uint32_t entity)
60 {
62
63 m_Entities.erase(entity);
64 Entity e((entt::entity)entity, FrameInfo::Get().m_World.get());
66 }
67}
#define SPICES_PROFILE_ZONE
void AddEntity(uint32_t entity)
Add an child entity to this Component.
virtual void OnDeSerialize() override
This interface defines how to deserialize.
void RemoveEntity(uint32_t entity)
Remove an child entity from this Component.
virtual void OnSerialize() override
This interface defines how to serialize.
virtual void DrawThis() override
This interface defines how to draw this component to property panel.
EntityComponent Class. This class defines the specific behaves of EntityComponent.
void AddToRoot()
Add a entity to this world root.
Definition Entity.h:101
void RemoveFromRoot()
Remove a entity from this world root.
Definition Entity.h:93
Entity Class. This class defines the specific behaves of Entity.
Definition Entity.h:20