-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCmdCreatePointEntity.cpp
81 lines (63 loc) · 1.91 KB
/
CmdCreatePointEntity.cpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//==============================
// CmdCreatePointEntity.cpp
//==============================
#include "pre.h"
#include "qe3.h"
#include "CmdCreatePointEntity.h"
#include "map.h"
#include "select.h"
// classname hack confirmation is done by the UI before creating this command,
// which assumes that whatever classname it is asked to create as a point entity
// is what was actually desired
CmdCreatePointEntity::CmdCreatePointEntity(const std::string& classname, const vec3 origin) : ent(nullptr), Command("Create Point Entity")
{
selectOnDo = true;
modifiesSelection = true;
if (classname == "worldspawn")
CmdError("Cannot create a new worldspawn entity.");
EntClass* ec = EntClass::ForName(classname, false, false);
CreatePointEntity(ec, origin);
state = LIVE;
}
CmdCreatePointEntity::CmdCreatePointEntity(EntClass* eclass, const vec3 origin) : ent(nullptr), Command("Create Point Entity")
{
selectOnDo = true;
modifiesSelection = true;
if (eclass == EntClass::Worldspawn())
CmdError("Cannot create a new worldspawn entity.");
CreatePointEntity(eclass, origin);
state = LIVE;
}
CmdCreatePointEntity::~CmdCreatePointEntity()
{
if (state == LIVE || state == UNDONE)
delete ent;
}
void CmdCreatePointEntity::CreatePointEntity(EntClass* eclass, const vec3 origin)
{
ent = new Entity();
ent->SetKeyValueIVector("origin", origin);
ent->ChangeClass(eclass);
}
//==============================
void CmdCreatePointEntity::Do_Impl()
{
ent->AddToList(&g_map.entities);
ent->brushes.ENext()->AddToList(g_map.brActive);
}
void CmdCreatePointEntity::Undo_Impl()
{
ent->RemoveFromList();
ent->brushes.ENext()->RemoveFromList();
}
void CmdCreatePointEntity::Redo_Impl()
{
ent->AddToList(&g_map.entities);
ent->brushes.ENext()->AddToList(g_map.brActive);
}
void CmdCreatePointEntity::Sel_Impl()
{
if (state != DONE) return;
ent->brushes.ENext()->RemoveFromList();
ent->brushes.ENext()->AddToList(g_brSelectedBrushes);
}