xoreos  0.0.5
functions_events.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2 *
3 * xoreos is the legal property of its developers, whose names
4 * can be found in the AUTHORS file distributed with this source
5 * distribution.
6 *
7 * xoreos is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * xoreos is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
26 
28 #include "src/engines/kotor/game.h"
30 
33 
34 namespace Engines {
35 
36 namespace KotOR {
37 
39  Engines::KotOR::Object *object = ObjectContainer::toObject(ctx.getParams()[0].getObject());
40  if (!object)
41  object = _game->getModule().getPC();
42 
43  Event *e = static_cast<Event *>(ctx.getParams()[1].getEngineType());
44  if (!e)
45  throw Common::Exception("Functions::signalEvent(): Invalid event");
46 
47  switch (e->getType()) {
48  case kEventUserDefined:
49  _lastEvent = e;
50  object->runScript(kScriptUserdefined, object);
51  break;
52  }
53 }
54 
57  e.setUserDefinedNumber(ctx.getParams()[0].getInt());
58  ctx.getReturn() = e;
59 }
60 
64 }
65 
66 } // End of namespace KotOR
67 
68 } // End of namespace Engines
void getUserDefinedEventNumber(Aurora::NWScript::FunctionContext &ctx)
Context of an NWScript function.
void signalEvent(Aurora::NWScript::FunctionContext &ctx)
void setUserDefinedNumber(int number)
Definition: event.cpp:36
Star Wars: Knights of the Old Republic event engine type.
The context handling the gameplay in Star Wars: Knights of the Old Republic.
A container of Star Wars: Knights of the Old Republic objects.
void eventUserDefined(Aurora::NWScript::FunctionContext &ctx)
StackException Exception
Definition: error.h:59
Star Wars: Knights of the Old Republic engine functions.
static KotOR::Object * toObject(::Aurora::NWScript::Object *object)
Module & getModule()
Return the module context.
Definition: game.cpp:65
The context needed to run a Star Wars: Knights of the Old Republic module.
EventType getType() const
Definition: event.cpp:40
int getUserDefinedNumber() const
Definition: event.cpp:44
Creature * getPC()
Return the currently playing PC.
Definition: module.cpp:181