You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
3.2 KiB
C++
73 lines
3.2 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 <AzFramework/Entity/SliceEntityOwnershipService.h>
|
|
#include <AzFramework/Entity/SliceGameEntityOwnershipServiceBus.h>
|
|
|
|
namespace AzFramework
|
|
{
|
|
class SliceGameEntityOwnershipService
|
|
: public SliceEntityOwnershipService
|
|
, private SliceGameEntityOwnershipServiceRequestBus::Handler
|
|
, private SliceInstantiationResultBus::MultiHandler
|
|
{
|
|
public:
|
|
AZ_CLASS_ALLOCATOR(SliceGameEntityOwnershipService, AZ::SystemAllocator, 0);
|
|
explicit SliceGameEntityOwnershipService(const EntityContextId& entityContextId, AZ::SerializeContext* serializeContext);
|
|
|
|
virtual ~SliceGameEntityOwnershipService();
|
|
|
|
static void Reflect(AZ::ReflectContext* context);
|
|
|
|
void Reset() override;
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// SliceGameEntityOwnershipServiceRequestBus::Handler
|
|
SliceInstantiationTicket InstantiateDynamicSlice(const AZ::Data::Asset<AZ::Data::AssetData>& sliceAsset,
|
|
const AZ::Transform& worldTransform, const AZ::IdUtils::Remapper<AZ::EntityId>::IdMapper& customIdMapper) override;
|
|
void CancelDynamicSliceInstantiation(const SliceInstantiationTicket& ticket) override;
|
|
bool DestroyDynamicSliceByEntity(const AZ::EntityId&) override;
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// SliceInstantiationResultBus::MultiHandler
|
|
void OnSlicePreInstantiate(const AZ::Data::AssetId& sliceAssetId, const AZ::SliceComponent::SliceInstanceAddress& instance) override;
|
|
void OnSliceInstantiated(const AZ::Data::AssetId& sliceAssetId, const AZ::SliceComponent::SliceInstanceAddress& instance) override;
|
|
void OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAssetId) override;
|
|
//////////////////////////////////////////////////////////////////////////
|
|
protected:
|
|
void CreateRootSlice() override;
|
|
|
|
private:
|
|
void FlushDynamicSliceDeletionList();
|
|
|
|
/**
|
|
* Specifies that a given entity should not be activated by default
|
|
* after it is created.
|
|
* @param entityId The entity that should not be activated by default.
|
|
*/
|
|
void MarkEntityForNoActivation(AZ::EntityId entityId);
|
|
|
|
struct InstantiatingDynamicSliceInfo
|
|
{
|
|
AZ::Data::Asset<AZ::Data::AssetData> m_asset;
|
|
AZ::Transform m_transform;
|
|
};
|
|
|
|
AZStd::unordered_map<SliceInstantiationTicket, InstantiatingDynamicSliceInfo> m_instantiatingDynamicSlices;
|
|
|
|
SliceInstanceUnorderedSet m_dynamicSlicesToDestroy;
|
|
};
|
|
}
|