/* * 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 #include #include #include #include #include #include #include #include namespace LmbrCentral { template class EditorWrappedComponentBase; } namespace Terrain { namespace AreaConstants { static const AZ::u32 s_backgroundLayer = 0; static const AZ::u32 s_foregroundLayer = 1; static const AZ::u32 s_priorityMin = 0; static const AZ::u32 s_priorityMax = 10000; //arbitrary number because std::numeric_limits::max() always dislays -1 in RPE static const AZ::u32 s_prioritySoftMax = 100; //design specified slider range } class TerrainLayerSpawnerConfig : public AZ::ComponentConfig { public: AZ_CLASS_ALLOCATOR(TerrainLayerSpawnerConfig, AZ::SystemAllocator, 0); AZ_RTTI(TerrainLayerSpawnerConfig, "{8E0695DE-E843-4858-BAEA-70953E74C810}", AZ::ComponentConfig); static void Reflect(AZ::ReflectContext* context); AZStd::vector> GetSelectableLayers() const; AZ::u32 m_layer = AreaConstants::s_foregroundLayer; AZ::u32 m_priority = AreaConstants::s_priorityMin; bool m_useGroundPlane = true; }; class TerrainLayerSpawnerComponent : public AZ::Component , private LmbrCentral::ShapeComponentNotificationsBus::Handler , private Terrain::TerrainSpawnerRequestBus::Handler { public: template friend class LmbrCentral::EditorWrappedComponentBase; AZ_COMPONENT(TerrainLayerSpawnerComponent, "{3848605F-A4EA-478C-B710-84AB8DCA9EC5}"); 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); TerrainLayerSpawnerComponent(const TerrainLayerSpawnerConfig& configuration); TerrainLayerSpawnerComponent() = default; ~TerrainLayerSpawnerComponent() = 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; protected: // ShapeComponentNotificationsBus void OnShapeChanged(ShapeChangeReasons changeReason) override; // TerrainSpawnerRequestBus void GetPriority(AZ::u32& outLayer, AZ::u32& outPriority) override; bool GetUseGroundPlane() override; void RefreshArea(); private: TerrainLayerSpawnerConfig m_configuration; }; }