2018-02-23 03:43:18 +08:00
using System.Collections.Generic ;
2018-02-24 05:55:51 +08:00
using static EventSystem . Framework . Delegates ;
2018-02-23 03:43:18 +08:00
2018-02-24 05:55:51 +08:00
namespace EventSystem.Framework
2018-02-23 03:43:18 +08:00
{
2018-12-30 18:00:05 +08:00
/// <summary>Used to pair a function and a parameter list using the super object class to run virtually any function for map events.</summary>
2018-02-24 05:55:51 +08:00
public class functionEvent
2018-02-23 03:43:18 +08:00
{
public paramFunction function ;
public List < object > parameters ;
2018-12-30 18:00:05 +08:00
/// <summary>Construct an instance.</summary>
2018-02-23 03:43:18 +08:00
/// <param name="Function">The function to be called when running an event.</param>
/// <param name="Parameters">The list of system.objects to be used in the function. Can include objects,strings, ints, etc. Anything can be passed in as a parameter or can be passed in as empty. Passing in null will just create an empty list.</param>
public functionEvent ( paramFunction Function , List < object > Parameters )
{
if ( this . parameters = = null ) this . parameters = new List < object > ( ) ;
this . function = Function ;
this . parameters = Parameters ;
}
2018-12-30 18:00:05 +08:00
/// <summary>Runs the function with the passed in parameters.</summary>
2018-02-23 03:43:18 +08:00
public void run ( )
{
this . function . Invoke ( this . parameters ) ;
}
2018-12-30 18:00:05 +08:00
/// <summary>Simply swaps out the old parameters list for a new one.</summary>
2018-02-23 03:43:18 +08:00
/// <param name="newParameters"></param>
public void updateParameters ( List < object > newParameters )
{
this . parameters = newParameters ;
}
}
}