add RelationalClasses
add attachevent
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
class ICCME_EventBase extends Object
|
||||
class ICCME_EventBase extends RelationalClasses
|
||||
abstract;
|
||||
|
||||
// time the event was created (relative to game start)
|
||||
@@ -7,8 +7,48 @@ var float createdTime;
|
||||
// Tell the engine this event must be treated in the current Tick() context and not the next one
|
||||
var bool bUrgent;
|
||||
|
||||
var array<ICCME_EventListenerBase> _ar_AttachedEventListener;
|
||||
var bool _bBroadcast;
|
||||
|
||||
// print Event relevent informations in the main UT log file
|
||||
function doLog()
|
||||
{
|
||||
log("===== Event:"@Self.Class@"["$createdTime$"]"@"=====");
|
||||
}
|
||||
|
||||
static function attach(ICCME_EventListenerBase EventListener)
|
||||
{
|
||||
local int i;
|
||||
local bool bAlreadyRegistered;
|
||||
|
||||
if(EventListener.bMonitor) return;
|
||||
|
||||
for(i=0;i<default._ar_AttachedEventListener.Length;i++)
|
||||
{
|
||||
if(default._ar_AttachedEventListener[i] == EventListener)
|
||||
{
|
||||
bAlreadyRegistered=True;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!bAlreadyRegistered)
|
||||
{
|
||||
default._ar_AttachedEventListener.Length = default._ar_AttachedEventListener.Length + 1;
|
||||
default._ar_AttachedEventListener[default._ar_AttachedEventListener.Length-1] = EventListener;
|
||||
}
|
||||
|
||||
for(i=0;i<default.Tchilds.length;i++)
|
||||
{
|
||||
class<ICCME_EventBase>(default.Tchilds[i]).static.attach(EventListener);
|
||||
}
|
||||
}
|
||||
|
||||
function RunAttached()
|
||||
{
|
||||
local int i;
|
||||
for(i=0;i<default._ar_AttachedEventListener.Length;i++)
|
||||
{
|
||||
default._ar_AttachedEventListener[i].ProcessEvent(Self);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,36 @@
|
||||
class ICCME_EventListenerBase extends Object
|
||||
abstract;
|
||||
|
||||
/* Context variables */
|
||||
var LevelInfo Level;
|
||||
var ICCME_GameStateBase GameState;
|
||||
|
||||
// future Mutator ordering
|
||||
/* EventListener configuration */
|
||||
var bool bMonitor; // this EventListener will receive all Events [even non-attached ones]
|
||||
/* future Mutator ordering */
|
||||
var string UUID;
|
||||
var array<string> ar_UUIDBefore;
|
||||
var array<string> ar_UUIDAfter;
|
||||
|
||||
// Init function automatically called when Listener added
|
||||
function Init();
|
||||
/* User-Defined functions */
|
||||
function Init(); // Init function automatically called when Listener added
|
||||
function ProcessEvent(ICCME_EventBase Event); // Main user function, to process incomming event.
|
||||
function Tick(float DeltaTime); // Optionnal user Tick() function
|
||||
|
||||
// Main user function, to process incomming event.
|
||||
function ProcessEvent(ICCME_EventBase Event);
|
||||
|
||||
// Optionnal user Tick() function
|
||||
function Tick(float DeltaTime);
|
||||
|
||||
/* User accessible API (Callable from User-Defined functions)*/
|
||||
// Helper function to add new event in the process Queue
|
||||
// => To be called from ProcessEvent()
|
||||
function AddEvent(ICCME_Event_CustomBase Event)
|
||||
function private AddEvent(ICCME_Event_CustomBase Event)
|
||||
{
|
||||
GameState.API_AddCustomPostEvent(Event);
|
||||
}
|
||||
// Helper function to force check EndGame conditions (During OverTime)
|
||||
// => To be called from ProcessEvent()
|
||||
function CheckEndGame()
|
||||
// Helper function to tell the engine to check EndGame conditions (Designed for OverTime)
|
||||
function private CheckEndGame()
|
||||
{
|
||||
GameState.API_CheckEndGame();
|
||||
}
|
||||
// Attach this EventListener to an Event
|
||||
function private attachEvent(class<ICCME_EventBase> TEvent)
|
||||
{
|
||||
TEvent.static.attach(Self);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user