67 lines
2.3 KiB
C++
67 lines
2.3 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "GameFramework/Controller.h"
|
|
#include "GameFramework/PlayerController.h"
|
|
#include "ThirdPersonController.generated.h"
|
|
|
|
class APlayerUnit;
|
|
class UUnitManagerComponent;
|
|
class AZoneActor;
|
|
|
|
UCLASS()
|
|
class MAYBETHISTIME_API AThirdPersonController : public APlayerController
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
|
|
public:
|
|
AThirdPersonController();
|
|
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite) UUnitManagerComponent* UnitManager;
|
|
UPROPERTY(Replicated, BlueprintReadOnly) FName PlayerFactionID;
|
|
|
|
UPROPERTY(BlueprintReadWrite) bool bShiftHeld;
|
|
|
|
// Units
|
|
UPROPERTY(Replicated, BlueprintReadOnly) APlayerUnit* PlayerUnit;
|
|
UFUNCTION(BlueprintCallable, BlueprintPure) APlayerUnit* GetPlayerUnit() const { return PlayerUnit; }
|
|
|
|
// Selection
|
|
UPROPERTY(BlueprintReadOnly) TArray<ABaseUnit*> SelectedUnits;
|
|
UFUNCTION(BlueprintCallable) void SelectUnit(ABaseUnit* Unit, bool bAddToSelection = false);
|
|
UFUNCTION(BlueprintCallable) void ClearUnitSelection();
|
|
UFUNCTION(BlueprintCallable) void BoxSelect(TArray<ABaseUnit*> UnitsInBox);
|
|
|
|
UPROPERTY(BlueprintReadOnly) TArray<AZoneActor*> SelectedZones;
|
|
UFUNCTION(BlueprintCallable) void SelectZone(AZoneActor* Zone, bool bAddToSelection = false);
|
|
UFUNCTION(BlueprintCallable) void ClearZoneSelection();
|
|
|
|
UFUNCTION(BlueprintCallable) void ClearMySelection();
|
|
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnSelectionChanged); // Delegate so UI knows when selection changes
|
|
UPROPERTY(BlueprintAssignable) FOnSelectionChanged OnSelectionChanged;
|
|
|
|
UFUNCTION(BlueprintCallable, BlueprintPure) TArray<AZoneActor*> GetOwnedZones() const;
|
|
UFUNCTION(BlueprintCallable) bool SelectClickedActor(AActor* ClickedActor);
|
|
|
|
// Currently hovered interactable
|
|
UPROPERTY() AActor* HoveredActor;
|
|
UFUNCTION(BlueprintCallable) void HandleHover();
|
|
UFUNCTION(BlueprintCallable) void HandleLeftClick();
|
|
UFUNCTION(BlueprintCallable) void HandleRightClick();
|
|
|
|
|
|
// Replication
|
|
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
|
protected:
|
|
virtual void BeginPlay() override;
|
|
virtual void Tick(float DeltaTime) override;
|
|
|
|
private:
|
|
UPROPERTY() AActor* LastHoveredActor;
|
|
bool IsMouseOverUI() const;
|
|
};
|