#pragma once #pragma region CPL License /* Nuclex Unreal Module Copyright (C) 2014-2021 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #include #include #include #include "PawnMove.h" #include "PawnController.generated.h" // --------------------------------------------------------------------------------------------- // UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) class NUCLEX_API UPawnController : public UActorComponent { GENERATED_BODY() /// Initializes the actor controller component to its default values public: UPawnController(); /// Retrieves the move currently being performed by the character /// @returns The currently active move for the pawn public: UFUNCTION(BlueprintCallable, Category="Moves") UPawnMove *GetActiveMove() const { return this->activeMove; } /// Selects the move that the character will perform next /// @param move Move the actor will perform public: UFUNCTION(BlueprintCallable, Category="Moves") void SetActiveMove(UPawnMove *move); /// Called when the game starts or when the actor is added to a running game protected: virtual void BeginPlay() override; /* /// Called when the game ends or when the actor is deleted from the running game /// @param endPlayReason Reason why the component is not in the game anymore protected: virtual void EndPlay(const EEndPlayReason::Type endPlayReason) override; */ /// Called every frame to advance simulation time /// @param deltaTime Amount of time that has elapsed since the last tick /// @param tickType Type of tick that is being broadcast /// @param thisTickFunction Completely useless function pointer providing no value protected: virtual void TickComponent( float deltaTime, ELevelTick tickType, FActorComponentTickFunction *thisTickFunction ) override; /// Deselects the active move, sending out the appropriate notifications private: void dropActiveMove(); /// Adopts the specified move by calling its Initialize() method /// @param move Move that will be initialized private: void initializeMove(UPawnMove *move); /// Logs a message that reports that the pawn has actived a new move private: void logMoveSwitch(); /// Whether the actor controller should log every time it switches to a different move public: UPROPERTY(EditAnywhere, BlueprintReadWrite) bool DebugAnnounceMoveSwitches; /// Move that is currently selected into the character private: UPROPERTY(Transient) UPawnMove *activeMove; /// Pawn that owns this component (and on which moves are executed) private: UPROPERTY(Transient) APawn *owningPawn; /// Whether the BeginPlay() method has been called on the active move yet private: bool wasBeginPlayCalled; /// Whether the active move was selected before BeginPlay() was issued /// @remarks /// When set, the call to the move's Initialize() method has been postponed /// and will be done as soon as this component's BeginPlay() method is called private: bool moveSelectedBeforeBeginPlay; };