2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-09-23 18:09:57 -04:00
|
|
|
#include "Item.h"
|
2013-01-11 23:46:01 -05:00
|
|
|
#include "PluginManager.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
class cClientHandle;
|
|
|
|
class cPlayer;
|
|
|
|
class cPickup;
|
|
|
|
class cItem;
|
|
|
|
class cEntity;
|
|
|
|
class cWorld;
|
2013-01-25 05:12:29 -05:00
|
|
|
class cChunkDesc;
|
2012-06-14 09:06:06 -04:00
|
|
|
struct TakeDamageInfo;
|
|
|
|
|
|
|
|
// fwd: cPlayer.h
|
|
|
|
class cPlayer;
|
|
|
|
|
|
|
|
// fwd: CraftingRecipes.h
|
|
|
|
class cCraftingGrid;
|
|
|
|
class cCraftingRecipe;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
class cPlugin
|
|
|
|
{
|
|
|
|
public:
|
2013-01-11 23:46:01 -05:00
|
|
|
// tolua_end
|
|
|
|
|
2012-10-13 19:34:47 -04:00
|
|
|
cPlugin( const AString & a_PluginDirectory );
|
2012-06-14 09:06:06 -04:00
|
|
|
virtual ~cPlugin();
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
virtual void OnDisable(void) {}
|
|
|
|
virtual bool Initialize(void) = 0;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
// Called each tick
|
2013-08-08 03:53:26 -04:00
|
|
|
virtual void Tick(float a_Dt) = 0;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
/**
|
2013-01-11 23:46:01 -05:00
|
|
|
* On all these functions, return true if you want to override default behavior and not call other plugins on that callback.
|
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
|
|
|
**/
|
2013-08-08 03:53:26 -04:00
|
|
|
virtual bool OnBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) = 0;
|
|
|
|
virtual bool OnChat (cPlayer * a_Player, AString & a_Message) = 0;
|
|
|
|
virtual bool OnChunkAvailable (cWorld * a_World, int a_ChunkX, int a_ChunkZ) = 0;
|
|
|
|
virtual bool OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) = 0;
|
|
|
|
virtual bool OnChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) = 0;
|
|
|
|
virtual bool OnChunkUnloaded (cWorld * a_World, int a_ChunkX, int a_ChunkZ) = 0;
|
|
|
|
virtual bool OnChunkUnloading (cWorld * a_World, int a_ChunkX, int a_ChunkZ) = 0;
|
|
|
|
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) = 0;
|
|
|
|
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
|
|
|
virtual bool OnDisconnect (cPlayer * a_Player, const AString & a_Reason) = 0;
|
|
|
|
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) = 0;
|
Added OnExploding() and OnExploded() hooks.
As requested in FS 413, with extra parameters:
World, BlockX, BlockY, BlockZ, Size, CanCauseFire, Source, SourceData
OnExploding() can return 3 values:
StopHook, CanCauseFire, ExplosionSize
2013-08-09 08:58:43 -04:00
|
|
|
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
|
|
|
|
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
|
2013-08-08 03:53:26 -04:00
|
|
|
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) = 0;
|
2013-08-11 08:57:07 -04:00
|
|
|
virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) = 0;
|
|
|
|
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) = 0;
|
2013-08-08 03:53:26 -04:00
|
|
|
virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer) = 0;
|
|
|
|
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) = 0;
|
2013-08-11 06:12:20 -04:00
|
|
|
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) = 0;
|
2013-08-08 03:53:26 -04:00
|
|
|
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
|
|
|
|
virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
|
|
|
|
virtual bool OnPlayerEating (cPlayer & a_Player) = 0;
|
|
|
|
virtual bool OnPlayerJoined (cPlayer & a_Player) = 0;
|
|
|
|
virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) = 0;
|
|
|
|
virtual bool OnPlayerMoved (cPlayer & a_Player) = 0;
|
|
|
|
virtual bool OnPlayerPlacedBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
|
|
|
|
virtual bool OnPlayerPlacingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
|
|
|
|
virtual bool OnPlayerRightClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) = 0;
|
|
|
|
virtual bool OnPlayerRightClickingEntity(cPlayer & a_Player, cEntity & a_Entity) = 0;
|
|
|
|
virtual bool OnPlayerShooting (cPlayer & a_Player) = 0;
|
|
|
|
virtual bool OnPlayerSpawned (cPlayer & a_Player) = 0;
|
|
|
|
virtual bool OnPlayerTossingItem (cPlayer & a_Player) = 0;
|
|
|
|
virtual bool OnPlayerUsedBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
|
|
|
|
virtual bool OnPlayerUsedItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) = 0;
|
|
|
|
virtual bool OnPlayerUsingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
|
|
|
|
virtual bool OnPlayerUsingItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) = 0;
|
|
|
|
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
|
|
|
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
|
|
|
virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) = 0;
|
|
|
|
virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) = 0;
|
|
|
|
virtual bool OnSpawningEntity (cWorld & a_World, cEntity & a_Entity) = 0;
|
|
|
|
virtual bool OnSpawningMonster (cWorld & a_World, cMonster & a_Monster) = 0;
|
|
|
|
virtual bool OnTakeDamage (cEntity & a_Receiver, TakeDamageInfo & a_TakeDamageInfo) = 0;
|
|
|
|
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) = 0;
|
|
|
|
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) = 0;
|
|
|
|
virtual bool OnWeatherChanged (cWorld & a_World) = 0;
|
|
|
|
virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) = 0;
|
2013-08-19 03:28:22 -04:00
|
|
|
virtual bool OnWorldTick (cWorld & a_World, float a_Dt) = 0;
|
2013-01-11 23:46:01 -05:00
|
|
|
|
2013-02-15 08:00:59 -05:00
|
|
|
/** Handles the command split into a_Split, issued by player a_Player.
|
|
|
|
Command permissions have already been checked.
|
|
|
|
Returns true if command handled successfully
|
|
|
|
*/
|
2013-08-08 03:53:26 -04:00
|
|
|
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer * a_Player) = 0;
|
2013-02-01 14:55:42 -05:00
|
|
|
|
2013-06-29 11:30:05 -04:00
|
|
|
/** Handles the console command split into a_Split.
|
|
|
|
Returns true if command handled successfully. Output is to be sent to the a_Output callback.
|
|
|
|
*/
|
2013-08-08 03:53:26 -04:00
|
|
|
virtual bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output) = 0;
|
2013-02-15 08:00:59 -05:00
|
|
|
|
2013-02-01 14:55:42 -05:00
|
|
|
/// All bound commands are to be removed, do any language-dependent cleanup here
|
|
|
|
virtual void ClearCommands(void) {} ;
|
|
|
|
|
2013-02-15 08:00:59 -05:00
|
|
|
/// All bound console commands are to be removed, do any language-dependent cleanup here
|
|
|
|
virtual void ClearConsoleCommands(void) {} ;
|
|
|
|
|
2013-01-14 03:21:13 -05:00
|
|
|
// tolua_begin
|
2013-01-11 23:46:01 -05:00
|
|
|
const AString & GetName(void) const { return m_Name; }
|
|
|
|
void SetName(const AString & a_Name) { m_Name = a_Name; }
|
|
|
|
|
|
|
|
int GetVersion(void) const { return m_Version; }
|
|
|
|
void SetVersion(int a_Version) { m_Version = a_Version; }
|
|
|
|
|
|
|
|
const AString & GetDirectory(void) const {return m_Directory; }
|
2013-09-18 16:15:12 -04:00
|
|
|
AString GetLocalDirectory(void) const {return GetLocalFolder(); } // OBSOLETE, use GetLocalFolder() instead
|
|
|
|
AString GetLocalFolder(void) const;
|
2012-06-14 09:06:06 -04:00
|
|
|
// tolua_end
|
2012-08-03 07:53:11 -04:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
/* This should not be exposed to scripting languages */
|
|
|
|
enum PluginLanguage
|
|
|
|
{
|
|
|
|
E_CPP,
|
|
|
|
E_LUA,
|
2013-08-07 16:39:40 -04:00
|
|
|
E_SQUIRREL, // OBSOLETE, but kept in place to remind us of the horrors lurking in the history
|
2012-06-14 09:06:06 -04:00
|
|
|
};
|
|
|
|
PluginLanguage GetLanguage() { return m_Language; }
|
|
|
|
void SetLanguage( PluginLanguage a_Language ) { m_Language = a_Language; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
PluginLanguage m_Language;
|
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;
|
2013-01-11 23:46:01 -05:00
|
|
|
}; // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|