public static void HandleGameMapMovementMessage(Bot bot, GameMapMovementMessage message) { if (bot.Character.Context == null) { logger.Error("Context is null as processing movement"); return; } var actor = bot.Character.Context.GetContextActor(message.actorId); if (actor == null) logger.Error("Actor {0} not found", message.actorId); // only a log for the moment until context are fully handled else { var path = Path.BuildFromServerCompressedPath(bot.Character.Map, message.keyMovements); if (path.IsEmpty()) { logger.Warn("Try to start moving with an empty path"); return; } var movement = new MovementBehavior(path, actor.GetAdaptedVelocity(path)); movement.Start(DateTime.Now + TimeSpan.FromMilliseconds(EstimatedMovementLag)); actor.NotifyStartMoving(movement); } }
private static void OnStartMoving(RolePlayActor actor, MovementBehavior movement) { if (!AllowComparer) return; var bot = BotManager.Instance.GetCurrentBot(); Task.Factory.StartNew( () => { var element = movement.TimedPath.GetCurrentElement(); bot.Character.HighlightCell(element.CurrentCell, Color.Green); while(!movement.IsEnded()) { var newElement = movement.TimedPath.GetCurrentElement(); if (element != newElement) { element = newElement; bot.Character.ResetCellsHighlight(); bot.Character.HighlightCell(element.CurrentCell, Color.Green); } Thread.Sleep(30); } }); }
public virtual bool NotifyStartMoving(Path path) { if (path.IsEmpty()) { logger.Warn("Try to start moving with an empty path"); return false; } Movement = new MovementBehavior(path, GetAdaptedVelocity(path)); Movement.Start(); return NotifyStartMoving(Movement); }
public virtual bool NotifyStartMoving(MovementBehavior movement) { Movement = movement; if (Movement.StartCell != Cell) { logger.Warn("Actor start cell incorrect for this moving path Position={0}, StartPath={1}, Path={2}", Cell, Movement.StartCell, String.Join<World.Cell>(",", Movement.MovementPath.Cells)); Cell = Movement.StartCell; } var handler = StartMoving; if (handler != null) handler(this, Movement); return true; }
public virtual bool NotifyStartMoving(MovementBehavior movement) { Movement = movement; if (Movement.StartCell != Position.Cell) { logger.Warn("Actor start cell incorrect for this moving path Position={0}, StartPath={1}", Position.Cell, Movement.StartCell); Position.Cell = Movement.StartCell; } var handler = StartMoving; if (handler != null) handler(this, Movement); return true; }
public static void HandleGameMapMovementMessage(Bot bot, GameMapMovementMessage message) { if (bot.Character == null || bot.Character.Context == null) { logger.Error("Context is null as processing movement"); return; } ContextActor actor = null; bool fightActor = false; if (bot.Character.IsFighting()) actor = bot.Character.Fight.GetActor(message.actorId); if (actor == null) actor = bot.Character.Context.GetActor(message.actorId); else fightActor = true; if (actor == null) { logger.Error("Actor {0} not found (known : {1})", message.actorId, String.Join(",", fightActor ? bot.Character.Fight.Actors : bot.Character.Context.Actors)); // only a log for the moment until context are fully handled return; } // just to update the position. If in fight, better update immediately to be sure that the next action take the mouvement into account if (message.keyMovements.Length == 1) { actor.UpdatePosition(message.keyMovements[0]); } else { Path path = Path.BuildFromServerCompressedPath(bot.Character.Map, message.keyMovements); if (path.IsEmpty()) { logger.Warn("Try to start moving with an empty path"); return; } var movement = new MovementBehavior(path, actor.GetAdaptedVelocity(path)); movement.Start(DateTime.Now + TimeSpan.FromMilliseconds(EstimatedMovementLag)); actor.NotifyStartMoving(movement); } }
private void StandUp(ContextActor sender, MovementBehavior path) { m_sit = false; m_bot.Character.StartMoving -= StandUp; }