45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
// Copyright 2016 Mookie. All Rights Reserved.
|
|
|
|
#include "EBGunActorFactory.h"
|
|
#include "EBGun.h"
|
|
#include "EBWeaponData.h"
|
|
#include "Engine/Selection.h"
|
|
#include "Editor.h"
|
|
|
|
UEBGunActorFactory::UEBGunActorFactory()
|
|
{
|
|
DisplayName = NSLOCTEXT("EasyBallistics", "GunDisplayName", "EasyBallistics Gun");
|
|
NewActorClass = AEBGun::StaticClass();
|
|
bUsePlacementExtent = true;
|
|
}
|
|
|
|
bool UEBGunActorFactory::CanCreateActorFrom(const FAssetData& AssetData, FText& OutErrorMsg)
|
|
{
|
|
if (AssetData.IsValid())
|
|
{
|
|
UClass* AssetClass = AssetData.GetClass();
|
|
if (AssetClass && AssetClass->IsChildOf(UEBWeaponData::StaticClass()))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return Super::CanCreateActorFrom(AssetData, OutErrorMsg);
|
|
}
|
|
|
|
AActor* UEBGunActorFactory::SpawnActor(UObject* InAsset, ULevel* InLevel, const FTransform& InTransform, const FActorSpawnParameters& InSpawnParams)
|
|
{
|
|
AEBGun* NewGun = Cast<AEBGun>(Super::SpawnActor(InAsset, InLevel, InTransform, InSpawnParams));
|
|
|
|
if (NewGun)
|
|
{
|
|
// If spawned from a weapon configuration asset, apply it
|
|
if (UEBWeaponData* WeaponData = Cast<UEBWeaponData>(InAsset))
|
|
{
|
|
NewGun->WeaponData = WeaponData;
|
|
NewGun->ApplyWeaponData(WeaponData);
|
|
}
|
|
}
|
|
|
|
return NewGun;
|
|
}
|