-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripting|World: Added the World.Thing class for mobj bindings
MobjThinkerData's info record is now an object derived from World.Thing. It identifies the mobj using its ID number, so native functions called via World.Thing can look up the native mobj.
- Loading branch information
Showing
10 changed files
with
144 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** @file bindings_world.h | ||
* | ||
* @authors Copyright (c) 2015 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#ifndef DENG_CLIENT_WORLD_BINDINGS_H | ||
#define DENG_CLIENT_WORLD_BINDINGS_H | ||
|
||
#include <de/Binder> | ||
|
||
namespace world { | ||
|
||
void initBindings(de::Binder &binder, de::Record &worldModule); | ||
|
||
} // namespace world | ||
|
||
#endif // DENG_CLIENT_WORLD_BINDINGS_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** @file bindings_world.cpp World related Doomsday Script bindings. | ||
* | ||
* @authors Copyright (c) 2015 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#include "world/bindings_world.h" | ||
#include "world/worldsystem.h" | ||
#include "world/map.h" | ||
#include "world/thinkers.h" | ||
#include "dd_main.h" | ||
|
||
#include <doomsday/world/mobj.h> | ||
#include <de/Context> | ||
|
||
using namespace de; | ||
|
||
namespace world { | ||
|
||
static mobj_t &instanceMobj(Context const &ctx) | ||
{ | ||
/// @todo Not necessarily always the current map. -jk | ||
int const id = ctx.selfInstance().geti(QStringLiteral("__id__"), 0); | ||
mobj_t *mo = App_WorldSystem().map().thinkers().mobjById(id); | ||
if(!mo) | ||
{ | ||
throw ::Map::MissingObjectError("instanceMobj", QString("Mobj %1 does not exist").arg(id)); | ||
} | ||
return *mo; | ||
} | ||
|
||
static Value *Function_Thing_Health(Context &ctx, Function::ArgumentValues const &) | ||
{ | ||
return new NumberValue(instanceMobj(ctx).health); | ||
} | ||
|
||
void initBindings(Binder &binder, Record &worldModule) | ||
{ | ||
// Thing | ||
{ | ||
Record &thing = worldModule.addRecord("Thing"); | ||
binder.init(thing) | ||
<< DENG2_FUNC_NOARG(Thing_Health, "health"); | ||
} | ||
} | ||
|
||
} // namespace world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters