afxSpellBook.h
Engine/source/afx/afxSpellBook.h
Classes:
Detailed Description
1 2 3//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 4// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames 5// Copyright (C) 2015 Faust Logic, Inc. 6// 7// Permission is hereby granted, free of charge, to any person obtaining a copy 8// of this software and associated documentation files (the "Software"), to 9// deal in the Software without restriction, including without limitation the 10// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11// sell copies of the Software, and to permit persons to whom the Software is 12// furnished to do so, subject to the following conditions: 13// 14// The above copyright notice and this permission notice shall be included in 15// all copies or substantial portions of the Software. 16// 17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23// IN THE SOFTWARE. 24// 25//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 26 27#ifndef _AFX_SPELL_BOOK_H_ 28#define _AFX_SPELL_BOOK_H_ 29 30//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 31 32#include "T3D/gameBase/gameBase.h" 33 34class afxSpellBookDefs 35{ 36public: 37 enum { 38 MAX_SPELLS_PER_PAGE = 12, 39 MAX_PAGES_PER_BOOK = 12 40 }; 41}; 42 43class afxMagicSpellData; 44class afxRPGMagicSpellData; 45 46class afxSpellBookData : public GameBaseData, public afxSpellBookDefs 47{ 48 typedef GameBaseData Parent; 49 50 bool do_id_convert; 51 52public: 53 U8 spells_per_page; 54 U8 pages_per_book; 55 afxMagicSpellData* spells[MAX_PAGES_PER_BOOK*MAX_SPELLS_PER_PAGE]; 56 afxRPGMagicSpellData* rpg_spells[MAX_PAGES_PER_BOOK*MAX_SPELLS_PER_PAGE]; 57 58public: 59 /*C*/ afxSpellBookData(); 60 61 virtual void packData(BitStream*); 62 virtual void unpackData(BitStream*); 63 64 bool preload(bool server, String &errorStr); 65 66 bool verifyPageSlot(S32 page, S32 slot); 67 S32 getPageSlotIndex(S32 page, S32 slot); 68 69 static void initPersistFields(); 70 71 DECLARE_CONOBJECT(afxSpellBookData); 72 DECLARE_CATEGORY("AFX"); 73}; 74 75inline bool afxSpellBookData::verifyPageSlot(S32 page, S32 slot) 76{ 77 return (page >= 0 && page < pages_per_book && slot >= 0 && slot < spells_per_page); 78} 79 80inline S32 afxSpellBookData::getPageSlotIndex(S32 page, S32 slot) 81{ 82 return (verifyPageSlot(page, slot)) ? page*spells_per_page + slot : -1; 83} 84 85 86//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 87 88class afxMagicSpellData; 89class afxSpellButton; 90 91class afxSpellBook : public GameBase, public afxSpellBookDefs 92{ 93 typedef GameBase Parent; 94 95 enum MaskBits 96 { 97 AllSpellCooldownMask = Parent::NextFreeMask << 0, 98 NextFreeMask = Parent::NextFreeMask << 1 99 }; 100 101private: 102 afxSpellBookData* mDataBlock; 103 F32 all_spell_cooldown; 104 105public: 106 /*C*/ afxSpellBook(); 107 /*D*/ ~afxSpellBook(); 108 109 virtual bool onNewDataBlock(GameBaseData* dptr, bool reload); 110 virtual void processTick(const Move*); 111 virtual void advanceTime(F32 dt); 112 113 virtual bool onAdd(); 114 virtual void onRemove(); 115 116 virtual U32 packUpdate(NetConnection*, U32, BitStream*); 117 virtual void unpackUpdate(NetConnection*, BitStream*); 118 119 static void initPersistFields(); 120 121 S32 getPageSlotIndex(S32 page, S32 slot); 122 char* formatDesc(char* buffer, int len, S32 page, S32 slot) const; 123 const char* getSpellIcon(S32 page, S32 slot) const; 124 bool isPlaceholder(S32 page, S32 slot) const; 125 afxMagicSpellData* getSpellData(S32 page, S32 slot); 126 afxRPGMagicSpellData* getSpellRPGData(S32 page, S32 slot); 127 128 void startAllSpellCooldown(); 129 F32 getCooldownFactor(S32 page, S32 slot); 130 131 DECLARE_CONOBJECT(afxSpellBook); 132 DECLARE_CATEGORY("AFX"); 133}; 134 135inline S32 afxSpellBook::getPageSlotIndex(S32 page, S32 slot) 136{ 137 return (mDataBlock) ? mDataBlock->getPageSlotIndex(page, slot) : -1; 138} 139 140 141//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 142 143#endif // _AFX_SPELL_BOOK_H_ 144