Skip to content

Commit

Permalink
fix(weaver): adding missing errors when Attributes are used in monobe…
Browse files Browse the repository at this point in the history
…haviour

Add missing error when someone uses `HasAuthorityAttribute` and `LocalPlayerAttribute` inside a monobehaviour
  • Loading branch information
James-Frowen committed Mar 3, 2021
1 parent be967e4 commit 64b580b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Assets/Mirage/Weaver/Processors/MonoBehaviourProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,21 @@ void ProcessSyncVars(TypeDefinition td)

void ProcessMethods(TypeDefinition td)
{
// find ServerRpc and RPC functions
// finds methods with RPC and other Attributes
foreach (MethodDefinition md in td.Methods)
{
if (md.HasCustomAttribute<ServerRpcAttribute>())
logger.Error($"ServerRpc {md.Name} must be declared inside a NetworkBehaviour", md);
if (md.HasCustomAttribute<ClientRpcAttribute>())
logger.Error($"ClientRpc {md.Name} must be declared inside a NetworkBehaviour", md);
if (md.HasCustomAttribute<ClientAttribute>())
logger.Error($"Client method {md.Name} must be declared inside a NetworkBehaviour", md);
logger.Error($"Client method {md.Name} must be declared inside a NetworkBehaviour", md);
if (md.HasCustomAttribute<ServerAttribute>())
logger.Error($"Server method {md.Name} must be declared inside a NetworkBehaviour", md);
if (md.HasCustomAttribute<HasAuthorityAttribute>())
logger.Error($"HasAuthority method {md.Name} must be declared inside a NetworkBehaviour", md);
if (md.HasCustomAttribute<LocalPlayerAttribute>())
logger.Error($"LocalPlayer method {md.Name} must be declared inside a NetworkBehaviour", md);
}
}
}
Expand Down

0 comments on commit 64b580b

Please sign in to comment.