public async Task Leave(Presence user) { user.Match = null; await Channel.RemoveUser(user); if (Channel.Users.IsEmpty) { Global.Channels.Remove(Channel.TrueName); Global.Rooms.Remove(Id); await Global.OnlineManager.AddPacketToAllUsers(await FastPackets.DisposeMatch(Id)); XConsole.Log($"Match {ToString()} ended", ConsoleColor.Green); } else { var slot = GetSlot(user.Id); if (slot is null) { return; } slot.User = null; slot.Mods = Mods.NoMod; slot.Team = MatchTeam.Neutral; slot.Status = SlotStatus.Open; if (user.Id == HostId) { Host = Slots.First(x => (x.Status & SlotStatus.HasPlayer) != 0).User; } await Update(); } }
public string GetMappingStatus(string slotIDString) { if (Type == StationType.PreAligner || Type == StationType.Transfer) { return(Slots.First().GetSlotMapStatus()); } else { if (slotIDString.Equals("00")) { StringBuilder _responseBuilder = new StringBuilder(); bool removeComma = false; foreach (var s in Slots) { _responseBuilder.Append(s.GetSlotMapStatus()); _responseBuilder.Append(','); removeComma = true; } if (removeComma) { _responseBuilder.Remove(_responseBuilder.Length - 1, 1); } return(_responseBuilder.ToString()); } else { return(Slots.Where(s => s.ID.ToString("D2").Equals(slotIDString)).FirstOrDefault().GetSlotMapStatus()); } } }
public void Equip(Relic relic) { if (FindContainingSlot(relic) != null) { return; } var suitableSlot = FindSuitableSlot(relic) ?? Slots.First(); Equip(relic, suitableSlot); }
public void SwapWeapon() { if (CombatEncounter.Active?.IsEntityTurn(gameObject) == false) { return; } var mh = Slots.First(s => s.Type == EquipmentSlotType.MainHand); var oh = Slots.First(s => s.Type == EquipmentSlotType.OffHand); if (mh.Item.IsAnySkillOnCooldown() || oh.Item.IsAnySkillOnCooldown()) { throw new SkillIsOnCooldownException(); } var current = new List <Item> { mh.Item, oh.Item }; if (!mh.IsEmpty) { RemoveItemBonuses(mh.Item, mh); RemoveVisuals(mh.Item, mh); } if (!oh.IsEmpty) { RemoveItemBonuses(oh.Item, oh); RemoveVisuals(oh.Item, oh); } mh.Put(AltWeaponSet[0]); oh.Put(AltWeaponSet[1]); if (!mh.IsEmpty) { ApplyItemBonuses(mh.Item, mh); ApplyVisuals(mh.Item, mh); } if (!oh.IsEmpty) { ApplyItemBonuses(oh.Item, oh); ApplyVisuals(oh.Item, oh); } IsOnAltWeaponSet = !IsOnAltWeaponSet; SetAltWeaponSet(current); ItemEquipped?.Invoke(mh.Item); ItemEquipped?.Invoke(oh.Item); }
public void SetAltWeaponSet(List <Item> items) { for (var i = 0; i < 2; i++) { var item = items.IndexInBounds(i) ? items[i] : Item.CreateEmpty(); item.Equipment = this; item.Inventory = this.inventory; item.EquipmentSlot = Slots.First(s => s.Type == (i == 0 ? EquipmentSlotType.MainHand : EquipmentSlotType.OffHand)); item.ChangeOwner(gameObject); AltWeaponSet[i] = item; } }
public bool IsDualWielding() { var mh = Slots.First(s => s.Type == EquipmentSlotType.MainHand); var oh = Slots.First(s => s.Type == EquipmentSlotType.OffHand); if (mh.Item.IsEmpty || oh.Item.IsEmpty) { return(false); } return(mh.Item.IsWeapon && oh.Item.Type.Type != ItemTypeType.Shield && oh.Item.Type.Type != ItemTypeType.OffHand); }
public void Swap(Item item1, Item item2) { if (item2.IsEmpty) { EquipIntoSlot(item1, FindContainingSlot(item2)); } if (item1.SlotType != item2.SlotType) { return; } var index1 = Slots.IndexOf(Slots.First(slot => slot.Item.Equals(item1))); var index2 = Slots.IndexOf(Slots.First(slot => slot.Item.Equals(item2))); Unequip(item1); Unequip(item2); EquipIntoSlot(item1, Slots[index2]); EquipIntoSlot(item2, Slots[index1]); }
public List <Item> UnequipWeapon() { var weapon = new List <Item>(); var mh = Slots.First(s => s.Type == EquipmentSlotType.MainHand).Item; if (!mh.IsEmpty) { weapon.Add(mh); Unequip(mh); } var oh = Slots.First(s => s.Type == EquipmentSlotType.OffHand).Item; if (!oh.IsEmpty) { weapon.Add(oh); Unequip(oh); } return(weapon); }