summaryrefslogtreecommitdiffstats
path: root/src/scripting
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-18 22:24:38 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-03-25 20:32:36 +0100
commit7aee56f062989c8901322a09b2da40bb028eb222 (patch)
tree2c3712c3926121d35b0ef569e1eeed8f42e34b32 /src/scripting
parent8ebd7ef2c200009e6d22b2cfaa3dd0d849155db6 (diff)
downloadmanaserv-7aee56f062989c8901322a09b2da40bb028eb222.tar.gz
manaserv-7aee56f062989c8901322a09b2da40bb028eb222.tar.xz
manaserv-7aee56f062989c8901322a09b2da40bb028eb222.zip
Changed Item to a component of Actor
Items also have positions, so the ItemComponent only makes sense as part of an Actor. Later on it will probably be part of an entity that also has an ActorComponent. Since it was annoying to update all the places where items were created, I've introduced a function for this. The component types are now prefixed with "CT_" because I wanted to introduce an 'Item' namespace which would otherwise be conflicting. The component types enum isn't used much in the code so it can look a bit ugly. Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src/scripting')
-rw-r--r--src/scripting/lua.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index dfc1bb0..0dd6582 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -471,12 +471,8 @@ static int item_drop(lua_State *s)
const int number = luaL_optint(s, 4, 1);
MapComposite *map = checkCurrentMap(s);
- Item *i = new Item(ic, number);
-
- i->setMap(map);
- Point pos(x, y);
- i->setPosition(pos);
- GameState::enqueueInsert(i);
+ Actor *item = Item::create(map, Point(x, y), ic, number);
+ GameState::enqueueInsert(item);
return 0;
}
@@ -956,9 +952,9 @@ static int chr_inv_change(lua_State *s)
nb = inv.insert(id, nb);
if (nb)
{
- Item *item = new Item(ic, nb);
- item->setMap(q->getMap());
- item->setPosition(q->getPosition());
+ Actor *item = Item::create(q->getMap(),
+ q->getPosition(),
+ ic, nb);
GameState::enqueueInsert(item);
}
}