-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddWorkShopAction.cpp
More file actions
47 lines (38 loc) · 1.24 KB
/
Copy pathAddWorkShopAction.cpp
File metadata and controls
47 lines (38 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "AddWorkShopAction.h"
AddWorkShopAction::AddWorkShopAction(ApplicationManager* pApp) : Action(pApp)
{}
void AddWorkShopAction::ReadActionParameters()
{
Grid* pGrid = pManager->GetGrid();
Input* pIn = pGrid->GetInput();
Output* pOut = pGrid->GetOutput();
pOut->PrintMessage("Click on a cell to place the WorkShop.");
WorkShopPos = pIn->GetCellClicked();
if (!(WorkShopPos.IsValidGameObjectCell()) || !(pGrid->IsCellEmpty(WorkShopPos)))
{
pOut->PrintMessage("Invalid cell selected! The Action is canceled. Click to continue");
int x, y;
pIn->GetPointClicked(x, y);
WorkShopPos = CellPosition(-1, -1);
return;
}
pOut->ClearStatusBar();
}
void AddWorkShopAction::Execute()
{
ReadActionParameters();
Grid* pGrid = pManager->GetGrid();
if (!(WorkShopPos.IsValidGameObjectCell()))
return;
Workshop* pWorkshop = new Workshop(WorkShopPos);
bool empty = pGrid->AddObjectToCell(pWorkshop);
if (!empty)
{
pGrid->PrintErrorMessage("Cannot add Workshop, Cell is invalid or occupied, Click to continue.");
delete pWorkshop;
return;
}
}
AddWorkShopAction::~AddWorkShopAction()
{
}