1
0
forked from 0ad/0ad

This was SVN commit r2159.

This commit is contained in:
MarkT 2005-04-22 19:14:50 +00:00
parent eb6f978ba1
commit 899cf87b41
3 changed files with 1106 additions and 0 deletions

View File

@ -0,0 +1,33 @@
// EventTypes.h
// Script event declarations
enum EEventType
{
// Entity events
EVENT_INITIALIZE = 0,
EVENT_TICK,
EVENT_ATTACK,
EVENT_GATHER,
EVENT_DAMAGE,
EVENT_TARGET_CHANGED,
EVENT_PREPARE_ORDER,
EVENT_ORDER_TRANSITION,
EVENT_LAST,
// General events
EVENT_GAME_START = 0,
EVENT_GAME_TICK,
EVENT_SELECTION_CHANGED,
};
// Only used for entity events...
static const wchar_t* EventNames[] =
{
/* EVENT_INITIALIZE */ L"onInitialize",
/* EVENT_TICK */ L"onTick",
/* EVENT_ATTACK */ L"onAttack", /* This unit is the one doing the attacking... */
/* EVENT_GATHER */ L"onGather", /* This unit is the one doing the gathering... */
/* EVENT_DAMAGE */ L"onTakesDamage",
/* EVENT_TARGET_CHANGED */ L"onTargetChanged", /* If this unit is selected and the mouseover object changes */
/* EVENT_PREPARE_ORDER */ L"onPrepareOrder", /* To check if a unit can execute a given order */
/* EVENT_ORDER_TRANSITION */ L"onOrderTransition" /* When we change orders (sometimes...) */
};

View File

@ -0,0 +1,37 @@
// GameEvents.h
// A class that exists to let scripts know when important things happen
// in the game.
#ifndef GAME_EVENTS_INCLUDED
#define GAME_EVENTS_INCLUDED
#include "DOMEvent.h"
class CGameEvents : public IEventTarget, public Singleton<CGameEvents>
{
// Game events don't really run on an object
JSObject* GetScriptExecContext( IEventTarget* target ) { return( g_ScriptingHost.GetGlobalObject() ); }
// Some events
class CEventSelectionChanged : public CScriptEvent
{
bool m_CausedByPlayer;
public:
CEventSelectionChanged( bool CausedByPlayer ) : CScriptEvent( L"selectionChanged", EVENT_SELECTION_CHANGED, false )
{
AddLocalProperty( L"byPlayer", &m_CausedByPlayer, true );
}
};
public:
void FireSelectionChanged( bool CausedByPlayer )
{
CEventSelectionChanged evt( CausedByPlayer );
DispatchEvent( &evt );
}
};
#define g_JSGameEvents CGameEvents::GetSingleton()
#endif

File diff suppressed because it is too large Load Diff