Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Fill out your copyright notice in the Description page of Project Settings.
- #include "FieldCommander.h"
- #include "FCWorldSettings.h"
- #include "FCGameState.h"
- #include "FCGameMode.h"
- #include "UnrealNetwork.h"
- #include "FCPlayerController.h"
- void AFCPlayerController::BeginPlay()
- {
- Super::BeginPlay();
- bShowMouseCursor = true;
- IsDragScrolling = false;
- }
- void AFCPlayerController::PlayerTick(float DeltaTime)
- {
- Super::PlayerTick(DeltaTime);
- if (!GetPawn())
- {
- return;
- }
- if (IsDragScrolling)
- {
- float mousex;
- float mousey;
- GetMousePosition(mousex, mousey);
- if (GetPawn() == CurrentFCStratPawn)
- {
- CurrentFCStratPawn->SetActorLocation(FVector(DragScrollStartLocation.X + ((DragScrollCursorStartLocation.X - mousex) * 10.0), DragScrollStartLocation.Y + ((DragScrollCursorStartLocation.Y - mousey) * 10.0), DragScrollStartLocation.Z));
- }
- else
- {
- IsDragScrolling = false;
- }
- }
- }
- void AFCPlayerController::PlayerReadyUp(bool PlayerIsReady)
- {
- if (Role < ROLE_Authority)
- {
- ServerPlayerReadyUp(PlayerIsReady);
- }
- else
- {
- AFCPlayerState* MyFCPlayerState = nullptr;
- if (PlayerState != nullptr)
- {
- MyFCPlayerState = (AFCPlayerState*)PlayerState;
- if (MyFCPlayerState != nullptr)
- {
- MyFCPlayerState->PlayerIsReady = PlayerIsReady;
- }
- }
- }
- }
- bool AFCPlayerController::ServerPlayerReadyUp_Validate(bool PlayerIsReady)
- {
- return true;
- }
- void AFCPlayerController::ServerPlayerReadyUp_Implementation(bool PlayerIsReady)
- {
- PlayerReadyUp(PlayerIsReady);
- }
- void AFCPlayerController::PlayerPickFaction(TSubclassOf<UFCFaction> NewFaction, bool IsRandomFaction)
- {
- if (Role < ROLE_Authority)
- {
- ServerPlayerPickFaction(NewFaction, IsRandomFaction);
- }
- else
- {
- AFCPlayerState* MyFCPlayerState = nullptr;
- if (PlayerState != nullptr)
- {
- MyFCPlayerState = (AFCPlayerState*)PlayerState;
- if (MyFCPlayerState != nullptr)
- {
- MyFCPlayerState->PlayerFactionClass = NewFaction;
- MyFCPlayerState->PlayerIsRandomFaction = IsRandomFaction;
- }
- }
- }
- }
- bool AFCPlayerController::ServerPlayerPickFaction_Validate(TSubclassOf<UFCFaction> NewFaction, bool IsRandomFaction)
- {
- return true;
- }
- void AFCPlayerController::ServerPlayerPickFaction_Implementation(TSubclassOf<UFCFaction> NewFaction, bool IsRandomFaction)
- {
- PlayerPickFaction(NewFaction, IsRandomFaction);
- }
- void AFCPlayerController::PlayerPickHero(TSubclassOf<AFCHero> NewHero, bool IsRandomHero)
- {
- if (Role < ROLE_Authority)
- {
- ServerPlayerPickHero(NewHero, IsRandomHero);
- }
- else
- {
- AFCPlayerState* MyFCPlayerState = nullptr;
- if (PlayerState != nullptr)
- {
- MyFCPlayerState = (AFCPlayerState*)PlayerState;
- if (MyFCPlayerState != nullptr)
- {
- MyFCPlayerState->PlayerHeroClass = NewHero;
- MyFCPlayerState->PlayerIsRandomHero = IsRandomHero;
- }
- }
- }
- }
- bool AFCPlayerController::ServerPlayerPickHero_Validate(TSubclassOf<AFCHero> NewHero, bool IsRandomHero)
- {
- return true;
- }
- void AFCPlayerController::ServerPlayerPickHero_Implementation(TSubclassOf<AFCHero> NewHero, bool IsRandomHero)
- {
- PlayerPickHero(NewHero, IsRandomHero);
- }
- void AFCPlayerController::PlayerPickPlayerSlot(int32 TeamSlotIdx, int32 ForceSlotIdx, int32 PlayerSlotIdx)
- {
- if (Role < ROLE_Authority)
- {
- ServerPlayerPickPlayerSlot(TeamSlotIdx, ForceSlotIdx, PlayerSlotIdx);
- }
- else
- {
- AFCPlayerState* MyFCPlayerState = nullptr;
- if (PlayerState != nullptr)
- {
- MyFCPlayerState = (AFCPlayerState*)PlayerState;
- if (MyFCPlayerState != nullptr)
- {
- MyFCPlayerState->PlayerTeamSlot = TeamSlotIdx;
- MyFCPlayerState->PlayerForceSlot = ForceSlotIdx;
- MyFCPlayerState->PlayerPlayerSlot = PlayerSlotIdx;
- }
- }
- }
- }
- bool AFCPlayerController::ServerPlayerPickPlayerSlot_Validate(int32 TeamSlotIdx, int32 ForceSlotIdx, int32 PlayerSlotIdx)
- {
- return true;
- }
- void AFCPlayerController::ServerPlayerPickPlayerSlot_Implementation(int32 TeamSlotIdx, int32 ForceSlotIdx, int32 PlayerSlotIdx)
- {
- PlayerPickPlayerSlot(TeamSlotIdx, ForceSlotIdx, PlayerSlotIdx);
- }
- void AFCPlayerController::PlayerPickStartLocationForForce(int32 NewStartLocation)
- {
- if (Role < ROLE_Authority)
- {
- ServerPlayerPickStartLocationForForce(NewStartLocation);
- }
- else
- {
- AFCPlayerState* MyFCPlayerState = nullptr;
- AFCGameState* tempfcgs = (AFCGameState*)GetWorld()->GetGameState();
- if (tempfcgs)
- {
- if (PlayerState != nullptr)
- {
- MyFCPlayerState = (AFCPlayerState*)PlayerState;
- if (MyFCPlayerState != nullptr)
- {
- int i = 0;
- AFCPlayerState* tempfcps = nullptr;
- for (i = 0; i < tempfcgs->PlayerArray.Num(); i++)
- {
- tempfcps = (AFCPlayerState*)tempfcgs->PlayerArray[i];
- if (tempfcps)
- {
- if ((tempfcps->PlayerTeamSlot == MyFCPlayerState->PlayerTeamSlot) && (tempfcps->PlayerForceSlot == MyFCPlayerState->PlayerForceSlot) && (tempfcps->PlayerPlayerSlot != -1))
- {
- tempfcps->PlayerStartLocation = NewStartLocation;
- }
- }
- }
- }
- }
- }
- }
- }
- bool AFCPlayerController::ServerPlayerPickStartLocationForForce_Validate(int32 NewStartLocation)
- {
- return true;
- }
- void AFCPlayerController::ServerPlayerPickStartLocationForForce_Implementation(int32 NewStartLocation)
- {
- PlayerPickStartLocationForForce(NewStartLocation);
- }
- void AFCPlayerController::PlayerSpawnBase(int32 NewBaseLocation, bool InstantActivation)
- {
- if (Role < ROLE_Authority)
- {
- ServerPlayerSpawnBase(NewBaseLocation, InstantActivation);
- }
- else
- {
- AFCGameState* fcgs = (AFCGameState*)GetWorld()->GetGameState();
- AFCGameMode* fcgm = (AFCGameMode*)GetWorld()->GetAuthGameMode();
- AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
- if ((fcgs) && (fcgm) && (fcps))
- {
- int i = 0;
- for (i = 0; i < fcgs->FCBaseArray.Num(); i++)
- {
- if (fcgs->FCBaseArray[i].BaseIndex == NewBaseLocation)
- {
- if (fcgs->FCBaseArray[i].CurrentBaseCentralBuilding == nullptr)
- {
- if (fcps->PlayerBases.Num() < 10)
- {
- AFCUnit* tempunit = fcgm->SpawnRTSUnit(fcps->PlayerFactionClass.GetDefaultObject()->FCCentralBaseBuildingUnit, fcgs->FCBaseArray[i].BaseStart->GetActorLocation(), fcgs->FCBaseArray[i].BaseStart->GetActorRotation(), fcps, false, fcps->PlayerTeamSlot, fcps->PlayerForceSlot, NewBaseLocation);
- if (tempunit)
- {
- fcgs->FCBaseArray[i].CurrentBaseCentralBuilding = tempunit;
- fcps->PlayerBases.AddUnique(tempunit);
- if (InstantActivation)
- {
- tempunit->FCActivateBuilding();
- }
- }
- }
- }
- }
- }
- }
- }
- }
- bool AFCPlayerController::ServerPlayerSpawnBase_Validate(int32 NewBaseLocation, bool InstantActivation)
- {
- return true;
- }
- void AFCPlayerController::ServerPlayerSpawnBase_Implementation(int32 NewBaseLocation, bool InstantActivation)
- {
- PlayerSpawnBase(NewBaseLocation, InstantActivation);
- }
- void AFCPlayerController::PlayerSpawnHero(FVector NewLocation)
- {
- if (Role < ROLE_Authority)
- {
- ServerPlayerSpawnHero(NewLocation);
- bShowMouseCursor = false;
- }
- else
- {
- if (CurrentFCHero)
- {
- AFCHero* fch = (AFCHero*)GetPawn();
- if (fch)
- {
- UnPossess();
- }
- CurrentFCHero->Destroy();
- CurrentFCHero = nullptr;
- }
- AFCGameMode* fcgm = (AFCGameMode*)GetWorld()->GetAuthGameMode();
- AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
- if (fcps)
- {
- if (fcps->PlayerHeroClass)
- {
- if (fcgm)
- {
- AFCUnit* tempunit = fcgm->SpawnRTSUnit(fcps->PlayerHeroClass, NewLocation, FRotator(0.0, 0.0, 0.0), fcps, false, fcps->PlayerTeamSlot, fcps->PlayerForceSlot, -1);
- AFCHero* newhero = (AFCHero*)tempunit;
- if (newhero)
- {
- CurrentFCHero = newhero;
- Possess(CurrentFCHero);
- bShowMouseCursor = false;
- }
- }
- }
- }
- }
- }
- bool AFCPlayerController::ServerPlayerSpawnHero_Validate(FVector NewLocation)
- {
- return true;
- }
- void AFCPlayerController::ServerPlayerSpawnHero_Implementation(FVector NewLocation)
- {
- PlayerSpawnHero(NewLocation);
- }
- void AFCPlayerController::PlayerSwapPerspective(bool ToStratCam)
- {
- if (Role < ROLE_Authority)
- {
- ServerPlayerSwapPerspective(ToStratCam);
- if (ToStratCam)
- {
- bShowMouseCursor = true;
- }
- else
- {
- bShowMouseCursor = false;
- }
- }
- else
- {
- UnPossess();
- if (ToStratCam)
- {
- Possess(CurrentFCStratPawn);
- bShowMouseCursor = true;
- }
- else
- {
- Possess(CurrentFCHero);
- bShowMouseCursor = false;
- }
- }
- }
- bool AFCPlayerController::ServerPlayerSwapPerspective_Validate(bool ToStratCam)
- {
- return true;
- }
- void AFCPlayerController::ServerPlayerSwapPerspective_Implementation(bool ToStratCam)
- {
- PlayerSwapPerspective(ToStratCam);
- }
- void AFCPlayerController::ReceivedGameModeFactionClasses()
- {
- HasReceivedGameModeFactionClasses = true;
- }
- AFCWorldSettings* AFCPlayerController::GetFCWorldSettings()
- {
- return (AFCWorldSettings*)GetWorldSettings();
- }
- void AFCPlayerController::SetupInputComponent()
- {
- Super::SetupInputComponent();
- InputComponent->BindAxis("MoveForward", this, &AFCPlayerController::HandleMoveForward);
- InputComponent->BindAxis("MoveRight", this, &AFCPlayerController::HandleMoveRight);
- InputComponent->BindAxis("LookUp", this, &AFCPlayerController::HandleLookUp);
- InputComponent->BindAxis("LookRight", this, &AFCPlayerController::HandleLookRight);
- InputComponent->BindAction("Jump", IE_Pressed, this, &AFCPlayerController::HandleJump);
- InputComponent->BindAction("PerspectiveSwap", IE_Pressed, this, &AFCPlayerController::HandlePerspectiveSwap);
- InputComponent->BindAction("PrimaryAction", IE_Pressed, this, &AFCPlayerController::HandlePrimaryAction);
- InputComponent->BindAction("SecondaryAction", IE_Pressed, this, &AFCPlayerController::HandleSecondaryAction);
- InputComponent->BindAction("TertiaryAction", IE_Pressed, this, &AFCPlayerController::HandleTertiaryAction);
- InputComponent->BindAction("PrimaryAction", IE_Released, this, &AFCPlayerController::HandlePrimaryActionEnd);
- InputComponent->BindAction("SecondaryAction", IE_Released, this, &AFCPlayerController::HandleSecondaryActionEnd);
- InputComponent->BindAction("TertiaryAction", IE_Released, this, &AFCPlayerController::HandleTertiaryActionEnd);
- InputComponent->BindAction("NextWeapon", IE_Pressed, this, &AFCPlayerController::HandleNextWeapon);
- InputComponent->BindAction("PrevWeapon", IE_Pressed, this, &AFCPlayerController::HandlePrevWeapon);
- InputComponent->BindAction("StratCommand1", IE_Pressed, this, &AFCPlayerController::HandleStratCommand1);
- InputComponent->BindAction("StratCommand2", IE_Pressed, this, &AFCPlayerController::HandleStratCommand2);
- InputComponent->BindAction("StratCommand3", IE_Pressed, this, &AFCPlayerController::HandleStratCommand3);
- InputComponent->BindAction("StratCommand4", IE_Pressed, this, &AFCPlayerController::HandleStratCommand4);
- InputComponent->BindAction("StratCommand5", IE_Pressed, this, &AFCPlayerController::HandleStratCommand5);
- InputComponent->BindAction("StratCommand6", IE_Pressed, this, &AFCPlayerController::HandleStratCommand6);
- InputComponent->BindAction("StratCommand7", IE_Pressed, this, &AFCPlayerController::HandleStratCommand7);
- InputComponent->BindAction("StratCommand8", IE_Pressed, this, &AFCPlayerController::HandleStratCommand8);
- InputComponent->BindAction("StratCommand9", IE_Pressed, this, &AFCPlayerController::HandleStratCommand9);
- InputComponent->BindAction("StratCommand0", IE_Pressed, this, &AFCPlayerController::HandleStratCommand0);
- InputComponent->BindAction("HotGroup1", IE_Pressed, this, &AFCPlayerController::HandleHotGroup1);
- InputComponent->BindAction("HotGroup2", IE_Pressed, this, &AFCPlayerController::HandleHotGroup2);
- InputComponent->BindAction("HotGroup3", IE_Pressed, this, &AFCPlayerController::HandleHotGroup3);
- InputComponent->BindAction("HotGroup4", IE_Pressed, this, &AFCPlayerController::HandleHotGroup4);
- InputComponent->BindAction("HotGroup5", IE_Pressed, this, &AFCPlayerController::HandleHotGroup5);
- InputComponent->BindAction("HotGroup6", IE_Pressed, this, &AFCPlayerController::HandleHotGroup6);
- InputComponent->BindAction("HotGroup7", IE_Pressed, this, &AFCPlayerController::HandleHotGroup7);
- InputComponent->BindAction("HotGroup8", IE_Pressed, this, &AFCPlayerController::HandleHotGroup8);
- InputComponent->BindAction("HotGroup9", IE_Pressed, this, &AFCPlayerController::HandleHotGroup9);
- InputComponent->BindAction("HotGroup10", IE_Pressed, this, &AFCPlayerController::HandleHotGroup10);
- InputComponent->BindAction("CancelKey", IE_Pressed, this, &AFCPlayerController::HandleCancelKey);
- InputComponent->BindAction("SwapKey", IE_Pressed, this, &AFCPlayerController::HandleSwapKey);
- }
- void AFCPlayerController::HandleMoveForward(float Value)
- {
- //ClientMessage(TEXT("HandleMoveForward"));
- if (!GetPawn())
- {
- return;
- }
- if (GetPawn() == CurrentFCStratPawn)
- {
- CurrentFCStratPawn->StratCamScrollUp(Value);
- }
- else if (GetPawn() == CurrentFCHero)
- {
- if (Value != 0.f)
- {
- FRotator const ControlSpaceRot = CurrentFCHero->GetActorRotation();
- // transform to world space and add it
- CurrentFCHero->AddMovementInput(FRotationMatrix(ControlSpaceRot).GetScaledAxis(EAxis::X), Value);
- }
- }
- }
- void AFCPlayerController::HandleMoveRight(float Value)
- {
- //ClientMessage(TEXT("HandleMoveRight"));
- if (!GetPawn())
- {
- return;
- }
- if (GetPawn() == CurrentFCStratPawn)
- {
- CurrentFCStratPawn->StratCamScrollRight(Value);
- }
- else if (GetPawn() == CurrentFCHero)
- {
- if (Value != 0.f)
- {
- FRotator const ControlSpaceRot = CurrentFCHero->GetActorRotation();
- // transform to world space and add it
- CurrentFCHero->AddMovementInput(FRotationMatrix(ControlSpaceRot).GetScaledAxis(EAxis::Y), Value);
- }
- }
- }
- void AFCPlayerController::HandleLookUp(float Value)
- {
- //ClientMessage(TEXT("HandleLookUp"));
- if (!GetPawn())
- {
- return;
- }
- AddPitchInput(Value);
- }
- void AFCPlayerController::HandleLookRight(float Value)
- {
- //ClientMessage(TEXT("HandleLookRight"));
- if (!GetPawn())
- {
- return;
- }
- AddYawInput(Value);
- }
- void AFCPlayerController::HandleJump()
- {
- if (!GetPawn())
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)
- {
- CurrentFCHero->Jump();
- }
- }
- }
- void AFCPlayerController::HandlePerspectiveSwap()
- {
- if (!GetPawn())
- {
- return;
- }
- if (!CurrentFCStratPawn)
- {
- return;
- }
- if (GetPawn() == CurrentFCStratPawn)
- {
- //fcsp->SetActorLocation(FVector(0.0, 0.0, 300));
- if (CurrentFCHero)
- {
- PlayerSwapPerspective(false);
- }
- else
- {
- FHitResult hitres = FHitResult();
- if (GetHitResultUnderCursor(ECollisionChannel::ECC_Pawn, true, hitres))
- {
- PlayerSpawnHero(hitres.ImpactPoint);
- }
- }
- }
- else if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)
- {
- PlayerSwapPerspective(true);
- }
- }
- }
- void AFCPlayerController::HandlePrimaryAction()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo: primary fire
- return;
- }
- }
- if (CurrentFCStratPawn)
- {
- if (GetPawn() == CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- //todo: selection
- return;
- }
- }
- }
- void AFCPlayerController::HandleSecondaryAction()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo: strat context command (one button style)
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo: selection
- return;
- }
- }
- }
- void AFCPlayerController::HandleTertiaryAction()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo: flare or secondary fire, havent decided yet
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo: drag scroll
- DragScrollStartLocation = GetPawn()->GetActorLocation();
- IsDragScrolling = true;
- float mousex;
- float mousey;
- GetMousePosition(mousex, mousey);
- DragScrollCursorStartLocation.X = mousex;
- DragScrollCursorStartLocation.Y = mousey;
- DragScrollCursorStartLocation.Z = 0.0;
- return;
- }
- }
- }
- void AFCPlayerController::HandlePrimaryActionEnd()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo: primary fire
- return;
- }
- }
- if (CurrentFCStratPawn)
- {
- if (GetPawn() == CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- //todo: selection
- return;
- }
- }
- }
- void AFCPlayerController::HandleSecondaryActionEnd()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo: strat context command (one button style)
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo: strat context action (2 button style)
- return;
- }
- }
- }
- void AFCPlayerController::HandleTertiaryActionEnd()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo: flare or secondary fire, havent decided yet
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo: drag scroll
- IsDragScrolling = false;
- return;
- }
- }
- }
- void AFCPlayerController::HandleNextWeapon()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo: next weapon
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo: zoom in
- CurrentFCStratPawn->SetActorLocation(CurrentFCStratPawn->GetActorLocation() + FVector(0.0, 0.0, -1000.0));
- return;
- }
- }
- }
- void AFCPlayerController::HandlePrevWeapon()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo: previous weapon
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo: zoom out
- CurrentFCStratPawn->SetActorLocation(CurrentFCStratPawn->GetActorLocation() + FVector(0.0, 0.0, 1000.0));
- return;
- }
- }
- }
- void AFCPlayerController::HandleStratCommand1()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- GiveStratCommand(1);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- GiveStratCommand(1);
- return;
- }
- }
- }
- void AFCPlayerController::HandleStratCommand2()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- GiveStratCommand(2);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- GiveStratCommand(2);
- return;
- }
- }
- }
- void AFCPlayerController::HandleStratCommand3()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- GiveStratCommand(3);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- GiveStratCommand(3);
- return;
- }
- }
- }
- void AFCPlayerController::HandleStratCommand4()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- GiveStratCommand(4);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- GiveStratCommand(4);
- return;
- }
- }
- }
- void AFCPlayerController::HandleStratCommand5()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- GiveStratCommand(5);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- GiveStratCommand(5);
- return;
- }
- }
- }
- void AFCPlayerController::HandleStratCommand6()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- GiveStratCommand(6);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- GiveStratCommand(6);
- return;
- }
- }
- }
- void AFCPlayerController::HandleStratCommand7()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- GiveStratCommand(7);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- GiveStratCommand(7);
- return;
- }
- }
- }
- void AFCPlayerController::HandleStratCommand8()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- GiveStratCommand(8);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- GiveStratCommand(8);
- return;
- }
- }
- }
- void AFCPlayerController::HandleStratCommand9()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- GiveStratCommand(9);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- GiveStratCommand(9);
- return;
- }
- }
- }
- void AFCPlayerController::HandleStratCommand0()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- GiveStratCommand(10);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- GiveStratCommand(10);
- return;
- }
- }
- }
- void AFCPlayerController::HandleHotGroup1()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- SelectHotGroup(1);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- SelectHotGroup(1);
- return;
- }
- }
- }
- void AFCPlayerController::HandleHotGroup2()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- SelectHotGroup(2);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- SelectHotGroup(2);
- return;
- }
- }
- }
- void AFCPlayerController::HandleHotGroup3()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- SelectHotGroup(3);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- SelectHotGroup(3);
- return;
- }
- }
- }
- void AFCPlayerController::HandleHotGroup4()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- SelectHotGroup(4);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- SelectHotGroup(4);
- return;
- }
- }
- }
- void AFCPlayerController::HandleHotGroup5()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- SelectHotGroup(5);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- SelectHotGroup(5);
- return;
- }
- }
- }
- void AFCPlayerController::HandleHotGroup6()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- SelectHotGroup(6);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- SelectHotGroup(6);
- return;
- }
- }
- }
- void AFCPlayerController::HandleHotGroup7()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- SelectHotGroup(7);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- SelectHotGroup(7);
- return;
- }
- }
- }
- void AFCPlayerController::HandleHotGroup8()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- SelectHotGroup(8);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- SelectHotGroup(8);
- return;
- }
- }
- }
- void AFCPlayerController::HandleHotGroup9()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- SelectHotGroup(9);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- SelectHotGroup(9);
- return;
- }
- }
- }
- void AFCPlayerController::HandleHotGroup10()
- {
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- SelectHotGroup(10);
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- SelectHotGroup(10);
- return;
- }
- }
- }
- void AFCPlayerController::HandleSwapKey()
- {
- AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- if (fcps)
- {
- if (fcps->SelectedUnits.Num() > 0)
- {
- }
- else
- {
- TArray<AFCUnit*> temparray = TArray<AFCUnit*>();
- temparray.Add(CurrentFCHero);
- PlayerSelectUnits(temparray);
- }
- }
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- return;
- }
- }
- }
- void AFCPlayerController::HandleCancelKey()
- {
- AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
- if (!GetPawn())//no pawn means this can't possibly do anything
- {
- return;
- }
- if (CurrentFCHero)
- {
- if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
- {
- //todo:
- if (fcps)
- {
- if (fcps->SelectedUnits.Num() > 0)
- {
- PlayerDeselectAllUnits();
- }
- }
- return;
- }
- }
- if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
- {
- if (GetPawn() == CurrentFCStratPawn)
- {
- //todo:
- if (fcps)
- {
- if (fcps->SelectedUnits.Num() > 0)
- {
- PlayerDeselectAllUnits();
- }
- }
- return;
- }
- }
- }
- void AFCPlayerController::SelectHotGroup(int32 group)
- {
- }
- void AFCPlayerController::GiveStratCommand(int32 Idx)
- {
- AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
- if (fcps->SelectedUnits.Num() > 0)
- {
- }
- else
- {
- if ((fcps->PlayerBases.Num() >= Idx) && (Idx > 0))
- {
- TArray<AFCUnit*> temparray = TArray<AFCUnit*>();
- temparray.Add(fcps->PlayerBases[Idx - 1]);
- //const TArray<AFCUnit*>& tempconstarray = temparray.GetData();
- PlayerSelectUnits(temparray);
- }
- }
- }
- void AFCPlayerController::OnRep_StratPawn()
- {
- }
- void AFCPlayerController::OnRep_HeroPawn()
- {
- }
- void AFCPlayerController::PlayerSelectUnits(const TArray<AFCUnit*>& NewUnits)
- {
- AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
- int32 i = 0;
- if (fcps)
- {
- if (Role < ROLE_Authority)
- {
- ServerPlayerSelectUnits(NewUnits);
- }
- for (i = 0; i < NewUnits.Num(); i++)
- {
- if (NewUnits[i])
- {
- if ((NewUnits[i]->TeamIndex == fcps->PlayerTeamSlot) && (NewUnits[i]->ForceIndex == fcps->PlayerForceSlot))
- {
- if (fcps->SelectedUnits.Num() == 0)//if this is the first unit selected
- {
- PlayerChangeCommandMenuPage(0);//set the page back to root
- TSubclassOf<AFCUnit> tempunitclass = NewUnits[i]->StaticClass();
- PlayerChangeSubSelectionUnitType(tempunitclass);
- }
- fcps->SelectedUnits.AddUnique(NewUnits[i]);
- }
- }
- }
- }
- }
- bool AFCPlayerController::ServerPlayerSelectUnits_Validate(const TArray<AFCUnit*>& NewUnits)
- {
- return true;
- }
- void AFCPlayerController::ServerPlayerSelectUnits_Implementation(const TArray<AFCUnit*>& NewUnits)
- {
- PlayerSelectUnits(NewUnits);
- }
- void AFCPlayerController::PlayerDeselectUnits(const TArray<AFCUnit*>& NewUnits)
- {
- AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
- int32 i = 0;
- if (fcps)
- {
- for (i = 0; i < NewUnits.Num(); i++)
- {
- if (NewUnits[i])
- {
- if ((NewUnits[i]->TeamIndex == fcps->PlayerTeamSlot) && (NewUnits[i]->ForceIndex == fcps->PlayerForceSlot))
- {
- fcps->SelectedUnits.Remove(NewUnits[i]);
- if (fcps->SelectedUnits.Num() == 0)
- {
- PlayerChangeCommandMenuPage(0);//set the page back to root
- }
- }
- }
- }
- }
- if (Role < ROLE_Authority)
- {
- ServerPlayerDeselectUnits(NewUnits);
- }
- }
- bool AFCPlayerController::ServerPlayerDeselectUnits_Validate(const TArray<AFCUnit*>& NewUnits)
- {
- return true;
- }
- void AFCPlayerController::ServerPlayerDeselectUnits_Implementation(const TArray<AFCUnit*>& NewUnits)
- {
- PlayerDeselectUnits(NewUnits);
- }
- void AFCPlayerController::PlayerDeselectAllUnits()
- {
- AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
- if (fcps)
- {
- fcps->SelectedUnits.Empty();
- PlayerChangeCommandMenuPage(0);//set the page back to root
- }
- if (Role < ROLE_Authority)
- {
- ServerPlayerDeselectAllUnits();
- }
- }
- bool AFCPlayerController::ServerPlayerDeselectAllUnits_Validate()
- {
- return true;
- }
- void AFCPlayerController::ServerPlayerDeselectAllUnits_Implementation()
- {
- PlayerDeselectAllUnits();
- }
- void AFCPlayerController::PlayerChangeCommandMenuPage(int32 newpage)
- {
- AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
- if (fcps)
- {
- fcps->PlayerCommandMenuPage = newpage;
- if (Role < ROLE_Authority)
- {
- ServerPlayerChangeCommandMenuPage(newpage);
- }
- }
- }
- bool AFCPlayerController::ServerPlayerChangeCommandMenuPage_Validate(int32 newpage)
- {
- return true;
- }
- void AFCPlayerController::ServerPlayerChangeCommandMenuPage_Implementation(int32 newpage)
- {
- PlayerChangeCommandMenuPage(newpage);
- }
- void AFCPlayerController::PlayerChangeSubSelectionUnitType(TSubclassOf<AFCUnit> NewUnitType)
- {
- AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
- if (fcps)
- {
- fcps->SubSelectionUnitType = NewUnitType;
- if (Role < ROLE_Authority)
- {
- ServerPlayerChangeSubSelectionUnitType(NewUnitType);
- }
- }
- }
- bool AFCPlayerController::ServerPlayerChangeSubSelectionUnitType_Validate(TSubclassOf<AFCUnit> NewUnitType)
- {
- return true;
- }
- void AFCPlayerController::ServerPlayerChangeSubSelectionUnitType_Implementation(TSubclassOf<AFCUnit> NewUnitType)
- {
- PlayerChangeSubSelectionUnitType(NewUnitType);
- }
- void AFCPlayerController::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
- {
- Super::GetLifetimeReplicatedProps(OutLifetimeProps);
- DOREPLIFETIME(AFCPlayerController, CurrentFCStratPawn);
- DOREPLIFETIME(AFCPlayerController, CurrentFCHero);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement