Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "FiniteStateMachine/MachineStateData.h"
- #include "Gameplay/Foes/AI/States/MTD_FoeState.h"
- #include "NativeGameplayTags.h"
- #include "MTD_FoeState_MovingAroundBlockade.generated.h"
- DECLARE_LOG_CATEGORY_EXTERN(MTD_LogFoe_MoveAroundBlockade, Log, All);
- UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_StateMachine_Label_MoveAround);
- UCLASS()
- class UMTD_FoeStateData_MovingAroundBlockade
- : public UMachineStateData
- {
- GENERATED_BODY()
- public:
- UPROPERTY(EditDefaultsOnly)
- bool bIgnoreMoveAroundBlockade = false;
- UPROPERTY(EditDefaultsOnly)
- float MoveAroundSomethingMaximumSpeed = 40.f;
- FVector StartMovingAroundBlockadeLocation = FVector::ZeroVector;
- FVector MovingAroundBlockadePoint = FVector::ZeroVector;
- /** It's either +1 or -1. Means right of left. */
- float MovingAroundBlockadeSide = 1.f;
- float LastBlockadeCheckTime = 0.f;
- float LastMovingAroundBlockadeTime = 0.f;
- float LastBlockadeWidth = 0.f;
- FVector LastBlockadeHitNormal = FVector::ZeroVector;
- TWeakObjectPtr<AActor> LastMovingAroundBlockadeActor = nullptr;
- };
- /**
- *
- */
- UCLASS()
- class UMTD_FoeState_MovingAroundBlockade
- : public UMTD_FoeState
- {
- GENERATED_BODY()
- public:
- UMTD_FoeState_MovingAroundBlockade();
- /**
- * Called we collide with a blockade, or even other enemies, to tell us to move around them on our way
- * to a destination.
- *
- * Subject to a variety of logical checks before we accept moving around the "blockade".
- *
- *
- * Debug information:
- * - Red sphere - TraceThroughBlockadePosition
- * - Green sphere - OurPosition
- * - White line - OurPosition -> TraceThroughBlockadePosition
- * - Red line - BlockadePosition -> BlockadePosition + HitNormal * 150
- * - Cyan sphere - MovingAroundBlockadePoint
- */
- static bool MoveAroundBlockade(UFiniteStateMachine* StateMachineContext, AActor* BlockadeActor, float BlockadeWidth,
- FVector HitNormal, bool bSkipBlockingCheck = false);
- /**
- * Check if a movement point around a blockade is valid, currently just whether it has ground underneath it!
- */
- static bool CheckMoveAroundBlockadePoint(const UFiniteStateMachine* StateMachineContext,
- const FVector& MoveToPoint);
- protected:
- //~UMTD_FoeState Interface
- virtual void Begin(TSubclassOf<UMachineState> PreviousState) override;
- virtual void Tick(float DeltaSeconds) override;
- virtual void End(TSubclassOf<UMachineState> NewState) override;
- //~End of UMTD_FoeState Interface
- private:
- //~Labels
- void MoveAroundBlockade(float DeltaSeconds);
- //~End of Labels
- void CancelMoveAround();
- void TryOtherBlockadeDirection();
- protected:
- TWeakObjectPtr<UMTD_FoeStateData_MovingAroundBlockade> StateData = nullptr;
- FTimerHandle CancelMoveAroundTimer;
- FTimerHandle TryOtherBlockadeDirectionTimer;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement