SanAndreasUnity/Assets/Scripts/Utilities/WhenOnClient.cs

30 lines
729 B
C#
Raw Normal View History

2019-05-28 14:30:47 +00:00
namespace SanAndreasUnity.Utilities
{
public enum WhenOnClient
{
Never = 0,
OnlyOnOtherClients,
OnlyOnLocalPlayer,
Always,
}
public static class WhenOnClientExtensions
{
public static bool Matches(this WhenOnClient when, bool isLocalPlayer, bool isClient)
{
if (when == WhenOnClient.Always)
return true;
if (when == WhenOnClient.Never)
return false;
2019-08-29 17:49:23 +00:00
if (when == WhenOnClient.OnlyOnLocalPlayer)
return isLocalPlayer;
if (when == WhenOnClient.OnlyOnOtherClients)
return isClient && ! isLocalPlayer;
2019-05-28 14:30:47 +00:00
return false;
}
}
}