using System; using Unity.Netcode; namespace ProjectI.Combat { public enum BuffSourceKind { None, Ability, Core } public struct EffectSourceKey : INetworkSerializable, IEquatable, IComparable { public BuffSourceKind Kind; public int SourceId; public ulong SourceOwner; public EffectSourceKey(BuffSourceKind kind,int sourceId,ulong sourceOwner) { Kind=kind;SourceId=sourceId;SourceOwner=sourceOwner; } public static EffectSourceKey Ability(int id,ulong owner)=>new EffectSourceKey(BuffSourceKind.Ability,id,owner); public static EffectSourceKey Core(ProjectI.Runs.UpgradeId id,ulong owner)=>new EffectSourceKey(BuffSourceKind.Core,(int)id,owner); public void NetworkSerialize(BufferSerializer s) where T:IReaderWriter { s.SerializeValue(ref Kind);s.SerializeValue(ref SourceId);s.SerializeValue(ref SourceOwner); } public bool Equals(EffectSourceKey other)=>Kind==other.Kind&&SourceId==other.SourceId&&SourceOwner==other.SourceOwner; public override bool Equals(object value)=>value is EffectSourceKey other&&Equals(other); public override int GetHashCode()=>unchecked(((int)Kind*397^SourceId)*397^SourceOwner.GetHashCode()); public int CompareTo(EffectSourceKey other) { int c=Kind.CompareTo(other.Kind);if(c!=0)return c;c=SourceId.CompareTo(other.SourceId);return c!=0?c:SourceOwner.CompareTo(other.SourceOwner); } } }