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,97 @@
/*
* 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 "precompiled.h"
#include "ScriptEventReferencesComponent.h"
namespace ScriptEvents
{
namespace Components
{
void ScriptEventReferencesComponent::Reflect(AZ::ReflectContext* context)
{
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
// The Script Event References component is no longer necessary, as all Script Event assets
// will be properly loaded as needed.
serializeContext->ClassDeprecate("ScriptEventReferencesComponent", "{D0F440AC-32D4-49EC-8B93-860B188266A6}");
}
}
void ScriptEventReferencesComponent::Activate()
{
for (auto& scriptEventReferences : m_scriptEventAssets)
{
const auto& asset = scriptEventReferences.GetAsset();
if (asset)
{
if (!AZ::Data::AssetBus::MultiHandler::BusIsConnectedId(asset.GetId()))
{
AZ::Data::AssetBus::MultiHandler::BusConnect(asset.GetId());
}
// Load the asset if it's not ready
if (!asset.IsReady())
{
AZ::Data::AssetInfo assetInfo;
AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &AZ::Data::AssetCatalogRequests::GetAssetInfoById, asset.GetId());
if (assetInfo.m_assetId.IsValid())
{
AZ::Data::AssetManager::Instance().GetAsset(asset.GetId(), azrtti_typeid<ScriptEventsAsset>(), AZ::Data::AssetLoadBehavior::Default)
.BlockUntilLoadComplete();
}
}
}
else
{
AZ_Warning("Script Events", false, "ScriptEventReferencesComponent could not find Script Event asset: %s", scriptEventReferences.GetDefinition() ? scriptEventReferences.GetDefinition()->GetName().c_str() : scriptEventReferences.GetAsset().GetId().ToString<AZStd::string>().c_str());
}
}
}
void ScriptEventReferencesComponent::Deactivate()
{
for (auto& scriptEventReferences : m_scriptEventAssets)
{
const auto& asset = scriptEventReferences.GetAsset();
if (asset)
{
AZ::Data::AssetBus::MultiHandler::BusDisconnect(asset.GetId());
}
}
}
void ScriptEventReferencesComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("ScriptEventReference", 0x3df92d40));
}
void ScriptEventReferencesComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("ScriptEventReference", 0x3df92d40));
}
void ScriptEventReferencesComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
dependent.push_back(AZ_CRC("LuaScriptService", 0x21d76c4b));
}
void ScriptEventReferencesComponent::OnAssetReady(AZ::Data::Asset<AZ::Data::AssetData> asset)
{
if (ScriptEventsAsset* scriptEventAsset = asset.GetAs<ScriptEventsAsset>())
{
scriptEventAsset->m_definition.RegisterInternal();
}
}
}
}
@@ -0,0 +1,48 @@
/*
* 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 <ScriptEvents/ScriptEventsAssetRef.h>
#include <AzCore/Asset/AssetCommon.h>
namespace ScriptEvents
{
namespace Components
{
class ScriptEventReferencesComponent
: public AZ::Component
, private AZ::Data::AssetBus::MultiHandler
{
public:
AZ_COMPONENT(ScriptEventReferencesComponent, "{D0F440AC-32D4-49EC-8B93-860B188266A6}", AZ::Component);
//////////////////////////////////////////////////////////////////////////
// AZ::Component
void Init() override {}
void Activate() override;
void Deactivate() override;
//////////////////////////////////////////////////////////////////////////
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
void OnAssetReady(AZ::Data::Asset<AZ::Data::AssetData> asset) override;
static void Reflect(AZ::ReflectContext* reflection);
AZStd::vector<ScriptEvents::ScriptEventsAssetRef> m_scriptEventAssets;
};
}
}