-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddWorkshopAction.cpp
More file actions
46 lines (37 loc) · 1.11 KB
/
Copy pathAddWorkshopAction.cpp
File metadata and controls
46 lines (37 loc) · 1.11 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
#include "AddWorkshopAction.h"
AddWorkshopAction::AddWorkshopAction(ApplicationManager * pApp) : Action(pApp)
{
// Initializes the pManager pointer of Action with the passed pointer
}
void AddWorkshopAction::ReadActionParameters()
{
// Get a pointer to the Input / Output Interfaces
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
pOut->PrintMessage("New Work Shop: Click on its Cell ...");
Workshippos = pIn->GetCellClicked();
if (!Workshippos.IsValidCell()) {
pOut->PrintMessage("Invalid cell! Click anywhere to continue.");
pIn->GetCellClicked();
return;
}
pOut->ClearStatusBar();
}
void AddWorkshopAction::Execute()
{
ReadActionParameters();
Workshop* pWorkshop = new Workshop(Workshippos);
Grid* pGrid = pManager->GetGrid();
bool added = pGrid->AddObjectToCell(pWorkshop);
// if the GameObject cannot be added
if (!added)
{
pGrid->PrintErrorMessage("Error: Cell already has an object ! Click to continue ...");
;
// Print an appropriate message
}
}
AddWorkshopAction::~AddWorkshopAction()
{
}