#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 "Actors/PawnMove.h" #include "NuclexErrors.h" // --------------------------------------------------------------------------------------------- // namespace { /// Name of the OnInitialized method, UnrealHeaderTool puts it in the .gen.cpp file const FName NAME_UPawnMove_OnInitialized = FName(TEXT("OnInitialized")); /// Name of the IsCompleted method, UnrealHeaderTool puts it in the .gen.cpp file const FName NAME_UPawnMove_IsCompleted = FName(TEXT("IsCompleted")); /// Name of the OnBeginPlay method, UnrealHeaderTool puts it in the .gen.cpp file const FName NAME_UPawnMove_BeginPlay = FName(TEXT("BeginPlay")); /// Name of the OnStarted method, UnrealHeaderTool puts it in the .gen.cpp file const FName NAME_UPawnMove_OnStarted = FName(TEXT("OnStarted")); /// Name of the OnEnded method, UnrealHeaderTool puts it in the .gen.cpp file const FName NAME_UPawnMove_OnEnded = FName(TEXT("OnEnded")); /// Name of the PhysicsTick method, UnrealHeaderTool puts it in the .gen.cpp file const FName NAME_UPawnMove_PhysicsTick = FName(TEXT("PhysicsTick")); } // anonymous namespace // --------------------------------------------------------------------------------------------- // UPawnMove::UPawnMove() : pawn(nullptr), isInitialized(false) {} // --------------------------------------------------------------------------------------------- // void UPawnMove::Initialize(APawn *newPawn) { // Initialize can be called multiple times, but a move, once bound to an actor, // must not be initialized on a different actor. if(this->isInitialized) { if(this->pawn != newPawn) { UE_LOG( LogNuclex, Error, TEXT("%s - ERROR: %s"), TEXT("UPawnMove::Initialize()"), TEXT("Actor move has already been initialized for another pawn!") ); } return; } // Update the pawn refeference for the move to use this->pawn = newPawn; this->isInitialized = true; // Allow the move implementation to do its own initialization UPawnMove::Execute_OnInitialized(this); } // --------------------------------------------------------------------------------------------- // void UPawnMove::Execute_OnInitialized(UObject *self) { check(self != nullptr); //check(self->GetClass()->ImplementsInterface(UPawnMove::StaticClass())); check(self->GetClass()->IsChildOf(UPawnMove::StaticClass())); UFunction *onInitializedFunction = self->FindFunction( NAME_UPawnMove_OnInitialized ); if(onInitializedFunction != nullptr) { self->ProcessEvent(onInitializedFunction, nullptr); } else { UPawnMove *PawnMove = static_cast( self->GetNativeInterfaceAddress(UPawnMove::StaticClass()) ); if(PawnMove != nullptr) { PawnMove->OnInitialized_Implementation(); } } } // --------------------------------------------------------------------------------------------- // bool UPawnMove::Execute_IsCompleted(UObject *self) { check(self != nullptr); //check(self->GetClass()->ImplementsInterface(UPawnMove::StaticClass())); check(self->GetClass()->IsChildOf(UPawnMove::StaticClass())); UFunction *isCompletedFunction = self->FindFunction( NAME_UPawnMove_IsCompleted ); if(isCompletedFunction != nullptr) { PawnMove_eventIsCompleted_Parms parameters; self->ProcessEvent(isCompletedFunction, ¶meters); return parameters.ReturnValue; } else { UPawnMove *PawnMove = static_cast( self->GetNativeInterfaceAddress(UPawnMove::StaticClass()) ); if(PawnMove != nullptr) { return PawnMove->IsCompleted_Implementation(); } } return false; } // --------------------------------------------------------------------------------------------- // void UPawnMove::Execute_OnStarted(UObject *self) { check(self != nullptr); //check(self->GetClass()->ImplementsInterface(UPawnMove::StaticClass())); check(self->GetClass()->IsChildOf(UPawnMove::StaticClass())); UFunction *onStartedFunction = self->FindFunction( NAME_UPawnMove_OnStarted ); if(onStartedFunction != nullptr) { self->ProcessEvent(onStartedFunction, nullptr); } else { UPawnMove *PawnMove = static_cast( self->GetNativeInterfaceAddress(UPawnMove::StaticClass()) ); if(PawnMove != nullptr) { PawnMove->OnStarted_Implementation(); } } } // --------------------------------------------------------------------------------------------- // void UPawnMove::Execute_OnEnded(UObject *self) { check(self != nullptr); //check(self->GetClass()->ImplementsInterface(UPawnMove::StaticClass())); check(self->GetClass()->IsChildOf(UPawnMove::StaticClass())); UFunction *onEndedFunction = self->FindFunction( NAME_UPawnMove_OnEnded ); if(onEndedFunction != nullptr) { self->ProcessEvent(onEndedFunction, nullptr); } else { UPawnMove *PawnMove = static_cast( self->GetNativeInterfaceAddress(UPawnMove::StaticClass()) ); if(PawnMove != nullptr) { PawnMove->OnEnded_Implementation(); } } } // --------------------------------------------------------------------------------------------- // void UPawnMove::Execute_PhysicsTick(UObject *self, float deltaTime) { check(self != nullptr); //check(self->GetClass()->ImplementsInterface(UPawnMove::StaticClass())); //check(self->GetClass()->IsBasedOnArchetype( ImplementsInterface(UPawnMove::StaticClass())); check(self->GetClass()->IsChildOf(UPawnMove::StaticClass())); UFunction *physicsTickFunction = self->FindFunction( NAME_UPawnMove_PhysicsTick ); if(physicsTickFunction != nullptr) { PawnMove_eventPhysicsTick_Parms parameters; parameters.deltaTime = deltaTime; self->ProcessEvent(physicsTickFunction, ¶meters); } else { UPawnMove *PawnMove = static_cast( self->GetNativeInterfaceAddress(UPawnMove::StaticClass()) ); if(PawnMove != nullptr) { PawnMove->PhysicsTick_Implementation(deltaTime); } } } // --------------------------------------------------------------------------------------------- //