summaryrefslogtreecommitdiff
path: root/src/game-server/item.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game-server/item.cpp')
-rw-r--r--src/game-server/item.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/game-server/item.cpp b/src/game-server/item.cpp
index c6c9d11c..44029303 100644
--- a/src/game-server/item.cpp
+++ b/src/game-server/item.cpp
@@ -1,6 +1,7 @@
/*
* The Mana Server
* Copyright (C) 2004-2010 The Mana World Development Team
+ * Copyright (C) 2010-2012 The Mana Developers
*
* This file is part of The Mana Server.
*
@@ -150,19 +151,37 @@ void ItemClass::addAttack(AttackInfo *attackInfo,
addEffect(new ItemEffectAttack(attackInfo), applyTrigger, dispellTrigger);
}
+const ComponentType ItemComponent::type;
-Item::Item(ItemClass *type, int amount)
- : Actor(OBJECT_ITEM), mType(type), mAmount(amount)
+ItemComponent::ItemComponent(ItemClass *type, int amount) :
+ mType(type),
+ mAmount(amount)
{
mLifetime = Configuration::getValue("game_floorItemDecayTime", 0) * 10;
}
-void Item::update()
+void ItemComponent::update(Entity &entity)
{
if (mLifetime)
{
mLifetime--;
if (!mLifetime)
- GameState::enqueueRemove(this);
+ GameState::enqueueRemove(static_cast<Actor*>(&entity));
}
}
+
+namespace Item {
+
+Actor *create(MapComposite *map,
+ Point pos,
+ ItemClass *itemClass,
+ int amount)
+{
+ Actor *itemActor = new Actor(OBJECT_ITEM);
+ itemActor->addComponent(new ItemComponent(itemClass, amount));
+ itemActor->setMap(map);
+ itemActor->setPosition(pos);
+ return itemActor;
+}
+
+} // namespace Item