using System; using Unity.Netcode; namespace ProjectI.Builds { [Serializable] public struct BuildLoadout : INetworkSerializable, IEquatable { public int PassiveFirst; public int PassiveSecond; public int ActiveFirst; public int ActiveSecond; public int ActiveThird; public int Ultimate; public int Melee; public static BuildLoadout Default => new BuildLoadout(1, 3, 101, 102, 201); public BuildLoadout(int passiveFirst, int passiveSecond, int activeFirst, int activeSecond, int melee) : this(passiveFirst, passiveSecond, activeFirst, activeSecond, 105, 302, melee) { } public BuildLoadout(int passiveFirst, int passiveSecond, int activeFirst, int activeSecond, int activeThird, int ultimate, int melee) { PassiveFirst = passiveFirst; PassiveSecond = passiveSecond; ActiveFirst = activeFirst; ActiveSecond = activeSecond; ActiveThird = activeThird; Ultimate = ultimate; Melee = melee; } public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { serializer.SerializeValue(ref PassiveFirst); serializer.SerializeValue(ref PassiveSecond); serializer.SerializeValue(ref ActiveFirst); serializer.SerializeValue(ref ActiveSecond); serializer.SerializeValue(ref ActiveThird); serializer.SerializeValue(ref Ultimate); serializer.SerializeValue(ref Melee); } public int EquippedId(int slot) => slot switch { EquippedAbilitySlot.First => ActiveFirst, EquippedAbilitySlot.Second => ActiveSecond, EquippedAbilitySlot.Third => ActiveThird, EquippedAbilitySlot.Ultimate => Ultimate, EquippedAbilitySlot.Melee => Melee, _ => 0 }; public bool Equals(BuildLoadout other) => PassiveFirst == other.PassiveFirst && PassiveSecond == other.PassiveSecond && ActiveFirst == other.ActiveFirst && ActiveSecond == other.ActiveSecond && ActiveThird == other.ActiveThird && Ultimate == other.Ultimate && Melee == other.Melee; public override bool Equals(object obj) => obj is BuildLoadout other && Equals(other); public override int GetHashCode() => HashCode.Combine(PassiveFirst, PassiveSecond, ActiveFirst, ActiveSecond, ActiveThird, Ultimate, Melee); } }