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,76 @@
/*
* 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 <Scripting/EditorEntityReferenceComponent.h>
namespace AZ
{
namespace Render
{
void EditorEntityReferenceComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<EditorEntityReferenceComponent, BaseClass>()
->Version(0);
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<EditorEntityReferenceComponent>(
"Entity Reference", "Contains a reference list to other entities")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute(Edit::Attributes::Category, "Atom")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/Component_Placeholder.svg")
->Attribute(AZ::Edit::Attributes::ViewportIcon, "editor/icons/components/viewport/component_placeholder.png")
->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->Attribute(Edit::Attributes::AutoExpand, true)
->Attribute(Edit::Attributes::HelpPageURL, "")
;
editContext->Class<EntityReferenceComponentController>("EntityReferenceComponentController", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &EntityReferenceComponentController::m_configuration, "Configuration", "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
;
editContext->Class<EntityReferenceComponentConfig>("EntityReferenceComponentConfig", "")
->DataElement(AZ::Edit::UIHandlers::Default, &EntityReferenceComponentConfig::m_entityIdReferences, "EntityIdReferences", "List of references to other entities.")
;
;
}
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<EditorEntityReferenceComponent>()->RequestBus("EntityReferenceRequestBus");
behaviorContext->ConstantProperty("EditorEntityReferenceComponentTypeId", BehaviorConstant(Uuid(EditorEntityReferenceComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
}
}
EditorEntityReferenceComponent::EditorEntityReferenceComponent(const EntityReferenceComponentConfig& config)
: BaseClass(config)
{
}
AZ::u32 EditorEntityReferenceComponent::OnConfigurationChanged()
{
return Edit::PropertyRefreshLevels::AttributesAndValues;
}
}
}
@@ -0,0 +1,37 @@
/*
* 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 <AzToolsFramework/ToolsComponents/EditorComponentAdapter.h>
#include <Scripting/EntityReferenceComponent.h>
#include <AzCore/std/containers/vector.h>
namespace AZ
{
namespace Render
{
class EditorEntityReferenceComponent final
: public AzToolsFramework::Components::EditorComponentAdapter<EntityReferenceComponentController, EntityReferenceComponent, EntityReferenceComponentConfig>
{
public:
using BaseClass = AzToolsFramework::Components::EditorComponentAdapter<EntityReferenceComponentController, EntityReferenceComponent, EntityReferenceComponentConfig>;
AZ_EDITOR_COMPONENT(AZ::Render::EditorEntityReferenceComponent, EditorEntityReferenceComponentTypeId, BaseClass);
static void Reflect(AZ::ReflectContext* context);
EditorEntityReferenceComponent() = default;
EditorEntityReferenceComponent(const EntityReferenceComponentConfig& config);
AZ::u32 OnConfigurationChanged() override;
};
}
}
@@ -0,0 +1,52 @@
/*
* 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 <Scripting/EntityReferenceComponent.h>
#include <AzCore/RTTI/BehaviorContext.h>
namespace AZ
{
namespace Render
{
EntityReferenceComponent::EntityReferenceComponent(const EntityReferenceComponentConfig& config)
: BaseClass(config)
{
}
void EntityReferenceComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<EntityReferenceComponent, BaseClass>()
->Version(0)
;
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->EBus<EntityReferenceRequestBus>("EntityReferenceRequestBus")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Module, "entity")
->Event("GetEntityReferences", &EntityReferenceRequests::GetEntityReferences)
;
behaviorContext->ConstantProperty("EntityReferenceComponentTypeId", BehaviorConstant(Uuid(EntityReferenceComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
;
}
}
}
}
@@ -0,0 +1,37 @@
/*
* 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/Components/ComponentAdapter.h>
#include <AtomLyIntegration/CommonFeatures/Scripting/EntityReferenceComponentConfig.h>
#include <AtomLyIntegration/CommonFeatures/Scripting/EntityReferenceConstants.h>
#include <Scripting/EntityReferenceComponentController.h>
namespace AZ
{
namespace Render
{
class EntityReferenceComponent final
: public AzFramework::Components::ComponentAdapter<EntityReferenceComponentController, EntityReferenceComponentConfig>
{
public:
using BaseClass = AzFramework::Components::ComponentAdapter<EntityReferenceComponentController, EntityReferenceComponentConfig>;
AZ_COMPONENT(AZ::Render::EntityReferenceComponent, EntityReferenceComponentTypeId, BaseClass);
EntityReferenceComponent() = default;
EntityReferenceComponent(const EntityReferenceComponentConfig& config);
static void Reflect(AZ::ReflectContext* context);
};
}
}
@@ -0,0 +1,32 @@
/*
* 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 <AtomLyIntegration/CommonFeatures/Scripting/EntityReferenceComponentConfig.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
namespace AZ
{
namespace Render
{
void EntityReferenceComponentConfig::Reflect(ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<EntityReferenceComponentConfig, ComponentConfig>()
->Version(0)
->Field("EntityReferences", &EntityReferenceComponentConfig::m_entityIdReferences)
;
}
}
}
}
@@ -0,0 +1,71 @@
/*
* 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 <Scripting/EntityReferenceComponentController.h>
namespace AZ
{
namespace Render
{
void EntityReferenceComponentController::Reflect(AZ::ReflectContext* context)
{
EntityReferenceComponentConfig::Reflect(context);
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<EntityReferenceComponentController>()
->Version(0)
->Field("Configuration", &EntityReferenceComponentController::m_configuration);
}
}
void EntityReferenceComponentController::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("EntityReferenceService"));
}
void EntityReferenceComponentController::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("EntityReferenceService"));
}
EntityReferenceComponentController::EntityReferenceComponentController(const EntityReferenceComponentConfig& config)
: m_configuration(config)
{
}
void EntityReferenceComponentController::Activate(EntityId entityId)
{
m_entityId = entityId;
EntityReferenceRequestBus::Handler::BusConnect(m_entityId);
}
void EntityReferenceComponentController::Deactivate()
{
EntityReferenceRequestBus::Handler::BusDisconnect(m_entityId);
m_entityId.SetInvalid();
}
void EntityReferenceComponentController::SetConfiguration(const EntityReferenceComponentConfig& config)
{
m_configuration = config;
}
AZStd::vector<EntityId> EntityReferenceComponentController::GetEntityReferences() const
{
return m_configuration.m_entityIdReferences;
}
}
}
@@ -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.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <AzCore/Component/TransformBus.h>
#include <AtomLyIntegration/CommonFeatures/Scripting/EntityReferenceRequestBus.h>
#include <AtomLyIntegration/CommonFeatures/Scripting/EntityReferenceComponentConfig.h>
namespace AZ
{
namespace Render
{
class EntityReferenceComponentController final
: public EntityReferenceRequestBus::Handler
{
public:
friend class EditorEntityReferenceComponent;
AZ_TYPE_INFO(AZ::Render::EntityReferenceComponentController, "{89D1D8DE-AC1F-4069-8884-5A04582C2EB1}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
EntityReferenceComponentController() = default;
EntityReferenceComponentController(const EntityReferenceComponentConfig& config);
void Activate(EntityId entityId);
void Deactivate();
void SetConfiguration(const EntityReferenceComponentConfig& config);
const EntityReferenceComponentConfig& GetConfiguration() const { return m_configuration; }
// EntityReferenceRequestBus Overrides
virtual AZStd::vector<EntityId> GetEntityReferences() const override;
private:
AZ_DISABLE_COPY(EntityReferenceComponentController);
EntityReferenceComponentConfig m_configuration;
EntityId m_entityId;
};
}
}