EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Asteroid.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 
27 #ifndef __ASTEROID_H_INCL__
28 #define __ASTEROID_H_INCL__
29 
30 #include "EVEServerConfig.h"
31 #include "StaticDataMgr.h"
32 #include "system/SystemEntity.h"
34 
35 
37 : public InventoryItem
38 {
39  friend class InventoryItem; // to let it construct us
40 public:
41  AsteroidItem(const ItemType& type, const ItemData& idata, const AsteroidData& adata);
42  virtual ~AsteroidItem() { /* Do nothing here */ }
43 
44  static AsteroidItemRef Load(uint32 asteroidID);
45  static AsteroidItemRef Spawn(ItemData &idata, AsteroidData& adata);
46  static AsteroidItemRef SpawnTemp(ItemData &idata, AsteroidData& adata);
47 
48 
49  double radius() const { return m_data.radius; }
50 
51 protected:
53  //virtual bool _Load();
54 
55  // Template loader:
56  template<class _Ty>
57  static RefPtr<_Ty> _LoadItem( uint32 asteroidID, const ItemType &type, const ItemData &data) {
59  _log(ITEM__ERROR, "Trying to load %s as Asteroid.", sDataMgr.GetCategoryName(type.categoryID()));
60  if (sConfig.debug.StackTrace)
62  return RefPtr<_Ty>();
63  }
64 
65  AsteroidData adata = AsteroidData();
66  if ( !ManagerDB::GetAsteroidData( asteroidID, adata ) )
67  return RefPtr<_Ty>();
68 
69  return AsteroidItemRef( new AsteroidItem(type, data, adata ) );
70  }
71 
72 private:
74 
75 };
76 
77 
83 : public ObjectSystemEntity
84 {
85 public:
87  virtual ~AsteroidSE() { /* Do nothing here */ }
88 
89  /* class type pointer querys. */
90  virtual AsteroidSE* GetAsteroidSE() { return this; }
91  /* class type tests. */
92  virtual bool IsAsteroidSE() { return true; }
93 
94  /* SystemEntity interface */
95  virtual void Delete();
96  virtual void Process();
97  virtual void EncodeDestiny( Buffer& into );
98  virtual void MakeDamageState(DoDestinyDamageState &into);
99 
100  /* specific functions handled in this class. */
101  void Grow();
102  void SetMgr(BeltMgr* beltMgr, uint32 beltID) { m_beltMgr = beltMgr; m_beltID = beltID; }
103 
104 protected:
105 
106 private:
110 };
111 
112 #endif /* !__ASTEROID__H__INCL__ */
#define sConfig
A macro for easier access to the singleton.
#define _log(type, fmt,...)
Definition: logsys.h:124
static AsteroidItemRef Spawn(ItemData &idata, AsteroidData &adata)
Definition: Asteroid.cpp:33
RefPtr< AsteroidItem > AsteroidItemRef
Definition: ItemRef.h:46
Timer m_growTimer
Definition: Asteroid.h:108
void SetMgr(BeltMgr *beltMgr, uint32 beltID)
Definition: Asteroid.h:102
static RefPtr< _Ty > _LoadItem(uint32 asteroidID, const ItemType &type, const ItemData &data)
Definition: Asteroid.h:57
double radius() const
Definition: Asteroid.h:49
BeltMgr * m_beltMgr
Definition: Asteroid.h:107
virtual bool _Load()
virtual bool IsAsteroidSE()
Definition: Asteroid.h:92
virtual void EncodeDestiny(Buffer &into)
Definition: Asteroid.cpp:91
uint8 categoryID() const
Definition: ItemType.h:66
AsteroidItem(const ItemType &type, const ItemData &idata, const AsteroidData &adata)
Definition: Asteroid.cpp:21
AsteroidData m_data
Definition: Asteroid.h:73
AsteroidSE(InventoryItemRef self, PyServiceMgr &services, SystemManager *system)
Definition: Asteroid.cpp:74
const ItemType & type() const
Generic class for buffers.
Definition: Buffer.h:40
PyTuple * MakeDamageState()
virtual void Process()
Definition: Asteroid.cpp:81
virtual void Delete()
Definition: Asteroid.cpp:134
virtual AsteroidSE * GetAsteroidSE()
Definition: Asteroid.h:90
unsigned __int32 uint32
Definition: eve-compat.h:50
static AsteroidItemRef SpawnTemp(ItemData &idata, AsteroidData &adata)
Definition: Asteroid.cpp:54
static AsteroidItemRef Load(uint32 asteroidID)
Definition: Asteroid.cpp:28
static bool GetAsteroidData(uint32 asteroidID, AsteroidData &dbData)
Definition: ManagerDB.cpp:478
void Grow()
Definition: Asteroid.cpp:119
uint32 m_beltID
Definition: Asteroid.h:109
virtual ~AsteroidSE()
Definition: Asteroid.h:87
void traceStack(void)
Definition: misc.cpp:169
Definition: timer.h:30
virtual ~AsteroidItem()
Definition: Asteroid.h:42
Reference-counting-based smart pointer.
Definition: RefPtr.h:133
#define sDataMgr