public CloseShop ( bool closedByCharacter = false ) : void | ||
closedByCharacter | bool | |
리턴 | void |
public void CloseShop(bool closedByCharacter = false)
{
if (HasShopOpened && Session.HasCurrentMap)
{
KeyValuePair<long, MapShop> shop = Session.CurrentMap.UserShops.FirstOrDefault(mapshop => mapshop.Value.OwnerId.Equals(CharacterId));
if (!shop.Equals(default(KeyValuePair<long, MapShop>)))
{
Session.CurrentMap.UserShops.Remove(shop.Key);
// declare that the shop cannot be closed
HasShopOpened = false;
Session.CurrentMap?.Broadcast(GenerateShopEnd());
Session.CurrentMap?.Broadcast(Session, GeneratePlayerFlag(0), ReceiverType.AllExceptMe);
IsSitting = false;
IsShopping = false; // close shop by character will always completely close the shop
LoadSpeed();
Session.SendPacket(GenerateCond());
Session.CurrentMap?.Broadcast(GenerateRest());
}
}
}
public void Destroy() { // unregister from WCF events ServiceFactory.Instance.CommunicationCallback.CharacterConnectedEvent -= CommunicationCallback_CharacterConnectedEvent; ServiceFactory.Instance.CommunicationCallback.CharacterDisconnectedEvent -= CommunicationCallback_CharacterDisconnectedEvent; // do everything necessary before removing client, DB save, Whatever if (HasSelectedCharacter) { Character.CloseShop(); // disconnect client ServiceFactory.Instance.CommunicationService.DisconnectCharacter(Character.Name); // unregister from map if registered if (CurrentMap != null) { CurrentMap.UnregisterSession(this.Character.CharacterId); CurrentMap = null; ServerManager.Instance.UnregisterSession(this.Character.CharacterId); } } if (Account != null) { ServiceFactory.Instance.CommunicationService.DisconnectAccount(Account.Name); } _queue.ClearQueue(); }