// Console commands of the player's body (Player/Body): Descent.Body.View, .Guns, .ThirdPerson. // The switches themselves are console variables (descent.Body.OldArm, descent.Body.Guns); the commands set them and say what they did. #include "Debug/DescentCommandUtil.h" #include "Player/Body/DescentPlayerBodyComponent.h" #include "Player/DescentCharacter.h" #include "TheDescent.h" #include "Engine/World.h" #include "GameFramework/PlayerController.h" #include "HAL/IConsoleManager.h" namespace { UDescentPlayerBodyComponent* BodyCmdBody(UWorld* World) { const APlayerController* PC = World ? World->GetFirstPlayerController() : nullptr; const ADescentCharacter* Ch = PC ? Cast(PC->GetPawn()) : nullptr; return Ch ? Ch->Body.Get() : nullptr; } void CmdBodyView(const TArray& Args, UWorld* World) { const bool bArm = Args.Num() == 1 && Args[0].Equals(TEXT("arm"), ESearchCase::IgnoreCase); const bool bBody = Args.Num() == 1 && Args[0].Equals(TEXT("body"), ESearchCase::IgnoreCase); if (!bArm && !bBody) { Descent::Cmd::Fail(World, TEXT("Descent.Body.View"), TEXT("usage: Descent.Body.View (body: the Twinblast body, the default; arm: the old cybernetic arm viewmodel, no body)")); return; } UDescentPlayerBodyComponent::SetOldArmView(bArm); if (UDescentPlayerBodyComponent* Body = BodyCmdBody(World)) { Body->Refresh(0.0); } UE_LOG(LogDescent, Display, TEXT("Body.View: the player's view is %s"), bArm ? TEXT("the old arm (the body is not drawn)") : TEXT("the Twinblast body")); } void CmdBodyGuns(const TArray& Args, UWorld* World) { bool bValid = false; const bool bShow = Args.Num() == 1 && Descent::Cmd::ParseBool(Args[0], bValid); if (!bValid) { Descent::Cmd::Fail(World, TEXT("Descent.Body.ShowGuns"), TEXT("usage: Descent.Body.ShowGuns <0 or 1> (0: the body's two pistols are not drawn, the default)")); return; } UDescentPlayerBodyComponent::SetGunsWanted(bShow); if (UDescentPlayerBodyComponent* Body = BodyCmdBody(World)) { Body->Refresh(0.0); } UE_LOG(LogDescent, Display, TEXT("Body.Guns: the pistols are %s"), bShow ? TEXT("drawn") : TEXT("not drawn")); } void CmdBodyThirdPerson(const TArray& Args, UWorld* World) { bool bValid = false; const bool bOn = Args.Num() == 1 && Descent::Cmd::ParseBool(Args[0], bValid); UDescentPlayerBodyComponent* Body = BodyCmdBody(World); if (!bValid || !Body) { Descent::Cmd::Fail(World, TEXT("Descent.Body.ThirdPerson"), !bValid ? TEXT("usage: Descent.Body.ThirdPerson <0 or 1> (1: the whole man with his head and the pack's own arm pose even in his own view)") : TEXT("the player's pawn has no body (needs a running game)")); return; } Body->bForceThirdPerson = bOn; Body->Refresh(0.0); UE_LOG(LogDescent, Display, TEXT("Body.ThirdPerson: %d"), bOn ? 1 : 0); } FAutoConsoleCommandWithWorldAndArgs GBodyCmdView(TEXT("Descent.Body.View"), TEXT("Descent.Body.View - the Twinblast body (default) or the old cybernetic arm as the player's view"), FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(&CmdBodyView)); FAutoConsoleCommandWithWorldAndArgs GBodyCmdGuns(TEXT("Descent.Body.ShowGuns"), TEXT("Descent.Body.ShowGuns <0 or 1> - draw the body's two pistols (default 0)"), FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(&CmdBodyGuns)); FAutoConsoleCommandWithWorldAndArgs GBodyCmdThirdPerson(TEXT("Descent.Body.ThirdPerson"), TEXT("Descent.Body.ThirdPerson <0 or 1> - the settings of any other view even in the player's own view (debug)"), FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(&CmdBodyThirdPerson)); }