My Project
ParaScriptingWorld.h
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2004 - 2006 ParaEngine Dev Studio, All Rights Reserved.
3 // Date: 2006.1
4 // Description: API for world
5 //-----------------------------------------------------------------------------
6 #pragma once
7 #include "ParaScriptingScene.h"
8 
9 namespace ParaEngine
10 {
11  class CNpcDatabase;
12  class CCharacterDB;
13  class CKidsDBProvider;
14  class AttributeProvider;
15 }
16 namespace luabind
17 {
18  namespace adl{
19  class object;
20  }
21  using adl::object;
22 }
23 
24 namespace ParaScripting
25 {
26  using namespace std;
27  using namespace luabind;
28  using namespace ParaEngine;
29 #ifdef USE_DIRECTX_RENDERER
30 
35  class PE_CORE_DECL ParaKidsDataProvider
36  {
37  public:
38  CKidsDBProvider* m_pObj; // a pointer to the object
39 
40  ParaKidsDataProvider();
41  ParaKidsDataProvider(CKidsDBProvider* pObj) { m_pObj = pObj; };
42  ~ParaKidsDataProvider();
43 
44  // -------------------------------
45  // Puzzle database functions
46  // -------------------------------
51  bool InsertPuzzleRecordFromString(const char* strRecord);
52 
57  bool DeletePuzzleRecordByID(int ID);
58 
59  // -------------------------------
60  // Item database functions
61  // -------------------------------
66  bool InsertItemRecordFromString(const char* strRecord);
67 
72  bool DeleteItemRecordByID(int ID);
73 
78  bool UpdateItemRecordFromString(const char* strRecord);
79 
84  const char * SelectItemRecordToString(__int64 ID) const;
85 
86  // -------------------------------
87  // Character database functions
88  // -------------------------------
93  bool InsertCharacterRecordFromString(const char* strRecord);
94 
99  bool DeleteCharacterRecordByID(int ID);
100 
101  // -------------------------------
102  // Chest database functions
103  // -------------------------------
108  bool InsertChestRecordFromString(const char* strRecord);
109 
114  bool DeleteChestRecordByID(int ID);
115 
116  // -------------------------------
117  // Fruit database functions
118  // -------------------------------
123  bool InsertFruitRecordFromString(const char* strRecord);
124 
129  bool DeleteFruitRecordByID(int ID);
130 
131  // -------------------------------
132  // PetAI database functions
133  // -------------------------------
138  bool InsertPetAIRecordFromString(const char* strRecord);
139 
144  bool DeletePetAIRecordByID(int ID);
145 
146  // -------------------------------
147  // Pet database functions
148  // -------------------------------
153  bool InsertPetRecordFromString(const char* strRecord);
154 
159  bool DeletePetRecordByID(int ID);
160 
161  // -------------------------------
162  // Quest database functions
163  // -------------------------------
168  bool InsertQuestRecordFromString(const char* strRecord);
169 
174  bool DeleteQuestRecordByID(int ID);
175 
176  // -------------------------------
177  // Title database functions
178  // -------------------------------
183  bool InsertTitleRecordFromString(const char* strRecord);
184 
189  bool DeleteTitleRecordByID(int ID);
190  };
191 #endif
192 
198  class PE_CORE_DECL ParaDataProvider
199  {
200  public:
201  // a pointer to the db provider
202  union{
203  void* m_pDataProvider;
204  AttributeProvider* m_pAttributeProvider;
205 #ifdef USE_DIRECTX_RENDERER
206  CCharacterDB* m_pDbCharacter;
207  CKidsDBProvider* m_pDbKidsProvider;
208  CNpcDatabase* m_pDbNPC;
209 #endif
210  };
211 
215  bool IsValid(){return m_pDataProvider!=NULL;}
216  public:
217  ParaDataProvider():m_pDataProvider(NULL){};
218  ParaDataProvider(void* pObj):m_pDataProvider(pObj){};
219  ~ParaDataProvider(){};
220  public:
221 
222 #ifdef USE_DIRECTX_RENDERER
223  static void GetKidsDBProvider(ParaKidsDataProvider* pOut);
224 #endif
225  //
227  // Kids game database
228  //
230 
235  bool InsertPuzzleRecordFromString(const char* strRecord);
236 
241  bool DeletePuzzleRecordByID(int ID);
242 
244  //
245  // NPC database
246  //
248 
254  int GetNPCIDByName(const char* name);
255 
260  int GetNPCCount();
261 
262 
264  //
265  // attribute provider
266  //
268 
274  bool DoesAttributeExists(const char* sName);
275 
285  object GetAttribute(const char* sName, const object& sOut);
286 
294  bool UpdateAttribute(const char* sName, const object& sIn);
295 
302  bool InsertAttribute(const char* sName, const object& sIn);
303 
309  bool DeleteAttribute(const char* sName);
310 
312  bool ExecSQL(const char* sCmd);
313 
318  void SetTableName(const char* sName);
323  const char* GetTableName();
324  };
325 
333  class PE_CORE_DECL ParaSelection
334  {
335  public:
340  static void RemoveObject(const ParaObject& obj);
346  static bool RemoveUIObject(const char* sName);
347 
354  static void AddObject(const ParaObject& obj, int nGroupID);
361  static bool AddUIObject(const char* sName, int nGroupID);
362 
369  static ParaObject GetObject(int nGroupID, int nItemIndex);
371  static void GetObject_(ParaObject* pOut, int nGroupID, int nItemIndex);
372 
379  static int GetItemNumInGroup(int nGroupID);
380 
386  static void SelectGroup(int nGroupID, bool bSelect);
391  static void ClearGroup(int nGroupID);
392 
399  static void SetMaxItemNumberInGroup(int nGroupID, int nMaxItemsNumber);
400 
406  static int GetMaxItemNumberInGroup(int nGroupID);
407  };
408 
412  class PE_CORE_DECL ParaWorld
413  {
414  public:
415  ParaWorld(void);
416  ~ParaWorld(void);
417  public:
433  static string NewWorld(const char* sWorldName, const char* sBaseWorldName);
435  static const char* NewWorld_(const char* sWorldName, const char* sBaseWorldName);
436 
438  static void DeleteWorld(const char* sWorldName);
439 
445  static string NewEmptyWorld(const char* sWorldName=NULL, float fTileSize=533.3333f, int nTileDimension=64 );
446 
450  static bool CreateRawTerrainFile(const char* sFilename, float fHeight = 0.f, int nDimension = 129);
451 
453  static const char* NewEmptyWorld_(const char* sWorldName=NULL, float fTileSize=533.3333f, int nTileDimension=64 );
454 
459  static void SetEnablePathEncoding(bool bEnable);
460 
465  static bool GetEnablePathEncoding();
466 
468  //
469  // data provider functions
470  //
472 
474  static ParaDataProvider GetNpcDB();
476  static void GetNpcDB_(ParaDataProvider* out);
477 
482  static void SetNpcDB(const char* sConnectionstring);
483 
484 
486  static ParaDataProvider GetAttributeProvider();
488  static void GetAttributeProvider_(ParaDataProvider * out);
489 
494  static void SetAttributeProvider(const char* sConnectionstring);
495 
501  static void SetWorldDB(const char* sConnectionstring);
502 
506  static string GetStringbyID(int ID);
507 
512  static int InsertString(const char* strEN, const char * strCN);
513 
514 
523  static void SetServerState(int nState);
524  static int GetServerState();
525 
536  static bool SendTerrainUpdate(const char* sDestination, float center_x,float center_y,float center_z, float fRadius, float fResolution);
537 
538 
540  static string GetWorldName();
541 
543  static string GetWorldDirectory();
544 
567  static void SetScriptSandBox(const object& SandboxNeuronFile);
568 
572  static const char* GetScriptSandBox();
573  };
574 }
different physics engine has different winding order.
Definition: EventBinding.h:32
ParaObject class: it is used to control game scene objects from scripts.
Definition: ParaScriptingScene.h:56
NPC data provider.
Definition: NpcDatabase.h:93
Definition: PEtypes.h:507
Attribute fields data provider: it is a group of attribute stored in {name, value} value pair fasion ...
Definition: AttributeProvider.h:32
it contains all functions to access the character database.
Definition: CharacterDB.h:8
for luabind, The main drawback of this approach is that the compilation time will increase for the fi...
Definition: luaSQLite.cpp:1971
world creation functions.
Definition: ParaScriptingWorld.h:412
A pool of currently selected objects.
Definition: ParaScriptingWorld.h:333
bool IsValid()
check if the object is valid
Definition: ParaScriptingWorld.h:215
Definition: KidsDBProvider.h:30
Wrapper of internal ParaWorld data provider.
Definition: ParaScriptingWorld.h:198