mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
MonoBehaviourProcessor: remove static WeavingFailed references
This commit is contained in:
parent
64964fb169
commit
b87096d5c9
@ -5,13 +5,13 @@ namespace Mirror.Weaver
|
|||||||
// only shows warnings in case we use SyncVars etc. for MonoBehaviour.
|
// only shows warnings in case we use SyncVars etc. for MonoBehaviour.
|
||||||
static class MonoBehaviourProcessor
|
static class MonoBehaviourProcessor
|
||||||
{
|
{
|
||||||
public static void Process(Logger Log, TypeDefinition td)
|
public static void Process(Logger Log, TypeDefinition td, ref bool WeavingFailed)
|
||||||
{
|
{
|
||||||
ProcessSyncVars(Log, td);
|
ProcessSyncVars(Log, td, ref WeavingFailed);
|
||||||
ProcessMethods(Log, td);
|
ProcessMethods(Log, td, ref WeavingFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessSyncVars(Logger Log, TypeDefinition td)
|
static void ProcessSyncVars(Logger Log, TypeDefinition td, ref bool WeavingFailed)
|
||||||
{
|
{
|
||||||
// find syncvars
|
// find syncvars
|
||||||
foreach (FieldDefinition fd in td.Fields)
|
foreach (FieldDefinition fd in td.Fields)
|
||||||
@ -19,18 +19,18 @@ static void ProcessSyncVars(Logger Log, TypeDefinition td)
|
|||||||
if (fd.HasCustomAttribute<SyncVarAttribute>())
|
if (fd.HasCustomAttribute<SyncVarAttribute>())
|
||||||
{
|
{
|
||||||
Log.Error($"SyncVar {fd.Name} must be inside a NetworkBehaviour. {td.Name} is not a NetworkBehaviour", fd);
|
Log.Error($"SyncVar {fd.Name} must be inside a NetworkBehaviour. {td.Name} is not a NetworkBehaviour", fd);
|
||||||
Weaver.WeavingFailed = true;
|
WeavingFailed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SyncObjectInitializer.ImplementsSyncObject(fd.FieldType))
|
if (SyncObjectInitializer.ImplementsSyncObject(fd.FieldType))
|
||||||
{
|
{
|
||||||
Log.Error($"{fd.Name} is a SyncObject and must be inside a NetworkBehaviour. {td.Name} is not a NetworkBehaviour", fd);
|
Log.Error($"{fd.Name} is a SyncObject and must be inside a NetworkBehaviour. {td.Name} is not a NetworkBehaviour", fd);
|
||||||
Weaver.WeavingFailed = true;
|
WeavingFailed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessMethods(Logger Log, TypeDefinition td)
|
static void ProcessMethods(Logger Log, TypeDefinition td, ref bool WeavingFailed)
|
||||||
{
|
{
|
||||||
// find command and RPC functions
|
// find command and RPC functions
|
||||||
foreach (MethodDefinition md in td.Methods)
|
foreach (MethodDefinition md in td.Methods)
|
||||||
@ -38,17 +38,17 @@ static void ProcessMethods(Logger Log, TypeDefinition td)
|
|||||||
if (md.HasCustomAttribute<CommandAttribute>())
|
if (md.HasCustomAttribute<CommandAttribute>())
|
||||||
{
|
{
|
||||||
Log.Error($"Command {md.Name} must be declared inside a NetworkBehaviour", md);
|
Log.Error($"Command {md.Name} must be declared inside a NetworkBehaviour", md);
|
||||||
Weaver.WeavingFailed = true;
|
WeavingFailed = true;
|
||||||
}
|
}
|
||||||
if (md.HasCustomAttribute<ClientRpcAttribute>())
|
if (md.HasCustomAttribute<ClientRpcAttribute>())
|
||||||
{
|
{
|
||||||
Log.Error($"ClientRpc {md.Name} must be declared inside a NetworkBehaviour", md);
|
Log.Error($"ClientRpc {md.Name} must be declared inside a NetworkBehaviour", md);
|
||||||
Weaver.WeavingFailed = true;
|
WeavingFailed = true;
|
||||||
}
|
}
|
||||||
if (md.HasCustomAttribute<TargetRpcAttribute>())
|
if (md.HasCustomAttribute<TargetRpcAttribute>())
|
||||||
{
|
{
|
||||||
Log.Error($"TargetRpc {md.Name} must be declared inside a NetworkBehaviour", md);
|
Log.Error($"TargetRpc {md.Name} must be declared inside a NetworkBehaviour", md);
|
||||||
Weaver.WeavingFailed = true;
|
WeavingFailed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ static bool WeaveNetworkBehavior(TypeDefinition td)
|
|||||||
if (!td.IsDerivedFrom<NetworkBehaviour>())
|
if (!td.IsDerivedFrom<NetworkBehaviour>())
|
||||||
{
|
{
|
||||||
if (td.IsDerivedFrom<UnityEngine.MonoBehaviour>())
|
if (td.IsDerivedFrom<UnityEngine.MonoBehaviour>())
|
||||||
MonoBehaviourProcessor.Process(Log, td);
|
MonoBehaviourProcessor.Process(Log, td, ref WeavingFailed);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user