Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,46 @@
/*
* 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/EBus/EBus.h>
#include <AzCore/Slice/SliceComponent.h>
namespace AzFramework
{
/**
* Interface for AzFramework::SliceEntityRequestBus, which can be used to request information about the owning slices of entities.
*/
class SliceEntityRequests
: public AZ::EBusTraits
{
public:
/**
* Destroys the instance of the class.
*/
virtual ~SliceEntityRequests() = default;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
using BusIdType = AZ::EntityId;
/**
* Gets the address of the slice instance that owns the entity.
*
* @return SliceInstanceAddress
*/
virtual AZ::SliceComponent::SliceInstanceAddress GetOwningSlice() = 0;
};
using SliceEntityRequestBus = AZ::EBus<SliceEntityRequests>;
}
@@ -0,0 +1,89 @@
/*
* 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/EBus/EBus.h>
#include <AzCore/Slice/SliceComponent.h>
#include<AzFramework/Slice/SliceInstantiationTicket.h>
namespace AzFramework
{
/**
* Interface for AzFramework::SliceInstantiationResultBus, which
* enables you to receive results regarding your slice instantiation
* requests.
*/
class SliceInstantiationResults
: public AZ::EBusTraits
{
public:
/**
* Destroys the instance of the class.
*/
virtual ~SliceInstantiationResults() = default;
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
/**
* Overrides the default AZ::EBusAddressPolicy to specify that the EBus
* has multiple addresses. Components that request slice instantiation
* receive the results of the request at the EBus address that is
* associated with the request ID of the slice instantiation ticket.
*/
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
/**
* Specifies that events are addressed by the request ID of the
* slice instantiation ticket.
*/
using BusIdType = SliceInstantiationTicket;
//////////////////////////////////////////////////////////////////////////
/**
* Signals that a slice was successfully instantiated prior to
* entity registration.
* @param sliceAssetId A reference to the slice asset ID.
* @param sliceAddress A reference to the slice instance address.
*/
virtual void OnSlicePreInstantiate(const AZ::Data::AssetId& /*sliceAssetId*/, const AZ::SliceComponent::SliceInstanceAddress& /*sliceAddress*/) {}
/**
* Signals that a slice was successfully instantiated after
* entity registration.
* @param sliceAssetId A reference to the slice asset ID.
* @param sliceAddress A reference to the slice instance address.
*/
virtual void OnSliceInstantiated(const AZ::Data::AssetId& /*sliceAssetId*/, const AZ::SliceComponent::SliceInstanceAddress& /*sliceAddress*/) {}
/**
* Signals that a slice could not be instantiated.
* @deprecated Please use OnSliceInstantiationFailedOrCanceled
* @param sliceAssetId A reference to the slice asset ID.
*/
virtual void OnSliceInstantiationFailed(const AZ::Data::AssetId& /*sliceAssetId*/) {}
/**
* Signals that a slice could not be instantiated.
* @param sliceAssetId A reference to the slice asset ID.
* @param canceled Set to true if the failure was due to cancellation.
*/
virtual void OnSliceInstantiationFailedOrCanceled(const AZ::Data::AssetId& /*sliceAssetId*/, bool /*canceled*/) {}
};
/**
* The EBus that notifies you about the results of your slice instantiation requests.
* The events are defined in the AzFramework::SliceInstantiationResults class.
*/
using SliceInstantiationResultBus = AZ::EBus<SliceInstantiationResults>;
}
@@ -0,0 +1,53 @@
/*
* 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.
*
*/
#include<AzFramework/Slice/SliceInstantiationTicket.h>
namespace AzFramework
{
SliceInstantiationTicket::SliceInstantiationTicket(const EntityContextId& contextId, AZ::u64 requestId)
: m_contextId(contextId)
, m_requestId(requestId)
{
}
bool SliceInstantiationTicket::operator==(const SliceInstantiationTicket& rhs) const
{
return rhs.m_contextId == m_contextId && rhs.m_requestId == m_requestId;
}
bool SliceInstantiationTicket::operator!=(const SliceInstantiationTicket& rhs) const
{
return !((*this) == rhs);
}
bool SliceInstantiationTicket::IsValid() const
{
return m_requestId != 0;
}
AZStd::string SliceInstantiationTicket::ToString() const
{
return AZStd::string::format("{%s::%llu}", m_contextId.ToString<AZStd::string>().c_str(), m_requestId);
}
const EntityContextId& SliceInstantiationTicket::GetContextId() const
{
return m_contextId;
}
AZ::u64 SliceInstantiationTicket::GetRequestId() const
{
return m_requestId;
}
}
@@ -0,0 +1,106 @@
/*
* 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/Asset/AssetCommon.h>
#include <AzCore/Math/Uuid.h>
#include <AzCore/RTTI/TypeInfo.h>
#include <AzCore/std/hash.h>
#include <AzCore/std/string/string.h>
namespace AzFramework
{
using EntityContextId = AZ::Uuid;
/**
* Identifies an asynchronous slice instantiation request.
* This can be used to get the results of a slice instantiation request.
*/
class SliceInstantiationTicket
{
public:
/**
* Enables this class to be identified across modules and serialized into
* different contexts.
*/
AZ_TYPE_INFO(SliceInstantiationTicket, "{E6E7C0C5-07C9-44BB-A38C-930431948667}");
/**
* Creates a slice instantiation ticket.
* @param contextId The ID of the entity context to create the slice in.
* @param requestId An ID for the slice instantiation ticket.
*/
explicit SliceInstantiationTicket(const EntityContextId& contextId = AZ::Uuid::CreateNull(), AZ::u64 requestId = 0);
/**
* Overloads the equality operator to indicate that two slice instantiation
* tickets are equal if they have the same entity context ID and request ID.
* @param rhs The slice instantiation ticket you want to compare to the
* current ticket.
* @return Returns true if the entity context ID and the request ID of the
* slice instantiation tickets are equal.
*/
bool operator==(const SliceInstantiationTicket& rhs) const;
/**
* Overloads the inequality operator to indicate that two slice instantiation
* tickets are not equal do not have the same entity context ID and request ID.
* @param rhs The slice instantiation ticket you want to compare to the
* current ticket.
* @return Returns true if the entity context ID and the request ID of the
* slice instantiation tickets are not equal.
*/
bool operator!=(const SliceInstantiationTicket& rhs) const;
/**
* Overloads the boolean operator to indicate that a slice instantiation
* ticket is true if its request ID is valid.
* @return Returns true if the request ID is not equal to zero.
*/
bool IsValid() const;
AZStd::string ToString() const;
const EntityContextId& GetContextId() const;
AZ::u64 GetRequestId() const;
private:
/**
* The ID of the entity context to create the slice in.
*/
EntityContextId m_contextId;
/**
* An ID for the slice instantiation ticket.
*/
AZ::u64 m_requestId;
};
}
namespace AZStd
{
/**
* Enables slice instantiation tickets to be keys in hashed data structures.
*/
template<>
struct hash<AzFramework::SliceInstantiationTicket>
{
inline size_t operator()(const AzFramework::SliceInstantiationTicket& value) const
{
size_t result = value.GetContextId().GetHash();
hash_combine(result, value.GetRequestId());
return result;
}
};
}