/* * 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 "ScriptCanvasDiagnosticSystemComponent.h" #include #include #include "DebugLibraryDefinition.h" namespace ScriptCanvasDiagnostics { void SystemComponent::Init() { AZ::EnvironmentVariable nodeRegistryVariable = AZ::Environment::FindVariable(ScriptCanvas::s_nodeRegistryName); if (nodeRegistryVariable) { ScriptCanvas::NodeRegistry& nodeRegistry = nodeRegistryVariable.Get(); ScriptCanvas::Libraries::Debug::InitNodeRegistry(nodeRegistry); } } SystemComponent::~SystemComponent() { } void SystemComponent::Activate() { SystemRequestBus::Handler::BusConnect(); CrySystemEventBus::Handler::BusConnect(); } void SystemComponent::Deactivate() { CrySystemEventBus::Handler::BusDisconnect(); SystemRequestBus::Handler::BusDisconnect(); } void SystemComponent::OnDebugDraw() { DebugDrawBus::Broadcast(&DebugDrawRequests::OnDebugDraw, m_system->GetIRenderer()); } void SystemComponent::OnCrySystemShutdown(ISystem& system) { m_system->GetIRenderer()->RemoveRenderDebugListener(this); } void SystemComponent::OnCrySystemInitialized(ISystem& system, const SSystemInitParams& systemInitParams) { m_system = &system; AZ_Assert(m_system->GetIRenderer(), "ScriptCanvasDiagnostics requires IRenderer"); m_system->GetIRenderer()->AddRenderDebugListener(this); } bool SystemComponent::IsEditor() { return m_system && m_system->GetGlobalEnvironment() && m_system->GetGlobalEnvironment()->IsEditor(); } void SystemComponent::Reflect(AZ::ReflectContext* context) { ScriptCanvas::Libraries::Debug::Reflect(context); if (auto serialize = azrtti_cast(context)) { serialize->Class() ->Version(0) ; if (AZ::EditContext* ec = serialize->GetEditContext()) { ec->Class("Script Canvas Diagnostic", "Script Canvas Diagnostic System Component") ->ClassElement(AZ::Edit::ClassElements::EditorData, "") ->Attribute(AZ::Edit::Attributes::Category, "Scripting") ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System", 0xc94d118b)) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) ; } } } }