It is very simple, i have :
Code:
public class Character
{
private string m_characterName;
private InventoryComponent m_inventory;
...
// all get and set
}
public class InventoryComponent
{
private int m_activeWeapon;
private int m_money;
private IDictionary m_inventoryItems; // hashtable of InventoryItem
...
// all get and set
}
public class InventoryItem
{
private int m_itemName;
private int m_slot;
...
// all get and set
}
I want to do in my code :
Code:
Character char1 = new Character();
...
string char1Name = char1.characterName;
int char1Money = char1.inventory.money;
InventoryItem item = (InventoryItem) char1.inventory.inventoryItems(10); // get the item in the slot number 10
In my database i have 2 tables, the table Character with fields :
- characterName
- activeWeapon
- money
And the table InventoryItem with :
- characterName
- itemName
- slot
My mapping file look like :
Code:
<class name="DOL.GS.Database.Character, GameServer" table="`Character`">
<id name="CharacterName" type="String(24)" column="`CharacterName`">
<generator class="assigned" />
</id>
...
<component name="Inventory" class="DOL.GS.Database.InventoryComponent, GameServer">
<property name="ActiveWeapon" not-null="true" column="`ActiveWeapon`"/>
<property name="Money" not-null="true" column="`Money`"/>
<map name="InventoryItems" cascade="delete" table="`InventoryItem`">
<key column="`CharacterName`"/>
<index column="`SlotPosition`" type="Int"/>
<one-to-many class="DOL.GS.Database.InventoryItem, GameServer"/>
</map>
</component>
</class>
But it does not seems to work, how does i can map that please ? Thx