Skip to content

Commit

Permalink
Input & Ability Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
StellarWarp committed Dec 2, 2023
1 parent 7a99278 commit 4d47ddd
Show file tree
Hide file tree
Showing 13 changed files with 4,778 additions and 3,668 deletions.
1,904 changes: 1,211 additions & 693 deletions Build/Windows/FileOpenOrder/CookerOpenOrder.log

Large diffs are not rendered by default.

6,491 changes: 3,530 additions & 2,961 deletions Build/Windows/FileOpenOrder/EditorOpenOrder.log

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Config/DefaultEngine.ini
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ ManualIPAddress=
+FunctionRedirects=(OldName="/Script/Cubeization.WorldDynamicTerrainControlSubsystem.SetCurrentPage",NewName="/Script/Cubeization.WorldDynamicTerrainControlSubsystem.InitCurrentPage")
+FunctionRedirects=(OldName="/Script/Cubeization.WorldDynamicTerrainControlSubsystem.InitPage",NewName="/Script/Cubeization.WorldDynamicTerrainControlSubsystem.AddPage")
+PropertyRedirects=(OldName="/Script/Cubeization.PageSetting.CurrentPage",NewName="/Script/Cubeization.PageSetting.StartPage")
+PropertyRedirects=(OldName="/Script/Cubeization.WeaponHitInfo.NormalImpulse",NewName="/Script/Cubeization.WeaponHitInfo.Impulse")

