mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Weaver ProcessEvents moved into NetworkBehaviourSyncEventProcessor too
This commit is contained in:
parent
4f5f76e42f
commit
39a599963a
@ -48,7 +48,7 @@ public void Process()
|
||||
|
||||
ProcessMethods();
|
||||
|
||||
ProcessEvents();
|
||||
NetworkBehaviourSyncEventProcessor.ProcessEvents(m_td, m_Events, m_EventInvocationFuncs);
|
||||
if (Weaver.fail)
|
||||
{
|
||||
return;
|
||||
@ -982,54 +982,6 @@ void ProcessMethods()
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessEvents()
|
||||
{
|
||||
// find events
|
||||
foreach (EventDefinition ed in m_td.Events)
|
||||
{
|
||||
foreach (var ca in ed.CustomAttributes)
|
||||
{
|
||||
if (ca.AttributeType.FullName == Weaver.SyncEventType.FullName)
|
||||
{
|
||||
if (ed.Name.Length > 4 && ed.Name.Substring(0, 5) != "Event")
|
||||
{
|
||||
Log.Error("Event [" + m_td.FullName + ":" + ed.FullName + "] doesnt have 'Event' prefix");
|
||||
Weaver.fail = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ed.EventType.Resolve().HasGenericParameters)
|
||||
{
|
||||
Log.Error("Event [" + m_td.FullName + ":" + ed.FullName + "] cannot have generic parameters");
|
||||
Weaver.fail = true;
|
||||
return;
|
||||
}
|
||||
|
||||
m_Events.Add(ed);
|
||||
MethodDefinition eventFunc = NetworkBehaviourSyncEventProcessor.ProcessEventInvoke(m_td, ed);
|
||||
if (eventFunc == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_td.Methods.Add(eventFunc);
|
||||
m_EventInvocationFuncs.Add(eventFunc);
|
||||
|
||||
Weaver.DLog(m_td, "ProcessEvent " + ed);
|
||||
|
||||
MethodDefinition eventCallFunc = NetworkBehaviourSyncEventProcessor.ProcessEventCall(ed, ca);
|
||||
m_td.Methods.Add(eventCallFunc);
|
||||
|
||||
Weaver.lists.replacedEvents.Add(ed);
|
||||
Weaver.lists.replacementEvents.Add(eventCallFunc);
|
||||
|
||||
Weaver.DLog(m_td, " Event: " + ed.Name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool HasMethod(string name)
|
||||
{
|
||||
foreach (var method in m_td.Methods)
|
||||
|
@ -1,4 +1,5 @@
|
||||
// all the SyncEvent code from NetworkBehaviourProcessor in one place
|
||||
using System.Collections.Generic;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
|
||||
@ -99,5 +100,53 @@ public static MethodDefinition ProcessEventCall(EventDefinition ed, CustomAttrib
|
||||
|
||||
return evt;
|
||||
}
|
||||
|
||||
public static void ProcessEvents(TypeDefinition td, List<EventDefinition> events, List<MethodDefinition> eventInvocationFuncs)
|
||||
{
|
||||
// find events
|
||||
foreach (EventDefinition ed in td.Events)
|
||||
{
|
||||
foreach (var ca in ed.CustomAttributes)
|
||||
{
|
||||
if (ca.AttributeType.FullName == Weaver.SyncEventType.FullName)
|
||||
{
|
||||
if (ed.Name.Length > 4 && ed.Name.Substring(0, 5) != "Event")
|
||||
{
|
||||
Log.Error("Event [" + td.FullName + ":" + ed.FullName + "] doesnt have 'Event' prefix");
|
||||
Weaver.fail = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ed.EventType.Resolve().HasGenericParameters)
|
||||
{
|
||||
Log.Error("Event [" + td.FullName + ":" + ed.FullName + "] cannot have generic parameters");
|
||||
Weaver.fail = true;
|
||||
return;
|
||||
}
|
||||
|
||||
events.Add(ed);
|
||||
MethodDefinition eventFunc = NetworkBehaviourSyncEventProcessor.ProcessEventInvoke(td, ed);
|
||||
if (eventFunc == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
td.Methods.Add(eventFunc);
|
||||
eventInvocationFuncs.Add(eventFunc);
|
||||
|
||||
Weaver.DLog(td, "ProcessEvent " + ed);
|
||||
|
||||
MethodDefinition eventCallFunc = NetworkBehaviourSyncEventProcessor.ProcessEventCall(ed, ca);
|
||||
td.Methods.Add(eventCallFunc);
|
||||
|
||||
Weaver.lists.replacedEvents.Add(ed);
|
||||
Weaver.lists.replacementEvents.Add(eventCallFunc);
|
||||
|
||||
Weaver.DLog(td, " Event: " + ed.Name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user