File: ETEdit.cpp

package info (click to toggle)
worlded 0.1.3-7
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,044 kB
  • ctags: 1,570
  • sloc: cpp: 8,093; ansic: 6,198; sh: 3,528; makefile: 419; yacc: 316; sed: 16
file content (82 lines) | stat: -rw-r--r-- 1,429 bytes parent folder | download | duplicates (3)
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
82
// $Id: ETEdit.cpp,v 1.4 2002/12/27 20:57:40 mat Exp $

#include "ETEdit.h"

#include "Application.h"
#include <sstream>

ETEdit::ETEdit (World *world) : EntityTool (world), m_Entity (NULL)
{}

ETEdit::~ETEdit()
{
   if (m_Entity) m_Entity->Unref();
}

/// Apply tool at (x,z)
void
ETEdit::Apply3D(Ark::Vector3 newpos, const Ark::Collision &col)
{
   if (col.GetType() != Ark::Collision::ENTITY)
   {
      m_Entity = NULL;
      return;
   }

   m_Entity = static_cast<Entity*>(col.m_Entity);
   std::cout << m_Entity->ToString();
   g_Application->GetUI()->EditEntity (m_Entity);
}

/// Update or reset tool
void
ETEdit::Update()
{
   m_Entity = NULL;
}

/// Create a command with a correct state.
Command*
ETEdit::CreateCommand()
{
   if (m_Entity == NULL)
      return NULL;
   else
      return new ECEdit (g_Application->GetWorld(), m_Entity);
}

///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////

ECEdit::ECEdit(World *world, Entity *entity) : 
   m_World (world),
   m_Entity (entity)
{
   assert (m_Entity != 0);
   m_Entity->Ref();
}

ECEdit::~ECEdit()
{
   if (m_Entity)
      m_Entity->Unref();
}

/// Return the command type.
std::string
ECEdit::Type() const
{
   return "Edit entity";
}

/// Execute this command.
void
ECEdit::Execute()
{
}

/// Undo the action done by this command.
void
ECEdit::Unexecute()
{
}