[/Script/Engine.UserInterfaceSettings]
RenderFocusRule=NavigationOnly
Expand Down
1 change: 1 addition & 0 deletions Config/DefaultGameplayTags.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ NetIndexFirstBitSegment=16
+GameplayTagList=(Tag="Ability",DevComment="")
+GameplayTagList=(Tag="Ability.Fire",DevComment="")
+GameplayTagList=(Tag="Ability.Weapon",DevComment="")
+GameplayTagList=(Tag="Ability.WeaponActivated",DevComment="")
Binary file modified Content/AbilitySystem/GA_Fire.uasset
Binary file not shown.
Binary file modified Content/Chaos/Projectile_ForceField.uasset
Binary file not shown.
Binary file modified Content/Maps/NewWorld.umap
Binary file not shown.
Binary file modified Content/ThirdPerson/Input/IMC_Default.uasset
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@ void UGameplayAbility_Weapon::ActivateAbility(const FGameplayAbilitySpecHandle H
const FGameplayAbilityActivationInfo ActivationInfo,
const FGameplayEventData* TriggerEventData)
{
//todo hack method remove this
float Time = GetWorld()->GetTimeSeconds();
if (!CommitAbility(Handle, ActorInfo, ActivationInfo) || Time - LastFireTime < FireInterval)
if (!CommitAbility(Handle, ActorInfo, ActivationInfo))
{
EndAbility(CurrentSpecHandle, CurrentActorInfo, CurrentActivationInfo, true, true);
return;
}
LastFireTime = Time;
//log LastFireTime and time

//direct raycast and spawn effect and damage

auto Actor = ActorInfo->AvatarActor.Get();
auto World = Actor->GetWorld();

FVector StartLocation = Actor->GetActorLocation();
FVector Direction = Actor->GetActorForwardVector();

FHitResult HitResult;
World->LineTraceSingleByChannel(HitResult,
Actor->GetActorLocation(),
Actor->GetActorLocation() + Actor->GetActorForwardVector() * 10000,
StartLocation,
StartLocation + Direction * 10000,
ECollisionChannel::ECC_Visibility,
FCollisionQueryParams::DefaultQueryParam,
FCollisionResponseParams::DefaultResponseParam);
Expand All @@ -42,7 +43,7 @@ void UGameplayAbility_Weapon::ActivateAbility(const FGameplayAbilitySpecHandle H
{
UNiagaraFunctionLibrary::SpawnSystemAtLocation(World, HitNiagaraEffect, HitResult.Location);
auto Trail = UNiagaraFunctionLibrary::SpawnSystemAtLocation(World, TrailNiagaraEffect,
Actor->GetActorLocation(),
StartLocation,
Actor->GetActorRotation());
Trail->SetFloatParameter(L"Length", HitResult.Distance);
}
Expand All @@ -56,10 +57,11 @@ void UGameplayAbility_Weapon::ActivateAbility(const FGameplayAbilitySpecHandle H
return;
}

//call cpp only
WeaponRespond->NotifyWeaponHit_Implementation({
HitResult.Location,
HitResult.ImpactNormal,
HitResult.ImpactNormal, //impose,
Direction * ImpulseMultiplier,
HitResult,
});

Expand Down Expand Up @@ -94,5 +96,14 @@ void UGameplayAbility_Weapon::ActivateAbility(const FGameplayAbilitySpecHandle H
// UGameplayStatics::SpawnEmitterAtLocation(ActorInfo->AvatarActor->GetWorld(), Effect, HitResult.ImpactPoint);


Super::ActivateAbility(Handle, ActorInfo, ActivationInfo, TriggerEventData);

// Super::ActivateAbility(Handle, ActorInfo, ActivationInfo, TriggerEventData);

//delay end ability
FTimerHandle TimerHandle;
World->GetTimerManager().SetTimer(TimerHandle, [this]()
{
EndAbility(CurrentSpecHandle, CurrentActorInfo, CurrentActivationInfo, true, true);
}, FireInterval, false);

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ class UGameplayAbility_Weapon: public UGameplayAbility
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GameplayAbility")
TObjectPtr<class UNiagaraSystem> TrailNiagaraEffect;

//hack
float LastFireTime = 0;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GameplayAbility")
float FireInterval = 0.5f;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GameplayAbility")
int ImpulseMultiplier = 1000;


virtual void ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ void UTerrainRepresentationSubsystem::Initialize(FSubsystemCollectionBase& Colle
Collection.InitializeDependency(UTerrainDataSubsystem::StaticClass());

Super::Initialize(Collection);

TerrainDataSubsystem = GetWorld()->GetSubsystem<UTerrainDataSubsystem>();

}

void UTerrainRepresentationSubsystem::Deinitialize()
Expand All @@ -28,7 +31,6 @@ void UTerrainRepresentationSubsystem::Tick(float DeltaTime)

void UTerrainRepresentationSubsystem::NotifyDestruction(FWeaponHitInfo Info)
{
auto TerrainDataSubsystem = GetWorld()->GetSubsystem<UTerrainDataSubsystem>();

FVector InnerPosition = Info.HitLocation - Info.HitNormal * 0.5f * TerrainDataSubsystem->CubeLength;

Expand All @@ -38,12 +40,16 @@ void UTerrainRepresentationSubsystem::NotifyDestruction(FWeaponHitInfo Info)
FIntVector2 CubeIndex = TerrainDataSubsystem->WorldPositionToLogicalIndex(InnerPosition);

DeferredReplacementQueue.Enqueue({CubeIndex, Info.HitLocation});

TerrainDataSubsystem->ApplyForce(
Info.HitLocation,
Info.Impulse.Z,
3);
}


void UTerrainRepresentationSubsystem::DeferredInstanceUpdate(UInstancedStaticMeshComponent* ISMC)
{
auto TerrainDataSubsystem = GetWorld()->GetSubsystem<UTerrainDataSubsystem>();

auto& InstanceTransforms = ISMC->PerInstanceSMData;
auto& InstanceBodies = ISMC->InstanceBodies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class CUBEIZATION_API UTerrainRepresentationSubsystem : public UTickableWorldSub

TQueue<DeferredReplacementParams> DeferredReplacementQueue;

//initialize in Initialize
class UTerrainDataSubsystem* TerrainDataSubsystem;

public:

virtual bool ShouldCreateSubsystem(UObject* Outer) const override { return true; }
Expand Down
2 changes: 1 addition & 1 deletion Source/Cubeization/Weapons/WeaponRespond.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct FWeaponHitInfo
FVector HitNormal;

UPROPERTY()
FVector NormalImpulse;
FVector Impulse;

UPROPERTY()
FHitResult HitResult;
Expand Down

0 comments on commit 4d47ddd

Please sign in to comment.