/* * 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 #include #include #include #include #include #include #include // Forward declarations namespace AZ { class Entity; } //////////////////////////////////////////////////////////////////////////////////////////////////// //! Bus for making requests to the UI entity context. //! There is one UiEntityContext per UI canvas. class UiEntityContextRequests : public AZ::EBusTraits { public: virtual ~UiEntityContextRequests() {} ////////////////////////////////////////////////////////////////////////// // EBusTraits overrides. Accessed by EntityContextId static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById; typedef AzFramework::EntityContextId BusIdType; static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; ////////////////////////////////////////////////////////////////////////// //! Creates an entity in a UI context. //! \return a new entity virtual AZ::Entity* CreateUiEntity(const char* name) = 0; //! Registers an existing entity with a UI context. virtual void AddUiEntity(AZ::Entity* entity) = 0; //! Registers an existing set of entities with a UI context. virtual void AddUiEntities(const AzFramework::EntityContext::EntityList& entities) = 0; //! Destroys an entity in a UI context. //! \return whether or not the entity was destroyed. A false return value signifies the entity did not belong to the UI context. virtual bool DestroyUiEntity(AZ::EntityId entityId) = 0; //! Clones a set of entities. //! \param sourceEntities - the source set of entities to clone //! \param resultEntities - the set of entities cloned from the source virtual bool CloneUiEntities(const AZStd::vector& sourceEntities, AzFramework::EntityContext::EntityList& resultEntities) = 0; }; using UiEntityContextRequestBus = AZ::EBus; //////////////////////////////////////////////////////////////////////////////////////////////////// //! Bus for receiving events/notifications from the UI entity context class UiEntityContextNotification : public AZ::EBusTraits { public: virtual ~UiEntityContextNotification() {}; //! Fired when the context is being reset. virtual void OnContextReset() {} //! Fired when a slice has been successfully instantiated. virtual void OnSliceInstantiated(const AZ::Data::AssetId& /*sliceAssetId*/, const AZ::SliceComponent::SliceInstanceAddress& /*sliceAddress*/, const AzFramework::SliceInstantiationTicket& /*ticket*/) {} //! Fired when a slice has failed to instantiate. virtual void OnSliceInstantiationFailed(const AZ::Data::AssetId& /*sliceAssetId*/, const AzFramework::SliceInstantiationTicket& /*ticket*/) {} //! Fired when the entity stream has been successfully loaded. virtual void OnEntityStreamLoadSuccess() {} //! Fired when the entity stream load has failed virtual void OnEntityStreamLoadFailed() {} }; using UiEntityContextNotificationBus = AZ::EBus;