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);
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
ASensor::ASensor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	/* Check if instantiation is real or just for placement guidlines */
	if (UObject::IsTemplate(RF_Transient)){
		return;
	}

//	UObject* something = StaticLoadObject(UObject::StaticClass(), NULL, TEXT("Blueprint'/Game/SensorNode.SensorNode'"));
//	UBlueprint* bp = Cast<UBlueprint>(something);
//	TSubclassOf<class UObject> MyItemBlueprint;
//	MyItemBlueprint = (UClass*)bp->GeneratedClass;
//	TSubclassOf<class UObject> MyItemBlueprint;
//	MyItemBlueprint = Cast<UClass>(blueprint->GeneratedClass);

	/* Find the blueprint of the 3D model */
	UBlueprint* blueprint = Cast<UBlueprint>(StaticLoadObject(UObject::StaticClass(), NULL, TEXT("Blueprint'/Game/SensorNode.SensorNode'")));
	TSubclassOf<class UObject> MyItemBlueprint = (UClass*)(blueprint->GeneratedClass);
	if (MyItemBlueprint != NULL) {
		UE_LOG(LogNet, Log, TEXT("BName: %s %s"), *(MyItemBlueprint->GetClass()->GetName()), *(this->GetActorLocation().ToString()));
	} else {
		UE_LOG(LogNet, Log, TEXT("I got nothing"));
	}

	/* Spawn the 3D model for the sensor in the virtual world */
	SensorActor = SpawnBP<AActor>(GetWorld(), MyItemBlueprint, this->GetActorLocation(), this->GetActorRotation());
	if(SensorActor) {
		UE_LOG(LogNet, Log, TEXT("SeName: %s"), *(SensorActor->GetName()));
		this->Children.Add(SensorActor);
		SensorActor->SetOwner(this);
		UE_LOG(LogNet, Log, TEXT("New Sensor: %s"), *(SensorActor->GetName()))
		/* Retrieve all the LEDS and turn them OFF */
		SensorActor->GetComponents(Leds);
		for (USpotLightComponent *l: Leds) {
			if (l == NULL) continue;
			UE_LOG(LogNet, Log, TEXT("%s owned by %s"), *(l->GetName()),
					*(l->GetOwner()->GetName()));
			l->SetIntensity(LEDOFF);
		}
	}
	else {
		UE_LOG(LogNet, Log, TEXT("SeName:Not spawned!"));
	}
//	AVirtual_CPS_WorldGameMode* gm = ((AVirtual_CPS_WorldGameMode*)GetWorld()->GetAuthGameMode());
//	if (gm)	ID = ((AVirtual_CPS_WorldGameMode*)GetWorld()->GetAuthGameMode())->getNewSensorID();

	/* Networking setup */
	sockSubSystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);
	socket = sockSubSystem->CreateSocket(NAME_DGram, TEXT("UDPCONN2"), true);
	if (socket) UE_LOG(LogNet, Log, TEXT("Created Socket"));
	socket->SetReceiveBufferSize(RecvSize, RecvSize);
	socket->SetSendBufferSize(SendSize, SendSize);


}
	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;
	}
