57 lines
1.0 KiB
C++
57 lines
1.0 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "ShapeAsset.h"
|
|
|
|
UShapeAsset::UShapeAsset()
|
|
{
|
|
|
|
InitializeShape();
|
|
}
|
|
|
|
void UShapeAsset::InitializeShape()
|
|
{
|
|
Slots.Empty();
|
|
for (int x = 0; x < ShapeWidth; x++)
|
|
{
|
|
for (int y = 0; y < ShapeHeight; y++)
|
|
{
|
|
Slots.Add(FShapeSlot(x, y, true));
|
|
}
|
|
}
|
|
}
|
|
|
|
bool UShapeAsset::IsSlotActive(int32 X, int32 Y) const
|
|
{
|
|
if (X < 0 || X >= ShapeWidth || Y < 0 || Y >= ShapeHeight)
|
|
return false;
|
|
|
|
for (auto BagSlot: Slots)
|
|
{
|
|
if (BagSlot.X == X && BagSlot.Y == Y)
|
|
return BagSlot.bIsActive;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void UShapeAsset::SetSlotActive(int32 X, int32 Y, bool Active)
|
|
{
|
|
if (X < 0 || X >= ShapeWidth || Y < 0 || Y >= ShapeHeight)
|
|
return;
|
|
int SlotIndex = FIndSlotIndex(X, Y);
|
|
if (SlotIndex != INDEX_NONE)
|
|
{
|
|
Slots[SlotIndex].bIsActive = Active;
|
|
}
|
|
}
|
|
|
|
int32 UShapeAsset::FIndSlotIndex(int32 X, int32 Y) const
|
|
{
|
|
for (int i = 0; i < Slots.Num(); i++)
|
|
{
|
|
if (Slots[i].X == X && Slots[i].Y == Y)
|
|
return i;
|
|
}
|
|
return INDEX_NONE;
|
|
}
|