fda28bb7b2
* Add the last known parent to the prefab undo cache to detect changes in the owning instance. Still WIP. * Progress in handling reparenting. Still WIP, need a change in CreateLink that will be addressed in a separate branch and then merged back. * A few fixes, reparenting now works with entities. Still working on instances. * Fix assert crashing the Editor because of the arguments being in the wrong order. * Handle moving the patches when removing and recreating links when reparenting nested instances. * Rearrange some code to prevent including instance removal in instance update undo node, as it would be redundant and cause errors in some edge cases. * Reorder instance reparenting to account for correct order of operation during undo/redo * Fix order of operations to support multiple operations in one edit (reparenting to non-container entities while changing instance) * Add function to refresh patches on links to allow aliases to be restored correctly on reparenting. * Removed RefreshEntityPatchOnLink function. Introduced a simpler way of handling porting patches. * Removing unnecessary code that was left after testing. * Minor fixes to naming and comments. * Restore previous error, no longer printing the failed patch. * Remove unused includes. * Restore include removed by mistake. * Simplified patches retrieval by using internal function. Renamed some internal functions and variables to be more accurate.
69 lines
2.3 KiB
C++
69 lines
2.3 KiB
C++
/*
|
|
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
|
* its licensors.
|
|
*
|
|
* For complete copyright and license terms please see the LICENSE at the root of this
|
|
* distribution (the "License"). All use of this software is governed by the License,
|
|
* or, if provided, by the license below or the license accompanying this file. Do not
|
|
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AzCore/Component/EntityId.h>
|
|
#include <AzCore/Memory/SystemAllocator.h>
|
|
#include <AzCore/std/containers/unordered_map.h>
|
|
#include <AzToolsFramework/Prefab/PrefabDomTypes.h>
|
|
#include <AzToolsFramework/Undo/UndoCacheInterface.h>
|
|
|
|
namespace AzToolsFramework
|
|
{
|
|
namespace UndoSystem
|
|
{
|
|
class URSequencePoint;
|
|
}
|
|
|
|
namespace Prefab
|
|
{
|
|
class InstanceEntityMapperInterface;
|
|
class InstanceToTemplateInterface;
|
|
|
|
class PrefabUndoCache
|
|
: UndoSystem::UndoCacheInterface
|
|
{
|
|
public:
|
|
AZ_CLASS_ALLOCATOR(PrefabUndoCache, AZ::SystemAllocator, 0);
|
|
|
|
void Initialize();
|
|
void Destroy();
|
|
|
|
// UndoCacheInterface...
|
|
void UpdateCache(const AZ::EntityId& entityId) override;
|
|
void PurgeCache(const AZ::EntityId& entityId) override;
|
|
void Clear() override;
|
|
void Validate(const AZ::EntityId& entityId) override;
|
|
|
|
// Retrieve the last known state for an entity
|
|
bool Retrieve(const AZ::EntityId& entityId, PrefabDom& outDom, AZ::EntityId& parentId);
|
|
|
|
// Store dom as the cached state of entityId
|
|
void Store(const AZ::EntityId& entityId, PrefabDom&& dom, const AZ::EntityId& parentId);
|
|
|
|
private:
|
|
struct PrefabUndoCacheItem
|
|
{
|
|
PrefabDom dom;
|
|
AZ::EntityId parentId;
|
|
};
|
|
typedef AZStd::unordered_map<AZ::EntityId, PrefabUndoCacheItem> EntityCache;
|
|
EntityCache m_entitySavedStates;
|
|
|
|
InstanceEntityMapperInterface* m_instanceEntityMapperInterface = nullptr;
|
|
InstanceToTemplateInterface* m_instanceToTemplateInterface = nullptr;
|
|
};
|
|
|
|
} // namespace Prefab
|
|
} // namespace AzToolsFramework
|