Exemplo n.º 5
0
void FMemberReference::SetGivenSelfScope(const FName InMemberName, const FGuid InMemberGuid, TSubclassOf<class UObject> InMemberParentClass, TSubclassOf<class UObject> SelfScope) const
{
	MemberName = InMemberName;
	MemberGuid = InMemberGuid;
	MemberParentClass = (InMemberParentClass != nullptr) ? InMemberParentClass->GetAuthoritativeClass() : nullptr;
	MemberScope.Empty();
	bSelfContext = (SelfScope->IsChildOf(InMemberParentClass)) || (SelfScope->ClassGeneratedBy == InMemberParentClass->ClassGeneratedBy);
	bWasDeprecated = false;

	if (bSelfContext)
	{
		MemberParentClass = NULL;
	}
}
Exemplo n.º 6
0
void UThumbnailManager::RegisterCustomRenderer(UClass* Class, TSubclassOf<UThumbnailRenderer> RendererClass)
{
	check(Class != nullptr);
	check(*RendererClass != nullptr);

	const FString NewClassPathName = Class->GetPathName();

	// Verify that this class isn't already registered
	for (int32 Index = 0; Index < RenderableThumbnailTypes.Num(); ++Index)
	{
		if (ensure(RenderableThumbnailTypes[Index].ClassNeedingThumbnailName != NewClassPathName))
		{
		}
		else
		{
			return;
		}
	}

	// Register the new class
	FThumbnailRenderingInfo& Info = *(new (RenderableThumbnailTypes) FThumbnailRenderingInfo());
	Info.ClassNeedingThumbnailName = NewClassPathName;
	Info.ClassNeedingThumbnail = Class;
	Info.Renderer = NewObject<UThumbnailRenderer>(GetTransientPackage(), RendererClass);
	Info.RendererClassName = RendererClass->GetPathName();

	bMapNeedsUpdate = true;
}
Exemplo n.º 7
0
//------------------------------------------------------------------------------
static void BlueprintActionDatabaseImpl::GetNodeSpecificActions(TSubclassOf<UEdGraphNode const> const NodeClass, FBlueprintActionDatabaseRegistrar& Registrar)
{
	using namespace FBlueprintNodeSpawnerFactory; // for MakeCommentNodeSpawner()/MakeDocumentationNodeSpawner()

	if (NodeClass->IsChildOf<UK2Node>() && !NodeClass->HasAnyClassFlags(CLASS_Abstract))
	{
		UK2Node const* const NodeCDO = NodeClass->GetDefaultObject<UK2Node>();
		check(NodeCDO != nullptr);
		NodeCDO->GetMenuActions(Registrar);
	}
	// unfortunately, UEdGraphNode_Comment is not a UK2Node and therefore cannot
	// leverage UK2Node's GetMenuActions() function, so here we HACK it in
	//
	// @TODO: DO NOT follow this example! Do as I say, not as I do! If we need
	//        to support other nodes in a similar way, then we should come up
	//        with a better (more generalized) solution.
	else if (NodeClass == UEdGraphNode_Comment::StaticClass())
	{
		Registrar.AddBlueprintAction(MakeCommentNodeSpawner());
	}
	else if (NodeClass == UEdGraphNode_Documentation::StaticClass())
	{
		// @TODO: BOOOOOOO! (see comment above)
		Registrar.AddBlueprintAction(MakeDocumentationNodeSpawner<UEdGraphNode_Documentation>());
	}
}
Exemplo n.º 8
0
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();
}
Exemplo n.º 9
0
void FMemberReference::SetExternalMember(FName InMemberName, TSubclassOf<class UObject> InMemberParentClass)
{
	MemberName = InMemberName;
	MemberParentClass = (InMemberParentClass != nullptr) ? InMemberParentClass->GetAuthoritativeClass() : nullptr;
	MemberScope.Empty();
	bSelfContext = false;
	bWasDeprecated = false;
}
Exemplo n.º 10
0
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;
}
void FMemberReference::SetGivenSelfScope(const FName InMemberName, const FGuid InMemberGuid, TSubclassOf<class UObject> InMemberParentClass, TSubclassOf<class UObject> SelfScope) const
{
	MemberName = InMemberName;
	MemberGuid = InMemberGuid;
	MemberParent = (InMemberParentClass != nullptr) ? InMemberParentClass->GetAuthoritativeClass() : nullptr;
	MemberScope.Empty();

	// SelfScope should always be valid, but if it's not ensure and move on, the node will be treated as if it's not self scoped.
	ensure(SelfScope);
	bSelfContext = SelfScope && ((SelfScope->IsChildOf(InMemberParentClass)) || (SelfScope->ClassGeneratedBy == InMemberParentClass->ClassGeneratedBy));
	bWasDeprecated = false;

	if (bSelfContext)
	{
		MemberParent = NULL;
	}
}
Exemplo n.º 12
0
TArray<UClass*> FComponentAssetBrokerage::GetSupportedAssets(UClass* InFilterComponentClass)
{
	InitializeMap();

	TArray< UClass* > SupportedAssets;

	for (auto ComponentTypeIt = ComponentToBrokerMap.CreateIterator(); ComponentTypeIt; ++ComponentTypeIt)
	{
		TSubclassOf<UActorComponent> Component = ComponentTypeIt.Key();

		if(InFilterComponentClass == NULL || Component->IsChildOf(InFilterComponentClass))
		{
			SupportedAssets.Add(ComponentTypeIt.Value()->GetSupportedAssetClass());
		}
	}
	
	return SupportedAssets;
}
Exemplo n.º 13
0
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);
	}
}
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);
}
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));
	}
}
Exemplo n.º 16
0
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
	}
}
Exemplo n.º 17
0
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;
}
void UCameraModifier_CameraShake::RemoveCameraShake(TSubclassOf<class UCameraShake> Shake)
{
	for (int32 i = 0; i < ActiveShakes.Num(); ++i)
	{
		if (ActiveShakes[i].SourceShakeName == Shake->GetFName())
		{
			UCameraAnimInst* AnimInst = ActiveShakes[i].AnimInst;
			if ( (AnimInst != NULL) && !AnimInst->bFinished )
			{
				CameraOwner->StopCameraAnim(AnimInst, true);
			}

			ActiveShakes.RemoveAt(i,1);
			return;
		}
	}
}
//------------------------------------------------------------------------------
static FText BlueprintComponentNodeSpawnerImpl::GetDefaultMenuCategory(TSubclassOf<UActorComponent> const ComponentClass)
{
	FText ClassGroup;
	TArray<FString> ClassGroupNames;
	ComponentClass->GetClassGroupNames(ClassGroupNames);

	static FText const DefaultClassGroup(LOCTEXT("DefaultClassGroup", "Common"));
	// 'Common' takes priority over other class groups
	if (ClassGroupNames.Contains(DefaultClassGroup.ToString()) || (ClassGroupNames.Num() == 0))
	{
		ClassGroup = DefaultClassGroup;
	}
	else
	{
		ClassGroup = FText::FromString(ClassGroupNames[0]);
	}
	return FText::Format(LOCTEXT("ComponentCategory", "Add Component|{0}"), ClassGroup);
}
bool UGAEK2Node_LatentAbilityTaskCall::IsHandling(TSubclassOf<UGameplayTask> TaskClass) const
{
	bool isChilldOf = TaskClass && TaskClass->IsChildOf(UGASAbilityTask::StaticClass());
	return isChilldOf;
}
bool UK2Node_LatentAbilityCall::IsHandling(TSubclassOf<UGameplayTask> TaskClass) const
{
	return TaskClass && TaskClass->IsChildOf(UAbilityTask::StaticClass());
}
FCameraShakeInstance UCameraModifier_CameraShake::InitializeShake(TSubclassOf<class UCameraShake> NewShake, float Scale, ECameraAnimPlaySpace PlaySpace, FRotator UserPlaySpaceRot)
{
	FCameraShakeInstance Inst;
	Inst.SourceShakeName = NewShake->GetFName();

	// Create a camera shake object of class NewShake
	Inst.SourceShake = Cast<UCameraShake>(StaticConstructObject(NewShake, this));

	Inst.Scale = Scale;
	if (GEngine->IsSplitScreen(CameraOwner->GetWorld()))
	{
		Scale *= SplitScreenShakeScale;
	}

	// init oscillations
	if ( Inst.SourceShake->OscillationDuration != 0.f )
	{
		Inst.RotSinOffset.X		= InitializeOffset( Inst.SourceShake->RotOscillation.Pitch );
		Inst.RotSinOffset.Y		= InitializeOffset( Inst.SourceShake->RotOscillation.Yaw );
		Inst.RotSinOffset.Z		= InitializeOffset( Inst.SourceShake->RotOscillation.Roll );

		Inst.LocSinOffset.X		= InitializeOffset( Inst.SourceShake->LocOscillation.X );
		Inst.LocSinOffset.Y		= InitializeOffset( Inst.SourceShake->LocOscillation.Y );
		Inst.LocSinOffset.Z		= InitializeOffset( Inst.SourceShake->LocOscillation.Z );

		Inst.FOVSinOffset		= InitializeOffset( Inst.SourceShake->FOVOscillation );

		Inst.OscillatorTimeRemaining = Inst.SourceShake->OscillationDuration;

		if (Inst.SourceShake->OscillationBlendInTime > 0.f)
		{
			Inst.bBlendingIn = true;
			Inst.CurrentBlendInTime = 0.f;
		}
	}

	// init anims
	if (Inst.SourceShake->Anim != NULL)
	{
		bool bLoop = false;
		bool bRandomStart = false;
		float Duration = 0.f;
		if (Inst.SourceShake->bRandomAnimSegment)
		{
			bLoop = true;
			bRandomStart = true;
			Duration = Inst.SourceShake->RandomAnimSegmentDuration;
		}

		if (Scale > 0.f)
		{
			Inst.AnimInst = CameraOwner->PlayCameraAnim(Inst.SourceShake->Anim, Inst.SourceShake->AnimPlayRate, Scale, Inst.SourceShake->AnimBlendInTime, Inst.SourceShake->AnimBlendOutTime, bLoop, bRandomStart, Duration, Inst.SourceShake->bSingleInstance);
			if (PlaySpace != CAPS_CameraLocal && Inst.AnimInst != NULL)
			{
				Inst.AnimInst->SetPlaySpace(PlaySpace, UserPlaySpaceRot);
			}
		}
	}

	Inst.PlaySpace = PlaySpace;
	if (Inst.PlaySpace == CAPS_UserDefined)
	{
		Inst.UserPlaySpaceMatrix = FRotationMatrix(UserPlaySpaceRot);
	}

	return Inst;
}
Exemplo n.º 23
0
void AAIController::ClaimTaskResource(TSubclassOf<UGameplayTaskResource> ResourceClass)
{
    if (CachedGameplayTasksComponent)
    {
        const uint8 ResourceID = UGameplayTaskResource::GetResourceID(ResourceClass);
        if (ScriptClaimedResources.HasID(ResourceID) == false)
        {
            ScriptClaimedResources.AddID(ResourceID);

            UE_VLOG(this, LogGameplayTasks, Log, TEXT("ClaimTaskResource %s"), *GetNameSafe(*ResourceClass));

            IGameplayTaskOwnerInterface& AsTaskOwner = *this;
            UGameplayTask_ClaimResource* ResourceTask = UGameplayTask_ClaimResource::ClaimResource(AsTaskOwner, ResourceClass, uint8(EAITaskPriority::High), ResourceClass->GetFName());
            if (ResourceTask)
            {
                CachedGameplayTasksComponent->AddTaskReadyForActivation(*ResourceTask);
            }
            UE_CVLOG(ResourceTask == nullptr, this, LogGameplayTasks, Warning, TEXT("ClaimTaskResource failed to create UGameplayTask_ClaimResource instance"));
        }
    }
}
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)
		{
			BulletsLeft_B--;
		}
		break;
	case 2:
		if (BulletsLeft_C > 0)
		{
			BulletsLeft_C--;
		}
		break;

	default:
		break;
	}

	if (BulletsLeft_A == 0 && CurrentBulletEquipped == 0)
	{
		PlayerAnimationInstance->bCanShoot = false;
	}
	else if (BulletsLeft_B == 0 && CurrentBulletEquipped == 1)
	{
		PlayerAnimationInstance->bCanShoot = false;
	}
	else if (BulletsLeft_C == 0 && CurrentBulletEquipped == 2)
	{
		PlayerAnimationInstance->bCanShoot = false;
	}

	PlayerController->UpdateUI();
}
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);
}
Exemplo n.º 26
0
/**
 *	Transforms CurveTable data into format more effecient to read at runtime.
 *	UCurveTable requires string parsing to map to GroupName/AttributeSet/Attribute
 *	Each curve in the table represents a *single attribute's values for all levels*.
 *	At runtime, we want *all attribute values at given level*.
 */
