public void Invoke() { var gameObject = entity ? entity : this.gameObject; var type = componentEvent.GetType(); var newEventInstance = (MonoBehaviourComponentData)gameObject.AddComponent(type); foreach (var field in type.GetFields()) { field.SetValue(newEventInstance, field.GetValue(componentEvent)); } EventSystem.Add(() => { newEventInstance.enabled = true; return(newEventInstance); }); }
static void Main(string[] args) { /* Console.WriteLine("调用Operations类内各函数:"); * UseOperation2(Operations.Add, 3, 5); * UseOperation2(Operations.Minus, 9, 4); * UseOperation2(Operations.Multiply, 3, 7); * UseOperation2(Operations.Divide, 8, 2); * UseOperation2(Operations.Modulo, 15, 4);*/ /* Console.WriteLine("打印Operations类内各函数属性:"); * PrintOperations();*/ /* Console.WriteLine("调用Operations类内各函数:"); * UseOperation("ADD", 3, 5); * UseOperation("MINUS", 9, 4); * UseOperation("MULTIPLY", 3, 7); * UseOperation("DIVIDE", 8, 2); * UseOperation("MOD", 15, 4);*/ Console.WriteLine("当前程序集名称:" + typeof(Program).Assembly.GetName()); Entity entity = new Entity(); entity.id = 6699; Player player = new Player(); player.ID = 55; EventSystem eventSystem = new EventSystem(); eventSystem.Add(DLLType.Model, typeof(Program).Assembly); // eventSystem.RegisterEvent(EventType.HelloWorld); int final = (int)NumericType.Hp / 10; int result = 555; eventSystem.RegisterEvent(EventType.HelloWorld); eventSystem.Run(EventType.HelloWorld, player, (NumericType)final, result); Console.ReadKey(); }
public void AddEventSystem() { EventSystem.Add(this); }