/* * 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 "StdAfx.h" #include namespace Blast { BlastFamilyComponentNotificationBusHandler::BlastFamilyComponentNotificationBusHandler() { m_events.resize(static_cast(Function::Count)); SetEvent(&BlastFamilyComponentNotificationBusHandler::OnActorCreatedDummy, "On Actor Created"); SetEvent(&BlastFamilyComponentNotificationBusHandler::OnActorDestroyedDummy, "On Actor Destroyed"); } void BlastFamilyComponentNotificationBusHandler::Reflect(AZ::ReflectContext* context) { if (AZ::BehaviorContext* behaviorContext = azrtti_cast(context)) { behaviorContext->EBus("BlastFamilyComponentNotificationBus") ->Attribute(AZ::Script::Attributes::Module, "destruction") ->Attribute(AZ::Script::Attributes::Category, "Blast") ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Handler(); } } void BlastFamilyComponentNotificationBusHandler::Disconnect() { BusDisconnect(); } bool BlastFamilyComponentNotificationBusHandler::Connect(AZ::BehaviorValueParameter* id) { return AZ::Internal::EBusConnector::Connect(this, id); } bool BlastFamilyComponentNotificationBusHandler::IsConnected() { return AZ::Internal::EBusConnector::IsConnected(this); } bool BlastFamilyComponentNotificationBusHandler::IsConnectedId(AZ::BehaviorValueParameter* id) { return AZ::Internal::EBusConnector::IsConnectedId(this, id); } int BlastFamilyComponentNotificationBusHandler::GetFunctionIndex(const char* functionName) const { if (strcmp(functionName, "On Actor Created") == 0) { return static_cast(Function::OnActorCreated); } if (strcmp(functionName, "On Actor Destroyed") == 0) { return static_cast(Function::OnActorDestroyed); } return -1; } void BlastFamilyComponentNotificationBusHandler::OnActorCreatedDummy(BlastActorData blastActor) { // This is never invoked, and only used for type deduction when calling SetEvent } void BlastFamilyComponentNotificationBusHandler::OnActorDestroyedDummy(BlastActorData blastActor) { // This is never invoked, and only used for type deduction when calling SetEvent } void BlastFamilyComponentNotificationBusHandler::OnActorCreated(const BlastActor& blastActor) { Call(static_cast(Function::OnActorCreated), BlastActorData(blastActor)); } void BlastFamilyComponentNotificationBusHandler::OnActorDestroyed(const BlastActor& blastActor) { Call(static_cast(Function::OnActorDestroyed), BlastActorData(blastActor)); } } // namespace Blast