Advertisement
Guest User

fcplayercontroller.cpp

a guest
Oct 24th, 2015
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 34.55 KB | None | 0 0
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2.  
  3. #include "FieldCommander.h"
  4. #include "FCWorldSettings.h"
  5. #include "FCGameState.h"
  6. #include "FCGameMode.h"
  7. #include "UnrealNetwork.h"
  8. #include "FCPlayerController.h"
  9.  
  10.  
  11. void AFCPlayerController::BeginPlay()
  12. {
  13.     Super::BeginPlay();
  14.     bShowMouseCursor = true;
  15.     IsDragScrolling = false;
  16. }
  17.  
  18. void AFCPlayerController::PlayerTick(float DeltaTime)
  19. {
  20.     Super::PlayerTick(DeltaTime);
  21.  
  22.     if (!GetPawn())
  23.     {
  24.         return;
  25.     }
  26.  
  27.     if (IsDragScrolling)
  28.     {
  29.         float mousex;
  30.         float mousey;
  31.         GetMousePosition(mousex, mousey);
  32.         if (GetPawn() == CurrentFCStratPawn)
  33.         {
  34.             CurrentFCStratPawn->SetActorLocation(FVector(DragScrollStartLocation.X + ((DragScrollCursorStartLocation.X - mousex) * 10.0), DragScrollStartLocation.Y + ((DragScrollCursorStartLocation.Y - mousey) * 10.0), DragScrollStartLocation.Z));
  35.         }
  36.         else
  37.         {
  38.             IsDragScrolling = false;
  39.         }
  40.     }
  41. }
  42.  
  43. void AFCPlayerController::PlayerReadyUp(bool PlayerIsReady)
  44. {
  45.     if (Role < ROLE_Authority)
  46.     {
  47.         ServerPlayerReadyUp(PlayerIsReady);
  48.     }
  49.     else
  50.     {
  51.         AFCPlayerState* MyFCPlayerState = nullptr;
  52.         if (PlayerState != nullptr)
  53.         {
  54.             MyFCPlayerState = (AFCPlayerState*)PlayerState;
  55.             if (MyFCPlayerState != nullptr)
  56.             {
  57.                 MyFCPlayerState->PlayerIsReady = PlayerIsReady;
  58.             }
  59.         }
  60.     }
  61. }
  62.  
  63. bool AFCPlayerController::ServerPlayerReadyUp_Validate(bool PlayerIsReady)
  64. {
  65.     return true;
  66. }
  67.  
  68. void AFCPlayerController::ServerPlayerReadyUp_Implementation(bool PlayerIsReady)
  69. {
  70.     PlayerReadyUp(PlayerIsReady);
  71. }
  72.  
  73. void AFCPlayerController::PlayerPickFaction(TSubclassOf<UFCFaction> NewFaction, bool IsRandomFaction)
  74. {
  75.     if (Role < ROLE_Authority)
  76.     {
  77.         ServerPlayerPickFaction(NewFaction, IsRandomFaction);
  78.     }
  79.     else
  80.     {
  81.         AFCPlayerState* MyFCPlayerState = nullptr;
  82.         if (PlayerState != nullptr)
  83.         {
  84.             MyFCPlayerState = (AFCPlayerState*)PlayerState;
  85.             if (MyFCPlayerState != nullptr)
  86.             {
  87.                 MyFCPlayerState->PlayerFactionClass = NewFaction;
  88.                 MyFCPlayerState->PlayerIsRandomFaction = IsRandomFaction;
  89.             }
  90.         }
  91.     }
  92. }
  93.  
  94. bool AFCPlayerController::ServerPlayerPickFaction_Validate(TSubclassOf<UFCFaction> NewFaction, bool IsRandomFaction)
  95. {
  96.     return true;
  97. }
  98.  
  99. void AFCPlayerController::ServerPlayerPickFaction_Implementation(TSubclassOf<UFCFaction> NewFaction, bool IsRandomFaction)
  100. {
  101.     PlayerPickFaction(NewFaction, IsRandomFaction);
  102. }
  103.  
  104. void AFCPlayerController::PlayerPickHero(TSubclassOf<AFCHero> NewHero, bool IsRandomHero)
  105. {
  106.     if (Role < ROLE_Authority)
  107.     {
  108.         ServerPlayerPickHero(NewHero, IsRandomHero);
  109.     }
  110.     else
  111.     {
  112.         AFCPlayerState* MyFCPlayerState = nullptr;
  113.         if (PlayerState != nullptr)
  114.         {
  115.             MyFCPlayerState = (AFCPlayerState*)PlayerState;
  116.             if (MyFCPlayerState != nullptr)
  117.             {
  118.                 MyFCPlayerState->PlayerHeroClass = NewHero;
  119.                 MyFCPlayerState->PlayerIsRandomHero = IsRandomHero;
  120.             }
  121.         }
  122.     }
  123. }
  124.  
  125. bool AFCPlayerController::ServerPlayerPickHero_Validate(TSubclassOf<AFCHero> NewHero, bool IsRandomHero)
  126. {
  127.     return true;
  128. }
  129.  
  130. void AFCPlayerController::ServerPlayerPickHero_Implementation(TSubclassOf<AFCHero> NewHero, bool IsRandomHero)
  131. {
  132.     PlayerPickHero(NewHero, IsRandomHero);
  133. }
  134.  
  135. void AFCPlayerController::PlayerPickPlayerSlot(int32 TeamSlotIdx, int32 ForceSlotIdx, int32 PlayerSlotIdx)
  136. {
  137.     if (Role < ROLE_Authority)
  138.     {
  139.         ServerPlayerPickPlayerSlot(TeamSlotIdx, ForceSlotIdx, PlayerSlotIdx);
  140.     }
  141.     else
  142.     {
  143.         AFCPlayerState* MyFCPlayerState = nullptr;
  144.         if (PlayerState != nullptr)
  145.         {
  146.             MyFCPlayerState = (AFCPlayerState*)PlayerState;
  147.             if (MyFCPlayerState != nullptr)
  148.             {
  149.                 MyFCPlayerState->PlayerTeamSlot = TeamSlotIdx;
  150.                 MyFCPlayerState->PlayerForceSlot = ForceSlotIdx;
  151.                 MyFCPlayerState->PlayerPlayerSlot = PlayerSlotIdx;
  152.             }
  153.         }
  154.     }
  155. }
  156.  
  157. bool AFCPlayerController::ServerPlayerPickPlayerSlot_Validate(int32 TeamSlotIdx, int32 ForceSlotIdx, int32 PlayerSlotIdx)
  158. {
  159.     return true;
  160. }
  161.  
  162. void AFCPlayerController::ServerPlayerPickPlayerSlot_Implementation(int32 TeamSlotIdx, int32 ForceSlotIdx, int32 PlayerSlotIdx)
  163. {
  164.     PlayerPickPlayerSlot(TeamSlotIdx, ForceSlotIdx, PlayerSlotIdx);
  165. }
  166.  
  167. void AFCPlayerController::PlayerPickStartLocationForForce(int32 NewStartLocation)
  168. {
  169.     if (Role < ROLE_Authority)
  170.     {
  171.         ServerPlayerPickStartLocationForForce(NewStartLocation);
  172.     }
  173.     else
  174.     {
  175.         AFCPlayerState* MyFCPlayerState = nullptr;
  176.         AFCGameState* tempfcgs = (AFCGameState*)GetWorld()->GetGameState();
  177.         if (tempfcgs)
  178.         {
  179.             if (PlayerState != nullptr)
  180.             {
  181.                 MyFCPlayerState = (AFCPlayerState*)PlayerState;
  182.                 if (MyFCPlayerState != nullptr)
  183.                 {
  184.                     int i = 0;
  185.                     AFCPlayerState* tempfcps = nullptr;
  186.                     for (i = 0; i < tempfcgs->PlayerArray.Num(); i++)
  187.                     {
  188.                         tempfcps = (AFCPlayerState*)tempfcgs->PlayerArray[i];
  189.                         if (tempfcps)
  190.                         {
  191.                             if ((tempfcps->PlayerTeamSlot == MyFCPlayerState->PlayerTeamSlot) && (tempfcps->PlayerForceSlot == MyFCPlayerState->PlayerForceSlot) && (tempfcps->PlayerPlayerSlot != -1))
  192.                             {
  193.                                 tempfcps->PlayerStartLocation = NewStartLocation;
  194.                             }
  195.                         }
  196.                     }
  197.                 }
  198.             }
  199.         }
  200.     }
  201. }
  202.  
  203. bool AFCPlayerController::ServerPlayerPickStartLocationForForce_Validate(int32 NewStartLocation)
  204. {
  205.     return true;
  206. }
  207.  
  208. void AFCPlayerController::ServerPlayerPickStartLocationForForce_Implementation(int32 NewStartLocation)
  209. {
  210.     PlayerPickStartLocationForForce(NewStartLocation);
  211. }
  212.  
  213. void AFCPlayerController::PlayerSpawnBase(int32 NewBaseLocation, bool InstantActivation)
  214. {
  215.     if (Role < ROLE_Authority)
  216.     {
  217.         ServerPlayerSpawnBase(NewBaseLocation, InstantActivation);
  218.     }
  219.     else
  220.     {
  221.         AFCGameState* fcgs = (AFCGameState*)GetWorld()->GetGameState();
  222.         AFCGameMode* fcgm = (AFCGameMode*)GetWorld()->GetAuthGameMode();
  223.         AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
  224.         if ((fcgs) && (fcgm) && (fcps))
  225.         {
  226.             int i = 0;
  227.             for (i = 0; i < fcgs->FCBaseArray.Num(); i++)
  228.             {
  229.                 if (fcgs->FCBaseArray[i].BaseIndex == NewBaseLocation)
  230.                 {
  231.                     if (fcgs->FCBaseArray[i].CurrentBaseCentralBuilding == nullptr)
  232.                     {
  233.                         if (fcps->PlayerBases.Num() < 10)
  234.                         {
  235.                             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);
  236.                             if (tempunit)
  237.                             {
  238.                                 fcgs->FCBaseArray[i].CurrentBaseCentralBuilding = tempunit;
  239.                                 fcps->PlayerBases.AddUnique(tempunit);
  240.                                 if (InstantActivation)
  241.                                 {
  242.                                     tempunit->FCActivateBuilding();
  243.                                 }
  244.                             }
  245.                         }                      
  246.                     }
  247.                 }
  248.             }
  249.         }
  250.     }
  251. }
  252.  
  253. bool AFCPlayerController::ServerPlayerSpawnBase_Validate(int32 NewBaseLocation, bool InstantActivation)
  254. {
  255.     return true;
  256. }
  257.  
  258. void AFCPlayerController::ServerPlayerSpawnBase_Implementation(int32 NewBaseLocation, bool InstantActivation)
  259. {
  260.     PlayerSpawnBase(NewBaseLocation, InstantActivation);
  261. }
  262.  
  263. void AFCPlayerController::PlayerSpawnHero(FVector NewLocation)
  264. {
  265.     if (Role < ROLE_Authority)
  266.     {
  267.         ServerPlayerSpawnHero(NewLocation);
  268.         bShowMouseCursor = false;
  269.     }
  270.     else
  271.     {
  272.         if (CurrentFCHero)
  273.         {
  274.             AFCHero* fch = (AFCHero*)GetPawn();
  275.             if (fch)
  276.             {
  277.                 UnPossess();
  278.             }
  279.             CurrentFCHero->Destroy();
  280.             CurrentFCHero = nullptr;
  281.         }
  282.  
  283.         AFCGameMode* fcgm = (AFCGameMode*)GetWorld()->GetAuthGameMode();
  284.         AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
  285.         if (fcps)
  286.         {
  287.             if (fcps->PlayerHeroClass)
  288.             {
  289.                 if (fcgm)
  290.                 {
  291.                     AFCUnit* tempunit = fcgm->SpawnRTSUnit(fcps->PlayerHeroClass, NewLocation, FRotator(0.0, 0.0, 0.0), fcps, false, fcps->PlayerTeamSlot, fcps->PlayerForceSlot, -1);
  292.                     AFCHero* newhero = (AFCHero*)tempunit;
  293.                     if (newhero)
  294.                     {
  295.                         CurrentFCHero = newhero;
  296.                         Possess(CurrentFCHero);
  297.                         bShowMouseCursor = false;
  298.                     }
  299.                 }
  300.             }
  301.         }
  302.     }
  303. }
  304.  
  305. bool AFCPlayerController::ServerPlayerSpawnHero_Validate(FVector NewLocation)
  306. {
  307.     return true;
  308. }
  309.  
  310. void AFCPlayerController::ServerPlayerSpawnHero_Implementation(FVector NewLocation)
  311. {
  312.     PlayerSpawnHero(NewLocation);
  313. }
  314.  
  315. void AFCPlayerController::PlayerSwapPerspective(bool ToStratCam)
  316. {
  317.     if (Role < ROLE_Authority)
  318.     {
  319.         ServerPlayerSwapPerspective(ToStratCam);
  320.         if (ToStratCam)
  321.         {
  322.             bShowMouseCursor = true;
  323.         }
  324.         else
  325.         {
  326.             bShowMouseCursor = false;
  327.         }
  328.     }
  329.     else
  330.     {
  331.         UnPossess();
  332.         if (ToStratCam)
  333.         {
  334.             Possess(CurrentFCStratPawn);
  335.             bShowMouseCursor = true;
  336.         }
  337.         else
  338.         {
  339.             Possess(CurrentFCHero);
  340.             bShowMouseCursor = false;
  341.         }
  342.     }
  343. }
  344.  
  345. bool AFCPlayerController::ServerPlayerSwapPerspective_Validate(bool ToStratCam)
  346. {
  347.     return true;
  348. }
  349.  
  350. void AFCPlayerController::ServerPlayerSwapPerspective_Implementation(bool ToStratCam)
  351. {
  352.     PlayerSwapPerspective(ToStratCam);
  353. }
  354.  
  355. void AFCPlayerController::ReceivedGameModeFactionClasses()
  356. {
  357.     HasReceivedGameModeFactionClasses = true;
  358. }
  359.  
  360. AFCWorldSettings* AFCPlayerController::GetFCWorldSettings()
  361. {
  362.     return (AFCWorldSettings*)GetWorldSettings();
  363. }
  364.  
  365. void AFCPlayerController::SetupInputComponent()
  366. {
  367.     Super::SetupInputComponent();
  368.     InputComponent->BindAxis("MoveForward", this, &AFCPlayerController::HandleMoveForward);
  369.     InputComponent->BindAxis("MoveRight", this, &AFCPlayerController::HandleMoveRight);
  370.     InputComponent->BindAxis("LookUp", this, &AFCPlayerController::HandleLookUp);
  371.     InputComponent->BindAxis("LookRight", this, &AFCPlayerController::HandleLookRight);
  372.  
  373.     InputComponent->BindAction("Jump", IE_Pressed, this, &AFCPlayerController::HandleJump);
  374.     InputComponent->BindAction("PerspectiveSwap", IE_Pressed, this, &AFCPlayerController::HandlePerspectiveSwap);
  375.     InputComponent->BindAction("PrimaryAction", IE_Pressed, this, &AFCPlayerController::HandlePrimaryAction);
  376.     InputComponent->BindAction("SecondaryAction", IE_Pressed, this, &AFCPlayerController::HandleSecondaryAction);
  377.     InputComponent->BindAction("TertiaryAction", IE_Pressed, this, &AFCPlayerController::HandleTertiaryAction);
  378.     InputComponent->BindAction("PrimaryAction", IE_Released, this, &AFCPlayerController::HandlePrimaryActionEnd);
  379.     InputComponent->BindAction("SecondaryAction", IE_Released, this, &AFCPlayerController::HandleSecondaryActionEnd);
  380.     InputComponent->BindAction("TertiaryAction", IE_Released, this, &AFCPlayerController::HandleTertiaryActionEnd);
  381.     InputComponent->BindAction("NextWeapon", IE_Pressed, this, &AFCPlayerController::HandleNextWeapon);
  382.     InputComponent->BindAction("PrevWeapon", IE_Pressed, this, &AFCPlayerController::HandlePrevWeapon);
  383.     InputComponent->BindAction("StratCommand1", IE_Pressed, this, &AFCPlayerController::HandleStratCommand1);
  384.     InputComponent->BindAction("StratCommand2", IE_Pressed, this, &AFCPlayerController::HandleStratCommand2);
  385.     InputComponent->BindAction("StratCommand3", IE_Pressed, this, &AFCPlayerController::HandleStratCommand3);
  386.     InputComponent->BindAction("StratCommand4", IE_Pressed, this, &AFCPlayerController::HandleStratCommand4);
  387.     InputComponent->BindAction("StratCommand5", IE_Pressed, this, &AFCPlayerController::HandleStratCommand5);
  388.     InputComponent->BindAction("StratCommand6", IE_Pressed, this, &AFCPlayerController::HandleStratCommand6);
  389.     InputComponent->BindAction("StratCommand7", IE_Pressed, this, &AFCPlayerController::HandleStratCommand7);
  390.     InputComponent->BindAction("StratCommand8", IE_Pressed, this, &AFCPlayerController::HandleStratCommand8);
  391.     InputComponent->BindAction("StratCommand9", IE_Pressed, this, &AFCPlayerController::HandleStratCommand9);
  392.     InputComponent->BindAction("StratCommand0", IE_Pressed, this, &AFCPlayerController::HandleStratCommand0);
  393.     InputComponent->BindAction("HotGroup1", IE_Pressed, this, &AFCPlayerController::HandleHotGroup1);
  394.     InputComponent->BindAction("HotGroup2", IE_Pressed, this, &AFCPlayerController::HandleHotGroup2);
  395.     InputComponent->BindAction("HotGroup3", IE_Pressed, this, &AFCPlayerController::HandleHotGroup3);
  396.     InputComponent->BindAction("HotGroup4", IE_Pressed, this, &AFCPlayerController::HandleHotGroup4);
  397.     InputComponent->BindAction("HotGroup5", IE_Pressed, this, &AFCPlayerController::HandleHotGroup5);
  398.     InputComponent->BindAction("HotGroup6", IE_Pressed, this, &AFCPlayerController::HandleHotGroup6);
  399.     InputComponent->BindAction("HotGroup7", IE_Pressed, this, &AFCPlayerController::HandleHotGroup7);
  400.     InputComponent->BindAction("HotGroup8", IE_Pressed, this, &AFCPlayerController::HandleHotGroup8);
  401.     InputComponent->BindAction("HotGroup9", IE_Pressed, this, &AFCPlayerController::HandleHotGroup9);
  402.     InputComponent->BindAction("HotGroup10", IE_Pressed, this, &AFCPlayerController::HandleHotGroup10);
  403.     InputComponent->BindAction("CancelKey", IE_Pressed, this, &AFCPlayerController::HandleCancelKey);
  404.     InputComponent->BindAction("SwapKey", IE_Pressed, this, &AFCPlayerController::HandleSwapKey);
  405. }
  406.  
  407. void AFCPlayerController::HandleMoveForward(float Value)
  408. {
  409.     //ClientMessage(TEXT("HandleMoveForward"));
  410.     if (!GetPawn())
  411.     {
  412.         return;
  413.     }
  414.     if (GetPawn() == CurrentFCStratPawn)
  415.     {
  416.         CurrentFCStratPawn->StratCamScrollUp(Value);
  417.     }
  418.     else if (GetPawn() == CurrentFCHero)
  419.     {
  420.         if (Value != 0.f)
  421.         {
  422.             FRotator const ControlSpaceRot = CurrentFCHero->GetActorRotation();
  423.  
  424.             // transform to world space and add it
  425.             CurrentFCHero->AddMovementInput(FRotationMatrix(ControlSpaceRot).GetScaledAxis(EAxis::X), Value);
  426.         }
  427.     }
  428. }
  429.  
  430. void AFCPlayerController::HandleMoveRight(float Value)
  431. {
  432.     //ClientMessage(TEXT("HandleMoveRight"));
  433.     if (!GetPawn())
  434.     {
  435.         return;
  436.     }
  437.     if (GetPawn() == CurrentFCStratPawn)
  438.     {
  439.         CurrentFCStratPawn->StratCamScrollRight(Value);
  440.     }
  441.     else if (GetPawn() == CurrentFCHero)
  442.     {
  443.         if (Value != 0.f)
  444.         {
  445.             FRotator const ControlSpaceRot = CurrentFCHero->GetActorRotation();
  446.  
  447.             // transform to world space and add it
  448.             CurrentFCHero->AddMovementInput(FRotationMatrix(ControlSpaceRot).GetScaledAxis(EAxis::Y), Value);
  449.         }
  450.     }
  451. }
  452.  
  453. void AFCPlayerController::HandleLookUp(float Value)
  454. {
  455.     //ClientMessage(TEXT("HandleLookUp"));
  456.     if (!GetPawn())
  457.     {
  458.         return;
  459.     }
  460.     AddPitchInput(Value);
  461. }
  462.  
  463. void AFCPlayerController::HandleLookRight(float Value)
  464. {
  465.     //ClientMessage(TEXT("HandleLookRight"));
  466.     if (!GetPawn())
  467.     {
  468.         return;
  469.     }
  470.     AddYawInput(Value);
  471. }
  472.  
  473. void AFCPlayerController::HandleJump()
  474. {
  475.     if (!GetPawn())
  476.     {
  477.         return;
  478.     }
  479.     if (CurrentFCHero)
  480.     {
  481.         if (GetPawn() == CurrentFCHero)
  482.         {
  483.             CurrentFCHero->Jump();
  484.         }
  485.     }
  486.  
  487. }
  488.  
  489. void AFCPlayerController::HandlePerspectiveSwap()
  490. {
  491.     if (!GetPawn())
  492.     {
  493.         return;
  494.     }
  495.     if (!CurrentFCStratPawn)
  496.     {
  497.         return;
  498.     }
  499.     if (GetPawn() == CurrentFCStratPawn)
  500.     {
  501.         //fcsp->SetActorLocation(FVector(0.0, 0.0, 300));
  502.         if (CurrentFCHero)
  503.         {
  504.             PlayerSwapPerspective(false);      
  505.         }
  506.         else
  507.         {
  508.             FHitResult hitres = FHitResult();
  509.             if (GetHitResultUnderCursor(ECollisionChannel::ECC_Pawn, true, hitres))
  510.             {
  511.                 PlayerSpawnHero(hitres.ImpactPoint);
  512.             }
  513.         }
  514.     }
  515.     else if (CurrentFCHero)
  516.     {
  517.         if (GetPawn() == CurrentFCHero)
  518.         {
  519.             PlayerSwapPerspective(true);
  520.         }
  521.     }
  522. }
  523.  
  524. void AFCPlayerController::HandlePrimaryAction()
  525. {
  526.     if (!GetPawn())//no pawn means this can't possibly do anything
  527.     {
  528.         return;
  529.     }
  530.     if (CurrentFCHero)
  531.     {
  532.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  533.         {
  534.             //todo: primary fire
  535.             return;
  536.         }
  537.     }
  538.     if (CurrentFCStratPawn)
  539.     {
  540.         if (GetPawn() == CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  541.         {
  542.             //todo: selection
  543.             return;
  544.         }
  545.     }
  546. }
  547.  
  548. void AFCPlayerController::HandleSecondaryAction()
  549. {
  550.     if (!GetPawn())//no pawn means this can't possibly do anything
  551.     {
  552.         return;
  553.     }
  554.     if (CurrentFCHero)
  555.     {
  556.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  557.         {
  558.             //todo: strat context command (one button style)
  559.             return;
  560.         }
  561.     }
  562.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  563.     {
  564.         if (GetPawn() == CurrentFCStratPawn)
  565.         {
  566.             //todo: selection
  567.             return;
  568.         }
  569.     }
  570. }
  571.  
  572. void AFCPlayerController::HandleTertiaryAction()
  573. {
  574.     if (!GetPawn())//no pawn means this can't possibly do anything
  575.     {
  576.         return;
  577.     }
  578.     if (CurrentFCHero)
  579.     {
  580.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  581.         {
  582.             //todo: flare or secondary fire, havent decided yet
  583.             return;
  584.         }
  585.     }
  586.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  587.     {
  588.         if (GetPawn() == CurrentFCStratPawn)
  589.         {
  590.             //todo: drag scroll
  591.             DragScrollStartLocation = GetPawn()->GetActorLocation();
  592.             IsDragScrolling = true;
  593.             float mousex;
  594.             float mousey;
  595.             GetMousePosition(mousex, mousey);
  596.             DragScrollCursorStartLocation.X = mousex;
  597.             DragScrollCursorStartLocation.Y = mousey;
  598.             DragScrollCursorStartLocation.Z = 0.0;
  599.             return;
  600.         }
  601.     }
  602. }
  603.  
  604. void AFCPlayerController::HandlePrimaryActionEnd()
  605. {
  606.     if (!GetPawn())//no pawn means this can't possibly do anything
  607.     {
  608.         return;
  609.     }
  610.     if (CurrentFCHero)
  611.     {
  612.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  613.         {
  614.             //todo: primary fire
  615.             return;
  616.         }
  617.     }
  618.     if (CurrentFCStratPawn)
  619.     {
  620.         if (GetPawn() == CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  621.         {
  622.             //todo: selection
  623.             return;
  624.         }
  625.     }
  626. }
  627.  
  628. void AFCPlayerController::HandleSecondaryActionEnd()
  629. {
  630.     if (!GetPawn())//no pawn means this can't possibly do anything
  631.     {
  632.         return;
  633.     }
  634.     if (CurrentFCHero)
  635.     {
  636.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  637.         {
  638.             //todo: strat context command (one button style)
  639.             return;
  640.         }
  641.     }
  642.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  643.     {
  644.         if (GetPawn() == CurrentFCStratPawn)
  645.         {
  646.             //todo: strat context action (2 button style)
  647.             return;
  648.         }
  649.     }
  650. }
  651.  
  652. void AFCPlayerController::HandleTertiaryActionEnd()
  653. {
  654.     if (!GetPawn())//no pawn means this can't possibly do anything
  655.     {
  656.         return;
  657.     }
  658.     if (CurrentFCHero)
  659.     {
  660.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  661.         {
  662.             //todo: flare or secondary fire, havent decided yet
  663.             return;
  664.         }
  665.     }
  666.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  667.     {
  668.         if (GetPawn() == CurrentFCStratPawn)
  669.         {
  670.             //todo: drag scroll
  671.             IsDragScrolling = false;
  672.             return;
  673.         }
  674.     }
  675. }
  676.  
  677. void AFCPlayerController::HandleNextWeapon()
  678. {
  679.     if (!GetPawn())//no pawn means this can't possibly do anything
  680.     {
  681.         return;
  682.     }
  683.     if (CurrentFCHero)
  684.     {
  685.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  686.         {
  687.             //todo: next weapon
  688.             return;
  689.         }
  690.     }
  691.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  692.     {
  693.         if (GetPawn() == CurrentFCStratPawn)
  694.         {
  695.             //todo: zoom in
  696.             CurrentFCStratPawn->SetActorLocation(CurrentFCStratPawn->GetActorLocation() + FVector(0.0, 0.0, -1000.0));
  697.             return;
  698.         }
  699.     }
  700. }
  701.  
  702. void AFCPlayerController::HandlePrevWeapon()
  703. {
  704.     if (!GetPawn())//no pawn means this can't possibly do anything
  705.     {
  706.         return;
  707.     }
  708.     if (CurrentFCHero)
  709.     {
  710.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  711.         {
  712.             //todo: previous weapon
  713.             return;
  714.         }
  715.     }
  716.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  717.     {
  718.         if (GetPawn() == CurrentFCStratPawn)
  719.         {
  720.             //todo: zoom out
  721.             CurrentFCStratPawn->SetActorLocation(CurrentFCStratPawn->GetActorLocation() + FVector(0.0, 0.0, 1000.0));
  722.             return;
  723.         }
  724.     }
  725. }
  726.  
  727. void AFCPlayerController::HandleStratCommand1()
  728. {
  729.     if (!GetPawn())//no pawn means this can't possibly do anything
  730.     {
  731.         return;
  732.     }
  733.     if (CurrentFCHero)
  734.     {
  735.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  736.         {
  737.             //todo:
  738.             GiveStratCommand(1);
  739.             return;
  740.         }
  741.     }
  742.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  743.     {
  744.         if (GetPawn() == CurrentFCStratPawn)
  745.         {
  746.             //todo:
  747.             GiveStratCommand(1);
  748.             return;
  749.         }
  750.     }
  751. }
  752.  
  753. void AFCPlayerController::HandleStratCommand2()
  754. {
  755.     if (!GetPawn())//no pawn means this can't possibly do anything
  756.     {
  757.         return;
  758.     }
  759.     if (CurrentFCHero)
  760.     {
  761.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  762.         {
  763.             //todo:
  764.             GiveStratCommand(2);
  765.             return;
  766.         }
  767.     }
  768.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  769.     {
  770.         if (GetPawn() == CurrentFCStratPawn)
  771.         {
  772.             //todo:
  773.             GiveStratCommand(2);
  774.             return;
  775.         }
  776.     }
  777. }
  778.  
  779. void AFCPlayerController::HandleStratCommand3()
  780. {
  781.     if (!GetPawn())//no pawn means this can't possibly do anything
  782.     {
  783.         return;
  784.     }
  785.     if (CurrentFCHero)
  786.     {
  787.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  788.         {
  789.             //todo:
  790.             GiveStratCommand(3);
  791.             return;
  792.         }
  793.     }
  794.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  795.     {
  796.         if (GetPawn() == CurrentFCStratPawn)
  797.         {
  798.             //todo:
  799.             GiveStratCommand(3);
  800.             return;
  801.         }
  802.     }
  803. }
  804.  
  805. void AFCPlayerController::HandleStratCommand4()
  806. {
  807.     if (!GetPawn())//no pawn means this can't possibly do anything
  808.     {
  809.         return;
  810.     }
  811.     if (CurrentFCHero)
  812.     {
  813.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  814.         {
  815.             //todo:
  816.             GiveStratCommand(4);
  817.             return;
  818.         }
  819.     }
  820.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  821.     {
  822.         if (GetPawn() == CurrentFCStratPawn)
  823.         {
  824.             //todo:
  825.             GiveStratCommand(4);
  826.             return;
  827.         }
  828.     }
  829. }
  830.  
  831. void AFCPlayerController::HandleStratCommand5()
  832. {
  833.     if (!GetPawn())//no pawn means this can't possibly do anything
  834.     {
  835.         return;
  836.     }
  837.     if (CurrentFCHero)
  838.     {
  839.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  840.         {
  841.             //todo:
  842.             GiveStratCommand(5);
  843.             return;
  844.         }
  845.     }
  846.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  847.     {
  848.         if (GetPawn() == CurrentFCStratPawn)
  849.         {
  850.             //todo:
  851.             GiveStratCommand(5);
  852.             return;
  853.         }
  854.     }
  855. }
  856.  
  857. void AFCPlayerController::HandleStratCommand6()
  858. {
  859.     if (!GetPawn())//no pawn means this can't possibly do anything
  860.     {
  861.         return;
  862.     }
  863.     if (CurrentFCHero)
  864.     {
  865.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  866.         {
  867.             //todo:
  868.             GiveStratCommand(6);
  869.             return;
  870.         }
  871.     }
  872.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  873.     {
  874.         if (GetPawn() == CurrentFCStratPawn)
  875.         {
  876.             //todo:
  877.             GiveStratCommand(6);
  878.             return;
  879.         }
  880.     }
  881. }
  882.  
  883. void AFCPlayerController::HandleStratCommand7()
  884. {
  885.     if (!GetPawn())//no pawn means this can't possibly do anything
  886.     {
  887.         return;
  888.     }
  889.     if (CurrentFCHero)
  890.     {
  891.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  892.         {
  893.             //todo:
  894.             GiveStratCommand(7);
  895.             return;
  896.         }
  897.     }
  898.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  899.     {
  900.         if (GetPawn() == CurrentFCStratPawn)
  901.         {
  902.             //todo:
  903.             GiveStratCommand(7);
  904.             return;
  905.         }
  906.     }
  907. }
  908.  
  909. void AFCPlayerController::HandleStratCommand8()
  910. {
  911.     if (!GetPawn())//no pawn means this can't possibly do anything
  912.     {
  913.         return;
  914.     }
  915.     if (CurrentFCHero)
  916.     {
  917.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  918.         {
  919.             //todo:
  920.             GiveStratCommand(8);
  921.             return;
  922.         }
  923.     }
  924.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  925.     {
  926.         if (GetPawn() == CurrentFCStratPawn)
  927.         {
  928.             //todo:
  929.             GiveStratCommand(8);
  930.             return;
  931.         }
  932.     }
  933. }
  934.  
  935. void AFCPlayerController::HandleStratCommand9()
  936. {
  937.     if (!GetPawn())//no pawn means this can't possibly do anything
  938.     {
  939.         return;
  940.     }
  941.     if (CurrentFCHero)
  942.     {
  943.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  944.         {
  945.             //todo:
  946.             GiveStratCommand(9);
  947.             return;
  948.         }
  949.     }
  950.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  951.     {
  952.         if (GetPawn() == CurrentFCStratPawn)
  953.         {
  954.             //todo:
  955.             GiveStratCommand(9);
  956.             return;
  957.         }
  958.     }
  959. }
  960.  
  961. void AFCPlayerController::HandleStratCommand0()
  962. {
  963.     if (!GetPawn())//no pawn means this can't possibly do anything
  964.     {
  965.         return;
  966.     }
  967.     if (CurrentFCHero)
  968.     {
  969.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  970.         {
  971.             //todo:
  972.             GiveStratCommand(10);
  973.             return;
  974.         }
  975.     }
  976.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  977.     {
  978.         if (GetPawn() == CurrentFCStratPawn)
  979.         {
  980.             //todo:
  981.             GiveStratCommand(10);
  982.             return;
  983.         }
  984.     }
  985. }
  986.  
  987. void AFCPlayerController::HandleHotGroup1()
  988. {
  989.     if (!GetPawn())//no pawn means this can't possibly do anything
  990.     {
  991.         return;
  992.     }
  993.     if (CurrentFCHero)
  994.     {
  995.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  996.         {
  997.             //todo:
  998.             SelectHotGroup(1);
  999.             return;
  1000.         }
  1001.     }
  1002.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  1003.     {
  1004.         if (GetPawn() == CurrentFCStratPawn)
  1005.         {
  1006.             //todo:
  1007.             SelectHotGroup(1);
  1008.             return;
  1009.         }
  1010.     }
  1011. }
  1012.  
  1013. void AFCPlayerController::HandleHotGroup2()
  1014. {
  1015.     if (!GetPawn())//no pawn means this can't possibly do anything
  1016.     {
  1017.         return;
  1018.     }
  1019.     if (CurrentFCHero)
  1020.     {
  1021.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  1022.         {
  1023.             //todo:
  1024.             SelectHotGroup(2);
  1025.             return;
  1026.         }
  1027.     }
  1028.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  1029.     {
  1030.         if (GetPawn() == CurrentFCStratPawn)
  1031.         {
  1032.             //todo:
  1033.             SelectHotGroup(2);
  1034.             return;
  1035.         }
  1036.     }
  1037. }
  1038.  
  1039. void AFCPlayerController::HandleHotGroup3()
  1040. {
  1041.     if (!GetPawn())//no pawn means this can't possibly do anything
  1042.     {
  1043.         return;
  1044.     }
  1045.     if (CurrentFCHero)
  1046.     {
  1047.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  1048.         {
  1049.             //todo:
  1050.             SelectHotGroup(3);
  1051.             return;
  1052.         }
  1053.     }
  1054.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  1055.     {
  1056.         if (GetPawn() == CurrentFCStratPawn)
  1057.         {
  1058.             //todo:
  1059.             SelectHotGroup(3);
  1060.             return;
  1061.         }
  1062.     }
  1063. }
  1064.  
  1065. void AFCPlayerController::HandleHotGroup4()
  1066. {
  1067.     if (!GetPawn())//no pawn means this can't possibly do anything
  1068.     {
  1069.         return;
  1070.     }
  1071.     if (CurrentFCHero)
  1072.     {
  1073.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  1074.         {
  1075.             //todo:
  1076.             SelectHotGroup(4);
  1077.             return;
  1078.         }
  1079.     }
  1080.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  1081.     {
  1082.         if (GetPawn() == CurrentFCStratPawn)
  1083.         {
  1084.             //todo:
  1085.             SelectHotGroup(4);
  1086.             return;
  1087.         }
  1088.     }
  1089. }
  1090.  
  1091. void AFCPlayerController::HandleHotGroup5()
  1092. {
  1093.     if (!GetPawn())//no pawn means this can't possibly do anything
  1094.     {
  1095.         return;
  1096.     }
  1097.     if (CurrentFCHero)
  1098.     {
  1099.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  1100.         {
  1101.             //todo:
  1102.             SelectHotGroup(5);
  1103.             return;
  1104.         }
  1105.     }
  1106.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  1107.     {
  1108.         if (GetPawn() == CurrentFCStratPawn)
  1109.         {
  1110.             //todo:
  1111.             SelectHotGroup(5);
  1112.             return;
  1113.         }
  1114.     }
  1115. }
  1116.  
  1117. void AFCPlayerController::HandleHotGroup6()
  1118. {
  1119.     if (!GetPawn())//no pawn means this can't possibly do anything
  1120.     {
  1121.         return;
  1122.     }
  1123.     if (CurrentFCHero)
  1124.     {
  1125.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  1126.         {
  1127.             //todo:
  1128.             SelectHotGroup(6);
  1129.             return;
  1130.         }
  1131.     }
  1132.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  1133.     {
  1134.         if (GetPawn() == CurrentFCStratPawn)
  1135.         {
  1136.             //todo:
  1137.             SelectHotGroup(6);
  1138.             return;
  1139.         }
  1140.     }
  1141. }
  1142.  
  1143. void AFCPlayerController::HandleHotGroup7()
  1144. {
  1145.     if (!GetPawn())//no pawn means this can't possibly do anything
  1146.     {
  1147.         return;
  1148.     }
  1149.     if (CurrentFCHero)
  1150.     {
  1151.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  1152.         {
  1153.             //todo:
  1154.             SelectHotGroup(7);
  1155.             return;
  1156.         }
  1157.     }
  1158.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  1159.     {
  1160.         if (GetPawn() == CurrentFCStratPawn)
  1161.         {
  1162.             //todo:
  1163.             SelectHotGroup(7);
  1164.             return;
  1165.         }
  1166.     }
  1167. }
  1168.  
  1169. void AFCPlayerController::HandleHotGroup8()
  1170. {
  1171.     if (!GetPawn())//no pawn means this can't possibly do anything
  1172.     {
  1173.         return;
  1174.     }
  1175.     if (CurrentFCHero)
  1176.     {
  1177.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  1178.         {
  1179.             //todo:
  1180.             SelectHotGroup(8);
  1181.             return;
  1182.         }
  1183.     }
  1184.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  1185.     {
  1186.         if (GetPawn() == CurrentFCStratPawn)
  1187.         {
  1188.             //todo:
  1189.             SelectHotGroup(8);
  1190.             return;
  1191.         }
  1192.     }
  1193. }
  1194.  
  1195. void AFCPlayerController::HandleHotGroup9()
  1196. {
  1197.     if (!GetPawn())//no pawn means this can't possibly do anything
  1198.     {
  1199.         return;
  1200.     }
  1201.     if (CurrentFCHero)
  1202.     {
  1203.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  1204.         {
  1205.             //todo:
  1206.             SelectHotGroup(9);
  1207.             return;
  1208.         }
  1209.     }
  1210.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  1211.     {
  1212.         if (GetPawn() == CurrentFCStratPawn)
  1213.         {
  1214.             //todo:
  1215.             SelectHotGroup(9);
  1216.             return;
  1217.         }
  1218.     }
  1219. }
  1220.  
  1221. void AFCPlayerController::HandleHotGroup10()
  1222. {
  1223.     if (!GetPawn())//no pawn means this can't possibly do anything
  1224.     {
  1225.         return;
  1226.     }
  1227.     if (CurrentFCHero)
  1228.     {
  1229.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  1230.         {
  1231.             //todo:
  1232.             SelectHotGroup(10);
  1233.             return;
  1234.         }
  1235.     }
  1236.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  1237.     {
  1238.         if (GetPawn() == CurrentFCStratPawn)
  1239.         {
  1240.             //todo:
  1241.             SelectHotGroup(10);
  1242.             return;
  1243.         }
  1244.     }
  1245. }
  1246.  
  1247. void AFCPlayerController::HandleSwapKey()
  1248. {
  1249.     AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
  1250.     if (!GetPawn())//no pawn means this can't possibly do anything
  1251.     {
  1252.         return;
  1253.     }
  1254.     if (CurrentFCHero)
  1255.     {
  1256.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  1257.         {
  1258.             //todo:
  1259.             if (fcps)
  1260.             {
  1261.                 if (fcps->SelectedUnits.Num() > 0)
  1262.                 {
  1263.  
  1264.                 }
  1265.                 else
  1266.                 {
  1267.                     TArray<AFCUnit*> temparray = TArray<AFCUnit*>();
  1268.                     temparray.Add(CurrentFCHero);
  1269.                     PlayerSelectUnits(temparray);
  1270.                 }
  1271.             }
  1272.             return;
  1273.         }
  1274.     }
  1275.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  1276.     {
  1277.         if (GetPawn() == CurrentFCStratPawn)
  1278.         {
  1279.             //todo:
  1280.             return;
  1281.         }
  1282.     }
  1283. }
  1284.  
  1285. void AFCPlayerController::HandleCancelKey()
  1286. {
  1287.     AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
  1288.     if (!GetPawn())//no pawn means this can't possibly do anything
  1289.     {
  1290.         return;
  1291.     }
  1292.     if (CurrentFCHero)
  1293.     {
  1294.         if (GetPawn() == CurrentFCHero)//if we have a hero and it is the current pawn
  1295.         {
  1296.             //todo:
  1297.             if (fcps)
  1298.             {
  1299.                 if (fcps->SelectedUnits.Num() > 0)
  1300.                 {
  1301.                     PlayerDeselectAllUnits();
  1302.                 }
  1303.             }
  1304.             return;
  1305.         }
  1306.     }
  1307.     if (CurrentFCStratPawn)//if we have a strat pawn and it is the current pawn
  1308.     {
  1309.         if (GetPawn() == CurrentFCStratPawn)
  1310.         {
  1311.             //todo:
  1312.             if (fcps)
  1313.             {
  1314.                 if (fcps->SelectedUnits.Num() > 0)
  1315.                 {
  1316.                     PlayerDeselectAllUnits();
  1317.                 }
  1318.             }
  1319.             return;
  1320.         }
  1321.     }
  1322. }
  1323.  
  1324. void AFCPlayerController::SelectHotGroup(int32 group)
  1325. {
  1326.  
  1327. }
  1328.  
  1329. void AFCPlayerController::GiveStratCommand(int32 Idx)
  1330. {
  1331.     AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
  1332.     if (fcps->SelectedUnits.Num() > 0)
  1333.     {
  1334.  
  1335.     }
  1336.     else
  1337.     {
  1338.         if ((fcps->PlayerBases.Num() >= Idx) && (Idx > 0))
  1339.         {
  1340.             TArray<AFCUnit*> temparray = TArray<AFCUnit*>();
  1341.             temparray.Add(fcps->PlayerBases[Idx - 1]);
  1342.             //const TArray<AFCUnit*>& tempconstarray = temparray.GetData();
  1343.             PlayerSelectUnits(temparray);
  1344.         }
  1345.     }
  1346. }
  1347.  
  1348. void AFCPlayerController::OnRep_StratPawn()
  1349. {
  1350.  
  1351. }
  1352. void AFCPlayerController::OnRep_HeroPawn()
  1353. {
  1354.  
  1355. }
  1356.  
  1357. void AFCPlayerController::PlayerSelectUnits(const TArray<AFCUnit*>& NewUnits)
  1358. {
  1359.     AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
  1360.     int32 i = 0;
  1361.     if (fcps)
  1362.     {
  1363.         if (Role < ROLE_Authority)
  1364.         {
  1365.             ServerPlayerSelectUnits(NewUnits);
  1366.         }
  1367.         for (i = 0; i < NewUnits.Num(); i++)
  1368.         {
  1369.             if (NewUnits[i])
  1370.             {
  1371.                 if ((NewUnits[i]->TeamIndex == fcps->PlayerTeamSlot) && (NewUnits[i]->ForceIndex == fcps->PlayerForceSlot))
  1372.                 {
  1373.                     if (fcps->SelectedUnits.Num() == 0)//if this is the first unit selected
  1374.                     {
  1375.                         PlayerChangeCommandMenuPage(0);//set the page back to root
  1376.                         TSubclassOf<AFCUnit> tempunitclass = NewUnits[i]->StaticClass();
  1377.                         PlayerChangeSubSelectionUnitType(tempunitclass);
  1378.                     }
  1379.                     fcps->SelectedUnits.AddUnique(NewUnits[i]);
  1380.                 }
  1381.             }
  1382.         }
  1383.     }
  1384. }
  1385.  
  1386. bool AFCPlayerController::ServerPlayerSelectUnits_Validate(const TArray<AFCUnit*>& NewUnits)
  1387. {
  1388.     return true;
  1389. }
  1390.  
  1391. void AFCPlayerController::ServerPlayerSelectUnits_Implementation(const TArray<AFCUnit*>& NewUnits)
  1392. {
  1393.     PlayerSelectUnits(NewUnits);
  1394. }
  1395.  
  1396. void AFCPlayerController::PlayerDeselectUnits(const TArray<AFCUnit*>& NewUnits)
  1397. {
  1398.     AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
  1399.     int32 i = 0;
  1400.     if (fcps)
  1401.     {
  1402.         for (i = 0; i < NewUnits.Num(); i++)
  1403.         {
  1404.             if (NewUnits[i])
  1405.             {
  1406.                 if ((NewUnits[i]->TeamIndex == fcps->PlayerTeamSlot) && (NewUnits[i]->ForceIndex == fcps->PlayerForceSlot))
  1407.                 {
  1408.                     fcps->SelectedUnits.Remove(NewUnits[i]);
  1409.                     if (fcps->SelectedUnits.Num() == 0)
  1410.                     {
  1411.                         PlayerChangeCommandMenuPage(0);//set the page back to root
  1412.                     }
  1413.                 }
  1414.             }
  1415.         }
  1416.     }
  1417.     if (Role < ROLE_Authority)
  1418.     {
  1419.         ServerPlayerDeselectUnits(NewUnits);
  1420.     }
  1421. }
  1422.  
  1423. bool AFCPlayerController::ServerPlayerDeselectUnits_Validate(const TArray<AFCUnit*>& NewUnits)
  1424. {
  1425.     return true;
  1426. }
  1427.  
  1428. void AFCPlayerController::ServerPlayerDeselectUnits_Implementation(const TArray<AFCUnit*>& NewUnits)
  1429. {
  1430.     PlayerDeselectUnits(NewUnits);
  1431. }
  1432.  
  1433. void AFCPlayerController::PlayerDeselectAllUnits()
  1434. {
  1435.     AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
  1436.     if (fcps)
  1437.     {
  1438.         fcps->SelectedUnits.Empty();
  1439.         PlayerChangeCommandMenuPage(0);//set the page back to root
  1440.     }
  1441.     if (Role < ROLE_Authority)
  1442.     {
  1443.         ServerPlayerDeselectAllUnits();
  1444.     }
  1445. }
  1446.  
  1447. bool AFCPlayerController::ServerPlayerDeselectAllUnits_Validate()
  1448. {
  1449.     return true;
  1450. }
  1451.  
  1452. void AFCPlayerController::ServerPlayerDeselectAllUnits_Implementation()
  1453. {
  1454.     PlayerDeselectAllUnits();
  1455. }
  1456.  
  1457. void AFCPlayerController::PlayerChangeCommandMenuPage(int32 newpage)
  1458. {
  1459.     AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
  1460.     if (fcps)
  1461.     {
  1462.         fcps->PlayerCommandMenuPage = newpage;
  1463.         if (Role < ROLE_Authority)
  1464.         {
  1465.             ServerPlayerChangeCommandMenuPage(newpage);
  1466.         }
  1467.     }
  1468. }
  1469.  
  1470. bool AFCPlayerController::ServerPlayerChangeCommandMenuPage_Validate(int32 newpage)
  1471. {
  1472.     return true;
  1473. }
  1474.  
  1475. void AFCPlayerController::ServerPlayerChangeCommandMenuPage_Implementation(int32 newpage)
  1476. {
  1477.     PlayerChangeCommandMenuPage(newpage);
  1478. }
  1479.  
  1480. void AFCPlayerController::PlayerChangeSubSelectionUnitType(TSubclassOf<AFCUnit> NewUnitType)
  1481. {
  1482.     AFCPlayerState* fcps = (AFCPlayerState*)PlayerState;
  1483.     if (fcps)
  1484.     {
  1485.         fcps->SubSelectionUnitType = NewUnitType;
  1486.         if (Role < ROLE_Authority)
  1487.         {
  1488.             ServerPlayerChangeSubSelectionUnitType(NewUnitType);
  1489.         }
  1490.     }
  1491. }
  1492.  
  1493. bool AFCPlayerController::ServerPlayerChangeSubSelectionUnitType_Validate(TSubclassOf<AFCUnit> NewUnitType)
  1494. {
  1495.     return true;
  1496. }
  1497.  
  1498. void AFCPlayerController::ServerPlayerChangeSubSelectionUnitType_Implementation(TSubclassOf<AFCUnit> NewUnitType)
  1499. {
  1500.     PlayerChangeSubSelectionUnitType(NewUnitType);
  1501. }
  1502.  
  1503. void AFCPlayerController::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
  1504. {
  1505.     Super::GetLifetimeReplicatedProps(OutLifetimeProps);
  1506.  
  1507.     DOREPLIFETIME(AFCPlayerController, CurrentFCStratPawn);
  1508.     DOREPLIFETIME(AFCPlayerController, CurrentFCHero);
  1509. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement