2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-09-23 18:09:57 -04:00
|
|
|
#include "Item.h"
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
class cClientHandle;
|
|
|
|
class cPlayer;
|
|
|
|
class cPickup;
|
|
|
|
class cItem;
|
|
|
|
class cEntity;
|
|
|
|
class cPawn;
|
|
|
|
class cWorld;
|
|
|
|
class cLuaChunk;
|
|
|
|
struct TakeDamageInfo;
|
|
|
|
|
|
|
|
// fwd: cPlayer.h
|
|
|
|
class cPlayer;
|
|
|
|
|
|
|
|
// fwd: CraftingRecipes.h
|
|
|
|
class cCraftingGrid;
|
|
|
|
class cCraftingRecipe;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
class cPlugin
|
|
|
|
{
|
|
|
|
public:
|
2012-10-13 19:34:47 -04:00
|
|
|
cPlugin( const AString & a_PluginDirectory );
|
2012-06-14 09:06:06 -04:00
|
|
|
virtual ~cPlugin();
|
|
|
|
|
|
|
|
virtual void OnDisable() {}
|
|
|
|
virtual bool Initialize() = 0;
|
|
|
|
|
|
|
|
// Called each tick
|
|
|
|
virtual void Tick(float a_Dt);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* On all these functions, return true if you want to override default behavior
|
2012-08-18 05:56:28 -04:00
|
|
|
* You can also return false, so default behavior is used.
|
2012-06-14 09:06:06 -04:00
|
|
|
**/
|
2012-08-18 05:56:28 -04:00
|
|
|
virtual bool OnBlockDig (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta);
|
|
|
|
virtual bool OnBlockPlace (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem);
|
|
|
|
virtual bool OnBlockToPickup (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups);
|
2012-08-18 06:38:15 -04:00
|
|
|
virtual bool OnChat (cPlayer * a_Player, const AString & a_Message);
|
2012-08-18 05:56:28 -04:00
|
|
|
virtual void OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ);
|
|
|
|
virtual bool OnChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk);
|
2012-08-24 05:49:00 -04:00
|
|
|
virtual bool OnCollectPickup (cPlayer * a_Player, cPickup * a_Pickup);
|
2012-08-18 05:56:28 -04:00
|
|
|
virtual bool OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
2012-08-19 15:42:32 -04:00
|
|
|
virtual bool OnDisconnect (cPlayer * a_Player, const AString & a_Reason);
|
|
|
|
virtual bool OnKilled (cPawn * a_Killed, cEntity* a_Killer );
|
2012-08-18 05:56:28 -04:00
|
|
|
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username);
|
2012-06-14 09:06:06 -04:00
|
|
|
virtual bool OnPlayerJoin (cPlayer* a_Player );
|
2012-08-03 07:53:11 -04:00
|
|
|
virtual void OnPlayerMove (cPlayer* a_Player );
|
2012-08-18 05:56:28 -04:00
|
|
|
virtual void OnPlayerSpawn (cPlayer* a_Player );
|
2012-08-03 07:53:11 -04:00
|
|
|
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
2012-08-18 05:56:28 -04:00
|
|
|
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
|
|
|
virtual void OnTakeDamage (cPawn * a_Pawn, TakeDamageInfo * a_TakeDamageInfo );
|
2012-09-01 17:31:20 -04:00
|
|
|
virtual bool OnUpdatedSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player);
|
|
|
|
virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player);
|
2012-08-18 05:56:28 -04:00
|
|
|
virtual bool OnWeatherChanged (cWorld * a_World);
|
2012-09-05 16:30:27 -04:00
|
|
|
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username);
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
// Accessors
|
2012-08-22 10:22:21 -04:00
|
|
|
const AString & GetName() const { return m_Name; }
|
|
|
|
virtual void SetName( const AString & a_Name ) { m_Name = a_Name; }
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
int GetVersion() const { return m_Version; }
|
|
|
|
void SetVersion( int a_Version ) { m_Version = a_Version; }
|
|
|
|
|
2012-10-13 19:34:47 -04:00
|
|
|
const AString & GetDirectory(void) const {return m_Directory; }
|
|
|
|
AString GetLocalDirectory(void) const; //tolua_export
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
struct CommandStruct
|
|
|
|
{
|
2012-10-13 19:34:47 -04:00
|
|
|
AString Command;
|
|
|
|
AString Description;
|
|
|
|
AString Permission;
|
2012-06-14 09:06:06 -04:00
|
|
|
};
|
|
|
|
|
2012-08-03 07:53:11 -04:00
|
|
|
void AddCommand(const AString & a_Command, const AString & a_Description, const AString & a_Permission);
|
2012-06-14 09:06:06 -04:00
|
|
|
// tolua_end
|
2012-08-03 07:53:11 -04:00
|
|
|
|
2012-10-13 19:34:47 -04:00
|
|
|
typedef bool (FuncCommandHandler)( AString & a_Command, std::vector< std::string > & a_Split );
|
|
|
|
void BindCommand( FuncCommandHandler* a_Function, AString & a_Command ); // >> EXPORTED IN MANUALBINDINGS <<
|
2012-06-14 09:06:06 -04:00
|
|
|
const std::vector< CommandStruct > & GetCommands() const { return m_Commands; } // >> EXPORTED IN MANUALBINDINGS <<
|
|
|
|
|
|
|
|
|
|
|
|
/* This should not be exposed to scripting languages */
|
|
|
|
enum PluginLanguage
|
|
|
|
{
|
|
|
|
E_CPP,
|
|
|
|
E_LUA,
|
|
|
|
E_SQUIRREL,
|
|
|
|
};
|
|
|
|
PluginLanguage GetLanguage() { return m_Language; }
|
|
|
|
void SetLanguage( PluginLanguage a_Language ) { m_Language = a_Language; }
|
|
|
|
|
|
|
|
bool CanBindCommands() { return m_bCanBindCommands; }
|
|
|
|
private:
|
|
|
|
friend class cPluginManager;
|
|
|
|
bool m_bCanBindCommands; // Only changed by cPluginManager
|
|
|
|
|
|
|
|
PluginLanguage m_Language;
|
|
|
|
std::vector< CommandStruct > m_Commands;
|
2012-10-13 19:34:47 -04:00
|
|
|
AString m_Name;
|
2012-06-14 09:06:06 -04:00
|
|
|
int m_Version;
|
2012-10-13 19:34:47 -04:00
|
|
|
|
|
|
|
AString m_Directory;
|
2012-06-14 09:06:06 -04:00
|
|
|
}; //tolua_export
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|