private void OnNewTick(NewTickPacket newTick) { _lastTickTime = _currentTickTime; int time = GetTime(); _currentTickTime = time; if (_request != null && time - _request.Start > _request.Timeout) { _request.OnTimeout?.Invoke(); _request = null; } if (_moveQueue.Count > 0) { MoveEvent e = _moveQueue.Peek(); MoveTo(e.X, e.Y); } _net.SendPacket(new MovePacket { TickId = newTick.TickId, NewPosition = position, Time = GetTime(), Records = _records }); foreach (var status in newTick.Statuses) { if (Players.ContainsKey(status.ObjectId)) { PlayerData.processStatData(status.Stats, Players[status.ObjectId]); } } }
private void Reset() { Players.Clear(); _request = null; _trade = null; _lastTickTime = 0; _currentTickTime = 0; _watch.Restart(); _moveQueue.Clear(); }
public RequestTradeEvent RequestTrade(string name, int timeout = 30000) { _net.SendPacket(new RequestTradePacket { Name = name }); return(_request = new RequestTradeEvent { Name = name, Timeout = timeout }); }
private void OnTradeStart(TradeStartPacket tradeStart) { if (_request != null && tradeStart.PartnerName.Equals(_request.Name, StringComparison.CurrentCultureIgnoreCase)) { Log($"Trade accepted by {tradeStart.PartnerName}"); _request.OnAccept?.Invoke(_trade = new TradeEvent(this, tradeStart.ClientItems, tradeStart.PartnerItems)); _request = null; return; } // wtf _net.SendPacket(new CancelTradePacket()); }