feat: add runtime play tick and play-mode scene editing semantics
This commit is contained in:
@@ -32,6 +32,10 @@ void SceneManager::SetSceneDirty(bool dirty) {
|
||||
}
|
||||
|
||||
void SceneManager::MarkSceneDirty() {
|
||||
if (!m_sceneDocumentDirtyTrackingEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
SetSceneDirty(true);
|
||||
}
|
||||
|
||||
@@ -43,7 +47,7 @@ void SceneManager::MarkSceneDirty() {
|
||||
::XCEngine::Components::GameObject* entity = m_scene->CreateGameObject(name, parent);
|
||||
const auto entityId = entity->GetID();
|
||||
SyncRootEntities();
|
||||
SetSceneDirty(true);
|
||||
MarkSceneDirty();
|
||||
|
||||
OnEntityCreated.Invoke(entityId);
|
||||
OnSceneChanged.Invoke();
|
||||
@@ -70,7 +74,7 @@ void SceneManager::DeleteEntity(::XCEngine::Components::GameObject::ID id) {
|
||||
const auto entityId = entity->GetID();
|
||||
m_scene->DestroyGameObject(entity);
|
||||
SyncRootEntities();
|
||||
SetSceneDirty(true);
|
||||
MarkSceneDirty();
|
||||
|
||||
OnEntityDeleted.Invoke(entityId);
|
||||
OnSceneChanged.Invoke();
|
||||
@@ -150,7 +154,7 @@ void SceneManager::CopyEntity(::XCEngine::Components::GameObject::ID id) {
|
||||
|
||||
const auto newEntityId = PasteEntityRecursive(*m_clipboard, parent);
|
||||
SyncRootEntities();
|
||||
SetSceneDirty(true);
|
||||
MarkSceneDirty();
|
||||
|
||||
OnEntityCreated.Invoke(newEntityId);
|
||||
OnSceneChanged.Invoke();
|
||||
@@ -320,7 +324,7 @@ void SceneManager::RenameEntity(::XCEngine::Components::GameObject::ID id, const
|
||||
if (!obj) return;
|
||||
|
||||
obj->SetName(newName);
|
||||
SetSceneDirty(true);
|
||||
MarkSceneDirty();
|
||||
OnEntityChanged.Invoke(id);
|
||||
|
||||
if (m_eventBus) {
|
||||
@@ -342,7 +346,7 @@ void SceneManager::MoveEntity(::XCEngine::Components::GameObject::ID id, ::XCEng
|
||||
|
||||
obj->SetParent(newParent);
|
||||
SyncRootEntities();
|
||||
SetSceneDirty(true);
|
||||
MarkSceneDirty();
|
||||
|
||||
OnEntityChanged.Invoke(id);
|
||||
OnSceneChanged.Invoke();
|
||||
|
||||
@@ -57,15 +57,21 @@ public:
|
||||
bool HasActiveScene() const override { return m_scene != nullptr; }
|
||||
bool IsSceneDirty() const override { return m_isSceneDirty; }
|
||||
void MarkSceneDirty() override;
|
||||
void SetSceneDocumentDirtyTrackingEnabled(bool enabled) override {
|
||||
m_sceneDocumentDirtyTrackingEnabled = enabled;
|
||||
}
|
||||
bool IsSceneDocumentDirtyTrackingEnabled() const override {
|
||||
return m_sceneDocumentDirtyTrackingEnabled;
|
||||
}
|
||||
const std::string& GetCurrentScenePath() const override { return m_currentScenePath; }
|
||||
const std::string& GetCurrentSceneName() const override { return m_currentSceneName; }
|
||||
::XCEngine::Components::Scene* GetScene() override { return m_scene.get(); }
|
||||
const ::XCEngine::Components::Scene* GetScene() const override { return m_scene.get(); }
|
||||
SceneSnapshot CaptureSceneSnapshot() const override;
|
||||
bool RestoreSceneSnapshot(const SceneSnapshot& snapshot) override;
|
||||
void CreateDemoScene() override;
|
||||
|
||||
bool HasClipboardData() const { return m_clipboard.has_value(); }
|
||||
SceneSnapshot CaptureSceneSnapshot() const;
|
||||
bool RestoreSceneSnapshot(const SceneSnapshot& snapshot);
|
||||
|
||||
::XCEngine::Core::Event<::XCEngine::Components::GameObject::ID> OnEntityCreated;
|
||||
::XCEngine::Core::Event<::XCEngine::Components::GameObject::ID> OnEntityDeleted;
|
||||
@@ -97,6 +103,7 @@ private:
|
||||
std::string m_currentScenePath;
|
||||
std::string m_currentSceneName = "Untitled Scene";
|
||||
bool m_isSceneDirty = false;
|
||||
bool m_sceneDocumentDirtyTrackingEnabled = true;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user