/// <summary> /// Player requests channel list /// </summary> /// <param name="player"></param> public static void PlayerRequestChannels(Player player) { List <Channel> channels = Channels.getChannelsForPlayer(player); player.Connection.SendChannelList(channels); }
/// <summary> /// Triggered when any creature speaks /// We're basically using "Creature" since this function will handle NPCs and monsters speaking /// </summary> /// <param name="creature"></param> /// <param name="type"></param> /// <param name="message"></param> /// <param name="privateTo"></param> /// <param name="channelId"></param> public static void CreatureSpeak(Creature creature, TalkType type, string message, string privateTo, short channelId = 0) { Task.Factory.StartNew(() => { HashSet <Creature> spectators = new HashSet <Creature>(); switch (type) { case TalkType.Say: GetCreatureSpectators(spectators, creature.Position, false, Map.maxClientViewportX, Map.maxClientViewportX, Map.maxClientViewportY, Map.maxClientViewportY); foreach (Creature c in spectators) { if (c is Player) { Player player = (Player)c; player.Connection.SendCreatureSay(creature, type, message); } c.onCreatureSpeak(creature, type, message); } break; case TalkType.Whisper: GetCreatureSpectators(spectators, creature.Position, false, Map.maxClientViewportX, Map.maxClientViewportX, Map.maxClientViewportY, Map.maxClientViewportY); foreach (Creature c in spectators) { if (c is Player) { Player player = (Player)c; if (Position.AreInRange(player.Position, creature.Position)) { player.Connection.SendCreatureSay(creature, type, message); } else { player.Connection.SendCreatureSay(creature, type, "pspsps"); } } c.onCreatureSpeak(creature, type, message); } break; case TalkType.Yell: // TODO: Yelling exhaustion, 30 seconds GetCreatureSpectators(spectators, creature.Position, false, 18, 18, 14, 14); foreach (Creature c in spectators) { if (c is Player) { Player player = (Player)c; player.Connection.SendCreatureSay(creature, type, message.ToUpper()); } } break; case TalkType.PrivateChannel: case TalkType.PrivateChannelRed: case TalkType.RuleViolationAnswer: PlayerTalkTo((Player)creature, type, message, privateTo); break; case TalkType.ChannelYellow: case TalkType.ChannelRed: case TalkType.ChannelRedAnonymous: if (!Channels.PlayerTalkToChannel((Player)creature, (ChannelID)channelId, message, type)) { // Re-send in default as we weren't able to talk to the given channel CreatureSpeak(creature, TalkType.Say, message, ""); } break; case TalkType.Broadcast: PlayerBroadcastMessage((Player)creature, message); break; case TalkType.RuleViolationContinue: RuleViolations.PlayerContinueRuleViolationReport((Player)creature, message); break; case TalkType.RuleViolationChannel: // Rule Violation Reporting RuleViolations.PlayerReportRuleViolation((Player)creature, message); break; default: break; } }); }