public virtual void NotifyUseInteractive(InteractiveObject interactive, InteractiveSkill skill, int duration) { if (duration > 0) { UsingInteractive = interactive; UsingSkill = skill; UsageEndTime = DateTime.Now + TimeSpan.FromMilliseconds(duration); } UseInteractiveHandler handler = StartUsingInteractive; if (handler != null) handler(this, interactive, skill, UsageEndTime); }
public bool UseInteractiveObject(InteractiveSkill skill) { m_useAfterMove = null; if (!Map.Interactives.Contains(skill.Interactive) || !skill.IsEnabled()) return false; if (skill.Interactive.Cell != null && !skill.Interactive.Cell.IsAdjacentTo(Cell)) { var cell = skill.Interactive.Cell.GetAdjacentCells(x => Map.CanStopOnCell(x)). OrderBy(x => x.ManhattanDistanceTo(Cell)).FirstOrDefault(); if (cell == null) return false; if (Move(cell)) { m_useAfterMove = skill; return true; } } else { Bot.SendToServer(new InteractiveUseRequestMessage(skill.Interactive.Id, skill.Id)); return true; } return false; }
public override void NotifyStopMoving(bool canceled, bool refused) { base.NotifyStopMoving(canceled, refused); if (m_useAfterMove != null) { if (!canceled) { var skill = m_useAfterMove; Bot.AddMessage(() => UseInteractiveObject(skill)); // call next tick } m_useAfterMove = null; } if (_actionAfterMove != null) { Bot.AddMessage(_actionAfterMove); _actionAfterMove = null; } if (m_nextMap != null) { if (!canceled && !refused) { var id = m_nextMap.Value; m_previousMap = Map.Id; Bot.AddMessage(() => Bot.SendToServer(new ChangeMapMessage(id))); } m_nextMap = null; } }