-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCutobject.cpp
More file actions
50 lines (42 loc) · 1.4 KB
/
Copy pathCutobject.cpp
File metadata and controls
50 lines (42 loc) · 1.4 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
48
49
50
#include "Cutobject.h"
Cutobject::Cutobject(ApplicationManager* pApp) : Action(pApp)
{
}
void Cutobject::ReadActionParameters()
{
CutCopygrid = pManager->GetGrid();
Output* pOut = CutCopygrid->GetOutput();
Input* pIn = CutCopygrid->GetInput();
pOut->PrintMessage("click on cell to cut object");
Cutcellposition = pIn->GetCellClicked();
pOut->ClearStatusBar();
}
void Cutobject::Execute()
{
ReadActionParameters();
ClipboardC = CutCopygrid->Getobjectfromcelllist(Cutcellposition); //set gameobject on clipboard
if (dynamic_cast<Flag*>(CutCopygrid->Getobjectfromcelllist(Cutcellposition))) //check cell have flag
{
AddFlagAction::resetisflag(); //reset the static isflag so that we can paste or add new flag
}
if (dynamic_cast<Antenna*>(CutCopygrid->Getobjectfromcelllist(Cutcellposition))) // check cell have antenna
{
AddAntennaAction::resetisantenna(); //reset the static isantenna so that we can paste or add new antenna
}
if (!ClipboardC) //cell is empty
{
CutCopygrid->PrintErrorMessage("error : no object to cut ! click to continue..");
}
else if (dynamic_cast<Belt*>(ClipboardC)) //cell has belt can't be cutting
{
CutCopygrid->PrintErrorMessage("error : Belt can't be cut ! click to continue..");
}
else
{
CutCopygrid->SetClipboard(ClipboardC);
CutCopygrid->RemoveObjectFromCell(Cutcellposition);
}
}
Cutobject::~Cutobject()
{
}