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.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json.Serialization;
|
||||
using Server.Collections;
|
||||
using Server.Json;
|
||||
|
|
@ -510,7 +511,7 @@ public class Region : IComparable<Region>, IValueLinkListNode<Region>
|
|||
return null;
|
||||
}
|
||||
|
||||
public Region GetRegion(string regionName)
|
||||
public Region GetRegion(string regionName, bool caseSensitive = true)
|
||||
{
|
||||
if (regionName == null)
|
||||
{
|
||||
|
|
@ -518,10 +519,11 @@ public class Region : IComparable<Region>, IValueLinkListNode<Region>
|
|||
}
|
||||
|
||||
var r = this;
|
||||
var comparisonType = caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
|
||||
|
||||
do
|
||||
{
|
||||
if (r.Name == regionName)
|
||||
if (string.Equals(r.Name, regionName, comparisonType))
|
||||
{
|
||||
return r;
|
||||
}
|
||||
|
|
@ -532,11 +534,14 @@ public class Region : IComparable<Region>, IValueLinkListNode<Region>
|
|||
return null;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
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(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) =>
|
||||
AllowSpawn() && (region == this || Parent?.AcceptsSpawnsFrom(region) == true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue