public static void SendEventMessage(Actor Actor, EventMessageScope Scope, String Message) { DatabaseLock.WaitOne(); switch (Scope) { //Send message only to the player case EventMessageScope.Single: { if (Actor == null) { break; } if (Actor.ConnectedClient == null) { break; } PendingMessages.Add(new RawPendingMessage(Actor.ConnectedClient, Message)); } break; //Send message to everyone in the same location as the player case EventMessageScope.Local: { if (Actor == null) { break; } var location = Actor.Location as Room; if (location == null) { break; } foreach (var thing in location.Contents) { var other = thing as Actor; if (other == null) { continue; } if (other.ConnectedClient == null) { continue; } PendingMessages.Add(new RawPendingMessage(other.ConnectedClient, Message)); } } break; //Send message to everyone in the same location EXCEPT the player. case EventMessageScope.External: { if (Actor == null) { break; } var location = Actor.Location as Room; if (location == null) { break; } foreach (var thing in location.Contents) { var other = thing as Actor; if (other == null) { continue; } if (Object.ReferenceEquals(other, Actor)) { continue; } if (other.ConnectedClient == null) { continue; } PendingMessages.Add(new RawPendingMessage(other.ConnectedClient, Message)); } } break; } DatabaseLock.ReleaseMutex(); }
public static void SendEventMessage(Actor Actor, EventMessageScope Scope, String Message) { DatabaseLock.WaitOne(); switch (Scope) { //Send message only to the player case EventMessageScope.Single: { if (Actor == null) break; if (Actor.ConnectedClient == null) break; PendingMessages.Add(new RawPendingMessage(Actor.ConnectedClient, Message)); } break; //Send message to everyone in the same location as the player case EventMessageScope.Local: { if (Actor == null) break; var location = Actor.Location as Room; if (location == null) break; foreach (var thing in location.Contents) { var other = thing as Actor; if (other == null) continue; if (other.ConnectedClient == null) continue; PendingMessages.Add(new RawPendingMessage(other.ConnectedClient, Message)); } } break; //Send message to everyone in the same location EXCEPT the player. case EventMessageScope.External: { if (Actor == null) break; var location = Actor.Location as Room; if (location == null) break; foreach (var thing in location.Contents) { var other = thing as Actor; if (other == null) continue; if (Object.ReferenceEquals(other, Actor)) continue; if (other.ConnectedClient == null) continue; PendingMessages.Add(new RawPendingMessage(other.ConnectedClient, Message)); } } break; } DatabaseLock.ReleaseMutex(); }