public void SetPet(int id = -1) { if (id > 0) { if (_pet != null) { _pet.Destroy(); } _pet = new WO_Pet(id, _object); _char.Data.Variables[Constants.PlayerVarPet] = id; } else if (_pet != null) { _char.Data.Variables.Remove(Constants.PlayerVarPet); _pet.Destroy(); _pet = null; } else { id = _char.Data.GetVariable(Constants.PlayerVarPet); if (id > 0) { _pet = new WO_Pet(id, _object); } } }
public void Destroy() { _player.NetUserDataChanged -= Player_NetUserDataChanged; _save.Destroy(); _object.Destroy(); _pet?.Destroy(); CharsMgr.SaveCharacter(_char); if (_dialog != null) { _dialog.Dialog.OnDialogEnd(this); } if (_shop != null) { _shop.Movement.Unlock(); } foreach (var item in _clones.Values.ToArray()) { item.Destroy(); } _pet = null; _save = null; _shop = null; _user = null; _char = null; _trade = null; _items = null; _clones = null; _dialog = null; _server = null; _player = null; _object = null; _skills = null; }