struct MyStruct
trigger trig
triggercondition c
triggeraction a
private method CleanTrigger takes nothing returns nothing
call TriggerRemoveCondition(.trig,.c)
call TriggerRemoveAction(.trig,.a)
call DestroyTrigger(.trig)
endmethod
static method Conditions takes nothing returns boolean
return true //whatever conditions
endmethod
static method Actions takes nothing returns nothing
local MyStruct data = GetTriggerStructA(GetTriggeringTrigger()) //retrieve the struct
call data.CleanTrigger() //must clear the conditions and actions before using
call DoNothing()//whatever actions
endmethod
static method create takes nothing returns MyStruct
local MyStruct data = MyStruct.allocate()
set data.trig = CreateTrigger()
call SetTriggerStuctA(data.trig, data) //I used ABC, just attach it somehow
call TriggerRegisterUnitEvent(data.trig,GetTriggerUnit(),EVENT_UNIT_DAMAGED) //whatever event you need
set data.c=TriggerAddCondition(data.trig,Condition(function MyStruct.Conditions)) //triggerconditions must be removed
set data.a=TriggerAddAction(data.trig,function MyStruct.Conditions) //so must triggeractions
return data
endmethod
endstruct
function Trig_MyStruct_Actions takes nothing returns nothing
local MyStruct data = MyStruct.create()
endfunction
//===========================================================================
function InitTrig_MyStruct takes nothing returns nothing
set gg_trg_MyStruct = CreateTrigger( )
call TriggerAddAction( gg_trg_MyStruct, function Trig_MyStruct_Actions )
endfunction