Advertisement
Guest User

Untitled

a guest
May 12th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.85 KB | None | 0 0
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2.  
  3. #pragma once
  4.  
  5. #include "CoreMinimal.h"
  6. #include "Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h"
  7. #include "Runtime/Engine/Classes/Components/StaticMeshComponent.h"
  8. #include "GameFramework/Actor.h"
  9. #include "Grid.generated.h"
  10.  
  11. /*
  12. * Enumeration to keep track of the type of grid. This drastically affects the source code, so it's important to keep track
  13. */
  14.  
  15. /* Because of the way our grid system works (where tiles can exist anywhere and everything in between
  16. is filled with nothings), we need a way to define these nothings. We can't use (0,0,0) because that may very
  17. well be the location of a grid. For our purposes, we will have a vector located at Infinity, since
  18. we don't want it to exist in-game */
  19. #define NULL_VECTOR FVector(INFINITY, INFINITY, INFINITY)
  20.  
  21. UENUM(BlueprintType)
  22. enum class EGridType : uint8
  23. {
  24.     EUnknown,
  25.     ETriangle,
  26.     ESquare,
  27.     EHexagon
  28. };
  29.  
  30. UCLASS()
  31. class TACTICSGAME_API AGrid : public AActor
  32. {
  33.     GENERATED_BODY()
  34.  
  35. public:
  36.     /* Initialize a grid
  37.     * The default constructor can get away with doing nothing because we always call a specific type anyway*/
  38.     AGrid();
  39.  
  40.     /* Called every frame */
  41.     virtual void Tick(float DeltaTime) override;
  42.  
  43.     /* Get the type of grid this is. There is no setter because a grid MUST keep its type consistant */
  44.     UFUNCTION(BlueprintPure, Category = "Grid")
  45.         EGridType GetGridType() const;
  46.  
  47.     /* The grid origin is the position of where the first space on the grid would be placed.
  48.     This is just the location of the Root Component, so we don't need to define a class variable*/
  49.     UFUNCTION(BlueprintPure, Category = "Grid")
  50.         FVector GetGridOrigin() const;
  51.  
  52. protected:
  53.     // Called when the game starts or when spawned
  54.     virtual void BeginPlay() override;
  55.  
  56.     /* This grid's type */
  57.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Grid")
  58.         EGridType GridType;
  59.  
  60.     /*
  61.     Array of vectors, used to store the structure of the grid
  62.     The reason we store an array of vectors at each point is to allow for multilevel maps (e.g. going underneath a bridge)
  63.     When the mouse moves over a space, hitting a key should switch between different vertical layers if possible.
  64.     Actually, since nested TArrays are not supported, we'll just use arithmetic to treat a 1D array as a 2D array, based on x and y
  65.     This also is the most flexible way to hold it.
  66.     This type of grid means we can easily shift between any number of dimensions, depending on our game type
  67.     */
  68.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Grid")
  69.         TArray<FVector> Grid;
  70.  
  71.     /* Static mesh to represent the grid in the level
  72.     This works by defining a mesh for a space of the grid (such as a square or hex), and copying it for each space*/
  73.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Grid")
  74.         class UStaticMeshComponent* GridMesh;
  75.  
  76. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement