public/extensions/ISDKHooks.h
author GoD-Tony <aangione@gmail.com>
Sun Aug 04 10:03:40 2013 -0400 (2013-08-04)
changeset 3971 d2e8100b2814
permissions -rw-r--r--
Added ISDKHooks interface with entity listeners (bug 5602, r=psychonic).
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * Source SDK Hooks Extension
     5  * Copyright (C) 2010-2012 Nicholas Hastings
     6  * Copyright (C) 2009-2010 Erik Minekus
     7  * =============================================================================
     8  *
     9  * This program is free software; you can redistribute it and/or modify it under
    10  * the terms of the GNU General Public License, version 3.0, as published by the
    11  * Free Software Foundation.
    12  * 
    13  * This program is distributed in the hope that it will be useful, but WITHOUT
    14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    16  * details.
    17  *
    18  * You should have received a copy of the GNU General Public License along with
    19  * this program.  If not, see <http://www.gnu.org/licenses/>.
    20  *
    21  * As a special exception, AlliedModders LLC gives you permission to link the
    22  * code of this program (as well as its derivative works) to "Half-Life 2," the
    23  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    24  * by the Valve Corporation.  You must obey the GNU General Public License in
    25  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    26  * this exception to all derivative works.  AlliedModders LLC defines further
    27  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    28  * or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32 
    33 #ifndef _INCLUDE_SMEXT_I_SDKHOOKS_H_
    34 #define _INCLUDE_SMEXT_I_SDKHOOKS_H_
    35 
    36 #include <IShareSys.h>
    37 
    38 #define SMINTERFACE_SDKHOOKS_NAME		"ISDKHooks"
    39 #define SMINTERFACE_SDKHOOKS_VERSION	1
    40 
    41 class CBaseEntity;
    42 
    43 /**
    44  * @brief SDKHooks shared API
    45  * @file ISDKHooks.h
    46  */
    47 
    48 namespace SourceMod
    49 {
    50 	/**
    51 	 * @brief Provides callbacks for entity events.
    52 	 */
    53 	class ISMEntityListener
    54 	{
    55 	public:
    56 		/**
    57 		 * @brief	When an entity is created
    58 		 *
    59 		 * @param	pEntity		CBaseEntity entity.
    60 		 * @param	classname	Entity classname.
    61 		 */
    62 		virtual void OnEntityCreated(CBaseEntity *pEntity, const char *classname)
    63 		{
    64 		}
    65 		
    66 		/**
    67 		 * @brief	When an entity is destroyed
    68 		 *
    69 		 * @param	pEntity		CBaseEntity entity.
    70 		 */
    71 		virtual void OnEntityDestroyed(CBaseEntity *pEntity)
    72 		{
    73 		}
    74 	};
    75 
    76 	/**
    77 	 * @brief SDKHooks API.
    78 	 */
    79 	class ISDKHooks : public SMInterface
    80 	{
    81 	public:
    82 		virtual const char *GetInterfaceName()
    83 		{
    84 			return SMINTERFACE_SDKHOOKS_NAME;
    85 		}
    86 		virtual unsigned int GetInterfaceVersion()
    87 		{
    88 			return SMINTERFACE_SDKHOOKS_VERSION;
    89 		}
    90 	public:
    91 		/**
    92 		 * @brief	Adds an entity listener.
    93 		 *
    94 		 * @param	listener		Pointer to an ISMEntityListener.
    95 		 */
    96 		virtual void AddEntityListener(ISMEntityListener *listener) =0;
    97 
    98 		/**
    99 		 * @brief	Removes an entity listener.
   100 		 *
   101 		 * @param	listener		Pointer to an ISMEntityListener.
   102 		 */
   103 		virtual void RemoveEntityListener(ISMEntityListener *listener) =0;
   104 	};
   105 }
   106 
   107 #endif /* _INCLUDE_SMEXT_I_SDKHOOKS_H_ */