EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ItemFactory.h
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Zhur
24  Updates: Allan
25 */
26 #ifndef EVE_ITEM_FACTORY_H
27 #define EVE_ITEM_FACTORY_H
28 
29 //#include "eve-compat.h"
30 
31 #include "utils/Singleton.h"
32 #include "inventory/ItemRef.h"
33 //#include "../../eve-common/EVE_RAM.h"
34 
35 
36 class ItemType;
37 
38 class ItemData;
39 class CharacterData;
40 class CorpData;
41 class OfficeData;
42 class AsteroidData;
43 
44 class BlueprintType;
45 class CharacterType;
46 class StationType;
47 class Missile;
48 class Client;
49 class EntityList;
50 class Inventory;
51 class PyServiceMgr;
52 class InventoryDB;
53 
55 : public Singleton<ItemFactory>
56 {
57 public:
58  ItemFactory();
59  ~ItemFactory();
60 
61  void Close();
62  int Initialize();
63  uint32 Count() { return m_items.size(); }
64 
65  void SaveItems();
66  void RemoveItem(uint32 itemID);
67  void SetUsingClient(Client *pClient) { m_pClient = pClient; }
68  void UnsetUsingClient() { m_pClient = nullptr; }
69  void AddItem(InventoryItemRef iRef);
70 
71  InventoryDB* db() { return m_db; }
72 
74  // load=true will load the item and its container (recursively) into server, up to solarSystem
75  Inventory* GetInventoryFromId(uint32 itemID, bool load=true);
76  // load=true will load the item and its container (recursively) into server, up to solarSystem
78 
79  // these load, cache and return requested type.
80  const ItemType* GetType(uint16 typeID);
81  const StationType* GetStationType(uint16 stationTypeID);
82  const CharacterType* GetCharacterType(uint16 characterTypeID);
83  const BlueprintType* GetBlueprintType(uint16 blueprintTypeID);
85 
86 
87  // return a RefPtr of requested itemID, loading (and cache) as needed
89  ShipItemRef GetShip(uint32 shipID);
91  BlueprintRef GetBlueprint(uint32 blueprintID);
92  CharacterRef GetCharacter(uint32 characterID);
94  SolarSystemRef GetSolarSystem(uint32 solarSystemID);
105 
106 
117  CharacterRef SpawnCharacter(CharacterData& charData, CorpData& corpData);
127 
132  /* ID Authority Functions */
137 
138 
139 protected:
141  Client* m_pClient; // client currently using the ItemFactory, we do not own this
142 
143  std::map<uint16, ItemType*> m_types;
144  std::map<uint32, InventoryItemRef> m_items;
145  std::map<uint32, InventoryItemRef> m_staticItems;
146  std::map<uint32, InventoryItemRef> m_dynamicItems;
147 
148  template<class _Ty>
149  const _Ty *_GetType(uint16 typeID);
150 
151  template<class _Ty>
153 
154 private:
155  // ID Authority:
156  // these hold the next valid ID for in-memory only objects
161 
162 };
163 
164 //Singleton
165 #define sItemFactory \
166  ( ItemFactory::get() )
167 
168 
169 #endif
170 
InventoryItemRef GetItem(uint32 itemID)
uint32 m_nextMissileID
Definition: ItemFactory.h:160
uint32 m_nextNPCID
Definition: ItemFactory.h:157
ProbeItemRef GetProbeItem(uint32 probeID)
Inventory * GetInventoryFromId(uint32 itemID, bool load=true)
const ItemType * GetType(uint16 typeID)
int Initialize()
Definition: ItemFactory.cpp:63
StationItemRef GetStationItem(uint32 stationID)
const StationType * GetStationType(uint16 stationTypeID)
uint32 m_nextDroneID
Definition: ItemFactory.h:159
AsteroidItemRef SpawnAsteroid(ItemData &idata, AsteroidData &adata)
InventoryItemRef SpawnTempItem(ItemData &data)
void RemoveItem(uint32 itemID)
SkillRef GetSkill(uint32 skillID)
const CharacterType * GetCharacterType(uint16 characterTypeID)
const CharacterType * GetCharacterTypeByBloodline(uint16 bloodlineID)
std::map< uint16, ItemType * > m_types
Definition: ItemFactory.h:143
CharacterRef GetCharacter(uint32 characterID)
SolarSystemRef GetSolarSystem(uint32 solarSystemID)
Client * GetUsingClient()
Definition: ItemFactory.h:73
CharacterRef SpawnCharacter(CharacterData &charData, CorpData &corpData)
SkillRef SpawnSkill(ItemData &data)
Client * m_pClient
Definition: ItemFactory.h:141
CelestialObjectRef GetCelestialObject(uint32 celestialID)
uint32 GetNextMissileID()
StationOfficeRef GetOffice(uint32 officeID)
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type()() itemID() copy() materialLevel()()() itemID() itemID Fits selected item to active ship() skillID(level)-gives skillID to specified level." ) COMMAND( online
InventoryItemRef SpawnItem(ItemData &data)
void SaveItems()
WreckContainerRef SpawnWreckContainer(ItemData &data)
std::map< uint32, InventoryItemRef > m_items
Definition: ItemFactory.h:144
AsteroidItemRef GetAsteroid(uint32 asteroidID)
InventoryDB * m_db
Definition: ItemFactory.h:140
const _Ty * _GetType(uint16 typeID)
const BlueprintType * GetBlueprintType(uint16 blueprintTypeID)
StationOfficeRef SpawnOffice(ItemData &idata, OfficeData &odata)
CargoContainerRef GetCargoContainer(uint32 containerID)
Definition: Client.h:66
void UnsetUsingClient()
Definition: ItemFactory.h:68
StructureItemRef GetStructure(uint32 structureID)
unsigned __int32 uint32
Definition: eve-compat.h:50
ProbeItemRef SpawnProbe(ItemData &data)
ShipItemRef GetShip(uint32 shipID)
uint32 GetNextTempID()
uint32 m_nextTempID
Definition: ItemFactory.h:158
std::map< uint32, InventoryItemRef > m_staticItems
Definition: ItemFactory.h:145
void Close()
Definition: ItemFactory.cpp:84
InventoryDB * db()
Definition: ItemFactory.h:71
ModuleItemRef GetModuleItem(uint32 moduleID)
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type()() itemID() copy() materialLevel()() itemID(attributeID)-Retrieves attribute value." ) COMMAND( setattr
ModuleItemRef SpawnModule(ItemData &data)
Template used for singleton classes.
Definition: Singleton.h:43
void AddItem(InventoryItemRef iRef)
std::map< uint32, InventoryItemRef > m_dynamicItems
Definition: ItemFactory.h:146
RefPtr< _Ty > _GetItem(uint32 itemID)
CargoContainerRef SpawnCargoContainer(ItemData &data)
Inventory * GetItemContainerInventory(uint32 itemID, bool load=true)
InventoryItemRef GetItemContainer(uint32 itemID, bool load=true)
BlueprintRef GetBlueprint(uint32 blueprintID)
InventoryItemRef GetInventoryItemFromID(uint32 itemID, bool load=true)
unsigned __int16 uint16
Definition: eve-compat.h:48
uint32 Count()
Definition: ItemFactory.h:63
uint32 GetNextDroneID()
WreckContainerRef GetWreckContainer(uint32 containerID)
uint32 GetNextNPCID()
void SetUsingClient(Client *pClient)
Definition: ItemFactory.h:67
StructureItemRef SpawnStructure(ItemData &data)
ShipItemRef SpawnShip(ItemData &data)