diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IDataInfo.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IDataInfo.cs
index 330b08ac41..34933f7d17 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IDataInfo.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Data/IDataInfo.cs
@@ -1,12 +1,15 @@
-namespace Barotrauma.LuaCs.Data;
+using System;
+using System.Collections.Generic;
+
+namespace Barotrauma.LuaCs.Data;
///
/// Serves as a compound-key to refer to all resources and information that comes from a specific source.
///
-public interface IDataInfo
+public interface IDataInfo : IEqualityComparer, IEquatable
{
///
- /// Package-Unique name to be used internally for all representations of, and references to, this information.
+ /// Internal name unique within the resources inside a package.
///
string InternalName { get; }
///
@@ -17,4 +20,33 @@ public interface IDataInfo
/// Used in place of the package data when the OwnerPackage is missing.
///
string FallbackPackageName { get; }
+
+ bool IEqualityComparer.Equals(IDataInfo x, IDataInfo y)
+ {
+ if (x is null || y is null)
+ return false;
+ if (x.OwnerPackage is null)
+ throw new NullReferenceException($"ContentPackage not set for resource {x}!");
+ if (y.OwnerPackage is null)
+ throw new NullReferenceException($"ContentPackage not set for resource {y}!");
+ if (x.InternalName.IsNullOrWhiteSpace())
+ throw new NullReferenceException($"InternalName not set for resource {x}!");
+ if (y.InternalName.IsNullOrWhiteSpace())
+ throw new NullReferenceException($"InternalName not set for resource {y}!");
+ return x.OwnerPackage == y.OwnerPackage && x.InternalName == y.InternalName;
+ }
+
+ bool IEquatable.Equals(IDataInfo other)
+ {
+ return Equals(this, other);
+ }
+
+ int IEqualityComparer.GetHashCode(IDataInfo obj)
+ {
+ if (obj.OwnerPackage is null)
+ throw new NullReferenceException($"ContentPackage not set for resource {obj}!");
+ if (obj.InternalName.IsNullOrWhiteSpace())
+ throw new NullReferenceException($"InternalName is null for object {obj}!");
+ return obj.InternalName.GetHashCode() + obj.OwnerPackage.GetHashCode();
+ }
}