-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/Anomaly: 귀신 손 이상현상 및 불태우기 나이아가라 #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
87c719b
c370960
ead8727
c6094aa
83d07aa
21aabdf
d4d6282
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 전반적으로 플레이어 캐릭터나 플레이어 컨트롤러를 들고와서 많이 쓰는데 멤버 변수로 캐싱하여 사용하는 것이 더 효율적으로 보입니다
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 확인했습니다. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| // Copyright by 2025-2 WAP Game 2 team | ||
|
|
||
|
|
||
| #include "Anomaly/EightExit/GhostHand/Anomaly_GhostHand.h" | ||
| #include "Components/StaticMeshComponent.h" | ||
| #include "Kismet/GameplayStatics.h" | ||
| #include "GameFramework/Character.h" | ||
| #include "Components/SkeletalMeshComponent.h" | ||
| #include "GameFramework/CharacterMovementComponent.h" | ||
| #include "Player/Controller/EHPlayerController.h" | ||
| #include "TimerManager.h" | ||
ssiver6324 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| #pragma region Base | ||
|
|
||
| AAnomaly_GhostHand::AAnomaly_GhostHand(const FObjectInitializer& ObjectInitializer) | ||
| : Super(ObjectInitializer) | ||
| { | ||
| PrimaryActorTick.bCanEverTick = false; | ||
ssiver6324 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| SM_Hand = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("SM_Hand")); | ||
| SM_Hand->SetupAttachment(RootComponent); | ||
| SM_Hand->SetVisibility(false); | ||
| SM_Hand->SetHiddenInGame(true); | ||
| SM_Hand->SetCollisionEnabled(ECollisionEnabled::NoCollision); | ||
| } | ||
|
|
||
| void AAnomaly_GhostHand::BeginPlay() | ||
| { | ||
| Super::BeginPlay(); | ||
| } | ||
ssiver6324 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| void AAnomaly_GhostHand::EndPlay(const EEndPlayReason::Type EndPlayReason) | ||
| { | ||
| ClearRunLock(); | ||
| Super::EndPlay(EndPlayReason); | ||
| } | ||
| #pragma endregion | ||
|
|
||
| #pragma region Activity | ||
| void AAnomaly_GhostHand::ActivateAnomaly(uint8 Anomaly_ID) | ||
| { | ||
| Super::ActivateAnomaly(Anomaly_ID); | ||
| ExecuteGhostHand(); | ||
| } | ||
ssiver6324 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #pragma endregion | ||
|
|
||
| #pragma region GhostHand | ||
| void AAnomaly_GhostHand::ExecuteGhostHand() | ||
| { | ||
| ACharacter* Player = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0); | ||
| if (!Player) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| USkeletalMeshComponent* PlayerMesh = Player->GetMesh(); | ||
| if (!PlayerMesh) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| const FAttachmentTransformRules Rules(EAttachmentRule::SnapToTarget, true); | ||
| SM_Hand->AttachToComponent(PlayerMesh, Rules, AttachSocketName); | ||
|
|
||
| SM_Hand->SetRelativeLocation(AttachLocationOffset); | ||
| SM_Hand->SetRelativeRotation(AttachRotationOffset); | ||
| SM_Hand->SetRelativeScale3D(AttachScale); | ||
|
|
||
| SM_Hand->SetHiddenInGame(false); | ||
| SM_Hand->SetVisibility(true); | ||
|
|
||
| if(bLockRun) | ||
| { | ||
| ApplyRunLock(); | ||
| } | ||
| } | ||
| #pragma endregion | ||
|
|
||
| #pragma region RunLock | ||
| void AAnomaly_GhostHand::ApplyRunLock() | ||
| { | ||
| ACharacter* Player = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0); | ||
| if (!Player) | ||
| { | ||
| return; | ||
| } | ||
| if (AEHPlayerController* PC = Cast<AEHPlayerController>(UGameplayStatics::GetPlayerController(GetWorld(),0))) | ||
| { | ||
| if (!bSaved) | ||
| { | ||
| SavedCanRun = PC->bCanRun; | ||
| } | ||
| PC->bCanRun = false; | ||
| } | ||
| UCharacterMovementComponent* Move = Player->GetCharacterMovement(); | ||
| if (!Move) | ||
| { | ||
| return; | ||
| } | ||
| if (!bSaved) | ||
| { | ||
| SavedMaxWalkSpeed = Move->MaxWalkSpeed; | ||
| bSaved = true; | ||
| } | ||
|
|
||
| Move->MaxWalkSpeed = LockedWalkSpeed; | ||
|
|
||
| GetWorld()->GetTimerManager().ClearTimer(ReapplySpeedHandle); | ||
| GetWorld()->GetTimerManager().SetTimer(ReapplySpeedHandle, FTimerDelegate::CreateLambda([this]() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CreateWeakLamda로 변경 바랍니다
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 확인했습니다. |
||
| { | ||
| ACharacter* P = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 지역변수라도 변수명이 너무 짧으면 의미 전달도 힘들고 충돌 가능성도 높아집니다
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 확인했습니다. |
||
| if (!P) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| if (UCharacterMovementComponent* M = P->GetCharacterMovement()) | ||
| { | ||
| M->MaxWalkSpeed = LockedWalkSpeed; | ||
| } | ||
| }), ReapplyInterval, true); | ||
| } | ||
|
|
||
| void AAnomaly_GhostHand::ClearRunLock() | ||
| { | ||
| if (GetWorld()) | ||
| { | ||
| GetWorld()->GetTimerManager().ClearTimer(ReapplySpeedHandle); | ||
| } | ||
ssiver6324 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (bSaved) | ||
| { | ||
| if (ACharacter* Player = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)) | ||
| { | ||
| if (UCharacterMovementComponent* Move = Player->GetCharacterMovement()) | ||
| { | ||
| Move->MaxWalkSpeed = SavedMaxWalkSpeed; | ||
| } | ||
| } | ||
| bSaved = false; | ||
| } | ||
| if (AEHPlayerController* PC = Cast<AEHPlayerController>(UGameplayStatics::GetPlayerController(GetWorld(), 0))) | ||
| { | ||
| PC->bCanRun = SavedCanRun; | ||
| } | ||
| } | ||
| #pragma endregion | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // Copyright by 2025-2 WAP Game 2 team | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "CoreMinimal.h" | ||
| #include "Anomaly/Base/Anomaly_Base_EightExit.h" | ||
| #include "Anomaly_GhostHand.generated.h" | ||
ssiver6324 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| UCLASS() | ||
| class ENDLESS_HOTEL_API AAnomaly_GhostHand : public AAnomaly_Base_EightExit | ||
| { | ||
| GENERATED_BODY() | ||
|
|
||
| #pragma region Base | ||
| public: | ||
| AAnomaly_GhostHand(const FObjectInitializer& ObjectInitializer); | ||
|
|
||
| protected: | ||
| virtual void BeginPlay() override; | ||
| virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; | ||
| #pragma endregion | ||
|
|
||
| #pragma region Activity | ||
| public: | ||
| virtual void ActivateAnomaly(uint8 Anomaly_ID) override; | ||
| #pragma endregion | ||
|
|
||
| #pragma region GhostHand | ||
| protected: | ||
| UPROPERTY(VisibleAnywhere, Category="GhostHand|Component") | ||
| TObjectPtr<class UStaticMeshComponent> SM_Hand; | ||
|
|
||
| UPROPERTY(EditAnywhere, Category = "GhostHand|Attach") | ||
| FName AttachSocketName = TEXT("Hand_Leg"); | ||
|
|
||
| UPROPERTY(EditAnywhere, Category = "GhostHand|Attach") | ||
| FVector AttachLocationOffset = FVector::ZeroVector; | ||
|
|
||
| UPROPERTY(EditAnywhere, Category = "GhostHand|Attach") | ||
| FRotator AttachRotationOffset = FRotator::ZeroRotator; | ||
|
|
||
| UPROPERTY(EditAnywhere, Category = "GhostHand|Attach") | ||
| FVector AttachScale = FVector(1.f, 1.f, 1.f); | ||
|
|
||
| UPROPERTY(EditAnywhere, Category = "GhostHand|Time") | ||
| float StartDelay = 0.5f; | ||
|
|
||
| void ExecuteGhostHand(); | ||
|
|
||
| FTimerHandle StartDelayHandle; | ||
| #pragma endregion | ||
|
|
||
| #pragma region RunLock | ||
| UPROPERTY(EditAnywhere, Category = "GhostHand|RunLock") | ||
| bool bLockRun = true; | ||
|
|
||
| UPROPERTY(EditAnywhere, Category = "GhostHand|RunLock") | ||
| float LockedWalkSpeed = 300.f; | ||
|
|
||
| UPROPERTY(EditAnywhere, Category = "GhostHand|RunLock") | ||
| float ReapplyInterval = 0.05f; | ||
|
|
||
| FTimerHandle ReapplySpeedHandle; | ||
|
|
||
| bool bSaved = false; | ||
ssiver6324 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| float SavedMaxWalkSpeed = 0.f; | ||
| bool SavedCanRun = true; | ||
|
|
||
| void ApplyRunLock(); | ||
| void ClearRunLock(); | ||
| #pragma endregion | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.