2022-02-03 01:11:06 +01:00
|
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
|
|
|
|
|
|
#include "MapObject.h"
|
|
|
|
#include "AdventureMap.h"
|
|
|
|
#include "HexTile.h"
|
|
|
|
|
|
|
|
// Sets default values
|
|
|
|
AMapObject::AMapObject()
|
|
|
|
{
|
|
|
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
|
|
|
PrimaryActorTick.bCanEverTick = true;
|
|
|
|
|
|
|
|
SceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Scene"));
|
|
|
|
RootComponent = SceneComponent;
|
|
|
|
OrientHexMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Orient"));
|
|
|
|
OrientHexMesh->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepWorldTransform);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called when the game starts or when spawned
|
|
|
|
void AMapObject::BeginPlay()
|
|
|
|
{
|
|
|
|
Super::BeginPlay();
|
|
|
|
Occupy();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called every frame
|
|
|
|
void AMapObject::Tick(float DeltaTime)
|
|
|
|
{
|
|
|
|
Super::Tick(DeltaTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMapObject::Touch()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMapObject::Activate()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-06-10 16:15:12 +02:00
|
|
|
// Any subclass of MapObject has a defined array of Vectors relative to its origin which has to occupy() upon being placed on the map.
|
2022-02-03 01:11:06 +01:00
|
|
|
void AMapObject::Occupy()
|
|
|
|
{
|
|
|
|
for (auto& V : Occupying) {
|
2022-06-10 16:15:12 +02:00
|
|
|
AHexTile* OccupiedHex = MapRef->Grid[MapRef->GridIndex(Origin->Q + V.Q, Origin->R + V.R)];
|
|
|
|
OccupiedHex->bFree = false;
|
|
|
|
OccupiedHex->MapObject = this;
|
2022-02-03 01:11:06 +01:00
|
|
|
}
|
|
|
|
}
|