本文整理汇总了C++中TSubclassOf::GetDefaultObject方法的典型用法代码示例。如果您正苦于以下问题:C++ TSubclassOf::GetDefaultObject方法的具体用法?C++ TSubclassOf::GetDefaultObject怎么用?C++ TSubclassOf::GetDefaultObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSubclassOf
的用法示例。
在下文中一共展示了TSubclassOf::GetDefaultObject方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ApplyEffectSpec
FGAEffectHandle UGABlueprintLibrary::ApplyEffectSpec(const FHitResult& Target, APawn* Instigator,
UObject* Causer, TSubclassOf<class UGAEffectSpecification> SpecIn)
{
FGAEffectHandle ReturnHandle;
IIGAAttributes* targetAttr = Cast<IIGAAttributes>(Target.Actor.Get());
IIGAAttributes* instiAttr = Cast<IIGAAttributes>(Instigator);
if (!targetAttr || !instiAttr)
return ReturnHandle;
UGAAttributeComponent* targetComp = targetAttr->GetAttributeComponent();
UGAAttributeComponent* instiComp = instiAttr->GetAttributeComponent();
FGAEffectContext context(Target.Location, Target.Actor, Causer,
Instigator, targetComp, instiComp);
FName EffectName;
if (SpecIn.GetDefaultObject()->Policy.Type != EGAEffectType::Instant)
{
if (SpecIn.GetDefaultObject()->EffectName.CustomName)
EffectName = SpecIn.GetDefaultObject()->EffectName.EffectName;
else
EffectName = SpecIn->GetFName();// Causer->GetClass()->GetFName();
}
ReturnHandle = instiComp->ApplyEffectToTarget(SpecIn, context, EffectName);
return ReturnHandle;
}
示例2: SpawnVariableGetNode
UK2Node_VariableGet* UGameplayAbilityGraphSchema::SpawnVariableGetNode(const FVector2D GraphPosition, class UEdGraph* ParentGraph, FName VariableName, UStruct* Source) const
{
// Perform handling to create custom nodes for some classes
UProperty* VarProp = FindField<UProperty>(Source, VariableName);
UObjectProperty* ObjProp = Cast<UObjectProperty>(VarProp);
if (ObjProp)
{
UBlueprint* Blueprint = FBlueprintEditorUtils::FindBlueprintForGraph(ParentGraph);
TSubclassOf<UObject> GenClass = Blueprint->GeneratedClass;
UObject* ActiveObject = GenClass->GetDefaultObject();
// If the variable is a GameplayEffect create a custom node to show it
FString PropType;
ObjProp->GetCPPMacroType(PropType);
if (PropType == "UGameplayEffect")
{
UK2Node_GameplayEffectVariable* NodeTemplate = NewObject<UK2Node_GameplayEffectVariable>();
UEdGraphSchema_K2::ConfigureVarNode(NodeTemplate, VariableName, Source, Blueprint);
UK2Node_GameplayEffectVariable* VariableNode = FEdGraphSchemaAction_K2NewNode::SpawnNodeFromTemplate<UK2Node_GameplayEffectVariable>(ParentGraph, NodeTemplate, GraphPosition);
UGameplayEffect* GameplayEffect = Cast<UGameplayEffect>(ObjProp->GetObjectPropertyValue_InContainer(ActiveObject));
if (GameplayEffect)
{
VariableNode->GameplayEffect = GameplayEffect;
}
return VariableNode;
}
}
// Couldn't find an appropriate custom node for this variable, use the generic case
return Super::SpawnVariableGetNode(GraphPosition, ParentGraph, VariableName, Source);
}
示例3: ApplyEffect
FGAEffectHandle FGAActiveEffectContainer::ApplyEffect(TSubclassOf<class UGAEffectSpecification> SpecIn,
const FGAEffectContext& Ctx, const FName& EffectName)
{
if (!SpecIn)
return FGAEffectHandle();
FGAEffectSpec spec(SpecIn.GetDefaultObject(), Ctx);
spec.EffectName.EffectName = EffectName;
switch (spec.Policy.Type)
{
case EGAEffectType::Instant:
{
FGAEffectInstant instntEffect(spec, Ctx);
return HandleInstantEffect(instntEffect, Ctx);
}
case EGAEffectType::Periodic:
{
return HandleDurationEffect(spec, Ctx);
}
case EGAEffectType::Duration:
{
return HandleDurationEffect(spec, Ctx);
}
case EGAEffectType::Infinite:
{
break;
}
default:
{
return FGAEffectHandle();
}
}
return FGAEffectHandle();
}
示例4: MakeGameEffect
FGAGameEffectHandle UGAAttributeComponent::MakeGameEffect(TSubclassOf<class UGAGameEffectSpec> SpecIn,
const FGAEffectContext& ContextIn)
{
FGAGameEffect* effect = new FGAGameEffect(SpecIn.GetDefaultObject(), ContextIn);
FGAGameEffectHandle handle = FGAGameEffectHandle::GenerateHandle(effect);
effect->Handle = &handle;
return handle;
}
示例5: GetUIRecipeForMod
void AMod::GetUIRecipeForMod(TSubclassOf<AMod> modClass, TArray<TSubclassOf<AMod> >& recipeArray)
{
AMod* defaultMod = Cast<AMod>(modClass->GetDefaultObject());
if (IsValid(defaultMod))
{
for (TSubclassOf<AMod> recipeItem : defaultMod->recipe)
recipeArray.Add(recipeItem);
}
}
示例6: ExtractLocation
FVector ExtractLocation(TSubclassOf<UEnvQueryItemType> ItemType, const TArray<uint8>& RawData, const TArray<FEnvQueryItem>& Items, int32 Index)
{
if (Items.IsValidIndex(Index) &&
ItemType->IsChildOf(UEnvQueryItemType_VectorBase::StaticClass()))
{
UEnvQueryItemType_VectorBase* DefTypeOb = (UEnvQueryItemType_VectorBase*)ItemType->GetDefaultObject();
return DefTypeOb->GetItemLocation(RawData.GetData() + Items[Index].DataOffset);
}
return FVector::ZeroVector;
}
示例7: FHTNTaskInstance
TSharedPtr<FHTNTaskInstance> UHTNPlannerComponent::InstantiateTask(const TSubclassOf<UHTNTask>& TaskClass)
{
if(*TaskClass)
{
UHTNTask* TaskCDO = Cast<UHTNTask>(TaskClass->GetDefaultObject());
TSharedPtr<FHTNTaskInstance> NewInstance = TSharedPtr<FHTNTaskInstance>(new FHTNTaskInstance(TaskCDO, TaskCDO->GetInstanceMemorySize()));
NewInstance->Task->Instantiate(*this, NewInstance->GetMemory());
return NewInstance;
}
return TSharedPtr<FHTNTaskInstance>(nullptr);
}
示例8: CopyFrom
void UNavArea::CopyFrom(TSubclassOf<UNavArea> AreaClass)
{
if (AreaClass)
{
UNavArea* DefArea = (UNavArea*)AreaClass->GetDefaultObject();
DefaultCost = DefArea->DefaultCost;
FixedAreaEnteringCost = DefArea->GetFixedAreaEnteringCost();
AreaFlags = DefArea->GetAreaFlags();
DrawColor = DefArea->DrawColor;
// don't copy supported agents bits
}
}
示例9: GetUIRecipeCost
int32 AMod::GetUIRecipeCost(TSubclassOf<AMod> modClass)
{
int32 cost = 0;
AMod* defaultMod = Cast<AMod>(modClass->GetDefaultObject());
if (IsValid(defaultMod))
{
cost = defaultMod->GetCost(false);
for (TSubclassOf<AMod> recipeItem : defaultMod->recipe)
{
AMod* recipeMod = Cast<AMod>(recipeItem->GetDefaultObject());
if (IsValid(recipeMod))
cost -= recipeMod->GetCost(false);
}
}
return cost;
}
示例10: AddCameraShake
void UCameraModifier_CameraShake::AddCameraShake( TSubclassOf<class UCameraShake> NewShake, float Scale, ECameraAnimPlaySpace PlaySpace, FRotator UserPlaySpaceRot )
{
if (NewShake != NULL)
{
if (Cast<UCameraShake>(NewShake->GetDefaultObject())->bSingleInstance)
{
for (int32 i = 0; i < ActiveShakes.Num(); ++i)
{
if (ActiveShakes[i].SourceShakeName == NewShake->GetFName())
{
ReinitShake(i, Scale);
return;
}
}
}
int32 NumShakes = ActiveShakes.Num();
// Initialize new shake and add it to the list of active shakes
ActiveShakes.Add(InitializeShake(NewShake, Scale, PlaySpace, UserPlaySpaceRot));
}
}
示例11: BeginSpawningActor
bool UAbilityTask_WaitTargetData::BeginSpawningActor(UObject* WorldContextObject, TSubclassOf<AGameplayAbilityTargetActor> TargetClass, AGameplayAbilityTargetActor*& SpawnedActor)
{
SpawnedActor = nullptr;
UGameplayAbility* MyAbility = Ability.Get();
if (MyAbility)
{
const AGameplayAbilityTargetActor* CDO = CastChecked<AGameplayAbilityTargetActor>(TargetClass->GetDefaultObject());
MyTargetActor = CDO;
bool Replicates = CDO->GetReplicates();
bool StaticFunc = CDO->StaticTargetFunction;
bool IsLocallyControlled = MyAbility->GetCurrentActorInfo()->IsLocallyControlled();
if (Replicates && StaticFunc)
{
// We can't replicate a staticFunc target actor, since we are just calling a static function and not spawning an actor at all!
ABILITY_LOG(Fatal, TEXT("AbilityTargetActor class %s can't be Replicating and Static"), *TargetClass->GetName());
Replicates = false;
}
// Spawn the actor if this is a locally controlled ability (always) or if this is a replicating targeting mode.
// (E.g., server will spawn this target actor to replicate to all non owning clients)
if (Replicates || IsLocallyControlled || CDO->ShouldProduceTargetDataOnServer)
{
if (StaticFunc)
{
// This is just a static function that should instantly give us back target data
FGameplayAbilityTargetDataHandle Data = CDO->StaticGetTargetData(MyAbility->GetWorld(), MyAbility->GetCurrentActorInfo(), MyAbility->GetCurrentActivationInfo());
OnTargetDataReadyCallback(Data);
}
else
{
UClass* Class = *TargetClass;
if (Class != NULL)
{
UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject);
SpawnedActor = World->SpawnActorDeferred<AGameplayAbilityTargetActor>(Class, FVector::ZeroVector, FRotator::ZeroRotator, NULL, NULL, true);
}
// If we spawned the target actor, always register the callbacks for when the data is ready.
SpawnedActor->TargetDataReadyDelegate.AddUObject(this, &UAbilityTask_WaitTargetData::OnTargetDataReadyCallback);
SpawnedActor->CanceledDelegate.AddUObject(this, &UAbilityTask_WaitTargetData::OnTargetDataCancelledCallback);
MyTargetActor = SpawnedActor;
AGameplayAbilityTargetActor* TargetActor = CastChecked<AGameplayAbilityTargetActor>(SpawnedActor);
if (TargetActor)
{
TargetActor->MasterPC = MyAbility->GetCurrentActorInfo()->PlayerController.Get();
}
}
}
// If not locally controlled (server for remote client), see if TargetData was already sent
// else register callback for when it does get here.
if (!IsLocallyControlled)
{
// Register with the TargetData callbacks if we are expecting client to send them
if (!CDO->ShouldProduceTargetDataOnServer)
{
// Problem here - if there's targeting data just sitting around, fire events don't get hooked up because of this if-else, even if we don't end the task.
if (AbilitySystemComponent->ReplicatedTargetData.IsValid(0))
{
ValidData.Broadcast(AbilitySystemComponent->ReplicatedTargetData);
if (ConfirmationType == EGameplayTargetingConfirmation::CustomMulti)
{
//Since multifire is supported, we still need to hook up the callbacks
OnTargetDataReplicatedCallbackDelegateHandle = AbilitySystemComponent->ReplicatedTargetDataDelegate.AddUObject(this, &UAbilityTask_WaitTargetData::OnTargetDataReplicatedCallback);
AbilitySystemComponent->ReplicatedTargetDataCancelledDelegate.AddDynamic(this, &UAbilityTask_WaitTargetData::OnTargetDataReplicatedCancelledCallback);
}
else
{
EndTask();
}
}
else
{
OnTargetDataReplicatedCallbackDelegateHandle = AbilitySystemComponent->ReplicatedTargetDataDelegate.AddUObject(this, &UAbilityTask_WaitTargetData::OnTargetDataReplicatedCallback);
AbilitySystemComponent->ReplicatedTargetDataCancelledDelegate.AddDynamic(this, &UAbilityTask_WaitTargetData::OnTargetDataReplicatedCancelledCallback);
}
}
}
}
return (SpawnedActor != nullptr);
}
示例12: ShootABullet
void ARoguelikeChar::ShootABullet()
{
FHitResult Hit;
FCollisionQueryParams ColParams = FCollisionQueryParams(FName("Tsirla"), false, GetOwner());
ColParams.AddIgnoredActor(GetOwner());
ColParams.AddIgnoredActor(this);
FVector Origin = LaserSource->GetComponentLocation();
FVector ForwardVector = PlayerCamera->GetForwardVector();
FVector Destination = Origin + (ForwardVector * 5000);
PlayerController->ClientPlayCameraShake(OurShake, ShakePower);
if (GetWorld()->LineTraceSingleByChannel(Hit, Origin, Destination, ECollisionChannel::ECC_WorldDynamic, ColParams))
{
AZombieCharacter* Zombie = Cast<AZombieCharacter>(Hit.GetActor());
if (Zombie)
{
TSubclassOf<UDamageType> const ValidDamageTypeClass = TSubclassOf<UDamageType>(UPlayerDamageType::StaticClass());
//Determine the effect that will be applied to the zombie based on currently equipped ammo
UPlayerDamageType* DamageType = Cast<UPlayerDamageType>(ValidDamageTypeClass.GetDefaultObject());
switch (CurrentBulletEquipped)
{
case 1:
{
DamageType->PlayerDamageType = EPlayerDamageType::Dot;
break;
}
case 2:
{
DamageType->PlayerDamageType = EPlayerDamageType::Slow;
break;
}
default:
{
DamageType->PlayerDamageType = EPlayerDamageType::Standard;
break;
}
}
FDamageEvent DamageEvent(ValidDamageTypeClass);
float DamageAmount = CalculateBulletDamage(CurrentBulletEquipped);
Zombie->TakeDamage(DamageAmount, DamageEvent, Zombie->GetController(), this);
/*if (Zombie->IsDead())
{
Kills++;
PlayerController->UpdateUI();
}*/
}
//if (Hit.Actor != GetOwner())
//{
// if (Hit.Component->ComponentHasTag("Zombie"))
// {
// TArray<USkeletalMeshComponent*> SkeletalMeshes;
// Hit.GetActor()->GetComponents<USkeletalMeshComponent>(SkeletalMeshes);
// UZombieAnimInstance* EnemyAnimInstance = Cast<UZombieAnimInstance>(SkeletalMeshes[0]->GetAnimInstance());
// if (!EnemyAnimInstance->bIsDead)
// {
// float DamageToDo = CalculateBulletDamage(CurrentBulletEquipped);
// // TO BE REMOVED AFTER ORFEUS COMPLETES ZOMBIE CRAP.
// TestHits++;
// if (TestHits > 3)
// {
// EnemyAnimInstance->bIsDead = true;
// Kills++;
// PlayerController->UpdateUI();
// }
// else
// {
// EnemyAnimInstance->GetHurt();
// }
// }
// }
//}
}
switch (CurrentBulletEquipped)
{
case 0:
if (BulletsLeft_A > 0)
{
BulletsLeft_A--;
}
break;
case 1:
if (BulletsLeft_B > 0)
//.........这里部分代码省略.........