Skip to content

Commit 75e3739

Browse files
committed
add lua / script canvas support
Signed-off-by: Wojciech Czerski <[email protected]>
1 parent b30aac2 commit 75e3739

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

Gems/CsvSpawner/Code/Include/CsvSpawner/CsvSpawnerInterface.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
#pragma once
1313

1414
#include <CsvSpawner/CsvSpawnerUtils.h>
15+
1516
#include <AzCore/EBus/EBus.h>
17+
#include <AzCore/RTTI/BehaviorContext.h>
1618

1719
namespace CsvSpawner
1820
{
@@ -52,4 +54,26 @@ namespace CsvSpawner
5254
// Create an EBus using the notification interface
5355
using CsvSpawnerNotificationBus = AZ::EBus<CsvSpawnerInterface>;
5456

57+
class CsvSpawnerNotificationBusHandler
58+
: public CsvSpawnerNotificationBus::Handler
59+
, public AZ::BehaviorEBusHandler
60+
{
61+
public:
62+
AZ_EBUS_BEHAVIOR_BINDER(
63+
CsvSpawnerNotificationBusHandler,
64+
CsvSpawnerNotificationBusHandlerTypeId,
65+
AZ::SystemAllocator,
66+
OnEntitiesSpawnBegin,
67+
OnEntitiesSpawnFinished);
68+
69+
void OnEntitiesSpawnBegin(CsvSpawnerUtils::SpawnInfo& m_spawnInfo) override
70+
{
71+
Call(FN_OnEntitiesSpawnBegin, m_spawnInfo);
72+
}
73+
74+
void OnEntitiesSpawnFinished(CsvSpawnerUtils::SpawnInfo& m_spawnInfo, CsvSpawnerUtils::SpawnStatus& m_statusCode) override
75+
{
76+
Call(FN_OnEntitiesSpawnFinished, m_spawnInfo, m_statusCode);
77+
}
78+
};
5579
} // namespace CsvSpawner

Gems/CsvSpawner/Code/Include/CsvSpawner/CsvSpawnerTypeIds.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ namespace CsvSpawner
2222

2323
// Interface TypeIds
2424
inline constexpr const char* CsvSpawnerInterfaceTypeId = "{77ACBD4E-069E-4610-8154-E1AC28CEE05A}";
25+
inline constexpr const char* CsvSpawnerNotificationBusHandlerTypeId = "{1F142F00-4E79-431B-9C1D-3AB157838FF8}";
2526
inline constexpr const char* CsvSpawnerSpawnInfoTypeId = "{81E5A014-3232-4359-98F5-7F9D7152629E}";
2627
} // namespace CsvSpawner

Gems/CsvSpawner/Code/Source/CsvSpawner/CsvSpawnerEditorComponent.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
*/
1010

1111
#include "CsvSpawnerEditorComponent.h"
12-
#include "AzCore/Debug/Trace.h"
1312
#include "CsvSpawnerComponent.h"
1413
#include "CsvSpawnerCsvParser.h"
1514
#include "CsvSpawnerUtils.h"
15+
#include <CsvSpawner/CsvSpawnerInterface.h>
1616

1717
#include <AzCore/Component/TransformBus.h>
18+
#include <AzCore/Debug/Trace.h>
1819
#include <AzCore/IO/Path/Path.h>
1920
#include <AzCore/Serialization/EditContext.h>
2021
#include <AzFramework/Physics/Common/PhysicsTypes.h>
2122
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
2223
#include <AzToolsFramework/Viewport/ViewportMessages.h>
23-
#include <thread>
2424

2525
namespace CsvSpawner
2626
{
@@ -63,6 +63,12 @@ namespace CsvSpawner
6363
->Attribute(AZ::Edit::Attributes::ChangeNotify, &CsvSpawnerEditorComponent::OnOnShowLabelsChanged);
6464
}
6565
}
66+
67+
if (const auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
68+
{
69+
behaviorContext->EBus<CsvSpawner::CsvSpawnerNotificationBus>("CsvSpawnerNotificationBus")
70+
->Handler<CsvSpawner::CsvSpawnerNotificationBusHandler>();
71+
}
6672
}
6773

6874
void CsvSpawnerEditorComponent::OnOnShowLabelsChanged()

0 commit comments

Comments
 (0)