fix: Adds required changes for Advanced Search feature (#1650)
This commit is contained in:
parent
96c3f2eb91
commit
fe6e9dfe5c
3 changed files with 14 additions and 20 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using Server.Collections;
|
using Server.Collections;
|
||||||
using Server.Json;
|
using Server.Json;
|
||||||
|
|
@ -510,7 +511,7 @@ public class Region : IComparable<Region>, IValueLinkListNode<Region>
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Region GetRegion(string regionName)
|
public Region GetRegion(string regionName, bool caseSensitive = true)
|
||||||
{
|
{
|
||||||
if (regionName == null)
|
if (regionName == null)
|
||||||
{
|
{
|
||||||
|
|
@ -518,10 +519,11 @@ public class Region : IComparable<Region>, IValueLinkListNode<Region>
|
||||||
}
|
}
|
||||||
|
|
||||||
var r = this;
|
var r = this;
|
||||||
|
var comparisonType = caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (r.Name == regionName)
|
if (string.Equals(r.Name, regionName, comparisonType))
|
||||||
{
|
{
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
@ -532,11 +534,14 @@ public class Region : IComparable<Region>, IValueLinkListNode<Region>
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool IsPartOf<T>() where T : Region => GetRegion<T>() != null;
|
public bool IsPartOf<T>() where T : Region => GetRegion<T>() != null;
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool IsPartOf(Region region) => this == region || IsChildOf(region);
|
public bool IsPartOf(Region region) => this == region || IsChildOf(region);
|
||||||
|
|
||||||
public bool IsPartOf(string regionName) => GetRegion(regionName) != null;
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public bool IsPartOf(string regionName, bool caseSensitive = false) => GetRegion(regionName, caseSensitive) != null;
|
||||||
|
|
||||||
public virtual bool AcceptsSpawnsFrom(Region region) =>
|
public virtual bool AcceptsSpawnsFrom(Region region) =>
|
||||||
AllowSpawn() && (region == this || Parent?.AcceptsSpawnsFrom(region) == true);
|
AllowSpawn() && (region == this || Parent?.AcceptsSpawnsFrom(region) == true);
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,13 @@ public static class InsensitiveStringHelpers
|
||||||
public static int InsensitiveCompare(this string a, string b) => string.Compare(a, b, StringComparison.OrdinalIgnoreCase);
|
public static int InsensitiveCompare(this string a, string b) => string.Compare(a, b, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static bool InsensitiveEquals(this ReadOnlySpan<char> a, string b) =>
|
public static bool InsensitiveEquals(this ReadOnlySpan<char> a, ReadOnlySpan<char> b) =>
|
||||||
a.Equals(b, StringComparison.OrdinalIgnoreCase);
|
a.Equals(b, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static bool InsensitiveEquals(this string a, ReadOnlySpan<char> b) =>
|
||||||
|
a?.AsSpan().Equals(b, StringComparison.OrdinalIgnoreCase) ?? false;
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static bool InsensitiveEquals(this string a, string b) =>
|
public static bool InsensitiveEquals(this string a, string b) =>
|
||||||
a?.Equals(b, StringComparison.OrdinalIgnoreCase) ?? b == null;
|
a?.Equals(b, StringComparison.OrdinalIgnoreCase) ?? b == null;
|
||||||
|
|
|
||||||
|
|
@ -61,21 +61,6 @@ namespace Server.Gumps
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnResponse(NetState sender, RelayInfo info)
|
public override void OnResponse(NetState sender, RelayInfo info) => m_Callback?.Invoke(info.ButtonID == 1);
|
||||||
{
|
|
||||||
if (m_Callback == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info.ButtonID == 1)
|
|
||||||
{
|
|
||||||
m_Callback(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Callback(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue