Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
        private async void Player_NetUserDataChanged(Player obj)
        {
            if (_char != null)
            {
                return;
            }
            _char = await ServerDB.SelectCharacterAsync(_user.Char);

            if (_char == null)
            {
                _player.Error($"Error while retrieving pony");
            }
            else
            {
                _player.SetBounds();
                _player.SetVersion();
                _object = new WO_Player(this);
                _save   = new AutoSaveChar(this);
                _items  = _object.GetComponent <ItemsMgr>();
                _trade  = _object.GetComponent <TradeMgr>();
                _skills = _object.GetComponent <SkillsMgr>();
                SetPet();
                _user.Map = _server.Map.Id;
                _char.Map = _user.Map;
                _player.SynchNetData();
                await CharsMgr.SaveCharacterAsync(_char);
            }
        }
Ejemplo n.º 3
0
 public ItemsMgr(WO_Player parent)
     : base(parent)
 {
     _wPlayer    = parent;
     _mPlayer    = _wPlayer.Player;
     _player     = _mPlayer.Player;
     m_data      = _mPlayer.Data;
     m_items     = m_data.Items;
     m_wears     = m_data.Wears;
     m_itemsHash = new HashSet <int>();
     foreach (var item in m_items)
     {
         var value = item.Value;
         if (!m_itemsHash.Contains(value.Item.Id))
         {
             m_itemsHash.Add(value.Item.Id);
         }
     }
     m_wearSlotsUsed = WearablePosition.None;
     foreach (var item in m_wears)
     {
         var     value = item.Value;
         DB_Item dbitem;
         if (DataMgr.Select(value.Id, out dbitem))
         {
             m_wearSlotsUsed |= dbitem.Slot;
         }
     }
     parent.OnSpawn   += ItemsMgr_OnSpawn;
     parent.OnDestroy += ItemsMgr_OnDestroy;
 }
Ejemplo n.º 4
0
 public void Teleport(WO_Player obj, ushort id = 0)
 {
     if (_nsObjects.TryGetValue(id, out var obj01) || _nsObjects.TryGetValue(0, out obj01))
     {
         obj.Teleport(obj01.Position);
         obj.Rotation = obj01.Rotation.ToRadians();
     }
 }
Ejemplo n.º 5
0
 public PlayerMovement(WO_Player parent)
     : base(parent)
 {
     _player           = parent.Player;
     _entry            = new SyncEntry();
     _position         = _player.Data.Position;
     _rotation         = _player.Data.Rotation;
     parent.OnSpawn   += PlayerMovement_OnSpawn;
     parent.OnDestroy += PlayerMovement_OnDestroy;
 }
Ejemplo n.º 6
0
 public TradeMgr(WO_Player parent)
     : base(parent)
 {
     _wPlayer          = parent;
     _player           = parent.Player;
     m_offer           = new Dictionary <int, TradingStack>();
     parent.OnSpawn   += TradeMgr_OnSpawn;
     parent.OnDestroy += TradeMgr_OnDestroy;
     parent.OnDespawn += TradeMgr_OnDespawn;
 }
Ejemplo n.º 7
0
 private void ItemsMgr_OnDestroy()
 {
     m_view      = null;
     m_data      = null;
     m_wears     = null;
     m_items     = null;
     _player     = null;
     _mPlayer    = null;
     _wPlayer    = null;
     m_itemsHash = null;
 }
Ejemplo n.º 8
0
 public SkillsMgr(WO_Player parent)
     : base(parent)
 {
     _wPlayer          = parent;
     _mPlayer          = _wPlayer.Player;
     _entry            = new TargetEntry();
     _skills           = _wPlayer.Player.Data.Skills;
     _cooldown         = new Dictionary <int, CooldownReset>();
     parent.OnSpawn   += SkillsMgr_OnSpawn;
     parent.OnDestroy += SkillsMgr_OnDestroy;
 }
Ejemplo n.º 9
0
 public PlayerStatsMgr(WO_Player parent)
     : base(parent)
 {
     _mPlayer = parent.Player;
     if (_stats.Count == 0)
     {
         CreateBase();
     }
     parent.OnDestroy += PlayerStatsMgr_OnDestroy;
     UpdateStats();
 }
Ejemplo n.º 10
0
        private void SkillsMgr_OnDestroy()
        {
            var toDestroy = _cooldown.ToArray();

            for (int i = 0; i < toDestroy.Length; i++)
            {
                toDestroy[i].Value.Destroy();
            }
            _cooldown.Clear();
            _skills   = null;
            _mPlayer  = null;
            _wPlayer  = null;
            _cooldown = null;
        }
Ejemplo n.º 11
0
 private void TradeMgr_OnDestroy()
 {
     _regected?.Destroy();
     if (_trading && _target.Trade._trading)
     {
         _target.Trade.Close();
     }
     _view     = null;
     m_offer   = null;
     _target   = null;
     _wPlayer  = null;
     _player   = null;
     _regected = null;
 }