diff --git a/Source/Engine/AI/BehaviorKnowledgeSelector.h b/Source/Engine/AI/BehaviorKnowledgeSelector.h index 976711282..092d42b1c 100644 --- a/Source/Engine/AI/BehaviorKnowledgeSelector.h +++ b/Source/Engine/AI/BehaviorKnowledgeSelector.h @@ -91,6 +91,13 @@ API_STRUCT(InBuild, Template, MarshalAs=StringAnsi) struct FLAXENGINE_API Behavi return false; } + BehaviorKnowledgeSelector() = default; + + BehaviorKnowledgeSelector(const StringAnsi& other) + { + Path = other; + } + BehaviorKnowledgeSelector& operator=(const StringAnsiView& other) noexcept { Path = other; diff --git a/Source/Engine/Content/JsonAssetReference.cs b/Source/Engine/Content/JsonAssetReference.cs index 7c8a8902f..766645161 100644 --- a/Source/Engine/Content/JsonAssetReference.cs +++ b/Source/Engine/Content/JsonAssetReference.cs @@ -12,7 +12,7 @@ namespace FlaxEngine #if FLAX_EDITOR [CustomEditor(typeof(FlaxEditor.CustomEditors.Editors.AssetRefEditor))] #endif - public struct JsonAssetReference + public struct JsonAssetReference : IComparable, IComparable>, IEquatable> { /// /// Gets or sets the referenced asset. @@ -94,16 +94,40 @@ namespace FlaxEngine return left.Asset != right.Asset; } + /// + public bool Equals(JsonAssetReference other) + { + return Asset == other.Asset; + } + + /// + public int CompareTo(JsonAssetReference other) + { + return Object.GetUnmanagedPtr(Asset).CompareTo(Object.GetUnmanagedPtr(other.Asset)); + } + + /// + public override bool Equals(object obj) + { + return obj is JsonAssetReference other && Asset == other.Asset; + } + /// public override string ToString() { return Asset?.ToString(); } + /// + public int CompareTo(object obj) + { + return obj is JsonAssetReference other ? CompareTo(other) : 1; + } + /// public override int GetHashCode() { - return Asset?.GetHashCode() ?? 0; + return (Asset != null ? Asset.GetHashCode() : 0); } } } diff --git a/Source/Engine/Content/JsonAssetReference.h b/Source/Engine/Content/JsonAssetReference.h index d84c44926..965a0aaa0 100644 --- a/Source/Engine/Content/JsonAssetReference.h +++ b/Source/Engine/Content/JsonAssetReference.h @@ -12,6 +12,13 @@ template API_STRUCT(NoDefault, Template, MarshalAs=JsonAsset*) struct JsonAssetReference : AssetReference { + JsonAssetReference() = default; + + JsonAssetReference(JsonAsset* asset) + { + OnSet(asset); + } + /// /// Gets the deserialized native object instance of the given type. Returns null if asset is not loaded or loaded object has different type. /// diff --git a/Source/Engine/Engine/NativeInterop.cs b/Source/Engine/Engine/NativeInterop.cs index 026f54fec..7dfd52d22 100644 --- a/Source/Engine/Engine/NativeInterop.cs +++ b/Source/Engine/Engine/NativeInterop.cs @@ -249,7 +249,7 @@ namespace FlaxEngine.Interop /// The input array. /// Converter callback. /// The output array. - public static TDst[] ConvertArray(Span src, Func convertFunc) + public static TDst[] ConvertArray(this Span src, Func convertFunc) { TDst[] dst = new TDst[src.Length]; for (int i = 0; i < src.Length; i++) @@ -265,7 +265,7 @@ namespace FlaxEngine.Interop /// The input array. /// Converter callback. /// The output array. - public static TDst[] ConvertArray(TSrc[] src, Func convertFunc) + public static TDst[] ConvertArray(this TSrc[] src, Func convertFunc) { TDst[] dst = new TDst[src.Length]; for (int i = 0; i < src.Length; i++)