void FAttributeSetInitter::PreloadAttributeSetData(UCurveTable* CurveData)
{
	if(!ensure(CurveData))
	{
		return;
	}

	/**
	 *	Get list of AttributeSet classes loaded
	 */

	TArray<TSubclassOf<UAttributeSet> >	ClassList;
	for (TObjectIterator<UClass> ClassIt; ClassIt; ++ClassIt)
	{
		UClass* TestClass = *ClassIt;
		if (TestClass->IsChildOf(UAttributeSet::StaticClass()))
		{
			ClassList.Add(TestClass);
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
			// This can only work right now on POD attribute sets. If we ever support FStrings or TArrays in AttributeSets
			// we will need to update this code to not use memcpy etc.
			for (TFieldIterator<UProperty> PropIt(TestClass, EFieldIteratorFlags::IncludeSuper); PropIt; ++PropIt)
			{
				if (!PropIt->HasAllPropertyFlags(CPF_IsPlainOldData))
				{
					ABILITY_LOG(Error, TEXT("FAttributeSetInitter::PreloadAttributeSetData Unable to Handle AttributeClass %s because it has a non POD property: %s"),
						*TestClass->GetName(), *PropIt->GetName());
					return;
				}
			}
#endif
		}
	}

	/**
	 *	Loop through CurveData table and build sets of Defaults that keyed off of Name + Level
	 */

	for (auto It = CurveData->RowMap.CreateConstIterator(); It; ++It)
	{
		FString RowName = It.Key().ToString();
		FString ClassName;
		FString SetName;
		FString AttributeName;
		FString Temp;

		RowName.Split(TEXT("."), &ClassName, &Temp);
		Temp.Split(TEXT("."), &SetName, &AttributeName);

		if (!ensure(!ClassName.IsEmpty() && !SetName.IsEmpty() && !AttributeName.IsEmpty()))
		{
			ABILITY_LOG(Verbose, TEXT("FAttributeSetInitter::PreloadAttributeSetData Unable to parse row %s in %s"), *RowName, *CurveData->GetName());
			continue;
		}

		// Find the AttributeSet

		TSubclassOf<UAttributeSet> Set = FindBestAttributeClass(ClassList, SetName);
		if (!Set)
		{
			// This is ok, we may have rows in here that don't correspond directly to attributes
			ABILITY_LOG(Verbose, TEXT("FAttributeSetInitter::PreloadAttributeSetData Unable to match AttributeSet from %s (row: %s)"), *SetName, *RowName);
			continue;
		}

		// Find the UProperty

		UNumericProperty* Property = FindField<UNumericProperty>(*Set, *AttributeName);
		if (!Property)
		{
			ABILITY_LOG(Verbose, TEXT("FAttributeSetInitter::PreloadAttributeSetData Unable to match Attribute from %s (row: %s)"), *AttributeName, *RowName);
			continue;
		}

		FRichCurve* Curve = It.Value();
		FName ClassFName = FName(*ClassName);
		FAttributeSetDefaulsCollection& DefaultCollection = Defaults.FindOrAdd(ClassFName);

		int32 LastLevel = Curve->GetLastKey().Time;
		DefaultCollection.LevelData.SetNum(FMath::Max(LastLevel, DefaultCollection.LevelData.Num()));

		
		//At this point we know the Name of this "class"/"group", the AttributeSet, and the Property Name. Now loop through the values on the curve to get the attribute default value at each level.
		for (auto KeyIter = Curve->GetKeyIterator(); KeyIter; ++KeyIter)
		{
			const FRichCurveKey& CurveKey = *KeyIter;

			int32 Level = CurveKey.Time;
			float Value = CurveKey.Value;

			FAttributeSetDefaults& SetDefaults = DefaultCollection.LevelData[Level-1];

			FAttributeDefaultValueList* DefaultDataList = SetDefaults.DataMap.Find(Set);
			if (DefaultDataList == nullptr)
			{
				ABILITY_LOG(Verbose, TEXT("Initializing new default set for %s[%d]. PropertySize: %d.. DefaultSize: %d"), *Set->GetName(), Level, Set->GetPropertiesSize(), UAttributeSet::StaticClass()->GetPropertiesSize());
				
				DefaultDataList = &SetDefaults.DataMap.Add(Set);
			}

			// Import curve value into default data

			check(DefaultDataList);
			DefaultDataList->AddPair(Property, Value);
		}


	}
}
Exemplo n.º 27
0
void AAIController::UnclaimTaskResource(TSubclassOf<UGameplayTaskResource> ResourceClass)
{
    if (CachedGameplayTasksComponent)
    {
        const uint8 ResourceID = UGameplayTaskResource::GetResourceID(ResourceClass);
        if (ScriptClaimedResources.HasID(ResourceID) == true)
        {
            ScriptClaimedResources.RemoveID(ResourceID);

            UE_VLOG(this, LogGameplayTasks, Log, TEXT("UnclaimTaskResource %s"), *GetNameSafe(*ResourceClass));

            UGameplayTask* ResourceTask = CachedGameplayTasksComponent->FindResourceConsumingTaskByName(ResourceClass->GetFName());
            if (ResourceTask)
            {
                ResourceTask->EndTask();
            }
            UE_CVLOG(ResourceTask == nullptr, this, LogGameplayTasks, Warning, TEXT("UnclaimTaskResource failed to find UGameplayTask_ClaimResource instance"));
        }
    }
}