xoreos
0.0.5
src
engines
kotor
script
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
25
#include "
src/aurora/nwscript/functioncontext.h
"
26
27
#include "
src/engines/kotor/objectcontainer.h
"
28
#include "
src/engines/kotor/game.h
"
29
#include "
src/engines/kotor/module.h
"
30
31
#include "
src/engines/kotor/script/functions.h
"
32
#include "
src/engines/kotor/script/event.h
"
33
34
namespace
Engines
{
35
36
namespace
KotOR {
37
38
void
Functions::signalEvent
(
Aurora::NWScript::FunctionContext
&ctx) {
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
55
void
Functions::eventUserDefined
(
Aurora::NWScript::FunctionContext
&ctx) {
56
Event
e(
kEventUserDefined
);
57
e.
setUserDefinedNumber
(ctx.
getParams
()[0].getInt());
58
ctx.
getReturn
() = e;
59
}
60
61
void
Functions::getUserDefinedEventNumber
(
Aurora::NWScript::FunctionContext
&ctx) {
62
if
(
_lastEvent
&&
_lastEvent
->
getType
() ==
kEventUserDefined
)
63
ctx.
getReturn
() =
_lastEvent
->
getUserDefinedNumber
();
64
}
65
66
}
// End of namespace KotOR
67
68
}
// End of namespace Engines
Engines::KotOR::Functions::getUserDefinedEventNumber
void getUserDefinedEventNumber(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_events.cpp:61
Engines::KotOR::Object
Definition:
object.h:47
functioncontext.h
Context of an NWScript function.
Engines::KotOR::kEventUserDefined
Definition:
event.h:35
Engines::KotOR::Functions::signalEvent
void signalEvent(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_events.cpp:38
Engines::KotOR::Functions::_lastEvent
Event * _lastEvent
Definition:
functions.h:77
Engines::KotOR::Event::setUserDefinedNumber
void setUserDefinedNumber(int number)
Definition:
event.cpp:36
event.h
Star Wars: Knights of the Old Republic event engine type.
Aurora::NWScript::FunctionContext
Definition:
functioncontext.h:42
Engines::KotOR::kScriptUserdefined
Definition:
types.h:103
game.h
The context handling the gameplay in Star Wars: Knights of the Old Republic.
objectcontainer.h
A container of Star Wars: Knights of the Old Republic objects.
Engines::KotOR::Functions::eventUserDefined
void eventUserDefined(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_events.cpp:55
Common::Exception
StackException Exception
Definition:
error.h:59
Engines
Definition:
console.cpp:69
functions.h
Star Wars: Knights of the Old Republic engine functions.
Aurora::NWScript::FunctionContext::getParams
Parameters & getParams()
Definition:
functioncontext.cpp:151
Engines::KotOR::ObjectContainer::toObject
static KotOR::Object * toObject(::Aurora::NWScript::Object *object)
Definition:
objectcontainer.cpp:125
Engines::KotOR::Game::getModule
Module & getModule()
Return the module context.
Definition:
game.cpp:65
Engines::KotOR::Functions::_game
Game * _game
Definition:
functions.h:76
Aurora::NWScript::FunctionContext::getReturn
Variable & getReturn()
Definition:
functioncontext.cpp:143
module.h
The context needed to run a Star Wars: Knights of the Old Republic module.
Engines::KotOR::Event::getType
EventType getType() const
Definition:
event.cpp:40
Engines::KotOR::Event::getUserDefinedNumber
int getUserDefinedNumber() const
Definition:
event.cpp:44
Engines::KotOR::Event
Definition:
event.h:38
Engines::KotOR::Module::getPC
Creature * getPC()
Return the currently playing PC.
Definition:
module.cpp:181
Generated on Sun Nov 18 2018 15:13:40 for xoreos by
1.8.14