Files
o3de/Gems/GradientSignal/Code/Source/Components/ReferenceGradientComponent.h
T
Steve Pham 38261d0800 Shorten copyright headers by splitting into 2 lines (#2213)
* Updated all copyright headers to split the longer original copyright line into 2 shorter lines

Signed-off-by: Steve Pham <spham@amazon.com>
2021-07-16 15:25:48 -07:00

79 lines
3.0 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <LmbrCentral/Dependency/DependencyMonitor.h>
#include <GradientSignal/GradientSampler.h>
#include <AzCore/Component/Component.h>
#include <GradientSignal/Ebuses/GradientRequestBus.h>
#include <GradientSignal/Ebuses/ReferenceGradientRequestBus.h>
namespace LmbrCentral
{
template<typename, typename>
class EditorWrappedComponentBase;
}
namespace GradientSignal
{
class ReferenceGradientConfig
: public AZ::ComponentConfig
{
public:
AZ_CLASS_ALLOCATOR(ReferenceGradientConfig, AZ::SystemAllocator, 0);
AZ_RTTI(ReferenceGradientConfig, "{121A6DAB-26C1-46B7-83AE-BE750FDABC04}", AZ::ComponentConfig);
static void Reflect(AZ::ReflectContext* context);
GradientSampler m_gradientSampler;
};
static const AZ::Uuid ReferenceGradientComponentTypeId = "{C4904252-3386-4820-9BF7-53DE705FA644}";
/**
* calculates a gradient value by referencing values from another gradient
*/
class ReferenceGradientComponent
: public AZ::Component
, private GradientRequestBus::Handler
, private ReferenceGradientRequestBus::Handler
{
public:
template<typename, typename> friend class LmbrCentral::EditorWrappedComponentBase;
AZ_COMPONENT(ReferenceGradientComponent, ReferenceGradientComponentTypeId);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services);
static void Reflect(AZ::ReflectContext* context);
ReferenceGradientComponent(const ReferenceGradientConfig& configuration);
ReferenceGradientComponent() = default;
~ReferenceGradientComponent() = default;
//////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Activate() override;
void Deactivate() override;
bool ReadInConfig(const AZ::ComponentConfig* baseConfig) override;
bool WriteOutConfig(AZ::ComponentConfig* outBaseConfig) const override;
//////////////////////////////////////////////////////////////////////////
// GradientRequestBus
float GetValue(const GradientSampleParams& sampleParams) const override;
bool IsEntityInHierarchy(const AZ::EntityId& entityId) const override;
protected:
//////////////////////////////////////////////////////////////////////////
// ReferenceGradientRequestBus
GradientSampler& GetGradientSampler() override;
private:
ReferenceGradientConfig m_configuration;
LmbrCentral::DependencyMonitor m_dependencyMonitor;
};
}