public static bool GetFriend(IEnumerable <string> notorieties, string bodyType = "Any", string distance = "Next", string infliction = "Any") { TargetNotoriety notoFlags = TargetNotoriety.None; foreach (string noto in notorieties) { if (Enum.TryParse(noto, true, out TargetNotoriety flag)) { notoFlags |= flag; } } if (!Enum.TryParse(bodyType, true, out TargetBodyType bt)) { bt = TargetBodyType.Any; } if (!Enum.TryParse(distance, true, out TargetDistance td)) { td = TargetDistance.Next; } if (!Enum.TryParse(infliction, true, out TargetInfliction ti)) { ti = TargetInfliction.Any; } return(TargetManager.GetInstance().GetFriend(notoFlags, bt, td, TargetFriendType.Include, ti)); }
public Mobile GetMobile(TargetNotoriety notoFlags, TargetBodyType bodyType, TargetDistance targetDistance, TargetFriendType friendType, TargetInfliction inflictionType) { Notoriety[] noto = NotoFlagsToArray(notoFlags); Mobile m; switch (targetDistance) { case TargetDistance.Next: m = GetNextMobile(noto, bodyType, MAX_DISTANCE, friendType, inflictionType); break; case TargetDistance.Nearest: m = GetNextMobile(noto, bodyType, 3, friendType, inflictionType); break; case TargetDistance.Closest: m = GetClosestMobile(noto, bodyType, friendType, inflictionType); break; default: throw new ArgumentOutOfRangeException(nameof(targetDistance), targetDistance, null); } return(m); }
public bool GetFriend(TargetNotoriety notoFlags, TargetBodyType bodyType, TargetDistance targetDistance, TargetFriendType friendType = TargetFriendType.Include) { Mobile m = GetMobile(notoFlags, bodyType, targetDistance, friendType); if (m == null) { return(false); } SetFriend(m); return(true); }
public bool GetEnemy(TargetNotoriety notoFlags, TargetBodyType bodyType, TargetDistance targetDistance, TargetFriendType friendType = TargetFriendType.None, TargetInfliction inflictionType = TargetInfliction.Any) { Mobile m = GetMobile(notoFlags, bodyType, targetDistance, friendType, inflictionType); if (m == null) { return(false); } SetEnemy(m); return(true); }
public Mobile GetMobile(TargetNotoriety notoFlags, TargetBodyType bodyType, TargetDistance targetDistance, TargetFriendType friendType, TargetInfliction inflictionType, int previousSerial = 0) { Notoriety[] noto = NotoFlagsToArray(notoFlags); Mobile m; switch (targetDistance) { case TargetDistance.Next: m = GetNextMobile(noto, bodyType, MAX_DISTANCE, friendType, inflictionType); break; case TargetDistance.Nearest: Mobile previousMobile = Engine.Mobiles.GetMobile(previousSerial); if (previousMobile == null || previousMobile.Distance > MAX_DISTANCE) { m = GetClosestMobile(noto, bodyType, friendType, inflictionType); } else { m = GetNextMobile(noto, bodyType, MAX_DISTANCE, friendType, inflictionType, false, previousMobile); } break; case TargetDistance.Closest: m = GetClosestMobile(noto, bodyType, friendType, inflictionType); break; case TargetDistance.Previous: m = GetNextMobile(noto, bodyType, MAX_DISTANCE, friendType, inflictionType, true); break; default: throw new ArgumentOutOfRangeException(nameof(targetDistance), targetDistance, null); } return(m); }
public bool GetFriend(TargetNotoriety notoFlags, TargetBodyType bodyType, TargetDistance targetDistance, TargetFriendType friendType = TargetFriendType.Include, TargetInfliction inflictionType = TargetInfliction.Any) { Mobile m = GetMobile(notoFlags, bodyType, targetDistance, friendType, inflictionType, targetDistance == TargetDistance.Nearest ? AliasCommands.GetAlias("friend") : 0); if (m == null) { return(false); } SetFriend(m); return(true); }
public static bool GetEnemy(IEnumerable <string> notos, string bodyType = "Any", string distance = "Next") { TargetNotoriety notoFlags = TargetNotoriety.None; foreach (string noto in notos) { if (Enum.TryParse(noto, true, out TargetNotoriety flag)) { notoFlags |= flag; } } if (!Enum.TryParse(bodyType, true, out TargetBodyType bt)) { bt = TargetBodyType.Any; } if (!Enum.TryParse(distance, true, out TargetDistance td)) { td = TargetDistance.Next; } return(TargetManager.GetInstance().GetEnemy(notoFlags, bt, td)); }
private static Notoriety[] NotoFlagsToArray(TargetNotoriety notoFlags) { List <Notoriety> notos = new List <Notoriety>(); if (notoFlags.HasFlag(TargetNotoriety.Criminal) || notoFlags.HasFlag(TargetNotoriety.Any)) { notos.Add(Notoriety.Criminal); } if (notoFlags.HasFlag(TargetNotoriety.Enemy) || notoFlags.HasFlag(TargetNotoriety.Any)) { notos.Add(Notoriety.Enemy); } if (notoFlags.HasFlag(TargetNotoriety.Gray) || notoFlags.HasFlag(TargetNotoriety.Any)) { notos.Add(Notoriety.Attackable); } if (notoFlags.HasFlag(TargetNotoriety.Innocent) || notoFlags.HasFlag(TargetNotoriety.Any)) { notos.Add(Notoriety.Innocent); } if (notoFlags.HasFlag(TargetNotoriety.Murderer) || notoFlags.HasFlag(TargetNotoriety.Any)) { notos.Add(Notoriety.Murderer); } if (notoFlags.HasFlag(TargetNotoriety.Friend) || notoFlags.HasFlag(TargetNotoriety.Any)) { notos.Add(Notoriety.Ally); } return(notos.ToArray()); }