Skip to content

Instantly share code, notes, and snippets.

@Pranavpaharia

Pranavpaharia/.h

Created Dec 4, 2019
Embed
What would you like to do?
SWP_WorldPlayerPawn.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/DefaultPawn.h"
#include "SWP_WorldPlayerController.h"
#include "ASWP_HUD.h"
#include "SWP_MapTileManager.h"
#include "SWP_WorldPlayerPawn.generated.h"
/**
*
*/
class ASWP_MapTileManager;
class ASWP_WorldPlayerController;
class AASWP_HUD;
class USWP_DebugMenuUI;
UENUM(BlueprintType)
enum class EPlayerMoveState : uint8
{
PMS_UpEdge,
PMS_DownEdge,
PMS_LeftEdge,
PMS_RightEdge
};
UENUM(BlueprintType)
enum class EPMS_UpSide : uint8
{
UpSide_Inside,
UpSide_Outside
};
UENUM(BlueprintType)
enum class EPMS_DownSide : uint8
{
DownSide_Inside,
DownSide_Outside
};
UENUM(BlueprintType)
enum class EPMS_LeftSide : uint8
{
LeftSide_Inside,
LeftSide_Outside
};
UENUM(BlueprintType)
enum class EPMS_RightSide : uint8
{
RightSide_Inside,
RightSide_Outside
};
UCLASS()
class SMARTWORLDPRO_API ASWP_WorldPlayerPawn : public ADefaultPawn
{
#define PAWN_DEBUGON 1;
#define PAWN_DEBUGOFF 0;
const int DEBUG_PAWNMOVEMENT = DEBUG_OFF;
//GENERATED_BODY()
GENERATED_UCLASS_BODY()
UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* Camera;
/*UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
class USpringArmComponent* SpringArm;*/
virtual void BeginPlay() override;
virtual void PostInitializeComponents() override;
virtual void TurnAtRate(float Rate) override;
virtual void LookUpAtRate(float Rate) override;
virtual void Tick(float DeltaSeconds) override;
virtual void SetupPlayerInputComponent(UInputComponent* InInputComponent) override;
void ZoomingMethod(float Rate);
int zoomPitch = 0;
int MapZoomLevel = 13;
FVector2D& GetScreenCenter();
FVector2D mapCenterSizeVector = FVector2D::ZeroVector;
FVector2D zoomCenterLatLonVector;
FVector zoomCenterWorldVector;
bool bLookZoomCenter = true;
void CalculateCenterLatitudeLongitude(FVector worldPoint);
ASWP_WorldPlayerPawn();
ASWP_MapTileManager* EarthRef;
AActor* MarkerCube;
ASWP_WorldPlayerController* playerController;
float MouseDeltaX, MouseDeltaY, MaxMouseDeltaX, MaxMouseDeltaY;
float KeyboardDeltaX, KeyboardDeltaY;
bool bOnMouseDown;
float hValue = 1, vValue = 1;
AASWP_HUD* HUDRef;
void GoUpwardsPressed();
void GoUpwardsReleased();
void GoDownwardsPressed();
void GoDownwardsReleased();
void GoLeftPressed();
void GoLeftReleased();
void GoRightPressed();
void GoRightReleased();
void ClickedMouseDown();
void PanMap(FVector2D panVector );
void ClickedMouseReleased();
void GetEarthReference();
void CalculateMarkerVector();
float* fptr = nullptr;
bool bMoveUp, bMoveDown, bMoveLeft, bMoveRight;
FVector movDirection;
float movMagnitude = 0.1f;
FVector2D CurrentMovementOffset = FVector2D::ZeroVector;
FVector2D InitialPosition = FVector2D::ZeroVector;
FVector _origin;
FVector _mousePosition;
FVector _mousePositionPrev;
FVector2D _mouseDelta;
bool _shouldDrag = false;
void PanMapUsingMouse();
void CalculateMovementOffset();
bool bDragMouseOn;
bool bMoveLocalCamera = false;
bool bMoveKeyboardCamera = false;
bool ClampLocalPositionY();
bool ClampLocalPositionZ();
EPMS_UpSide pms_upState;
EPMS_DownSide pms_downState;
EPMS_LeftSide pms_leftState;
EPMS_RightSide pms_rightState;
void CameraPanState();
float MaxFOV, MinFOV;
float currentFOV;
float deltaFOV = 9.5f;
public:
void ResetAfterPanLimit();
UPROPERTY(EditAnywhere,BlueprintReadWrite)
float MaxLeftX = -130.f;//-7.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float MaxRightX = 120.f;//14.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float MaxUpY = 185.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float MaxDownY = -185.f;
USWP_DebugMenuUI* DebugMenuWidget;
FVector2D MovementOffsetMinLimit = FVector2D(-91.3f, -6.79f);
FVector2D MovementOffsetMaxLimit = FVector2D(99.44f, 13.66f);
// void MoveMarkerLeft();
// void MoveMarkerUp();
// UMovementComponent* actorMoveComponent = nullptr;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.